|
Janus 2.0.0
High-performance C++20 dual-mode numerical framework
|
Convenience header bringing common Janus symbols into scope. More...
#include "janus.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, SymbolicScalar > | sym_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> | |
| T | abs (const T &x) |
| Computes the absolute value of a scalar. | |
| template<JanusScalar T> | |
| T | acos (const T &x) |
| Computes arc cosine of x. | |
| template<JanusScalar T> | |
| T | asin (const T &x) |
| Computes arc sine of x. | |
| template<JanusScalar T> | |
| T | atan (const T &x) |
| Computes arc tangent of x. | |
| template<JanusScalar T> | |
| T | atan2 (const T &y, const T &x) |
| Computes arc tangent of y/x using signs of both arguments. | |
| template<JanusScalar T> | |
| T | ceil (const T &x) |
| Computes ceiling of x. | |
| template<JanusScalar T> | |
| T | cos (const T &x) |
| Computes cosine of x. | |
| template<JanusScalar T> | |
| T | cosh (const T &x) |
| Computes hyperbolic cosine of x. | |
| template<JanusScalar T> | |
| T | exp (const T &x) |
| Computes the exponential function e^x. | |
| template<JanusScalar T> | |
| T | floor (const T &x) |
| Computes floor of x. | |
| template<JanusScalar T> | |
| T | log (const T &x) |
| Computes the natural logarithm of x. | |
| template<JanusScalar T> | |
| T | log10 (const T &x) |
| Computes the base-10 logarithm of x. | |
| template<JanusScalar T> | |
| T | pow (const T &base, const T &exponent) |
| Computes the power function: base^exponent. | |
| template<JanusScalar T> | |
| T | sin (const T &x) |
| Computes sine of x. | |
| template<JanusScalar T> | |
| T | sinh (const T &x) |
| Computes hyperbolic sine. | |
| template<JanusScalar T> | |
| T | sqrt (const T &x) |
| Computes the square root of a scalar. | |
| template<JanusScalar T> | |
| T | tan (const T &x) |
| Computes tangent of x. | |
| template<JanusScalar T> | |
| 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. | |
Convenience header bringing common Janus symbols into scope.
Include this header for cleaner code without explicit janus:: prefixes.
| using janus::NumericMatrix |
Eigen::MatrixXd equivalent.
| using janus::NumericScalar |
Numeric scalar type.
| using janus::NumericVector |
Eigen::VectorXd equivalent.
| using janus::SymbolicMatrix |
Eigen matrix of MX elements.
| using janus::SymbolicScalar |
CasADi MX symbolic scalar.
| using janus::SymbolicVector |
Eigen vector of MX elements.
|
strong |
Dense linear solver algorithm.
|
strong |
Iterative Krylov solver algorithm.
|
strong |
Preconditioner for iterative solvers.
|
strong |
Backend selection for linear system solves.
|
strong |
Univariate Askey-scheme family used for a PCE input dimension.
|
strong |
Multi-index truncation strategy for a multidimensional basis.
|
strong |
Sparse direct solver algorithm.
|
strong |
One-dimensional rule family used to generate stochastic quadrature nodes.
| T janus::abs | ( | const T & | x | ) |
Computes the absolute value of a scalar.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| T janus::acos | ( | const T & | x | ) |
Computes arc cosine of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
|
inline |
Run structural observability and identifiability checks together.
| fn | Function to analyze |
| opts | Combined analysis options (at least one input index must be non-negative) |
|
inline |
Analyze which parameters are structurally identifiable from selected outputs.
| fn | Function whose Jacobian sparsity is analyzed |
| parameter_input_idx | Index of the parameter input block |
| opts | Output selection options |
|
inline |
Analyze which states are structurally observable from selected outputs.
| fn | Function whose Jacobian sparsity is analyzed |
| state_input_idx | Index of the state input block |
| opts | Output selection options |
|
inline |
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.
| v | SymbolicVector to convert |
|
inline |
Convert CasADi MX vector to SymbolicVector (Eigen container of MX).
| m | Input CasADi MX (column vector) |
| T janus::asin | ( | const T & | x | ) |
Computes arc sine of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| T janus::atan | ( | const T & | x | ) |
Computes arc tangent of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| T janus::atan2 | ( | const T & | y, |
| const T & | x ) |
Computes arc tangent of y/x using signs of both arguments.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| y | Numerator |
| x | Denominator |
| T janus::ceil | ( | const T & | x | ) |
Computes ceiling of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| T janus::cos | ( | const T & | x | ) |
Computes cosine of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value (radians) |
| T janus::cosh | ( | const T & | x | ) |
Computes hyperbolic cosine of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| T janus::exp | ( | const T & | x | ) |
Computes the exponential function e^x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| T janus::floor | ( | const T & | x | ) |
Computes floor of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| 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.
| Derived | Eigen vector type |
| f | Function values (vector) |
| dx | Spacing (scalar or vector). If scalar, uniform spacing is assumed. |
| edge_order | Order of accuracy at boundaries (1 or 2) |
| n | Derivative order (1 for first derivative, 2 for second derivative) |
|
inline |
Create a standard normal (Hermite) dimension.
|
inline |
Hessian matrix (second-order derivatives).
Computes the matrix of second derivatives: H_ij = d²f / (dx_i dx_j)
| expr | Scalar expression |
| vars | Variables |
|
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.
| expr | Scalar expression f(x) |
| vars | Differentiation variables x |
| direction | Direction vector/matrix v with the same shape as x |
|
inline |
Create a Beta-family (Jacobi) dimension on [-1, 1].
| alpha | Jacobi alpha parameter (> -1) |
| beta | Jacobi beta parameter (> -1) |
| 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.
| Expr | Expression type (must be convertible to MX) |
| Vars | Variable types (must be convertible to MX) |
| expression | Expression to differentiate |
| variables | Variables to differentiate with respect to |
|
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.
| objective | Objective function f(x) (scalar) |
| constraints | Constraint function g(x) |
| vars | Decision variables x |
| multipliers | Lagrange multipliers λ (same number of entries as g) |
| direction | Direction vector/matrix v with the same shape as x |
|
inline |
Create a Gamma-family (Laguerre) dimension on [0, inf).
| alpha | Laguerre alpha parameter (> -1) |
Create a uniform (Legendre) dimension on [-1, 1].
| JanusVector< T > janus::linspace | ( | const T & | start, |
| const T & | end, | ||
| int | n ) |
Generates linearly spaced vector.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| start | Start value |
| end | End value |
| n | Number of points |
| T janus::log | ( | const T & | x | ) |
Computes the natural logarithm of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| T janus::log10 | ( | const T & | x | ) |
Computes the base-10 logarithm of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
| Scalar janus::pce_mean | ( | const JanusVector< Scalar > & | coefficients | ) |
Extract PCE mean (zeroth coefficient).
| Scalar | Scalar type (NumericScalar or SymbolicScalar) |
| coefficients | PCE coefficient vector |
| 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:
| 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).
| Scalar | Scalar type (NumericScalar or SymbolicScalar) |
| basis | Polynomial chaos basis |
| samples | Sample matrix (rows = samples, cols = dimensions) |
| weights | Quadrature weights |
| sample_values | Function values at sample points |
| 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).
| Scalar | Scalar type (NumericScalar or SymbolicScalar) |
| basis | Polynomial chaos basis |
| samples | Sample matrix |
| sample_values | Function values at sample points |
| ridge | Ridge regularization parameter |
|
inline |
Return the probability-measure squared norm of a univariate basis term.
| Scalar janus::pce_variance | ( | const PolynomialChaosBasis & | basis, |
| const JanusVector< Scalar > & | coefficients ) |
Compute PCE variance from coefficients.
| Scalar | Scalar type (NumericScalar or SymbolicScalar) |
| basis | Polynomial chaos basis |
| coefficients | PCE coefficient vector |
| T janus::pow | ( | const T & | base, |
| const T & | exponent ) |
Computes the power function: base^exponent.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| base | Base value |
| exponent | Exponent value |
| T janus::sin | ( | const T & | x | ) |
Computes sine of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value (radians) |
| T janus::sinh | ( | const T & | x | ) |
Computes hyperbolic sine.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
|
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.
| dimensions | Stochastic dimension descriptors |
| level | Sparse grid level (>= 1) |
| options | Smolyak construction options |
| T janus::sqrt | ( | const T & | x | ) |
Computes the square root of a scalar.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
|
inline |
Build a one-dimensional stochastic quadrature rule from a refinement level.
| dimension | Stochastic dimension descriptor |
| level | Refinement level (>= 1) |
| rule | Quadrature rule family |
|
inline |
Build a one-dimensional stochastic quadrature rule with a fixed order.
| dimension | Stochastic dimension descriptor |
| order | Number of quadrature points |
| rule | Quadrature rule family |
|
inline |
Create a named symbolic scalar variable.
| name | Name of the variable |
|
inline |
Create a symbolic vector preserving the CasADi primitive connection.
| name | Name of the variable |
| size | Number of elements |
|
inline |
Create symbolic vector and return both SymbolicVector and underlying MX.
| name | Name of the variable |
| size | Number of elements |
|
inline |
Create a named symbolic vector (returns SymbolicVector).
| name | Name of the variable |
| size | Number of elements |
| T janus::tan | ( | const T & | x | ) |
Computes tangent of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value (radians) |
| T janus::tanh | ( | const T & | x | ) |
Computes hyperbolic tangent of x.
| T | Scalar type (NumericScalar or SymbolicScalar) |
| x | Input value |
|
inline |
Build the tensor-product grid from a list of one-dimensional rules.
| rules | Vector of univariate quadrature rules |
|
inline |
| casadi::MX janus::to_mx | ( | const Eigen::MatrixBase< Derived > & | e | ) |
| 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.
| cond | Condition |
| if_true | Value if true |
| if_false | Value if false |