Nektar++
Polylib.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: Polylib.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description:
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef H_PLYLIB
36
39#include <complex>
40
41/*
42 * LIBRARY ROUTINES FOR POLYNOMIAL CALCULUS AND INTERPOLATION
43 */
44
45/** \brief The namespace associated with the the Polylib library
46 * (\ref pagePolylib "Polylib introduction")
47 */
48namespace Polylib
49{
50
51/**
52 \page pagePolylib The Polylib library
53 \section sectionPolyLib Routines For Orthogonal Polynomial Calculus and
54 Interpolation
55
56 Spencer Sherwin,
57 Aeronautics, Imperial College London
58
59 Based on codes by Einar Ronquist and Ron Henderson
60
61 Abbreviations
62 - z - Set of collocation/quadrature points
63 - w - Set of quadrature weights
64 - D - Derivative matrix
65 - h - Lagrange Interpolant
66 - I - Interpolation matrix
67 - g - Gauss
68 - k - Kronrod
69 - gr - Gauss-Radau
70 - gl - Gauss-Lobatto
71 - j - Jacobi
72 - m - point at minus 1 in Radau rules
73 - p - point at plus 1 in Radau rules
74
75 -----------------------------------------------------------------------\n
76 MAIN ROUTINES\n
77 -----------------------------------------------------------------------\n
78
79 Points and Weights:
80
81 - zwgj Compute Gauss-Jacobi points and weights
82 - zwgrjm Compute Gauss-Radau-Jacobi points and weights (z=-1)
83 - zwgrjp Compute Gauss-Radau-Jacobi points and weights (z= 1)
84 - zwglj Compute Gauss-Lobatto-Jacobi points and weights
85 - zwgk Compute Gauss-Kronrod-Jacobi points and weights
86 - zwrk Compute Radau-Kronrod points and weights
87 - zwlk Compute Lobatto-Kronrod points and weights
88 - JacZeros Compute Gauss-Jacobi points and weights
89
90 Integration Matrices:
91
92 - Qg Compute Gauss integration matrix
93
94 Derivative Matrices:
95
96 - Dgj Compute Gauss-Jacobi derivative matrix
97 - Dgrjm Compute Gauss-Radau-Jacobi derivative matrix (z=-1)
98 - Dgrjp Compute Gauss-Radau-Jacobi derivative matrix (z= 1)
99 - Dglj Compute Gauss-Lobatto-Jacobi derivative matrix
100
101 Lagrange Interpolants:
102
103 - hgj Compute Gauss-Jacobi Lagrange interpolants
104 - hgrjm Compute Gauss-Radau-Jacobi Lagrange interpolants (z=-1)
105 - hgrjp Compute Gauss-Radau-Jacobi Lagrange interpolants (z= 1)
106 - hglj Compute Gauss-Lobatto-Jacobi Lagrange interpolants
107
108 Interpolation Operators:
109
110 - Imgj Compute interpolation operator gj->m
111 - Imgrjm Compute interpolation operator grj->m (z=-1)
112 - Imgrjp Compute interpolation operator grj->m (z= 1)
113 - Imglj Compute interpolation operator glj->m
114
115 Polynomial Evaluation:
116
117 - polycoeff Returns value and derivative of Jacobi poly.
118 - jacobfd Returns value and derivative of Jacobi poly. at point z
119 - jacobd Returns derivative of Jacobi poly. at point z (valid at z=-1,1)
120
121 -----------------------------------------------------------------------\n
122 LOCAL ROUTINES\n
123 -----------------------------------------------------------------------\n
124
125 - jacobz Returns Jacobi polynomial zeros
126 - gammaf Gamma function for integer values and halves
127 - RecCoeff Calculates the recurrence coefficients for orthogonal poly
128 - TriQL QL algorithm for symmetrix tridiagonal matrix
129 - JKMatrix Generates the Jacobi-Kronrod matrix
130
131 ------------------------------------------------------------------------\n
132
133 Useful references:
134
135 - [1] Gabor Szego: Orthogonal Polynomials, American Mathematical Society,
136 Providence, Rhode Island, 1939.
137 - [2] Abramowitz \& Stegun: Handbook of Mathematical Functions,
138 Dover, New York, 1972.
139 - [3] Canuto, Hussaini, Quarteroni \& Zang: Spectral Methods in Fluid
140 Dynamics, Springer-Verlag, 1988.
141 - [4] Ghizzetti \& Ossicini: Quadrature Formulae, Academic Press, 1970.
142 - [5] Karniadakis \& Sherwin: Spectral/hp element methods for CFD, 1999
143
144
145 NOTES
146
147 -# Legendre polynomial \f$ \alpha = \beta = 0 \f$
148 -# Chebychev polynomial \f$ \alpha = \beta = -0.5 \f$
149 -# All routines are double precision.
150 -# All array subscripts start from zero, i.e. vector[0..N-1]
151*/
152
153/*-----------------------------------------------------------------------
154 M A I N R O U T I N E S
155 -----------------------------------------------------------------------*/
156
157/* Points and weights */
158LIB_UTILITIES_EXPORT void zwgj(double *, double *, const int, const double,
159 const double);
160LIB_UTILITIES_EXPORT void zwgrjm(double *, double *, const int, const double,
161 const double);
162LIB_UTILITIES_EXPORT void zwgrjp(double *, double *, const int, const double,
163 const double);
164LIB_UTILITIES_EXPORT void zwglj(double *, double *, const int, const double,
165 const double);
166LIB_UTILITIES_EXPORT void zwgk(double *, double *, const int, const double,
167 const double);
168LIB_UTILITIES_EXPORT void zwrk(double *, double *, const int, const double,
169 const double);
170LIB_UTILITIES_EXPORT void zwlk(double *, double *, const int, const double,
171 const double);
172LIB_UTILITIES_EXPORT void JacZeros(const int, double *, double *, const double,
173 const double);
174
175/* Integration operators */
176LIB_UTILITIES_EXPORT void Qg(double *, const double *, const int);
177
178/* Derivative operators */
179LIB_UTILITIES_EXPORT void Dgj(double *, const double *, const int, const double,
180 const double);
181LIB_UTILITIES_EXPORT void Dgrjm(double *, const double *, const int,
182 const double, const double);
183LIB_UTILITIES_EXPORT void Dgrjp(double *, const double *, const int,
184 const double, const double);
185LIB_UTILITIES_EXPORT void Dglj(double *, const double *, const int,
186 const double, const double);
187
188/* Lagrangian interpolants */
189LIB_UTILITIES_EXPORT double laginterp(double, int, const double *, int);
190LIB_UTILITIES_EXPORT double laginterpderiv(double, int, const double *, int);
191LIB_UTILITIES_EXPORT double hgj(const int, const double, const double *,
192 const int, const double, const double);
193LIB_UTILITIES_EXPORT double hgrjm(const int, const double, const double *,
194 const int, const double, const double);
195LIB_UTILITIES_EXPORT double hgrjp(const int, const double, const double *,
196 const int, const double, const double);
197LIB_UTILITIES_EXPORT double hglj(const int, const double, const double *,
198 const int, const double, const double);
199
200/* Interpolation operators */
201LIB_UTILITIES_EXPORT void Imgj(double *, const double *, const double *,
202 const int, const int, const double,
203 const double);
204LIB_UTILITIES_EXPORT void Imgrjm(double *, const double *, const double *,
205 const int, const int, const double,
206 const double);
207LIB_UTILITIES_EXPORT void Imgrjp(double *, const double *, const double *,
208 const int, const int, const double,
209 const double);
210LIB_UTILITIES_EXPORT void Imglj(double *, const double *, const double *,
211 const int, const int, const double,
212 const double);
213
214/* Polynomial functions */
215LIB_UTILITIES_EXPORT void polycoeffs(double *, const double *, const int,
216 const int);
217LIB_UTILITIES_EXPORT void jacobfd(const int, const double *, double *, double *,
218 const int, const double, const double);
219LIB_UTILITIES_EXPORT void jacobd(const int, const double *, double *, const int,
220 const double, const double);
221
222/* Gamma function routines */
223LIB_UTILITIES_EXPORT double gammaF(const double);
224LIB_UTILITIES_EXPORT double gammaFracGammaF(const int, const double, const int,
225 const double);
226
227/* Bessel function routines */
228LIB_UTILITIES_EXPORT std::complex<Nektar::NekDouble> ImagBesselComp(
229 const int, std::complex<Nektar::NekDouble>);
230
231} // namespace Polylib
232
233#define H_PLYLIB
234#endif /* END OF POLYLIB.H DECLARATIONS */
#define LIB_UTILITIES_EXPORT
The namespace associated with the the Polylib library (Polylib introduction)
Definition: Polylib.cpp:50
double laginterpderiv(double z, int k, const double *zj, int np)
Definition: Polylib.cpp:98
double gammaF(const double x)
Calculate the Gamma function , , for integer values and halves.
Definition: Polylib.cpp:1413
void Dgj(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Jacobi zeros.
Definition: Polylib.cpp:653
void zwgrjm(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=-1.
Definition: Polylib.cpp:182
void JacZeros(const int n, double *a, double *b, const double alpha, const double beta)
Zero and Weight determination through the eigenvalues and eigenvectors of a tridiagonal matrix from t...
Definition: Polylib.cpp:1665
void zwgrjp(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=1.
Definition: Polylib.cpp:225
double laginterp(double z, int j, const double *zj, int np)
Definition: Polylib.cpp:85
void Dglj(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix associated with the Gauss-Lobatto-Jacobi zeros.
Definition: Polylib.cpp:833
void Imgrjp(double *im, const double *zgrj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=1) to an arbitrary distrubtion at ...
Definition: Polylib.cpp:1116
void zwglj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Lobatto-Jacobi zeros and weights with end point at z=-1,1.
Definition: Polylib.cpp:266
void zwgj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Jacobi zeros and weights.
Definition: Polylib.cpp:152
void Imgj(double *im, const double *zgj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Jacobi points to an arbitrary distribution at points zm.
Definition: Polylib.cpp:1054
double hgrjm(const int i, const double z, const double *zgrj, const int np, const double alpha, const double beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Radau-Jacobi points zgrj at...
Definition: Polylib.cpp:951
void Qg(double *Q, const double *z, const int np)
Compute the Integration Matrix.
Definition: Polylib.cpp:611
double gammaFracGammaF(const int x, const double alpha, const int y, const double beta)
Calculate fraction of two Gamma functions, , for integer values and halves.
Definition: Polylib.cpp:1468
void polycoeffs(double *c, const double *z, const int i, const int np)
Compute the coefficients of Lagrange interpolation polynomials.
Definition: Polylib.cpp:1170
double hgj(const int i, const double z, const double *zgj, const int np, const double alpha, const double beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Jacobi points zgj at the ar...
Definition: Polylib.cpp:914
void Imgrjm(double *im, const double *zgrj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=-1) to an arbitrary distrubtion at...
Definition: Polylib.cpp:1085
void zwgk(double *z, double *w, const int npt, const double alpha, const double beta)
Gauss-Kronrod-Jacobi zeros and weights.
Definition: Polylib.cpp:317
void Dgrjm(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Radau-Jacobi zeros with a z...
Definition: Polylib.cpp:704
std::complex< Nektar::NekDouble > ImagBesselComp(int n, std::complex< Nektar::NekDouble > y)
Calcualte the bessel function of the first kind with complex double input y. Taken from Numerical Rec...
Definition: Polylib.cpp:1559
void Dgrjp(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix associated with the Gauss-Radau-Jacobi zeros with a zero at z=1.
Definition: Polylib.cpp:768
double hgrjp(const int i, const double z, const double *zgrj, const int np, const double alpha, const double beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Radau-Jacobi points zgrj at...
Definition: Polylib.cpp:988
void zwrk(double *z, double *w, const int npt, const double alpha, const double beta)
Gauss-Radau-Kronrod-Jacobi zeros and weights.
Definition: Polylib.cpp:389
double hglj(const int i, const double z, const double *zglj, const int np, const double alpha, const double beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Lobatto-Jacobi points zgrj ...
Definition: Polylib.cpp:1025
void Imglj(double *im, const double *zglj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Lobatto-Jacobi points to an arbitrary distrubtion at points zm.
Definition: Polylib.cpp:1147
void jacobd(const int np, const double *z, double *polyd, const int n, const double alpha, const double beta)
Calculate the derivative of Jacobi polynomials.
Definition: Polylib.cpp:1378
void jacobfd(const int np, const double *z, double *poly_in, double *polyd, const int n, const double alpha, const double beta)
Routine to calculate Jacobi polynomials, , and their first derivative, .
Definition: Polylib.cpp:1248
void zwlk(double *z, double *w, const int npt, const double alpha, const double beta)
Gauss-Lobatto-Kronrod-Jacobi zeros and weights.
Definition: Polylib.cpp:495