Changeset 40331
- Timestamp:
- Jan 31, 2018, 9:47:06 AM (8 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/stack_math.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/stack_math.c
r40019 r40331 599 599 } 600 600 601 // the vector is applied to each column (currently only valid for 2D matrix)601 // the vector is applied to each ROW (currently only valid for 2D matrix), e.g.: M[20,10] * X[20] -> M'[20,10] where M'[2,1] = M[2,1] * X[2] 602 602 int MV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 603 603 … … 607 607 Nx = V1[0].buffer[0].matrix.Naxis[0]; 608 608 Ny = V1[0].buffer[0].matrix.Naxis[1]; 609 if (Ny != V2[0].vector[0].Nelements) { 610 push_error ("dimension mismatch"); 609 if (Nx != V2[0].vector[0].Nelements) { 610 snprintf (line, 512, "error: matrix OP vector matrix dimensions do not match: (%d x %d) OP %d", Nx, Ny, V2[0].vector[0].Nelements); 611 push_error (line); 611 612 return (FALSE); 612 613 } … … 628 629 # define MV_FUNC(OP) { \ 629 630 if (V2->vector->type == OPIHI_FLT) { \ 630 opihi_flt *M2 = V2[0].vector[0].elements.Flt;\631 for (i = 0; i < Ny; i++, M2++) {\632 for (j = 0; j < Nx; j++, out++, M1++ ) {\631 for (i = 0; i < Ny; i++) { \ 632 opihi_flt *M2 = V2[0].vector[0].elements.Flt; \ 633 for (j = 0; j < Nx; j++, out++, M1++, M2++) { \ 633 634 *out = OP; \ 634 635 } \ … … 637 638 } \ 638 639 if (V2->vector->type != OPIHI_FLT) { \ 639 opihi_int *M2 = V2[0].vector[0].elements.Int;\640 for (i = 0; i < Ny; i++, M2++) {\641 for (j = 0; j < Nx; j++, out++, M1++ ) {\640 for (i = 0; i < Ny; i++) { \ 641 opihi_int *M2 = V2[0].vector[0].elements.Int; \ 642 for (j = 0; j < Nx; j++, out++, M1++, M2++) { \ 642 643 *out = OP; \ 643 644 } \ … … 695 696 } 696 697 697 // the vector is applied to each row (currently only valid for 2D matrix) 698 // the vector is applied to each COLUMN (currently only valid for 2D matrix) 699 // e.g.: X[10] * M[20,10] -> M'[20,10] where M'[2,1] = X[1] * M[2,1] 698 700 int VM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 699 701 … … 703 705 Nx = V2[0].buffer[0].matrix.Naxis[0]; 704 706 Ny = V2[0].buffer[0].matrix.Naxis[1]; 705 if (Nx != V1[0].vector[0].Nelements) { 707 if (Ny != V1[0].vector[0].Nelements) { 708 snprintf (line, 512, "error: vector OP matrix dimensions do not match: %d OP (%d x %d)", V1[0].vector[0].Nelements, Nx, Ny); 709 push_error (line); 706 710 return (FALSE); 707 711 } … … 722 726 # define VM_FUNC(OP) { \ 723 727 if (V1->vector->type == OPIHI_FLT) { \ 724 for (i = 0; i < Ny; i++) {\725 opihi_flt *M1 = V1[0].vector[0].elements.Flt;\726 for (j = 0; j < Nx; j++, out++, M 1++, M2++) { \728 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 729 for (i = 0; i < Ny; i++, M1++) { \ 730 for (j = 0; j < Nx; j++, out++, M2++) { \ 727 731 *out = OP; \ 728 732 } \ … … 731 735 } \ 732 736 if (V1->vector->type != OPIHI_FLT) { \ 733 for (i = 0; i < Ny; i++) {\734 opihi_int *M1 = V1[0].vector[0].elements.Int;\735 for (j = 0; j < Nx; j++, out++, M 1++, M2++) { \737 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 738 for (i = 0; i < Ny; i++, M1++) { \ 739 for (j = 0; j < Nx; j++, out++, M2++) { \ 736 740 *out = OP; \ 737 741 } \
Note:
See TracChangeset
for help on using the changeset viewer.
