Changeset 38406
- Timestamp:
- Jun 6, 2015, 10:03:56 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/opihi
- Files:
-
- 5 edited
-
cmd.data/cast.c (modified) (4 diffs)
-
cmd.data/read_vectors.c (modified) (2 diffs)
-
cmd.data/vstats.c (modified) (1 diff)
-
lib.shell/VectorIO.c (modified) (2 diffs)
-
lib.shell/evaluate_stack.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/cast.c
r36489 r38406 17 17 // out type 18 18 char outType = OPIHI_NOTYPE; 19 if (!strcasecmp(argv[5], "int")) outType = OPIHI_INT; 20 if (!strcasecmp(argv[5], "float")) outType = OPIHI_FLT; 19 if (!strcasecmp(argv[5], "int")) outType = OPIHI_INT; 20 if (!strcasecmp(argv[5], "float")) outType = OPIHI_FLT; 21 if (!strcasecmp(argv[5], "single")) outType = OPIHI_FLT; 22 if (!strcasecmp(argv[5], "int64")) outType = OPIHI_FLT; 21 23 if (outType == OPIHI_NOTYPE) goto usage; 24 25 int ForceSingle = FALSE; 26 if (!strcasecmp(argv[5], "single")) ForceSingle = TRUE; 27 28 int ForceI64 = FALSE; 29 if (!strcasecmp(argv[5], "int64")) ForceI64 = TRUE; 22 30 23 31 if ((ovec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto error; … … 32 40 opihi_flt *vo = ovec[0].elements.Flt; 33 41 for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) { 34 *vo = *vi; 42 if (ForceSingle) { 43 float tmp = *vi; 44 *vo = tmp; 45 } else if (ForceI64) { 46 int64_t tmp = *vi; 47 *vo = tmp; 48 } else { 49 *vo = *vi; 50 } 35 51 } 36 52 return (TRUE); … … 48 64 opihi_flt *vo = ovec[0].elements.Flt; 49 65 for (i = 0; i < ovec[0].Nelements; i++, vi++, vo++) { 50 *vo = *vi; 66 if (ForceSingle) { 67 float tmp = *vi; 68 *vo = tmp; 69 } else { 70 *vo = *vi; 71 } 51 72 } 52 73 return (TRUE); … … 66 87 67 88 usage: 68 gprint (GP_ERR, "SYNTAX: cast vec = vec as (int/float)\n"); 89 gprint (GP_ERR, "SYNTAX: cast vec = vec as (int/float/single)\n"); 90 gprint (GP_ERR, " note: (single) forces vector to have single precision\n"); 69 91 return (FALSE); 70 92 } -
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c
r38367 r38406 487 487 } 488 488 if (start < 0) ESCAPE ("invalid range: start < 0\n"); 489 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny ( %d)\n", header.Naxis[1]);489 if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny ("OFF_T_FMT")\n", header.Naxis[1]); 490 490 if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n"); 491 491 492 492 // just a warning: 493 493 if (start + Nrows > header.Naxis[1]) { 494 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %drows\n", header.Naxis[1] - start);494 if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only "OFF_T_FMT" rows\n", header.Naxis[1] - start); 495 495 } 496 496 … … 555 555 556 556 vecType = OPIHI_INT; 557 if (!strcmp (type, "double") || !strcmp (type, "float") ) {557 if (!strcmp (type, "double") || !strcmp (type, "float") || !strcmp (type, "int64_t")) { 558 558 vecType = OPIHI_FLT; 559 559 } -
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/vstats.c
r35109 r38406 121 121 goto skip; 122 122 } 123 // we can hit inf if pmax and pmin are close to the max range 124 if (isinf(dx)) dx = DBL_MAX / Nbin; 123 125 124 126 ALLOCATE (Nval, int, Nbin + 2); -
branches/eam_branches/ohana.20150429/src/opihi/lib.shell/VectorIO.c
r38367 r38406 320 320 ASSIGN_DATA(short, short, Int); 321 321 ASSIGN_DATA(int, int, Int); 322 ASSIGN_DATA(int64_t, int64_t, Int);322 ASSIGN_DATA(int64_t, int64_t, Flt); // int64_t has a problem: Int is too small, Flt is wrong precision 323 323 ASSIGN_DATA(float, float, Flt); 324 324 ASSIGN_DATA(double, double, Flt); … … 345 345 ASSIGN_DATA_TRANSPOSE(short, short, Int); 346 346 ASSIGN_DATA_TRANSPOSE(int, int, Int); 347 ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Int);347 ASSIGN_DATA_TRANSPOSE(int64_t, int64_t, Flt); 348 348 ASSIGN_DATA_TRANSPOSE(float, float, Flt); 349 349 ASSIGN_DATA_TRANSPOSE(double, double, Flt); -
branches/eam_branches/ohana.20150429/src/opihi/lib.shell/evaluate_stack.c
r38062 r38406 115 115 116 116 /* there are no valid unary string operators */ 117 push_error ("invalid operands for trinary operator (mismatch types?)"); 117 snprintf (line, 512, "invalid operands for trinary operator %s (mismatch types?)", stack[i].name); 118 push_error (line); 118 119 clear_stack (&tmp_stack); 119 120 return (FALSE); … … 210 211 211 212 /* there are no valid unary string operators */ 212 push_error ("syntax error: no valid string unary ops"); 213 snprintf (line, 512, "invalid operand for unary operator %s (undefined value?)", stack[i].name); 214 push_error (line); 213 215 clear_stack (&tmp_stack); 214 216 return (FALSE);
Note:
See TracChangeset
for help on using the changeset viewer.
