/* prog5a.c -- Solve Least Squares Problem by QR Factorization Written Mar 30, 2001 by Eric Olson for Mathematics 483 For more information see Step 27 in First Steps in Numerical Analysis, 2nd Edition, by Hosking, Joe, Joyce and Turner. */ #include #include #define N 200 #define m 4 static int n; static double At[m][N],C[m],Y[N]; double phi(double x,int i){ switch(i){ case 0: return 1; break; case 1: return x; break; case 2: return x*x; break; case 3: return x*x*x; break; default: printf("Unknown basis function number %d!\n",i); exit(1); } } writeC(){ int i; printf("C=[ "); for(i=0;i0) s=-s; s+=s; { double t=sqrt(0.5-At[l][l]/s); int j; w[l]=t; t*=-s; for(j=l+1;j=0;l--){ double s=0.0; int k; for(k=l+1;kN){ printf("Capacity of %d data points exceeded!\n",N); exit(2); } printf("Reading %d data points:\n",n); for(j=0;j