|
Boost Users : |
Subject: Re: [Boost-users] multi_array : using double** from 3rd party lib
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-02-24 03:24:10
> 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<double, 7> 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 ) <<std::endl; //outputs 11
return 0;
}
, but probably you wanted something simpler.
> 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<double, 2>, if there is no
pointer arithmetic in the function then that it is easy to do. right?
Alfredo
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