Boost multi_array library
Boost multi_array library
我需要将一些vba代码转换为c++,问题是算法非常特殊,它使用矩阵高达15维,因此我决定使用boost multi_array。现在我的问题是,在VBA中,你可以在运行时改变尺寸,我想知道我是否也可以在boost multi_array中做到这一点。
欢呼
您可以在运行时更改每个维度的范围(大小),但不能更改变量的维度数:
typedef boost::multi_array<double, 3> array_type;
// Create a 2x4x5 array
array_type array3(boost::extents[2][4][5]);
// Reshape (no copy) - The total number of elements must remain the same
boost::array<array_type::index, 3> new_dims{{5, 4, 2}};
array3.reshape(new_dims);
// Resize, keeping currently stored elements by copying them
array3.resize(boost::extents[8][10][5]);
// Create a new array
array3 = array_type(boost::extents[7][6][8]);
由于维度数是boost::multi_array
的模板参数,所以不能在运行时更改。
相关文章:
- Boost Graph Library,修复节点大小
- SFML library: http request
- C++11 中不同类型的对象的 std::array 的替代方案
- constexpr begin of a std::array
- C++如果必须在编译时确定大小,std::array 有什么意义?
- OpenGL VBO Indexing ( How to compute Index Array)
- 标准::unordered_map 中的 std::array 的值初始化
- 解决"ld: library not found for -ltensorflow_framework.2.3.0"
- "Warning: Comma within array index expression"但逗号分隔函数参数
- 确保编译时的特定 std::array 位置
- Linking library C++
- std::array的长度有大小限制吗?
- 将 std::array 移动到另一个 std::array
- 首先按给定顺序打印所有数字,然后使用 Array 打印所有字符和其他符号
- 为什么 std::shared_ptr 被认为是"heavy"和"expensive",但 std::array "same perfprmance as plain (c-style) arrays
- 将 **float array 从 C++ Dll 传递给 python
- std::bind on statd::array 的运算符 []
- 在VS2019项目中集成ImageMagick:x64-windows-static library
- 检查输入 std::array 指针数据是否等于某个常量数组
- OpenSSL fips in C++ wrapper Library 如何?错误:指纹不匹配