static void mTXChMatrix (MTXCh *x, t_symbol *s, int argc, t_atom *argv) { int rows = atom_getint (argv++); int columns = atom_getint (argv++); int size = rows * columns; int in_size = argc-2; unsigned int n; /* size check */ if (!size) post("mtx_circular_harmonics: invalid dimensions"); else if (in_size<size) post("mtx_circular_harmonics: sparse matrix not yet supported: use \"mtx_check\""); else if ((rows!=1)||(columns<1)) post("mtx_circular_harmonics: 1 X L matrix expected with phi vector, but got more rows/no entries"); else { if (x->l!=columns) { deleteMTXChdata(x); x->l=columns; allocMTXChdata(x); } for (n=0;n<x->l;n++) { x->phi[n]=(double) atom_getfloat(argv+n); } if (x->wc!=0) { int n; chebyshev12(x->phi, x->wc); in_size=x->l*(2*x->nmax+1); SETFLOAT(x->list_ch,(float)x->l); SETFLOAT(x->list_ch+1,(float)(2*x->nmax+1)); for (n=0;n<in_size; n++) SETFLOAT(x->list_ch+n+2,(float)x->wc->t[n]); mTXChBang(x); } else post("mtx_circular_harmonics: memory error, no operation"); } }
int main (int argc, char *argv[]) { int nmax, l, lc, n, m; Cheby12WorkSpace *wc=0; double *ptr,*phi; if (argc <3) { printf("chebyshev12 requires nmax as input argument followed by phi values\n"); return 0; } nmax=atoi(argv[1]); l=argc-2; if ((phi=(double*)calloc(l,sizeof(double)))==0) { printf("chebyshev12 could not allocate memory for %d phi-values\n",l); return 0; } if ((wc=chebyshev12_alloc(nmax,l))==0) { printf("chebyshev12 could not allocate memory for n=%d\n and l=%d\n",nmax, l); return 0; } for (n=0; n<l; n++) { phi[n]=atof(argv[n+2]); } chebyshev12(phi,wc); ptr=wc->t; for (lc=0; lc<l; lc++) { printf("pt %d:\n",lc); for (m=-nmax; m<=nmax; m++) { printf("T[%2d](%7.4f)=%7.4f\n",m,phi[lc],*ptr++); } } chebyshev12_free(wc); free(phi); return 1; }