首页 > 其他分享 >Eigen

Eigen

时间:2023-11-02 13:07:11浏览次数:39  
标签:files Eigen program include my eigen

 

http://eigen.tuxfamily.org/index.php?title=Main_Page

 

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.

 

wget http://bitbucket.org/eigen/eigen/get/3.3.7.tar.bz2

tar -jxvf 3.3.7.tar.bz2

How to "install" Eigen?

In order to use Eigen, you just need to download and extract Eigen's source code (see the wiki for download instructions). In fact, the header files in the Eigen subdirectory are the only files required to compile programs using Eigen. The header files are the same for all platforms. It is not necessary to use CMake or install anything.

A simple first program

Here is a rather simple program to get you started.

#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
std::cout << m << std::endl;
}

We will explain the program after telling you how to compile it.

Compiling and running your first program

There is no library to link to. The only thing that you need to keep in mind when compiling the above program is that the compiler must be able to find the Eigen header files. The directory in which you placed Eigen's source code must be in the include path. With GCC you use the -I option to achieve this, so you can compile the program with a command like this:

g++ -I /path/to/eigen/ my_program.cpp -o my_program

On Linux or Mac OS X, another option is to symlink or copy the Eigen folder into /usr/local/include/. This way, you can compile the program with:

g++ my_program.cpp -o my_program

When you run the program, it produces the following output:

3 -1

2.5 1.5


 



标签:files,Eigen,program,include,my,eigen
From: https://blog.51cto.com/emanlee/8143855

相关文章

  • [转]By not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH this project has
    在编译安装的时候出现如下问题,是Eigen3的Cmake依赖问题,已经安装eigen3,但在项目的find_package(Eigen3QUERIED)中,无法找到FindEigen3.Cmake. CMakeErroratloam_velodyne/CMakeLists.txt:13(find_package):Bynotproviding"FindEigen3.cmake"inCMAKE_MODULE_......
  • Ubuntu18.04 安装Opencv3.4.15、PCL1.8.1、VTK7.1.0、Eigen3.4、Pangolin0.6、Sophus
    Eigen3.4安装方法mkdirbuild&&cdbuildcmake..sudomakeinstall安装后头文件安装在/usr/local/include/eigen3/,可以打开看一看安装的库Pangolin0.6安装方法+安装依赖项目sudoapt-getinstalllibglew-devsudoapt-getinstalllibboost-devli......
  • Eigen库操作
    #include<iostream>#include<eigen3/Eigen/Dense>usingnamespacestd;usingnamespaceEigen;intmain(){Matrix2fss;ss<<2.3f,3.2f,3.4f,3.1f;cout<<ss<<endl;cout<<"======="<<endl;......
  • Eigen::Tensor实现permute方法
    需求使用C++处理Eigen::Tensor希望交换指定维度的位置注意是交换(改变内存顺序)而不是reshape实现torch.tensor中内置了permute方法实现快速交换Eigen::Tensor中实现相同操作需要一点技巧例如,将一个1x2x3的tensor排列为3x1x2那么对应t1[0,1,1]==t2[1,0,1]则排列生效代码如......
  • eigen库稀疏矩阵
    使用Eigen的稀疏矩阵库可以有效地处理具有大量零元素的矩阵,以节省内存和计算资源。eigen库稀疏矩阵:SparseMatrix<double>Hsta=SparseMatrix<double>(4,4);//定义一个大小为4*4名字为Hsta的稀疏矩阵。插入数据 Hsta.insert(0,0)=1;//向Hsta的1行1列插入数字1。......
  • 安装eigen
    1安装eigensudoapt-getinstallgdb查看版本pkg-config--modversioneigen33.4.0查看安装的路径dpkg-Llibeigen3-dev/./usr/usr/include/usr/include/eigen3/usr/include/eigen3/Eigen/usr/include/eigen3/Eigen/Cholesky/usr/include/eigen3/Eigen/Cholmod......
  • Eigensequence UVA - 11133
    给你一个递增序列的第一位a1,最后一位an,求有多少个序列满足:以a1为首,an为尾 1、B(1)=A(1)2、后面每项满足A[j]=B[j], A(j-1)<B(j)≤A(j),且bj能整除A(j)-A(j-1)。   F[i][j]最后一位为j的方案数#include<iostream>#include<cstring>#include<a......
  • Eigen Faces
    处理图像一张\((H,W)\)大小的图像可以按像素点展开为\((1,HW)\)大小数组.我们将训练集中所有图像展开到一个\((N,HW)\)大小的数组中;然后求一个\((1,HW)\)大小的平均脸参考代码:#Supposeimgsisa(N,W,H)nparrayimg2D=imgs.reshape(imgs.shape[0],-1)......
  • cmake使用eigen库
    Eigen是一个C++开源线性代数库:提供矩阵的线性代数运算。注:Eigen是一个只有头文件的库cmake使用eigen库find_package(Eigen3)INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR})程序中使用eigen库,引用各功能头文件#include<Eigen/core> ......
  • Ubuntu安装eigen3
    Eigen是C++语言里的一个开源模版库,支持线性代数运算,矩阵和矢量运算,数值分析及其相关的算法。下载源码https://github.com/eigenteam/eigen-git-mirror编译安装mkdirbuildcdbuildcmake..make-j24sudomakeinstall编译之后只会产生头文件,头文件就有so的功能,但是......