@@ -54,6 +54,7 @@ double OrthoFunction::scalar_prod(int n, int m)
5454 return ans;
5555}
5656
57+ // Compute the unnormalized polynomial
5758Eigen::VectorXd OrthoFunction::poly_eval (double t, int n)
5859{
5960 Eigen::VectorXd ret (n+1 );
@@ -68,6 +69,8 @@ Eigen::VectorXd OrthoFunction::poly_eval(double t, int n)
6869 return ret;
6970}
7071
72+ // Compute the orthogonality matrix. A perfect result is the unit
73+ // matrix.
7174Eigen::MatrixXd OrthoFunction::testOrtho ()
7275{
7376 Eigen::MatrixXd ret (nmax+1 , nmax+1 );
@@ -80,10 +83,10 @@ Eigen::MatrixXd OrthoFunction::testOrtho()
8083 double f = dx*lq->weight (i)*d_r_to_x (x)*pow (r, dof-1 );
8184 double y = 2.0 *r/scale; if (segment) y = x;
8285
83- // Evaluate polynomial
86+ // Evaluate the unnormalized polynomial
8487 Eigen::VectorXd p = poly_eval (y, nmax) * W (r);
8588
86- // Compute scalar products
89+ // Compute scalar products with the normalizations
8790 for (int n1=0 ; n1<=nmax; n1++) {
8891 for (int n2=0 ; n2<=nmax; n2++) {
8992 ret (n1, n2) += f * p (n1) * p (n2) / sqrt (norm[n1]*norm[n2]);
@@ -110,7 +113,7 @@ void OrthoFunction::dumpOrtho(const std::string& filename)
110113 double r = x_to_r (x);
111114 double y = 2.0 *r/scale; if (segment) y = x;
112115
113- // Evaluate polynomial
116+ // Evaluate polynomial and apply the normalization
114117 //
115118 Eigen::VectorXd p = poly_eval (y, nmax) * W (r);
116119 fout << std::setw (16 ) << r;
@@ -132,9 +135,11 @@ Eigen::VectorXd OrthoFunction::operator()(double r)
132135 double y = 2.0 *r/scale;
133136 if (segment) y = r_to_x (r);
134137
135- // Generate normalized orthogonal functions
138+ // Generate normalized orthogonal functions with weighting
136139 auto p = poly_eval (y, nmax);
137140 for (int i=0 ; i<=nmax; i++) p (i) *= w/sqrt (norm[i]);
138141
142+ // The inner product of p(i), p(j) is Kronecker delta(i, j)
143+
139144 return p;
140145}
0 commit comments