IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 17, 2005, 12:20:48 PM (21 years ago)
Author:
eugene
Message:

added erf to stack_math, fixed up precedence order

File:
1 edited

Legend:

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

    r3414 r4305  
    2323    type = 0;
    2424    /* unary operations */
    25     if (!strcmp (argv[i], "abs"))   { type = 7; goto gotit; }
    26     if (!strcmp (argv[i], "int"))   { type = 7; goto gotit; }
    27     if (!strcmp (argv[i], "exp"))   { type = 7; goto gotit; }
    28     if (!strcmp (argv[i], "ten"))   { type = 7; goto gotit; }
    29     if (!strcmp (argv[i], "log"))   { type = 7; goto gotit; }
    30     if (!strcmp (argv[i], "ln"))    { type = 7; goto gotit; }
    31     if (!strcmp (argv[i], "sqrt"))  { type = 7; goto gotit; }
     25    if (!strcmp (argv[i], "abs"))    { type = 7; goto gotit; }
     26    if (!strcmp (argv[i], "int"))    { type = 7; goto gotit; }
     27    if (!strcmp (argv[i], "exp"))    { type = 7; goto gotit; }
     28    if (!strcmp (argv[i], "ten"))    { type = 7; goto gotit; }
     29    if (!strcmp (argv[i], "log"))    { type = 7; goto gotit; }
     30    if (!strcmp (argv[i], "ln"))     { type = 7; goto gotit; }
     31    if (!strcmp (argv[i], "sqrt"))   { type = 7; goto gotit; }
     32    if (!strcmp (argv[i], "erf"))    { type = 7; goto gotit; }
    3233
    3334    if (!strcmp (argv[i], "sinh"))   { type = 7; goto gotit; }
     
    3637    if (!strcmp (argv[i], "acosh"))  { type = 7; goto gotit; }
    3738
    38     if (!strcmp (argv[i], "sin"))   { type = 7; goto gotit; }
    39     if (!strcmp (argv[i], "cos"))   { type = 7; goto gotit; }
    40     if (!strcmp (argv[i], "tan"))   { type = 7; goto gotit; }
    41     if (!strcmp (argv[i], "dsin"))  { type = 7; goto gotit; }
    42     if (!strcmp (argv[i], "dcos"))  { type = 7; goto gotit; }
    43     if (!strcmp (argv[i], "dtan"))  { type = 7; goto gotit; }
    44     if (!strcmp (argv[i], "asin"))  { type = 7; goto gotit; }
    45     if (!strcmp (argv[i], "acos"))  { type = 7; goto gotit; }
    46     if (!strcmp (argv[i], "atan"))  { type = 7; goto gotit; }
    47     if (!strcmp (argv[i], "dasin")) { type = 7; goto gotit; }
    48     if (!strcmp (argv[i], "dacos")) { type = 7; goto gotit; }
    49     if (!strcmp (argv[i], "datan")) { type = 7; goto gotit; }
     39    if (!strcmp (argv[i], "sin"))    { type = 7; goto gotit; }
     40    if (!strcmp (argv[i], "cos"))    { type = 7; goto gotit; }
     41    if (!strcmp (argv[i], "tan"))    { type = 7; goto gotit; }
     42    if (!strcmp (argv[i], "dsin"))   { type = 7; goto gotit; }
     43    if (!strcmp (argv[i], "dcos"))   { type = 7; goto gotit; }
     44    if (!strcmp (argv[i], "dtan"))   { type = 7; goto gotit; }
     45    if (!strcmp (argv[i], "asin"))   { type = 7; goto gotit; }
     46    if (!strcmp (argv[i], "acos"))   { type = 7; goto gotit; }
     47    if (!strcmp (argv[i], "atan"))   { type = 7; goto gotit; }
     48    if (!strcmp (argv[i], "dasin"))  { type = 7; goto gotit; }
     49    if (!strcmp (argv[i], "dacos"))  { type = 7; goto gotit; }
     50    if (!strcmp (argv[i], "datan"))  { type = 7; goto gotit; }
    5051
    5152    if (!strcmp (argv[i], "lgamma")) { type = 7; goto gotit; }
    5253
    53     if (!strcmp (argv[i], "rnd"))   { type = 7; goto gotit; }
    54     if (!strcmp (argv[i], "xramp")) { type = 7; goto gotit; }
    55     if (!strcmp (argv[i], "yramp")) { type = 7; goto gotit; }
    56     if (!strcmp (argv[i], "ramp"))  { type = 7; goto gotit; }
    57     if (!strcmp (argv[i], "zero"))  { type = 7; goto gotit; }
    58     if (!strcmp (argv[i], "--"))    { type = 7; goto gotit; }
    59     if (!strcmp (argv[i], "not"))   { type = 7; goto gotit; }
    60     if (!strcmp (argv[i], "isinf")) { type = 7; goto gotit; }
    61     if (!strcmp (argv[i], "isnan")) { type = 7; goto gotit; }
     54    if (!strcmp (argv[i], "rnd"))    { type = 7; goto gotit; }
     55    if (!strcmp (argv[i], "xramp"))  { type = 7; goto gotit; }
     56    if (!strcmp (argv[i], "yramp"))  { type = 7; goto gotit; }
     57    if (!strcmp (argv[i], "ramp"))   { type = 7; goto gotit; }
     58    if (!strcmp (argv[i], "zero"))   { type = 7; goto gotit; }
     59    if (!strcmp (argv[i], "--"))     { type = 7; goto gotit; }
     60    if (!strcmp (argv[i], "not"))    { type = 7; goto gotit; }
     61    if (!strcmp (argv[i], "isinf"))  { type = 7; goto gotit; }
     62    if (!strcmp (argv[i], "isnan"))  { type = 7; goto gotit; }
    6263
    6364    /* binary operations */
    64     if (!strcmp (argv[i], "^"))     { type = 6; goto gotit; }
    65     if (!strcmp (argv[i], "@"))     { type = 5; goto gotit; }
    66 
    67     if (!strcmp (argv[i], "<"))     { type = 5; goto gotit; }
    68     if (!strcmp (argv[i], ">"))     { type = 5; goto gotit; }
    69     if (!strcmp (argv[i], "&&"))    { type = 5; strcpy (argv[i], "A"); goto gotit; }
    70     if (!strcmp (argv[i], "||"))    { type = 5; strcpy (argv[i], "O"); goto gotit; }
    71     if (!strcmp (argv[i], "=="))    { type = 5; strcpy (argv[i], "E"); goto gotit; }
    72     if (!strcmp (argv[i], "!="))    { type = 5; strcpy (argv[i], "N"); goto gotit; }
    73     if (!strcmp (argv[i], "<="))    { type = 5; strcpy (argv[i], "L"); goto gotit; }
    74     if (!strcmp (argv[i], ">="))    { type = 5; strcpy (argv[i], "G"); goto gotit; }
    75     if (!strcmp (argv[i], ">>"))    { type = 5; strcpy (argv[i], "U"); goto gotit; }
    76     if (!strcmp (argv[i], "<<"))    { type = 5; strcpy (argv[i], "D"); goto gotit; }
    77 
    78     if (!strcmp (argv[i], "&"))     { type = 5; goto gotit; }
    79     if (!strcmp (argv[i], "|"))     { type = 5; goto gotit; }
    80 
    81     if (!strcmp (argv[i], "/"))     { type = 4; goto gotit; }
    82     if (!strcmp (argv[i], "*"))     { type = 4; goto gotit; }
    83 
    84     if (!strcmp (argv[i], "+"))     { type = 3; goto gotit; }
    85     if (!strcmp (argv[i], "-"))     { type = 3; goto gotit; }
     65    if (!strcmp (argv[i], "^"))      { type = 6; goto gotit; }
     66
     67    if (!strcmp (argv[i], "@"))      { type = 5; goto gotit; }
     68    if (!strcmp (argv[i], "/"))      { type = 5; goto gotit; }
     69    if (!strcmp (argv[i], "*"))      { type = 5; goto gotit; }
     70
     71    if (!strcmp (argv[i], "+"))      { type = 4; goto gotit; }
     72    if (!strcmp (argv[i], "-"))      { type = 4; goto gotit; }
    8673       
    87     if (!strcmp (argv[i], "("))     { type = 2; goto gotit; }
    88     if (!strcmp (argv[i], ")"))     { type = 1; goto gotit; }
     74    if (!strcmp (argv[i], "<"))      { type = 3; goto gotit; }
     75    if (!strcmp (argv[i], ">"))      { type = 3; goto gotit; }
     76    if (!strcmp (argv[i], "&&"))     { type = 3; strcpy (argv[i], "A"); goto gotit; }
     77    if (!strcmp (argv[i], "||"))     { type = 3; strcpy (argv[i], "O"); goto gotit; }
     78    if (!strcmp (argv[i], "=="))     { type = 3; strcpy (argv[i], "E"); goto gotit; }
     79    if (!strcmp (argv[i], "!="))     { type = 3; strcpy (argv[i], "N"); goto gotit; }
     80    if (!strcmp (argv[i], "<="))     { type = 3; strcpy (argv[i], "L"); goto gotit; }
     81    if (!strcmp (argv[i], ">="))     { type = 3; strcpy (argv[i], "G"); goto gotit; }
     82    if (!strcmp (argv[i], ">>"))     { type = 3; strcpy (argv[i], "U"); goto gotit; }
     83    if (!strcmp (argv[i], "<<"))     { type = 3; strcpy (argv[i], "D"); goto gotit; }
     84    if (!strcmp (argv[i], "&"))      { type = 3; goto gotit; }
     85    if (!strcmp (argv[i], "|"))      { type = 3; goto gotit; }
     86
     87    if (!strcmp (argv[i], "("))      { type = 2; goto gotit; }
     88    if (!strcmp (argv[i], ")"))      { type = 1; goto gotit; }
    8989
    9090  gotit:
    9191    /* choose how to deal with object */
    9292    switch (type) {
    93     case 6:  /* unary OPs */
     93    case 6:  /* exponentiation */
    9494      /* pop previous, higher operators from OP stack to stack */
    9595      for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type > type); j--) {
     
    104104      Nop_stack ++;
    105105      break;
    106     case 7: /* binary OPs */
     106    case 7: /* unary OPs */
    107107    case 5: /* binary OPs */
    108108    case 4:
Note: See TracChangeset for help on using the changeset viewer.