pg_utils.numerics.matrices.InnerQuad_GaussJacobi

class pg_utils.numerics.matrices.InnerQuad_GaussJacobi(inner_prod: InnerProduct1D, automatic: bool = False, alpha: Expr = - 1 / 2, beta: Expr = - 1 / 2, quadN: Optional[Expr] = None)[source]

Bases: InnerQuad_Rule

Quadrature of inner product following Gauss-Jacobi quadrature

Parameters:
  • inner_prod (expansion.InnerProduct1D) – inner prod to be evaluated

  • int_var (sympy.Symbol) – integration variable

  • deduce (bool) – whether to automatically deduce the indices

  • alpha (sympy.Expr) – alpha idx of Jacobi quadrature

  • beta (sympy.Expr) – beta idx of Jacobi quadrature

  • powerN (sympy.Expr) – total degree to be integrated

__init__(inner_prod: InnerProduct1D, automatic: bool = False, alpha: Expr = - 1 / 2, beta: Expr = - 1 / 2, quadN: Optional[Expr] = None) None[source]

Initialization

Parameters:
  • inner_prod (expansion.InnerProduct1D) – inner prod to be evaluated

  • automatic (bool) – whether to automatically deduce the orders of Jacobi quadrature and the degree of polynomial to be integrated

  • alpha (sympy.Expr) – alpha index of Jacobi quadrature. Ignored when automatic is True, default to Chebyshev alpha = -1/2 when automatic deduction is turned off.

  • beta (sympy.Expr) – beta index of Jacobi quadrature. Ignored when automatic is True, default to Chebyshev beta = -1/2 when automatic deduction is turned off.

  • quadN (int or sympy.Expr) – no. of quadrature points. Ignored when automatic deduction is True and the quantity not explicitly given, default to n_test + n_trial when automatic deduction turned off. When a valid quadN is given, the input will always be used.

Methods

__init__(inner_prod[, automatic, alpha, ...])

Initialization

deduce_params(Ntrial, Ntest)

Determine the parameters of the quadrature

deduce_params_outer(Ntrial, Ntest)

Determine the parameters of the quadrature

get_powers(int_var, expr, **kwargs)

Get the powers of p1=(1 - xi), p2=(1 + xi) and xi

gramian(nrange_trial, nrange_test[, ...])

Compute Gram matrix, concrete realization for Gauss Jacobi quadrature

output_form(M_in[, output])

Cast output matrix to desired form and data types

deduce_params(Ntrial: int, Ntest: int)[source]

Determine the parameters of the quadrature

This method is called to determine the values of the parameters during evaluation of Gram matrices as integration of the full integrand.

Parameters:
  • Ntrial (int) – maximum value for n_trial

  • Ntest (int) – maximum value for n_test we assume that the maximum degree of the function to be integrated will be reached at maximum n_trial and n_test

Returns:

alpha, beta, quadN

deduce_params_outer(Ntrial: int, Ntest: int)[source]

Determine the parameters of the quadrature

This method is called to determine the values of the parameters during evaluation of Gram matrices as integration of outer products.

Parameters:
  • Ntrial (int) – maximum value for n_trial

  • Ntest (int) – maximum value for n_test we assume that the maximum degree of the function to be integrated will be reached at maximum n_trial and n_test

Returns:

alpha, beta, quadN

classmethod get_powers(int_var: Symbol, expr: Expr, **kwargs) ndarray[source]

Get the powers of p1=(1 - xi), p2=(1 + xi) and xi

Parameters:
  • int_var (sympy.Symbol) – integration variable

  • expr (sympy.Expr) – the expression where the powers are retrieved

  • **kwargs – whatever that needs to be passed to powers_of

For details, please refer to power_of

gramian(nrange_trial: List[int], nrange_test: List[int], backend: str = 'sympy', int_opt: dict = {}, output: str = 'sympy', out_opt: dict = {}, outer: bool = True, verbose: bool = True) Union[ndarray, matrix, MutableDenseMatrix][source]

Compute Gram matrix, concrete realization for Gauss Jacobi quadrature

This is the main interface for calculating the inner product matrix; it is a conglomerate of different methods with different options.

Parameters:
  • nrange_trial (List[int]) – idx range for trial func, see InnerQuadRule.gramian

  • nrange_test (List[int]) – idx range for test func, see InnerQuadRule.gramian

  • backend (str) –

    which backend to use for integration. * “sympy”: the evaluation will be done using sympy evalf * “scipy”: the evaluation will be conducted using numpy/scipy funcs

    the precision will be limited to platform support for np.float

    • ”mpmath”: multi-precision evaluation with mpmath

    • ”gmpy2”: multi-precision evaluation with gmpy2

  • int_opt (dict) – kwargs passed to integration function

  • output (str) – which form of matrix to output. * “sympy”: the output will be cast to a sympy.Matrix * “numpy”: the output will be cast to a numpy.ndarray

  • out_opt (dict) – kwargs passed to _output_form method

  • outer (bool) – whether to use outer product formulation

output_form(M_in: Union[ndarray, MutableDenseMatrix], output: str = 'sympy', **kwargs) Union[ndarray, MutableDenseMatrix][source]

Cast output matrix to desired form and data types