Changeset 25864 for branches/pap/psLib/src/math/psMatrix.c
- Timestamp:
- Oct 16, 2009, 5:05:44 PM (17 years ago)
- File:
-
- 1 edited
-
branches/pap/psLib/src/math/psMatrix.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psLib/src/math/psMatrix.c
r25862 r25864 103 103 static void vectorPStoGSL(gsl_vector *out, const psVector *in) 104 104 { 105 psAssert(out->size == in->n, "Sizes don't match!"); 106 105 107 long n = in->n; // Size of input 106 108 switch (in->type.type) { … … 122 124 static void vectorGSLtoPS(psVector *out, const gsl_vector *in) 123 125 { 126 psAssert(in->size == out->n, "Sizes don't match!"); 127 124 128 long n = out->n; // Size of output 125 129 switch (out->type.type) { … … 142 146 static void matrixPStoGSL(gsl_matrix *out, const psImage *in) 143 147 { 148 psAssert(out->size1 == in->numRows && out->size2 == in->numCols, "Sizes don't match!"); 149 144 150 int numCols = in->numCols, numRows = in->numRows; // Size of matrix 145 151 switch (in->type.type) { … … 152 158 break; 153 159 case PS_TYPE_F64: 154 if (in->parent ) {160 if (in->parent|| out->tda != out->size1) { 155 161 for (int y = 0, i = 0; y < numRows; y++, i += numCols) { 156 162 memcpy(&out->data[i], in->data.F64[y], numCols * PSELEMTYPE_SIZEOF(PS_TYPE_F64)); 157 163 } 158 164 } else { 159 memcpy(out->data, in-> data.F64, numCols * numRows * PSELEMTYPE_SIZEOF(PS_TYPE_F64));165 memcpy(out->data, in->p_rawDataBuffer, numCols * numRows * PSELEMTYPE_SIZEOF(PS_TYPE_F64)); 160 166 } 161 167 break; … … 167 173 168 174 /** Static function to copy GSL matrix data to a psF32 or psF64 image */ 169 static void matrixGSLtoPS(psImage *out, gsl_matrix *in) 170 { 175 static void matrixGSLtoPS(psImage *out, const gsl_matrix *in) 176 { 177 psAssert(in->size1 == out->numRows && in->size2 == out->numCols, "Sizes don't match!"); 178 171 179 int numCols = out->numCols, numRows = out->numRows; // Size of matrix 172 180 switch (out->type.type) { … … 179 187 break; 180 188 case PS_TYPE_F64: 181 if (out->parent ) {189 if (out->parent || in->tda != in->size1) { 182 190 for (int y = 0, i = 0; y < numRows; y++, i += numCols) { 183 191 memcpy(out->data.F64[y], &in->data[i], numCols * PSELEMTYPE_SIZEOF(PS_TYPE_F64)); 184 192 } 185 193 } else { 186 memcpy(out-> data.F64, in->data, numCols * numRows * PSELEMTYPE_SIZEOF(PS_TYPE_F64));194 memcpy(out->p_rawDataBuffer, in->data, numCols * numRows * PSELEMTYPE_SIZEOF(PS_TYPE_F64)); 187 195 } 188 196 break;
Note:
See TracChangeset
for help on using the changeset viewer.
