Can I delete/resize a multi_array??

I recently discovered the multi_array, which was the answer to my prayers:
typedef boost::multi_array

Ramon F Herrera wrote:
I recently discovered the multi_array, which was the answer to my prayers:
typedef boost::multi_array
ExpressionArrayType; ExpressionArrayType exprTable(boost::extents[extreme_row][extreme_col]); But now I need more functionality, which can be either:
(1) Erase the current "exprTable" and create a new one, with different dimensions.
Do you mean different dimensionality? The dimensionality is part of the type and determined at compile time. Different dimensionality requires a different type.
(2) Resize the current dimensions.
Doesn't this explain resizing? http://www.boost.org/doc/libs/1_44_0/libs/multi_array/doc/user.html#sec_resi... Jeff

On 2/28/2011 10:53 AM, Jeff Flinn wrote:
Ramon F Herrera wrote:
I recently discovered the multi_array, which was the answer to my prayers:
typedef boost::multi_array
ExpressionArrayType; ExpressionArrayType exprTable(boost::extents[extreme_row][extreme_col]); But now I need more functionality, which can be either:
(1) Erase the current "exprTable" and create a new one, with different dimensions.
Do you mean different dimensionality? The dimensionality is part of the type and determined at compile time. Different dimensionality requires a different type.
(2) Resize the current dimensions.
Doesn't this explain resizing?
http://www.boost.org/doc/libs/1_44_0/libs/multi_array/doc/user.html#sec_resi...
Jeff
Thanks, Jeff!
The snippet below is along the lines of what I am trying to accomplish.
I read in TFM :-) that there is a destroy method (?), but I have never
need those (until now).
-Ramon
--------------
#include <iostream>
#include <string>
#include

On 2/28/2011 11:22 AM, Ramon F Herrera wrote:
On 2/28/2011 10:53 AM, Jeff Flinn wrote:
Do you mean different dimensionality? The dimensionality is part of the type and determined at compile time. Different dimensionality requires a different type.
No. All my multi_arrays are tables of 2 dimensions. -RFH

On Feb 28, 9:28 am, Ramon F Herrera
On 2/28/2011 11:22 AM, Ramon F Herrera wrote:
On 2/28/2011 10:53 AM, Jeff Flinn wrote:
Do you mean different dimensionality? The dimensionality is part of the type and determined at compile time. Different dimensionality requires a different type.
No. All my multi_arrays are tables of 2 dimensions.
you can always resize m.resize(extents[n1][n2]) the problem with that is that it won't necessarily "erase" the old data. You can erase the data manually after that. Or alternatively you can first resize to 0, 0 and then to the final size: m.resize(extents[0][0]); m.resize(extents[n1][n2]); in which case the data is always probably reallocated. Hope it is useful. Alfredo
-RFH
_______________________________________________ Boost-users mailing list Boost-us...@lists.boost.orghttp://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
alfC
-
Jeff Flinn
-
Ramon F Herrera