| 1 | #include <stdio.h>
|
|---|
| 2 | #include "pslib.h"
|
|---|
| 3 |
|
|---|
| 4 | #define ORDER 3
|
|---|
| 5 | #define BAD 1
|
|---|
| 6 |
|
|---|
| 7 | int main(int argc, char **argv)
|
|---|
| 8 | {
|
|---|
| 9 | psPolynomial1D *poly = psPolynomial1DAlloc(ORDER, PS_POLYNOMIAL_ORD);
|
|---|
| 10 |
|
|---|
| 11 | for (int i = 0; i < poly->n; i++) {
|
|---|
| 12 | poly->coeff[i] = (float)i;
|
|---|
| 13 | if (i == BAD) {
|
|---|
| 14 | poly->mask[i] = 1; // Don't use this coefficient!
|
|---|
| 15 | } else {
|
|---|
| 16 | poly->mask[i] = 0;
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | fprintf(stderr,"Value using mask: %f\n", psPolynomial1DEval(0.5, poly));
|
|---|
| 21 |
|
|---|
| 22 | // A different method of doing the same thing
|
|---|
| 23 | poly->coeff[BAD] = 0.0; // Set coefficient to zero instead of masking
|
|---|
| 24 | poly->mask[BAD] = 0; // Use this coefficient
|
|---|
| 25 |
|
|---|
| 26 | fprintf(stderr,"Value using coefficient zeroing: %f\n", psPolynomial1DEval(0.5, poly));
|
|---|
| 27 |
|
|---|
| 28 | psFree(poly);
|
|---|
| 29 |
|
|---|
| 30 | exit(EXIT_SUCCESS);
|
|---|
| 31 | }
|
|---|