diff options
-rw-r--r-- | abs/polyfun-help.pd | 20 | ||||
-rw-r--r-- | abs/polyfun.pd | 77 |
2 files changed, 97 insertions, 0 deletions
diff --git a/abs/polyfun-help.pd b/abs/polyfun-help.pd new file mode 100644 index 0000000..5d50743 --- /dev/null +++ b/abs/polyfun-help.pd @@ -0,0 +1,20 @@ +#N canvas 137 170 448 308 10; +#X text 338 10 part of zexy; +#X text 122 40 calculate a polynomial function; +#X text 289 279 updated for zexy-2.1; +#X floatatom 45 164 0 0 0 0 x - -; +#X floatatom 45 264 0 0 0 0 y - -; +#X msg 89 189 1 2; +#X text 128 190 y=2x+1; +#X msg 110 214 3 0 -1; +#X text 166 215 y=3-x^2; +#X text 32 80 on the right inlet you give the coefficients (a0..aN) +of the polynomial function: y=a0+a1*x+a2*x^2+...+aN*x^N; +#X text 33 109 the length of the coefficient list determines the order +of the polynomial function.; +#X obj 60 39 polyfun; +#X obj 45 238 polyfun; +#X connect 3 0 12 0; +#X connect 5 0 12 1; +#X connect 7 0 12 1; +#X connect 12 0 4 0; diff --git a/abs/polyfun.pd b/abs/polyfun.pd new file mode 100644 index 0000000..540816b --- /dev/null +++ b/abs/polyfun.pd @@ -0,0 +1,77 @@ +#N canvas 618 139 492 542 10; +#X obj 97 112 inlet x; +#X obj 97 437 outlet y=a0+a1*x+a2*x^2+a3*x^3+...; +#X obj 97 415 f; +#X obj 119 335 +; +#X obj 119 302 * 1; +#X obj 97 133 t b b f; +#X obj 119 195 t l f; +#X obj 199 111 inlet coefficients; +#X obj 119 173 list; +#X text 36 29 the right inlet takes the coefficients a0...aN \; whenever +a value 'x' appears on the left inlet \, 'y' is calculated by:; +#X text 96 68 y=a0+a1*x+a2*x^2+...+aN*x^N; +#X text 93 14 polynomial function of order N; +#X text 11 86 N is determined at execution time (depending on length +of coeff-list).; +#N canvas 0 0 543 426 repack 0; +#X obj 158 194 list split 1; +#X obj 158 284 list; +#X obj 158 305 route list float; +#X obj 211 331 t l; +#X obj 119 126 list split 1; +#X obj 188 241 outlet; +#X obj 119 65 inlet; +#X text 137 110 discard the 1st element (it is extracted outside); +#X obj 158 218 t b f; +#X connect 0 0 8 0; +#X connect 0 1 1 1; +#X connect 1 0 2 0; +#X connect 2 0 3 0; +#X connect 2 1 3 0; +#X connect 3 0 0 0; +#X connect 4 1 0 0; +#X connect 6 0 4 0; +#X connect 8 0 1 0; +#X connect 8 1 5 0; +#X restore 119 220 pd repack 1; +#N canvas 0 0 450 300 x^n 0; +#X obj 158 203 * 1; +#X obj 158 225 t f f; +#X obj 158 182 f; +#X msg 204 178 1; +#X obj 174 157 t f b; +#X obj 158 123 inlet bang; +#X obj 249 123 inlet x; +#X obj 158 250 outlet; +#X connect 0 0 1 0; +#X connect 1 0 7 0; +#X connect 1 1 0 1; +#X connect 2 0 0 0; +#X connect 3 0 0 1; +#X connect 4 0 2 1; +#X connect 4 1 3 0; +#X connect 5 0 2 0; +#X connect 6 0 4 0; +#X restore 149 273 pd x^n; +#X obj 119 249 t f b; +#X text 148 314 an*x^n; +#X text 147 349 sum; +#X obj 119 382 t f f; +#X connect 0 0 5 0; +#X connect 2 0 1 0; +#X connect 3 0 18 0; +#X connect 4 0 3 0; +#X connect 5 0 2 0; +#X connect 5 1 8 0; +#X connect 5 2 14 1; +#X connect 6 0 13 0; +#X connect 6 1 3 1; +#X connect 7 0 8 1; +#X connect 8 0 6 0; +#X connect 13 0 15 0; +#X connect 14 0 4 1; +#X connect 15 0 4 0; +#X connect 15 1 14 0; +#X connect 18 0 3 1; +#X connect 18 1 2 1; |