Dumb multi_array question about assignment
I'm currently working on a numerical project that uses boost.python, and
since we already had boost as a dependency we've begun using
boost/multi_array_ref to simplify multi-dimensional array handling in
our code. I was rather surprised when the following code fragment spit
out pages of errors when I tried to compile it:
float* data = (float*) malloc(nx*ny*sizeof(float));
[...]
boost::multi_array_ref
Hi Grant, On Jan 10, 2005, at 12:44 PM, Grant Goodyear wrote:
I'm currently working on a numerical project that uses boost.python, and since we already had boost as a dependency we've begun using boost/multi_array_ref to simplify multi-dimensional array handling in our code. I was rather surprised when the following code fragment spit out pages of errors when I tried to compile it:
float* data = (float*) malloc(nx*ny*sizeof(float)); [...] boost::multi_array_ref
xy(data, boost::extents[nx][ny]); xy = 0.; // errors out here
Yes, multi_array_ref does not support assignment from one type like you have there. You can assign between arrays that have the same dimensions however.
Looking through the docs I realized that operator= isn't even mentioned, so perhaps I shouldn't have been surprised. It is rather unfortunate, though, that such a statement isn't allowed. (Unless, of course, I'm doing something wrong, which is completely possible.) Is there any plan to add such functionality in the future, or would it make more sense for us to switch to a different library (blitz++ or something similar)?
What other functionality are you looking for? Hope this Helps, ron
Ronald Garcia wrote: [Mon Jan 10 2005, 12:23:31PM CST]
Yes, multi_array_ref does not support assignment from one type like you have there. You can assign between arrays that have the same dimensions however.
Thanks, that helps, and that will probably suffice for us.
What other functionality are you looking for?
Actually, I'm not sure just yet. I'm going to be porting some f90 code, but I haven't started the hard stuff just yet. Thanks again, Grant Goodyear -- Grant Goodyear web: http://www.grantgoodyear.org e-mail: grant@grantgoodyear.org
participants (2)
-
Grant Goodyear
-
Ronald Garcia