Changeset 10605 for trunk/psLib/src/math/psPolynomialUtils.c
- Timestamp:
- Dec 9, 2006, 6:13:25 PM (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
r10598 r10605 180 180 psPolynomial2D *psPolynomial2D_dX (psPolynomial2D *out, psPolynomial2D *poly) 181 181 { 182 psPolynomial2D *dest = NULL; 182 183 int nXout = poly->nX - 1; 183 184 int nYout = poly->nY; 184 185 186 if (poly->nX == 0) 187 return NULL; 188 189 bool inPlace = false; 190 185 191 if (out == NULL) { 186 out = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXout, nYout); 187 } else { 188 psPolynomial2DRecycle (out, poly->type, nXout, nYout); 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 } 189 202 } 190 203 191 204 for (int i = 0; i < nXout + 1; i++) { 192 205 for (int j = 0; j < nYout + 1; j++) { 193 out->mask[i][j] = poly->mask[i+1][j]; 194 out->coeff[i][j] = poly->coeff[i+1][j] * (i+1); 195 } 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; 196 214 } 197 215 return out; … … 200 218 psPolynomial2D *psPolynomial2D_dY (psPolynomial2D *out, psPolynomial2D *poly) 201 219 { 202 203 int nXout = poly->nX - 1; 204 int nYout = poly->nY; 220 psPolynomial2D *dest = NULL; 221 int nXout = poly->nX; 222 int nYout = poly->nY - 1; 223 224 if (poly->nY == 0) 225 return NULL; 226 227 bool inPlace = false; 205 228 206 229 if (out == NULL) { 207 out = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXout, nYout); 208 } else { 209 psPolynomial2DRecycle (out, poly->type, nXout, nYout); 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 } 210 240 } 211 241 212 242 for (int i = 0; i < nXout + 1; i++) { 213 243 for (int j = 0; j < nYout + 1; j++) { 214 out->mask[i][j] = poly->mask[i][j+1]; 215 out->coeff[i][j] = poly->coeff[i][j+1] * (j+1); 216 } 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; 217 252 } 218 253 return out;
Note:
See TracChangeset
for help on using the changeset viewer.
