eradiate.quad#

Utility components for quadrature rules.

class eradiate.quad.Quad(type, nodes, weights)[source]#

A data class storing information about a quadrature rule. Nodes and weights are defined in the [-1, 1] interval. The reference interval can be changed using the interval argument of the eval_nodes() and integrate() functions.

Parameters:
  • type (QuadType) – Quadrature type. If a string is passed, it is converted to a QuadType.

  • nodes (ndarray) – Quadrature rule nodes.

  • weights (ndarray) – Quadrature rule weights.

Fields:
  • type (QuadType) – Quadrature type.

  • nodes (ndarray) – Quadrature rule nodes.

  • weights (ndarray) – Quadrature rule weights.

eval_nodes(interval=None)[source]#

Compute nodes scaled to a specific interval.

Parameters:

interval (tuple of float, optional) – Interval for which nodes are to be scaled as a 2-tuple. If None, the default [-1, 1] is used.

Returns:

ndarray – Scaled node values.

classmethod gauss_legendre(n)[source]#

Initialize a Quad instance with Gauss-Legendre nodes and weights.

Parameters:

n (int) – Number of quadrature points.

Returns:

Quad – Gauss-Legendre quadrature definition.

classmethod gauss_lobatto(n)[source]#

Initialize a Quad instance with Gauss-Lobatto nodes and weights.

Parameters:

n (int) – Number of quadrature points.

Returns:

Quad – Gauss-Lobatto quadrature definition.

integrate(values, interval)[source]#

Evaluate quadrature rule, accounting for interval scaling.

Parameters:
  • values (ndarray) – Function values at quadrature nodes.

  • interval (tuple of float, optional) – Interval on which the integral is being computed as a 2-tuple. If None, the default [-1, 1] is used.

Returns:

float – Quadrature evaluation for the specified interval.

classmethod new(type, n)[source]#

Initialize a Quad instance of the specified type.

Parameters:
  • type (str or QuadType) – Quadrature rule type. If a string is passed, it is converted to a QuadType.

  • n (int) – Number of quadrature points.

Returns:

Quad – Quadrature definition.

property str_summary#

Return a summarized representation of the current instance.

Returns:

str – Instance summary.

class eradiate.quad.QuadType(value)[source]#

Quadrature rule type flags.