|
Boost : |
From: Gary Powell (powellg_at_[hidden])
Date: 2002-01-08 18:51:27
ah!, sorry that I missed that. Multi-array seems to satisfy all of the
issues I can think of for now. I vote for inclusion.
-gary-
PS
Anyone up for a rerun of the tests with the code below? I'd be interested
if they are comparable in time, vs [].
-----Original Message-----
From: Jeremy Siek [mailto:jsiek_at_[hidden]]
Sent: Tuesday, January 08, 2002 4:04 AM
To: boost_at_[hidden]
Subject: RE: [boost] Re: N-Dimensional array library submission...
multi_array can do what you want, it has iterators over each dimension. It
looks like this:
for (i = A.begin(); i != A.end(); ++i)
for (j = i->begin(); j != i->end(); ++j)
for (k = j->begin(); k != j->end(); ++k)
*k = values++;
On Mon, 7 Jan 2002, Gary Powell wrote:
> 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-
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
----------------------------------------------------------------------
Jeremy Siek http://www.osl.iu.edu/~jsiek/
Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------
Info: http://www.boost.org Send unsubscribe requests to:
<mailto:boost-unsubscribe_at_[hidden]>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk