Boost :: uBLAS vs本征 [英] Boost::uBLAS vs Eigen

查看:150
本文介绍了Boost :: uBLAS vs本征的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几乎所有的数学线性代数工作都习惯于本征. 最近,我发现Boost还提供了一个C ++模板类库,该库提供了基本线性代数库(解决方案

我正在将一个大型项目从boost :: uBLAS重写到Eigen.这是商业环境中的生产代码.我是2006年选择uBLAS的人,现在建议将其更改为Eigen.

uBLAS导致编译器执行的实际矢量化非常少.我可以使用浮点类型查看使用SSE编译为amd64架构的大型源文件的汇编输出,而找不到单个*** ps指令(addps,mulps,subps,4路打包单精度浮点)指令)和仅*** ss指令(加法,...,标量单精度).

使用Eigen编写库,以确保产生矢量指令.

本征非常完整.有很多矩阵分解和求解器.在boost :: uBLAS中,LU因式分解是一个未记录的附件,是一段有用的代码. Eigen为3D几何添加了附加功能,例如旋转和四元数,而不是uBLAS.

在最基本的操作上,uBLAS更为完整.本征缺少某些东西,例如投影(使用另一个矩阵索引一个矩阵),而uBLAS却拥有它.对于这两种功能,Eigen更为简洁,使表达式更易于阅读.

然后,uBLAS完全过时了.我不明白有人在2016/2017年如何看待它.阅读常见问题解答:

问:我应该在新项目中使用uBLAS吗? 答:在撰写本文时(09/2012),有很多好的矩阵库可供使用,例如MTL4,犰狳,本征. uBLAS提供一组稳定且经过良好测试的向量和矩阵类,线性代数的典型运算以及三角方程组的求解器. uBLAS提供密集,结构化和稀疏的矩阵-所有这些都使用相似的接口.最后,uBLAS提供了良好(但不是出色)的性能.另一方面,uBLAS的上一次重大改进是在2008年,自2009年以来未进行任何重大更改.因此,应该问自己一些问题以帮助做出决定:可用性? uBLAS是增强技术的一部分,因此可在许多环境中使用.便于使用? uBLAS易于用于简单的事情,但是当您离开这条路时,需要一定的C ++知识.表现?有更快的选择.前沿? uBLAS已有10多年的历史了,错过了C ++ 11的所有新功能.

I am used to Eigen for almost all my mathematical linear algebra work. Recently, I have discovered that Boost also provides a C++ template class library that provides Basic Linear Algebra Library (Boost::uBLAS). This got me wondering if I can get all my work based only on boost as it is already a major library for my code.

A closer look at both didn't really got me a clearer distinction between them:

  • Boost::uBLAS :

uBLAS provides templated C++ classes for dense, unit and sparse vectors, dense, identity, triangular, banded, symmetric, hermitian and sparse matrices. Views into vectors and matrices can be constructed via ranges, slices, adaptor classes and indirect arrays. The library covers the usual basic linear algebra operations on vectors and matrices: reductions like different norms, addition and subtraction of vectors and matrices and multiplication with a scalar, inner and outer products of vectors, matrix vector and matrix matrix products and triangular solver.

...

  • Eigen :

It supports all matrix sizes, from small fixed-size matrices to arbitrarily large dense matrices, and even sparse matrices.

It supports all standard numeric types, including std::complex, integers, and is easily extensible to custom numeric types.

It supports various matrix decompositions and geometry features.

Its ecosystem of unsupported modules provides many specialized features such as non-linear optimization, matrix functions, a polynomial solver, FFT, and much more.

...

Does anyone have a better idea about their key differences and on which basis can we choose between them?

解决方案

I'm rewriting a substantial project from boost::uBLAS to Eigen. This is production code in a commercial environment. I was the one who chose uBLAS back in 2006 and now recommended the change to Eigen.

uBLAS results in very little actual vectorization performed by the compiler. I can look at the assembly output of big source files, compiled to amd64 architecture, with SSE, using the float type, and not find a single ***ps instruction (addps, mulps, subps, 4 way packed single-precision floating point instructions) and only ***ss instructions (addss, ..., scalar single-precision).

With Eigen, the library is written to make sure that vector instructions result.

Eigen is very feature complete. Has lots of matrix factorizations and solvers. In boost::uBLAS the LU factorization is an undocumented add-on, a piece of contributed code. Eigen has additions for 3D geometry, such as rotations and quaternions, not uBLAS.

uBLAS is slightly more complete on the most basic operations. Eigen lacks some things, such as projection (indexing a matrix using another matrix), while uBLAS has it. For features that both have, Eigen is more terse, resulting in expressions that are easier to read.

Then, uBLAS is completely stale. I can't understand how anyone considers it in 2016/2017. Read the FAQ:

Q: Should I use uBLAS for new projects? A: At the time of writing (09/2012) there are a lot of good matrix libraries available, e.g., MTL4, armadillo, eigen. uBLAS offers a stable, well tested set of vector and matrix classes, the typical operations for linear algebra and solvers for triangular systems of equations. uBLAS offers dense, structured and sparse matrices - all using similar interfaces. And finally uBLAS offers good (but not outstanding) performance. On the other side, the last major improvement of uBLAS was in 2008 and no significant change was committed since 2009. So one should ask himself some questions to aid the decision: Availability? uBLAS is part of boost and thus available in many environments. Easy to use? uBLAS is easy to use for simple things, but needs decent C++ knowledge when you leave the path. Performance? There are faster alternatives. Cutting edge? uBLAS is more than 10 years old and missed all new stuff from C++11.

这篇关于Boost :: uBLAS vs本征的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆