/* legendre.c */ /************************************************************ * * * Permission is hereby granted to any individual or * * institution for use, copying, or redistribution of * * the xgobi code and associated documentation, provided * * that such code and documentation are not sold for * * profit and the following copyright notice is retained * * in the code and documentation: * * Copyright (c) 1990, ..., 1996 Bellcore * * * * We welcome your questions and comments, and request * * that you share any modifications with us. * * * * Deborah F. Swayne Dianne Cook * * dfs@research.att.com dicook@iastate.edu * * (973) 360-8423 www.public.iastate.edu/~dicook/ * * * * Andreas Buja * * andreas@research.att.com * * www.research.att.com/~andreas/ * * * ************************************************************/ #include #include "xincludes.h" #include "xgobitypes.h" #include "xgobivars.h" #include "xgobiexterns.h" #define SQRT2PI 2.5066282746310007 static float **P0, **P1, **Rp, **Pp0, **Pp1; static float **acoefs; /* This index is discussed in "Exploratory Projection Pursuit" by * Jerome H. Friedman, JASA 1987 */ void alloc_legendre(int n, int maxlJ) { int i; P0 = (float **) XtMalloc( (unsigned int) maxlJ*sizeof(float *)); for (i=0; i= 0.) tmpf2 = (1. + erf(tmpf1)) / 2.; else tmpf2 = erfc(fabs(tmpf1)) / 2.; Rp[0][k] = tmpf2*2. - 1.; tmpf1 = proj_data[1][k]; tmpf1 /= (sqrt((double) 2.)); if (tmpf1 >= 0.) tmpf2 = (1. + erf(tmpf1)) / 2.; else tmpf2 = erfc(fabs(tmpf1)) / 2.; Rp[1][k] = tmpf2*2. - 1.; } /* calculate P's */ for (i=0; i 1) { for (i=0; i 1) { for (i=0; i