#include #include #include #include "nr.h" using namespace std; // Driver for routine orthog DP func(const DP x) { return 1.0/SQR(1.0+x); } int main(void) { int i,n; DP amu0,check,xx; // Test with w[x] = -log x for (;;) { cout << "Enter N (or 0 to stop): "; cin >> n; cout << endl; if (n < 1) break; Vec_DP alpha(2*n-1),beta(2*n-1); Vec_DP a(n),b(n),x(n),w(n),anu(2*n); alpha[0]=0.5; beta[0]=1.0; for (i=1;i<2*n-1;i++) { alpha[i]=0.5; beta[i]=1.0/(4.0*(4.0-1.0/(i*i))); } anu[0]=1.0; anu[1] = -0.25; for (i=1;i<2*n-1;i++) anu[i+1] = -anu[i]*(i+1)*i/(2.0*(i+2)*(2*i+1)); NR::orthog(anu,alpha,beta,a,b); amu0=1.0; NR::gaucof(a,b,amu0,x,w); cout << " #" << setw(13) << "x(i)" << setw(15) << "w(i)" << endl; cout << fixed << setprecision(6); for (i=0;i