0001 #include <complex.h>
0002 #include <math.h>
0003 #include "mex.h"
0004
0005 struct polynomial_piecewise_0D {
0006 double *data;
0007 };
0008
0009 struct polynomial_piecewise_1D {
0010 mxChar *form_f;
0011 double *breaks_f;
0012 double *coefs_f;
0013 double *pieces_f;
0014 double *order_f;
0015 double *dim_f;
0016 mxChar *orient_f;
0017 mxChar *form_dfdrho;
0018 double *breaks_dfdrho;
0019 double *coefs_dfdrho;
0020 double *pieces_dfdrho;
0021 double *order_dfdrho;
0022 double *dim_dfdrho;
0023 mxChar *orient_dfdrho;
0024 mxChar *form_d2fdrho2;
0025 double *breaks_d2fdrho2;
0026 double *coefs_d2fdrho2;
0027 double *pieces_d2fdrho2;
0028 double *order_d2fdrho2;
0029 double *dim_d2fdrho2;
0030 mxChar *orient_d2fdrho2;
0031 };
0032
0033 struct polynomial_piecewise_2D {
0034 double *n;
0035 mxChar *form_a0;
0036 double *breaks_a0;
0037 double *coefs_a0;
0038 double *pieces_a0;
0039 double *order_a0;
0040 double *dim_a0;
0041 mxChar *orient_a0;
0042 mxChar *form_da0drho;
0043 double *breaks_da0drho;
0044 double *coefs_da0drho;
0045 double *pieces_da0drho;
0046 double *order_da0drho;
0047 double *dim_da0drho;
0048 mxChar *orient_da0drho;
0049 mxChar *form_d2a0drho2;
0050 double *breaks_d2a0drho2;
0051 double *coefs_d2a0drho2;
0052 double *pieces_d2a0drho2;
0053 double *order_d2a0drho2;
0054 double *dim_d2a0drho2;
0055 mxChar *orient_d2a0drho2;
0056 mxChar *form_an;
0057 double *breaks_an;
0058 double *coefs_an;
0059 double *pieces_an;
0060 double *order_an;
0061 double *dim_an;
0062 mxChar *orient_an;
0063 mxChar *form_dandrho;
0064 double *breaks_dandrho;
0065 double *coefs_dandrho;
0066 double *pieces_dandrho;
0067 double *order_dandrho;
0068 double *dim_dandrho;
0069 mxChar *orient_dandrho;
0070 mxChar *form_d2andrho2;
0071 double *breaks_d2andrho2;
0072 double *coefs_d2andrho2;
0073 double *pieces_d2andrho2;
0074 double *order_d2andrho2;
0075 double *dim_d2andrho2;
0076 mxChar *orient_d2andrho2;
0077 mxChar *form_bn;
0078 double *breaks_bn;
0079 double *coefs_bn;
0080 double *pieces_bn;
0081 double *order_bn;
0082 double *dim_bn;
0083 mxChar *orient_bn;
0084 mxChar *form_dbndrho;
0085 double *breaks_dbndrho;
0086 double *coefs_dbndrho;
0087 double *pieces_dbndrho;
0088 double *order_dbndrho;
0089 double *dim_dbndrho;
0090 mxChar *orient_dbndrho;
0091 mxChar *form_d2bndrho2;
0092 double *breaks_d2bndrho2;
0093 double *coefs_d2bndrho2;
0094 double *pieces_d2bndrho2;
0095 double *order_d2bndrho2;
0096 double *dim_d2bndrho2;
0097 mxChar *orient_d2bndrho2;
0098 };
0099
0100 struct rayprofiles {
0101 double *Te;
0102 double *ne;
0103 double *zTi;
0104 double *zni;
0105 double *dTedY;
0106 double *dnedY;
0107 double **dzTidY;
0108 double **dznidY;
0109 double *d2TedY2;
0110 double *d2nedY2;
0111 double **d2zTidY2;
0112 double **d2znidY2;
0113 };
0114
0115
0116 struct rayparam {
0117 double *testmode;
0118 double *tensortype;
0119 double *t0;
0120 double *tfinal;
0121 double *dt0;
0122 double *dS;
0123 double *tol;
0124 double *kmax;
0125 double *ncyclharm;
0126 double *reflection;
0127 double *rel_opt;
0128 double *nperp;
0129 double *pperpmax;
0130 double *tau_lim;
0131 double *kextra;
0132 double *rhomin;
0133 double *metricmode;
0134 double *rhoswitch;
0135 double *deltaswitch;
0136 double *substitution_method;
0137 };
0138
0139 struct equilparam {
0140 double *zZi;
0141 double *zmi;
0142 int *ns;
0143 double *Rp;
0144 double *ap;
0145 double *Zp;
0146 double *psia_apRp;
0147 };
0148
0149 struct fluctparam {
0150 int *ne_nmodel;
0151 double **ne_model;
0152 double **ne_sigmar_max;
0153 double **ne_sigmar_hwhm;
0154 double **ne_sigmar_rho;
0155 double **ne_polmode;
0156 double **ne_epsi_rho;
0157 double **ne_epsi_theta;
0158 double **ne_epsi_phi;
0159 double **ne_lmin;
0160 double **ne_mmin;
0161 double **ne_nmin;
0162 double **ne_lmax;
0163 double **ne_mmax;
0164 double **ne_nmax;
0165 int **ne_nphase;
0166 double **ne_phase;
0167 int *B_nmodel;
0168 double **B_model;
0169 double **B_sigmar_max;
0170 double **B_sigmar_hwhm;
0171 double **B_sigmar_rho;
0172 double **B_polmode;
0173 double **B_epsi_rho;
0174 double **B_epsi_theta;
0175 double **B_epsi_phi;
0176 double **B_lmin;
0177 double **B_mmin;
0178 double **B_nmin;
0179 double **B_lmax;
0180 double **B_mmax;
0181 double **B_nmax;
0182 int **B_nphase;
0183 double **B_phase;
0184 };
0185
0186 struct distriparam {
0187 double *pn;
0188 int *npn;
0189 double *mhu;
0190 int *nmhu;
0191 double *ne_ref;
0192 double *betath_ref;
0193 };
0194
0195 typedef struct polynomial_piecewise_0D pp_0D_format;
0196 typedef struct polynomial_piecewise_1D pp_1D_format;
0197 typedef struct polynomial_piecewise_2D pp_2D_format;
0198 typedef struct rayparam rayparam_format;
0199 typedef struct equilparam equilparam_format;
0200 typedef struct fluctparam fluctparam_format;
0201 typedef struct rayprofiles rayprofiles_format;
0202 typedef struct distriparam distriparam_format;
0203
0204 int strcmp();
0205
0206 distriparam_format load_distri_param(structure_name)
0207 mxArray *structure_name;
0208 {
0209 distriparam_format data;
0210
0211 data.pn= mxGetData(mxGetField(structure_name, 0, "pn"));
0212 data.npn = mxCalloc(1,sizeof(int));
0213 data.npn[0] = fmax(mxGetM(mxGetField(structure_name, 0, "pn")),mxGetN(mxGetField(structure_name, 0, "pn")));
0214 data.mhu = mxGetData(mxGetField(structure_name, 0, "mhu"));
0215 data.nmhu = mxCalloc(1,sizeof(int));
0216 data.nmhu[0] = fmax(mxGetM(mxGetField(structure_name, 0, "mhu")),mxGetN(mxGetField(structure_name, 0, "mhu")));
0217 data.ne_ref = mxGetData(mxGetField(structure_name, 0, "ne_ref"));
0218 data.betath_ref = mxGetData(mxGetField(structure_name, 0, "betath_ref"));
0219 return(data);
0220 }
0221
0222
0223
0224 rayparam_format load_ray_param(structure_name)
0225 mxArray *structure_name;
0226 {
0227 rayparam_format data;
0228
0229 data.testmode = mxGetData(mxGetField(structure_name, 0, "testmode"));
0230 data.t0 = mxGetData(mxGetField(structure_name, 0, "t0"));
0231 data.tfinal = mxGetData(mxGetField(structure_name, 0, "tfinal"));
0232 data.dt0 = mxGetData(mxGetField(structure_name, 0, "dt0"));
0233 data.dS = mxGetData(mxGetField(structure_name, 0, "dS"));
0234 data.tol = mxGetData(mxGetField(structure_name, 0, "tol"));
0235 data.kmax = mxGetData(mxGetField(structure_name, 0, "kmax"));
0236 data.tensortype = mxGetData(mxGetField(structure_name, 0, "tensortype"));
0237 data.ncyclharm = mxGetData(mxGetField(structure_name, 0, "ncyclharm"));
0238 data.reflection = mxGetData(mxGetField(structure_name, 0, "reflection"));
0239 data.rel_opt = mxGetData(mxGetField(structure_name, 0, "rel_opt"));
0240 data.nperp = mxGetData(mxGetField(structure_name, 0, "nperp"));
0241 data.pperpmax = mxGetData(mxGetField(structure_name, 0, "pperpmax"));
0242 data.tau_lim = mxGetData(mxGetField(structure_name, 0, "tau_lim"));
0243 data.kextra = mxGetData(mxGetField(structure_name, 0, "kextra"));
0244 data.rhomin = mxGetData(mxGetField(structure_name, 0, "rhomin"));
0245 data.metricmode = mxGetData(mxGetField(structure_name, 0, "metricmode"));
0246 data.rhoswitch = mxGetData(mxGetField(structure_name, 0, "rhoswitch"));
0247 data.deltaswitch = mxGetData(mxGetField(structure_name, 0, "deltaswitch"));
0248 data.substitution_method = mxGetData(mxGetField(structure_name, 0, "substitution_method"));
0249
0250 return(data);
0251 }
0252
0253 equilparam_format load_equil_param(structure_name)
0254 mxArray *structure_name;
0255 {
0256 equilparam_format data;
0257
0258 data.zZi= mxGetData(mxGetField(structure_name, 0, "zZi"));
0259 data.zmi = mxGetData(mxGetField(structure_name, 0, "zmi"));
0260 data.ns = mxCalloc(1,sizeof(int));
0261 data.ns[0] = fmax(mxGetM(mxGetField(structure_name, 0, "zmi")),mxGetN(mxGetField(structure_name, 0, "zmi")));
0262 data.ap = mxGetData(mxGetField(structure_name, 0, "ap"));
0263 data.Rp = mxGetData(mxGetField(structure_name, 0, "Rp"));
0264 data.Zp = mxGetData(mxGetField(structure_name, 0, "Zp"));
0265 data.psia_apRp = mxGetData(mxGetField(structure_name, 0, "psia_apRp"));
0266
0267 return(data);
0268 }
0269
0270 fluctparam_format load_fluct_param(structure_name)
0271 mxArray *structure_name;
0272 {
0273 fluctparam_format data;
0274 int nss,iss,nfield,ifield;
0275 const char *fieldname;
0276 mxArray *tmp,*sub_tmp;
0277
0278 nfield = mxGetNumberOfFields(structure_name);
0279
0280 if (nfield < 9) {
0281 mexPrintf("WARNING: There is no model of plasma fluctuations in the fluct_fit matlab structure !\n",nfield);
0282 } else {
0283
0284 data.ne_nmodel = mxCalloc(1,sizeof(int));
0285 data.ne_nmodel[0] = 0;
0286 data.B_nmodel = mxCalloc(1,sizeof(int));
0287 data.B_nmodel[0] = 0;
0288
0289 for (ifield = 8; ifield < nfield; ifield++){
0290 tmp = mxGetFieldByNumber(structure_name, 0,ifield);
0291 if (mxIsStruct(tmp)) {
0292 fieldname = mxGetFieldNameByNumber(structure_name,ifield);
0293 nss = fmax(mxGetDimensions(tmp)[0],mxGetDimensions(tmp)[1]);
0294
0295 if (strcmp(fieldname,"ne_fit") == 0) {
0296
0297 data.ne_model = mxCalloc(nss,sizeof(double *));
0298 data.ne_sigmar_max = mxCalloc(nss,sizeof(double *));
0299 data.ne_sigmar_hwhm = mxCalloc(nss,sizeof(double *));
0300 data.ne_sigmar_rho = mxCalloc(nss,sizeof(double *));
0301 data.ne_polmode = mxCalloc(nss,sizeof(double *));
0302 data.ne_epsi_rho = mxCalloc(nss,sizeof(double *));
0303 data.ne_epsi_theta = mxCalloc(nss,sizeof(double *));
0304 data.ne_epsi_phi = mxCalloc(nss,sizeof(double *));
0305 data.ne_lmin = mxCalloc(nss,sizeof(double *));
0306 data.ne_mmin = mxCalloc(nss,sizeof(double *));
0307 data.ne_nmin = mxCalloc(nss,sizeof(double *));
0308 data.ne_lmax = mxCalloc(nss,sizeof(double *));
0309 data.ne_mmax = mxCalloc(nss,sizeof(double *));
0310 data.ne_nmax = mxCalloc(nss,sizeof(double *));
0311 data.ne_nphase = mxCalloc(nss,sizeof(int *));
0312
0313 for (iss = 0;iss < nss; iss++) {
0314 data.ne_model[iss] = mxCalloc(1,sizeof(double));
0315 data.ne_sigmar_max[iss] = mxCalloc(1,sizeof(double));
0316 data.ne_sigmar_hwhm[iss] = mxCalloc(1,sizeof(double));
0317 data.ne_sigmar_rho[iss] = mxCalloc(1,sizeof(double));
0318 data.ne_polmode[iss] = mxCalloc(1,sizeof(double));
0319 data.ne_epsi_rho[iss] = mxCalloc(1,sizeof(double));
0320 data.ne_epsi_theta[iss] = mxCalloc(1,sizeof(double));
0321 data.ne_epsi_phi[iss] = mxCalloc(1,sizeof(double));
0322 data.ne_lmin[iss] = mxCalloc(1,sizeof(double));
0323 data.ne_mmin[iss] = mxCalloc(1,sizeof(double));
0324 data.ne_nmin[iss] = mxCalloc(1,sizeof(double));
0325 data.ne_lmax[iss] = mxCalloc(1,sizeof(double));
0326 data.ne_mmax[iss] = mxCalloc(1,sizeof(double));
0327 data.ne_nmax[iss] = mxCalloc(1,sizeof(double));
0328 data.ne_nphase[iss] = mxCalloc(1,sizeof(int));
0329 }
0330
0331 data.ne_nmodel[0] = nss;
0332
0333 for (iss = 0; iss < nss; iss++){
0334 data.ne_model[iss] = mxGetData(mxGetField(tmp, iss, "model"));
0335 data.ne_sigmar_max[iss] = mxGetData(mxGetField(tmp, iss, "sigmar_max"));
0336 data.ne_sigmar_hwhm[iss] = mxGetData(mxGetField(tmp, iss, "sigmar_hwhm"));
0337 data.ne_sigmar_rho[iss] = mxGetData(mxGetField(tmp, iss, "sigmar_rho"));
0338 data.ne_polmode[iss] = mxGetData(mxGetField(tmp, iss, "polmode"));
0339 data.ne_epsi_rho[iss] = mxGetData(mxGetField(tmp, iss, "epsi_rho"));
0340 data.ne_epsi_theta[iss] = mxGetData(mxGetField(tmp, iss, "epsi_theta"));
0341 data.ne_epsi_phi[iss] = mxGetData(mxGetField(tmp, iss, "epsi_phi"));
0342 data.ne_lmin[iss] = mxGetData(mxGetField(tmp, iss, "lmin"));
0343 data.ne_mmin[iss] = mxGetData(mxGetField(tmp, iss, "mmin"));
0344 data.ne_nmin[iss] = mxGetData(mxGetField(tmp, iss, "nmin"));
0345 data.ne_lmax[iss] = mxGetData(mxGetField(tmp, iss, "lmax"));
0346 data.ne_mmax[iss] = mxGetData(mxGetField(tmp, iss, "mmax"));
0347 data.ne_nmax[iss] = mxGetData(mxGetField(tmp, iss, "nmax"));
0348
0349 sub_tmp = mxGetField(tmp, iss, "phase");
0350 data.ne_nphase[iss][0] = fmax(mxGetDimensions(sub_tmp)[0],mxGetDimensions(sub_tmp)[1]);
0351
0352 }
0353
0354 data.ne_phase = mxCalloc(nss,sizeof(double *));
0355
0356 for (iss = 0;iss < nss; iss++) {
0357 data.ne_phase[iss] = mxCalloc(data.ne_nphase[iss][0],sizeof(double));
0358 }
0359
0360 for (iss = 0; iss < nss; iss++){
0361 data.ne_phase[iss] = mxGetData(mxGetField(tmp, iss, "phase"));
0362 }
0363 }
0364
0365 if (strcmp(fieldname,"B_fit") == 0) {
0366
0367 data.B_model = mxCalloc(nss,sizeof(double *));
0368 data.B_sigmar_max = mxCalloc(nss,sizeof(double *));
0369 data.B_sigmar_hwhm = mxCalloc(nss,sizeof(double *));
0370 data.B_sigmar_rho = mxCalloc(nss,sizeof(double *));
0371 data.B_polmode = mxCalloc(nss,sizeof(double *));
0372 data.B_epsi_rho = mxCalloc(nss,sizeof(double *));
0373 data.B_epsi_theta = mxCalloc(nss,sizeof(double *));
0374 data.B_epsi_phi = mxCalloc(nss,sizeof(double *));
0375 data.B_lmin = mxCalloc(nss,sizeof(double *));
0376 data.B_mmin = mxCalloc(nss,sizeof(double *));
0377 data.B_nmin = mxCalloc(nss,sizeof(double *));
0378 data.B_lmax = mxCalloc(nss,sizeof(double *));
0379 data.B_mmax = mxCalloc(nss,sizeof(double *));
0380 data.B_nmax = mxCalloc(nss,sizeof(double *));
0381 data.B_nphase = mxCalloc(nss,sizeof(int *));
0382
0383 for (iss = 0;iss < nss; iss++) {
0384 data.B_model[iss] = mxCalloc(1,sizeof(double));
0385 data.B_sigmar_max[iss] = mxCalloc(1,sizeof(double));
0386 data.B_sigmar_hwhm[iss] = mxCalloc(1,sizeof(double));
0387 data.B_sigmar_rho[iss] = mxCalloc(1,sizeof(double));
0388 data.B_polmode[iss] = mxCalloc(1,sizeof(double));
0389 data.B_epsi_rho[iss] = mxCalloc(1,sizeof(double));
0390 data.B_epsi_theta[iss] = mxCalloc(1,sizeof(double));
0391 data.B_epsi_phi[iss] = mxCalloc(1,sizeof(double));
0392 data.B_lmin[iss] = mxCalloc(1,sizeof(double));
0393 data.B_mmin[iss] = mxCalloc(1,sizeof(double));
0394 data.B_nmin[iss] = mxCalloc(1,sizeof(double));
0395 data.B_lmax[iss] = mxCalloc(1,sizeof(double));
0396 data.B_mmax[iss] = mxCalloc(1,sizeof(double));
0397 data.B_nmax[iss] = mxCalloc(1,sizeof(double));
0398 data.B_nphase[iss] = mxCalloc(1,sizeof(int));
0399 }
0400
0401 data.B_nmodel[0] = nss;
0402
0403 for (iss = 0; iss < nss; iss++){
0404 data.B_model[iss] = mxGetData(mxGetField(tmp, iss, "model"));
0405 data.B_sigmar_max[iss] = mxGetData(mxGetField(tmp, iss, "sigmar_max"));
0406 data.B_sigmar_hwhm[iss] = mxGetData(mxGetField(tmp, iss, "sigmar_hwhm"));
0407 data.B_sigmar_rho[iss] = mxGetData(mxGetField(tmp, iss, "sigmar_rho"));
0408 data.B_polmode[iss] = mxGetData(mxGetField(tmp, iss, "polmode"));
0409 data.B_epsi_rho[iss] = mxGetData(mxGetField(tmp, iss, "epsi_rho"));
0410 data.B_epsi_theta[iss] = mxGetData(mxGetField(tmp, iss, "epsi_theta"));
0411 data.B_epsi_phi[iss] = mxGetData(mxGetField(tmp, iss, "epsi_phi"));
0412 data.B_lmin[iss] = mxGetData(mxGetField(tmp, iss, "lmin"));
0413 data.B_mmin[iss] = mxGetData(mxGetField(tmp, iss, "mmin"));
0414 data.B_nmin[iss] = mxGetData(mxGetField(tmp, iss, "nmin"));
0415 data.B_lmax[iss] = mxGetData(mxGetField(tmp, iss, "lmax"));
0416 data.B_mmax[iss] = mxGetData(mxGetField(tmp, iss, "mmax"));
0417 data.B_nmax[iss] = mxGetData(mxGetField(tmp, iss, "nmax"));
0418
0419 sub_tmp = mxGetField(tmp, iss, "phase");
0420 data.B_nphase[iss][0] = fmax(mxGetDimensions(sub_tmp)[0],mxGetDimensions(sub_tmp)[1]);
0421 }
0422
0423 data.B_phase = mxCalloc(nss,sizeof(double *));
0424
0425 for (iss = 0;iss < nss; iss++) {
0426 data.B_phase[iss] = mxCalloc(data.B_nphase[iss][0],sizeof(double));
0427 }
0428
0429 for (iss = 0; iss < nss; iss++){
0430 data.B_phase[iss] = mxGetData(mxGetField(tmp, iss, "phase"));
0431 }
0432 }
0433
0434 } else {
0435
0436 }
0437 }
0438 }
0439
0440 return(data);
0441 }
0442
0443 pp_0D_format load_value_0D(structure_name,field_name)
0444 mxArray *structure_name;
0445 char *field_name;
0446 {
0447 mxArray *tmp;
0448 pp_0D_format fit;
0449
0450 fit.data = mxGetData(mxGetField(structure_name, 0, field_name));
0451
0452 return(fit);
0453 }
0454
0455
0456 pp_1D_format load_profile_1D(structure_name,field_name)
0457 mxArray *structure_name;
0458 char *field_name;
0459 {
0460 mxArray *tmp,*sub_tmp;
0461 pp_1D_format fit;
0462
0463 tmp = mxGetField(structure_name, 0, field_name);
0464 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,0));
0465 if (mxIsStruct(sub_tmp)) {
0466 fit.form_f = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0467 fit.breaks_f = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0468 fit.coefs_f = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0469 fit.pieces_f = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0470 fit.order_f = mxGetData(mxGetField(sub_tmp, 0, "order"));
0471 fit.dim_f = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0472 fit.orient_f = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0473 }
0474
0475 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,1));
0476 if (mxIsStruct(sub_tmp)) {
0477 fit.form_dfdrho = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0478 fit.breaks_dfdrho = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0479 fit.coefs_dfdrho = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0480 fit.pieces_dfdrho = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0481 fit.order_dfdrho = mxGetData(mxGetField(sub_tmp, 0, "order"));
0482 fit.dim_dfdrho = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0483 fit.orient_dfdrho = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0484 }
0485
0486 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,2));
0487 if (mxIsStruct(sub_tmp)) {
0488 fit.form_d2fdrho2 = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0489 fit.breaks_d2fdrho2 = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0490 fit.coefs_d2fdrho2 = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0491 fit.pieces_d2fdrho2 = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0492 fit.order_d2fdrho2 = mxGetData(mxGetField(sub_tmp, 0, "order"));
0493 fit.dim_d2fdrho2 = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0494 fit.orient_d2fdrho2 = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0495 }
0496
0497 return(fit);
0498 }
0499
0500 pp_2D_format load_grid_2D(structure_name,field_name,is)
0501 mxArray *structure_name;
0502 char *field_name;
0503 int is;
0504 {
0505 mxArray *tmp,*sub_tmp;
0506 pp_2D_format fit;
0507
0508 tmp = mxGetField(structure_name, is, field_name);
0509
0510 fit.n = mxGetData(mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,0)));
0511
0512 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,1));
0513 if (mxIsStruct(sub_tmp)) {
0514 fit.form_a0 = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0515 fit.breaks_a0 = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0516 fit.coefs_a0 = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0517 fit.pieces_a0 = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0518 fit.order_a0 = mxGetData(mxGetField(sub_tmp, 0, "order"));
0519 fit.dim_a0 = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0520 fit.orient_a0 = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0521 }
0522
0523 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,4));
0524 if (mxIsStruct(sub_tmp)) {
0525 fit.form_da0drho = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0526 fit.breaks_da0drho = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0527 fit.coefs_da0drho = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0528 fit.pieces_da0drho = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0529 fit.order_da0drho = mxGetData(mxGetField(sub_tmp, 0, "order"));
0530 fit.dim_da0drho = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0531 fit.orient_da0drho = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0532 }
0533
0534 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,7));
0535 if (mxIsStruct(sub_tmp)) {
0536 fit.form_d2a0drho2 = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0537 fit.breaks_d2a0drho2 = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0538 fit.coefs_d2a0drho2 = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0539 fit.pieces_d2a0drho2 = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0540 fit.order_d2a0drho2 = mxGetData(mxGetField(sub_tmp, 0, "order"));
0541 fit.dim_d2a0drho2 = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0542 fit.orient_d2a0drho2 = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0543 }
0544
0545 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,2));
0546 if (mxIsStruct(sub_tmp)) {
0547 fit.form_an = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0548 fit.breaks_an = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0549 fit.coefs_an = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0550 fit.pieces_an = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0551 fit.order_an = mxGetData(mxGetField(sub_tmp, 0, "order"));
0552 fit.dim_an = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0553 fit.orient_an = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0554 }
0555
0556 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,5));
0557 if (mxIsStruct(sub_tmp)) {
0558 fit.form_dandrho = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0559 fit.breaks_dandrho = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0560 fit.coefs_dandrho = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0561 fit.pieces_dandrho = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0562 fit.order_dandrho = mxGetData(mxGetField(sub_tmp, 0, "order"));
0563 fit.dim_dandrho = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0564 fit.orient_dandrho = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0565 }
0566
0567 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,8));
0568 if (mxIsStruct(sub_tmp)) {
0569 fit.form_d2andrho2 = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0570 fit.breaks_d2andrho2 = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0571 fit.coefs_d2andrho2 = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0572 fit.pieces_d2andrho2 = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0573 fit.order_d2andrho2 = mxGetData(mxGetField(sub_tmp, 0, "order"));
0574 fit.dim_d2andrho2 = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0575 fit.orient_d2andrho2 = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0576 }
0577
0578 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,3));
0579 if (mxIsStruct(sub_tmp)) {
0580 fit.form_bn = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0581 fit.breaks_bn = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0582 fit.coefs_bn = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0583 fit.pieces_bn = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0584 fit.order_bn = mxGetData(mxGetField(sub_tmp, 0, "order"));
0585 fit.dim_bn = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0586 fit.orient_bn = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0587 }
0588
0589 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,6));
0590 if (mxIsStruct(sub_tmp)) {
0591 fit.form_dbndrho = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0592 fit.breaks_dbndrho = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0593 fit.coefs_dbndrho = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0594 fit.pieces_dbndrho = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0595 fit.order_dbndrho = mxGetData(mxGetField(sub_tmp, 0, "order"));
0596 fit.dim_dbndrho = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0597 fit.orient_dbndrho = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0598 }
0599
0600 sub_tmp = mxGetField(tmp, 0, mxGetFieldNameByNumber(tmp,9));
0601 if (mxIsStruct(sub_tmp)) {
0602 fit.form_d2bndrho2 = mxGetChars(mxGetField(sub_tmp, 0, "form"));
0603 fit.breaks_d2bndrho2 = mxGetData(mxGetField(sub_tmp, 0, "breaks"));
0604 fit.coefs_d2bndrho2 = mxGetData(mxGetField(sub_tmp, 0, "coefs"));
0605 fit.pieces_d2bndrho2 = mxGetData(mxGetField(sub_tmp, 0, "pieces"));
0606 fit.order_d2bndrho2 = mxGetData(mxGetField(sub_tmp, 0, "order"));
0607 fit.dim_d2bndrho2 = mxGetData(mxGetField(sub_tmp, 0, "dim"));
0608 fit.orient_d2bndrho2 = mxGetChars(mxGetField(sub_tmp, 0, "orient"));
0609 }
0610
0611
0612 return(fit);
0613 }
0614