14 #include"Teuchos_LAPACK.hpp"
18 #ifndef __ORTHOGONAL_POLYNOMIALS__
19 #define __ORTHOGONAL_POLYNOMIALS__
38 void rec_jacobi( ROL::Ptr<Teuchos::LAPACK<int,Real> > lapack,
42 std::vector<Real> &b ) {
45 Real nu = (beta-alpha)/
double(alpha+beta+2.0);
46 Real mu = pow(2.0,alpha+beta+1.0)*tgamma(alpha+1.0)*tgamma(beta+1.0)/tgamma(alpha+beta+2.0);
48 Real sqdif = pow(beta,2)-pow(alpha,2);
55 for(
int n=1;n<N;++n) {
57 a[n] = sqdif/(nab*(nab+2));
60 b[1] = 4.0*(alpha+1.0)*(beta+1.0)/(pow(alpha+beta+2.0,2)*(alpha+beta+3.0));
63 for(
int n=2;n<N;++n) {
65 b[n] = 4.0*(n+alpha)*(n+beta)*n*(n+alpha+beta)/(nab*nab*(nab+1.0)*(nab-1.0));
82 const std::vector<Real> &b,
83 const std::vector<Real> &x,
84 std::vector<Real> &
V) {
85 const int n = a.size();
87 for(
int i=0;i<n;++i) {
93 for(
int j=1;j<n-1;++j) {
94 for(
int i=0;i<n;++i) {
95 V[i+(j+1)*n] = (x[i] - a[j])*V[i+j*n] - b[j]*V[i+(j-1)*n];
113 void gauss( ROL::Ptr<Teuchos::LAPACK<int,Real> > lapack,
114 const std::vector<Real> &a,
115 const std::vector<Real> &b,
116 std::vector<Real> &x,
117 std::vector<Real> &w ) {
119 const int N = a.size();
121 const char COMPZ =
'I';
123 std::vector<Real> D(N,0.0);
124 std::vector<Real> E(N,0.0);
125 std::vector<Real> WORK(4*N,0.0);
128 std::vector<Real> Z(N*N,0);
132 for(
int i=0;i<N-1;++i) {
136 lapack->STEQR(COMPZ,N,&D[0],&E[0],&Z[0],LDZ,&WORK[0],&INFO);
138 for(
int i=0;i<N;++i){
140 w[i] = b[0]*pow(Z[N*i],2);
160 void rec_lobatto( ROL::Ptr<Teuchos::LAPACK<int,Real> >
const lapack,
163 std::vector<Real> &a,
164 std::vector<Real> &b ) {
165 const int N = a.size()-1;
167 std::vector<Real> amod(N,0.0);
168 std::vector<Real> bmod(N-1,0.0);
169 std::vector<Real> en(N,0.0);
170 std::vector<Real> g(N,0.0);
175 for(
int i=0;i<N-1;++i) {
176 bmod[i] = sqrt(b[i+1]);
179 for(
int i=0;i<N;++i) {
183 trisolve(lapack,bmod,amod,bmod,en,g);
186 for(
int i=0;i<N;++i) {
190 trisolve(lapack,bmod,amod,bmod,en,g);
193 a[N] = (g1*xl2-g2*xl1)/(g1-g2);
194 b[N] = (xl2-xl1)/(g1-g2);
void rec_lobatto(ROL::Ptr< Teuchos::LAPACK< int, Real > > const lapack, const double xl1, const double xl2, std::vector< Real > &a, std::vector< Real > &b)
Modify the given recurrence coefficients so that the set of zeros of the maximal order polynomial inc...
void vandermonde(const std::vector< Real > &a, const std::vector< Real > &b, const std::vector< Real > &x, std::vector< Real > &V)
Construct the generalized Vandermonde matrix (in column stacked form) based upon the recurrence coeff...
void trisolve(ROL::Ptr< Teuchos::LAPACK< int, Real > > lapack, const std::vector< Real > &a, const std::vector< Real > &b, const std::vector< Real > &c, const std::vector< Real > &r, std::vector< Real > &x)
Solve a tridiagonal system.
void gauss(ROL::Ptr< Teuchos::LAPACK< int, Real > > lapack, const std::vector< Real > &a, const std::vector< Real > &b, std::vector< Real > &x, std::vector< Real > &w)
Compute the Gauss quadrature nodes and weights for the polynomials generated by the recurrence coeffi...
void rec_jacobi(ROL::Ptr< Teuchos::LAPACK< int, Real > > lapack, const double alpha, const double beta, std::vector< Real > &a, std::vector< Real > &b)
Generate the Jacobi polynomial recursion coeffcients .