aboutsummaryrefslogtreecommitdiff
path: root/src/mtx_sh/cmdline/chebyshev12_cmd.c
diff options
context:
space:
mode:
authorFranz Zotter <fzotter@users.sourceforge.net>2009-01-12 17:09:13 +0000
committerFranz Zotter <fzotter@users.sourceforge.net>2009-01-12 17:09:13 +0000
commit55253e4e15b093a0826fc10b376f7724cea2ba7e (patch)
tree1e1c06129db9f86a12daddcf7c985d530d0872d9 /src/mtx_sh/cmdline/chebyshev12_cmd.c
parentbacae787abd380690126e6adf82ab0cd19f5abec (diff)
added [mtx_sh] for spherical harmonics evaluation.
svn path=/trunk/externals/iem/iemmatrix/; revision=10515
Diffstat (limited to 'src/mtx_sh/cmdline/chebyshev12_cmd.c')
-rw-r--r--src/mtx_sh/cmdline/chebyshev12_cmd.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mtx_sh/cmdline/chebyshev12_cmd.c b/src/mtx_sh/cmdline/chebyshev12_cmd.c
new file mode 100644
index 0000000..07f0305
--- /dev/null
+++ b/src/mtx_sh/cmdline/chebyshev12_cmd.c
@@ -0,0 +1,46 @@
+
+/* command line test for chebyshev12.c
+ * Franz Zotter, 2009, see ../LICENSE.txt */
+
+#include <stdio.h>
+
+#include "chebyshev12.h"
+
+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;
+}
+
+