#include <math.h>#include <stdio.h>#include <netcdf.h>#include "nco_netcdf.h"#include "nco.h"#include "nco_cnf_typ.h"Include dependency graph for nco_var_scv.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| void | var_scv_add (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, ptr_unn op1, scv_sct *scv) |
| void | var_scv_mlt (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, ptr_unn op1, scv_sct *scv) |
| void | var_scv_mod (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, ptr_unn op1, scv_sct *scv) |
| void | scv_var_mod (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, scv_sct *scv, ptr_unn op2) |
| void | var_scv_dvd (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, ptr_unn op1, scv_sct *scv) |
| void | scv_var_dvd (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, scv_sct *scv, ptr_unn op2) |
| void | var_scv_pwr (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, ptr_unn op1, scv_sct *scv) |
| void | scv_var_pwr (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, scv_sct *scv, ptr_unn op2) |
| void | var_scv_sub (const nc_type type, const long sz, const int has_mss_val, ptr_unn mss_val, ptr_unn op1, scv_sct *scv) |
|
||||||||||||||||||||||||||||
|
Definition at line 349 of file nco_var_scv.c. References cast_void_nctype(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), and type. Referenced by ncap_scv_var_dvd(). 00355 { 00356 /* Threads: Routine is thread safe and calls no unsafe routines */ 00357 /* Purpose: Divide all values in scv by op2 00358 Store result in second operand */ 00359 00360 /* Scalar-variable division is currently defined as op2:=scv/op2 */ 00361 00362 long idx; 00363 00364 /* Typecast pointer to values before access */ 00365 (void)cast_void_nctype(type,&op2); 00366 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00367 00368 switch(type){ 00369 case NC_FLOAT:{ 00370 const float scv_flt=scv->val.f; 00371 if(!has_mss_val){ 00372 for(idx=0;idx<sz;idx++) op2.fp[idx]=scv_flt/op2.fp[idx]; 00373 }else{ 00374 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00375 for(idx=0;idx<sz;idx++){ 00376 if(op2.fp[idx] != mss_val_flt) op2.fp[idx]=scv_flt/op2.fp[idx]; 00377 } /* end for */ 00378 } /* end else */ 00379 break; 00380 } /* endif NC_FLOAT */ 00381 case NC_DOUBLE:{ 00382 const double scv_dbl=scv->val.d; 00383 if(!has_mss_val){ 00384 for(idx=0;idx<sz;idx++) op2.dp[idx]=scv_dbl/op2.dp[idx]; 00385 }else{ 00386 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00387 for(idx=0;idx<sz;idx++){ 00388 if(op2.dp[idx] != mss_val_dbl) op2.dp[idx]=scv_dbl/op2.dp[idx]; 00389 } /* end for */ 00390 } /* end else */ 00391 break; 00392 } /* endif NC_DOUBLE */ 00393 case NC_INT:{ 00394 const nco_int scv_lng=scv->val.l; 00395 if(!has_mss_val){ 00396 for(idx=0;idx<sz;idx++) op2.lp[idx]=scv_lng/op2.lp[idx]; 00397 }else{ 00398 const nco_int mss_val_lng=*mss_val.lp; /* Temporary variable reduces de-referencing */ 00399 for(idx=0;idx<sz;idx++){ 00400 if(op2.lp[idx] != mss_val_lng) op2.lp[idx]=scv_lng/op2.lp[idx]; 00401 } /* end for */ 00402 } /* end else */ 00403 break; 00404 } /* endif NC_INT */ 00405 case NC_SHORT:{ 00406 const short scv_sht=scv->val.s; 00407 if(!has_mss_val){ 00408 for(idx=0;idx<sz;idx++) op2.sp[idx]=scv_sht/op2.sp[idx]; 00409 }else{ 00410 const short mss_val_sht=*mss_val.sp; /* Temporary variable reduces de-referencing */ 00411 for(idx=0;idx<sz;idx++){ 00412 if(op2.sp[idx] != mss_val_sht) op2.sp[idx]=scv_sht/op2.sp[idx]; 00413 } /* end for */ 00414 } /* end else */ 00415 break; 00416 } /* endif NC_SHORT */ 00417 case NC_CHAR: 00418 /* Do nothing */ 00419 break; 00420 case NC_BYTE: 00421 /* Do nothing */ 00422 break; 00423 default: nco_dfl_case_nc_type_err(); break; 00424 } /* end switch */ 00425 00426 /* NB: it is not neccessary to un-typecast pointers to values after access 00427 because we have only operated on local copies of them. */ 00428 00429 } /* end scv_var_dvd() */
|
|
||||||||||||||||||||||||||||
|
Definition at line 528 of file nco_var_scv.c. References cast_void_nctype(), fabsf(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), and type. Referenced by ncap_scv_var_mod(). 00534 { 00535 /* Threads: Routine is thread safe and calls no unsafe routines */ 00536 /* Purpose: Take modulus of all values in scv by op2 00537 Store result in op2 */ 00538 00539 /* Scalar-variable modulus is currently defined as op2:=scv%op2 */ 00540 00541 /* http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html 00542 __GNUC__ : Defined by gcc 00543 __GNUG__ : Defined by g++, equivalent to (__GNUC__ && __cplusplus) */ 00544 00545 #ifndef __GNUG__ 00546 float fmodf(float,float); /* Cannot insert fmodf() in ncap_sym_init() because it takes two arguments TODO #20 */ 00547 /* Sun cc math.h does not include fabsf() prototype 00548 AIX xlc work fine with this prototype 00549 HP-UX cc fails when fabsf() is prototyped */ 00550 #ifndef HPUX 00551 float fabsf(float); 00552 #endif /* HPUX */ 00553 #endif /* __GNUG__ */ 00554 00555 long idx; 00556 00557 /* Typecast pointer to values before access */ 00558 (void)cast_void_nctype(type,&op2); 00559 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00560 00561 switch(type){ 00562 case NC_FLOAT:{ 00563 const float scv_flt=fabsf(scv->val.f); 00564 if(!has_mss_val){ 00565 for(idx=0;idx<sz;idx++) op2.fp[idx]=fmodf(scv_flt,op2.fp[idx]); 00566 }else{ 00567 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00568 for(idx=0;idx<sz;idx++){ 00569 if(op2.fp[idx] != mss_val_flt) op2.fp[idx]=fmodf(scv_flt,op2.fp[idx]); 00570 } /* end for */ 00571 } /* end else */ 00572 break; 00573 } /* endif NC_FLOAT */ 00574 case NC_DOUBLE:{ 00575 const double scv_dbl=fabs(scv->val.d); 00576 if(!has_mss_val){ 00577 for(idx=0;idx<sz;idx++) op2.dp[idx]=fmod(scv_dbl,op2.dp[idx]); 00578 }else{ 00579 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00580 for(idx=0;idx<sz;idx++){ 00581 if(op2.dp[idx] != mss_val_dbl) op2.dp[idx]=fmod(scv_dbl,op2.dp[idx]); 00582 } /* end for */ 00583 } /* end else */ 00584 break; 00585 } /* endif NC_DOUBLE */ 00586 case NC_INT:{ 00587 const nco_int scv_lng=scv->val.l; 00588 if(!has_mss_val){ 00589 for(idx=0;idx<sz;idx++) op2.lp[idx]=scv_lng%op2.lp[idx]; 00590 }else{ 00591 const nco_int mss_val_lng=*mss_val.lp; /* Temporary variable reduces de-referencing */ 00592 for(idx=0;idx<sz;idx++){ 00593 if(op2.lp[idx] != mss_val_lng) op2.lp[idx]=scv_lng%op2.lp[idx]; 00594 } /* end for */ 00595 } /* end else */ 00596 break; 00597 } /* endif NC_INT */ 00598 case NC_SHORT:{ 00599 const short scv_sht=scv->val.s; 00600 if(!has_mss_val){ 00601 for(idx=0;idx<sz;idx++) op2.sp[idx]=scv_sht%op2.sp[idx]; 00602 }else{ 00603 const short mss_val_sht=*mss_val.sp; /* Temporary variable reduces de-referencing */ 00604 for(idx=0;idx<sz;idx++){ 00605 if(op2.sp[idx] != mss_val_sht) op2.sp[idx]=scv_sht%op2.sp[idx]; 00606 } /* end for */ 00607 } /* end else */ 00608 break; 00609 } /* endif NC_SHORT */ 00610 case NC_CHAR: 00611 /* Do nothing */ 00612 break; 00613 case NC_BYTE: 00614 /* Do nothing */ 00615 break; 00616 default: nco_dfl_case_nc_type_err(); break; 00617 } /* end switch */ 00618 00619 } /* end scv_var_mod */
|
|
||||||||||||||||||||||||||||
|
Definition at line 688 of file nco_var_scv.c. References cast_void_nctype(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), powf(), and type. Referenced by ncap_scv_var_pwr(). 00694 { 00695 /* Purpose: Raise scv to power in var */ 00696 00697 /* Scalar-variable empowerment is currently defined as op2:=scv^op2 */ 00698 00699 long idx; 00700 00701 /* Typecast pointer to values before access */ 00702 (void)cast_void_nctype(type,&op2); 00703 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00704 00705 switch(type){ 00706 case NC_FLOAT:{ 00707 const float scv_flt=scv->val.f; 00708 if(!has_mss_val){ 00709 for(idx=0;idx<sz;idx++) op2.fp[idx]=powf(scv_flt,op2.fp[idx]); 00710 }else{ 00711 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00712 for(idx=0;idx<sz;idx++){ 00713 if(op2.fp[idx] != mss_val_flt) op2.fp[idx]=powf(scv_flt,op2.fp[idx]); 00714 } /* end for */ 00715 } /* end else */ 00716 break; 00717 } /* end NC_FLOAT */ 00718 case NC_DOUBLE:{ 00719 const double scv_dbl=scv->val.d; 00720 if(!has_mss_val){ 00721 for(idx=0;idx<sz;idx++) op2.dp[idx]=pow(scv_dbl,op2.dp[idx]); 00722 }else{ 00723 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00724 for(idx=0;idx<sz;idx++){ 00725 if(op2.dp[idx] != mss_val_dbl) op2.dp[idx]=pow(scv_dbl,op2.dp[idx]); 00726 } /* end for */ 00727 } /* end else */ 00728 break; 00729 } /* end NC_DOUBLE */ 00730 case NC_INT: 00731 /* Do nothing */ 00732 /* fxm: nco322 Implement integer empowerment? GSL? */ 00733 break; 00734 case NC_SHORT: 00735 /* Do nothing */ 00736 break; 00737 case NC_CHAR: 00738 /* Do nothing */ 00739 break; 00740 case NC_BYTE: 00741 /* Do nothing */ 00742 break; 00743 default: nco_dfl_case_nc_type_err(); break; 00744 }/* end switch */ 00745 00746 /* NB: it is not neccessary to un-typecast pointers to values after access 00747 because we have only operated on local copies of them. */ 00748 00749 } /* end var_scv_pwr */
|
|
||||||||||||||||||||||||||||
|
Definition at line 13 of file nco_var_scv.c. References cast_void_nctype(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), and type. Referenced by ncap_var_scv_add(), ncap_var_scv_sub(), and nco_var_upk(). 00019 { 00020 /* Threads: Routine is thread safe and calls no unsafe routines */ 00021 /* Purpose: Add scv to all values in op1 00022 Store result in first operand */ 00023 00024 /* Addition is currently defined as op1:=op1+scv */ 00025 00026 long idx; 00027 00028 /* Typecast pointer to values before access */ 00029 (void)cast_void_nctype(type,&op1); 00030 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00031 00032 switch(type){ 00033 case NC_FLOAT:{ 00034 const float scv_flt=scv->val.f; 00035 if(!has_mss_val){ 00036 for(idx=0;idx<sz;idx++) op1.fp[idx]+=scv_flt; 00037 }else{ 00038 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00039 for(idx=0;idx<sz;idx++){ 00040 if(op1.fp[idx] != mss_val_flt) op1.fp[idx]+=scv_flt; 00041 } /* end for */ 00042 } /* end else */ 00043 break; 00044 } /* endif NC_FLOAT */ 00045 case NC_DOUBLE:{ 00046 const double scv_dbl=scv->val.d; 00047 if(!has_mss_val){ 00048 for(idx=0;idx<sz;idx++) op1.dp[idx]+=scv_dbl; 00049 }else{ 00050 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00051 for(idx=0;idx<sz;idx++){ 00052 if(op1.dp[idx] != mss_val_dbl) op1.dp[idx]+=scv_dbl; 00053 } /* end for */ 00054 } /* end else */ 00055 break; 00056 } /* endif NC_DOUBLE */ 00057 case NC_INT:{ 00058 const nco_int scv_lng=scv->val.l; 00059 if(!has_mss_val){ 00060 for(idx=0;idx<sz;idx++) op1.lp[idx]+=scv_lng; 00061 }else{ 00062 const nco_int mss_val_lng=*mss_val.lp; /* Temporary variable reduces de-referencing */ 00063 for(idx=0;idx<sz;idx++){ 00064 if(op1.lp[idx] != mss_val_lng) op1.lp[idx]+=scv_lng; 00065 } /* end for */ 00066 } /* end else */ 00067 break; 00068 } /* endif NC_INT */ 00069 case NC_SHORT:{ 00070 const short scv_sht=scv->val.s; 00071 if(!has_mss_val){ 00072 for(idx=0;idx<sz;idx++) op1.sp[idx]+=scv_sht; 00073 }else{ 00074 const short mss_val_sht=*mss_val.sp; /* Temporary variable reduces de-referencing */ 00075 for(idx=0;idx<sz;idx++){ 00076 if(op1.sp[idx] != mss_val_sht) op1.sp[idx]+=scv_sht; 00077 } /* end for */ 00078 } /* end else */ 00079 break; 00080 } /* endif NC_SHORT */ 00081 case NC_CHAR: 00082 /* Do nothing */ 00083 break; 00084 case NC_BYTE: 00085 /* Do nothing */ 00086 break; 00087 default: nco_dfl_case_nc_type_err(); break; 00088 } /* end switch */ 00089 00090 /* NB: it is not neccessary to un-typecast pointers to values after access 00091 because we have only operated on local copies of them. */ 00092 00093 } /* end var_scv_add() */
|
|
||||||||||||||||||||||||||||
|
Definition at line 265 of file nco_var_scv.c. References cast_void_nctype(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), and type. Referenced by ncap_var_scv_dvd(), and nco_var_pck(). 00271 { 00272 /* Threads: Routine is thread safe and calls no unsafe routines */ 00273 /* Purpose: Divide all values in op1 by scv 00274 Store result in first operand */ 00275 00276 /* Variable-scalar division is currently defined as op1:=op1/scv */ 00277 00278 long idx; 00279 00280 /* Typecast pointer to values before access */ 00281 (void)cast_void_nctype(type,&op1); 00282 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00283 00284 switch(type){ 00285 case NC_FLOAT:{ 00286 const float scv_flt=scv->val.f; 00287 if(!has_mss_val){ 00288 for(idx=0;idx<sz;idx++) op1.fp[idx]/=scv_flt; 00289 }else{ 00290 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00291 for(idx=0;idx<sz;idx++){ 00292 if(op1.fp[idx] != mss_val_flt) op1.fp[idx]/=scv_flt; 00293 } /* end for */ 00294 } /* end else */ 00295 break; 00296 } /* endif NC_FLOAT */ 00297 case NC_DOUBLE:{ 00298 const double scv_dbl=scv->val.d; 00299 if(!has_mss_val){ 00300 for(idx=0;idx<sz;idx++) op1.dp[idx]/=scv_dbl; 00301 }else{ 00302 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00303 for(idx=0;idx<sz;idx++){ 00304 if(op1.dp[idx] != mss_val_dbl) op1.dp[idx]/=scv_dbl; 00305 } /* end for */ 00306 } /* end else */ 00307 break; 00308 } /* endif NC_DOUBLE */ 00309 case NC_INT:{ 00310 const nco_int scv_lng=scv->val.l; 00311 if(!has_mss_val){ 00312 for(idx=0;idx<sz;idx++) op1.lp[idx]/=scv_lng; 00313 }else{ 00314 const nco_int mss_val_lng=*mss_val.lp; /* Temporary variable reduces de-referencing */ 00315 for(idx=0;idx<sz;idx++){ 00316 if(op1.lp[idx] != mss_val_lng) op1.lp[idx]/=scv_lng; 00317 } /* end for */ 00318 } /* end else */ 00319 break; 00320 } /* endif NC_INT */ 00321 case NC_SHORT:{ 00322 const short scv_sht=scv->val.s; 00323 if(!has_mss_val){ 00324 for(idx=0;idx<sz;idx++) op1.sp[idx]/=scv_sht; 00325 }else{ 00326 const short mss_val_sht=*mss_val.sp; /* Temporary variable reduces de-referencing */ 00327 for(idx=0;idx<sz;idx++){ 00328 if(op1.sp[idx] != mss_val_sht) op1.sp[idx]/=scv_sht; 00329 } /* end for */ 00330 } /* end else */ 00331 break; 00332 } /* endif NC_SHORT */ 00333 case NC_CHAR: 00334 /* Do nothing */ 00335 break; 00336 case NC_BYTE: 00337 /* Do nothing */ 00338 break; 00339 default: nco_dfl_case_nc_type_err(); break; 00340 } /* end switch */ 00341 00342 /* NB: it is not neccessary to un-typecast pointers to values after access 00343 because we have only operated on local copies of them. */ 00344 00345 } /* end var_scv_dvd() */
|
|
||||||||||||||||||||||||||||
|
Definition at line 181 of file nco_var_scv.c. References cast_void_nctype(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), and type. Referenced by ncap_var_scv_mlt(), and nco_var_upk(). 00187 { 00188 /* Threads: Routine is thread safe and calls no unsafe routines */ 00189 /* Purpose: Multiply all values in op1 by scv 00190 Store result in first operand */ 00191 00192 /* Multiplication is currently defined as op1:=op1*scv */ 00193 00194 long idx; 00195 00196 /* Typecast pointer to values before access */ 00197 (void)cast_void_nctype(type,&op1); 00198 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00199 00200 switch(type){ 00201 case NC_FLOAT:{ 00202 const float scv_flt=scv->val.f; 00203 if(!has_mss_val){ 00204 for(idx=0;idx<sz;idx++) op1.fp[idx]*=scv_flt; 00205 }else{ 00206 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00207 for(idx=0;idx<sz;idx++){ 00208 if(op1.fp[idx] != mss_val_flt) op1.fp[idx]*=scv_flt; 00209 } /* end for */ 00210 } /* end else */ 00211 break; 00212 } 00213 case NC_DOUBLE:{ 00214 const double scv_dbl=scv->val.d; 00215 if(!has_mss_val){ 00216 for(idx=0;idx<sz;idx++) op1.dp[idx]*=scv_dbl; 00217 }else{ 00218 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00219 for(idx=0;idx<sz;idx++){ 00220 if(op1.dp[idx] != mss_val_dbl) op1.dp[idx]*=scv_dbl; 00221 } /* end for */ 00222 } /* end else */ 00223 break; 00224 } 00225 case NC_INT:{ 00226 const nco_int scv_lng=scv->val.l; 00227 if(!has_mss_val){ 00228 for(idx=0;idx<sz;idx++) op1.lp[idx]*=scv_lng; 00229 }else{ 00230 const nco_int mss_val_lng=*mss_val.lp; /* Temporary variable reduces de-referencing */ 00231 for(idx=0;idx<sz;idx++){ 00232 if(op1.lp[idx] != mss_val_lng) op1.lp[idx]*=scv_lng; 00233 } /* end for */ 00234 } /* end else */ 00235 break; 00236 } 00237 case NC_SHORT:{ 00238 const short scv_sht=scv->val.s; 00239 if(!has_mss_val){ 00240 for(idx=0;idx<sz;idx++) op1.sp[idx]*=scv_sht; 00241 }else{ 00242 const short mss_val_sht=*mss_val.sp; /* Temporary variable reduces de-referencing */ 00243 for(idx=0;idx<sz;idx++){ 00244 if(op1.sp[idx] != mss_val_sht) op1.sp[idx]*=scv_sht; 00245 } /* end for */ 00246 } /* end else */ 00247 break; 00248 } 00249 case NC_CHAR: 00250 /* Do nothing */ 00251 break; 00252 case NC_BYTE: 00253 /* Do nothing */ 00254 break; 00255 default: nco_dfl_case_nc_type_err(); break; 00256 } /* end switch */ 00257 00258 /* NB: it is not neccessary to un-typecast pointers to values after access 00259 because we have only operated on local copies of them. */ 00260 00261 } /* end var_scv_mlt() */
|
|
||||||||||||||||||||||||||||
|
Definition at line 433 of file nco_var_scv.c. References cast_void_nctype(), fabsf(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), and type. Referenced by ncap_var_scv_mod(). 00439 { 00440 /* Threads: Routine is thread safe and calls no unsafe routines */ 00441 /* Purpose: Take modulus of all values in op1 by scv 00442 Store result in op1 */ 00443 00444 /* Variable-scalar modulus is currently defined as op1:=op1%scv */ 00445 00446 /* http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html 00447 __GNUC__ : Defined by gcc 00448 __GNUG__ : Defined by g++, equivalent to (__GNUC__ && __cplusplus) */ 00449 00450 #ifndef __GNUG__ 00451 float fmodf(float,float); /* Cannot insert fmodf() in ncap_sym_init() because it takes two arguments TODO #20 */ 00452 /* Sun cc math.h does not include fabsf() prototype 00453 AIX xlc work fine with this prototype 00454 HP-UX cc fails when fabsf() is prototyped */ 00455 #ifndef HPUX 00456 float fabsf(float); 00457 #endif /* HPUX */ 00458 #endif /* __GNUG__ */ 00459 00460 long idx; 00461 00462 /* Typecast pointer to values before access */ 00463 (void)cast_void_nctype(type,&op1); 00464 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00465 00466 switch(type){ 00467 case NC_FLOAT:{ 00468 const float scv_flt=fabsf(scv->val.f); 00469 if(!has_mss_val){ 00470 for(idx=0;idx<sz;idx++) op1.fp[idx]=fmodf(op1.fp[idx],scv_flt); 00471 }else{ 00472 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00473 for(idx=0;idx<sz;idx++){ 00474 if(op1.fp[idx] != mss_val_flt) op1.fp[idx]=fmodf(op1.fp[idx],scv_flt); 00475 } /* end for */ 00476 } /* end else */ 00477 break; 00478 } /* endif NC_FLOAT */ 00479 case NC_DOUBLE:{ 00480 const double scv_dbl=fabs(scv->val.d); 00481 if(!has_mss_val){ 00482 for(idx=0;idx<sz;idx++) op1.dp[idx]=fmod(op1.dp[idx],scv_dbl); 00483 }else{ 00484 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00485 for(idx=0;idx<sz;idx++){ 00486 if(op1.dp[idx] != mss_val_dbl) op1.dp[idx]=fmod(op1.dp[idx],scv_dbl); 00487 } /* end for */ 00488 } /* end else */ 00489 break; 00490 } /* endif NC_DOUBLE */ 00491 case NC_INT:{ 00492 const nco_int scv_lng=scv->val.l; 00493 if(!has_mss_val){ 00494 for(idx=0;idx<sz;idx++) op1.lp[idx]%=scv_lng; 00495 }else{ 00496 const nco_int mss_val_lng=*mss_val.lp; /* Temporary variable reduces de-referencing */ 00497 for(idx=0;idx<sz;idx++){ 00498 if(op1.lp[idx] != mss_val_lng) op1.lp[idx]%=scv_lng; 00499 } /* end for */ 00500 } /* end else */ 00501 break; 00502 } /* endif NC_INT */ 00503 case NC_SHORT:{ 00504 const short scv_sht=scv->val.s; 00505 if(!has_mss_val){ 00506 for(idx=0;idx<sz;idx++) op1.sp[idx]%=scv_sht; 00507 }else{ 00508 const short mss_val_sht=*mss_val.sp; /* Temporary variable reduces de-referencing */ 00509 for(idx=0;idx<sz;idx++){ 00510 if(op1.sp[idx] != mss_val_sht) op1.sp[idx]%=scv_sht; 00511 } /* end for */ 00512 } /* end else */ 00513 break; 00514 } /* endif NC_SHORT */ 00515 case NC_CHAR: 00516 /* Do nothing */ 00517 break; 00518 case NC_BYTE: 00519 /* Do nothing */ 00520 break; 00521 default: nco_dfl_case_nc_type_err(); break; 00522 } /* end switch */ 00523 00524 } /* end var_scv_mod */
|
|
||||||||||||||||||||||||||||
|
Definition at line 623 of file nco_var_scv.c. References cast_void_nctype(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), powf(), and type. Referenced by ncap_var_scv_pwr(). 00629 { 00630 /* Purpose: Raise var to power in scv */ 00631 00632 /* Variable-scalar empowerment is currently defined as op1:=op1^scv */ 00633 00634 long idx; 00635 00636 /* Typecast pointer to values before access */ 00637 (void)cast_void_nctype(type,&op1); 00638 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00639 00640 switch(type){ 00641 case NC_FLOAT:{ 00642 const float scv_flt=scv->val.f; 00643 if(!has_mss_val){ 00644 for(idx=0;idx<sz;idx++) op1.fp[idx]=powf(op1.fp[idx],scv_flt); 00645 }else{ 00646 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00647 for(idx=0;idx<sz;idx++){ 00648 if(op1.fp[idx] != mss_val_flt) op1.fp[idx]=powf(op1.fp[idx],scv_flt); 00649 } /* end for */ 00650 } /* end else */ 00651 break; 00652 } /* end NC_FLOAT */ 00653 case NC_DOUBLE:{ 00654 const double scv_dbl=scv->val.d; 00655 if(!has_mss_val){ 00656 for(idx=0;idx<sz;idx++) op1.dp[idx]=pow(op1.dp[idx],scv_dbl); 00657 }else{ 00658 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00659 for(idx=0;idx<sz;idx++){ 00660 if(op1.dp[idx] != mss_val_dbl) op1.dp[idx]=pow(op1.dp[idx],scv_dbl); 00661 } /* end for */ 00662 } /* end else */ 00663 break; 00664 } /* end NC_DOUBLE */ 00665 case NC_INT: 00666 /* Do nothing */ 00667 /* fxm: nco322 Implement integer empowerment? GSL? */ 00668 break; 00669 case NC_SHORT: 00670 /* Do nothing */ 00671 break; 00672 case NC_CHAR: 00673 /* Do nothing */ 00674 break; 00675 case NC_BYTE: 00676 /* Do nothing */ 00677 break; 00678 default: nco_dfl_case_nc_type_err(); break; 00679 }/* end switch */ 00680 00681 /* NB: it is not neccessary to un-typecast pointers to values after access 00682 because we have only operated on local copies of them. */ 00683 00684 } /* end var_scv_pwr */
|
|
||||||||||||||||||||||||||||
|
Definition at line 97 of file nco_var_scv.c. References cast_void_nctype(), NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, nco_dfl_case_nc_type_err(), and type. Referenced by nco_var_pck(). 00103 { 00104 /* Threads: Routine is thread safe and calls no unsafe routines */ 00105 /* Purpose: Subtract scv from all values in op1 00106 Store result in first operand */ 00107 00108 /* Subtraction is currently defined as op1:=op1-scv */ 00109 00110 long idx; 00111 00112 /* Typecast pointer to values before access */ 00113 (void)cast_void_nctype(type,&op1); 00114 if(has_mss_val) (void)cast_void_nctype(type,&mss_val); 00115 00116 switch(type){ 00117 case NC_FLOAT:{ 00118 const float scv_flt=scv->val.f; 00119 if(!has_mss_val){ 00120 for(idx=0;idx<sz;idx++) op1.fp[idx]-=scv_flt; 00121 }else{ 00122 const float mss_val_flt=*mss_val.fp; /* Temporary variable reduces de-referencing */ 00123 for(idx=0;idx<sz;idx++){ 00124 if(op1.fp[idx] != mss_val_flt) op1.fp[idx]-=scv_flt; 00125 } /* end for */ 00126 } /* end else */ 00127 break; 00128 } 00129 case NC_DOUBLE:{ 00130 const double scv_dbl=scv->val.d; 00131 if(!has_mss_val){ 00132 for(idx=0;idx<sz;idx++) op1.dp[idx]-=scv_dbl; 00133 }else{ 00134 const double mss_val_dbl=*mss_val.dp; /* Temporary variable reduces de-referencing */ 00135 for(idx=0;idx<sz;idx++){ 00136 if(op1.dp[idx] != mss_val_dbl) op1.dp[idx]-=scv_dbl; 00137 } /* end for */ 00138 } /* end else */ 00139 break; 00140 } 00141 case NC_INT:{ 00142 const nco_int scv_lng=scv->val.l; 00143 if(!has_mss_val){ 00144 for(idx=0;idx<sz;idx++) op1.lp[idx]-=scv_lng; 00145 }else{ 00146 const nco_int mss_val_lng=*mss_val.lp; /* Temporary variable reduces de-referencing */ 00147 for(idx=0;idx<sz;idx++){ 00148 if(op1.lp[idx] != mss_val_lng) op1.lp[idx]-=scv_lng; 00149 } /* end for */ 00150 } /* end else */ 00151 break; 00152 } 00153 case NC_SHORT:{ 00154 const short scv_sht=scv->val.s; 00155 if(!has_mss_val){ 00156 for(idx=0;idx<sz;idx++) op1.sp[idx]-=scv_sht; 00157 }else{ 00158 const short mss_val_sht=*mss_val.sp; /* Temporary variable reduces de-referencing */ 00159 for(idx=0;idx<sz;idx++){ 00160 if(op1.sp[idx] != mss_val_sht) op1.sp[idx]-=scv_sht; 00161 } /* end for */ 00162 } /* end else */ 00163 break; 00164 } 00165 case NC_CHAR: 00166 /* Do nothing */ 00167 break; 00168 case NC_BYTE: 00169 /* Do nothing */ 00170 break; 00171 default: nco_dfl_case_nc_type_err(); break; 00172 } /* end switch */ 00173 00174 /* NB: it is not neccessary to un-typecast pointers to values after access 00175 because we have only operated on local copies of them. */ 00176 00177 } /* end var_scv_sub() */
|
1.4.4