Armadillo C++:- Efficient access of columns in a cube structure
armadillo, c++, matrix
Solution
I think you want
B = A.subcube( span:all, span(i), span(j) );
or equivalently
B = A.subcube( span(), span(i), span(j) );
where `B` will be a row or column vector of the same type as `A` (e.g. containing `double` by default, or a number of other available types).
Problem
Using Armadillo matrix library I am aware that the efficient way of accessing a column in a 2d matrix is via a simply call to .col(i). I am wondering is there an efficient way of extracting a column stored in a "cube", without first having to call the slice command? I need the most efficient possible way of accessing the data stored in for instance (using matlab notation) A(:,i,j) . I will be doing this millions of times on a very large dataset, so speed and efficiency is of a high priority.