I am currently on Ubuntu code::blocks and run into a few problems when trying to do linear algebra.
under compiler settings>search directories>compiler i have "/usr/include"
and under compiler settings>search directories>linker i have "/user/lib"
my liblapack-dev, libblas-dev, libboost-dev, libarmadillo-dev are installed via apt-get
i commented which part of the code give me error. without the difficult part of the code my code runs fine, so i think i have armadillo installed fine? so why cant i access all its functions?
#include <iostream>
#include <armadillo>
using namespace arma;
using namespace std;
int main()
{
mat A;
A<<1<<2<<endr<<3<<4;
cout<<A;
vec e=A.col(0);
vec r=A.col(1);
cout<<endl<<e<<endl<<r<<endl;//works perfectly up to here
//if only there was not more of these codes
cout<<e*r<<endl;//doesnt work from here anymore
float y=dot(A,A);//from here on i get the error message:
cout<<y<<endl;//'wrapper_ddot_' is not defined
double z=as_scalar(e*r);//and wrapper_blas.hpp file opens
double t=dot(e,r);
cout<<z<<endl;//and points me to line 185
return 0;//with an error
}
There is a bug in the code. You are using e*r
but they are both 2x1 so you need to transpose e
as e.t()*r
so you get a 1x1 product. You also have the same problem three rows below. If you installed Armadillo using apt-get
there is normally no need to add the blas/lapack libs. It should be sufficient to use the -larmadillo
flag to the linker.