Max 5 API Reference
00001 /* 00002 * Copyright 2001-2005 - Cycling '74 00003 * Derek Gerstmann - derek@cycling74.com 00004 * 00005 * Evaluation over n-dim using regularly spaced linearly interpolated 00006 * sampling. 00007 * 00008 */ 00009 00010 /*************************************************************************/ 00011 00012 #include "jit.common.h" 00013 #include "jit.functor.h" 00014 00015 /*************************************************************************/ 00016 00017 typedef struct _jit_functor_sampler_regular_vecdata_fixed 00018 { 00019 long coord[JIT_MATRIX_MAX_DIMCOUNT]; // coordinates 00020 long offset[JIT_MATRIX_MAX_DIMCOUNT]; // offsets 00021 long step[JIT_MATRIX_MAX_DIMCOUNT]; // increments 00022 00023 } t_jit_functor_sampler_regular_vecdata_fixed; 00024 00025 typedef struct _jit_functor_sampler_regular_vecdata_float32 00026 { 00027 float coord[JIT_MATRIX_MAX_DIMCOUNT]; // coordinates 00028 float offset[JIT_MATRIX_MAX_DIMCOUNT]; // offsets 00029 float step[JIT_MATRIX_MAX_DIMCOUNT]; // increments 00030 00031 } t_jit_functor_sampler_regular_vecdata_float32; 00032 00033 typedef struct _jit_functor_sampler_regular_vecdata_float64 00034 { 00035 double coord[JIT_MATRIX_MAX_DIMCOUNT]; // coordinates 00036 double offset[JIT_MATRIX_MAX_DIMCOUNT]; // offsets 00037 double step[JIT_MATRIX_MAX_DIMCOUNT]; // increments 00038 00039 } t_jit_functor_sampler_regular_vecdata_float64; 00040 00041 typedef struct _jit_functor_sampler_regular_vecdata 00042 { 00043 t_jit_functor_sampler_regular_vecdata_fixed vfixed; // fixed vecdata 00044 t_jit_functor_sampler_regular_vecdata_float32 vfloat32; // float32 vecdata 00045 t_jit_functor_sampler_regular_vecdata_float64 vfloat64; // float64 veecdata 00046 00047 } t_jit_functor_sampler_regular_vecdata; 00048 00049 00050 /*************************************************************************/ 00051 00052 // the classname object 00053 typedef struct _jit_functor_sampler_regular 00054 { 00055 t_object ob; 00056 00057 // dimensional offsets 00058 double offset[JIT_MATRIX_MAX_DIMCOUNT]; 00059 00060 // dimensional scale factors 00061 double scale[JIT_MATRIX_MAX_DIMCOUNT]; 00062 00063 // dimensional step factors 00064 double step[JIT_MATRIX_MAX_DIMCOUNT]; 00065 00066 // matrix state info 00067 long dimcount; 00068 long planecount; 00069 00070 // matrix calc update flag 00071 long update; 00072 00073 // vector evaluation data 00074 t_jit_functor_sampler_regular_vecdata vecdata; 00075 00076 } t_jit_functor_eval; 00077 00078 void *_jit_functor_sampler_regular_class; 00079 00080 /*************************************************************************/ 00081 00082 t_jit_err jit_functor_sampler_regular_init(void); 00083 t_jit_functor_eval *jit_functor_sampler_regular_new(void); 00084 void jit_functor_sampler_regular_free(t_jit_functor_eval *x); 00085 void jit_functor_sampler_regular_recalc(t_jit_functor_eval *x); 00086 00087 t_jit_err jit_functor_sampler_regular_setattr_scale(t_jit_functor_eval *x, void *attr, long argc, t_atom *argv); 00088 t_jit_err jit_functor_sampler_regular_setattr_offset(t_jit_functor_eval *x, void *attr, long argc, t_atom *argv); 00089 00090 t_jit_err jit_functor_sampler_regular_matrix_calc( 00091 t_jit_functor_eval *x, void *inputs, void *outputs); 00092 00093 void jit_functor_sampler_regular_calculate_ndim( 00094 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00095 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w); 00096 00097 void jit_functor_sampler_regular_calculate_char_ndim_recurse( 00098 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00099 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w, 00100 t_jit_functor_sampler_regular_vecdata_fixed *vp); 00101 00102 void jit_functor_sampler_regular_calculate_long_ndim_recurse( 00103 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00104 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w, 00105 t_jit_functor_sampler_regular_vecdata_fixed *vp); 00106 00107 void jit_functor_sampler_regular_calculate_float32_ndim_recurse( 00108 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00109 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w, 00110 t_jit_functor_sampler_regular_vecdata_float32 *vp); 00111 00112 void jit_functor_sampler_regular_calculate_float64_ndim_recurse( 00113 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00114 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w, 00115 t_jit_functor_sampler_regular_vecdata_float64 *vp); 00116 00117 void jit_functor_sampler_regular_vector_char( 00118 t_jit_functor_eval *x, long n, t_jit_functor_sampler_regular_vecdata_fixed *v, 00119 t_jit_op_info *out, t_jit_parallel_ndim_worker *w); 00120 00121 void jit_functor_sampler_regular_vector_long( 00122 t_jit_functor_eval *x, long n, t_jit_functor_sampler_regular_vecdata_fixed *v, 00123 t_jit_op_info *out, t_jit_parallel_ndim_worker *w); 00124 00125 void jit_functor_sampler_regular_vector_float32( 00126 t_jit_functor_eval *x, long n, t_jit_functor_sampler_regular_vecdata_float32 *v, 00127 t_jit_op_info *out, t_jit_parallel_ndim_worker *w); 00128 00129 void jit_functor_sampler_regular_vector_float64( 00130 t_jit_functor_eval *x, long n, t_jit_functor_sampler_regular_vecdata_float64 *v, 00131 t_jit_op_info *out, t_jit_parallel_ndim_worker *w); 00132 00133 /*************************************************************************/ 00134 00135 t_jit_err jit_functor_sampler_regular_init(void) 00136 { 00137 long attrflags=0; 00138 void *mop, *attr; 00139 00140 // create class 00141 _jit_functor_sampler_regular_class = jit_class_new("jit_functor_sampler_regular", 00142 (method)jit_functor_sampler_regular_new,(method)jit_functor_sampler_regular_free, 00143 sizeof(t_jit_functor_eval),0L); 00144 00145 // add mop 00146 mop = jit_object_new(_jit_sym_jit_mop,0,1); 00147 jit_class_addadornment(_jit_functor_sampler_regular_class,mop); 00148 00149 // add matrix methods 00150 jit_class_addmethod(_jit_functor_sampler_regular_class, (method)jit_functor_sampler_regular_matrix_calc, "matrix_calc", A_CANT, 0L); 00151 00152 //user opaque attributes 00153 attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW; 00154 attr = jit_object_new(_jit_sym_jit_attr_offset_array,"offset",_jit_sym_float64,JIT_MATRIX_MAX_DIMCOUNT,attrflags, 00155 (method)0L,(method)jit_functor_sampler_regular_setattr_offset,NULL/*fixed*/,calcoffset(t_jit_functor_eval,offset)); 00156 jit_class_addattr(_jit_functor_sampler_regular_class,attr); 00157 attr = jit_object_new(_jit_sym_jit_attr_offset_array,"scale",_jit_sym_float64,JIT_MATRIX_MAX_DIMCOUNT,attrflags, 00158 (method)0L,(method)jit_functor_sampler_regular_setattr_scale,NULL/*fixed*/,calcoffset(t_jit_functor_eval,scale)); 00159 jit_class_addattr(_jit_functor_sampler_regular_class,attr); 00160 00161 // register class 00162 jit_class_register(_jit_functor_sampler_regular_class); 00163 return JIT_ERR_NONE; 00164 } 00165 00166 t_jit_functor_eval *jit_functor_sampler_regular_new(void) 00167 { 00168 long i, p; 00169 t_jit_functor_eval *x; 00170 00171 if (x=(t_jit_functor_eval *)jit_object_alloc(_jit_functor_sampler_regular_class)) { 00172 00173 x->update = TRUE; 00174 00175 // init object 00176 jit_functor_sampler_regular_recalc(x); 00177 00178 } else { 00179 x = NULL; 00180 } 00181 return x; 00182 } 00183 00184 void jit_functor_sampler_regular_free(t_jit_functor_eval *x) 00185 { 00186 // zippo 00187 return; 00188 } 00189 00190 /*************************************************************************/ 00191 00192 void jit_functor_sampler_regular_recalc( t_jit_functor_eval *x ) 00193 { 00194 // reset update flag 00195 x->update = TRUE; 00196 } 00197 00198 t_jit_err jit_functor_sampler_regular_setattr_offset(t_jit_functor_eval *x, void *attr, long argc, t_atom *argv) 00199 { 00200 long i; 00201 double v; 00202 char changed = FALSE; // changed flag 00203 00204 if (x) { 00205 for(i = 0; i < argc && i < JIT_MATRIX_MAX_DIMCOUNT; i++) 00206 { 00207 v = jit_atom_getfloat(argv+i); 00208 00209 if(x->offset[i] != v) { 00210 x->offset[i] = v; 00211 changed = TRUE; 00212 } 00213 } 00214 if(changed) 00215 jit_functor_sampler_regular_recalc(x); 00216 00217 return JIT_ERR_NONE; 00218 } 00219 return JIT_ERR_INVALID_PTR; 00220 } 00221 00222 t_jit_err jit_functor_sampler_regular_setattr_scale(t_jit_functor_eval *x, void *attr, long argc, t_atom *argv) 00223 { 00224 long i; 00225 double v; 00226 char changed = FALSE; // changed flag 00227 00228 if (x) { 00229 for(i = 0; i < argc && i < JIT_MATRIX_MAX_DIMCOUNT; i++) 00230 { 00231 v = jit_atom_getfloat(argv+i); 00232 00233 if(x->scale[i] != v) { 00234 x->scale[i] = v; 00235 changed = TRUE; 00236 } 00237 } 00238 if(changed) 00239 jit_functor_sampler_regular_recalc(x); 00240 00241 return JIT_ERR_NONE; 00242 } 00243 return JIT_ERR_INVALID_PTR; 00244 } 00245 00246 /*************************************************************************/ 00247 00248 t_jit_err jit_functor_sampler_regular_matrix_calc(t_jit_functor_eval *x, void *inputs, void *outputs) 00249 { 00250 t_jit_err err=JIT_ERR_NONE; 00251 long out_savelock; 00252 t_jit_matrix_info out_minfo; 00253 char *out_bp; 00254 long i,dimcount,planecount,dim[JIT_MATRIX_MAX_DIMCOUNT]; 00255 void *out_matrix; 00256 00257 out_matrix = jit_object_method(outputs,_jit_sym_getindex,0); 00258 00259 if (out_matrix && x && x->update) { 00260 out_savelock = (long) jit_object_method(out_matrix,_jit_sym_lock,1); 00261 00262 jit_object_method(out_matrix,_jit_sym_getinfo,&out_minfo); 00263 jit_object_method(out_matrix,_jit_sym_getdata,&out_bp); 00264 00265 if (!out_bp) { err=JIT_ERR_INVALID_OUTPUT; goto out;} 00266 00267 // get dimensions/planecount 00268 x->dimcount = out_minfo.dimcount; 00269 x->planecount = out_minfo.planecount; 00270 00271 // initialize dimensions and vecdata 00272 for( i = 0 ; i < x->dimcount; i++) { 00273 00274 dim[i] = out_minfo.dim[i]; 00275 00276 if(dim[i] != 0) 00277 x->step[i] = x->scale[i] * 1.0 / (dim[i] - 1.0); 00278 else 00279 x->step[i] = x->scale[i]; 00280 } 00281 00282 // evaluate 00283 jit_parallel_ndim_simplecalc1((method)jit_functor_sampler_regular_calculate_ndim, 00284 x, out_minfo.dimcount, out_minfo.dim, out_minfo.planecount, 00285 &out_minfo, out_bp, 0 ); 00286 00287 // reset update flag 00288 x->update = FALSE; 00289 00290 } else if(x == NULL){ 00291 return JIT_ERR_INVALID_PTR; 00292 } 00293 00294 out: 00295 jit_object_method(out_matrix,gensym("lock"),out_savelock); 00296 return err; 00297 } 00298 00299 void jit_functor_sampler_regular_calculate_ndim( 00300 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00301 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w) 00302 { 00303 long i; 00304 t_jit_functor_sampler_regular_vecdata_fixed vecfixed; 00305 t_jit_functor_sampler_regular_vecdata_float32 vecfloat32; 00306 t_jit_functor_sampler_regular_vecdata_float64 vecfloat64; 00307 00308 if( dimcount < 1 ) return; //safety 00309 00310 if (out_minfo->type == _jit_sym_char) 00311 { 00312 // initialize dimensions and vecdata 00313 for( i = 0 ; i < dimcount; i++) { 00314 vecfixed.offset[i] = DoubleToFixed(x->offset[i]); 00315 vecfixed.step[i] = DoubleToFixed(x->step[i]); 00316 vecfixed.coord[i] = FloatToFixed(FixedToFloat(vecfixed.offset[i]) + w->offset[i] * FixedToFloat(vecfixed.step[i])); 00317 } 00318 00319 // perform recursive evaluation 00320 jit_functor_sampler_regular_calculate_char_ndim_recurse(x, dimcount, dim, planecount, out_minfo, bop, w, &vecfixed); 00321 } 00322 else if (out_minfo->type == _jit_sym_long) 00323 { 00324 // initialize dimensions and vecdata 00325 for( i = 0 ; i < dimcount; i++) { 00326 vecfixed.offset[i] = DoubleToFixed(x->offset[i]); 00327 vecfixed.step[i] = DoubleToFixed(x->step[i]); 00328 vecfixed.coord[i] = FloatToFixed(FixedToFloat(vecfixed.offset[i]) + w->offset[i] * FixedToFloat(vecfixed.step[i])); 00329 } 00330 00331 // perform recursive evaluation 00332 jit_functor_sampler_regular_calculate_long_ndim_recurse(x, dimcount, dim, planecount, out_minfo, bop, w, &vecfixed); 00333 } 00334 else if (out_minfo->type == _jit_sym_float32) 00335 { 00336 // initialize dimensions and vecdata 00337 for( i = 0 ; i < dimcount; i++) { 00338 vecfloat32.offset[i] = (float)x->offset[i]; 00339 vecfloat32.step[i] = (float)x->step[i]; 00340 vecfloat32.coord[i] = vecfloat32.offset[i] + w->offset[i] * vecfloat32.step[i]; 00341 } 00342 00343 // perform recursive evaluation 00344 jit_functor_sampler_regular_calculate_float32_ndim_recurse(x, dimcount, dim, planecount, out_minfo, bop, w, &vecfloat32); 00345 } 00346 else if (out_minfo->type == _jit_sym_float64) 00347 { 00348 // initialize dimensions and vecdata 00349 for( i = 0 ; i < dimcount; i++) { 00350 vecfloat64.offset[i] = (double)x->offset[i]; 00351 vecfloat64.step[i] = (double)x->step[i]; 00352 vecfloat64.coord[i] = vecfloat64.offset[i] + w->offset[i] * vecfloat64.step[i]; 00353 } 00354 00355 // perform recursive evaluation 00356 jit_functor_sampler_regular_calculate_float64_ndim_recurse(x, dimcount, dim, planecount, out_minfo, bop, w, &vecfloat64); 00357 } 00358 } 00359 00360 void jit_functor_sampler_regular_calculate_char_ndim_recurse( 00361 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00362 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w, 00363 t_jit_functor_sampler_regular_vecdata_fixed *vp) 00364 { 00365 char *cop,*op; 00366 long i,j,n,p,tmp; 00367 t_jit_op_info out_opinfo; 00368 00369 // initialize dimensions and vecdata 00370 switch( dimcount ){ 00371 case 1: 00372 // set y dimension to 1 and evaluate in 2d 00373 dim[1] = 1; 00374 00375 case 2: 00376 00377 n = dim[0]; 00378 out_opinfo.stride = 1; 00379 00380 // evaluate 2d slice 00381 for (i=0;i<dim[1];i++){ 00382 00383 // get offset buffer pointer 00384 out_opinfo.p = bop + i*out_minfo->dimstride[1]; 00385 00386 // calculate coordinates 00387 if(i == 0) 00388 vp->coord[1] = FloatToFixed(FixedToFloat(vp->offset[1]) + w->offset[1] * FixedToFloat(vp->step[1])); 00389 else 00390 vp->coord[1] += vp->step[1]; 00391 00392 // evaluate 2d vector 00393 jit_functor_sampler_regular_vector_char(x, n, vp, &out_opinfo, w); 00394 } 00395 break; 00396 00397 default: 00398 00399 // recursively evaluate 00400 for (i=0;i<dim[dimcount-1];i++) { 00401 00402 // get offset buffer pointer 00403 cop = bop + i*out_minfo->dimstride[dimcount-1]; 00404 00405 // calculate coordinates 00406 if(i == 0) { 00407 vp->coord[dimcount-1] = FloatToFixed(FixedToFloat(vp->offset[dimcount-1]) + w->offset[dimcount-1] * FixedToFloat(vp->step[dimcount-1])); 00408 } else { 00409 vp->coord[dimcount-1] += vp->step[dimcount-1]; 00410 } 00411 00412 // evaluate recursively 00413 jit_functor_sampler_regular_calculate_char_ndim_recurse(x, dimcount-1, dim, planecount, out_minfo, cop, w, vp); 00414 } 00415 break; 00416 }; 00417 } 00418 00419 void jit_functor_sampler_regular_calculate_long_ndim_recurse( 00420 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00421 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w, 00422 t_jit_functor_sampler_regular_vecdata_fixed *vp) 00423 { 00424 char *cop,*op; 00425 long i,j,n,p,tmp; 00426 t_jit_op_info out_opinfo; 00427 00428 // initialize dimensions and vecdata 00429 switch( dimcount ){ 00430 case 1: 00431 00432 // set y dimension to 1 and evaluate in 2d 00433 dim[1] = 1; 00434 00435 case 2: 00436 00437 n = dim[0]; 00438 out_opinfo.stride = 1; 00439 00440 // evaluate 2d slice 00441 for (i=0;i<dim[1];i++){ 00442 00443 // get offset buffer pointer 00444 out_opinfo.p = bop + i*out_minfo->dimstride[1]; 00445 00446 // calculate coordinates 00447 if(i == 0) 00448 vp->coord[1] = FloatToFixed(FixedToFloat(vp->offset[1]) + w->offset[1] * FixedToFloat(vp->step[1])); 00449 else 00450 vp->coord[1] += vp->step[1]; 00451 00452 // evaluate 2d vector 00453 jit_functor_sampler_regular_vector_long(x, n, vp, &out_opinfo, w); 00454 } 00455 break; 00456 00457 default: 00458 00459 // recursively evaluate 00460 for (i=0;i<dim[dimcount-1];i++) { 00461 00462 // get offset buffer pointer 00463 cop = bop + i*out_minfo->dimstride[dimcount-1]; 00464 00465 // calculate coordinates 00466 if(i == 0) { 00467 vp->coord[dimcount-1] = FloatToFixed(FixedToFloat(vp->offset[dimcount-1]) + w->offset[dimcount-1] * FixedToFloat(vp->step[dimcount-1])); 00468 } else { 00469 vp->coord[dimcount-1] += vp->step[dimcount-1]; 00470 } 00471 00472 // evaluate recursively 00473 jit_functor_sampler_regular_calculate_long_ndim_recurse(x, dimcount-1, dim, planecount, out_minfo, cop, w, vp); 00474 } 00475 break; 00476 }; 00477 } 00478 00479 void jit_functor_sampler_regular_calculate_float32_ndim_recurse( 00480 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00481 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w, 00482 t_jit_functor_sampler_regular_vecdata_float32 *vp) 00483 { 00484 char *cop,*op; 00485 long i,j,n,p,tmp; 00486 t_jit_op_info out_opinfo; 00487 00488 00489 // initialize dimensions and vecdata 00490 switch( dimcount ){ 00491 case 1: 00492 // set y dimension to 1 and evaluate in 2d 00493 dim[1] = 1; 00494 00495 case 2: 00496 00497 n = dim[0]; 00498 out_opinfo.stride = 1; 00499 00500 // evaluate 2d slice 00501 for (i=0;i<dim[1];i++){ 00502 00503 // get offset buffer pointer 00504 out_opinfo.p = bop + i*out_minfo->dimstride[1]; 00505 00506 // calculate coordinates 00507 if(i == 0) 00508 vp->coord[1] = vp->offset[1] + w->offset[1] * vp->step[1]; 00509 else 00510 vp->coord[1] += vp->step[1]; 00511 00512 // evaluate 2d vector 00513 jit_functor_sampler_regular_vector_float32(x, n, vp, &out_opinfo, w); 00514 } 00515 break; 00516 00517 default: 00518 00519 // recursively evaluate 00520 for (i=0;i<dim[dimcount-1];i++) { 00521 00522 // get offset buffer pointer 00523 cop = bop + i*out_minfo->dimstride[dimcount-1]; 00524 00525 // calculate coordinates 00526 if(i == 0) { 00527 vp->coord[dimcount-1] = vp->offset[dimcount-1] + w->offset[dimcount-1] * vp->step[dimcount-1]; 00528 } else { 00529 vp->coord[dimcount-1] += vp->step[dimcount-1]; 00530 } 00531 00532 // evaluate recursively 00533 jit_functor_sampler_regular_calculate_float32_ndim_recurse(x, dimcount-1, dim, planecount, out_minfo, cop, w, vp); 00534 } 00535 break; 00536 }; 00537 } 00538 00539 void jit_functor_sampler_regular_calculate_float64_ndim_recurse( 00540 t_jit_functor_eval *x, long dimcount, long *dim, long planecount, 00541 t_jit_matrix_info *out_minfo, char *bop, t_jit_parallel_ndim_worker *w, 00542 t_jit_functor_sampler_regular_vecdata_float64 *vp) 00543 { 00544 char *cop,*op; 00545 long i,j,n,p,tmp; 00546 t_jit_op_info out_opinfo; 00547 00548 00549 // initialize dimensions and vecdata 00550 switch( dimcount ){ 00551 case 1: 00552 // set y dimension to 1 and evaluate in 2d 00553 dim[1] = 1; 00554 00555 case 2: 00556 00557 n = dim[0]; 00558 out_opinfo.stride = 1; 00559 00560 // evaluate 2d slice 00561 for (i=0;i<dim[1];i++){ 00562 00563 // get offset buffer pointer 00564 out_opinfo.p = bop + i*out_minfo->dimstride[1]; 00565 00566 // calculate coordinates 00567 if(i == 0) 00568 vp->coord[1] = vp->offset[1] + w->offset[1] * vp->step[1]; 00569 else 00570 vp->coord[1] += vp->step[1]; 00571 00572 // evaluate 2d vector 00573 jit_functor_sampler_regular_vector_float64(x, n, vp, &out_opinfo, w); 00574 } 00575 break; 00576 00577 default: 00578 00579 // recursively evaluate 00580 for (i=0;i<dim[dimcount-1];i++) { 00581 00582 // get offset buffer pointer 00583 cop = bop + i*out_minfo->dimstride[dimcount-1]; 00584 00585 // calculate coordinates 00586 if(i == 0) { 00587 vp->coord[dimcount-1] = vp->offset[dimcount-1] + w->offset[dimcount-1] * vp->step[dimcount-1]; 00588 } else { 00589 vp->coord[dimcount-1] += vp->step[dimcount-1]; 00590 } 00591 00592 // evaluate recursively 00593 jit_functor_sampler_regular_calculate_float64_ndim_recurse(x, dimcount-1, dim, planecount, out_minfo, cop, w, vp); 00594 } 00595 break; 00596 }; 00597 } 00598 /*************************************************************************/ 00599 00600 void jit_functor_sampler_regular_vector_char( 00601 t_jit_functor_eval *x, long n, t_jit_functor_sampler_regular_vecdata_fixed *v, 00602 t_jit_op_info *out, t_jit_parallel_ndim_worker *w) 00603 { 00604 long i, j, d, p; 00605 long os; 00606 uchar *op; 00607 long val; 00608 long pos[JIT_MATRIX_MAX_DIMCOUNT]; 00609 00610 op = ((uchar *)out->p); 00611 os = out->stride; 00612 00613 for (i = 0; i < n; i++) 00614 { 00615 // calculate current coordinate 00616 if(i == 0) { 00617 v->coord[0] = FloatToFixed(FixedToFloat(v->offset[0]) + w->offset[0] * FixedToFloat(v->step[0])); 00618 } else { 00619 v->coord[0] += v->step[0]; 00620 } 00621 00622 if(x->planecount > 1) 00623 { 00624 // apply dimensional coordinate to planar data 00625 for (p = 0; p < x->planecount && p < x->dimcount; p++) { 00626 op[p] = v->coord[p]; 00627 } 00628 op += x->planecount; 00629 } 00630 else 00631 { 00632 *op = v->coord[0]; 00633 op += os; 00634 } 00635 } 00636 } 00637 00638 void jit_functor_sampler_regular_vector_long( 00639 t_jit_functor_eval *x, long n, t_jit_functor_sampler_regular_vecdata_fixed *v, 00640 t_jit_op_info *out, t_jit_parallel_ndim_worker *w) 00641 { 00642 long i, j, d, p; 00643 long os; 00644 long *op; 00645 long val; 00646 long pos[JIT_MATRIX_MAX_DIMCOUNT]; 00647 00648 op = ((long *)out->p); 00649 os = out->stride; 00650 00651 for (i = 0; i < n; i++) 00652 { 00653 // calculate current coordinate 00654 if(i == 0) { 00655 v->coord[0] = FloatToFixed(FixedToFloat(v->offset[0]) + w->offset[0] * FixedToFloat(v->step[0])); 00656 } else { 00657 v->coord[0] += v->step[0]; 00658 } 00659 00660 if(x->planecount > 1) 00661 { 00662 // apply dimensional coordinate to planar data 00663 for (p = 0; p < x->planecount && p < x->dimcount; p++) { 00664 op[p] = v->coord[p]; 00665 } 00666 op += x->planecount; 00667 } 00668 else 00669 { 00670 *op = v->coord[0]; 00671 op += os; 00672 } 00673 } 00674 } 00675 00676 void jit_functor_sampler_regular_vector_float32( 00677 t_jit_functor_eval *x, long n, t_jit_functor_sampler_regular_vecdata_float32 *v, 00678 t_jit_op_info *out, t_jit_parallel_ndim_worker *w) 00679 { 00680 long i, j, d, p; 00681 long os; 00682 float *op; 00683 float val; 00684 float pos[JIT_MATRIX_MAX_DIMCOUNT]; 00685 00686 op = ((float *)out->p); 00687 os = out->stride; 00688 00689 for (i = 0; i < n; i++) 00690 { 00691 // calculate current coordinate 00692 if(i == 0) { 00693 v->coord[0] = w->offset[0] * v->step[0] + v->offset[0]; 00694 } else { 00695 v->coord[0] += v->step[0]; 00696 } 00697 00698 if(x->planecount > 1) 00699 { 00700 // apply dimensional coordinate to planar data 00701 for (p = 0; p < x->planecount && p < x->dimcount; p++) { 00702 op[p] = v->coord[p]; 00703 } 00704 op += x->planecount; 00705 } 00706 else 00707 { 00708 *op = v->coord[0]; 00709 op += os; 00710 } 00711 } 00712 } 00713 00714 void jit_functor_sampler_regular_vector_float64( 00715 t_jit_functor_eval *x, long n, t_jit_functor_sampler_regular_vecdata_float64 *v, 00716 t_jit_op_info *out, t_jit_parallel_ndim_worker *w) 00717 { 00718 long i, j, d, p; 00719 long os; 00720 double *op; 00721 double val; 00722 double pos[JIT_MATRIX_MAX_DIMCOUNT]; 00723 00724 op = ((double *)out->p); 00725 os = out->stride; 00726 00727 for (i = 0; i < n; i++) 00728 { 00729 // calculate current coordinate 00730 if(i == 0) { 00731 v->coord[0] = w->offset[0] * v->step[0] + v->offset[0]; 00732 } else { 00733 v->coord[0] += v->step[0]; 00734 } 00735 00736 if(x->planecount > 1) 00737 { 00738 // apply dimensional coordinate to planar data 00739 for (p = 0; p < x->planecount && p < x->dimcount; p++) { 00740 op[p] = v->coord[p]; 00741 } 00742 op += x->planecount; 00743 } 00744 else 00745 { 00746 *op = v->coord[0]; 00747 op += os; 00748 } 00749 } 00750 } 00751 00752 /*************************************************************************/
Copyright © 2008, Cycling '74