Boost's Linear Algebra Solution for y=Ax

2019-02-03 12:36发布

Does boost have one? Where A, y and x is a matrix (sparse and can be very large) and vectors respectively. Either y or x can be unknown.

I can't seem to find it here: http://www.boost.org/doc/libs/1_39_0/libs/numeric/ublas/doc/index.htm

6条回答
Root(大扎)
2楼-- · 2019-02-03 13:15

Linear solvers are generally part of the LAPACK library which is a higher level extension of the BLAS library. If you are on Linux, the Intel MKL has some good solvers, optimized both for dense and sparse matrices. If you are on windows, MKL has a one month trial for free... and to be honest I haven't tried any of the other ones out there. I know the Atlas package has a free LAPACK implementation but not sure how hard it is to get running on windows.

Anyways, search around for a LAPACK library which works on your system.

查看更多
做个烂人
3楼-- · 2019-02-03 13:19

Boost's linear algebra package's tuning focused on "dense matrices". As far as I know, Boost's package do not have any linear-system-solver. How about use source code in "Numerical Recipe in C (http://www.nr.com/oldverswitcher.html)" ?

Note. There can be subtle index bug in the source code (some code uses array index start from 1)

查看更多
劳资没心,怎么记你
4楼-- · 2019-02-03 13:20

Reading the boost documentation, it does not seem like solving w.r.t x is implemented. Solving in y is only a matter of matrix-vector product, which seems implemented in ublas.

One thing to keep in mind is that blas only implement 'easy' operations like addition, multiplication, etc... of vector and matrix types. Anything more advanced (linear problem solving, like your "solve in x y = A x", eigen vectors and co) is part of LAPACK, which built on top of BLAS. I don't know what boost provides in that respect.

查看更多
劫难
5楼-- · 2019-02-03 13:26

One of the best solvers for Ax = b, when A is sparse, is Tim Davis's UMFPACK

UMFPACK computes a sparse LU decomposition of A. It is the algorithm that gets used behind the scenes in Matlab when you type x=A\b (and A is sparse and square). UMFPACK is free software (GPL)

Also note if y=Ax, and x is known, but y is not, you compute y by performing a sparse matrix vector multiply, not by solving a linear system.

查看更多
女痞
6楼-- · 2019-02-03 13:36

yes, you can solve linear equations with boost's ublas library. Here is one short way using LU-factorize and back-substituting to get the inverse:

using namespace boost::ublas;

Ainv = identity_matrix<float>(A.size1());
permutation_matrix<size_t> pm(A.size1());
lu_factorize(A,pm)
lu_substitute(A, pm, Ainv);

So to solve a linear system Ax=y, you would solve the equation trans(A)Ax=trans(A)y by taking the inverse of (trans(A)A)^-1 to get x: x = (trans(A)A)^-1Ay.

查看更多
forever°为你锁心
7楼-- · 2019-02-03 13:36

Take a look at JAMA/TNT. I've only used it for non-sparse matrices (you probably want the QR or LU factorizations, both of which have solver utility methods), but it apparently has some facilities for sparse matrices.

查看更多
登录 后发表回答