Dear all,
I have a 2D matrix M(x,y) and want to perform the integration M(x,y)dy. For performance concerns, I am using a FORTRAN-like representation of the matrix, which means my data are written in a 1D valarray as:
M(x0,y0) M(x1,y0) ... M(xN,y0) M(x0,y1) M(x1,y1) .... M(xN,yN).
To integrate the data, I'd use a function of the type:
The caller for the integrate() function should pass it a pointer to the array containing the slice of the complete array M I am considering. The trivial implementation could be:
The problem here is the creation of a temporary copy. Since the slice can be quite large (and I do mean large), how would it be possible to avoid the temporary creation? An implementation like:
doesn't work unfortunately (error C2440: 'initializing' : cannot convert from 'std::slice_array<_Ty> *__w64 ' to 'compile_valarray *'... with VC++ 8.0).
Thanks & regards,
MrMF
I have a 2D matrix M(x,y) and want to perform the integration M(x,y)dy. For performance concerns, I am using a FORTRAN-like representation of the matrix, which means my data are written in a 1D valarray as:
M(x0,y0) M(x1,y0) ... M(xN,y0) M(x0,y1) M(x1,y1) .... M(xN,yN).
To integrate the data, I'd use a function of the type:
Code:
double integrate(valarray<doube>* variable, valarray<doube>* integrand)
{
double result = 0;
// calculate
return result;
}
The caller for the integrate() function should pass it a pointer to the array containing the slice of the complete array M I am considering. The trivial implementation could be:
Code:
valarray<double> y // the integration variable
valarray<double> M // the complete matrix
slice s(first,length,stride);
valarray<double> thisSlice = M[s];
double result = integrate(&y, &thisSlice);
The problem here is the creation of a temporary copy. Since the slice can be quite large (and I do mean large), how would it be possible to avoid the temporary creation? An implementation like:
Code:
double result = integrate(&y, &(M[s]))
doesn't work unfortunately (error C2440: 'initializing' : cannot convert from 'std::slice_array<_Ty> *__w64 ' to 'compile_valarray *'... with VC++ 8.0).
Thanks & regards,
MrMF