Boost logo

Boost Users :

From: Sebastien Fortier (sebastien.fortier_at_[hidden])
Date: 2006-08-14 08:14:18


Thank you again for your help, you mention specifying a different
storage order for the multi_array, but you did not explain further...
I tried what you have suggested and it seems to work just fine. Could
you elaborate on the storage order stuff? Do you have any suggestions?

Ronald Garcia wrote:

> Hello Sebastien,
>
> On Aug 11, 2006, at 9:31 AM, Sebastien Fortier wrote:
>
>> I would like to know if it is possible to use memcpy to copy a float
>> array to a particular dimension of a multi_array.
>
>
> In some situations you can, but not as your array is currently specified.
>
>>
>> [...]
>
>
> If you change your multi_array so that the third dimension is the
> first dimension, then the dim1*dim2 elements will be stored
> contiguously in the array and you will then be able to memcpy them (or
> pass a pointer to the array buffer and avoid copying altogether).
> If you require the dimensions of the multi_array to be as you
> specified, then you will need to specify a different storage order for
> the array in order to make the dim1*dim2 elements contiguous.
>
> for example:
> /* switch the dimensions of the array */
> array_type3D_f_t valueMatrix(boost::extents[dim3][dim1][dim2]);
>
> /* ... */
> for (int i=0; i != dim3; ++i) {
> function(valueMatrix[i].origin()); // directly passes the
> multi_array buffer to the function
> }
>
> HTH,
> ron
>
>> [...]
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Boost-users mailing list
>Boost-users_at_[hidden]
>http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Sébastien Fortier


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net