Boost logo

Boost Users :

Subject: [Boost-users] 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:

__BEGIN__
#include<boost/numeric/ublas/matrix.hpp>
#include<boost/numeric/ublas/io.hpp>
#include<boost/numeric/bindings/traits/ublas_matrix.hpp>
#include<boost/numeric/bindings/lapack/gesv.hpp>
#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;

    lapack::gesv(A,b);

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

    return 0;
}
__END__

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
solve_Axb_byhand.cc -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*)':
solve_Axb_byhand2.cc:(.text._ZN5boost7numeric8bindings6lapack6detail4gesvEiiPfiPiS4_iS5_[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
__END__

What's wrong with my approach?

- G.V


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net