开发者

System of linear equations in C++? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I need to solve a system of linear equations in my program. I开发者_如何学Cs there a simple linear algebra library for C++, preferably comprised of no more than a few headers? I've been looking for nearly an hour, and all the ones I found require messing around with Linux, compiling DLLs in MinGW, etc. etc. etc. (I'm using Visual Studio 2008.)


I think Eigen is what you're looking for.

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

It is a headers only library and compiles on many compilers. It even uses exotic assembly for faster math.

This is the page that shows off the linear solver api.

http://eigen.tuxfamily.org/dox-2.0/TutorialAdvancedLinearAlgebra.html

It has a few solvers with a simple api.


Boost has some basic linear algebra stuff.


You can use the C++ bindings of LAPACK. A quick google turned up this link to some LAPACK for Windows libraries. Depending on the how big your systems are all this might be overkill though.


I am a big fan of Armadillo but your compiler may be an issue here according to the the end of the download page:

Windows

The development and testing of Armadillo has so far been done mainly on UNIX-like platforms, however there should be little or no platform specific code. While rudimentary tests were done on a Windows machine, the developers are interested in hearing how well Armadillo works in more thorough tests.

If you're having trouble with the 'MS Visual C++ 2008 Express Edition' compiler (due to its incomplete support for the C++ standard), you may want to try the following alternative free compilers:

  • Intel's C++ compiler
  • GCC (part of MinGW)
  • GCC (part of CygWin)

It is worth trying out as this is a well-designated (and mostly templated) library.

Otherwise, maybe try Eigen2 which lists your compiler as supported.

Edit: In response to the comment, Armadillo does not require Lapack but works better with it (and better still with tuned Blas):

Q: What other libraries do I need to make full use of Armadillo ?
A: Armadillo can work without external libraries. However it is recommended to install the LAPACK and ATLAS libraries in order to get added functionality. Armadillo will use ATLAS routines in lieu of LAPACK wherever possible.

Q: How well will Armadillo work without LAPACK/ATLAS ?
A: Basic functionality will be available (e.g. matrix addition and multiplication), but things like eigen decomposition will not be. Matrix multiplication (mainly for big matrices) will not be as fast.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜