Boost logo

Ublas :

Subject: [ublas] Compiling With Boost’s UBlas Numeric Binding Library to Solve Ax=b Linear System
From: Peverall Dubois (gundalav_at_[hidden])
Date: 2009-08-05 23:35:57

I am using Numeric Library Bindings for Boost UBlas to solve a simple
linear system:

#include <boost/numeric/bindings/traits/ublas_vector2.hpp>

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

int main()
    ublas::matrix<float,ublas::column_major> A(3,3);
    ublas::vector<float> b(3);

    for(unsigned i=0;i < A.size1();i++)
        for(unsigned j =0;j < A.size2();j++)
            std::cout << "enter element "<<i << j << std::endl;
            std::cin >> A(i,j);

    std::cout << A << std::endl;

    b(0) = 21; b(1) = 1; b(2) = 17;


    std::cout << b << std::endl;

    return 0;

I tried compiling it with the following command:
g++ -I/home/foolb/.boost/include/boost-1_38
-I/home/foolb/.boostnumbind/include/boost-numeric-bindings -o solve_Axb_byhand

but fail with the following error:

media/disk/tmp/ccbd973l.o: In function
`boost::numeric::bindings::lapack::detail::gesv(int, int, float*, int,
int*, float*, int, int*)':[boost::numeric::bindings::lapack::detail::gesv(int,
int, float*, int, int*, float*, int, int*)]+0x59): undefined reference
to `sgesv_'
collect2: ld returned 1 exit status

What's wrong with my approach?

- G.V