Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

How to use bindings ?

Help
Pierre
2007-03-10
2013-05-14
  • Pierre
    Pierre
    2007-03-10

    Hi all,

    I must resolve a Least Square problem with a SVD(singular value decomposition).

    I have no problem to create my matrix with UBLAS.

    I have add all bindings (blas and lapack), and I don't understand if I need to install Lapack and how to compile lapack for my windows environnement.

    I try this but I have a link error :

    #include <boost/numeric/ublas/vector.hpp>
    #include <boost/numeric/ublas/matrix.hpp>
    #include <boost/numeric/ublas/io.hpp>
    #include <boost/numeric/bindings/atlas/clapack.hpp>

    #include <boost/numeric/bindings/lapack/gesv.hpp>
    #include <boost/numeric/bindings/traits/ublas_matrix.hpp>

    #include <iostream>

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

    int main(int argc, char** argv)
    {
        // system matrix A:
        ublas::matrix<double, ublas::column_major> A(3,3); 
        A(0,0) = 1.; A(0,1) = 1.; A(0,2) = 1.;
        A(1,0) = 2.; A(1,1) = 3.; A(1,2) = 1.;
        A(2,0) = 1.; A(2,1) = -1.; A(2,2) = -1.;
        std::cout << "A: " << A << std::endl;

        // right-hand side matrix B:
        ublas::matrix<double, ublas::column_major> B(3,1); 
        B(0,0) = 4.; B(1,0) = 9.; B(2,0) = -2.;
        std::cout << "B: " << B << std::endl;

        // solve system:
        boost::numeric::bindings::atlas::gesv(A, B);
        // B now contains solution:
        std::cout << "X: " << B << std::endl;

        //The expected result :
        /* A: [3,3]((1,1,1),(2,3,1),(1,-1,-1))
      B: [3,1]((4),(9),(-2))
      X: [3,1]((1),(2),(1))*/

        int a=0;
        std::cin>>a;
    }

    Can you help me ?

    Just explain me how to do to have a correct bindings....

    Thanks for all ;)
    Pierre