boost-multi-array

Boost MultiArrays performance is poor

做~自己de王妃 提交于 2019-12-11 10:07:54
问题 I noticed that my boost mutiarrays were performing very badly compared to STL Vector. I came upon this question asked earlier, where the most liked answer stated that 1) Boost is nearly as fast as native array 2) You need to change the order in which you access your data elements to get the best performance out of Boost MultiArray. Also, that you need to run in Release mode, and not Debug. Well, I did all that, and yet the performance of my MultiArrays is pretty shabby. I am posting my code

How to assign / copy a Boost::multi_array

早过忘川 提交于 2019-12-09 10:32:27
问题 I want to assign a copy of a boost::multi_array. How can I do this. The object where I want to assign it to has been initialized with the default constructors. This code does not work, because the dimensions and size are not the same class Field { boost::multi_array<char, 2> m_f; void set_f(boost::multi_array<short, 2> &f) { m_f = f; } } What to use instead of m_f = f ? 回答1: You should resize m_f before assigning. It could look like in the following sample: void set_f(boost::multi_array<short

Eigen::Matrix vs. boost::multi_array vs. Eigen::Map

怎甘沉沦 提交于 2019-12-07 23:48:37
问题 I'm getting puzzling results while doing fairly simple tasks to compare the performance of: Eigen::Matrix boost::multi_array boost::multi_array mapped to Eigen::Matrix using Eigen::Map This is an abridged version of my test code; a fuller version can be found at: http://pastebin.com/faZ7TvJG. boost::multi_array<double, 2, Eigen::aligned_allocator<double> > boost_multi_array; Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> eigen_matrix; Eigen::Map<Eigen::Matrix<double,

Eigen::Matrix vs. boost::multi_array vs. Eigen::Map

徘徊边缘 提交于 2019-12-06 07:39:48
I'm getting puzzling results while doing fairly simple tasks to compare the performance of: Eigen::Matrix boost::multi_array boost::multi_array mapped to Eigen::Matrix using Eigen::Map This is an abridged version of my test code; a fuller version can be found at: http://pastebin.com/faZ7TvJG . boost::multi_array<double, 2, Eigen::aligned_allocator<double> > boost_multi_array; Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> eigen_matrix; Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> > boost_multi_array_mapped(boost_multi_array.data(),

How to specify degenerate dimension of boost multi_array at runtime?

主宰稳场 提交于 2019-12-05 16:43:16
问题 I have a 3D multi_array and I would like to make 2D slices using dimensions specified at runtime. I know the index of degenerate dimension and the index of a slice that I want to extract in that degenerate dimension. Currently the ugly workaround looks like that: if (0 == degenerate_dimension) { Slice slice = input_array[boost::indices[slice_index][range()][range()]]; } else if (1 == degenerate_dimension) { Slice slice = input_array[boost::indices[range()][slice_index][range()]]; } else if (2

One-line initialiser for Boost.MultiArray

假装没事ソ 提交于 2019-11-30 14:10:42
问题 I have a n-dimensional Boost.MultiArray I initialize as follows: const int n=3, size=4; //# of dimensions and size of one dimension boost::multi_array<char,n> arr; boost::array<size_t,n> extents; //size of each dimension extents.assign(size); //assign size to each dimension -> {{4, 4, 4}} arr.resize(extents); So I have 4 lines of code to get the MultiArray, but I'd like to do it in one line. Is there any simple way to generate an MultiArray with n dimensions each having size length (so I can

One-line initialiser for Boost.MultiArray

房东的猫 提交于 2019-11-30 09:38:49
I have a n-dimensional Boost.MultiArray I initialize as follows: const int n=3, size=4; //# of dimensions and size of one dimension boost::multi_array<char,n> arr; boost::array<size_t,n> extents; //size of each dimension extents.assign(size); //assign size to each dimension -> {{4, 4, 4}} arr.resize(extents); So I have 4 lines of code to get the MultiArray, but I'd like to do it in one line. Is there any simple way to generate an MultiArray with n dimensions each having size length (so I can write arr(samevaluearray(n,size)) ) or did I miss a handy constructor for MultiArray? Edit: It should

Compare blitz++, armadillo, boost::MultiArray

醉酒当歌 提交于 2019-11-30 01:24:24
I did a comparison between blitz++, armadillo, boost::MultiArray with the following code (borrowed from an old post ) #include <iostream> using namespace std; #include <windows.h> #define _SCL_SECURE_NO_WARNINGS #define BOOST_DISABLE_ASSERTS #include <boost/multi_array.hpp> #include <blitz/array.h> #include <armadillo> int main(int argc, char* argv[]) { const int X_SIZE = 1000; const int Y_SIZE = 1000; const int ITERATIONS = 100; unsigned int startTime = 0; unsigned int endTime = 0; // Create the boost array //------------------Measure boost Loop------------------------------------------ {

Compare blitz++, armadillo, boost::MultiArray

青春壹個敷衍的年華 提交于 2019-11-28 22:13:51
问题 I did a comparison between blitz++, armadillo, boost::MultiArray with the following code (borrowed from an old post) #include <iostream> using namespace std; #include <windows.h> #define _SCL_SECURE_NO_WARNINGS #define BOOST_DISABLE_ASSERTS #include <boost/multi_array.hpp> #include <blitz/array.h> #include <armadillo> int main(int argc, char* argv[]) { const int X_SIZE = 1000; const int Y_SIZE = 1000; const int ITERATIONS = 100; unsigned int startTime = 0; unsigned int endTime = 0; // Create

Boost::multi_array performance question

∥☆過路亽.° 提交于 2019-11-27 17:27:44
I am trying to compare the performance of boost::multi_array to native dynamically allocated arrays, with the following test program: #include <windows.h> #define _SCL_SECURE_NO_WARNINGS #define BOOST_DISABLE_ASSERTS #include <boost/multi_array.hpp> int main(int argc, char* argv[]) { const int X_SIZE = 200; const int Y_SIZE = 200; const int ITERATIONS = 500; unsigned int startTime = 0; unsigned int endTime = 0; // Create the boost array typedef boost::multi_array<double, 2> ImageArrayType; ImageArrayType boostMatrix(boost::extents[X_SIZE][Y_SIZE]); // Create the native array double