Changeset 4305
- Timestamp:
- Jun 17, 2005, 12:20:48 PM (21 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 4 edited
-
lib.shell/convert_to_RPN.c (modified) (3 diffs)
-
lib.shell/evaluate_stack.c (modified) (1 diff)
-
lib.shell/stack_math.c (modified) (3 diffs)
-
scripts/test.pro (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c
r3414 r4305 23 23 type = 0; 24 24 /* 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; } 32 33 33 34 if (!strcmp (argv[i], "sinh")) { type = 7; goto gotit; } … … 36 37 if (!strcmp (argv[i], "acosh")) { type = 7; goto gotit; } 37 38 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; } 50 51 51 52 if (!strcmp (argv[i], "lgamma")) { type = 7; goto gotit; } 52 53 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; } 62 63 63 64 /* 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; } 86 73 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; } 89 89 90 90 gotit: 91 91 /* choose how to deal with object */ 92 92 switch (type) { 93 case 6: /* unary OPs*/93 case 6: /* exponentiation */ 94 94 /* pop previous, higher operators from OP stack to stack */ 95 95 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type > type); j--) { … … 104 104 Nop_stack ++; 105 105 break; 106 case 7: /* binary OPs */106 case 7: /* unary OPs */ 107 107 case 5: /* binary OPs */ 108 108 case 4: -
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
r3318 r4305 75 75 TWO_OP ("S","W",WW_binary); 76 76 77 /*78 if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "V", 1))79 status = VV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);80 if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "S", 1))81 status = VS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);82 if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "V", 1))83 status = SV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);84 if (!strncasecmp (&stack[i - 2].type, "M", 1) && !strncasecmp (&stack[i - 1].type, "V", 1))85 status = MV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);86 if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "M", 1))87 status = VM_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);88 if (!strncasecmp (&stack[i - 2].type, "M", 1) && !strncasecmp (&stack[i - 1].type, "M", 1))89 status = MM_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);90 if (!strncasecmp (&stack[i - 2].type, "M", 1) && !strncasecmp (&stack[i - 1].type, "S", 1))91 status = MS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);92 if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "M", 1))93 status = SM_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);94 if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "S", 1))95 status = SS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);96 if (!strncasecmp (&stack[i - 2].type, "X", 1) && !strncasecmp (&stack[i - 1].type, "X", 1))97 status = XX_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);98 */99 100 /* string op number is not valid101 if (!strncasecmp (&stack[i - 2].type, "W", 1) && strncasecmp (&stack[i - 1].type, "W", 1)) {102 free (tmp_stack.name);103 return (FALSE);104 }105 if (strncasecmp (&stack[i - 2].type, "W", 1) && !strncasecmp (&stack[i - 1].type, "W", 1)) {106 free (tmp_stack.name);107 return (FALSE);108 } */109 110 77 if (!status) { 111 78 free (tmp_stack.name); -
trunk/Ohana/src/opihi/lib.shell/stack_math.c
r3318 r4305 1166 1166 if (!strcmp (op, "ln")) { *out = log (*M1); } 1167 1167 if (!strcmp (op, "sqrt")) { *out = sqrt (*M1); } 1168 if (!strcmp (op, "erf")) { *out = erf (*M1); } 1168 1169 1169 1170 if (!strcmp (op, "sinh")) { *out = sinh (*M1); } … … 1223 1224 if (!strcmp (op, "ln")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = log(*M1); }} 1224 1225 if (!strcmp (op, "sqrt")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = sqrt(*M1); }} 1226 if (!strcmp (op, "erf")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = erf(*M1); }} 1225 1227 1226 1228 if (!strcmp (op, "sinh")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = sinh(*M1); }} … … 1289 1291 if (!strcmp (op, "ln")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = log(*M1); }} 1290 1292 if (!strcmp (op, "sqrt")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = sqrt(*M1); }} 1293 if (!strcmp (op, "erf")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = erf(*M1); }} 1291 1294 1292 1295 if (!strcmp (op, "sinh")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = sinh(*M1); }} -
trunk/Ohana/src/opihi/scripts/test.pro
r3689 r4305 1 2 macro testgauss 3 create x -20 20 0.1 4 set dy = zero(x) + 0.03 5 set X = x - $1 6 set y = $3*exp(-0.5*(X^2/$2^2)) + $4 + 0.1*(rnd(X) - 0.5) 7 # set y = $3*exp(-0.5*(X^2/$2^2)) + $4 8 lim x y; clear; box; plot x y -dy dy -x 2 -pt 2 9 10 $C0 = $1+5 11 $C1 = $2-10 12 $C2 = $3 13 $C3 = $4 14 15 vgauss x y dy yf 16 end 17 18 macro testpoor 19 create x -20 20 0.1 20 set dy = zero(x) + 0.03 21 set X = x - $1 22 set y = 3 + zero(x) + 0.1*(rnd(X) - 0.5) 23 # set y = (x + 20)/10 + $4 + 0.1*(rnd(X) - 0.5) 24 # set y = $3*exp(-0.5*(X^2/$2^2)) + $4 25 lim x y; clear; box; plot x y -dy dy -x 2 -pt 2 26 27 $C0 = $1 28 $C1 = $2 29 $C2 = $3 30 $C3 = $4 31 32 vgauss x y dy yf 33 end 1 34 2 35 macro testfit
Note:
See TracChangeset
for help on using the changeset viewer.
