Janus 2.0.0
High-performance C++20 dual-mode numerical framework
Loading...
Searching...
No Matches
using.hpp File Reference

Convenience header bringing common Janus symbols into scope. More...

#include "janus.hpp"
Include dependency graph for using.hpp:

Go to the source code of this file.

Classes

struct  LinearSolvePolicy
 Configuration for linear system solve backend and algorithm. More...
class  PolynomialChaosBasis
 Multidimensional polynomial chaos basis with fixed truncation/order. More...
struct  PolynomialChaosBasisOptions
 Basis construction controls for multidimensional PCE. More...
struct  PolynomialChaosDimension
 One stochastic dimension in a polynomial chaos basis. More...
struct  PolynomialChaosTerm
 One multidimensional chaos basis term. More...
struct  SmolyakQuadratureOptions
 Options for Smolyak sparse-grid construction. More...
struct  StochasticQuadratureGrid
 Multidimensional stochastic quadrature grid with row-major sample layout. More...
struct  StructuralDiagnosticsOptions
 Combined observability and identifiability analysis options. More...
struct  StructuralDiagnosticsReport
 Combined structural diagnostics report. More...
struct  StructuralSensitivityOptions
 Output-selection options shared by the structural diagnostics helpers. More...
struct  StructuralSensitivityReport
 Structural rank analysis of selected outputs with respect to one input block. More...
struct  UnivariateQuadratureRule
 One-dimensional stochastic quadrature rule on a probability measure. More...

Typedefs

using NumericMatrix
 Eigen::MatrixXd equivalent.
using NumericScalar
 Numeric scalar type.
using NumericVector
 Eigen::VectorXd equivalent.
using SymbolicMatrix
 Eigen matrix of MX elements.
using SymbolicScalar
 CasADi MX symbolic scalar.
using SymbolicVector
 Eigen vector of MX elements.

Enumerations

enum class  DenseLinearSolver
 Dense linear solver algorithm. More...
enum class  IterativeKrylovSolver
 Iterative Krylov solver algorithm. More...
enum class  IterativePreconditioner
 Preconditioner for iterative solvers. More...
enum class  LinearSolveBackend
 Backend selection for linear system solves. More...
enum class  PolynomialChaosFamily
 Univariate Askey-scheme family used for a PCE input dimension. More...
enum class  PolynomialChaosTruncation
 Multi-index truncation strategy for a multidimensional basis. More...
enum class  SparseDirectLinearSolver
 Sparse direct solver algorithm. More...
enum class  StochasticQuadratureRule
 One-dimensional rule family used to generate stochastic quadrature nodes. More...

Functions

SymbolicScalar sym (const std::string &name)
 Create a named symbolic scalar variable.
SymbolicVector sym_vec (const std::string &name, int size)
 Create a symbolic vector preserving the CasADi primitive connection.
std::pair< SymbolicVector, SymbolicScalarsym_vec_pair (const std::string &name, int size)
 Create symbolic vector and return both SymbolicVector and underlying MX.
SymbolicVector sym_vector (const std::string &name, int size)
 Create a named symbolic vector (returns SymbolicVector).
SymbolicScalar as_mx (const SymbolicVector &v)
 Get the underlying MX representation of a SymbolicVector.
SymbolicVector as_vector (const casadi::MX &m)
 Convert CasADi MX vector to SymbolicVector (Eigen container of MX).
Eigen::Matrix< casadi::MX, Eigen::Dynamic, Eigen::Dynamic > to_eigen (const casadi::MX &m)
 Convert CasADi MX to Eigen matrix of MX.
template<typename Derived>
casadi::MX to_mx (const Eigen::MatrixBase< Derived > &e)
 Convert Eigen matrix of MX (or numeric) to CasADi MX.
StructuralDiagnosticsReport analyze_structural_diagnostics (const Function &fn, const StructuralDiagnosticsOptions &opts)
 Run structural observability and identifiability checks together.
StructuralSensitivityReport analyze_structural_identifiability (const Function &fn, int parameter_input_idx, const StructuralSensitivityOptions &opts={})
 Analyze which parameters are structurally identifiable from selected outputs.
StructuralSensitivityReport analyze_structural_observability (const Function &fn, int state_input_idx=0, const StructuralSensitivityOptions &opts={})
 Analyze which states are structurally observable from selected outputs.
template<JanusScalar T>
abs (const T &x)
 Computes the absolute value of a scalar.
template<JanusScalar T>
acos (const T &x)
 Computes arc cosine of x.
template<JanusScalar T>
asin (const T &x)
 Computes arc sine of x.
template<JanusScalar T>
atan (const T &x)
 Computes arc tangent of x.
template<JanusScalar T>
atan2 (const T &y, const T &x)
 Computes arc tangent of y/x using signs of both arguments.
template<JanusScalar T>
ceil (const T &x)
 Computes ceiling of x.
template<JanusScalar T>
cos (const T &x)
 Computes cosine of x.
template<JanusScalar T>
cosh (const T &x)
 Computes hyperbolic cosine of x.
template<JanusScalar T>
exp (const T &x)
 Computes the exponential function e^x.
template<JanusScalar T>
floor (const T &x)
 Computes floor of x.
template<JanusScalar T>
log (const T &x)
 Computes the natural logarithm of x.
template<JanusScalar T>
log10 (const T &x)
 Computes the base-10 logarithm of x.
template<JanusScalar T>
pow (const T &base, const T &exponent)
 Computes the power function: base^exponent.
template<JanusScalar T>
sin (const T &x)
 Computes sine of x.
template<JanusScalar T>
sinh (const T &x)
 Computes hyperbolic sine.
template<JanusScalar T>
sqrt (const T &x)
 Computes the square root of a scalar.
template<JanusScalar T>
tan (const T &x)
 Computes tangent of x.
template<JanusScalar T>
tanh (const T &x)
 Computes hyperbolic tangent of x.
template<typename Cond, JanusScalar T1, JanusScalar T2>
auto where (const Cond &cond, const T1 &if_true, const T2 &if_false)
 Select values based on condition (ternary operator) Returns: cond ? if_true : if_false Supports mixed types.
template<typename DerivedF, typename Spacing = double>
auto gradient (const Eigen::MatrixBase< DerivedF > &f, const Spacing &dx=1.0, int edge_order=1, int n=1)
 Computes gradient using second-order accurate central differences.
PolynomialChaosDimension hermite_dimension ()
 Create a standard normal (Hermite) dimension.
SymbolicMatrix hessian (const SymbolicArg &expr, const SymbolicArg &vars)
 Hessian matrix (second-order derivatives).
SymbolicMatrix hessian_vector_product (const SymbolicArg &expr, const SymbolicArg &vars, const SymbolicArg &direction)
 Hessian-vector product for a scalar expression without forming the dense Hessian.
PolynomialChaosDimension jacobi_dimension (double alpha, double beta)
 Create a Beta-family (Jacobi) dimension on [-1, 1].
template<typename Expr, typename... Vars>
auto jacobian (const Expr &expression, const Vars &...variables)
 Computes Jacobian of an expression with respect to variables.
SymbolicMatrix lagrangian_hessian_vector_product (const SymbolicArg &objective, const SymbolicArg &constraints, const SymbolicArg &vars, const SymbolicArg &multipliers, const SymbolicArg &direction)
 Hessian-vector product of a Lagrangian, i.e. a second-order adjoint action.
PolynomialChaosDimension laguerre_dimension (double alpha=0.0)
 Create a Gamma-family (Laguerre) dimension on [0, inf).
PolynomialChaosDimension legendre_dimension ()
 Create a uniform (Legendre) dimension on [-1, 1].
template<JanusScalar Scalar>
Scalar pce_mean (const JanusVector< Scalar > &coefficients)
 Extract PCE mean (zeroth coefficient).
template<JanusScalar Scalar>
Scalar pce_polynomial (const PolynomialChaosDimension &dimension, int degree, const Scalar &x, bool normalized=true)
 Evaluate a univariate chaos basis polynomial.
template<JanusScalar Scalar>
JanusVector< Scalar > pce_projection_coefficients (const PolynomialChaosBasis &basis, const NumericMatrix &samples, const NumericVector &weights, const JanusVector< Scalar > &sample_values)
 Compute PCE projection coefficients from weighted samples (vector).
template<JanusScalar Scalar>
JanusVector< Scalar > pce_regression_coefficients (const PolynomialChaosBasis &basis, const NumericMatrix &samples, const JanusVector< Scalar > &sample_values, double ridge=1e-12)
 Compute PCE coefficients via least-squares regression (vector).
double pce_squared_norm (const PolynomialChaosDimension &dimension, int degree, bool normalized=true)
 Return the probability-measure squared norm of a univariate basis term.
template<JanusScalar Scalar>
Scalar pce_variance (const PolynomialChaosBasis &basis, const JanusVector< Scalar > &coefficients)
 Compute PCE variance from coefficients.
StochasticQuadratureGrid smolyak_sparse_grid (const std::vector< PolynomialChaosDimension > &dimensions, int level, SmolyakQuadratureOptions options={})
 Build a Smolyak sparse grid on probability measures.
UnivariateQuadratureRule stochastic_quadrature_level (const PolynomialChaosDimension &dimension, int level, StochasticQuadratureRule rule=StochasticQuadratureRule::AutoNested)
 Build a one-dimensional stochastic quadrature rule from a refinement level.
UnivariateQuadratureRule stochastic_quadrature_rule (const PolynomialChaosDimension &dimension, int order, StochasticQuadratureRule rule=StochasticQuadratureRule::Gauss)
 Build a one-dimensional stochastic quadrature rule with a fixed order.
StochasticQuadratureGrid tensor_product_quadrature (const std::vector< UnivariateQuadratureRule > &rules)
 Build the tensor-product grid from a list of one-dimensional rules.
template<typename T>
JanusVector< T > linspace (const T &start, const T &end, int n)
 Generates linearly spaced vector.

Detailed Description

Convenience header bringing common Janus symbols into scope.

Include this header for cleaner code without explicit janus:: prefixes.

#include <janus/using.hpp>
auto x = sym("x");
auto y = sin(x) + pow(x, 2);
auto z = where(x > 0, x, -x);
Convenience header bringing common Janus symbols into scope.
auto where(const Cond &cond, const T1 &if_true, const T2 &if_false)
Select values based on condition (ternary operator) Returns: cond ? if_true : if_false Supports mixed...
Definition Logic.hpp:43
T sin(const T &x)
Computes sine of x.
Definition Trig.hpp:21
SymbolicScalar sym(const std::string &name)
Create a named symbolic scalar variable.
Definition JanusTypes.hpp:90
T pow(const T &base, const T &exponent)
Computes the power function: base^exponent.
Definition Arithmetic.hpp:72
Warning
This header pollutes the global namespace. Use with care in library code - prefer explicit janus:: prefixes there.

Typedef Documentation

◆ NumericMatrix

Eigen::MatrixXd equivalent.

Examples
Basic.

◆ NumericScalar

Numeric scalar type.

◆ NumericVector

◆ SymbolicMatrix

Eigen matrix of MX elements.

◆ SymbolicScalar

◆ SymbolicVector

Enumeration Type Documentation

◆ DenseLinearSolver

enum class janus::DenseLinearSolver
strong

Dense linear solver algorithm.

◆ IterativeKrylovSolver

enum class janus::IterativeKrylovSolver
strong

Iterative Krylov solver algorithm.

◆ IterativePreconditioner

enum class janus::IterativePreconditioner
strong

Preconditioner for iterative solvers.

◆ LinearSolveBackend

enum class janus::LinearSolveBackend
strong

Backend selection for linear system solves.

◆ PolynomialChaosFamily

enum class janus::PolynomialChaosFamily
strong

Univariate Askey-scheme family used for a PCE input dimension.

◆ PolynomialChaosTruncation

Multi-index truncation strategy for a multidimensional basis.

◆ SparseDirectLinearSolver

Sparse direct solver algorithm.

◆ StochasticQuadratureRule

One-dimensional rule family used to generate stochastic quadrature nodes.

Function Documentation

◆ abs()

template<JanusScalar T>
T janus::abs ( const T & x)

Computes the absolute value of a scalar.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Absolute value of x

◆ acos()

template<JanusScalar T>
T janus::acos ( const T & x)

Computes arc cosine of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Arc cosine of x (radians)

◆ analyze_structural_diagnostics()

Run structural observability and identifiability checks together.

Parameters
fnFunction to analyze
optsCombined analysis options (at least one input index must be non-negative)
Returns
Combined diagnostics report
See also
analyze_structural_observability, analyze_structural_identifiability

◆ analyze_structural_identifiability()

StructuralSensitivityReport janus::analyze_structural_identifiability ( const Function & fn,
int parameter_input_idx,
const StructuralSensitivityOptions & opts = {} )
inline

Analyze which parameters are structurally identifiable from selected outputs.

Parameters
fnFunction whose Jacobian sparsity is analyzed
parameter_input_idxIndex of the parameter input block
optsOutput selection options
Returns
Structural sensitivity report
See also
analyze_structural_observability

◆ analyze_structural_observability()

StructuralSensitivityReport janus::analyze_structural_observability ( const Function & fn,
int state_input_idx = 0,
const StructuralSensitivityOptions & opts = {} )
inline

Analyze which states are structurally observable from selected outputs.

Parameters
fnFunction whose Jacobian sparsity is analyzed
state_input_idxIndex of the state input block
optsOutput selection options
Returns
Structural sensitivity report
See also
analyze_structural_identifiability, analyze_structural_diagnostics

◆ as_mx()

Get the underlying MX representation of a SymbolicVector.

This packs an Eigen container of MX elements back into a single CasADi MX for use with janus::Function or janus::jacobian.

Parameters
vSymbolicVector to convert
Returns
Single casadi::MX representing the vector

◆ as_vector()

SymbolicVector janus::as_vector ( const casadi::MX & m)
inline

Convert CasADi MX vector to SymbolicVector (Eigen container of MX).

Parameters
mInput CasADi MX (column vector)
Returns
SymbolicVector (Eigen::Matrix<casadi::MX, Dynamic, 1>)

◆ asin()

template<JanusScalar T>
T janus::asin ( const T & x)

Computes arc sine of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Arc sine of x (radians)

◆ atan()

template<JanusScalar T>
T janus::atan ( const T & x)

Computes arc tangent of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Arc tangent of x (radians)

◆ atan2()

template<JanusScalar T>
T janus::atan2 ( const T & y,
const T & x )

Computes arc tangent of y/x using signs of both arguments.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
yNumerator
xDenominator
Returns
Arc tangent of y/x (radians, included in [-pi, pi])

◆ ceil()

template<JanusScalar T>
T janus::ceil ( const T & x)

Computes ceiling of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Ceiling of x

◆ cos()

template<JanusScalar T>
T janus::cos ( const T & x)

Computes cosine of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value (radians)
Returns
Cosine of x

◆ cosh()

template<JanusScalar T>
T janus::cosh ( const T & x)

Computes hyperbolic cosine of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Hyperbolic cosine of x

◆ exp()

template<JanusScalar T>
T janus::exp ( const T & x)

Computes the exponential function e^x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
e raised to the power of x

◆ floor()

template<JanusScalar T>
T janus::floor ( const T & x)

Computes floor of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Floor of x

◆ gradient()

template<typename DerivedF, typename Spacing = double>
auto janus::gradient ( const Eigen::MatrixBase< DerivedF > & f,
const Spacing & dx = 1.0,
int edge_order = 1,
int n = 1 )

Computes gradient using second-order accurate central differences.

Returns the gradient of a 1D array using second-order accurate central differences in the interior and first or second-order accurate one-sided differences at boundaries.

Template Parameters
DerivedEigen vector type
Parameters
fFunction values (vector)
dxSpacing (scalar or vector). If scalar, uniform spacing is assumed.
edge_orderOrder of accuracy at boundaries (1 or 2)
nDerivative order (1 for first derivative, 2 for second derivative)
Returns
Gradient vector (same size as f)

◆ hermite_dimension()

Create a standard normal (Hermite) dimension.

Returns
Hermite dimension descriptor

◆ hessian()

SymbolicMatrix janus::hessian ( const SymbolicArg & expr,
const SymbolicArg & vars )
inline

Hessian matrix (second-order derivatives).

Computes the matrix of second derivatives: H_ij = d²f / (dx_i dx_j)

Parameters
exprScalar expression
varsVariables
Returns
Symmetric Hessian matrix (SymbolicMatrix)

◆ hessian_vector_product()

SymbolicMatrix janus::hessian_vector_product ( const SymbolicArg & expr,
const SymbolicArg & vars,
const SymbolicArg & direction )
inline

Hessian-vector product for a scalar expression without forming the dense Hessian.

This uses CasADi's directional derivative of the reverse-mode gradient, i.e. forward-over-reverse AD.

Parameters
exprScalar expression f(x)
varsDifferentiation variables x
directionDirection vector/matrix v with the same shape as x
Returns
Matrix/vector with the same shape as x containing ∇²f(x) v

◆ jacobi_dimension()

PolynomialChaosDimension janus::jacobi_dimension ( double alpha,
double beta )
inline

Create a Beta-family (Jacobi) dimension on [-1, 1].

Parameters
alphaJacobi alpha parameter (> -1)
betaJacobi beta parameter (> -1)
Returns
Jacobi dimension descriptor

◆ jacobian()

template<typename Expr, typename... Vars>
auto janus::jacobian ( const Expr & expression,
const Vars &... variables )

Computes Jacobian of an expression with respect to variables.

Wraps CasADi's jacobian function. Automatic Jacobian only supported for Symbolic types currently.

Template Parameters
ExprExpression type (must be convertible to MX)
VarsVariable types (must be convertible to MX)
Parameters
expressionExpression to differentiate
variablesVariables to differentiate with respect to
Returns
Jacobian matrix (symbolic)

◆ lagrangian_hessian_vector_product()

SymbolicMatrix janus::lagrangian_hessian_vector_product ( const SymbolicArg & objective,
const SymbolicArg & constraints,
const SymbolicArg & vars,
const SymbolicArg & multipliers,
const SymbolicArg & direction )
inline

Hessian-vector product of a Lagrangian, i.e. a second-order adjoint action.

Computes ∇²L(x, λ) v for L(x, λ) = f(x) + λᵀ g(x) without forming the dense Hessian.

Parameters
objectiveObjective function f(x) (scalar)
constraintsConstraint function g(x)
varsDecision variables x
multipliersLagrange multipliers λ (same number of entries as g)
directionDirection vector/matrix v with the same shape as x
Returns
Matrix/vector with the same shape as x containing ∇²L(x, λ) v

◆ laguerre_dimension()

Create a Gamma-family (Laguerre) dimension on [0, inf).

Parameters
alphaLaguerre alpha parameter (> -1)
Returns
Laguerre dimension descriptor

◆ legendre_dimension()

Create a uniform (Legendre) dimension on [-1, 1].

Returns
Legendre dimension descriptor

◆ linspace()

template<typename T>
JanusVector< T > janus::linspace ( const T & start,
const T & end,
int n )

Generates linearly spaced vector.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
startStart value
endEnd value
nNumber of points
Returns
Vector of n linearly spaced points

◆ log()

template<JanusScalar T>
T janus::log ( const T & x)

Computes the natural logarithm of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Natural logarithm of x

◆ log10()

template<JanusScalar T>
T janus::log10 ( const T & x)

Computes the base-10 logarithm of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Base-10 logarithm of x

◆ pce_mean()

template<JanusScalar Scalar>
Scalar janus::pce_mean ( const JanusVector< Scalar > & coefficients)

Extract PCE mean (zeroth coefficient).

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
coefficientsPCE coefficient vector
Returns
Mean value

◆ pce_polynomial()

template<JanusScalar Scalar>
Scalar janus::pce_polynomial ( const PolynomialChaosDimension & dimension,
int degree,
const Scalar & x,
bool normalized = true )

Evaluate a univariate chaos basis polynomial.

The input x is assumed to already be expressed on the natural support of the chosen family:

  • Hermite: standard normal variable
  • Legendre/Jacobi: support [-1, 1]
  • Laguerre: support [0, inf)

◆ pce_projection_coefficients()

template<JanusScalar Scalar>
JanusVector< Scalar > janus::pce_projection_coefficients ( const PolynomialChaosBasis & basis,
const NumericMatrix & samples,
const NumericVector & weights,
const JanusVector< Scalar > & sample_values )

Compute PCE projection coefficients from weighted samples (vector).

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
basisPolynomial chaos basis
samplesSample matrix (rows = samples, cols = dimensions)
weightsQuadrature weights
sample_valuesFunction values at sample points
Returns
PCE coefficient vector

◆ pce_regression_coefficients()

template<JanusScalar Scalar>
JanusVector< Scalar > janus::pce_regression_coefficients ( const PolynomialChaosBasis & basis,
const NumericMatrix & samples,
const JanusVector< Scalar > & sample_values,
double ridge = 1e-12 )

Compute PCE coefficients via least-squares regression (vector).

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
basisPolynomial chaos basis
samplesSample matrix
sample_valuesFunction values at sample points
ridgeRidge regularization parameter
Returns
PCE coefficient vector

◆ pce_squared_norm()

double janus::pce_squared_norm ( const PolynomialChaosDimension & dimension,
int degree,
bool normalized = true )
inline

Return the probability-measure squared norm of a univariate basis term.

◆ pce_variance()

template<JanusScalar Scalar>
Scalar janus::pce_variance ( const PolynomialChaosBasis & basis,
const JanusVector< Scalar > & coefficients )

Compute PCE variance from coefficients.

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
basisPolynomial chaos basis
coefficientsPCE coefficient vector
Returns
Variance

◆ pow()

template<JanusScalar T>
T janus::pow ( const T & base,
const T & exponent )

Computes the power function: base^exponent.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
baseBase value
exponentExponent value
Returns
base raised to the power of exponent

◆ sin()

template<JanusScalar T>
T janus::sin ( const T & x)

Computes sine of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value (radians)
Returns
Sine of x

◆ sinh()

template<JanusScalar T>
T janus::sinh ( const T & x)

Computes hyperbolic sine.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Hyperbolic sine of x

◆ smolyak_sparse_grid()

StochasticQuadratureGrid janus::smolyak_sparse_grid ( const std::vector< PolynomialChaosDimension > & dimensions,
int level,
SmolyakQuadratureOptions options = {} )
inline

Build a Smolyak sparse grid on probability measures.

The level follows the standard convention with one-dimensional indices i_j >= 1 and total-index band level <= |i| <= level + d - 1.

Parameters
dimensionsStochastic dimension descriptors
levelSparse grid level (>= 1)
optionsSmolyak construction options
Returns
Sparse quadrature grid

◆ sqrt()

template<JanusScalar T>
T janus::sqrt ( const T & x)

Computes the square root of a scalar.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Square root of x

◆ stochastic_quadrature_level()

UnivariateQuadratureRule janus::stochastic_quadrature_level ( const PolynomialChaosDimension & dimension,
int level,
StochasticQuadratureRule rule = StochasticQuadratureRule::AutoNested )
inline

Build a one-dimensional stochastic quadrature rule from a refinement level.

Parameters
dimensionStochastic dimension descriptor
levelRefinement level (>= 1)
ruleQuadrature rule family
Returns
Univariate quadrature rule

◆ stochastic_quadrature_rule()

UnivariateQuadratureRule janus::stochastic_quadrature_rule ( const PolynomialChaosDimension & dimension,
int order,
StochasticQuadratureRule rule = StochasticQuadratureRule::Gauss )
inline

Build a one-dimensional stochastic quadrature rule with a fixed order.

Parameters
dimensionStochastic dimension descriptor
orderNumber of quadrature points
ruleQuadrature rule family
Returns
Univariate quadrature rule

◆ sym()

SymbolicScalar janus::sym ( const std::string & name)
inline

Create a named symbolic scalar variable.

Parameters
nameName of the variable
Returns
SymbolicScalar (casadi::MX)

◆ sym_vec()

SymbolicVector janus::sym_vec ( const std::string & name,
int size )
inline

Create a symbolic vector preserving the CasADi primitive connection.

auto state = janus::sym_vec("state", 3);
auto jac = janus::jacobian({janus::to_mx(dydt)}, {janus::to_mx(state)});
SymbolicVector sym_vec(const std::string &name, int size)
Create a symbolic vector preserving the CasADi primitive connection.
Definition JanusTypes.hpp:137
casadi::MX to_mx(const Eigen::MatrixBase< Derived > &e)
Convert Eigen matrix of MX (or numeric) to CasADi MX.
Definition JanusTypes.hpp:189
auto jacobian(const Expr &expression, const Vars &...variables)
Computes Jacobian of an expression with respect to variables.
Definition AutoDiff.hpp:109
Parameters
nameName of the variable
sizeNumber of elements
Returns
SymbolicVector with MX elements from single underlying vector
See also
sym_vector, sym_vec_pair

◆ sym_vec_pair()

std::pair< SymbolicVector, SymbolicScalar > janus::sym_vec_pair ( const std::string & name,
int size )
inline

Create symbolic vector and return both SymbolicVector and underlying MX.

auto [state_vec, state_mx] = janus::sym_vec_pair("state", 3);
auto jac = janus::jacobian({janus::to_mx(dydt)}, {state_mx, theta});
std::pair< SymbolicVector, SymbolicScalar > sym_vec_pair(const std::string &name, int size)
Create symbolic vector and return both SymbolicVector and underlying MX.
Definition JanusTypes.hpp:155
Parameters
nameName of the variable
sizeNumber of elements
Returns
Pair of (SymbolicVector, underlying MX)
See also
sym_vec

◆ sym_vector()

SymbolicVector janus::sym_vector ( const std::string & name,
int size )
inline

Create a named symbolic vector (returns SymbolicVector).

auto x = janus::sym_vector("x", 3); // Returns SymbolicVector
SymbolicVector sym_vector(const std::string &name, int size)
Create a named symbolic vector (returns SymbolicVector).
Definition JanusTypes.hpp:115
Parameters
nameName of the variable
sizeNumber of elements
Returns
SymbolicVector with MX elements
See also
sym_vec, sym_vec_pair

◆ tan()

template<JanusScalar T>
T janus::tan ( const T & x)

Computes tangent of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value (radians)
Returns
Tangent of x

◆ tanh()

template<JanusScalar T>
T janus::tanh ( const T & x)

Computes hyperbolic tangent of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Hyperbolic tangent of x

◆ tensor_product_quadrature()

Build the tensor-product grid from a list of one-dimensional rules.

Parameters
rulesVector of univariate quadrature rules
Returns
Tensor-product grid

◆ to_eigen()

Eigen::Matrix< casadi::MX, Eigen::Dynamic, Eigen::Dynamic > janus::to_eigen ( const casadi::MX & m)
inline

Convert CasADi MX to Eigen matrix of MX.

Parameters
mInput CasADi MX
Returns
Eigen matrix (dynamic size)

◆ to_mx()

template<typename Derived>
casadi::MX janus::to_mx ( const Eigen::MatrixBase< Derived > & e)

Convert Eigen matrix of MX (or numeric) to CasADi MX.

Template Parameters
DerivedEigen matrix type
Parameters
eInput Eigen matrix
Returns
CasADi MX (dense)

◆ where()

template<typename Cond, JanusScalar T1, JanusScalar T2>
auto janus::where ( const Cond & cond,
const T1 & if_true,
const T2 & if_false )

Select values based on condition (ternary operator) Returns: cond ? if_true : if_false Supports mixed types.

Parameters
condCondition
if_trueValue if true
if_falseValue if false
Returns
Selected value
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.