Changeset 10607
- Timestamp:
- Dec 10, 2006, 7:28:33 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psPolynomialUtils.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomialUtils.c
r10605 r10607 180 180 psPolynomial2D *psPolynomial2D_dX (psPolynomial2D *out, psPolynomial2D *poly) 181 181 { 182 psPolynomial2D *dest = NULL;183 182 int nXout = poly->nX - 1; 184 183 int nYout = poly->nY; 185 184 185 if (out == poly) { 186 psError(PS_ERR_UNKNOWN, false, "cannot assign output to input polynomial"); 187 return NULL; 188 } 189 186 190 if (poly->nX == 0) 187 191 return NULL; 188 192 189 bool inPlace = false;190 191 193 if (out == NULL) { 192 dest = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXout, nYout); 193 out = dest; 194 } else { 195 if (out == poly) { 196 inPlace = true; 197 dest = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXout, nYout); 198 } else { 199 dest = out; 200 psPolynomial2DRecycle (dest, poly->type, nXout, nYout); 201 } 194 out = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXout, nYout); 195 } else { 196 psPolynomial2DRecycle (out, poly->type, nXout, nYout); 202 197 } 203 198 204 199 for (int i = 0; i < nXout + 1; i++) { 205 200 for (int j = 0; j < nYout + 1; j++) { 206 dest->mask[i][j] = poly->mask[i+1][j]; 207 dest->coeff[i][j] = poly->coeff[i+1][j] * (i+1); 208 } 209 } 210 211 if (inPlace) { 212 psFree (poly); 213 out = dest; 201 out->mask[i][j] = poly->mask[i+1][j]; 202 out->coeff[i][j] = poly->coeff[i+1][j] * (i+1); 203 } 214 204 } 215 205 return out; … … 218 208 psPolynomial2D *psPolynomial2D_dY (psPolynomial2D *out, psPolynomial2D *poly) 219 209 { 220 psPolynomial2D *dest = NULL;221 210 int nXout = poly->nX; 222 211 int nYout = poly->nY - 1; 223 212 213 if (out == poly) { 214 psError(PS_ERR_UNKNOWN, false, "cannot assign output to input polynomial"); 215 return NULL; 216 } 217 224 218 if (poly->nY == 0) 225 219 return NULL; 226 220 227 bool inPlace = false;228 229 221 if (out == NULL) { 230 dest = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXout, nYout); 231 out = dest; 232 } else { 233 if (out == poly) { 234 inPlace = true; 235 dest = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXout, nYout); 236 } else { 237 dest = out; 238 psPolynomial2DRecycle (dest, poly->type, nXout, nYout); 239 } 222 out = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXout, nYout); 223 } else { 224 psPolynomial2DRecycle (out, poly->type, nXout, nYout); 240 225 } 241 226 242 227 for (int i = 0; i < nXout + 1; i++) { 243 228 for (int j = 0; j < nYout + 1; j++) { 244 dest->mask[i][j] = poly->mask[i][j+1]; 245 dest->coeff[i][j] = poly->coeff[i][j+1] * (j+1); 246 } 247 } 248 249 if (inPlace) { 250 psFree (poly); 251 out = dest; 229 out->mask[i][j] = poly->mask[i][j+1]; 230 out->coeff[i][j] = poly->coeff[i][j+1] * (j+1); 231 } 252 232 } 253 233 return out;
Note:
See TracChangeset
for help on using the changeset viewer.
