Changeset 20856
- Timestamp:
- Nov 28, 2008, 8:45:10 AM (17 years ago)
- Location:
- branches/eam_branch_20081124/Ohana/src/opihi
- Files:
-
- 17 edited
-
cmd.data/create.c (modified) (2 diffs)
-
dvo/mextract.c (modified) (1 diff)
-
dvo/mmextract.c (modified) (1 diff)
-
include/dvomath.h (modified) (1 diff)
-
lib.data/graphtools.c (modified) (2 diffs)
-
lib.shell/VectorOps.c (modified) (3 diffs)
-
lib.shell/check_stack.c (modified) (2 diffs)
-
lib.shell/dvomath.c (modified) (1 diff)
-
lib.shell/evaluate_stack.c (modified) (1 diff)
-
lib.shell/expand_vectors.c (modified) (1 diff)
-
lib.shell/multicommand.c (modified) (4 diffs)
-
lib.shell/parse.c (modified) (1 diff)
-
lib.shell/stack_math.c (modified) (21 diffs)
-
mana/findpeaks.c (modified) (1 diff)
-
mana/fitcontour.c (modified) (1 diff)
-
mana/rawstars.c (modified) (1 diff)
-
mana/starcontour.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/create.c
r20839 r20856 3 3 int create (int argc, char **argv) { 4 4 5 int i ;5 int i, N, INT; 6 6 float start, end, delta; 7 7 Vector *vec; 8 8 9 INT = FALSE; 10 if ((N = get_argument (argc, argv, "-int"))) { 11 INT = TRUE; 12 remove_argument (N, &argc, argv); 13 } 14 9 15 if ((argc != 5) && (argc != 4)) { 10 16 gprint (GP_ERR, "USAGE: create vector start end [delta]\n"); … … 27 33 } 28 34 35 if (INT && (delta != (int)delta)) { 36 gprint (GP_ERR, "integer vector requested but fractional step-size specified\n"); 37 return (FALSE); 38 } 39 29 40 vec[0].Nelements = (end - start) / delta; 30 REALLOCATE (vec[0].elements.Flt, opihi_flt, vec[0].Nelements);31 41 32 for (i = 0; i < vec[0].Nelements; i++) { 33 vec[0].elements.Flt[i] = start + i*delta; 42 if (INT) { 43 vec[0].type = OPIHI_INT; 44 REALLOCATE (vec[0].elements.Int, opihi_int, vec[0].Nelements); 45 for (i = 0; i < vec[0].Nelements; i++) { 46 vec[0].elements.Int[i] = start + i*delta; 47 } 48 } else { 49 vec[0].type = OPIHI_FLT; 50 REALLOCATE (vec[0].elements.Flt, opihi_flt, vec[0].Nelements); 51 for (i = 0; i < vec[0].Nelements; i++) { 52 vec[0].elements.Flt[i] = start + i*delta; 53 } 34 54 } 35 55 -
branches/eam_branch_20081124/Ohana/src/opihi/dvo/mextract.c
r20839 r20856 97 97 } 98 98 if ((vec[i] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) goto escape; 99 ResetVector (vec[i], fields[i].type, NNN); 99 100 } 100 101 -
branches/eam_branch_20081124/Ohana/src/opihi/dvo/mmextract.c
r20839 r20856 152 152 if ((vec[2*i+0] = SelectVector (name1, ANYVECTOR, TRUE)) == NULL) goto escape; 153 153 if ((vec[2*i+1] = SelectVector (name2, ANYVECTOR, TRUE)) == NULL) goto escape; 154 ResetVector (vec[2*i+0], fields[i].type, NNN); 155 ResetVector (vec[2*i+1], fields[i].type, NNN); 154 156 } 155 157 -
branches/eam_branch_20081124/Ohana/src/opihi/include/dvomath.h
r20839 r20856 97 97 void InitVectors PROTO((void)); 98 98 int CopyVector PROTO((Vector *out, Vector *in)); 99 int MatchVector PROTO((Vector *out, Vector *in, char type)); 99 100 int MoveVector PROTO((Vector *out, Vector *in)); 100 101 int DeleteVector PROTO((Vector *vec)); -
branches/eam_branch_20081124/Ohana/src/opihi/lib.data/graphtools.c
r20839 r20856 8 8 9 9 if (xvec != NULL) { 10 maxX = minX = xvec[0].elements.Flt[0]; 11 for (i = 1; i < xvec[0].Nelements; i++) { 12 if (!finite(xvec[0].elements.Flt[i])) continue; 13 maxX = MAX (maxX, xvec[0].elements.Flt[i]); 14 minX = MIN (minX, xvec[0].elements.Flt[i]); 10 if (xvec->type == OPIHI_FLT) { 11 maxX = minX = xvec[0].elements.Flt[0]; 12 for (i = 1; i < xvec[0].Nelements; i++) { 13 if (!finite(xvec[0].elements.Flt[i])) continue; 14 maxX = MAX (maxX, xvec[0].elements.Flt[i]); 15 minX = MIN (minX, xvec[0].elements.Flt[i]); 16 } 17 } else { 18 maxX = minX = xvec[0].elements.Int[0]; 19 for (i = 1; i < xvec[0].Nelements; i++) { 20 if (!finite(xvec[0].elements.Int[i])) continue; 21 maxX = MAX (maxX, xvec[0].elements.Int[i]); 22 minX = MIN (minX, xvec[0].elements.Int[i]); 23 } 15 24 } 16 25 range = maxX - minX; … … 22 31 23 32 if (yvec != NULL) { 24 maxY = minY = yvec[0].elements.Flt[0]; 25 for (i = 1; i < yvec[0].Nelements; i++) { 26 if (!finite(yvec[0].elements.Flt[i])) continue; 27 maxY = MAX (maxY, yvec[0].elements.Flt[i]); 28 minY = MIN (minY, yvec[0].elements.Flt[i]); 33 if (xvec->type == OPIHI_FLT) { 34 maxY = minY = yvec[0].elements.Flt[0]; 35 for (i = 1; i < yvec[0].Nelements; i++) { 36 if (!finite(yvec[0].elements.Flt[i])) continue; 37 maxY = MAX (maxY, yvec[0].elements.Flt[i]); 38 minY = MIN (minY, yvec[0].elements.Flt[i]); 39 } 40 } else { 41 maxY = minY = yvec[0].elements.Int[0]; 42 for (i = 1; i < yvec[0].Nelements; i++) { 43 if (!finite(yvec[0].elements.Int[i])) continue; 44 maxY = MAX (maxY, yvec[0].elements.Int[i]); 45 minY = MIN (minY, yvec[0].elements.Int[i]); 46 } 29 47 } 30 48 range = maxY - minY; -
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/VectorOps.c
r20839 r20856 63 63 } 64 64 65 // XXX add TYPE to arguments? 65 66 Vector *SelectVector (char *name, int mode, int verbose) { 66 67 … … 159 160 } 160 161 162 int MatchVector(Vector *out, Vector *in, char type) { 163 if (out[0].elements.Ptr) free (out[0].elements.Ptr); 164 out[0].Nelements = in[0].Nelements; 165 if (type == OPIHI_FLT) { 166 ALLOCATE (out[0].elements.Flt, opihi_flt, out[0].Nelements); 167 out[0].type = OPIHI_FLT; 168 } else { 169 ALLOCATE (out[0].elements.Int, opihi_int, out[0].Nelements); 170 out[0].type = OPIHI_INT; 171 } 172 return (TRUE); 173 } 174 175 // ResetVector (vecx, OPIHI_FLT, MAX (Npts, 1)); 176 int ResetVector (Vector *vec, char type, int Nelements) { 177 178 vec[0].Nelements = Nelements; 179 if (type == OPIHI_FLT) { 180 REALLOCATE (vec[0].elements.Flt, opihi_flt, Nelements); 181 vec[0].type = OPIHI_FLT; 182 } else { 183 REALLOCATE (vec[0].elements.Int, opihi_int, Nelements); 184 vec[0].type = OPIHI_INT; 185 } 186 return TRUE; 187 } 188 161 189 /* move data from in to out - use old memory space */ 162 190 int MoveNamedVector (char *out, char *in) { … … 203 231 gprint (GP_LOG, " N name size\n"); 204 232 for (i = 0; i < Nvectors; i++) { 205 gprint (GP_LOG, "%5d %10s %10d\n", 206 i, vectors[i][0].name, vectors[i][0].Nelements); 207 } 208 return (TRUE); 209 } 210 233 if (vectors[i][0].type == OPIHI_FLT) { 234 gprint (GP_LOG, "%5d %10s %10d (FLT)\n", i, vectors[i][0].name, vectors[i][0].Nelements); 235 } else { 236 gprint (GP_LOG, "%5d %10s %10d (INT)\n", i, vectors[i][0].name, vectors[i][0].Nelements); 237 } 238 } 239 return (TRUE); 240 } 241 -
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/check_stack.c
r20839 r20856 4 4 5 5 int i, Nx, Ny, Nv, size; 6 char *c ;6 char *c1, *c2; 7 7 8 8 Nv = Nx = Ny = -1; … … 11 11 if (stack[i].type == 'X') { 12 12 13 /** if this is a number, put it on the list of scalers and move on **/ 14 // XXX need to handle IntValue vs FltValue 15 stack[i].FltValue = strtod (stack[i].name, &c); 16 if (c == stack[i].name + strlen (stack[i].name)) { 17 stack[i].type = 'S'; 13 /** if this is a number, put it on the list of scalars and move on. assume value is 14 * an int unless proven otherwise **/ 15 stack[i].FltValue = strtod (stack[i].name, &c1); 16 stack[i].IntValue = strtol (stack[i].name, &c2, 0); 17 if (c2 == stack[i].name + strlen (stack[i].name)) { 18 stack[i].type = 's'; // 's' == (int) 19 continue; 20 } 21 if (c1 == stack[i].name + strlen (stack[i].name)) { 22 stack[i].type = 'S'; // 'S' == (float) 18 23 continue; 19 24 } -
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/dvomath.c
r20839 r20856 76 76 case 0: 77 77 if (Ncstack == 1) { 78 /* use exact input work*/79 sprintf (outname, "%s", stack[0].name);78 /* use exact input word */ 79 sprintf (outname, "%s", stack[0].name); 80 80 } else { 81 if (stack[0].type == 's') { 82 sprintf (outname, "%d", stack[0].IntValue); 83 } else { 81 84 sprintf (outname, "%.12g", stack[0].FltValue); 85 } 82 86 } 83 87 break; -
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/evaluate_stack.c
r20839 r20856 21 21 22 22 if (*Nstack == 1) { 23 if ( stack[0].type == 'S') {23 if ((stack[0].type == 'S') || (stack[0].type == 's')) { 24 24 clear_stack (&tmp_stack); 25 25 return (TRUE); -
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/expand_vectors.c
r20839 r20856 126 126 } 127 127 if (I < 0) I += vec[0].Nelements; 128 f1 = vec[0].elements.Flt[I]; 128 if (vec[0].type == OPIHI_FLT) { 129 f1 = vec[0].elements.Flt[I]; 130 } else { 131 f1 = vec[0].elements.Int[I]; 132 } 129 133 } 130 134 } -
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/multicommand.c
r19789 r20856 88 88 exit (32); 89 89 default: 90 gprint (GP_ERR, "server is busy... \n");90 gprint (GP_ERR, "server is busy...32\n"); 91 91 bufferPending = TRUE; 92 92 goto escape; … … 101 101 exit (33); 102 102 default: 103 gprint (GP_ERR, "server is busy... \n");103 gprint (GP_ERR, "server is busy...33\n"); 104 104 bufferPending = TRUE; 105 105 goto escape; … … 116 116 exit (34); 117 117 default: 118 gprint (GP_ERR, "server is busy... \n");118 gprint (GP_ERR, "server is busy...34\n"); 119 119 bufferPending = TRUE; 120 120 goto escape; … … 131 131 exit (35); 132 132 default: 133 gprint (GP_ERR, "server is busy... \n");133 gprint (GP_ERR, "server is busy...35\n"); 134 134 bufferPending = TRUE; 135 135 goto escape; -
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/parse.c
r20839 r20856 190 190 } 191 191 if (Nx < 0) Nx += vec[0].Nelements; 192 vec[0].elements.Flt[Nx] = atof (val); 192 if (vec[0].type == OPIHI_FLT) { 193 vec[0].elements.Flt[Nx] = atof (val); 194 } else { 195 vec[0].elements.Int[Nx] = atol (val); 196 } 193 197 } 194 198 -
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/stack_math.c
r20839 r20856 4 4 labeled by "m". if one of the input matrices is already a temp variable, we 5 5 can continue using it this round 6 */ 6 */ 7 8 // XXX we temporarily drop the concept of using one of the temporary input vectors for 9 // the output vector (thus saving an ALLOC): we have to juggle the size of the input vectors 10 // as well as their temporary state 7 11 8 12 int VV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { … … 18 22 Nx = V1[0].vector[0].Nelements; 19 23 20 // XXX we temporarily drop the concept of using one of the temporary input vectors for21 // the output vector (thus saving an ALLOC): we have to juggle the size of the input vectors22 // as well as their temporary state23 24 24 // create the output vector guaranteed to be temporary until the very end 25 25 OUT[0].vector = InitVector (); … … 28 28 // set up the possible operations : int OP int -> int, all else yield float 29 29 // OP is the operation performed on *M1 and *M2 30 # define VV_FUNC(OP) \31 if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_FLT)) { \32 CopyVector (OUT[0].vector, V1[0].vector);\33 opihi_flt *M1 = V1[0].vector[0].elements.Flt;\34 opihi_flt *M2 = V2[0].vector[0].elements.Flt;\35 opihi_flt *out = OUT[0].vector[0].elements.Flt;\36 for (i = 0; i < Nx; i++, out++, M1++, M2++) {\37 *out = OP; \38 }\39 break;\40 }\41 if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \42 CopyVector (OUT[0].vector, V1[0].vector);\43 opihi_flt *M1 = V1[0].vector[0].elements.Flt;\44 opihi_int *M2 = V2[0].vector[0].elements.Int;\45 opihi_flt *out = OUT[0].vector[0].elements.Flt;\46 for (i = 0; i < Nx; i++, out++, M1++, M2++) {\47 *out = OP; \48 }\49 break;\50 }\51 if ((V1->vector->type != OPIHI_FLT) && (V2->vector->type == OPIHI_FLT)) { \52 CopyVector (OUT[0].vector, V2[0].vector);\53 opihi_int *M1 = V1[0].vector[0].elements.Int;\54 opihi_flt *M2 = V2[0].vector[0].elements.Flt;\55 opihi_flt *out = OUT[0].vector[0].elements.Flt;\56 for (i = 0; i < Nx; i++, out++, M1++, M2++) {\57 *out = OP; \58 }\59 break;\60 }\61 if ((V1->vector->type != OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \62 CopyVector (OUT[0].vector, V1[0].vector);\63 opihi_int *M1 = V1[0].vector[0].elements.Int;\64 opihi_int *M2 = V2[0].vector[0].elements.Int;\65 opihi_int *out = OUT[0].vector[0].elements.Int;\66 for (i = 0; i < Nx; i++, out++, M1++, M2++) {\67 *out = OP; \68 }\69 break;\70 }30 # define VV_FUNC(OP) { \ 31 if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_FLT)) { \ 32 CopyVector (OUT[0].vector, V1[0].vector); \ 33 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 34 opihi_flt *M2 = V2[0].vector[0].elements.Flt; \ 35 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 36 for (i = 0; i < Nx; i++, out++, M1++, M2++) { \ 37 *out = OP; \ 38 } \ 39 break; \ 40 } \ 41 if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 42 CopyVector (OUT[0].vector, V1[0].vector); \ 43 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 44 opihi_int *M2 = V2[0].vector[0].elements.Int; \ 45 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 46 for (i = 0; i < Nx; i++, out++, M1++, M2++) { \ 47 *out = OP; \ 48 } \ 49 break; \ 50 } \ 51 if ((V1->vector->type != OPIHI_FLT) && (V2->vector->type == OPIHI_FLT)) { \ 52 CopyVector (OUT[0].vector, V2[0].vector); \ 53 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 54 opihi_flt *M2 = V2[0].vector[0].elements.Flt; \ 55 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 56 for (i = 0; i < Nx; i++, out++, M1++, M2++) { \ 57 *out = OP; \ 58 } \ 59 break; \ 60 } \ 61 if ((V1->vector->type != OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 62 CopyVector (OUT[0].vector, V1[0].vector); \ 63 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 64 opihi_int *M2 = V2[0].vector[0].elements.Int; \ 65 opihi_int *out = OUT[0].vector[0].elements.Int; \ 66 for (i = 0; i < Nx; i++, out++, M1++, M2++) { \ 67 *out = OP; \ 68 } \ 69 break; \ 70 } } 71 71 72 72 switch (op[0]) { … … 90 90 case 'A': VV_FUNC((*M1 && *M2) ? 1 : 0); 91 91 case 'O': VV_FUNC((*M1 || *M2) ? 1 : 0); 92 default:93 sprintf (line, "error: op %c not defined!", op[0]);94 push_error (line);95 return (FALSE);92 default: 93 sprintf (line, "error: op %c not defined!", op[0]); 94 push_error (line); 95 return (FALSE); 96 96 } 97 97 # undef VV_FUNC … … 122 122 Nx = V2[0].vector[0].Nelements; 123 123 124 if (V2[0].type == 'v') { /** use V2 as temp buffer, but header of V1 **/ 125 OUT[0].vector = V2[0].vector; 126 V2[0].type = 'V'; /* prevent it from being freed below */ 127 } else { /* no spare temp buffer */ 128 OUT[0].vector = InitVector (); 129 CopyVector (OUT[0].vector, V2[0].vector); 130 } 124 OUT[0].vector = InitVector (); 131 125 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/ 132 126 133 opihi_flt M1 = V1[0].FltValue; 134 opihi_flt *M2 = V2[0].vector[0].elements.Flt; 135 opihi_flt *out = OUT[0].vector[0].elements.Flt; 136 137 # define SV_FUNC(OP) \ 138 for (i = 0; i < Nx; i++, out++, M2++) \ 139 *out = OP; \ 140 break; 127 // set up the possible operations : int OP int -> int, all else yield float 128 // OP is the operation performed on *M1 and *M2 129 # define SV_FUNC(OP) \ 130 if ((V1->type == 'S') && (V2->vector->type == OPIHI_FLT)) { \ 131 CopyVector (OUT[0].vector, V2[0].vector); \ 132 opihi_flt M1 = V1[0].FltValue; \ 133 opihi_flt *M2 = V2[0].vector[0].elements.Flt; \ 134 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 135 for (i = 0; i < Nx; i++, out++, M2++) { \ 136 *out = OP; \ 137 } \ 138 break; \ 139 } \ 140 if ((V1->type == 'S') && (V2->vector->type != OPIHI_FLT)) { \ 141 MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT); \ 142 opihi_flt M1 = V1[0].FltValue; \ 143 opihi_int *M2 = V2[0].vector[0].elements.Int; \ 144 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 145 for (i = 0; i < Nx; i++, out++, M2++) { \ 146 *out = OP; \ 147 } \ 148 break; \ 149 } \ 150 if ((V1->type == 's') && (V2->vector->type == OPIHI_FLT)) { \ 151 CopyVector (OUT[0].vector, V2[0].vector); \ 152 opihi_int M1 = V1[0].IntValue; \ 153 opihi_flt *M2 = V2[0].vector[0].elements.Flt; \ 154 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 155 for (i = 0; i < Nx; i++, out++, M2++) { \ 156 *out = OP; \ 157 } \ 158 break; \ 159 } \ 160 if ((V1->type == 's') && (V2->vector->type != OPIHI_FLT)) { \ 161 CopyVector (OUT[0].vector, V2[0].vector); \ 162 opihi_int M1 = V1[0].IntValue; \ 163 opihi_int *M2 = V2[0].vector[0].elements.Int; \ 164 opihi_int *out = OUT[0].vector[0].elements.Int; \ 165 for (i = 0; i < Nx; i++, out++, M2++) { \ 166 *out = OP; \ 167 } \ 168 break; \ 169 } 141 170 142 171 switch (op[0]) { … … 188 217 Nx = V1[0].vector[0].Nelements; 189 218 190 if (V1[0].type == 'v') { /** use V1 as temp buffer **/ 191 OUT[0].vector = V1[0].vector; 192 V1[0].type = 'V'; /* prevent it from being freed below */ 193 } else { /* no spare temp buffer */ 194 OUT[0].vector = InitVector (); 195 CopyVector (OUT[0].vector, V1[0].vector); 196 } 219 OUT[0].vector = InitVector (); 197 220 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/ 198 221 199 opihi_flt *M1 = V1[0].vector[0].elements.Flt; 200 opihi_flt M2 = V2[0].FltValue; 201 opihi_flt *out = OUT[0].vector[0].elements.Flt; 202 203 # define VS_FUNC(OP) \ 204 for (i = 0; i < Nx; i++, out++, M1++) \ 205 *out = OP; \ 206 break; 222 // set up the possible operations : int OP int -> int, all else yield float 223 // OP is the operation performed on *M1 and *M2 224 # define VS_FUNC(OP) \ 225 if ((V2->type == 'S') && (V1->vector->type == OPIHI_FLT)) { \ 226 CopyVector (OUT[0].vector, V1[0].vector); \ 227 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 228 opihi_flt M2 = V2[0].FltValue; \ 229 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 230 for (i = 0; i < Nx; i++, out++, M1++) { \ 231 *out = OP; \ 232 } \ 233 break; \ 234 } \ 235 if ((V2->type == 'S') && (V1->vector->type != OPIHI_FLT)) { \ 236 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 237 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 238 opihi_flt M2 = V2[0].FltValue; \ 239 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 240 for (i = 0; i < Nx; i++, out++, M1++) { \ 241 *out = OP; \ 242 } \ 243 break; \ 244 } \ 245 if ((V2->type == 's') && (V1->vector->type == OPIHI_FLT)) { \ 246 CopyVector (OUT[0].vector, V1[0].vector); \ 247 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 248 opihi_int M2 = V2[0].IntValue; \ 249 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 250 for (i = 0; i < Nx; i++, out++, M1++) { \ 251 *out = OP; \ 252 } \ 253 break; \ 254 } \ 255 if ((V2->type == 's') && (V1->vector->type != OPIHI_FLT)) { \ 256 CopyVector (OUT[0].vector, V1[0].vector); \ 257 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 258 opihi_int M2 = V2[0].IntValue; \ 259 opihi_int *out = OUT[0].vector[0].elements.Int; \ 260 for (i = 0; i < Nx; i++, out++, M1++) { \ 261 *out = OP; \ 262 } \ 263 break; \ 264 } 207 265 208 266 switch (op[0]) { … … 276 334 float *out = (float *)OUT[0].buffer[0].matrix.buffer; 277 335 278 # define MV_FUNC(OP) \279 for (i = 0; i < Ny; i++, M2++) {\280 for (j = 0; j < Nx; j++, out++, M1++) {\281 *out = OP;\282 }\283 }\284 break;336 # define MV_FUNC(OP) \ 337 for (i = 0; i < Ny; i++, M2++) { \ 338 for (j = 0; j < Nx; j++, out++, M1++) { \ 339 *out = OP; \ 340 } \ 341 } \ 342 break; 285 343 286 344 switch (op[0]) { … … 355 413 float *out = (float *)OUT[0].buffer[0].matrix.buffer; 356 414 357 # define VM_FUNC(OP) \358 for (i = 0; i < Ny; i++) {\359 M1 = V1[0].vector[0].elements.Flt;\360 for (j = 0; j < Nx; j++, out++, M1++, M2++) {\361 *out = OP;\362 }\363 }\364 break;415 # define VM_FUNC(OP) \ 416 for (i = 0; i < Ny; i++) { \ 417 M1 = V1[0].vector[0].elements.Flt; \ 418 for (j = 0; j < Nx; j++, out++, M1++, M2++) { \ 419 *out = OP; \ 420 } \ 421 } \ 422 break; 365 423 366 424 switch (op[0]) { … … 437 495 out = (float *)OUT[0].buffer[0].matrix.buffer; 438 496 497 # define MM_FUNC(OP) \ 498 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) { \ 499 *out = OP; \ 500 } \ 501 break; 502 439 503 switch (op[0]) { 440 case '+': 441 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 442 *out = *M1 + *M2; 443 break; 444 case '-': 445 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 446 *out = *M1 - *M2; 447 break; 448 case '*': 449 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 450 *out = *M1 * *M2; 451 break; 452 case '/': 453 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 454 *out = *M1 / *M2; 455 break; 456 case '%': 457 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 458 *out = (int) *M1 % (int) *M2; 459 break; 460 case 0x5e: 461 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 462 *out = pow (*M1, *M2); 463 break; 464 case '@': 465 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 466 *out = DEG_RAD*atan2 (*M1, *M2); 467 break; 468 case 'D': 469 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 470 *out = MIN (*M1, *M2); 471 break; 472 case 'U': 473 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 474 *out = MAX (*M1, *M2); 475 break; 476 case '<': 477 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 478 *out = (*M1 < *M2) ? 1 : 0; 479 break; 480 case '>': 481 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 482 *out = (*M1 > *M2) ? 1 : 0; 483 break; 484 case '&': 485 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 486 *out = ((int)*M1 & (int)*M2); 487 break; 488 case '|': 489 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 490 *out = ((int)*M1 | (int)*M2); 491 break; 492 case 'E': 493 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 494 *out = (*M1 == *M2) ? 1 : 0; 495 break; 496 case 'N': 497 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 498 *out = (*M1 != *M2) ? 1 : 0; 499 break; 500 case 'L': 501 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 502 *out = (*M1 <= *M2) ? 1 : 0; 503 break; 504 case 'G': 505 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 506 *out = (*M1 >= *M2) ? 1 : 0; 507 break; 508 case 'A': 509 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 510 *out = (*M1 && *M2) ? 1 : 0; 511 break; 512 case 'O': 513 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++) 514 *out = (*M1 || *M2) ? 1 : 0; 515 break; 516 default: 517 sprintf (line, "error: op %c not defined!", op[0]); 518 push_error (line); 519 return (FALSE); 520 } 504 case '+': MM_FUNC(*M1 + *M2); 505 case '-': MM_FUNC(*M1 - *M2); 506 case '*': MM_FUNC(*M1 * *M2); 507 case '/': MM_FUNC(*M1 / *M2); 508 case '%': MM_FUNC((int) *M1 % (int) *M2); 509 case '^': MM_FUNC(pow (*M1, *M2)); 510 case '@': MM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 511 case 'D': MM_FUNC(MIN (*M1, *M2)); 512 case 'U': MM_FUNC(MAX (*M1, *M2)); 513 case '<': MM_FUNC((*M1 < *M2) ? 1 : 0); 514 case '>': MM_FUNC((*M1 > *M2) ? 1 : 0); 515 case '&': MM_FUNC(((int)*M1 & (int)*M2)); 516 case '|': MM_FUNC(((int)*M1 | (int)*M2)); 517 case 'E': MM_FUNC((*M1 == *M2) ? 1 : 0); 518 case 'N': MM_FUNC((*M1 != *M2) ? 1 : 0); 519 case 'L': MM_FUNC((*M1 <= *M2) ? 1 : 0); 520 case 'G': MM_FUNC((*M1 >= *M2) ? 1 : 0); 521 case 'A': MM_FUNC((*M1 && *M2) ? 1 : 0); 522 case 'O': MM_FUNC((*M1 || *M2) ? 1 : 0); 523 default: 524 sprintf (line, "error: op %c not defined!", op[0]); 525 push_error (line); 526 return (FALSE); 527 } 528 # undef MM_FUNC 521 529 522 530 /** free up any temporary buffers: **/ … … 538 546 /* at the end, V1 and V2 are deleted only if they were temporary */ 539 547 return (TRUE); 540 541 } 542 548 } 543 549 544 550 int MS_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 545 551 546 552 int i, Nx, Ny; 547 float *out, *M1;548 opihi_flt M2;549 553 char line[512]; // this is only used to report an error 550 554 … … 562 566 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/ 563 567 564 M1 = (float *)V1[0].buffer[0].matrix.buffer; 565 M2 = V2[0].FltValue; 566 out = (float *)OUT[0].buffer[0].matrix.buffer; 568 float *M1 = (float *)V1[0].buffer[0].matrix.buffer; 569 opihi_flt M2 = V2[0].FltValue; 570 float *out = (float *)OUT[0].buffer[0].matrix.buffer; 571 572 # define MS_FUNC(OP) \ 573 for (i = 0; i < Nx*Ny; i++, out++, M1++) { \ 574 *out = OP; \ 575 } \ 576 break; 567 577 568 578 switch (op[0]) { 569 case '+': 570 for (i = 0; i < Nx*Ny; i++, out++, M1++) 571 *out = *M1 + M2; 572 break; 573 case '-': 574 for (i = 0; i < Nx*Ny; i++, out++, M1++) 575 *out = *M1 - M2; 576 break; 577 case '*': 578 for (i = 0; i < Nx*Ny; i++, out++, M1++) 579 *out = *M1 * M2; 580 break; 581 case '/': 582 for (i = 0; i < Nx*Ny; i++, out++, M1++) 583 *out = *M1 / M2; 584 break; 585 case '%': 586 for (i = 0; i < Nx*Ny; i++, out++, M1++) 587 *out = (int) *M1 % (int) M2; 588 break; 589 case 0x5e: 590 for (i = 0; i < Nx*Ny; i++, out++, M1++) 591 *out = pow (*M1, M2); 592 break; 593 case '@': 594 for (i = 0; i < Nx*Ny; i++, out++, M1++) 595 *out = DEG_RAD*atan2 (*M1, M2); 596 break; 597 case 'D': 598 for (i = 0; i < Nx*Ny; i++, out++, M1++) 599 *out = MIN (*M1, M2); 600 break; 601 case 'U': 602 for (i = 0; i < Nx*Ny; i++, out++, M1++) 603 *out = MAX (*M1, M2); 604 break; 605 case '<': 606 for (i = 0; i < Nx*Ny; i++, out++, M1++) 607 *out = (*M1 < M2) ? 1 : 0; 608 break; 609 case '>': 610 for (i = 0; i < Nx*Ny; i++, out++, M1++) 611 *out = (*M1 > M2) ? 1 : 0; 612 break; 613 case '&': 614 for (i = 0; i < Nx*Ny; i++, out++, M1++) 615 *out = ((int)*M1 & (int)M2); 616 break; 617 case '|': 618 for (i = 0; i < Nx*Ny; i++, out++, M1++) 619 *out = ((int)*M1 | (int)M2); 620 break; 621 case 'E': 622 for (i = 0; i < Nx*Ny; i++, out++, M1++) 623 *out = (*M1 == M2) ? 1 : 0; 624 break; 625 case 'N': 626 for (i = 0; i < Nx*Ny; i++, out++, M1++) 627 *out = (*M1 != M2) ? 1 : 0; 628 break; 629 case 'L': 630 for (i = 0; i < Nx*Ny; i++, out++, M1++) 631 *out = (*M1 <= M2) ? 1 : 0; 632 break; 633 case 'G': 634 for (i = 0; i < Nx*Ny; i++, out++, M1++) 635 *out = (*M1 >= M2) ? 1 : 0; 636 break; 637 case 'A': 638 for (i = 0; i < Nx*Ny; i++, out++, M1++) 639 *out = (*M1 && M2) ? 1 : 0; 640 break; 641 case 'O': 642 for (i = 0; i < Nx*Ny; i++, out++, M1++) 643 *out = (*M1 || M2) ? 1 : 0; 644 break; 645 default: 646 sprintf (line, "error: op %c not defined!", op[0]); 647 push_error (line); 648 return (FALSE); 649 } 579 case '+': MS_FUNC(*M1 + M2); 580 case '-': MS_FUNC(*M1 - M2); 581 case '*': MS_FUNC(*M1 * M2); 582 case '/': MS_FUNC(*M1 / M2); 583 case '%': MS_FUNC((int) *M1 % (int) M2); 584 case '^': MS_FUNC(pow (*M1, M2)); 585 case '@': MS_FUNC(DEG_RAD*atan2 (*M1, M2)); 586 case 'D': MS_FUNC(MIN (*M1, M2)); 587 case 'U': MS_FUNC(MAX (*M1, M2)); 588 case '<': MS_FUNC((*M1 < M2) ? 1 : 0); 589 case '>': MS_FUNC((*M1 > M2) ? 1 : 0); 590 case '&': MS_FUNC(((int)*M1 & (int)M2)); 591 case '|': MS_FUNC(((int)*M1 | (int)M2)); 592 case 'E': MS_FUNC((*M1 == M2) ? 1 : 0); 593 case 'N': MS_FUNC((*M1 != M2) ? 1 : 0); 594 case 'L': MS_FUNC((*M1 <= M2) ? 1 : 0); 595 case 'G': MS_FUNC((*M1 >= M2) ? 1 : 0); 596 case 'A': MS_FUNC((*M1 && M2) ? 1 : 0); 597 case 'O': MS_FUNC((*M1 || M2) ? 1 : 0); 598 default: 599 sprintf (line, "error: op %c not defined!", op[0]); 600 push_error (line); 601 return (FALSE); 602 } 603 # undef MS_FUNC 650 604 651 605 if (V1[0].type == 'm') { … … 658 612 659 613 return (TRUE); 660 661 614 } 662 615 … … 665 618 666 619 int i, Nx, Ny; 667 float *out, *M2;668 opihi_flt M1;669 620 char line[512]; // this is only used to report an error 670 621 … … 681 632 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/ 682 633 683 M1 = V1[0].FltValue; 684 M2 = (float *)OUT[0].buffer[0].matrix.buffer; 685 out = (float *)OUT[0].buffer[0].matrix.buffer; 634 opihi_flt M1 = V1[0].FltValue; 635 float *M2 = (float *)V2[0].buffer[0].matrix.buffer; 636 float *out = (float *)OUT[0].buffer[0].matrix.buffer; 637 638 # define SM_FUNC(OP) \ 639 for (i = 0; i < Nx*Ny; i++, out++, M2++) \ 640 *out = OP; \ 641 break; 686 642 687 643 switch (op[0]) { 688 case '+': 689 for (i = 0; i < Nx*Ny; i++, out++, M2++) 690 *out = M1 + *M2; 691 break; 692 case '-': 693 for (i = 0; i < Nx*Ny; i++, out++, M2++) 694 *out = M1 - *M2; 695 break; 696 case '*': 697 for (i = 0; i < Nx*Ny; i++, out++, M2++) 698 *out = M1 * *M2; 699 break; 700 case '/': 701 for (i = 0; i < Nx*Ny; i++, out++, M2++) 702 *out = M1 / *M2; 703 break; 704 case '%': 705 for (i = 0; i < Nx*Ny; i++, out++, M2++) 706 *out = (int) M1 % (int) *M2; 707 break; 708 case 0x5e: 709 for (i = 0; i < Nx*Ny; i++, out++, M2++) 710 *out = pow (M1, *M2); 711 break; 712 case '@': 713 for (i = 0; i < Nx*Ny; i++, out++, M2++) 714 *out = DEG_RAD*atan2 (M1, *M2); 715 break; 716 case 'D': 717 for (i = 0; i < Nx*Ny; i++, out++, M2++) 718 *out = MIN (M1, *M2); 719 break; 720 case 'U': 721 for (i = 0; i < Nx*Ny; i++, out++, M2++) 722 *out = MAX (M1, *M2); 723 break; 724 case '<': 725 for (i = 0; i < Nx*Ny; i++, out++, M2++) 726 *out = (M1 < *M2) ? 1 : 0; 727 break; 728 case '>': 729 for (i = 0; i < Nx*Ny; i++, out++, M2++) 730 *out = (M1 > *M2) ? 1 : 0; 731 break; 732 case '&': 733 for (i = 0; i < Nx*Ny; i++, out++, M2++) 734 *out = ((int)M1 & (int)*M2); 735 break; 736 case '|': 737 for (i = 0; i < Nx*Ny; i++, out++, M2++) 738 *out = ((int)M1 | (int)*M2); 739 break; 740 case 'E': 741 for (i = 0; i < Nx*Ny; i++, out++, M2++) 742 *out = (M1 == *M2) ? 1 : 0; 743 break; 744 case 'N': 745 for (i = 0; i < Nx*Ny; i++, out++, M2++) 746 *out = (M1 != *M2) ? 1 : 0; 747 break; 748 case 'L': 749 for (i = 0; i < Nx*Ny; i++, out++, M2++) 750 *out = (M1 <= *M2) ? 1 : 0; 751 break; 752 case 'G': 753 for (i = 0; i < Nx*Ny; i++, out++, M2++) 754 *out = (M1 >= *M2) ? 1 : 0; 755 break; 756 case 'A': 757 for (i = 0; i < Nx*Ny; i++, out++, M2++) 758 *out = (M1 && *M2) ? 1 : 0; 759 break; 760 case 'O': 761 for (i = 0; i < Nx*Ny; i++, out++, M2++) 762 *out = (M1 || *M2) ? 1 : 0; 763 break; 764 default: 765 sprintf (line, "error: op %c not defined!", op[0]); 766 push_error (line); 767 return (FALSE); 768 } 644 case '+': SM_FUNC(M1 + *M2); 645 case '-': SM_FUNC(M1 - *M2); 646 case '*': SM_FUNC(M1 * *M2); 647 case '/': SM_FUNC(M1 / *M2); 648 case '%': SM_FUNC((int) M1 % (int) *M2); 649 case '^': SM_FUNC(pow (M1, *M2)); 650 case '@': SM_FUNC(DEG_RAD*atan2 (M1, *M2)); 651 case 'D': SM_FUNC(MIN (M1, *M2)); 652 case 'U': SM_FUNC(MAX (M1, *M2)); 653 case '<': SM_FUNC((M1 < *M2) ? 1 : 0); 654 case '>': SM_FUNC((M1 > *M2) ? 1 : 0); 655 case '&': SM_FUNC(((int)M1 & (int)*M2)); 656 case '|': SM_FUNC(((int)M1 | (int)*M2)); 657 case 'E': SM_FUNC((M1 == *M2) ? 1 : 0); 658 case 'N': SM_FUNC((M1 != *M2) ? 1 : 0); 659 case 'L': SM_FUNC((M1 <= *M2) ? 1 : 0); 660 case 'G': SM_FUNC((M1 >= *M2) ? 1 : 0); 661 case 'A': SM_FUNC((M1 && *M2) ? 1 : 0); 662 case 'O': SM_FUNC((M1 || *M2) ? 1 : 0); 663 default: 664 sprintf (line, "error: op %c not defined!", op[0]); 665 push_error (line); 666 return (FALSE); 667 } 668 # undef SM_FUNC 769 669 770 670 if (V2[0].type == 'm') { … … 780 680 } 781 681 782 783 682 int SS_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 784 683 785 opihi_flt M1, M2;786 684 char line[512]; // this is only used to report an error 787 685 788 M1 = V1[0].FltValue; 789 M2 = V2[0].FltValue; 790 OUT[0].type = 'S'; 686 # define SS_FUNC(OP) \ 687 if ((V1->type == 'S') && (V2->type == 'S')) { \ 688 opihi_flt M1 = V1[0].FltValue; \ 689 opihi_flt M2 = V2[0].FltValue; \ 690 OUT[0].type = 'S'; \ 691 OUT[0].FltValue = OP; \ 692 break; \ 693 } \ 694 if ((V1->type == 'S') && (V2->type == 's')) { \ 695 opihi_flt M1 = V1[0].FltValue; \ 696 opihi_int M2 = V2[0].IntValue; \ 697 OUT[0].type = 'S'; \ 698 OUT[0].FltValue = OP; \ 699 break; \ 700 } \ 701 if ((V1->type == 's') && (V2->type == 'S')) { \ 702 opihi_int M1 = V1[0].IntValue; \ 703 opihi_flt M2 = V2[0].FltValue; \ 704 OUT[0].type = 'S'; \ 705 OUT[0].FltValue = OP; \ 706 break; \ 707 } \ 708 if ((V1->type == 's') && (V2->type == 's')) { \ 709 opihi_int M1 = V1[0].IntValue; \ 710 opihi_int M2 = V2[0].IntValue; \ 711 OUT[0].type = 's'; \ 712 OUT[0].IntValue = OP; \ 713 break; \ 714 } 791 715 792 716 switch (op[0]) { 793 case '+': 794 OUT[0].FltValue = M1 + M2; 795 break; 796 case '-': 797 OUT[0].FltValue = M1 - M2; 798 break; 799 case '*': 800 OUT[0].FltValue = M1 * M2; 801 break; 802 case '/': 803 OUT[0].FltValue = M1 / M2; 804 break; 805 case '%': 806 OUT[0].FltValue = (int) M1 % (int) M2; 807 break; 808 case 0x5e: 809 OUT[0].FltValue = pow (M1, M2); 810 break; 811 case '@': 812 OUT[0].FltValue = DEG_RAD*atan2 (M1, M2); 813 break; 814 case 'D': 815 OUT[0].FltValue = MIN (M1, M2); 816 break; 817 case 'U': 818 OUT[0].FltValue = MAX (M1, M2); 819 break; 820 case '<': 821 OUT[0].FltValue = (M1 < M2) ? 1 : 0; 822 break; 823 case '>': 824 OUT[0].FltValue = (M1 > M2) ? 1 : 0; 825 break; 826 case '&': 827 OUT[0].FltValue = ((int)M1 & (int)M2); 828 break; 829 case '|': 830 OUT[0].FltValue = ((int)M1 | (int)M2); 831 break; 832 case 'E': 833 OUT[0].FltValue = (M1 == M2) ? 1 : 0; 834 break; 835 case 'N': 836 OUT[0].FltValue = (M1 != M2) ? 1 : 0; 837 break; 838 case 'L': 839 OUT[0].FltValue = (M1 <= M2) ? 1 : 0; 840 break; 841 case 'G': 842 OUT[0].FltValue = (M1 >= M2) ? 1 : 0; 843 break; 844 case 'A': 845 OUT[0].FltValue = (M1 && M2) ? 1 : 0; 846 break; 847 case 'O': 848 OUT[0].FltValue = (M1 || M2) ? 1 : 0; 849 break; 850 default: 851 sprintf (line, "error: op %c not defined!", op[0]); 852 push_error (line); 853 return (FALSE); 854 } 717 case '+': SS_FUNC(M1 + M2); 718 case '-': SS_FUNC(M1 - M2); 719 case '*': SS_FUNC(M1 * M2); 720 case '/': SS_FUNC(M1 / M2); 721 case '%': SS_FUNC((int) M1 % (int) M2); 722 case '^': SS_FUNC(pow (M1, M2)); 723 case '@': SS_FUNC(DEG_RAD*atan2 (M1, M2)); 724 case 'D': SS_FUNC(MIN (M1, M2)); 725 case 'U': SS_FUNC(MAX (M1, M2)); 726 case '<': SS_FUNC((M1 < M2) ? 1 : 0); 727 case '>': SS_FUNC((M1 > M2) ? 1 : 0); 728 case '&': SS_FUNC(((int)M1 & (int)M2)); 729 case '|': SS_FUNC(((int)M1 | (int)M2)); 730 case 'E': SS_FUNC((M1 == M2) ? 1 : 0); 731 case 'N': SS_FUNC((M1 != M2) ? 1 : 0); 732 case 'L': SS_FUNC((M1 <= M2) ? 1 : 0); 733 case 'G': SS_FUNC((M1 >= M2) ? 1 : 0); 734 case 'A': SS_FUNC((M1 && M2) ? 1 : 0); 735 case 'O': SS_FUNC((M1 || M2) ? 1 : 0); 736 default: 737 sprintf (line, "error: op %c not defined!", op[0]); 738 push_error (line); 739 return (FALSE); 740 } 741 # undef SS_FUNC 855 742 856 743 clear_stack (V1); … … 867 754 868 755 /* only 'N' and 'E' are allowed for WW_binary operations. anything else is either a 869 syntax error or is a string which looks like a math expression. */756 syntax error or is a string which looks like a math expression. */ 870 757 871 758 if ((op[0] != 'N') && (op[0] != 'E')) { … … 889 776 890 777 switch (op[0]) { 891 case 'E':892 value = strcmp (V1[0].name, V2[0].name) ? 0 : 1;778 case 'E': 779 value = strcmp (V1[0].name, V2[0].name) ? 0 : 1; 893 780 break; 894 case 'N':895 value = strcmp (V1[0].name, V2[0].name) ? 1 : 0;781 case 'N': 782 value = strcmp (V1[0].name, V2[0].name) ? 1 : 0; 896 783 break; 897 default:898 sprintf (line, "error: op %c not defined for string operations!", op[0]);899 push_error (line);900 return (FALSE);784 default: 785 sprintf (line, "error: op %c not defined for string operations!", op[0]); 786 push_error (line); 787 return (FALSE); 901 788 } 902 789 … … 914 801 int S_unary (StackVar *OUT, StackVar *V1, char *op) { 915 802 916 opihi_flt M1;803 char line[512]; // this is only used to report an error 917 804 918 M1 = V1[0].FltValue; 919 OUT[0].type = 'S'; 920 921 if (!strcmp (op, "=")) { } 922 if (!strcmp (op, "abs")) { OUT[0].FltValue = fabs(M1); } 923 if (!strcmp (op, "int")) { OUT[0].FltValue = (float)(int)(M1); } 924 if (!strcmp (op, "exp")) { OUT[0].FltValue = exp (M1); } 925 if (!strcmp (op, "ten")) { OUT[0].FltValue = pow (10.0,M1); } 926 if (!strcmp (op, "log")) { OUT[0].FltValue = log10 (M1); } 927 if (!strcmp (op, "ln")) { OUT[0].FltValue = log (M1); } 928 if (!strcmp (op, "sqrt")) { OUT[0].FltValue = sqrt (M1); } 929 if (!strcmp (op, "erf")) { OUT[0].FltValue = erf (M1); } 930 931 if (!strcmp (op, "sinh")) { OUT[0].FltValue = sinh (M1); } 932 if (!strcmp (op, "cosh")) { OUT[0].FltValue = cosh (M1); } 933 if (!strcmp (op, "asinh")) { OUT[0].FltValue = asinh (M1); } 934 if (!strcmp (op, "acosh")) { OUT[0].FltValue = acosh (M1); } 935 if (!strcmp (op, "lgamma")) { OUT[0].FltValue = lgamma (M1); } 936 937 if (!strcmp (op, "sin")) { OUT[0].FltValue = sin (M1); } 938 if (!strcmp (op, "cos")) { OUT[0].FltValue = cos (M1); } 939 if (!strcmp (op, "tan")) { OUT[0].FltValue = tan (M1); } 940 if (!strcmp (op, "dsin")) { OUT[0].FltValue = sin (M1*RAD_DEG); } 941 if (!strcmp (op, "dcos")) { OUT[0].FltValue = cos (M1*RAD_DEG); } 942 if (!strcmp (op, "dtan")) { OUT[0].FltValue = tan (M1*RAD_DEG); } 943 if (!strcmp (op, "asin")) { OUT[0].FltValue = asin (M1); } 944 if (!strcmp (op, "acos")) { OUT[0].FltValue = acos (M1); } 945 if (!strcmp (op, "atan")) { OUT[0].FltValue = atan (M1); } 946 if (!strcmp (op, "dasin")) { OUT[0].FltValue = asin (M1)*DEG_RAD; } 947 if (!strcmp (op, "dacos")) { OUT[0].FltValue = acos (M1)*DEG_RAD; } 948 if (!strcmp (op, "datan")) { OUT[0].FltValue = atan (M1)*DEG_RAD; } 949 if (!strcmp (op, "rnd")) { OUT[0].FltValue = drand48(); } 950 if (!strcmp (op, "not")) { OUT[0].FltValue = !(M1); } 951 if (!strcmp (op, "--")) { OUT[0].FltValue = - (M1); } 952 if (!strcmp (op, "isinf")) { OUT[0].FltValue = !finite(M1); } 953 if (!strcmp (op, "isnan")) { OUT[0].FltValue = isnan(M1); } 954 955 clear_stack (V1); 956 return (TRUE); 805 # define S_FUNC(OP,FTYPE) { \ 806 if (V1->type == 'S') { \ 807 opihi_flt M1 = V1[0].FltValue; \ 808 OUT[0].type = 'S'; \ 809 OUT[0].FltValue = OP; \ 810 clear_stack (V1); \ 811 return (TRUE); \ 812 } \ 813 if ((FTYPE == 'S') && (V1->type == 's')) { \ 814 opihi_int M1 = V1[0].IntValue; \ 815 OUT[0].type = 'S'; \ 816 OUT[0].FltValue = OP; \ 817 clear_stack (V1); \ 818 return (TRUE); \ 819 } \ 820 if ((FTYPE == 's') && (V1->type == 's')) { \ 821 opihi_int M1 = V1[0].FltValue; \ 822 OUT[0].type = 's'; \ 823 OUT[0].IntValue = OP; \ 824 clear_stack (V1); \ 825 return (TRUE); \ 826 } \ 827 } 828 829 if (!strcmp (op, "=")) S_FUNC(M1, 's'); 830 if (!strcmp (op, "abs")) S_FUNC(fabs(M1), 's'); 831 if (!strcmp (op, "int")) S_FUNC((int)(M1), 's'); 832 if (!strcmp (op, "exp")) S_FUNC(exp (M1), 'S'); 833 if (!strcmp (op, "ten")) S_FUNC(pow (10.0,M1), 'S'); 834 if (!strcmp (op, "log")) S_FUNC(log10 (M1), 'S'); 835 if (!strcmp (op, "ln")) S_FUNC(log (M1), 'S'); 836 if (!strcmp (op, "sqrt")) S_FUNC(sqrt (M1), 'S'); 837 if (!strcmp (op, "erf")) S_FUNC(erf (M1), 'S'); 838 if (!strcmp (op, "sinh")) S_FUNC(sinh (M1), 'S'); 839 if (!strcmp (op, "cosh")) S_FUNC(cosh (M1), 'S'); 840 if (!strcmp (op, "asinh")) S_FUNC(asinh (M1), 'S'); 841 if (!strcmp (op, "acosh")) S_FUNC(acosh (M1), 'S'); 842 if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), 'S'); 843 if (!strcmp (op, "sin")) S_FUNC(sin (M1), 'S'); 844 if (!strcmp (op, "cos")) S_FUNC(cos (M1), 'S'); 845 if (!strcmp (op, "tan")) S_FUNC(tan (M1), 'S'); 846 if (!strcmp (op, "dsin")) S_FUNC(sin (M1*RAD_DEG), 'S'); 847 if (!strcmp (op, "dcos")) S_FUNC(cos (M1*RAD_DEG), 'S'); 848 if (!strcmp (op, "dtan")) S_FUNC(tan (M1*RAD_DEG), 'S'); 849 if (!strcmp (op, "asin")) S_FUNC(asin (M1), 'S'); 850 if (!strcmp (op, "acos")) S_FUNC(acos (M1), 'S'); 851 if (!strcmp (op, "atan")) S_FUNC(atan (M1), 'S'); 852 if (!strcmp (op, "dasin")) S_FUNC(asin (M1)*DEG_RAD, 'S'); 853 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, 'S'); 854 if (!strcmp (op, "datan")) S_FUNC(atan (M1)*DEG_RAD, 'S'); 855 if (!strcmp (op, "rnd")) S_FUNC(M1*0.0 + drand48(), 'S'); 856 if (!strcmp (op, "not")) S_FUNC(!(M1), 's'); 857 if (!strcmp (op, "--")) S_FUNC(-(M1), 's'); 858 if (!strcmp (op, "isinf")) S_FUNC(!finite(M1), 'S'); // XXX modify in future 859 if (!strcmp (op, "isnan")) S_FUNC(isnan(M1), 'S'); // XXX modify in future 860 861 # undef S_FUNC 862 863 clear_stack (V1); 864 sprintf (line, "error: op %s not defined!", op); 865 push_error (line); 866 return (FALSE); 957 867 958 868 } … … 963 873 964 874 Nx = V1[0].vector[0].Nelements; 965 966 if (V1[0].type == 'v') { /** use V1 as temp buffer **/ 967 OUT[0].vector = V1[0].vector; 968 V1[0].type = 'V'; /* prevent it from being freed below */ 969 } else { /* no spare temp buffer */ 970 OUT[0].vector = InitVector (); 971 CopyVector (OUT[0].vector, V1[0].vector); 972 } 875 876 OUT[0].vector = InitVector (); 973 877 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/ 974 opihi_flt *M1 = V1[0].vector[0].elements.Flt; 975 opihi_flt *out = OUT[0].vector[0].elements.Flt; 976 977 if (!strcmp (op, "=")) { } /* already set equal */ 978 if (!strcmp (op, "abs")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = fabs(*M1); }} 979 if (!strcmp (op, "int")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = (float)(int)(*M1); }} 980 if (!strcmp (op, "exp")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = exp(*M1); }} 981 if (!strcmp (op, "ten")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = pow(10.0,*M1); }} 982 if (!strcmp (op, "log")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = log10(*M1); }} 983 if (!strcmp (op, "ln")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = log(*M1); }} 984 if (!strcmp (op, "sqrt")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = sqrt(*M1); }} 985 if (!strcmp (op, "erf")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = erf(*M1); }} 986 987 if (!strcmp (op, "sinh")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = sinh(*M1); }} 988 if (!strcmp (op, "cosh")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = cosh(*M1); }} 989 if (!strcmp (op, "asinh")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = asinh(*M1); }} 990 if (!strcmp (op, "acosh")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = acosh(*M1); }} 991 if (!strcmp (op, "lgamma")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = lgamma(*M1); }} 992 993 if (!strcmp (op, "sin")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = sin(*M1); }} 994 if (!strcmp (op, "cos")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = cos(*M1); }} 995 if (!strcmp (op, "tan")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = tan(*M1); }} 996 if (!strcmp (op, "dsin")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = sin(*M1*RAD_DEG); }} 997 if (!strcmp (op, "dcos")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = cos(*M1*RAD_DEG); }} 998 if (!strcmp (op, "dtan")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = tan(*M1*RAD_DEG); }} 999 if (!strcmp (op, "asin")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = asin(*M1); }} 1000 if (!strcmp (op, "acos")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = acos(*M1); }} 1001 if (!strcmp (op, "atan")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = atan(*M1); }} 1002 if (!strcmp (op, "dasin")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = asin(*M1)*DEG_RAD; }} 1003 if (!strcmp (op, "dacos")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = acos(*M1)*DEG_RAD; }} 1004 if (!strcmp (op, "datan")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = atan(*M1)*DEG_RAD; }} 1005 if (!strcmp (op, "rnd")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = drand48(); }} 1006 if (!strcmp (op, "ramp")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = i; }} 1007 if (!strcmp (op, "zero")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = 0; }} 1008 if (!strcmp (op, "not")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = !(*M1); }} 1009 if (!strcmp (op, "--")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = -(*M1); }} 1010 if (!strcmp (op, "isinf")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = !finite(*M1); }} 1011 if (!strcmp (op, "isnan")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = isnan(*M1); }} 1012 1013 /* xramp and yramp only make sense in for matrices. for vectors, xramp = ramp, yramp = zero */ 1014 if (!strcmp (op, "xramp")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = i; }} 1015 if (!strcmp (op, "yramp")) { for (i = 0; i < Nx; i++, out++, M1++) { *out = 0; }} 878 879 # define V_FUNC(OP,FTYPE) { \ 880 if (V1->vector->type == OPIHI_FLT) { \ 881 CopyVector (OUT[0].vector, V1[0].vector); \ 882 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 883 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 884 for (i = 0; i < Nx; i++, out++, M1++) { \ 885 *out = OP; \ 886 } \ 887 clear_stack (V1); \ 888 return (TRUE); \ 889 } \ 890 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 'S')) { \ 891 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 892 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 893 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 894 for (i = 0; i < Nx; i++, out++, M1++) { \ 895 *out = OP; \ 896 } \ 897 clear_stack (V1); \ 898 return (TRUE); \ 899 } \ 900 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 's')) { \ 901 CopyVector (OUT[0].vector, V1[0].vector); \ 902 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 903 opihi_int *out = OUT[0].vector[0].elements.Int; \ 904 for (i = 0; i < Nx; i++, out++, M1++) { \ 905 *out = OP; \ 906 } \ 907 clear_stack (V1); \ 908 return (TRUE); \ 909 } } 910 911 if (!strcmp (op, "=")) V_FUNC(*M1, 's'); 912 if (!strcmp (op, "abs")) V_FUNC(fabs(*M1), 's'); 913 if (!strcmp (op, "int")) V_FUNC((int)(*M1), 's'); 914 if (!strcmp (op, "exp")) V_FUNC(exp(*M1), 'S'); 915 if (!strcmp (op, "ten")) V_FUNC(pow(10.0,*M1), 'S'); 916 if (!strcmp (op, "log")) V_FUNC(log10(*M1), 'S'); 917 if (!strcmp (op, "ln")) V_FUNC(log(*M1), 'S'); 918 if (!strcmp (op, "sqrt")) V_FUNC(sqrt(*M1), 'S'); 919 if (!strcmp (op, "erf")) V_FUNC(erf(*M1), 'S'); 920 if (!strcmp (op, "sinh")) V_FUNC(sinh(*M1), 'S'); 921 if (!strcmp (op, "cosh")) V_FUNC(cosh(*M1), 'S'); 922 if (!strcmp (op, "asinh")) V_FUNC(asinh(*M1), 'S'); 923 if (!strcmp (op, "acosh")) V_FUNC(acosh(*M1), 'S'); 924 if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), 'S'); 925 if (!strcmp (op, "sin")) V_FUNC(sin(*M1), 'S'); 926 if (!strcmp (op, "cos")) V_FUNC(cos(*M1), 'S'); 927 if (!strcmp (op, "tan")) V_FUNC(tan(*M1), 'S'); 928 if (!strcmp (op, "dsin")) V_FUNC(sin(*M1*RAD_DEG), 'S'); 929 if (!strcmp (op, "dcos")) V_FUNC(cos(*M1*RAD_DEG), 'S'); 930 if (!strcmp (op, "dtan")) V_FUNC(tan(*M1*RAD_DEG), 'S'); 931 if (!strcmp (op, "asin")) V_FUNC(asin(*M1), 'S'); 932 if (!strcmp (op, "acos")) V_FUNC(acos(*M1), 'S'); 933 if (!strcmp (op, "atan")) V_FUNC(atan(*M1), 'S'); 934 if (!strcmp (op, "dasin")) V_FUNC(asin(*M1)*DEG_RAD, 'S'); 935 if (!strcmp (op, "dacos")) V_FUNC(acos(*M1)*DEG_RAD, 'S'); 936 if (!strcmp (op, "datan")) V_FUNC(atan(*M1)*DEG_RAD, 'S'); 937 if (!strcmp (op, "rnd")) V_FUNC(drand48(), 'S'); 938 if (!strcmp (op, "ramp")) V_FUNC(i, 's'); 939 if (!strcmp (op, "zero")) V_FUNC(0, 's'); 940 if (!strcmp (op, "not")) V_FUNC(!(*M1), 's'); 941 if (!strcmp (op, "--")) V_FUNC(-(*M1), 's'); 942 if (!strcmp (op, "isinf")) V_FUNC(!finite(*M1), 'S'); 943 if (!strcmp (op, "isnan")) V_FUNC(isnan(*M1), 'S'); 944 if (!strcmp (op, "xramp")) V_FUNC(i, 's'); 945 if (!strcmp (op, "yramp")) V_FUNC(0, 's'); 946 /* xramp and yramp above only make sense for matrices. for vectors, xramp = ramp, yramp = zero */ 947 948 # undef V_FUNC 1016 949 1017 950 if (V1[0].type == 'v') { … … 1085 1018 for (j = 0; j < Ny; j++) { 1086 1019 for (i = 0; i < Nx; i++, out++, M1++) { 1087 *out = i;1020 *out = i; 1088 1021 } 1089 1022 } … … 1092 1025 for (j = 0; j < Ny; j++) { 1093 1026 for (i = 0; i < Nx; i++, out++, M1++) { 1094 *out = j;1027 *out = j; 1095 1028 } 1096 1029 } -
branches/eam_branch_20081124/Ohana/src/opihi/mana/findpeaks.c
r20839 r20856 76 76 } 77 77 78 REALLOCATE (vecx[0].elements.Flt, opihi_flt, MAX (Npeak, 1)); 79 REALLOCATE (vecy[0].elements.Flt, opihi_flt, MAX (Npeak, 1)); 80 REALLOCATE (vecz[0].elements.Flt, opihi_flt, MAX (Npeak, 1)); 78 ResetVector (vecx, OPIHI_FLT, MAX (Npeak, 1)); 79 ResetVector (vecy, OPIHI_FLT, MAX (Npeak, 1)); 80 ResetVector (vecz, OPIHI_FLT, MAX (Npeak, 1)); 81 81 82 /* eliminate non-local peaks */ 82 83 for (N = n = 0; n < Npeak; n++) { -
branches/eam_branch_20081124/Ohana/src/opihi/mana/fitcontour.c
r20839 r20856 17 17 xo = atof (argv[3]); 18 18 yo = atof (argv[4]); 19 20 // require these to be float vectors 21 if (vecx->type != OPIHI_FLT) return (FALSE); 22 if (vecy->type != OPIHI_FLT) return (FALSE); 19 23 20 24 ALLOCATE (B, double *, NTERM); -
branches/eam_branch_20081124/Ohana/src/opihi/mana/rawstars.c
r20839 r20856 55 55 Np = xp[0].Nelements; 56 56 57 REALLOCATE (xc[0].elements.Flt, opihi_flt, Np); 58 REALLOCATE (yc[0].elements.Flt, opihi_flt, Np); 59 REALLOCATE (sx[0].elements.Flt, opihi_flt, Np); 60 REALLOCATE (sy[0].elements.Flt, opihi_flt, Np); 61 REALLOCATE (sxy[0].elements.Flt, opihi_flt, Np); 62 REALLOCATE (zs[0].elements.Flt, opihi_flt, Np); 63 REALLOCATE (zc[0].elements.Flt, opihi_flt, Np); 64 REALLOCATE (sk[0].elements.Flt, opihi_flt, Np); 65 xc[0].Nelements = yc[0].Nelements = sx[0].Nelements = Np; 66 sy[0].Nelements = zs[0].Nelements = zc[0].Nelements = Np; 67 sxy[0].Nelements = sk[0].Nelements = Np; 57 ResetVector (xc, OPIHI_FLT, Np); 58 ResetVector (yc, OPIHI_FLT, Np); 59 ResetVector (sx, OPIHI_FLT, Np); 60 ResetVector (sy, OPIHI_FLT, Np); 61 ResetVector (sxy, OPIHI_FLT, Np); 62 ResetVector (zs, OPIHI_FLT, Np); 63 ResetVector (zc, OPIHI_FLT, Np); 64 ResetVector (sk, OPIHI_FLT, Np); 68 65 69 66 v = (float *) buff[0].matrix.buffer; -
branches/eam_branch_20081124/Ohana/src/opihi/mana/starcontour.c
r20839 r20856 22 22 N = 0; 23 23 Npts = 100; 24 R EALLOCATE (vecx[0].elements.Flt, opihi_flt, MAX (Npts, 1));25 R EALLOCATE (vecy[0].elements.Flt, opihi_flt, MAX (Npts, 1));24 ResetVector (vecx, OPIHI_FLT, MAX (Npts, 1)); 25 ResetVector (vecy, OPIHI_FLT, MAX (Npts, 1)); 26 26 27 27 Nx = buf[0].matrix.Naxis[0];
Note:
See TracChangeset
for help on using the changeset viewer.
