犰狳点产品C++



我目前在 Ubuntu code::blocks 上,在尝试做线性代数时遇到了一些问题。

在编译器设置>搜索目录>编译器下,我有"/usr/include">

在编译器设置>搜索目录>链接器下,我有"/user/lib">

我的 Liblapack-dev、libblas-dev、libboost-dev、libarmadillo-dev 是通过 apt-get 安装的

评论了代码的哪一部分给了我错误。 没有代码的困难部分,我的代码运行良好,所以我认为我安装犰狳很好? 那么为什么我无法访问它的所有功能呢?

#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
}

代码中存在错误。您正在使用e*r但它们都是 2x1,因此您需要将e转置为 e.t()*r,以便获得 1x1 产品。您在下面三行也遇到了相同的问题。如果您使用apt-get安装了犰狳,则通常不需要添加blas/lapack库。对链接器使用 -larmadillo 标志就足够了。

相关内容

  • 没有找到相关文章

最新更新