C++ 的 NumPy 样式数组? [英] NumPy style arrays for C++?

查看:48
本文介绍了C++ 的 NumPy 样式数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何具有类似 NumPy 的数组的 C++(或 C)库支持切片、向量化操作、逐个元素添加和减去内容等?

Are there any C++ (or C) libs that have NumPy-like arrays with support for slicing, vectorized operations, adding and subtracting contents element-by-element, etc.?

推荐答案

这里有几个可能适合您需求的免费软件.

Here are several free software that may suit your needs.

  1. GNU 科学图书馆是用 C 语言编写的 GPL 软件.因此,它具有类似 C 的分配和编程方式(指针等).使用 GSLwrap,您可以使用 C++ 编程方式,同时仍然使用 GSL.GSL 有一个 BLAS 实现,但您可以使用 ATLAS 而不是默认的 CBLAS,如果你想要更多的表演.

  1. The GNU Scientific Library is a GPL software written in C. Thus, it has a C-like allocation and way of programming (pointers, etc.). With the GSLwrap, you can have a C++ way of programming, while still using the GSL. GSL has a BLAS implementation, but you can use ATLAS instead of the default CBLAS, if you want even more performances.

boost/uBLAS 库是一个 BSL 库,用 C++ 编写并作为 boost 包分发.它是实现 BLAS 标准的 C++ 方式.uBLAS 带有一些线性代数函数,并且有一个 实验绑定到图集.

The boost/uBLAS library is a BSL library, written in C++ and distributed as a boost package. It is a C++-way of implementing the BLAS standard. uBLAS comes with a few linear algebra functions, and there is an experimental binding to ATLAS.

eigen 是一个用 C++ 编写的线性代数库,在 MPL2 许可下分发(从版本 3.1.1) 或 LGPL3/GPL2(旧版本).这是一种 C++ 编程方式,但比其他两种方式更加集成(可用的算法和数据结构更多).Eigen 声称比上面的 BLAS 实现更快, 而不是遵循事实上的标准 BLAS API.Eigen 似乎并没有在并行实现上投入太多精力.

eigen is a linear algebra library written in C++, distributed under the MPL2 license (starting from version 3.1.1) or LGPL3/GPL2 (older versions). It's a C++ way of programming, but more integrated than the two others (more algorithms and data structures are available). Eigen claims to be faster than the BLAS implementations above, while not following the de-facto standard BLAS API. Eigen does not seem to put a lot of effort on parallel implementation.

Armadillo 是 C++ 的 LGPL3 库.它绑定了 LAPACK(numpy 使用的库).它使用递归模板和模板元编程,这是一个很好的点(不知道其他库是否也这样做?).

Armadillo is LGPL3 library for C++. It has binding for LAPACK (the library used by numpy). It uses recursive templates and template meta-programming, which is a good point (I don't know if other libraries are doing it also?).

xtensor 是 BSD 许可的 C++ 库.它提供了与 NumPy 非常相似的 C++ API.请参阅 https://xtensor.readthedocs.io/en/latest/numpy.html 备忘单.

xtensor is a C++ library that is BSD licensed. It offers A C++ API very similar to that of NumPy. See https://xtensor.readthedocs.io/en/latest/numpy.html for a cheat sheet.

如果您只想获得数据结构和基本的线性代数,这些替代方案非常好.根据您对风格、许可或系统管理员挑战的品味(安装 LAPACK 等大型库可能很困难),您可以选择最适合您需求的库.

These alternatives are really good if you just want to get data structures and basic linear algebra. Depending on your taste about style, license or sysadmin challenges (installing big libraries like LAPACK may be difficult), you may choose the one that best suits your needs.

这篇关于C++ 的 NumPy 样式数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆