-----Original Message-----
From: "alfC" [alfredo.correa@gmail.com]
Date: 24/02/2010 08:24 AM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] multi_array : using double** from 3rd party lib
and I wish to pass the "subarray" as a double** argument and call their function .It's not possible, is it?
you have to create the array of pointers:
double trace(double** arr){
double ret=0;
for(unsigned i=0; i!=4; ++i){
ret+=arr[i][i];
}
return ret;
}
int main(){
boost::multi_array a(boost::extents[2][2][2][2][2][4]
[4]);
a[1][1][1][1][1][0][0]=8;
a[1][1][1][1][1][3][3]=3;
double** sarr=new double*[4];
for(unsigned i=0; i!=4; ++i){
sarr[i]=(&a[1][1][1][1][1][i][0]);
}
std::cout<< trace( sarr ) <
I am actually able to override their function that takes in a double** data.
Can it work then?
If you can "override" (sic) the function that takes the data, can't
you just replace by some multi_array, if there is no
pointer arithmetic in the function then that it is easy to do. right?
Alfredo
_______________________________________________
The function is a virtual member function of a class.
It has signature
virtual f(double** data, ....)
So I can override in my derived class, but then I can only override it with the same signature.
creating the array of pointers is what the library does in their default implementation.
But for me, I have the data already in the array, so it is a waste of runtime and memory,
anyways, you confirmed there is no way around this,
thanks very much,