Boost logo

Boost :

From: Gary Powell (powellg_at_[hidden])
Date: 2002-01-07 18:28:09


My problem is that for "C" code I tend to write:

-------------------------------------------

int carray_3D(double* A)
{
   // Assign values to the elements
   int values = 0;
   double const* const rowLength = (sizeof(double *) * row_size);
   double const* const rowTimesCol = (rowLength * col_size);
   double const * const AEnd = A + (rowTimesCol * width_size));
   for(double * i = A; i != AEnd; )
   {
     double const * const rowEnd = i + rowTimesCol;
     for(double *j = 0; j != rowEnd; )
     {
       double *columnEnd = j + rowLength;
       for(double *k = j; k != columnEnd; ++k)
       {
         *k = values++;
       }
       j = columnEnd;
     }
     i = rowEnd;
   }

   ...// etc.
   return 0;
}

And that's what I want my multi-array access to generate. To not reload
initial offsets, to do basic addition at the inner most level, not
multiplication and addition for every access. (Without errors, as I'm sure
the above code has!)

IF you are only randomly accessing [][][], then I really like the syntax of
multi-array. It's just what I've written (Only not anywhere as nicely) Call
me greedy, but I want it all. Speed, easy to read source, and small code.
(sounds like I need a better compiler!)

  Yours,
 -gary-


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk