您的位置:首页 > 其它

Eigen 矩阵运算库在实际项目中的使用

2016-08-28 14:03 369 查看
Eigen 矩阵运算库在实际项目中的使用情况如何?

心血来潮,试了试纯模板技术写的 Eigen 并作了简单的性能测试,三个 1000 阶的方阵连乘运算 Eigen 比 MATLAB 快了一倍,比 OpenCV 快了 2 倍,但是这个库在实际项目中的稳定性和速度如何我还不大清楚,故有此问。

另外,目前流行的 C++ 数值计算库很多都使用了 expression template 技术来抑制临时对象的生成,极大提高了运算性能,但对于同样使用这个技术的不同的库,速度却相差很大,例如 Armadillo,虽然它的底层采用了 BLAS 和 LAPACK,但在上述运算中比 Eigen 慢了整整 4 倍。产生这种现象的原因是什么?

1 条评论 分享

默认排序

按时间排序

8 个回答

7

赞同反对,不会显示你的姓名

白菜哈哈哈

7 人赞同

总体来说还是Armadillo快些,需要自己设置一下,方法的网上有教程。

下面是Eigen的项目:

Projects using Eigen

Extensions, numerical computation and bindings

Google's Ceres solver is a portable C++ library that allows for modeling and solving large complicated nonlinear least squares problems.

The Manifold ToolKit MTK provides easy mechanisms to enable arbitrary algorithms to operate on manifolds. It also provides a Sparse Least Squares Solver (SLoM) and an Unscented Kalman Filter (UKFoM).

minieigen is small boost::python wrapper for Eigen's core classes (dense fixed and dynamic-sized vectors, matrices, aligned boxes, quaternions; with integer, floating and complex scalars) including operators and subset of Eigen's API methods.

redsvd is a RandomizED Singular Value Decomposition library for sparse or very large dense matrices.

The RcppEigen package provides bindings and more for R.

trustOptim is a trust-region based non linear solver supporting sparse Hessians (C++ implementation with R binding).

sparray: a python binding of the Sparse module - alpha stage.

Shogun: a large scale machine learning toolbox.

Stan: a statistical package based on Eigen that includes a reverse-mode automatic differentiation implementation.

jeigen, a Java wrapper for Eigen.

Science

The Large Survey Synoptic Telescope (website; trac) is a project to build a 3.2Mpixel camera on an 8.4m telescope and survey the entire visible sky every three days.

Gnu Data Language, a GPL interpretor of IDL syntax codes.

The Space Trajectory Analysis project at the European Space Agency. They even have an announcement on using Eigen.

Avogadro, an opensource advanced molecular editor.

The 3D astronomical visualization application Celestia is now using Eigen for all orbital and geometric calculation.

Yade, platform for dynamic particle models, uses Eigen for geometric computations (switched from the WildMagic package)

SLangTNG, an application suite for numerical analysis, linear algebra, advanced statistics, FEM, structural dynamics, data visualization, etc.

Clip, an opensource program for the orientation of Laue exposures.

Multiprecision Computing Toolbox for MATLAB uses Eigen as core library for matrix computations.

Pteros, a C++ library for molecular modeling.

Cufflinks, a tool for transcript assembly, differential expression, and differential regulation for RNA-Sequences.

Vortexje: a GPL library for simulation implementing the source-doublet panel method.

Woo(dem), particle dynamics software (DEM, FEM); Eigen wrapped using minieigen in Python.

Robotics and engineering

The Yujin Robot company uses Eigen for the navigation and arm control of their next gen robots. (switched from blitz, ublas and tvmet)

The Robotic Operating System (ROS) developed by Willow Garage.

openAHRS Open Source IMU / AHRS

The Darmstadt Dribblers autonomous Humanoid Robot Soccer Team and Darmstadt Rescue Robot Team use Eigen for navigation and world modeling.

The Mobile Robot Programming Toolkit (MRPT), a set of libraries for SLAM, localization and computer vision, moved to Eigen (blogannouncement) (switched from home made math classes).

RBDL: a C++ library for rigid body dynamics.

RL a self-contained C++ library for robot kinematics, motion planning and control.

BTK is a Biomechanical ToolKit, licensed under BSD whose primary goal is to propose a set of tools for the analysis of the human body motion which is independent of any acquisition system. It proposes bindings for Matlab/Octave and Python, and a GUI software
called Mokka to visualize/analyze 3D/2D motion capture data.

libpointmatcher is a "Iterative Closest Point" library for 3D mapping in robotics.

Computer Graphics

Computational Geometry Algorithms Library (CGAL), a collaborative effort to develop a robust, easy to use, and efficient C++ software library of geometric data structures and algorithms.

Point Cloud Library (PCL), a large scale, BSD licensed, open project for point cloud processing. Uses Eigen as their math backend.

VcgLib, an opensource C++ template library for the manipulation and processing of triangle and tetrahedral meshes. (switched from home made math classes)

MeshLab, an opensource software for the processing and editing of unstructured 3D triangular meshes and point cloud. (switched from vcglib's math classes)

Expe, an experimental framework for the rapid prototyping of graphics applications. No release yet, but it uses 90% of Eigen's features. (switched from home made math classes).

libmv, an opensource structure from motion library. (switched from FLENS)

openMVG a simple library for multiple view geometry.

Google

Google uses Eigen for machine learning, computer vision, and optimization.

In particular, see the mention of Ceres above.

Mobile apps

Layar, an augmented reality appplication for IPhone and Android.

Red Sword Studios, maker of the iPhone games Gradient, Fortress Luna, Stimulus, and Lustre, uses Eigen extensively. Why roll your own matrix/vector/transformation code when there's Eigen?

iPerfectPutt, an iPhone game, uses Eigen for 3D geometry calculations.

KDE (our origins!)

Step, an educational physics simulator.

Koffice2 (KDE's office suite), in particular Krita, the painting and image editing module. Eigen is also used a bit by KSpread, the spreadsheet module, for matrix functions such as MINVERSE, MMULT, MDETERM.

Kalzium uses Eigen indirectly through the aforementioned Avogadro library.

the Mandelbrot wallpaper plugin, some screensavers, kgllib, solidkreator, etc.

Others

WhirlyGlobe a 3D globe component.

编辑于 2014-02-15 添加评论 感谢 分享 收藏 • 没有帮助 • 举报 • 作者保留权利 收起

2

赞同反对,不会显示你的姓名

jiahui zhu

2 人赞同

同志,你确定纯用Eigen比MATLAB会快?我想知道你是怎么设置的?

我用Eigen+Intel MKL在Release x64模式下也只是跟MATLAB运算速度差不多而已

Visual Studio下实现Eigen+Intel MKL的矩阵乘法

发布于 2016-01-14 1 条评论 感谢 分享 收藏 • 没有帮助 • 举报 • 作者保留权利

1

赞同反对,不会显示你的姓名

知乎用户数学虐我千百遍,我待数学如初恋;不学c+…

1 人赞同

我依稀记得OpenCV底层支持Eigen,OpenCV在机器视觉领域是王者之一,Eigen的影响力可见一斑。我在自己的项目大量使用Eigen来做数值计算,我觉得Eigen就是方便好用,速度瓶颈主要在算法而不是底层库。

发布于 2015-11-04 添加评论 感谢 分享 收藏 • 没有帮助 • 举报 • 作者保留权利

2

赞同反对,不会显示你的姓名

武锐

2 人赞同

显然openblas比matlab的mkl快。要速度的话,GPU加速吧,至少快5倍。

发布于 2015-05-29 添加评论 感谢 分享 收藏 • 没有帮助 • 举报 • 作者保留权利

1

赞同反对,不会显示你的姓名

Steve Shi

1 人赞同

Benchmark - Eigen

图中可以看到Eigen和主流的MKL不相上下,实际使用中也有类似的体验。值得注意的是Eigen的稀疏矩阵处理非常优秀,Armadillo之流无法与之相比。

查看Libmesh才发现,其中也用到了Eigen,在Eigen页面里没有提到。

LZ提到比Armadillo快了4倍,我觉得是可能的,Armadillo只是个和matlab长得像的壳子,具体计算还是调用Blas库来进行运算的,在优化层次上比不上Eigen

发布于 2016-02-24 添加评论 感谢 分享 收藏 • 没有帮助 • 举报 • 作者保留权利

1

赞同反对,不会显示你的姓名

少先队员团结紧张严肃活泼

1 人赞同

如果代码基本一样,eigen比arm快,看看底层是具体用的哪个库做运算,还有编译选项也很重要,template在-o2和-o0上会完全是两个速度

发布于 2015-07-18 1 条评论 感谢 分享 收藏 • 没有帮助 • 举报 • 作者保留权利

1

赞同反对,不会显示你的姓名

慕容泊IT

1 人赞同

Armadillo+Openblas的组合更快,而且Armadillo的函数更接近Matlab

发布于 2015-05-06 添加评论 感谢 分享 收藏 • 没有帮助 • 举报 • 作者保留权利

0

赞同反对,不会显示你的姓名

贾文其

有没有遇到过这种情况,在用eigen库的时候用比较大的维数矩阵运算的时候

,会出现这样的错误

发布于 2015-05-06 2 条评论 感谢 分享 收藏 • 没有帮助 • 举报 • 作者保留权利
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: