IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 16, 2020, 1:54:47 PM (6 years ago)
Author:
tdeboer
Message:

revert to working Ohana build

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/stack_math.c

    r41176 r41340  
    3434    case '?': SSS_FUNC(M1 ? M2: M3);
    3535    default:
    36       snprintf (line, 512, "error: op %c not defined as scalar trinary op!", op[0]);
     36      snprintf (line, 512, "error: op %c not defined!", op[0]);
    3737      push_error (line);
    3838      return (FALSE);
     
    162162    case '?': VVV_FUNC(*M1 ? *M2: *M3);
    163163    default:
    164       snprintf (line, 512, "error: op %c not defined as vector trinary op!", op[0]);
     164      snprintf (line, 512, "error: op %c not defined!", op[0]);
    165165      push_error (line);
    166166      return (FALSE);
     
    227227    case '?': MMM_FUNC(*M1 ? *M2: *M3);
    228228    default:
    229       snprintf (line, 512, "error: op %c not defined as matrix trinary op!", op[0]);
     229      snprintf (line, 512, "error: op %c not defined!", op[0]);
    230230      push_error (line);
    231231      return (FALSE);
     
    357357    case 'A': VV_FUNC(ST_SCALAR_INT, (*M1 && *M2) ? 1 : 0);
    358358    case 'O': VV_FUNC(ST_SCALAR_INT, (*M1 || *M2) ? 1 : 0);
    359 
    360     // for the bitshift operators, we have to treat the INT and FLT values differently
    361     // this makes the operator incompatible with the macros used above
    362     case 'l': {
    363       CopyVector (OUT[0].vector, V1[0].vector);
    364       if ((V1->vector->type == OPIHI_FLT) || (V2->vector->type == OPIHI_FLT)) {
    365         // bitshift is not valid with float valuess
    366         for (i = 0; i < Nx; i++) {
    367           OUT[0].vector[0].elements.Flt[i] = NAN;
    368         }
    369         break;
    370       }
    371       // I could just do this for all types and bitshift regardless...
    372       opihi_int *M1  =  V1[0].vector[0].elements.Int;
    373       opihi_int *M2  =  V2[0].vector[0].elements.Int;
    374       opihi_int *out = OUT[0].vector[0].elements.Int;
    375       for (i = 0; i < Nx; i++, out++, M1++, M2++) {
    376         *out = *M1 << *M2;
    377       }
    378       break;
    379     }
    380 
    381     case 'r': {
    382       CopyVector (OUT[0].vector, V1[0].vector);
    383       if ((V1->vector->type == OPIHI_FLT) || (V2->vector->type == OPIHI_FLT)) {
    384         // bitshift is not valid with float valuess
    385         CopyVector (OUT[0].vector, V1[0].vector);
    386         for (i = 0; i < Nx; i++) {
    387           OUT[0].vector[0].elements.Flt[i] = NAN;
    388         }
    389         break;
    390       }
    391       // I could just do this for all types and bitshift regardless...
    392       opihi_int *M1  =  V1[0].vector[0].elements.Int;
    393       opihi_int *M2  =  V2[0].vector[0].elements.Int;
    394       opihi_int *out = OUT[0].vector[0].elements.Int;
    395       for (i = 0; i < Nx; i++, out++, M1++, M2++) {
    396         *out = *M1 >> *M2;
    397       }
    398       break;
    399     }
    400 
    401359    default:
    402       snprintf (line, 512, "error: op %c not defined for (vector OP vector)!", op[0]);
     360      snprintf (line, 512, "error: op %c not defined!", op[0]);
    403361      push_error (line);
    404362      return (FALSE);
     
    511469    case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0);
    512470    case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0);
    513 
    514     // for the bitshift operators, we have to treat the INT and FLT values differently
    515     // this makes the operator incompatible with the macros used above
    516     case 'l': {
    517       CopyVector (OUT[0].vector, V2[0].vector);
    518       if ((V1->type == ST_SCALAR_FLT) || (V2->vector->type == OPIHI_FLT)) {
    519         // bitshift is not valid with float valuess
    520         for (i = 0; i < Nx; i++) {
    521           OUT[0].vector[0].elements.Flt[i] = NAN;
    522         }
    523         break;
    524       }
    525       opihi_int  M1  =  V1[0].IntValue;                                 \
    526       opihi_int *M2  =  V2[0].vector[0].elements.Int;
    527       opihi_int *out = OUT[0].vector[0].elements.Int;
    528       for (i = 0; i < Nx; i++, out++, M2++) {
    529         *out = M1 << *M2;
    530       }
    531       break;
    532     }
    533 
    534     case 'r': {
    535       CopyVector (OUT[0].vector, V2[0].vector);
    536       if ((V1->type == ST_SCALAR_FLT) || (V2->vector->type == OPIHI_FLT)) {
    537         // bitshift is not valid with float valuess
    538         for (i = 0; i < Nx; i++) {
    539           OUT[0].vector[0].elements.Flt[i] = NAN;
    540         }
    541         break;
    542       }
    543       opihi_int  M1  =  V1[0].IntValue;                                 \
    544       opihi_int *M2  =  V2[0].vector[0].elements.Int;
    545       opihi_int *out = OUT[0].vector[0].elements.Int;
    546       for (i = 0; i < Nx; i++, out++, M2++) {
    547         *out = M1 >> *M2;
    548       }
    549       break;
    550     }
    551 
    552471    default:
    553       snprintf (line, 512, "error: op %c not defined for (scalar OP vector)!", op[0]);
     472      snprintf (line, 512, "error: op %c not defined!", op[0]);
    554473      push_error (line);
    555474      return (FALSE);
     
    658577    case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0);
    659578    case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0);
    660 
    661     case 'l': {
    662       CopyVector (OUT[0].vector, V1[0].vector);
    663       if ((V1->vector->type == OPIHI_FLT) || (V2->type == ST_SCALAR_FLT)) {
    664         // bitshift is not valid with float valuess
    665         for (i = 0; i < Nx; i++) {
    666           OUT[0].vector[0].elements.Flt[i] = NAN;
    667         }
    668         break;
    669       }
    670       opihi_int *M1  =  V1[0].vector[0].elements.Int;
    671       opihi_int  M2  =  V2[0].IntValue;                                 \
    672       opihi_int *out = OUT[0].vector[0].elements.Int;
    673       for (i = 0; i < Nx; i++, out++, M1++) {
    674         *out = *M1 << M2;
    675       }
    676       break;
    677     }
    678 
    679     case 'r': {
    680       CopyVector (OUT[0].vector, V1[0].vector);
    681       if ((V1->vector->type == OPIHI_FLT) || (V2->type == ST_SCALAR_FLT)) {
    682         // bitshift is not valid with float valuess
    683         CopyVector (OUT[0].vector, V1[0].vector);
    684         for (i = 0; i < Nx; i++) {
    685           OUT[0].vector[0].elements.Flt[i] = NAN;
    686         }
    687         break;
    688       }
    689       opihi_int *M1  =  V1[0].vector[0].elements.Int;
    690       opihi_int  M2  =  V2[0].IntValue;                                 \
    691       opihi_int *out = OUT[0].vector[0].elements.Int;
    692       for (i = 0; i < Nx; i++, out++, M1++) {
    693         *out = *M1 >> M2;
    694       }
    695       break;
    696     }
    697 
    698579    default:
    699       snprintf (line, 512, "error: op %c not defined for (vector OP scalar)!", op[0]);
     580      snprintf (line, 512, "error: op %c not defined!", op[0]);
    700581      push_error (line);
    701582      return (FALSE);
     
    789670    case 'A': MV_FUNC((*M1 && *M2) ? 1 : 0);
    790671    case 'O': MV_FUNC((*M1 || *M2) ? 1 : 0);
    791 
    792672    default:
    793       snprintf (line, 512, "error: op %c not defined for (matrix OP vector)!", op[0]);
     673      snprintf (line, 512, "error: op %c not defined!", op[0]);
    794674      push_error (line);
    795675      return (FALSE);
     
    888768    case 'O': VM_FUNC((*M1 || *M2) ? 1 : 0);
    889769    default:
    890       snprintf (line, 512, "error: op %c not defined for (vector OP matrix)!", op[0]);
     770      snprintf (line, 512, "error: op %c not defined!", op[0]);
    891771      push_error (line);
    892772      return (FALSE);
     
    969849    case 'O': MM_FUNC((*M1 || *M2) ? 1 : 0);
    970850    default:
    971       snprintf (line, 512, "error: op %c not defined for (matrix OP matrix)!", op[0]);
     851      snprintf (line, 512, "error: op %c not defined!", op[0]);
    972852      push_error (line);
    973853      return (FALSE);
     
    1055935    case 'O': MS_FUNC((*M1 || M2) ? 1 : 0);
    1056936    default:
    1057       snprintf (line, 512, "error: op %c not defined for (matrix OP scalar)!", op[0]);
     937      snprintf (line, 512, "error: op %c not defined!", op[0]);
    1058938      push_error (line);
    1059939      return (FALSE);
     
    11321012    case 'O': SM_FUNC((M1 || *M2) ? 1 : 0);
    11331013    default:
    1134       snprintf (line, 512, "error: op %c not defined for (scalar OP matrix)!", op[0]);
     1014      snprintf (line, 512, "error: op %c not defined!", op[0]);
    11351015      push_error (line);
    11361016      return (FALSE);
     
    12141094    case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0);
    12151095    case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0);
    1216 
    1217     // for the bitshift operators, we have to treat the INT and FLT values differently
    1218     // this makes the operator incompatible with the macros used above
    1219     case 'l': {
    1220       if ((V1->type == ST_SCALAR_FLT) || (V2->type == ST_SCALAR_FLT)) {
    1221         // bitshift is not valid with float valuess
    1222         OUT[0].type = ST_SCALAR_FLT;
    1223         OUT[0].FltValue = NAN;
    1224         break;
    1225       }
    1226       opihi_int M1 = V1[0].IntValue;
    1227       opihi_int M2 = V2[0].IntValue;
    1228       OUT[0].type = ST_SCALAR_INT;
    1229       OUT[0].IntValue = M1 << M2;
    1230       break;
    1231     }
    1232 
    1233     case 'r': {
    1234       if ((V1->type == ST_SCALAR_FLT) || (V2->type == ST_SCALAR_FLT)) {
    1235         // bitshift is not valid with float valuess
    1236         OUT[0].type = ST_SCALAR_FLT;
    1237         OUT[0].FltValue = NAN;
    1238         break;
    1239       }
    1240       opihi_int M1 = V1[0].IntValue;
    1241       opihi_int M2 = V2[0].IntValue;
    1242       OUT[0].type = ST_SCALAR_INT;
    1243       OUT[0].IntValue = M1 >> M2;
    1244       break;
    1245     }
    1246 
    12471096    default:
    1248       snprintf (line, 512, "error: op %c not defined for (scalar OP scalar)!", op[0]);
     1097      snprintf (line, 512, "error: op %c not defined!", op[0]);
    12491098      push_error (line);
    12501099      return (FALSE);
     
    13191168int S_unary (StackVar *OUT, StackVar *V1, char *op) {
    13201169
     1170  char line[512]; // this is only used to report an error
     1171 
    13211172# define S_FUNC(OP,FTYPE) {                                             \
    13221173    if (V1->type == ST_SCALAR_FLT) {                                    \
     
    13591210  if (!strcmp (op, "asinh"))  S_FUNC(asinh (M1), ST_SCALAR_FLT);
    13601211  if (!strcmp (op, "acosh"))  S_FUNC(acosh (M1), ST_SCALAR_FLT);
     1212  if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), ST_SCALAR_FLT);
    13611213  if (!strcmp (op, "sin"))    S_FUNC(sin (M1), ST_SCALAR_FLT);
    13621214  if (!strcmp (op, "cos"))    S_FUNC(cos (M1), ST_SCALAR_FLT);
     
    13711223  if (!strcmp (op, "dacos"))  S_FUNC(acos (M1)*DEG_RAD, ST_SCALAR_FLT);
    13721224  if (!strcmp (op, "datan"))  S_FUNC(atan (M1)*DEG_RAD, ST_SCALAR_FLT);
    1373   if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), ST_SCALAR_FLT);
    13741225  if (!strcmp (op, "rnd"))    S_FUNC(0.0*M1 + drand48(), ST_SCALAR_FLT);
    13751226  if (!strcmp (op, "drnd"))   S_FUNC(0.0*M1 + drand48(), ST_SCALAR_FLT);
     
    13841235
    13851236  clear_stack (V1);
    1386 
    1387   char line[512]; // this is only used to report an error
    1388   snprintf (line, 512, "error: op %s not defined as unary scalar op!", op);
     1237  snprintf (line, 512, "error: op %s not defined!", op);
    13891238  push_error (line);
    13901239  return (FALSE);
     1240
    13911241}
    13921242
     
    14451295  if (!strcmp (op, "asinh"))  V_FUNC(asinh(*M1), ST_SCALAR_FLT);
    14461296  if (!strcmp (op, "acosh"))  V_FUNC(acosh(*M1), ST_SCALAR_FLT);
     1297  if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), ST_SCALAR_FLT);
    14471298  if (!strcmp (op, "sin"))    V_FUNC(sin(*M1), ST_SCALAR_FLT);
    14481299  if (!strcmp (op, "cos"))    V_FUNC(cos(*M1), ST_SCALAR_FLT);
     
    14571308  if (!strcmp (op, "dacos"))  V_FUNC(acos(*M1)*DEG_RAD, ST_SCALAR_FLT);
    14581309  if (!strcmp (op, "datan"))  V_FUNC(atan(*M1)*DEG_RAD, ST_SCALAR_FLT);
    1459   if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), ST_SCALAR_FLT);
    14601310  if (!strcmp (op, "rnd"))    V_FUNC(drand48(), ST_SCALAR_FLT);
    14611311  if (!strcmp (op, "drnd"))   V_FUNC(drand48(), ST_SCALAR_FLT);
    14621312  if (!strcmp (op, "lrnd"))   V_FUNC(lrand48(), ST_SCALAR_INT);
    14631313  if (!strcmp (op, "mrnd"))   V_FUNC(mrand48(), ST_SCALAR_INT);
     1314  if (!strcmp (op, "ramp"))   V_FUNC(i, ST_SCALAR_INT);
     1315  if (!strcmp (op, "zero"))   V_FUNC(0, ST_SCALAR_INT);
    14641316  if (!strcmp (op, "not"))    V_FUNC(!(*M1), ST_SCALAR_INT);
    14651317  if (!strcmp (op, "--"))     V_FUNC(-1*(*M1), ST_SCALAR_INT); // NOTE: opihi_int is signed
    14661318  if (!strcmp (op, "isinf"))  V_FUNC(!finite(*M1), ST_SCALAR_FLT);
    14671319  if (!strcmp (op, "isnan"))  V_FUNC(isnan((opihi_flt)(*M1)), ST_SCALAR_FLT);
    1468   if (!strcmp (op, "ramp"))   V_FUNC(i, ST_SCALAR_INT);
    14691320  if (!strcmp (op, "xramp"))  V_FUNC(i, ST_SCALAR_INT);
    14701321  if (!strcmp (op, "yramp"))  V_FUNC(0, ST_SCALAR_INT);
    14711322  if (!strcmp (op, "zramp"))  V_FUNC(0, ST_SCALAR_INT);
    1472   if (!strcmp (op, "zero"))   V_FUNC(0, ST_SCALAR_INT);
    14731323  /* xramp, yramp, zramp above only make sense for matrices. for vectors, xramp = ramp, yramp = zero */
    14741324
    14751325# undef V_FUNC
    14761326
    1477   // free the temp vector if needed
     1327escape:
     1328
    14781329  if (V1[0].type == ST_VECTOR_TMP) {
    14791330    free (V1[0].vector[0].elements.Ptr);
     
    14831334
    14841335  clear_stack (V1);
    1485 
    1486   char line[512]; // this is only used to report an error
    1487   snprintf (line, 512, "error: op %s not defined as unary vector op!", op);
    1488   push_error (line);
    1489   return (FALSE);
    1490 
    1491 escape:
    1492 
    1493   if (V1[0].type == ST_VECTOR_TMP) {
    1494     free (V1[0].vector[0].elements.Ptr);
    1495     free (V1[0].vector);
    1496     V1[0].vector = NULL;
    1497   } 
    1498 
    1499   clear_stack (V1);
    1500   return (TRUE);
    1501 
    1502 }
    1503 
    1504 # define M_FUNC(OP) { for (i = 0; i < Npix; i++, out++, M1++) { *out = (OP); } goto escape; }
     1336  return (TRUE);
     1337
     1338}
     1339
     1340# define M_FUNC(OP) { for (i = 0; i < Npix; i++, out++, M1++) { *out = (OP); }}
    15051341
    15061342int M_unary (StackVar *OUT, StackVar *V1, char *op) {
     
    15241360// if (!strcmp (op, "rint"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = nearbyint (*M1); }}
    15251361 
    1526   if (!strcmp (op, "="))      { goto escape; }
     1362  if (!strcmp (op, "="))     { }
    15271363  if (!strcmp (op, "abs"))    M_FUNC(fabs(*M1));
    15281364  if (!strcmp (op, "int"))    M_FUNC((opihi_flt)(long long)(*M1));
     
    15391375  if (!strcmp (op, "asinh"))  M_FUNC(asinh(*M1));
    15401376  if (!strcmp (op, "acosh"))  M_FUNC(acosh(*M1));
     1377  if (!strcmp (op, "lgamma")) M_FUNC(lgamma(*M1));
    15411378  if (!strcmp (op, "sin"))    M_FUNC(sin(*M1));
    15421379  if (!strcmp (op, "cos"))    M_FUNC(cos(*M1));
     
    15511388  if (!strcmp (op, "dacos"))  M_FUNC(acos(*M1)*DEG_RAD);
    15521389  if (!strcmp (op, "datan"))  M_FUNC(atan(*M1)*DEG_RAD);
    1553   if (!strcmp (op, "lgamma")) M_FUNC(lgamma(*M1));
     1390  if (!strcmp (op, "not"))    M_FUNC(!(*M1));
     1391  if (!strcmp (op, "--"))     M_FUNC(-(*M1));
    15541392  if (!strcmp (op, "rnd"))    M_FUNC(drand48());
    15551393  if (!strcmp (op, "drnd"))   M_FUNC(drand48());
    15561394  if (!strcmp (op, "lrnd"))   M_FUNC(lrand48());
    15571395  if (!strcmp (op, "mrnd"))   M_FUNC(mrand48());
    1558   if (!strcmp (op, "not"))    M_FUNC(!(*M1));
    1559   if (!strcmp (op, "--"))     M_FUNC(-(*M1));
    15601396  if (!strcmp (op, "ramp"))   M_FUNC(i);
     1397  if (!strcmp (op, "zero"))   M_FUNC(0);
    15611398  if (!strcmp (op, "isinf"))  M_FUNC(!finite(*M1));
    15621399  if (!strcmp (op, "isnan"))  M_FUNC(isnan(*M1));
    1563   if (!strcmp (op, "zero"))   M_FUNC(0);
    15641400
    15651401  /* xrm and yrm only make sense for 2D matrices. see special meaning for vectors */
     
    15751411      }
    15761412    }
    1577     goto escape;
    15781413  }
    15791414  if (!strcmp (op, "yramp")) {
     
    15881423      }
    15891424    }
    1590     goto escape;
    15911425  }
    15921426  if (!strcmp (op, "zramp")) {
     
    16011435      }
    16021436    }
    1603     goto escape;
    1604   }
    1605  
    1606   if (V1[0].type == ST_MATRIX_TMP) {
    1607     free (V1[0].buffer[0].header.buffer);
    1608     free (V1[0].buffer[0].matrix.buffer);
    1609     free (V1[0].buffer);
    1610   }
    1611 
    1612   clear_stack (V1);
    1613 
    1614   char line[512]; // this is only used to report an error
    1615   snprintf (line, 512, "error: op %s not defined as unary matrix op!", op);
    1616   push_error (line);
    1617   return (FALSE);
    1618 
    1619  escape:
    1620 
     1437  }
     1438 
    16211439  if (V1[0].type == ST_MATRIX_TMP) {
    16221440    free (V1[0].buffer[0].header.buffer);
Note: See TracChangeset for help on using the changeset viewer.