111 questions
2
votes
1
answer
123
views
How to delete the first rows/columns in a boost::multi_array?
It is very easy to delete the last rows or columns in a boost::multi_array, for example, using the following minimal example:
#include "boost/multi_array.hpp"
#include <iostream>
...
2
votes
1
answer
91
views
Function returning a custom struct that includes a boost::multi_array
I have this apparently simple code, but boost complains about a dimension mismatch:
#include <iostream>
#include <fstream>
#include "boost/multi_array.hpp"
struct t_struct {
...
2
votes
2
answers
225
views
Unable to see gains on using boost::multi_array as compared to raw C array of pointers or C++ vector<vector<double>>
I am running a simple benchmarking exercise of 2d array access of reading and writing.
I have const int XDim = 1000; and const int YDim = 1000; and create a 1000 x 1000 matrix.
In C-style, I ...
3
votes
2
answers
94
views
Is safe boost::multi_array_ref returned by a function?
I'm trying to use boost::multi_array_ref to use a block of contiguous data in my code. But I worry about if I use the code like below, the 1d C array won't be confirmed to save:
#include <iostream&...
1
vote
1
answer
182
views
How to change type of elements in C++ boost multi array?
I receive a matrix with elements of type unsigned char from another function and I am trying to find its max value.
boost::multi_array<unsigned char, 2> matrix;
All elements are integers and so ...
1
vote
1
answer
75
views
Accessing dimension of boost multi-arrays in C++
When I run the following with warning flags I get a type conversion warning.
#include <boost/multi_array.hpp>
void function (boost::multi_array<unsigned char, 2> matrix) {
int nrows = ...
1
vote
1
answer
299
views
How to store values in the boost multi_array container?
I'm struggling to access the values and store them in boost multi_array container. I've tried to access the elements using the indexing methods ([] and .at()), but throws error: no matching function ...
2
votes
2
answers
152
views
How to convert a pointer to an element in boost::multi_array into its indices?
In my program I use boost::multi_array and sometimes it is important to convert a pointer to an element inside the container into its indices, for example, to check that the element is not on the ...
1
vote
1
answer
349
views
boost::multi_array_ref vs. boost::multi_array&
Is there a reason to prefere the usage of boost::multi_array_ref over boost::multi_array&? Why is the adapter class boost::multi_array_ref provided by boost at all?
2
votes
2
answers
310
views
How to execute mathematical operations between two boost::multi_arrays (C++)?
How can I execute a mathematical operation between two boost::multi_arrays?
Example of adding two arrays with value type double:
auto array1 = boost::multi_array<double, 2>(boost::extents[10][10]...
1
vote
1
answer
116
views
Copy selected values (via view) from boost::multi_array to another array (C++)
How can I copy (deep-copy) a selcted range (view) from a boost::multi_array to another array?
2
votes
1
answer
184
views
How to send subarray of 2d Boost.MultiArray via Boost.MPI?
I need to send reference to a subarray of 2d of Boost.MultiArray with Boost.MPI.
Now I have the following code:
matrix_type::array_view<2>::type
current_process_batch = ...
2
votes
1
answer
455
views
How to take subarray from 2d Boost.MultiArray?
I am working on a program where I need to use 2d Boost.MultiArray. I managed to initialize it and fill it with data. But I don't understand how to take subarray of size i,j if multiarray is of size m,...
1
vote
2
answers
82
views
What is the most efficient (time, memory) way to add a 2D-horizontal- and a 2D-vertical-aligned boost::multi_array resulting in a 3D array?
I want to add two boost multi-arrays in C++.
The first challenge is the alignment of the two arrays. One of these arrays is vertically aligned and the other is horizontally aligned as shown in the ...
1
vote
2
answers
217
views
How do I get a view of a boost multi_array and assign it back to the same boost multi_array?
I have a function called DataView that performs the "slicing" (creation of the array_view) as follows:
template <class T>
typename Boost<T>::Array2D::template array_view<2>::type ...
1
vote
1
answer
139
views
Initializing const boost multi_array
I have several large arrays of 64-bit integers whose values are expensive to calculate, so I presently have generator codes in my build system that calculate the constants and generate the .cpp files ...
2
votes
1
answer
93
views
Does boost::multi_array default initialize its contents?
std::vector<T> foo(100) initialises every element with the default value for T. Does boost::multi_array<T, 2> foo(boost::extents[10][10]) do the same?
1
vote
0
answers
172
views
Sum neighborhood of every matrix element efficiently
I programmed a piece of code where I have a huge 3D matrix in C++ using boost::multi_array.
For every matrix element I want to sum up the neighborhood in a certain distance dist. Every element is ...
4
votes
1
answer
104
views
c++ boost::multi_array index too large
I'm using a two-dimensional boost::multi_array to store objects of a custom struct. The problem is that I have a huge amount of these objects so that the index of the array I would need exceeds the ...
3
votes
1
answer
743
views
multi_array boost library error?
I got this error in C++. I am trying to implement Strassen matrix multiplication with multi_array. I assign one array to another which they same dimension.
Like that A11[i][j][k] = A[i][j][k]. I ...
6
votes
3
answers
1k
views
What is the type of a boost::extent object after providing dimensions?
Say I have
#include <boost/multi_array.hpp>
using intArray3D = boost::multi_array<int, 3>;
and I want to create a bunch of intArray3Ds with the same shape:
auto my_shape = boost::...
1
vote
1
answer
52
views
Specify the length of all arrays in boost::multi_array
I have a probably stupid question, but I am trying to define a 8x3 array (each row is an array of 3 xyz-indices of a cell, there are 8 cells in total) using boost::multi_array. My question is, is ...
2
votes
1
answer
282
views
Passing boost::multi_array between functions (c++)
Suppose i need a five-dimensional array as class member and want to use it in different functions. For this puropose I use boost::multi_array e.g.:
class myClass {
typedef boost::multiarray<...
3
votes
1
answer
253
views
Converting boost multi_array to its native array type
I am writing a class that acts as a go-between for c++ classes and legacy c code.
I have been using boost multi_array's to simplify a lot of the code. This mult_array is declared as such:
using Array ...
7
votes
1
answer
552
views
How to std::move a boost::multi_array?
It doesn't appear that multi_array has a move constructor - is this correct? Is there a reason for this or was it just never implemented since the class seems to have been written before move ...
5
votes
2
answers
1k
views
What is the best way to populate a boost::multi_array from an initializer list?
I'd like to initialize a boost::multi_array inline in some code. But I don't think the boost::multi_array supports initialization from an initializer list. Here's what I have so far:
// First create ...
0
votes
0
answers
51
views
boost multi array typedef not recognized c++ [duplicate]
I m quite new to c++ but working hard.
I m using the boost::multi_array library in a project but I got problem with typedef.
//in main.h
#include "boost/multi_array.hpp"
#DEFINE D
#include "...
2
votes
1
answer
40
views
Can you call a function using different sized boost::multi_arrays?
I am trying to build a function to write multidimensional arrays to the file system. In order to keep it compact I would like to just create one function for different sized multi_arrays.
typedef ...
3
votes
2
answers
125
views
boost multiarray segmentation fault
I`m writing a code for which I'm using a 3 dimensional boost multiarray to save coordinates. But I always get a segmentation fault at some point.
How are boost multiarray sizes limited and how can I ...
3
votes
1
answer
161
views
arrow operator and boost multiarray iterator
Is the arrow operator missing from boost multiarray iterators? Am I wrong to expect this to work?
#include <vector>
#include <boost/multi_array.hpp>
struct foo {
int n;
};
int main()...
2
votes
1
answer
470
views
multi_array_view assignment without deep copy?
How can I reassign a boost multi_array_view to point to a different part of a multi_array? I don't want a deep copy.
boost::multi_array<int, 2> a(...);
array_view b = a[indices[index_range(0, 5)...
2
votes
2
answers
77
views
Using boost multi_array and its views in the same function
A multi_array view has many of the same methods as a multi_array. Do they have a common base that I can use by reference?
void count(Type a) {
// ^^^^ what should I use here?
cout <<...
2
votes
1
answer
101
views
(c++) Storing lambda function in a boost multi_array
My plan is to store hundreds (or even thousands) of (interpolation) functions in the multidimensional array multi_array from the boost library. I need to store them, since I need to call them at ...
2
votes
0
answers
188
views
Plotting Boost Multi-Array with gnuplot
I want to plot a multi-array I have created with the Boost library. I keep getting stuck inside my gnuplot-third party library (added in order to plot). Im having trouble sending the correct ...
3
votes
1
answer
121
views
boost::multi_array memory management and scope
I am using a boost::multi_array to store some data. I do all my work on the data using views, because I need to work with slices of the data in different dimensions.
My question is, how is the memory ...
2
votes
1
answer
144
views
How to construct a multi_array::index_gen at runtime
In the following code, the ExtractSubArray function is totally generic, while the ExtractSubArrayCornerAndExtent requires knowledge of the dimensionality at the time the code is written (to construct ...
3
votes
1
answer
311
views
Sorting boost's multi_array using sort function and a recursive comparator
I work on big data and program in c++. For example, I need to create 4-dimensional arrays of size [7 x 128^3 x 5 x 5] etc. I will have to create many more arrays as intermediate data structures for ...
0
votes
2
answers
1k
views
Iterate through a boost::multi_array view
I want to understand how to use the view functionality provided by boost::multi_array. Specifically, I want to be able to iterate within a single loop over all elements of a view that represents a ...
0
votes
1
answer
446
views
Extracting a sub-array from a multi_array
I am trying to extract a sub-array from a multi_array. For this demo, let's assume that there are no collapsed dimensions (i.e. the dimensionality of the sub-array is the same as the original array). ...
1
vote
0
answers
123
views
Why is `index_gen` in `multi_array` a `boost::detail::multi_array::index_gen<0,0>`
This discussion has let to another question. It seems that index_gen in multi_array (a.k.a. boost::multi_array::index_gen) is set to boost::detail::multi_array::index_gen<0,0>, where I would ...
2
votes
0
answers
133
views
How do you assign a boost::indices in a variable?
I am trying to store a boost::indices in a variable. From what I can gather, this produces an index_gen type. However, index_gen seems to be templated in boost::detail, but the template parameters are ...
0
votes
1
answer
268
views
boost_multi array too large? bad_alloc error
I am writing a program to test a feature. However, I get an error when I declare a boost::multi_array that has a certain size. I get the following error:
terminate called after throwing an instance ...
4
votes
1
answer
951
views
clean way to initialize boost::multi_array with actual elements
I'm looking for clean syntactic sugar to initialize a boost::multi_array from explicit values. The best I could come up with was
double g[5][5] = {
{-0.0009 , 0.003799 , 0.00666 , 0.00374 ...
2
votes
1
answer
282
views
assignment between array elements using boost multi_array iterator
Working on a Kubuntu 14.04 system with gcc 4.8.4 I ran into the following problem:
Using std:vector, I can assign between vector elements via an iterator:
std::vector<float> v ;
v.push_back(0....
3
votes
2
answers
1k
views
resizing boost::multi_array to match another
I need to resize one multi_array to the size of another.
In Blitz++ I could just do
arr1.resize(arr2.shape());
Is there a multi_array solution of similar length? Because
arr1.resize(boost::...
2
votes
1
answer
810
views
for_each algorithm to loop over boost::multi_array
Related questions have been asked here before, but I still haven't found a satisfactory answer, so I will try to explain my problem and hope someone can enlighten me.
I am currently writing some code ...
5
votes
2
answers
5k
views
How to properly initialize a boost multi_array of objects?
I have been surprised to find that boost::multi_array seems to allocate its initial elements differently from, say, std::vector. It does not seem to fill each element with a unique element (using its ...
3
votes
1
answer
346
views
memory-size of boost::multi_array
I have a boost::multi_array of 3 dimensions
boost::multi_array<Struct, 3>* newArr = new boost::multi_array<Struct, 3>(boost::extents[x][y][z], boost::fortran_storage_order())
Is there ...
2
votes
1
answer
161
views
Container for boost::multi_array of same type but with different dimentionality
What i need is to create a class that can hold boost::multi_array of same type but with different dimentions
assume there are one or more such arrays of Double
boost::multi_array<double, 2> ...
1
vote
1
answer
1k
views
3D-Grid of bins: nested std::vector vs std::unordered_map
pros, I need some performance-opinions with the following:
1st Question:
I want to store objects in a 3D-Grid-Structure, overall it will be ~33% filled, i.e. 2 out of 3 gridpoints will be empty.
...