Best C++ Matrix Library for sparse unitary matrices

◇◆丶佛笑我妖孽 提交于 2019-11-26 20:28:50

问题


I am looking for a good (in the best case actively maintained) C++ matrix library. Thereby it should be templated, because I want to use a complex of rationals as numerical type. The matrices what I am dealing with are mainly sparse and unitary.

Can you please suggest libraries and also give a small explaination why to use them, because I know how to find them, but I cannot really decide what is suitable for me because I am missing the experience with them.

EDIT:

The main operations I am dealing with are matrix multiplication, scalar multiplication with a vector and kronecker product. The size of the matrices is exponential and I wanna at least be able to deal with matrices up to 1024x1024 entries.


回答1:


Many people doing "serious" matrix stuff, rely on BLAS, adding LAPACK / ATLAS (normal matrices) or UMFPACK (sparse matrices) for more advanced math. The reason is that this code is well-tested, stable, reliable, and quite fast. Furthermore, you can buy them directly from a vendor (e.g. Intel MKL) tuned towards your architecture, but also get them for free. uBLAS mentioned in Manuel's answer is probably the standard C++ BLAS implementation. And if you need something like LAPACK later on, there are bindings to do so.

However, none of these standard libraries (BLAS / LAPACK / ATLAS or uBLAS + bindings + LAPACK / ATLAS) ticks your box for being templated and easy to use (unless uBLAS is all you'll ever need). Actually, I must admit, that I tend to call the C / Fortran interface directly when I use a BLAS / LAPACK implementation, since I often don't see much additional advantage in the uBLAS + bindings combination.

If I a need a simple-to-use, general-purpose C++ matrix library, I tend to use Eigen (I used to use NewMat in the past). Advantages:

  • quite fast on Intel architecture, probably the fastest for smaller matrices
  • nice interface
  • almost everything you expect from a matrix library
  • you can easily add new types

Disadvantages (IMO):

  • single-processor [Edit: partly fixed in Eigen 3.0]
  • slower for larger matrices and some advanced math than ATLAS or Intel MKL (e.g. LU decomposition) [Edit: also improved in Eigen 3.0]
  • only experimental support for sparse matrices [Edit: improved in upcoming version 3.1].

Edit: The upcoming Eigen 3.1 allows some functions to use the Intel MKL (or any other BLAS / LAPACK implementation).




回答2:


Boost uBLAS, because it's passed the Boost filter.

There are a few template libs that support sparse matrices, so it's really hard to come up with a better rationale if you're not more specific about your needs.




回答3:


You should also try MLT and HASEM Matrix C++ Library. The last one is very well documented.



来源:https://stackoverflow.com/questions/2222549/best-c-matrix-library-for-sparse-unitary-matrices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!