On 8/22/07, chris dion <evolocity@hotmail.com> wrote:
Hi

I'm having a problem with the boost/multi_array and I'm hoping someone here
can help, or at least explain why the following doesn't work.

What you are trying is not possible with the views (from your code it seems you misunderstood the way they work - take a second look at the docs here).

You can solve your problem with a multi_array_ref and a different storage ordering. Here is an example:

   using namespace boost;
   typedef multi_array<int,2> arr2;
   typedef multi_array_ref<int,2> rarr2;
   typedef array<arr2::index, 2> shape2;
   //
   // create and fill array
   //
   shape2 sh = {3,4};
   arr2 foo(sh);
   for (int i=0; i!=sh[0]; ++i)
      for (int j=0; j!=sh[1]; ++j)
         foo[i][j] = i + j*10;
   //
   // create a reference to transposed shape
   //
   shape2 shT = {4,3};
   rarr2 fooT(foo.data(), shT, fortran_storage_order());
   for (int i=0; i!=sh[0]; ++i)
      for (int j=0; j!=sh[1]; ++j)
         assert( foo[i][j] == fooT[j][i] );

 
hth
Levent

--
Server Levent Yilmaz
Mechanical Engineering
University of Pittsburgh