Hello,
I have a problem using the data fitting for a linear interpolation of a vector valued function. It seems that the format rhint is ignored by the function dfdInterpolate1D.
#include <iostream> #include "mkl.h" #define ALIGNMENT 64 int main(int argc, char** argv){ DFTaskPtr task; MKL_INT NX = 3; MKL_INT NY = 2; double* x = (double*)mkl_malloc(NX*sizeof(double), ALIGNMENT); double* y = (double*)mkl_malloc(NX*NY*sizeof(double), ALIGNMENT); x[0] = 0; x[1] = 1; x[2] = 2; /* y is 2 dimensional in col-major format (y(0)=(0;1), y(1)=(5;1), y(3)=(10;1)) */ y[0] = 0; y[1] = 1; y[2] = 5; y[3] = 1; y[4] = 10; y[5] = 1; MKL_INT yHint = DF_MATRIX_STORAGE_COLS; int status = dfdNewTask1D( &task, NX, x, DF_NO_HINT, NY, y, yHint); std::cout << "Status after dfdNewTask1D: "<< status << std::endl; MKL_INT s_order = DF_PP_LINEAR; MKL_INT s_type = DF_PP_DEFAULT; MKL_INT ic_type = DF_NO_IC; double* ic = NULL; MKL_INT bc_type = DF_NO_BC; double* bc = NULL; double* scoeff = (double*)mkl_malloc(NY*(NX-1)* s_order * sizeof(double), ALIGNMENT); MKL_INT scoeffhint = DF_NO_HINT; status = dfdEditPPSpline1D( task, s_order, s_type, bc_type, bc, ic_type, ic, scoeff, scoeffhint ); std::cout << "Status after dfdEditPPSpline1D: "<< status << std::endl; status = dfdConstruct1D( task, DF_PP_SPLINE, DF_METHOD_STD ); std::cout << "Status after dfdConstruct1D: "<< status << std::endl; MKL_INT NSITE = 2; double* site = (double*)mkl_malloc(NSITE*sizeof(double), ALIGNMENT); site[0] = 0.5; site[1] = 1.5; MKL_INT sitehint = DF_NO_HINT; double* r = (double*)mkl_malloc(NSITE*NY*sizeof(double), ALIGNMENT); MKL_INT rhint = DF_MATRIX_STORAGE_COLS; MKL_INT ndorder = 1; MKL_INT dorder = 1; double* datahint = NULL; MKL_INT* cell = NULL; status = dfdInterpolate1D( task, DF_INTERP, DF_METHOD_PP, NSITE, site, sitehint, ndorder, &dorder, datahint, r, rhint, cell ); std::cout << "Status after dfdInterpolate1D: "<< status << std::endl; status = dfDeleteTask( &task ); std::cout << "Status after dfDeleteTask: "<< status << std::endl; /* Print output */ std::cout << "scoeff = ( "; for (int i = 0; i<NY*(NX-1)* s_order; i++){ std::cout << scoeff[i] << ""; } std::cout << ")"<< std::endl; std::cout << "r = ( "; for (int i = 0; i<NSITE*NY; i++){ std::cout << r[i] << ""; } std::cout << ")"<< std::endl; std::cout << "r_expected = ( 2.5 1 7.5 1 )"<< std::endl; mkl_free(x); mkl_free(y); mkl_free(scoeff); mkl_free(site); mkl_free(r); return 0; }
Output is (Compiled on RedHat 64bit with parallel studio 2016):
Status after dfdNewTask1D: 0
Status after dfdEditPPSpline1D: 0
Status after dfdConstruct1D: 0
Status after dfdInterpolate1D: 0
Status after dfDeleteTask: 0
scoeff = ( 0 5 5 5 1 0 1 0 )
r = ( 2.5 7.5 1 1 )
r_expected = ( 2.5 1 7.5 1 )
RUN FINISHED; exit value 0; real time: 30ms; user: 0ms; system: 0ms
The output is written in row-major format to r instead of the choosen col-major format using rhint. Is there a problem with my code or is it not possible to get the expected format.
Thanks,
Mario