Boost logo

Ublas :

From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2006-10-05 05:51:20


Hi!

It seems that all bindings only work for dense matrices.
But maybe I obverlooked something, so please tell me if it is easy to get
code similar to the one below compiled with a few changes ...

regards, Markus

#include <boost/numeric/bindings/traits/ublas_matrix.hpp>
#include <boost/numeric/bindings/traits/std_vector.hpp>
#include <boost/numeric/bindings/lapack/gesvd.hpp>
#include <boost/numeric/bindings/lapack/gesdd.hpp>

#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/bindings/traits/sparse_traits.hpp>
#include <boost/numeric/ublas/triangular.hpp>
// #include <boost/numeric/ublas/lu.hpp>
#include <boost/numeric/ublas/io.hpp>

#include <iostream>

namespace ublas = boost::numeric::ublas;
namespace lapack = boost::numeric::bindings::lapack;

int main()
{
        typedef ublas::coordinate_matrix<double, ublas::column_major> matrix_t;
        
        matrix_t H (3, 3, 9);
        
        H(0,0) = 1.00000; H(0,1) = 0.50000; H(0,2) = 0.33333;
        H(1,0) = 0.50000; H(1,1) = 0.33333; H(1,2) = 0.25000;
        H(2,0) = 0.33333; H(2,1) = 0.25000; H(2,2) = 0.20000;

        matrix_t U (3, 3, 9);
        ublas::vector<double> s (3);
        matrix_t VT (3, 3, 9);

         lapack::gesvd('A', 'A', H, s, U, VT);

        // divide and conquer
        //lapack::gesdd(H, s, U, VT);

        std::cout << U << std::endl;
        std::cout << s << std::endl;
        std::cout << ublas::trans(VT) << std::endl;

        return 0;
}