- Timestamp:
- Nov 24, 2008, 5:09:38 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/stack_math.c
r18078 r20827 35 35 out = OUT[0].ptr = (float *)OUT[0].vector[0].elements; 36 36 37 switch (op[0]) { 37 // XXX this is not quite there: 38 // 1) do I drop the .ptr element of StackVar? 39 // 2) things below are using type from a StackVar to get the vector type -- wrong place 40 // 3) the temp would need lots of work -- is it worth it? 41 // 4) some operators force the output to be float -- we cannot use a single bit of code to 42 // define the output type based on which is a float and which is not. getting ugly. 43 // ??? how much more work to bring the MV, etc functions into shape ??? 44 45 # define VV_FUNC(OP) \ 46 if ((M1->type == OPIHI_FLOAT) && (M2->type == OPIHI_FLOAT)) { \ 47 // output must be float, can use either as a temp \ 48 opihi_float *M1 = V1[0].vector[0].elements; \ 49 opihi_float *M2 = V2[0].vector[0].elements; \ 50 for (i = 0; i < Nx; i++, out++, M1++, M2++) { \ 51 *out = *M1 OP *M2; \ 52 } \ 53 break; \ 54 } \ 55 if ((M1->type != OPIHI_FLOAT) && (M2->type == OPIHI_FLOAT)) { \ 56 // output must be float, can use M2 as a temp \ 57 opihi_float *M1 = V1[0].vector[0].elementsInt; \ 58 opihi_float *M2 = V2[0].vector[0].elements; \ 59 for (i = 0; i < Nx; i++, out++, M1++, M2++) { \ 60 *out = *M1 OP *M2; \ 61 } \ 62 break; \ 63 } \ 64 if ((M1->type == OPIHI_FLOAT) && (M2->type != OPIHI_FLOAT)) { \ 65 // output must be float, can use M1 as a temp \ 66 opihi_float *M1 = V1[0].vector[0].elements; \ 67 opihi_float *M2 = V2[0].vector[0].elementsInt; \ 68 for (i = 0; i < Nx; i++, out++, M1++, M2++) { \ 69 *out = *M1 OP *M2; \ 70 } \ 71 break; \ 72 } \ 73 if ((M1->type != OPIHI_FLOAT) && (M2->type != OPIHI_FLOAT)) { \ 74 // output may be int, can use either as temp \ 75 opihi_float *M1 = V1[0].vector[0].elementsInt; \ 76 opihi_float *M2 = V2[0].vector[0].elementsInt; \ 77 for (i = 0; i < Nx; i++, out++, M1++, M2++) { \ 78 *out = *M1 OP *M2; \ 79 } \ 80 break; \ 81 } 82 83 switch (op[0]) { 38 84 case '+': 39 for (i = 0; i < Nx; i++, out++, M1++, M2++) 40 *out = *M1 + *M2; 41 break; 85 VV_FUNC 86 87 if ((M1->type == OPIHI_FLOAT) && (M2->type == OPIHI_FLOAT)) { 88 // output must be float, can use either as a temp 89 M1 = V1[0].vector[0].elements; 90 M2 = V2[0].vector[0].elements; 91 for (i = 0; i < Nx; i++, out++, M1++, M2++) { 92 *out = *M1 + *M2; 93 } 94 break; 95 } 96 if ((M1->type != OPIHI_FLOAT) && (M2->type == OPIHI_FLOAT)) { 97 // output must be float, can use M2 as a temp 98 M1 = V1[0].vector[0].elementsInt; 99 M2 = V2[0].vector[0].elements; 100 for (i = 0; i < Nx; i++, out++, M1++, M2++) { 101 *out = *M1 + *M2; 102 } 103 break; 104 } 105 if ((M1->type == OPIHI_FLOAT) && (M2->type != OPIHI_FLOAT)) { 106 // output must be float, can use M1 as a temp 107 M1 = V1[0].vector[0].elements; 108 M2 = V2[0].vector[0].elementsInt; 109 for (i = 0; i < Nx; i++, out++, M1++, M2++) { 110 *out = *M1 + *M2; 111 } 112 break; 113 } 114 if ((M1->type != OPIHI_FLOAT) && (M2->type != OPIHI_FLOAT)) { 115 // output may be int, can use either as temp 116 M1 = V1[0].vector[0].elementsInt; 117 M2 = V2[0].vector[0].elementsInt; 118 for (i = 0; i < Nx; i++, out++, M1++, M2++) { 119 *out = *M1 + *M2; 120 } 121 break; 122 } 42 123 case '-': 43 124 for (i = 0; i < Nx; i++, out++, M1++, M2++)
Note:
See TracChangeset
for help on using the changeset viewer.
