0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #define DUMP(u) mexPrintf("%s = %e\n", #u, u)
0018
0019 #include <math.h>
0020 #include "mex.h"
0021 #include <complex.h>
0022 #include "structures_raytracing_yp.h"
0023 #include <time.h>
0024
0025
0026
0027 #define equil_IN prhs[0]
0028 #define rayparam_IN prhs[1]
0029 #define equilparam_IN prhs[2]
0030 #define rho_IN prhs[3]
0031 #define theta_IN prhs[4]
0032
0033
0034
0035 #define x_OUT plhs[0]
0036 #define y_OUT plhs[1]
0037
0038 void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
0039 {
0040 double *x,*y,*rho,*theta;
0041
0042 rho = mxCalloc(1,sizeof(double));
0043 theta = mxCalloc(1,sizeof(double));
0044
0045
0046
0047 rho = mxGetPr(rho_IN);
0048 theta = mxGetPr(theta_IN);
0049
0050
0051
0052
0053 x_OUT = mxCreateDoubleScalar(mxREAL);
0054 y_OUT = mxCreateDoubleScalar(mxREAL);
0055 x = mxGetPr(x_OUT);
0056 y = mxGetPr(y_OUT);
0057
0058
0059
0060
0061 rayparam_format rayparam;
0062 rayequil_format rayequil;
0063 equilparam_format equilparam;
0064
0065
0066
0067 rayequil.x_fit = load_grid_2D(equil_IN,"x_fit",0);
0068 rayequil.y_fit = load_grid_2D(equil_IN,"y_fit",0);
0069 rayparam = load_ray_param(rayparam_IN);
0070 equilparam = load_equil_param(equilparam_IN);
0071
0072
0073
0074 double a,b,dummy;
0075 ppvald_2D(rayequil.x_fit,rayparam.dS[0],rho[0],theta[0],x,&dummy,&dummy,&dummy,&dummy);
0076 ppvald_2D(rayequil.y_fit,rayparam.dS[0],rho[0],theta[0],y,&dummy,&dummy,&dummy,&dummy);
0077 x[0]=x[0]/equilparam.ap[0];
0078 y[0]=y[0]/equilparam.ap[0];
0079 return;
0080 }