Changeset 41176 for trunk/Ohana
- Timestamp:
- Nov 27, 2019, 12:09:13 PM (7 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 10 edited
- 2 copied
-
. (modified) (1 prop)
-
src/libfits/include/gfitsio.h (modified) (1 diff)
-
src/libfits/table/F_define_column.c (modified) (1 diff)
-
src/libfits/table/F_set_column.c (modified) (6 diffs)
-
src/libohana/src/isolate_elements.c (modified) (3 diffs)
-
src/opihi/cmd.basic/test/stackmath.sh (copied) (copied from branches/eam_branches/ipp-20191011/Ohana/src/opihi/cmd.basic/test/stackmath.sh )
-
src/opihi/cmd.basic/test/tap.sh (copied) (copied from branches/eam_branches/ipp-20191011/Ohana/src/opihi/cmd.basic/test/tap.sh )
-
src/opihi/lib.data/SplineOps.c (modified) (1 diff)
-
src/opihi/lib.shell/VectorIO.c (modified) (5 diffs)
-
src/opihi/lib.shell/convert_to_RPN.c (modified) (2 diffs)
-
src/opihi/lib.shell/parse.c (modified) (2 diffs)
-
src/opihi/lib.shell/stack_math.c (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20191011/Ohana (added) merged: 41136-41137,41141-41144,41170
- Property svn:mergeinfo changed
-
trunk/Ohana/src/libfits/include/gfitsio.h
r39460 r41176 259 259 int gfits_read_table PROTO((char *filename, FTable *ftable)); 260 260 int gfits_set_bintable_column PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow)); 261 int gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder));261 int gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, int element, char nativeOrder)); 262 262 int gfits_set_table_column PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow)); 263 263 int gfits_table_column PROTO((FTable *ftable, char *field, char *mode,...)) OHANA_FORMAT(printf, 3, 4); -
trunk/Ohana/src/libfits/table/F_define_column.c
r38553 r41176 56 56 char type[64], field[64]; 57 57 58 // this call supported multiple columns per named field 58 59 if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE); 59 60 -
trunk/Ohana/src/libfits/table/F_set_column.c
r39993 r41176 253 253 /***********************/ 254 254 // convert the input data array (of the specified intype) to the desired table data type. swap unless nativeOrder is requested 255 int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder) {255 int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, int element, char nativeOrder) { 256 256 257 257 off_t Nx, Ny; … … 288 288 289 289 if (!gfits_bintable_format (format, outtype, &Nval, &NbytesOut)) return (FALSE); 290 if (element >= Nval) { 291 fprintf (stderr, "programming error: element >= Nval for field %s, format %s\n", label, format); 292 return FALSE; 293 } 290 294 291 295 /* check existing table dimensions */ … … 307 311 } 308 312 313 // NOTE: we are inserting a single column into the output 314 // table. If the output field is multi-value, the resulting 315 // array is inserted into the appropriate bytes in that output field 316 309 317 /* make duplicate of data with correct type 310 318 byte swap and Bzero/Bscale */ 311 ALLOCATE (array, char, NbytesOut*N val*Nrow);319 ALLOCATE (array, char, NbytesOut*Nrow); 312 320 Pin = data; 313 Pout = array; 321 Pout = array; // 314 322 315 323 // # define ASSIGN_DATA(ITYPE,INAME,ISIZE,OTYPE,ONAME) … … 321 329 if (!strcmp (outtype, OUTNAME) && !strcmp (intype, INNAME)) { \ 322 330 int NbytesIn = NBYTES_IN; \ 323 for (i = 0; i < N val*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { \331 for (i = 0; i < Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { \ 324 332 if (directCopy) { \ 325 333 *(OUTTYPE *)Pout = *(INTYPE *)Pin; \ … … 385 393 SET_VALUES("double", double, "double", double, SWAP_DBLE, 8); 386 394 387 # if (0)388 /** input == char **/389 if (!strcmp (outtype, "char") && !strcmp (intype, "char")) {390 int NbytesIn = 1;391 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {392 if (directCopy) { *(char *)Pout = *(char *)Pin; } else {393 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;394 }395 }396 }397 if (!strcmp (outtype, "byte") && !strcmp (intype, "char")) {398 int NbytesIn = 1;399 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {400 if (directCopy) { *(char *)Pout = *(char *)Pin; } else {401 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;402 }403 }404 }405 if (!strcmp (outtype, "short") && !strcmp (intype, "char")) {406 int NbytesIn = 1;407 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {408 if (directCopy) { *(short *)Pout = *(char *)Pin; } else {409 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale;410 }411 # ifdef BYTE_SWAP412 if (!nativeOrder) { SWAP_BYTE; }413 # endif414 }415 }416 if (!strcmp (outtype, "int") && !strcmp (intype, "char")) {417 int NbytesIn = 1;418 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {419 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale;420 # ifdef BYTE_SWAP421 if (!nativeOrder) { SWAP_WORD; }422 # endif423 }424 }425 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "char")) {426 int NbytesIn = 1;427 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {428 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale;429 # ifdef BYTE_SWAP430 if (!nativeOrder) { SWAP_DBLE; }431 # endif432 }433 }434 if (!strcmp (outtype, "float") && !strcmp (intype, "char")) {435 int NbytesIn = 1;436 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {437 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale;438 # ifdef BYTE_SWAP439 if (!nativeOrder) { SWAP_WORD; }440 # endif441 }442 }443 if (!strcmp (outtype, "double") && !strcmp (intype, "char")) {444 int NbytesIn = 1;445 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {446 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale;447 # ifdef BYTE_SWAP448 if (!nativeOrder) { SWAP_DBLE; }449 # endif450 }451 }452 453 /** input == byte **/454 if (!strcmp (outtype, "char") && !strcmp (intype, "byte")) {455 int NbytesIn = 1;456 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {457 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;458 }459 }460 if (!strcmp (outtype, "byte") && !strcmp (intype, "byte")) {461 int NbytesIn = 1;462 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {463 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;464 }465 }466 if (!strcmp (outtype, "short") && !strcmp (intype, "byte")) {467 int NbytesIn = 1;468 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {469 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale;470 # ifdef BYTE_SWAP471 if (!nativeOrder) { SWAP_BYTE; }472 # endif473 }474 }475 if (!strcmp (outtype, "int") && !strcmp (intype, "byte")) {476 int NbytesIn = 1;477 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {478 *(int *)Pout = (*(char *)Pin - Bzero) / Bscale;479 # ifdef BYTE_SWAP480 if (!nativeOrder) { SWAP_WORD; }481 # endif482 }483 }484 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "byte")) {485 int NbytesIn = 1;486 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {487 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale;488 # ifdef BYTE_SWAP489 if (!nativeOrder) { SWAP_DBLE; }490 # endif491 }492 }493 if (!strcmp (outtype, "float") && !strcmp (intype, "byte")) {494 int NbytesIn = 1;495 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {496 *(float *)Pout = (*(char *)Pin - Bzero) / Bscale;497 # ifdef BYTE_SWAP498 if (!nativeOrder) { SWAP_WORD; }499 # endif500 }501 }502 if (!strcmp (outtype, "double") && !strcmp (intype, "byte")) {503 int NbytesIn = 1;504 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {505 *(double *)Pout = (*(char *)Pin - Bzero) / Bscale;506 # ifdef BYTE_SWAP507 if (!nativeOrder) { SWAP_DBLE; }508 # endif509 }510 }511 512 /** input == short **/513 if (!strcmp (outtype, "char") && !strcmp (intype, "short")) {514 int NbytesIn = 2;515 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {516 *(char *)Pout = (*(short *)Pin - Bzero) / Bscale;517 }518 }519 if (!strcmp (outtype, "byte") && !strcmp (intype, "short")) {520 int NbytesIn = 2;521 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {522 *(char *)Pout = (*(short *)Pin - Bzero) / Bscale;523 }524 }525 if (!strcmp (outtype, "short") && !strcmp (intype, "short")) {526 int NbytesIn = 2;527 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {528 *(short *)Pout = (*(short *)Pin - Bzero) / Bscale;529 # ifdef BYTE_SWAP530 if (!nativeOrder) { SWAP_BYTE; }531 # endif532 }533 }534 if (!strcmp (outtype, "int") && !strcmp (intype, "short")) {535 int NbytesIn = 2;536 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {537 *(int *)Pout = (*(short *)Pin - Bzero) / Bscale;538 # ifdef BYTE_SWAP539 if (!nativeOrder) { SWAP_WORD; }540 # endif541 }542 }543 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "short")) {544 int NbytesIn = 2;545 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {546 *(int64_t *)Pout = (*(short *)Pin - Bzero) / Bscale;547 # ifdef BYTE_SWAP548 if (!nativeOrder) { SWAP_DBLE; }549 # endif550 }551 }552 if (!strcmp (outtype, "float") && !strcmp (intype, "short")) {553 int NbytesIn = 2;554 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {555 *(float *)Pout = (*(short *)Pin - Bzero) / Bscale;556 # ifdef BYTE_SWAP557 if (!nativeOrder) { SWAP_WORD; }558 # endif559 }560 }561 if (!strcmp (outtype, "double") && !strcmp (intype, "short")) {562 int NbytesIn = 2;563 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {564 *(double *)Pout = (*(short *)Pin - Bzero) / Bscale;565 # ifdef BYTE_SWAP566 if (!nativeOrder) { SWAP_DBLE; }567 # endif568 }569 }570 571 /** input == int **/572 if (!strcmp (outtype, "char") && !strcmp (intype, "int")) {573 int NbytesIn = 4;574 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {575 *(char *)Pout = (*(int *)Pin - Bzero) / Bscale;576 }577 }578 if (!strcmp (outtype, "byte") && !strcmp (intype, "int")) {579 int NbytesIn = 4;580 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {581 *(char *)Pout = (*(int *)Pin - Bzero) / Bscale;582 }583 }584 if (!strcmp (outtype, "short") && !strcmp (intype, "int")) {585 int NbytesIn = 4;586 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {587 *(short *)Pout = (*(int *)Pin - Bzero) / Bscale;588 # ifdef BYTE_SWAP589 if (!nativeOrder) { SWAP_BYTE; }590 # endif591 }592 }593 if (!strcmp (outtype, "int") && !strcmp (intype, "int")) {594 int NbytesIn = 4;595 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {596 *(int *)Pout = (*(int *)Pin - Bzero) / Bscale;597 # ifdef BYTE_SWAP598 if (!nativeOrder) { SWAP_WORD; }599 # endif600 }601 }602 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "int")) {603 int NbytesIn = 4;604 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {605 *(int64_t *)Pout = (*(int *)Pin - Bzero) / Bscale;606 # ifdef BYTE_SWAP607 if (!nativeOrder) { SWAP_DBLE; }608 # endif609 }610 }611 if (!strcmp (outtype, "float") && !strcmp (intype, "int")) {612 int NbytesIn = 4;613 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {614 *(float *)Pout = (*(int *)Pin - Bzero) / Bscale;615 # ifdef BYTE_SWAP616 if (!nativeOrder) { SWAP_WORD; }617 # endif618 }619 }620 if (!strcmp (outtype, "double") && !strcmp (intype, "int")) {621 int NbytesIn = 4;622 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {623 *(double *)Pout = (*(int *)Pin - Bzero) / Bscale;624 # ifdef BYTE_SWAP625 if (!nativeOrder) { SWAP_DBLE; }626 # endif627 }628 }629 630 /** input == int64_t **/631 if (!strcmp (outtype, "char") && !strcmp (intype, "int64_t")) {632 int NbytesIn = 8;633 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {634 *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;635 }636 }637 if (!strcmp (outtype, "byte") && !strcmp (intype, "int64_t")) {638 int NbytesIn = 8;639 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {640 *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;641 }642 }643 if (!strcmp (outtype, "short") && !strcmp (intype, "int64_t")) {644 int NbytesIn = 8;645 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {646 *(short *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;647 # ifdef BYTE_SWAP648 if (!nativeOrder) { SWAP_BYTE; }649 # endif650 }651 }652 if (!strcmp (outtype, "int") && !strcmp (intype, "int64_t")) {653 int NbytesIn = 8;654 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {655 *(int *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;656 # ifdef BYTE_SWAP657 if (!nativeOrder) { SWAP_WORD; }658 # endif659 }660 }661 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "int64_t")) {662 int NbytesIn = 8;663 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {664 *(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;665 # ifdef BYTE_SWAP666 if (!nativeOrder) { SWAP_DBLE; }667 # endif668 }669 }670 if (!strcmp (outtype, "float") && !strcmp (intype, "int64_t")) {671 int NbytesIn = 8;672 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {673 *(float *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;674 # ifdef BYTE_SWAP675 if (!nativeOrder) { SWAP_WORD; }676 # endif677 }678 }679 if (!strcmp (outtype, "double") && !strcmp (intype, "int64_t")) {680 int NbytesIn = 8;681 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {682 *(double *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;683 # ifdef BYTE_SWAP684 if (!nativeOrder) { SWAP_DBLE; }685 # endif686 }687 }688 689 /** input == float **/690 if (!strcmp (outtype, "char") && !strcmp (intype, "float")) {691 int NbytesIn = 4;692 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {693 *(char *)Pout = (*(float *)Pin - Bzero) / Bscale;694 }695 }696 if (!strcmp (outtype, "byte") && !strcmp (intype, "float")) {697 int NbytesIn = 4;698 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {699 *(char *)Pout = (*(float *)Pin - Bzero) / Bscale;700 }701 }702 if (!strcmp (outtype, "short") && !strcmp (intype, "float")) {703 int NbytesIn = 4;704 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {705 *(short *)Pout = (*(float *)Pin - Bzero) / Bscale;706 # ifdef BYTE_SWAP707 if (!nativeOrder) { SWAP_BYTE; }708 # endif709 }710 }711 if (!strcmp (outtype, "int") && !strcmp (intype, "float")) {712 int NbytesIn = 4;713 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {714 *(int *)Pout = (*(float *)Pin - Bzero) / Bscale;715 # ifdef BYTE_SWAP716 if (!nativeOrder) { SWAP_WORD; }717 # endif718 }719 }720 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "float")) {721 int NbytesIn = 4;722 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {723 *(int64_t *)Pout = (*(float *)Pin - Bzero) / Bscale;724 # ifdef BYTE_SWAP725 if (!nativeOrder) { SWAP_DBLE; }726 # endif727 }728 }729 if (!strcmp (outtype, "float") && !strcmp (intype, "float")) {730 int NbytesIn = 4;731 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {732 *(float *)Pout = (*(float *)Pin - Bzero) / Bscale;733 # ifdef BYTE_SWAP734 if (!nativeOrder) { SWAP_WORD; }735 # endif736 }737 }738 if (!strcmp (outtype, "double") && !strcmp (intype, "float")) {739 int NbytesIn = 4;740 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {741 *(double *)Pout = (*(float *)Pin - Bzero) / Bscale;742 # ifdef BYTE_SWAP743 if (!nativeOrder) { SWAP_DBLE; }744 # endif745 }746 }747 748 /** input == double **/749 if (!strcmp (outtype, "char") && !strcmp (intype, "double")) {750 int NbytesIn = 8;751 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {752 *(char *)Pout = (*(double *)Pin - Bzero) / Bscale;753 }754 }755 if (!strcmp (outtype, "byte") && !strcmp (intype, "double")) {756 int NbytesIn = 8;757 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {758 *(char *)Pout = (*(double *)Pin - Bzero) / Bscale;759 }760 }761 if (!strcmp (outtype, "short") && !strcmp (intype, "double")) {762 int NbytesIn = 8;763 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {764 *(short *)Pout = (*(double *)Pin - Bzero) / Bscale;765 # ifdef BYTE_SWAP766 if (!nativeOrder) { SWAP_BYTE; }767 # endif768 }769 }770 if (!strcmp (outtype, "int") && !strcmp (intype, "double")) {771 int NbytesIn = 8;772 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {773 *(int *)Pout = (*(double *)Pin - Bzero) / Bscale;774 # ifdef BYTE_SWAP775 if (!nativeOrder) { SWAP_WORD; }776 # endif777 }778 }779 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "double")) {780 int NbytesIn = 8;781 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {782 *(int64_t *)Pout = (*(double *)Pin - Bzero) / Bscale;783 # ifdef BYTE_SWAP784 if (!nativeOrder) { SWAP_DBLE; }785 # endif786 }787 }788 if (!strcmp (outtype, "float") && !strcmp (intype, "double")) {789 int NbytesIn = 8;790 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {791 *(float *)Pout = (*(double *)Pin - Bzero) / Bscale;792 # ifdef BYTE_SWAP793 if (!nativeOrder) { SWAP_WORD; }794 # endif795 }796 }797 if (!strcmp (outtype, "double") && !strcmp (intype, "double")) {798 int NbytesIn = 8;799 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {800 *(double *)Pout = (*(double *)Pin - Bzero) / Bscale;801 # ifdef BYTE_SWAP802 if (!nativeOrder) { SWAP_DBLE; }803 # endif804 }805 }806 # endif807 808 395 /* check array space */ 809 396 if (Nx*Ny < Nx*(Nrow - 1) + Nstart + Nval*NbytesOut) { … … 813 400 814 401 /* insert bytes from array into appropriate section of buffer */ 815 Pout = table[0].buffer + Nstart ;402 Pout = table[0].buffer + Nstart + element*NbytesOut; 816 403 Pin = array; 817 for (i = 0; i < Nrow; i++, Pout += Nx, Pin += N val*NbytesOut) {818 memcpy (Pout, Pin, N val*NbytesOut);404 for (i = 0; i < Nrow; i++, Pout += Nx, Pin += NbytesOut) { 405 memcpy (Pout, Pin, NbytesOut); 819 406 } 820 407 -
trunk/Ohana/src/libohana/src/isolate_elements.c
r40291 r41176 186 186 if (!strncmp (c, "+", 1)) return (TRUE); 187 187 if (!strncmp (c, "-", 1)) return (TRUE); 188 if (!strncmp (c, "&", 1)) return (TRUE);189 if (!strncmp (c, "|", 1)) return (TRUE);190 191 if (!strncmp (c, "<", 1)) return (TRUE);192 if (!strncmp (c, ">", 1)) return (TRUE);193 188 194 189 if (!strncmp (c, "(", 1)) return (TRUE); … … 203 198 if (!strncmp (c, "<=", 2)) return (TRUE); 204 199 if (!strncmp (c, ">=", 2)) return (TRUE); 200 if (!strncmp (c, "<~", 2)) return (TRUE); 201 if (!strncmp (c, "~>", 2)) return (TRUE); 202 203 if (!strncmp (c, "<", 1)) return (TRUE); 204 if (!strncmp (c, ">", 1)) return (TRUE); 205 if (!strncmp (c, "&", 1)) return (TRUE); 206 if (!strncmp (c, "|", 1)) return (TRUE); 205 207 206 208 return (FALSE); … … 218 220 if (!strncmp (c, "<=", 2)) return (TRUE); 219 221 if (!strncmp (c, ">=", 2)) return (TRUE); 222 if (!strncmp (c, "<~", 2)) return (TRUE); 223 if (!strncmp (c, "~>", 2)) return (TRUE); 220 224 221 225 return (FALSE); -
trunk/Ohana/src/opihi/lib.data/SplineOps.c
r41162 r41176 181 181 182 182 // NOTE: if we want to compress the output table, use native byte order here (last element) 183 gfits_set_bintable_column_reformat (&theader, &ftable, "X_KNOT", "double", myspline->xk, myspline->Nknots, FALSE);184 gfits_set_bintable_column_reformat (&theader, &ftable, "Y_KNOT", "double", myspline->yk, myspline->Nknots, FALSE);185 gfits_set_bintable_column_reformat (&theader, &ftable, "DY2_DX", "double", myspline->y2, myspline->Nknots, FALSE);183 gfits_set_bintable_column_reformat (&theader, &ftable, "X_KNOT", "double", myspline->xk, myspline->Nknots, 0, FALSE); 184 gfits_set_bintable_column_reformat (&theader, &ftable, "Y_KNOT", "double", myspline->yk, myspline->Nknots, 0, FALSE); 185 gfits_set_bintable_column_reformat (&theader, &ftable, "DY2_DX", "double", myspline->y2, myspline->Nknots, 0, FALSE); 186 186 187 187 if (!append) { -
trunk/Ohana/src/opihi/lib.shell/VectorIO.c
r41161 r41176 7 7 int j; 8 8 9 char *tformat = NULL;10 11 9 Header *theader = ftable->header; 12 10 gfits_create_table_header (theader, "BINTABLE", extname); 13 11 14 ALLOCATE (tformat, char, 2*Nvec); 12 // allocate an array of strings to represent the format for each output field 13 // formats include single column formats (BIJKDE) and multi-column formats (e.g., 2I) 14 // we will have no more than Nvec fields (but we can have fewer) 15 int Nfield = 0; 16 ALLOCATE_PTR (tformat, char *, Nvec); 17 ALLOCATE_PTR (Nelement, int, Nvec); 18 15 19 if (format) { 16 // the bintable format string can only define the byte-width of each field. valid output columns are currently: 20 // the bintable format string can defines the byte-width of each field and number of elements (columns per field). 21 // valid output columns are currently: 17 22 // B (char), I (16 bit short), J (32 bit int), E (32 bit float), D (64 bit double). 18 // the format string is just the sequence of types, eg: LIIJEED 19 // validate the format string 23 // the format string is just the sequence of types, eg: LIIJEED. 24 // it may have spaces or integer element counts: 25 // "2D 4I EEJ" 26 27 // *** validate the format string 28 29 // as I parse each elements, if it is a digit, I need parse that value 30 20 31 char *ptr = format; 21 for (j = 0; j < Nvec; j++) {32 for (j = 0; j < Nvec; ) { 22 33 while (*ptr && OHANA_WHITESPACE (*ptr)) ptr++; 23 34 if (*ptr == 0) { … … 25 36 goto escape; 26 37 } 38 39 // is there a leading integer? 40 char *endptr; 41 Nelement[Nfield] = strtol (ptr, &endptr, 10); 42 if (endptr == ptr) { 43 Nelement[Nfield] = 1; 44 } 45 ptr = endptr; // this should now point at the letter that is the format type 27 46 if ((*ptr != 'B') && (*ptr != 'I') && (*ptr != 'J') && (*ptr != 'K') && (*ptr != 'D') && (*ptr != 'E')) { 28 47 gprint (GP_ERR, "error in binary table format %s: invalid character %c\n", format, *ptr); 29 48 goto escape; 30 49 } 31 tformat[2*j + 0] = *ptr; 32 tformat[2*j + 1] = 0; // a bit sleazy : use a 2xN string to store N 1-byte strings 50 51 int Nchar = snprintf (tformat[Nfield], 0, "%d%c", Nelement[Nfield], *ptr); 52 ALLOCATE (tformat[Nfield], char, Nchar + 1); 53 int Nout = snprintf (tformat[Nfield], Nchar + 1, "%d%c", Nelement[Nfield], *ptr); 54 myAssert (Nout <= Nchar, "oops"); 55 56 // tformat[2*j + 0] = *ptr; 57 // tformat[2*j + 1] = 0; // a bit sleazy : use a 2xN string to store N 1-byte strings 58 59 j += Nelement[Nfield]; // advance past 60 if (j > Nvec) { 61 gprint (GP_ERR, "error in binary table format %s (too few vectors for listed field)\n", format); 62 goto escape; 63 } 64 33 65 ptr ++; 66 Nfield ++; 34 67 } 35 68 while (*ptr && OHANA_WHITESPACE (*ptr)) ptr++; … … 41 74 for (j = 0; j < Nvec; j++) { 42 75 // if the format is not defined, just use the native byte-widths 43 tformat[2*j + 0] = (vec[j][0].type == OPIHI_FLT) ? 'D' : 'K'; // this depends on opihi_int == int64_t for Int 44 tformat[2*j + 1] = 0; 45 } 76 ALLOCATE (tformat[j], char, 2); 77 tformat[j][0] = (vec[j][0].type == OPIHI_FLT) ? 'D' : 'K'; // this depends on opihi_int == int64_t for Int 78 tformat[j][1] = 0; 79 Nelement[j] = 1; 80 } 81 Nfield = Nvec; 46 82 } 47 83 … … 49 85 // output table (because the data goes to the named column below). need to enforce 50 86 // this somehow 51 for (j = 0; j < Nvec; j++) { 52 gfits_define_bintable_column (theader, &tformat[2*j], vec[j][0].name, NULL, NULL, 1.0, 0.0); 87 int ivec = 0; 88 for (j = 0; j < Nfield; j++) { 89 // XX need to loop over fields, and skip the additional vectors that are part of a field 90 // this call supported multiple columns per named field 91 gfits_define_bintable_column (theader, tformat[j], vec[ivec][0].name, NULL, NULL, 1.0, 0.0); 92 ivec += Nelement[j]; 93 } 94 95 // need to free the array 96 for (j = 0; j < Nfield; j++) { 97 free (tformat[j]); 53 98 } 54 99 free (tformat); … … 57 102 gfits_create_table (theader, ftable); 58 103 104 // I need to add each vector in order, but I need to 105 // track which field it corresponds to. 106 59 107 // add the vectors to the output array 60 for (j = 0; j < Nvec; j++) { 61 if (vec[j][0].type == OPIHI_FLT) { 62 gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements, nativeOrder); 63 } else { 64 // gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements, nativeOrder); 65 gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int64_t", vec[j][0].elements.Int, vec[j][0].Nelements, nativeOrder); 108 for (ivec = 0, j = 0; j < Nfield; j++) { 109 // the first vector provides the name for the field 110 char *fieldname = vec[ivec][0].name; 111 for (int k = 0; k < Nelement[j]; k++, ivec++) { 112 Vector *thisvec = vec[ivec]; 113 if (thisvec->type == OPIHI_FLT) { 114 gfits_set_bintable_column_reformat (theader, ftable, fieldname, "double", thisvec->elements.Flt, thisvec->Nelements, k, nativeOrder); 115 } else { 116 gfits_set_bintable_column_reformat (theader, ftable, fieldname, "int64_t", thisvec->elements.Int, thisvec->Nelements, k, nativeOrder); 117 } 66 118 } 67 119 } -
trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c
r40291 r41176 78 78 if (!strcmp (argv[i], "atan2")) { type = ST_BINARY; strcpy (argv[i], "a"); goto gotit; } 79 79 if (!strcmp (argv[i], "datan2")) { type = ST_BINARY; strcpy (argv[i], "d"); goto gotit; } 80 81 if (!strcmp (argv[i], "<~")) { type = ST_BINARY; strcpy (argv[i], "l"); goto gotit; } 82 if (!strcmp (argv[i], "~>")) { type = ST_BINARY; strcpy (argv[i], "r"); goto gotit; } 83 80 84 if (!strcmp (argv[i], ",")) { type = ST_COMMA; goto gotit; } 81 85 … … 99 103 if (!strcmp (argv[i], ">>")) { type = ST_LOGIC; strcpy (argv[i], "U"); goto gotit; } 100 104 if (!strcmp (argv[i], "<<")) { type = ST_LOGIC; strcpy (argv[i], "D"); goto gotit; } 105 106 /* XXX I would like to change the syntax to allow << and >> to mean bitshifts 107 but that means breaking these older values which means MIN and MAX */ 108 // for now, use <- and -> to mean bitshift 101 109 102 110 if (!strcmp (argv[i], "&&")) { type = ST_AND; strcpy (argv[i], "A"); goto gotit; } -
trunk/Ohana/src/opihi/lib.shell/parse.c
r40574 r41176 66 66 /* dvomath returns a new string, or NULL, with the result of the expression */ 67 67 val = dvomath (1, &V1, &size, 0); 68 if (val == NULL) goto error;68 if (val == NULL) { print_error (); goto error; } 69 69 fval += atof(val); 70 70 // save the result … … 88 88 /* dvomath returns a new string, or NULL, with the result of the expression */ 89 89 val = dvomath (1, &V1, &size, 0); 90 if (val == NULL) goto error;90 if (val == NULL) { print_error (); goto error; } 91 91 fval -= atof(val); 92 92 // save the result -
trunk/Ohana/src/opihi/lib.shell/stack_math.c
r40331 r41176 34 34 case '?': SSS_FUNC(M1 ? M2: M3); 35 35 default: 36 snprintf (line, 512, "error: op %c not defined !", op[0]);36 snprintf (line, 512, "error: op %c not defined as scalar trinary op!", op[0]); 37 37 push_error (line); 38 38 return (FALSE); … … 162 162 case '?': VVV_FUNC(*M1 ? *M2: *M3); 163 163 default: 164 snprintf (line, 512, "error: op %c not defined !", op[0]);164 snprintf (line, 512, "error: op %c not defined as vector trinary op!", op[0]); 165 165 push_error (line); 166 166 return (FALSE); … … 227 227 case '?': MMM_FUNC(*M1 ? *M2: *M3); 228 228 default: 229 snprintf (line, 512, "error: op %c not defined !", op[0]);229 snprintf (line, 512, "error: op %c not defined as matrix trinary op!", op[0]); 230 230 push_error (line); 231 231 return (FALSE); … … 357 357 case 'A': VV_FUNC(ST_SCALAR_INT, (*M1 && *M2) ? 1 : 0); 358 358 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 359 401 default: 360 snprintf (line, 512, "error: op %c not defined !", op[0]);402 snprintf (line, 512, "error: op %c not defined for (vector OP vector)!", op[0]); 361 403 push_error (line); 362 404 return (FALSE); … … 469 511 case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0); 470 512 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 471 552 default: 472 snprintf (line, 512, "error: op %c not defined !", op[0]);553 snprintf (line, 512, "error: op %c not defined for (scalar OP vector)!", op[0]); 473 554 push_error (line); 474 555 return (FALSE); … … 577 658 case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0); 578 659 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 579 698 default: 580 snprintf (line, 512, "error: op %c not defined !", op[0]);699 snprintf (line, 512, "error: op %c not defined for (vector OP scalar)!", op[0]); 581 700 push_error (line); 582 701 return (FALSE); … … 670 789 case 'A': MV_FUNC((*M1 && *M2) ? 1 : 0); 671 790 case 'O': MV_FUNC((*M1 || *M2) ? 1 : 0); 791 672 792 default: 673 snprintf (line, 512, "error: op %c not defined !", op[0]);793 snprintf (line, 512, "error: op %c not defined for (matrix OP vector)!", op[0]); 674 794 push_error (line); 675 795 return (FALSE); … … 768 888 case 'O': VM_FUNC((*M1 || *M2) ? 1 : 0); 769 889 default: 770 snprintf (line, 512, "error: op %c not defined !", op[0]);890 snprintf (line, 512, "error: op %c not defined for (vector OP matrix)!", op[0]); 771 891 push_error (line); 772 892 return (FALSE); … … 849 969 case 'O': MM_FUNC((*M1 || *M2) ? 1 : 0); 850 970 default: 851 snprintf (line, 512, "error: op %c not defined !", op[0]);971 snprintf (line, 512, "error: op %c not defined for (matrix OP matrix)!", op[0]); 852 972 push_error (line); 853 973 return (FALSE); … … 935 1055 case 'O': MS_FUNC((*M1 || M2) ? 1 : 0); 936 1056 default: 937 snprintf (line, 512, "error: op %c not defined !", op[0]);1057 snprintf (line, 512, "error: op %c not defined for (matrix OP scalar)!", op[0]); 938 1058 push_error (line); 939 1059 return (FALSE); … … 1012 1132 case 'O': SM_FUNC((M1 || *M2) ? 1 : 0); 1013 1133 default: 1014 snprintf (line, 512, "error: op %c not defined !", op[0]);1134 snprintf (line, 512, "error: op %c not defined for (scalar OP matrix)!", op[0]); 1015 1135 push_error (line); 1016 1136 return (FALSE); … … 1094 1214 case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0); 1095 1215 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 1096 1247 default: 1097 snprintf (line, 512, "error: op %c not defined !", op[0]);1248 snprintf (line, 512, "error: op %c not defined for (scalar OP scalar)!", op[0]); 1098 1249 push_error (line); 1099 1250 return (FALSE); … … 1168 1319 int S_unary (StackVar *OUT, StackVar *V1, char *op) { 1169 1320 1170 char line[512]; // this is only used to report an error1171 1172 1321 # define S_FUNC(OP,FTYPE) { \ 1173 1322 if (V1->type == ST_SCALAR_FLT) { \ … … 1210 1359 if (!strcmp (op, "asinh")) S_FUNC(asinh (M1), ST_SCALAR_FLT); 1211 1360 if (!strcmp (op, "acosh")) S_FUNC(acosh (M1), ST_SCALAR_FLT); 1212 if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), ST_SCALAR_FLT);1213 1361 if (!strcmp (op, "sin")) S_FUNC(sin (M1), ST_SCALAR_FLT); 1214 1362 if (!strcmp (op, "cos")) S_FUNC(cos (M1), ST_SCALAR_FLT); … … 1223 1371 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, ST_SCALAR_FLT); 1224 1372 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); 1225 1374 if (!strcmp (op, "rnd")) S_FUNC(0.0*M1 + drand48(), ST_SCALAR_FLT); 1226 1375 if (!strcmp (op, "drnd")) S_FUNC(0.0*M1 + drand48(), ST_SCALAR_FLT); … … 1235 1384 1236 1385 clear_stack (V1); 1237 snprintf (line, 512, "error: op %s not defined!", op); 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); 1238 1389 push_error (line); 1239 1390 return (FALSE); 1240 1241 1391 } 1242 1392 … … 1295 1445 if (!strcmp (op, "asinh")) V_FUNC(asinh(*M1), ST_SCALAR_FLT); 1296 1446 if (!strcmp (op, "acosh")) V_FUNC(acosh(*M1), ST_SCALAR_FLT); 1297 if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), ST_SCALAR_FLT);1298 1447 if (!strcmp (op, "sin")) V_FUNC(sin(*M1), ST_SCALAR_FLT); 1299 1448 if (!strcmp (op, "cos")) V_FUNC(cos(*M1), ST_SCALAR_FLT); … … 1308 1457 if (!strcmp (op, "dacos")) V_FUNC(acos(*M1)*DEG_RAD, ST_SCALAR_FLT); 1309 1458 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); 1310 1460 if (!strcmp (op, "rnd")) V_FUNC(drand48(), ST_SCALAR_FLT); 1311 1461 if (!strcmp (op, "drnd")) V_FUNC(drand48(), ST_SCALAR_FLT); 1312 1462 if (!strcmp (op, "lrnd")) V_FUNC(lrand48(), ST_SCALAR_INT); 1313 1463 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);1316 1464 if (!strcmp (op, "not")) V_FUNC(!(*M1), ST_SCALAR_INT); 1317 1465 if (!strcmp (op, "--")) V_FUNC(-1*(*M1), ST_SCALAR_INT); // NOTE: opihi_int is signed 1318 1466 if (!strcmp (op, "isinf")) V_FUNC(!finite(*M1), ST_SCALAR_FLT); 1319 1467 if (!strcmp (op, "isnan")) V_FUNC(isnan((opihi_flt)(*M1)), ST_SCALAR_FLT); 1468 if (!strcmp (op, "ramp")) V_FUNC(i, ST_SCALAR_INT); 1320 1469 if (!strcmp (op, "xramp")) V_FUNC(i, ST_SCALAR_INT); 1321 1470 if (!strcmp (op, "yramp")) V_FUNC(0, ST_SCALAR_INT); 1322 1471 if (!strcmp (op, "zramp")) V_FUNC(0, ST_SCALAR_INT); 1472 if (!strcmp (op, "zero")) V_FUNC(0, ST_SCALAR_INT); 1323 1473 /* xramp, yramp, zramp above only make sense for matrices. for vectors, xramp = ramp, yramp = zero */ 1324 1474 1325 1475 # undef V_FUNC 1326 1476 1327 escape: 1328 1477 // free the temp vector if needed 1329 1478 if (V1[0].type == ST_VECTOR_TMP) { 1330 1479 free (V1[0].vector[0].elements.Ptr); … … 1334 1483 1335 1484 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); 1336 1500 return (TRUE); 1337 1501 1338 1502 } 1339 1503 1340 # define M_FUNC(OP) { for (i = 0; i < Npix; i++, out++, M1++) { *out = (OP); } }1504 # define M_FUNC(OP) { for (i = 0; i < Npix; i++, out++, M1++) { *out = (OP); } goto escape; } 1341 1505 1342 1506 int M_unary (StackVar *OUT, StackVar *V1, char *op) { … … 1360 1524 // if (!strcmp (op, "rint")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = nearbyint (*M1); }} 1361 1525 1362 if (!strcmp (op, "=")) {}1526 if (!strcmp (op, "=")) { goto escape; } 1363 1527 if (!strcmp (op, "abs")) M_FUNC(fabs(*M1)); 1364 1528 if (!strcmp (op, "int")) M_FUNC((opihi_flt)(long long)(*M1)); … … 1375 1539 if (!strcmp (op, "asinh")) M_FUNC(asinh(*M1)); 1376 1540 if (!strcmp (op, "acosh")) M_FUNC(acosh(*M1)); 1377 if (!strcmp (op, "lgamma")) M_FUNC(lgamma(*M1));1378 1541 if (!strcmp (op, "sin")) M_FUNC(sin(*M1)); 1379 1542 if (!strcmp (op, "cos")) M_FUNC(cos(*M1)); … … 1388 1551 if (!strcmp (op, "dacos")) M_FUNC(acos(*M1)*DEG_RAD); 1389 1552 if (!strcmp (op, "datan")) M_FUNC(atan(*M1)*DEG_RAD); 1390 if (!strcmp (op, "not")) M_FUNC(!(*M1)); 1391 if (!strcmp (op, "--")) M_FUNC(-(*M1)); 1553 if (!strcmp (op, "lgamma")) M_FUNC(lgamma(*M1)); 1392 1554 if (!strcmp (op, "rnd")) M_FUNC(drand48()); 1393 1555 if (!strcmp (op, "drnd")) M_FUNC(drand48()); 1394 1556 if (!strcmp (op, "lrnd")) M_FUNC(lrand48()); 1395 1557 if (!strcmp (op, "mrnd")) M_FUNC(mrand48()); 1558 if (!strcmp (op, "not")) M_FUNC(!(*M1)); 1559 if (!strcmp (op, "--")) M_FUNC(-(*M1)); 1396 1560 if (!strcmp (op, "ramp")) M_FUNC(i); 1397 if (!strcmp (op, "zero")) M_FUNC(0);1398 1561 if (!strcmp (op, "isinf")) M_FUNC(!finite(*M1)); 1399 1562 if (!strcmp (op, "isnan")) M_FUNC(isnan(*M1)); 1563 if (!strcmp (op, "zero")) M_FUNC(0); 1400 1564 1401 1565 /* xrm and yrm only make sense for 2D matrices. see special meaning for vectors */ … … 1411 1575 } 1412 1576 } 1577 goto escape; 1413 1578 } 1414 1579 if (!strcmp (op, "yramp")) { … … 1423 1588 } 1424 1589 } 1590 goto escape; 1425 1591 } 1426 1592 if (!strcmp (op, "zramp")) { … … 1435 1601 } 1436 1602 } 1437 } 1438 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 1439 1621 if (V1[0].type == ST_MATRIX_TMP) { 1440 1622 free (V1[0].buffer[0].header.buffer);
Note:
See TracChangeset
for help on using the changeset viewer.
