98 #define INTREPID_POLYLIB_STOP 50
101 #define INTREPID_POLYLIB_POLYNOMIAL_DEFLATION 0
103 #ifdef INTREPID_POLYLIB_POLYNOMIAL_DEFLATION
104 #define jacobz(n,z,alpha,beta) Jacobz(n,z,alpha,beta)
107 #define jacobz(n,z,alpha,beta) JacZeros(n,z,alpha,beta)
112 template <
class Scalar>
115 Scalar fac, one = 1.0, two = 2.0, apb = alpha + beta;
123 for(i = 0; i < np; ++i) w[i] = fac/(w[i]*w[i]*(one-z[i]*z[i]));
129 template <
class Scalar>
138 Scalar fac, one = 1.0, two = 2.0, apb = alpha + beta;
147 for(i = 0; i < np; ++i) w[i] = fac*(1-z[i])/(w[i]*w[i]);
148 w[0] *= (beta + one);
155 template <
class Scalar>
164 Scalar fac, one = 1.0, two = 2.0, apb = alpha + beta;
173 for(i = 0; i < np; ++i) w[i] = fac*(1+z[i])/(w[i]*w[i]);
174 w[np-1] *= (alpha + one);
181 template <
class Scalar>
190 Scalar fac, one = 1.0, apb = alpha + beta, two = 2.0;
200 for(i = 0; i < np; ++i) w[i] = fac/(w[i]*w[i]);
201 w[0] *= (beta + one);
202 w[np-1] *= (alpha + one);
209 template <
class Scalar>
213 Scalar one = 1.0, two = 2.0;
222 pd = (Scalar *)malloc(np*
sizeof(Scalar));
225 for (i = 0; i < np; i++){
226 for (j = 0; j < np; j++){
230 D[i*np+j] = pd[i]/(pd[j]*(z[i]-z[j]));
232 D[i*np+j] = (alpha - beta + (alpha + beta + two)*z[j])/
233 (two*(one - z[j]*z[j]));
242 template <
class Scalar>
251 Scalar one = 1.0, two = 2.0;
254 pd = (Scalar *)malloc(np*
sizeof(Scalar));
259 for(i = 1; i < np; ++i) pd[i] *= (1+z[i]);
261 for (i = 0; i < np; i++) {
262 for (j = 0; j < np; j++){
265 D[i*np+j] = pd[i]/(pd[j]*(z[i]-z[j]));
268 D[i*np+j] = -(np + alpha + beta + one)*(np - one)/
271 D[i*np+j] = (alpha - beta + one + (alpha + beta + one)*z[j])/
272 (two*(one - z[j]*z[j]));
282 template <
class Scalar>
291 Scalar one = 1.0, two = 2.0;
294 pd = (Scalar *)malloc(np*
sizeof(Scalar));
298 for(i = 0; i < np-1; ++i) pd[i] *= (1-z[i]);
302 for (i = 0; i < np; i++) {
303 for (j = 0; j < np; j++){
306 D[i*np+j] = pd[i]/(pd[j]*(z[i]-z[j]));
309 D[i*np+j] = (np + alpha + beta + one)*(np - one)/
312 D[i*np+j] = (alpha - beta - one + (alpha + beta + one)*z[j])/
313 (two*(one - z[j]*z[j]));
323 template <
class Scalar>
332 Scalar one = 1.0, two = 2.0;
335 pd = (Scalar *)malloc(np*
sizeof(Scalar));
340 for(i = 1; i < np-1; ++i) pd[i] *= (one-z[i]*z[i]);
344 for (i = 0; i < np; i++) {
345 for (j = 0; j < np; j++){
348 D[i*np+j] = pd[i]/(pd[j]*(z[i]-z[j]));
351 D[i*np+j] = (alpha - (np-1)*(np + alpha + beta))/(two*(beta+ two));
353 D[i*np+j] =-(beta - (np-1)*(np + alpha + beta))/(two*(alpha+ two));
355 D[i*np+j] = (alpha - beta + (alpha + beta)*z[j])/
356 (two*(one - z[j]*z[j]));
366 template <
class Scalar>
368 const int np,
const Scalar alpha,
const Scalar beta)
371 Scalar zi, dz, p, pd, h;
375 if (std::abs(dz) < INTREPID_TOL)
return 1.0;
385 template <
class Scalar>
387 const int np,
const Scalar alpha,
const Scalar beta)
390 Scalar zi, dz, p, pd, h;
394 if (std::abs(dz) < INTREPID_TOL)
return 1.0;
399 h = (1.0 + zi)*pd + p;
401 h = (1.0 + z )*p/(h*dz);
407 template <
class Scalar>
409 const int np,
const Scalar alpha,
const Scalar beta)
412 Scalar zi, dz, p, pd, h;
416 if (std::abs(dz) < INTREPID_TOL)
return 1.0;
421 h = (1.0 - zi)*pd - p;
423 h = (1.0 - z )*p/(h*dz);
429 template <
class Scalar>
431 const int np,
const Scalar alpha,
const Scalar beta)
433 Scalar one = 1., two = 2.;
434 Scalar zi, dz, p, pd, h;
438 if (std::abs(dz) < INTREPID_TOL)
return 1.0;
443 h = (one - zi*zi)*pd - two*zi*p;
445 h = (one - z*z)*p/(h*dz);
451 template <
class Scalar>
453 const int mz,
const Scalar alpha,
const Scalar beta){
458 for (i = 0; i < mz; ++i) {
460 for (j = 0; j < nz; ++j) {
479 template <
class Scalar>
481 const int mz,
const Scalar alpha,
const Scalar beta)
486 for (i = 0; i < mz; i++) {
488 for (j = 0; j < nz; j++) {
507 template <
class Scalar>
509 const int mz,
const Scalar alpha,
const Scalar beta)
514 for (i = 0; i < mz; i++) {
516 for (j = 0; j < nz; j++) {
535 template <
class Scalar>
537 const int mz,
const Scalar alpha,
const Scalar beta)
542 for (i = 0; i < mz; i++) {
544 for (j = 0; j < nz; j++) {
563 template <
class Scalar>
566 jacobfd (
const int np,
const Scalar *z, Scalar *poly_in, Scalar *polyd,
567 const int n,
const Scalar alpha,
const Scalar beta)
569 const Scalar zero = 0.0, one = 1.0, two = 2.0;
577 for (
int i = 0; i < np; ++i) {
582 for (
int i = 0; i < np; ++i) {
589 for (
int i = 0; i < np; ++i) {
590 poly_in[i] = 0.5*(alpha - beta + (alpha + beta + two)*z[i]);
594 for (
int i = 0; i < np; ++i) {
595 polyd[i] = 0.5*(alpha + beta + two);
601 Scalar apb = alpha + beta;
602 Scalar *poly, *polyn1,*polyn2;
605 polyn1 = (Scalar *)malloc(2*np*
sizeof(Scalar));
610 polyn1 = (Scalar *)malloc(3*np*
sizeof(Scalar));
615 for (
int i = 0; i < np; ++i) {
617 polyn1[i] = 0.5*(alpha - beta + (alpha + beta + two)*z[i]);
620 for (
int k = 2; k <= n; ++k) {
621 a1 = two*k*(k + apb)*(two*k + apb - two);
622 a2 = (two*k + apb - one)*(alpha*alpha - beta*beta);
623 a3 = (two*k + apb - two)*(two*k + apb - one)*(two*k + apb);
624 a4 = two*(k + alpha - one)*(k + beta - one)*(two*k + apb);
630 for (
int i = 0; i < np; ++i) {
631 poly [i] = (a2 + a3*z[i])*polyn1[i] - a4*polyn2[i];
632 polyn2[i] = polyn1[i];
633 polyn1[i] = poly [i];
638 a1 = n*(alpha - beta);
639 a2 = n*(two*n + alpha + beta);
640 a3 = two*(n + alpha)*(n + beta);
641 a4 = (two*n + alpha + beta);
642 a1 /= a4; a2 /= a4; a3 /= a4;
645 for (
int i = 0; i < np; ++i) {
646 polyd[i] = (a1- a2*z[i])*poly[i] + a3*polyn2[i];
647 polyd[i] /= (one - z[i]*z[i]);
656 template <
class Scalar>
658 const Scalar alpha,
const Scalar beta)
663 for(i = 0; i < np; ++i) polyd[i] = 0.0;
667 for(i = 0; i < np; ++i) polyd[i] *= 0.5*(alpha + beta + (Scalar)n + one);
673 template <
class Scalar>
676 Scalar dth = M_PI/(2.0*(Scalar)n);
677 Scalar poly,pder,rlast=0.0;
679 Scalar one = 1.0, two = 2.0;
684 for(k = 0; k < n; ++k){
685 r = -std::cos((two*(Scalar)k + one) * dth);
686 if(k) r = 0.5*(r + rlast);
691 for(i = 0, sum = 0.0; i < k; ++i) sum += one/(r - z[i]);
693 delr = -poly / (pder - sum * poly);
695 if( std::abs(delr) < INTREPID_TOL )
break;
704 template <
class Scalar>
707 Scalar apb, apbi,a2b2;
713 b = (Scalar *) malloc(n*
sizeof(Scalar));
720 a[0] = (beta-alpha)/apbi;
721 b[0] = std::sqrt(4.0*(1.0+alpha)*(1.0+beta)/((apbi+1.0)*apbi*apbi));
723 a2b2 = beta*beta-alpha*alpha;
724 for(i = 1; i < n-1; ++i){
725 apbi = 2.0*(i+1) + apb;
726 a[i] = a2b2/((apbi-2.0)*apbi);
727 b[i] = std::sqrt(4.0*(i+1)*(i+1+alpha)*(i+1+beta)*(i+1+apb)/
728 ((apbi*apbi-1)*apbi*apbi));
733 if (n>1) a[n-1] = a2b2/((apbi-2.0)*apbi);
743 template <
class Scalar>
746 Scalar s,r,p,g,f,dd,c,b;
751 for (m=l;m<n-1;m++) {
752 dd=std::abs(d[m])+std::abs(d[m+1]);
753 if (std::abs(e[m])+dd == dd)
break;
757 TEUCHOS_TEST_FOR_EXCEPTION((1),
759 ">>> ERROR (IntrepidPolylib): Too many iterations in TQLI.");
761 g=(d[l+1]-d[l])/(2.0*e[l]);
762 r=std::sqrt((g*g)+1.0);
764 g=d[m]-d[l]+e[l]/(g+((g)<0 ? -std::abs(r) : std::abs(r)));
767 for (i=m-1;i>=l;i--) {
770 if (std::abs(f) >= std::abs(g)) {
772 r=std::sqrt((c*c)+1.0);
777 r=std::sqrt((s*s)+1.0);
782 r=(d[i]-g)*s+2.0*c*b;
795 for(i = 0; i < n-1; ++i){
798 for(l = i+1; l < n; ++l)
809 template <
class Scalar>
813 if (x == -0.5) gamma = -2.0*std::sqrt(M_PI);
814 else if (!x)
return gamma;
815 else if ((x-(
int)x) == 0.5){
819 gamma = std::sqrt(M_PI);
825 else if ((x-(
int)x) == 0.0){
835 TEUCHOS_TEST_FOR_EXCEPTION((1),
836 std::invalid_argument,
837 ">>> ERROR (IntrepidPolylib): Argument is not of integer or half order.");
844 #if defined(Intrepid_SHOW_DEPRECATED_WARNINGS)
846 #warning "The Intrepid package is deprecated"
static void Dgrjm(Scalar *D, const Scalar *z, const int np, const Scalar alpha, const Scalar beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Radau-Jacobi zeros with a z...
static void Imgj(Scalar *im, const Scalar *zgj, const Scalar *zm, const int nz, const int mz, const Scalar alpha, const Scalar beta)
Interpolation Operator from Gauss-Jacobi points to an arbitrary distribution at points zm...
static Scalar hgrjp(const int i, const Scalar z, const Scalar *zgrj, const int np, const Scalar alpha, const Scalar beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Radau-Jacobi points zgrj at...
static void zwgrjp(Scalar *z, Scalar *w, const int np, const Scalar alpha, const Scalar beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=1.
static void TriQL(const int n, Scalar *d, Scalar *e)
QL algorithm for symmetric tridiagonal matrix.
#define INTREPID_POLYLIB_STOP
Maximum number of iterations in polynomial defalation routine Jacobz.
static Scalar hglj(const int i, const Scalar z, const Scalar *zglj, const int np, const Scalar alpha, const Scalar beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Lobatto-Jacobi points zglj ...
static void zwglj(Scalar *z, Scalar *w, const int np, const Scalar alpha, const Scalar beta)
Gauss-Lobatto-Jacobi zeros and weights with end point at z=-1,1.
static Scalar hgj(const int i, const Scalar z, const Scalar *zgj, const int np, const Scalar alpha, const Scalar beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Jacobi points zgj at the ar...
static void zwgrjm(Scalar *z, Scalar *w, const int np, const Scalar alpha, const Scalar beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=-1.
static Scalar hgrjm(const int i, const Scalar z, const Scalar *zgrj, const int np, const Scalar alpha, const Scalar beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Radau-Jacobi points zgrj at...
static void JacZeros(const int n, Scalar *a, const Scalar alpha, const Scalar beta)
Zero determination through the eigenvalues of a tridiagonal matrix from the three term recursion rela...
static void jacobd(const int np, const Scalar *z, Scalar *polyd, const int n, const Scalar alpha, const Scalar beta)
Calculate the derivative of Jacobi polynomials.
static void Dgrjp(Scalar *D, const Scalar *z, const int np, const Scalar alpha, const Scalar beta)
Compute the Derivative Matrix associated with the Gauss-Radau-Jacobi zeros with a zero at z=1...
static void Imgrjm(Scalar *im, const Scalar *zgrj, const Scalar *zm, const int nz, const int mz, const Scalar alpha, const Scalar beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=-1) to an arbitrary distrubtion at...
static void jacobfd(const int np, const Scalar *z, Scalar *poly_in, Scalar *polyd, const int n, const Scalar alpha, const Scalar beta)
Routine to calculate Jacobi polynomials, , and their first derivative, .
static void Jacobz(const int n, Scalar *z, const Scalar alpha, const Scalar beta)
Calculate the n zeros, z, of the Jacobi polynomial, i.e. .
static void Dgj(Scalar *D, const Scalar *z, const int np, const Scalar alpha, const Scalar beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Jacobi zeros.
static void Dglj(Scalar *D, const Scalar *z, const int np, const Scalar alpha, const Scalar beta)
Compute the Derivative Matrix associated with the Gauss-Lobatto-Jacobi zeros.
static void zwgj(Scalar *z, Scalar *w, const int np, const Scalar alpha, const Scalar beta)
Gauss-Jacobi zeros and weights.
static void Imglj(Scalar *im, const Scalar *zglj, const Scalar *zm, const int nz, const int mz, const Scalar alpha, const Scalar beta)
Interpolation Operator from Gauss-Lobatto-Jacobi points to an arbitrary distrubtion at points zm...
static Scalar gammaF(const Scalar x)
Calculate the Gamma function , , for integer values x and halves.
#define jacobz(n, z, alpha, beta)
zero determination using Newton iteration with polynomial deflation
static void Imgrjp(Scalar *im, const Scalar *zgrj, const Scalar *zm, const int nz, const int mz, const Scalar alpha, const Scalar beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=1) to an arbitrary distrubtion at ...