public GaussianQuadrature(int n, GaussianOrthogonalPolynomial orthPoly) { x_ = new Vector(n); w_ = new Vector(n); // set-up matrix to compute the roots and the weights Vector e = new Vector(n-1); int i; for (i=1; i < n; ++i) { x_[i] = orthPoly.alpha(i); e[i-1] = Math.Sqrt(orthPoly.beta(i)); } x_[0] = orthPoly.alpha(0); TqrEigenDecomposition tqr = new TqrEigenDecomposition( x_, e, TqrEigenDecomposition.EigenVectorCalculation.OnlyFirstRowEigenVector, TqrEigenDecomposition.ShiftStrategy.Overrelaxation); x_ = tqr.eigenvalues(); Matrix ev = tqr.eigenvectors(); double mu_0 = orthPoly.mu_0(); for (i=0; i<n; ++i) { w_[i] = mu_0*ev[0,i]*ev[0,i] / orthPoly.w(x_[i]); } }
public GaussianQuadrature(int n, GaussianOrthogonalPolynomial orthPoly) { x_ = new Vector(n); w_ = new Vector(n); // set-up matrix to compute the roots and the weights Vector e = new Vector(n - 1); int i; for (i = 1; i < n; ++i) { x_[i] = orthPoly.alpha(i); e[i - 1] = Math.Sqrt(orthPoly.beta(i)); } x_[0] = orthPoly.alpha(0); TqrEigenDecomposition tqr = new TqrEigenDecomposition(x_, e, TqrEigenDecomposition.EigenVectorCalculation.OnlyFirstRowEigenVector, TqrEigenDecomposition.ShiftStrategy.Overrelaxation); x_ = tqr.eigenvalues(); Matrix ev = tqr.eigenvectors(); double mu_0 = orthPoly.mu_0(); for (i = 0; i < n; ++i) { w_[i] = mu_0 * ev[0, i] * ev[0, i] / orthPoly.w(x_[i]); } }