Hi, I've recently found out about the existence of MultiArray and I am quite impressed! I was thinking of implementing something similar myself but now hopefully I don't have to! However I have a few questions that I'm hoping someone can answer. Question 1 ---------- In the user documentation there is an example which has some example code: for(index i = 0; i != 3; ++i) for(index j = 0; j != 4; ++j) for(index k = 0; k != 2; ++k) A[i][j][k] = values++; Why can't you change the != into Ie, do: for(index i = 0; i < 3; ++i) for(index j = 0; j < 4; ++j) for(index k = 0; k < 2; ++k) A[i][j][k] = values++; or can you? This would be more efficient I should think, and requiring that index types be ordered shouldn't be too onerous should it? Question 2 ---------- If I use the built-in "no-frills" C array type to represent a 2-dimensional array in row-major order, then I would access an element (i, j) by doing: a[ &a[0] + i*n + j ] where a is my m by n array. And if I wish to traverse a, in row-major order, I can do: for (int* ip=&(a[0]); ip<&(a[n*m]); ip+=n) { for (int* ijp=&(ip[0]); ijp<&(ip[n]); ++ijp) { visit(ijp); } } These are a very efficient ways of doing things, but it lacks somewhat in ease-of-generalization and in readbility. This is where the MultiArray library is useful. But do I lose in efficiency by going to MultiArray? Ie, in the simple case where base is 0, stride is 1, and when we traverse in row-major order, is the MultiArray library smart enough to do compile-time optimizations to generate code which is as efficient as the above? I am guessing that this sort of approach is what the Blitz++ library does?? Question 3 ---------- Is it possible to construct a new multi_array/multi_array_ref/const_multi_array_ref from an array_view by doing a deep copy of the view? A view is a nice way of looking at different parts of a MultiArray object in a readable way, but sometimes you might wish to turn this view into a more-efficiently represented object. Is this easy to do in the MultiArray library? Question 4 ---------- Sometimes you might have an object starts off being mostly accessed in row-major order, so you want a representation which works efficiently for this use. But down the track you might wish to change to mostly column-major access. Does MultiArray provide easy ways to transform from one underlying representation to another? Thanks, Mark Phillips.
Hi!
I'm working with the boost::numeric::ublas library and I'm having some
problems, but I'm posting here because I think the problem is due to the
type_traits library. In fact, with Visual C++ 7.0 this piece of code
does not compile, with the error C2529: "reference to reference is
illegal".
------------------------------------
#include
Lorenzo Bolla wrote:
I'm working with the boost::numeric::ublas library and I'm having some problems, but I'm posting here because I think the problem is due to the type_traits library. In fact, with Visual C++ 7.0 this piece of code does not compile, with the error C2529: "reference to reference is illegal".
------------------------------------
#include
#include <complex> //typedef double value_t; typedef std::complex<double> value_t;
int main() { // reference to reference!!! boost::remove_reference
::type const &a (value_t (0.)); return 0; } -----------------------------------
With value_t == double everything works fine. Any suggestions?
Adding BOOST_TT_BROKEN_COMPILER_SPEC(value_t) after the typedef should take care of it. See the second paragraph in http://www.boost.org/libs/type_traits/index.html#transformations. -- Aleksey Gurtovoy MetaCommunications Engineering
participants (3)
-
Aleksey Gurtovoy
-
Dr Mark H Phillips
-
Lorenzo Bolla