简体   繁体   中英

Open source C++ library for vector mathematics

I would need some basic vector mathematics constructs in an application. Dot product, cross product. Finding the intersection of lines, that kind of stuff.

I can do this by myself (in fact, have already) but isn't there a "standard" to use so bugs and possible optimizations would not be on me?

Boost does not have it. Their mathematics part is about statistical functions, as far as I was able to see.

Addendum:

Boost 1.37 indeed seems to have this . They also gracefully introduce a number of other solutions at the field, and why they still went and did their own. I like that.

I've not tested it, but the C++ eigen library is becoming increasingly more popular these days. According to them, they are on par with the fastest libraries around there and their API looks quite neat to me.

Re-check that ol'good friend of C++ programmers called Boost . It has a linear algebra package that may well suits your needs.

Armadillo

Armadillo employs a delayed evaluation approach to combine several operations into one and reduce (or eliminate) the need for temporaries. Where applicable, the order of operations is optimised. Delayed evaluation and optimisation are achieved through recursive templates and template meta-programming.

While chained operations such as addition, subtraction and multiplication (matrix and element-wise) are the primary targets for speed-up opportunities, other operations, such as manipulation of submatrices, can also be optimised. Care was taken to maintain efficiency for both "small" and "big" matrices.

I would stay away from using NRC code for anything other than learning the concepts.

I think what you are looking for is Blitz++

Check www.netlib.org , which is maintained by Oak Ridge National Lab and the University of Tennessee. You can search for numerical packages there. There's also Numerical Recipes in C++ , which has code that goes with it, but the C++ version of the book is somewhat expensive and I've heard the code described as "terrible." The C and FORTRAN versions are free, and the associated code is quite good.

There is a nice Vector library for 3d graphics in the prophecy SDK:

Check out http://www.twilight3d.com/downloads.html

For linear algebra: try JAMA/TNT . That would cover dot products. (+matrix factoring and other stuff) As far as vector cross products (really valid only for 3D, otherwise I think you get into tensors), I'm not sure.

For an extremely lightweight (single .h file) library, check out CImg . It's geared towards image processing, but has no problem handling vectors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM