简体   繁体   English

用于矢量数学的开源C ++库

[英]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. Boost没有它。 Their mathematics part is about statistical functions, as far as I was able to see. 就我所见,他们的数学部分是关于统计函数的。

Addendum: 附录:

Boost 1.37 indeed seems to have this . 提升1.37确实似乎有这个 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. 我没有测试它,但是C ++ 特征库现在变得越来越流行。 According to them, they are on par with the fastest libraries around there and their API looks quite neat to me. 据他们说,他们与那里最快的库相当,他们的API看起来非常整洁。

Re-check that ol'good friend of C++ programmers called Boost . 重新检查C ++程序员的ol'good朋友叫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. 除了学习概念之外,我不会使用NRC代码。

I think what you are looking for is Blitz++ 我认为你要找的是Blitz ++

Check www.netlib.org , which is maintained by Oak Ridge National Lab and the University of Tennessee. 查看由Oak Ridge国家实验室和田纳西大学维护的www.netlib.org 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." 还有C ++中的Numerical Recipes ,其代码与之相关,但本书的C ++版本有些昂贵,而且我听说这些代码被描述为“可怕”。 The C and FORTRAN versions are free, and the associated code is quite good. C和FORTRAN版本是免费的,相关的代码非常好。

There is a nice Vector library for 3d graphics in the prophecy SDK: 预言SDK中有一个很好的3D图形矢量库:

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

For linear algebra: try JAMA/TNT . 对于线性代数:尝试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. (+矩阵保理和其他东西)就矢量交叉产品而言(实际上只对3D有效,否则我认为你进入张量),我不确定。

For an extremely lightweight (single .h file) library, check out CImg . 对于非常轻量级(单个.h文件)库,请查看CImg It's geared towards image processing, but has no problem handling vectors. 它适用于图像处理,但处理矢量没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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