Janus 2.0.0
High-performance C++20 dual-mode numerical framework
Loading...
Searching...
No Matches
janus Namespace Reference

Namespaces

namespace  detail
 Smooth approximation of ReLU function: softplus(x) = (1/beta) * log(1 + exp(beta * x)).
namespace  utils

Classes

struct  StructuralSensitivityOptions
 Output-selection options shared by the structural diagnostics helpers. More...
struct  DiagnosticInputRef
 One scalarized element of the selected input block. More...
struct  DiagnosticOutputRef
 One scalarized row in the selected output stack. More...
struct  StructuralDeficiencyGroup
 One structurally deficient connected component in the sensitivity graph. More...
struct  StructuralDiagnosticIssue
 One user-facing structural diagnostic with an attached remediation hint. More...
struct  StructuralSensitivityReport
 Structural rank analysis of selected outputs with respect to one input block. More...
struct  StructuralDiagnosticsOptions
 Combined observability and identifiability analysis options. More...
struct  StructuralDiagnosticsReport
 Combined structural diagnostics report. More...
class  Function
 Wrapper around casadi::Function providing Eigen-native IO. More...
class  JanusError
 Base exception for all Janus errors. More...
class  InvalidArgument
 Input validation failed (e.g., mismatched sizes, invalid parameters). More...
class  RuntimeError
 Operation failed at runtime (e.g., CasADi eval with free variables). More...
class  InterpolationError
 Interpolation-specific errors. More...
class  IntegrationError
 Integration/ODE solver errors. More...
class  SymbolicArg
 Universal symbolic argument wrapper for Function inputs/outputs. More...
class  SparsityPattern
class  GraphColoring
 Wrapper around a CasADi graph coloring assignment. More...
class  SparseJacobianEvaluator
 Cached sparse Jacobian evaluator with fixed structural ordering. More...
class  SparseHessianEvaluator
 Cached sparse Hessian evaluator with fixed structural ordering. More...
struct  NaNSparsityOptions
 Options for NaN-propagation sparsity detection. More...
struct  StructuralTransformOptions
 Options for structural simplification and analysis passes. More...
struct  AliasSubstitution
 A single eliminated alias or trivial affine variable relation. More...
struct  AliasEliminationResult
 Result of alias elimination on a selected residual block. More...
struct  StructuralBlock
 One diagonal block in a block-triangular decomposition. More...
struct  BLTDecomposition
 Block-triangular decomposition and tearing metadata for a selected block. More...
struct  StructuralAnalysis
 Combined alias-elimination and BLT analysis pass. More...
struct  SensitivitySwitchOptions
 Heuristics controlling automatic forward-vs-adjoint selection. More...
struct  SensitivityRecommendation
 Result of Janus sensitivity regime selection. More...
struct  OdeResult
 Result structure for ODE solvers. More...
struct  SecondOrderOdeResult
 Result structure for second-order IVP solvers. More...
struct  SecondOrderIvpOptions
 Options for second-order structure-preserving trajectory integration. More...
struct  MassMatrixIvpOptions
 Options for stiff mass-matrix integration. More...
struct  QuadResult
 Result structure for quadrature (definite integration). More...
struct  SecondOrderStepResult
 Result of a second-order integration step. More...
struct  RK45Result
 Result of RK45 step with error estimate. More...
struct  ExtrapolationConfig
 Configuration for extrapolation behavior. More...
class  Interpolator
struct  LinearSolvePolicy
 Configuration for linear system solve backend and algorithm. More...
struct  EigenDecomposition
 Result of eigendecomposition: eigenvalues and eigenvectors. More...
struct  BooleanType
struct  BooleanType< SymbolicScalar >
struct  PolynomialChaosDimension
 One stochastic dimension in a polynomial chaos basis. More...
struct  PolynomialChaosBasisOptions
 Basis construction controls for multidimensional PCE. More...
struct  PolynomialChaosTerm
 One multidimensional chaos basis term. More...
class  PolynomialChaosBasis
 Multidimensional polynomial chaos basis with fixed truncation/order. More...
struct  UnivariateQuadratureRule
 One-dimensional stochastic quadrature rule on a probability measure. More...
struct  StochasticQuadratureGrid
 Multidimensional stochastic quadrature grid with row-major sample layout. More...
struct  SmolyakQuadratureOptions
 Options for Smolyak sparse-grid construction. More...
class  Quaternion
 Quaternion class for rotation representation. More...
struct  RootFinderOptions
 Options for root finding algorithms. More...
struct  ImplicitFunctionOptions
 Options for building differentiable implicit solve wrappers. More...
struct  RootResult
 Result of a root finding operation. More...
class  NewtonSolver
 Persistent nonlinear root solver. More...
class  ScatteredInterpolator
struct  BirkhoffPseudospectralOptions
 Options for BirkhoffPseudospectral setup. More...
class  BirkhoffPseudospectral
 Birkhoff pseudospectral transcription. More...
struct  CollocationOptions
 Options for DirectCollocation setup. More...
class  DirectCollocation
 Direct collocation transcription. More...
struct  MultiShootingOptions
 Options for MultipleShooting. More...
class  MultipleShooting
 Multiple shooting transcription. More...
struct  VariableOptions
 Options for variable creation. More...
class  Opti
 Main optimization environment class. More...
struct  SNOPTOptions
 SNOPT-specific solver options. More...
struct  OptiOptions
 Options for solving optimization problems. More...
class  OptiSol
 Solution wrapper for optimization results. More...
struct  SweepResult
 Result of a parametric sweep. More...
struct  PseudospectralOptions
 Options for Pseudospectral setup. More...
class  Pseudospectral
 Pseudospectral (Gauss-Lobatto) transcription. More...
struct  ScalingAnalysisOptions
 Thresholds controlling Opti scaling diagnostics. More...
struct  ScalingIssue
 One diagnostic item produced by Opti::analyze_scaling(). More...
struct  VariableScalingInfo
 Scaling metadata for one declared variable block. More...
struct  ConstraintScalingInfo
 Scaling metadata for one scalarized constraint row. More...
struct  ObjectiveScalingInfo
 Scaling metadata for the current objective. More...
struct  ScalingSummary
 Top-level scalar summary for an Opti scaling report. More...
struct  ScalingReport
 Aggregate result returned by Opti::analyze_scaling(). More...
class  TranscriptionBase
 Shared CRTP base for transcription methods. More...

Concepts

concept  JanusScalar
 Concept for valid Janus scalars.

Typedefs

template<typename Scalar>
using JanusMatrix = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
 Dynamic-size matrix for both numeric and symbolic backends.
template<typename Scalar>
using JanusVector = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>
 Dynamic-size column vector for both numeric and symbolic backends.
template<typename Scalar>
using Vec2 = Eigen::Matrix<Scalar, 2, 1>
 Fixed-size vectors and matrices for performance-critical code.
template<typename Scalar>
using Vec3 = Eigen::Matrix<Scalar, 3, 1>
template<typename Scalar>
using Vec4 = Eigen::Matrix<Scalar, 4, 1>
template<typename Scalar>
using Mat2 = Eigen::Matrix<Scalar, 2, 2>
template<typename Scalar>
using Mat3 = Eigen::Matrix<Scalar, 3, 3>
template<typename Scalar>
using Mat4 = Eigen::Matrix<Scalar, 4, 4>
using NumericScalar = double
 Numeric scalar type.
using NumericMatrix = JanusMatrix<NumericScalar>
 Eigen::MatrixXd equivalent.
using NumericVector = JanusVector<NumericScalar>
 Eigen::VectorXd equivalent.
using SymbolicScalar = casadi::MX
 CasADi MX symbolic scalar.
using SymbolicMatrix = JanusMatrix<SymbolicScalar>
 Eigen matrix of MX elements.
using SymbolicVector = JanusVector<SymbolicScalar>
 Eigen vector of MX elements.
using SparseMatrix = Eigen::SparseMatrix<double>
 Sparse matrix types for efficient storage of large, sparse numeric data.
using SparseTriplet = Eigen::Triplet<double>
 (row, col, value) triplet
template<typename T>
using BooleanType_t = typename BooleanType<T>::type

Enumerations

enum class  StructuralProperty { Observability , Identifiability }
 Structural property being analyzed from a symbolic sensitivity pattern. More...
enum class  MapParallelization { Parallel , Serial , Unroll }
 Batch mapping backend for janus::Function::map(). More...
enum class  DeepGraphFormat { DOT , HTML , PDF }
 Export format for deep graph visualization. More...
enum class  SparseJacobianMode { Forward , Reverse }
 Preferred directional mode for a sparse Jacobian evaluator. More...
enum class  SensitivityRegime { Forward , Adjoint , CheckpointedAdjoint }
 Sensitivity regime selected for a Jacobian-like derivative workload. More...
enum class  CheckpointInterpolation { None , Hermite , Polynomial }
 Checkpoint interpolation recommendation for long-horizon adjoints. More...
enum class  IntegrationMethod { ForwardEuler , BackwardEuler , Trapezoidal , Midpoint }
 Integration/differentiation method for trajectory optimization. More...
enum class  SecondOrderIntegratorMethod { StormerVerlet , RungeKuttaNystrom4 }
 Stepper selection for second-order systems q'' = a(t, q). More...
enum class  MassMatrixIntegratorMethod { RosenbrockEuler , Bdf1 }
 Stepper selection for mass-matrix systems M(t, y) y' = f(t, y). More...
enum class  InterpolationMethod { Linear , Hermite , BSpline , Nearest }
 Supported interpolation methods. More...
enum class  ExtrapolationMode { Clamp , Linear }
 Controls behavior when query points fall outside grid bounds. More...
enum class  LinearSolveBackend { Dense , SparseDirect , IterativeKrylov }
 Backend selection for linear system solves. More...
enum class  DenseLinearSolver {
  ColPivHouseholderQR , PartialPivLU , FullPivLU , LLT ,
  LDLT
}
 Dense linear solver algorithm. More...
enum class  SparseDirectLinearSolver { SparseLU , SparseQR , SimplicialLLT , SimplicialLDLT }
 Sparse direct solver algorithm. More...
enum class  IterativeKrylovSolver { BiCGSTAB , GMRES }
 Iterative Krylov solver algorithm. More...
enum class  IterativePreconditioner { None , Diagonal }
 Preconditioner for iterative solvers. More...
enum class  NormType { L1 , L2 , Inf , Frobenius }
 Norm type selection. More...
enum class  PolynomialChaosFamily { Hermite , Legendre , Jacobi , Laguerre }
 Univariate Askey-scheme family used for a PCE input dimension. More...
enum class  PolynomialChaosTruncation { TotalOrder , TensorProduct }
 Multi-index truncation strategy for a multidimensional basis. More...
enum class  StochasticQuadratureRule { Gauss , ClenshawCurtis , GaussKronrod15 , AutoNested }
 One-dimensional rule family used to generate stochastic quadrature nodes. More...
enum class  RootSolveStrategy {
  Auto , TrustRegionNewton , LineSearchNewton , QuasiNewtonBroyden ,
  PseudoTransientContinuation
}
 Numeric nonlinear solver strategy selection. More...
enum class  RootSolveMethod {
  None , TrustRegionNewton , LineSearchNewton , QuasiNewtonBroyden ,
  PseudoTransientContinuation
}
 Numeric nonlinear solver method actually used. More...
enum class  RBFKernel {
  ThinPlateSpline , Multiquadric , Gaussian , Linear ,
  Cubic
}
 Radial basis function kernel types for scattered interpolation. More...
enum class  SigmoidType { Tanh , Logistic , Arctan , Polynomial }
 Sigmoid shape selection. More...
enum class  BirkhoffScheme { LGL , CGL }
 Available Birkhoff node distributions. More...
enum class  CollocationScheme { Trapezoidal , HermiteSimpson }
 Collocation scheme for dynamics discretization. More...
enum class  Solver { Ipopt , Snopt , QpOases }
 Available NLP solvers. More...
enum class  PseudospectralScheme { LGL , CGL }
 Available pseudospectral node distributions. More...
enum class  ScalingIssueLevel { Warning , Critical }
 Severity used by Opti scaling diagnostics. More...
enum class  ScalingIssueKind { Variable , Constraint , Objective , Summary }
 Diagnostic category for a scaling issue. More...

Functions

StructuralSensitivityReport analyze_structural_observability (const Function &fn, int state_input_idx=0, const StructuralSensitivityOptions &opts={})
 Analyze which states are structurally observable from selected outputs.
StructuralSensitivityReport analyze_structural_identifiability (const Function &fn, int parameter_input_idx, const StructuralSensitivityOptions &opts={})
 Analyze which parameters are structurally identifiable from selected outputs.
StructuralDiagnosticsReport analyze_structural_diagnostics (const Function &fn, const StructuralDiagnosticsOptions &opts)
 Run structural observability and identifiability checks together.
template<int NInputs, int NOutputs, typename Func>
Function make_function (const std::string &name, Func &&fn)
 Create a Function from a lambda expression.
template<int NInputs, typename Func>
Function make_function (const std::string &name, const std::vector< std::string > &input_names, Func &&fn)
 Create a Function from a lambda with named inputs.
template<typename Derived>
void print (const std::string &label, const Eigen::MatrixBase< Derived > &mat)
 Print a matrix to stdout with a label.
template<typename Derived>
void disp (const std::string &label, const Eigen::MatrixBase< Derived > &mat)
 Deprecated alias for print.
template<typename Derived>
auto eval (const Eigen::MatrixBase< Derived > &mat)
 Evaluate a symbolic matrix to a numeric Eigen matrix.
double eval (const SymbolicScalar &val)
 Evaluate a symbolic scalar to a double.
template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
eval (const T &val)
 Passthrough eval for numeric types.
void export_graph_dot (const SymbolicScalar &expr, const std::string &filename, const std::string &name="expression")
 Export a symbolic expression to DOT format for visualization.
bool render_graph (const std::string &dot_file, const std::string &output_file)
 Export a janus::Function to DOT format for visualization.
bool visualize_graph (const SymbolicScalar &expr, const std::string &output_base)
 Convenience function: export expression to DOT and render to PDF.
void export_graph_html (const SymbolicScalar &expr, const std::string &filename, const std::string &name="expression")
 Export a symbolic expression to an interactive HTML file.
void export_sx_graph_dot (const casadi::SX &expr, const std::string &filename, const std::string &name="expression")
 Export an SX expression to DOT format for deep visualization.
void export_sx_graph_html (const casadi::SX &expr, const std::string &filename, const std::string &name="expression")
 Export an SX expression to an interactive HTML file for deep visualization.
void export_graph_deep (const casadi::Function &fn, const std::string &filename, DeepGraphFormat format=DeepGraphFormat::HTML, const std::string &name="")
 Export a CasADi Function to deep graph format showing all operations.
bool visualize_graph_deep (const casadi::Function &fn, const std::string &output_base)
 Convenience function: export Function to deep graph and render to PDF.
SymbolicScalar sym (const std::string &name)
 Create a named symbolic scalar variable.
SymbolicScalar sym (const std::string &name, int rows, int cols=1)
 Create a named symbolic matrix variable.
SymbolicVector sym_vector (const std::string &name, int size)
 Create a named symbolic vector (returns SymbolicVector).
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.
SymbolicScalar as_mx (const SymbolicVector &v)
 Get the underlying MX representation of a SymbolicVector.
template<typename Derived>
casadi::MX to_mx (const Eigen::MatrixBase< Derived > &e)
 Convert Eigen matrix of MX (or numeric) to CasADi MX.
Eigen::Matrix< casadi::MX, Eigen::Dynamic, Eigen::Dynamic > to_eigen (const casadi::MX &m)
 Convert CasADi MX to Eigen matrix of MX.
SymbolicVector as_vector (const casadi::MX &m)
 Convert CasADi MX vector to SymbolicVector (Eigen container of MX).
SymbolicVector to_eigen_vec (const casadi::MX &m)
 Backwards compatibility alias for as_vector.
SparsityPattern sparsity_of_jacobian (const SymbolicScalar &expr, const SymbolicScalar &vars)
 Get Jacobian sparsity without computing the full Jacobian.
SparsityPattern sparsity_of_hessian (const SymbolicScalar &expr, const SymbolicScalar &vars)
 Get Hessian sparsity of a scalar expression.
SparsityPattern get_jacobian_sparsity (const Function &fn, int output_idx=0, int input_idx=0)
 Get sparsity of a janus::Function Jacobian.
SparsityPattern get_hessian_sparsity (const Function &fn, int output_idx=0, int input_idx=0)
 Get Hessian sparsity of a scalar janus::Function output.
SparsityPattern get_sparsity_in (const Function &fn, int input_idx=0)
 Get input sparsity of a janus::Function.
SparsityPattern get_sparsity_out (const Function &fn, int output_idx=0)
 Get output sparsity of a janus::Function.
SparseJacobianEvaluator sparse_jacobian (const SymbolicArg &expression, const SymbolicArg &variables, const std::string &name="")
 Compile a sparse Jacobian evaluator from symbolic expressions.
SparseJacobianEvaluator sparse_jacobian (const std::vector< SymbolicArg > &expressions, const std::vector< SymbolicArg > &variables, const std::string &name="")
 Compile a sparse Jacobian evaluator from vector arguments.
SparseJacobianEvaluator sparse_jacobian (const Function &fn, int output_idx=0, int input_idx=0, const std::string &name="")
 Compile a sparse Jacobian evaluator from a janus::Function.
SparseHessianEvaluator sparse_hessian (const SymbolicArg &expression, const SymbolicArg &variables, const std::string &name="")
 Compile a sparse Hessian evaluator from symbolic expressions.
SparseHessianEvaluator sparse_hessian (const SymbolicArg &expression, const std::vector< SymbolicArg > &variables, const std::string &name="")
 Compile a sparse Hessian evaluator from vector arguments.
SparseHessianEvaluator sparse_hessian (const Function &fn, int output_idx=0, int input_idx=0, const std::string &name="")
 Compile a sparse Hessian evaluator from a janus::Function.
template<typename Func>
SparsityPattern nan_propagation_sparsity (Func &&fn, int n_inputs, int n_outputs, const NaNSparsityOptions &opts={})
 Detect Jacobian sparsity using NaN propagation.
SparsityPattern nan_propagation_sparsity (const Function &fn, const NaNSparsityOptions &opts={})
 Detect Jacobian sparsity of a janus::Function using NaN propagation.
AliasEliminationResult alias_eliminate (const Function &fn, const StructuralTransformOptions &opts={})
 Eliminate trivial affine alias rows from a selected residual block.
BLTDecomposition block_triangularize (const Function &fn, const StructuralTransformOptions &opts={})
 Compute a block-triangular decomposition of a selected residual block.
StructuralAnalysis structural_analyze (const Function &fn, const StructuralTransformOptions &opts={})
 Run alias elimination followed by BLT decomposition.
template<JanusScalar T>
abs (const T &x)
 Computes the absolute value of a scalar.
template<typename Derived>
auto abs (const Eigen::MatrixBase< Derived > &x)
 Computes absolute value element-wise for a matrix.
template<JanusScalar T>
sqrt (const T &x)
 Computes the square root of a scalar.
template<typename Derived>
auto sqrt (const Eigen::MatrixBase< Derived > &x)
 Computes square root element-wise for a matrix.
template<JanusScalar T>
pow (const T &base, const T &exponent)
 Computes the power function: base^exponent.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
pow (const T &base, double exponent)
 Computes power function base^exponent for scalars (mixed types).
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
pow (double base, const T &exponent)
 Computes power function base^exponent for scalars (mixed types: double base).
template<typename Derived, typename Scalar>
auto pow (const Eigen::MatrixBase< Derived > &base, const Scalar &exponent)
 Computes power function element-wise for a matrix.
template<JanusScalar T>
exp (const T &x)
 Computes the exponential function e^x.
template<typename Derived>
auto exp (const Eigen::MatrixBase< Derived > &x)
 Computes exponential function element-wise for a matrix.
template<JanusScalar T>
log (const T &x)
 Computes the natural logarithm of x.
template<typename Derived>
auto log (const Eigen::MatrixBase< Derived > &x)
 Computes natural logarithm element-wise for a matrix.
template<JanusScalar T>
log10 (const T &x)
 Computes the base-10 logarithm of x.
template<typename Derived>
auto log10 (const Eigen::MatrixBase< Derived > &x)
 Computes base-10 logarithm element-wise for a matrix.
template<JanusScalar T>
sinh (const T &x)
 Computes hyperbolic sine.
template<typename Derived>
auto sinh (const Eigen::MatrixBase< Derived > &x)
 Computes hyperbolic sine element-wise for a matrix.
template<JanusScalar T>
cosh (const T &x)
 Computes hyperbolic cosine of x.
template<typename Derived>
auto cosh (const Eigen::MatrixBase< Derived > &x)
 Computes hyperbolic cosine element-wise for a matrix.
template<JanusScalar T>
tanh (const T &x)
 Computes hyperbolic tangent of x.
template<typename Derived>
auto tanh (const Eigen::MatrixBase< Derived > &x)
 Computes hyperbolic tangent element-wise for a matrix.
template<JanusScalar T>
floor (const T &x)
 Computes floor of x.
template<typename Derived>
auto floor (const Eigen::MatrixBase< Derived > &x)
 Computes floor element-wise for a matrix.
template<JanusScalar T>
ceil (const T &x)
 Computes ceiling of x.
template<typename Derived>
auto ceil (const Eigen::MatrixBase< Derived > &x)
 Computes ceiling element-wise for a matrix.
template<JanusScalar T>
sign (const T &x)
 Computes sign of x.
template<typename Derived>
auto sign (const Eigen::MatrixBase< Derived > &x)
 Computes sign element-wise for a matrix.
template<JanusScalar T>
fmod (const T &x, const T &y)
 Computes floating-point remainder of x/y.
template<typename Derived, typename Scalar>
auto fmod (const Eigen::MatrixBase< Derived > &x, const Scalar &y)
 Computes floating-point remainder element-wise for a matrix.
template<JanusScalar T>
log2 (const T &x)
 Computes base-2 logarithm of x.
template<typename Derived>
auto log2 (const Eigen::MatrixBase< Derived > &x)
 Computes base-2 logarithm element-wise for a matrix.
template<JanusScalar T>
exp2 (const T &x)
 Computes 2^x.
template<typename Derived>
auto exp2 (const Eigen::MatrixBase< Derived > &x)
 Computes 2^x element-wise for a matrix.
template<JanusScalar T>
cbrt (const T &x)
 Computes cube root of x.
template<typename Derived>
auto cbrt (const Eigen::MatrixBase< Derived > &x)
 Computes cube root element-wise for a matrix.
template<JanusScalar T>
round (const T &x)
 Rounds x to the nearest integer.
template<typename Derived>
auto round (const Eigen::MatrixBase< Derived > &x)
 Rounds element-wise for a matrix.
template<JanusScalar T>
trunc (const T &x)
 Truncates x toward zero.
template<typename Derived>
auto trunc (const Eigen::MatrixBase< Derived > &x)
 Truncates element-wise for a matrix.
template<JanusScalar T>
hypot (const T &x, const T &y)
 Computes sqrt(x^2 + y^2) without undue overflow/underflow.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
hypot (const T &x, double y)
 Computes hypot(x, y) with mixed types.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
hypot (double x, const T &y)
 Computes hypot(x, y) with mixed types (double first).
template<typename Derived>
auto hypot (const Eigen::MatrixBase< Derived > &x, const Eigen::MatrixBase< Derived > &y)
 Computes hypot element-wise for matrices.
template<JanusScalar T>
expm1 (const T &x)
 Computes exp(x) - 1, accurate for small x.
template<typename Derived>
auto expm1 (const Eigen::MatrixBase< Derived > &x)
 Computes expm1 element-wise for a matrix.
template<JanusScalar T>
log1p (const T &x)
 Computes log(1 + x), accurate for small x.
template<typename Derived>
auto log1p (const Eigen::MatrixBase< Derived > &x)
 Computes log1p element-wise for a matrix.
template<JanusScalar T>
copysign (const T &x, const T &y)
 Returns magnitude of x with sign of y.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
copysign (const T &x, double y)
 Copysign with mixed types.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
copysign (double x, const T &y)
 Copysign with mixed types (double magnitude).
template<typename Derived>
auto copysign (const Eigen::MatrixBase< Derived > &x, const Eigen::MatrixBase< Derived > &y)
 Copysign element-wise for matrices.
template<JanusScalar T>
square (const T &x)
 Computes x^2 (more efficient than pow(x, 2)).
template<typename Derived>
auto square (const Eigen::MatrixBase< Derived > &x)
 Computes square element-wise for a matrix.
template<typename Expr, typename... Vars>
auto jacobian (const Expr &expression, const Vars &...variables)
 Computes Jacobian of an expression with respect to variables.
SensitivityRecommendation select_sensitivity_regime (int parameter_count, int output_count, int horizon_length=1, bool stiff=false, const SensitivitySwitchOptions &opts=SensitivitySwitchOptions())
 Recommend a sensitivity regime from parameter/output counts.
SensitivityRecommendation select_sensitivity_regime (const Function &fn, int output_idx=0, int input_idx=0, int horizon_length=1, bool stiff=false, const SensitivitySwitchOptions &opts=SensitivitySwitchOptions())
 Recommend a sensitivity regime for a selected janus::Function block.
Function sensitivity_jacobian (const Function &fn, int output_idx=0, int input_idx=0, int horizon_length=1, bool stiff=false, const SensitivitySwitchOptions &opts=SensitivitySwitchOptions())
 Build a Jacobian function for one output/input block using the recommended regime.
auto jacobian (const std::vector< SymbolicArg > &expressions, const std::vector< SymbolicArg > &variables)
 Computes Jacobian with vector arguments (expressions and variables).
SymbolicVector sym_gradient (const SymbolicArg &expr, const SymbolicArg &vars)
 Symbolic gradient (for scalar-output functions).
SymbolicMatrix hessian (const SymbolicArg &expr, const SymbolicArg &vars)
 Hessian matrix (second-order derivatives).
SymbolicMatrix hessian_lagrangian (const SymbolicArg &objective, const SymbolicArg &constraints, const SymbolicArg &vars, const SymbolicArg &multipliers)
 Hessian of Lagrangian for constrained optimization.
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.
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.
Function hessian_vector_product (const Function &fn, int output_idx=0, int input_idx=0)
 Build a matrix-free Hessian-vector product function for one scalar output/input block.
Function lagrangian_hessian_vector_product (const Function &fn, int objective_output_idx, int constraint_output_idx, int input_idx=0)
 Build a Lagrangian Hessian-vector product function for optimization workflows.
SymbolicVector sym_gradient (const SymbolicArg &expr, const std::vector< SymbolicArg > &vars)
 Symbolic gradient with vector of variables.
SymbolicMatrix hessian (const SymbolicArg &expr, const std::vector< SymbolicArg > &vars)
 Hessian with vector of variables.
SymbolicMatrix hessian_lagrangian (const SymbolicArg &objective, const SymbolicArg &constraints, const std::vector< SymbolicArg > &vars, const SymbolicArg &multipliers)
 Hessian of Lagrangian with vector inputs.
SymbolicMatrix hessian_vector_product (const SymbolicArg &expr, const std::vector< SymbolicArg > &vars, const SymbolicArg &direction)
 Hessian-vector product with vector of variables.
SymbolicMatrix lagrangian_hessian_vector_product (const SymbolicArg &objective, const SymbolicArg &constraints, const std::vector< SymbolicArg > &vars, const SymbolicArg &multipliers, const SymbolicArg &direction)
 Lagrangian Hessian-vector product with vector of variables.
template<typename Derived>
auto diff (const Eigen::MatrixBase< Derived > &v)
 Computes adjacent differences of a vector Returns a vector of size N-1 where out[i] = v[i+1] - v[i].
template<typename DerivedY, typename DerivedX>
auto trapz (const Eigen::MatrixBase< DerivedY > &y, const Eigen::MatrixBase< DerivedX > &x)
 Computes trapezoidal integration Approximation of integral of y(x) using trapezoidal rule.
template<typename DerivedY, typename DerivedX>
auto cumtrapz (const Eigen::MatrixBase< DerivedY > &y, const Eigen::MatrixBase< DerivedX > &x)
 Computes the cumulative trapezoidal integral.
template<typename DerivedY, JanusScalar Spacing = double>
auto cumtrapz (const Eigen::MatrixBase< DerivedY > &y, const Spacing &dx=1.0)
 Computes the cumulative trapezoidal integral with uniform spacing.
template<typename DerivedY, typename DerivedX>
auto gradient_1d (const Eigen::MatrixBase< DerivedY > &y, const Eigen::MatrixBase< DerivedX > &x)
 Computes gradient of 1D data using central differences.
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.
template<typename DerivedF, typename Spacing = double, typename Period>
auto gradient_periodic (const Eigen::MatrixBase< DerivedF > &f, const Spacing &dx, const Period &period, int edge_order=1, int n=1)
 Computes gradient with periodic boundary conditions.
IntegrationMethod parse_integration_method (const std::string &method)
 Parse integration method from string.
template<typename Scalar>
std::pair< Scalar, Scalar > forward_euler_weights (Scalar h)
 Forward Euler (explicit) differentiation weights.
template<typename Scalar>
std::pair< Scalar, Scalar > backward_euler_weights (Scalar h)
 Backward Euler (implicit) differentiation weights.
template<typename Scalar>
std::pair< Scalar, Scalar > central_difference_weights (Scalar h)
 Central difference differentiation weights.
template<typename Scalar>
std::pair< Scalar, Scalar > trapezoidal_weights (Scalar h)
 Trapezoidal integration weights.
template<typename Scalar>
JanusVector< Scalar > forward_difference (const JanusVector< Scalar > &f, const JanusVector< Scalar > &x)
 Compute derivative using forward difference.
template<typename Scalar>
JanusVector< Scalar > backward_difference (const JanusVector< Scalar > &f, const JanusVector< Scalar > &x)
 Compute derivative using backward difference.
template<typename Scalar>
JanusVector< Scalar > central_difference (const JanusVector< Scalar > &f, const JanusVector< Scalar > &x)
 Compute derivative using central difference.
template<typename Scalar>
JanusVector< Scalar > integration_defects (const JanusVector< Scalar > &x, const JanusVector< Scalar > &xdot, const JanusVector< Scalar > &t, IntegrationMethod method=IntegrationMethod::Trapezoidal)
 Compute integration defects for derivative constraints.
template<typename Scalar>
JanusVector< Scalar > finite_difference_coefficients (const JanusVector< Scalar > &x, Scalar x0=Scalar(0.0), int derivative_degree=1)
 Computes finite difference coefficients for arbitrary grids.
template<typename Func, typename T>
QuadResult< T > quad (Func &&func, T a, T b, double abstol=1e-8, double reltol=1e-6)
 Compute definite integral using adaptive quadrature (numeric) or CVODES (symbolic).
QuadResult< SymbolicScalarquad (const SymbolicScalar &expr, const SymbolicScalar &variable, double a, double b, double abstol=1e-8, double reltol=1e-6)
 Compute definite integral of a symbolic expression using CasADi CVODES.
template<typename Func>
OdeResult< double > solve_ivp (Func &&fun, std::pair< double, double > t_span, const NumericVector &y0, int n_eval=100, double abstol=1e-8, double reltol=1e-6)
 Solve initial value problem: dy/dt = f(t, y), y(t0) = y0.
template<typename Func>
OdeResult< double > solve_ivp (Func &&fun, std::pair< double, double > t_span, std::initializer_list< double > y0_init, int n_eval=100, double abstol=1e-8, double reltol=1e-6)
 Convenience overload: solve_ivp with initializer list for y0.
template<typename AccelFunc>
SecondOrderOdeResult< double > solve_second_order_ivp (AccelFunc &&acceleration, std::pair< double, double > t_span, const NumericVector &q0, const NumericVector &v0, int n_eval=100, const SecondOrderIvpOptions &opts={})
 Solve a second-order IVP q'' = a(t, q), q(t0) = q0, v(t0) = v0.
template<typename AccelFunc>
SecondOrderOdeResult< double > solve_second_order_ivp (AccelFunc &&acceleration, std::pair< double, double > t_span, std::initializer_list< double > q0_init, std::initializer_list< double > v0_init, int n_eval=100, const SecondOrderIvpOptions &opts={})
 Convenience overload for second-order IVPs using initializer lists.
template<typename RhsFunc, typename MassFunc>
OdeResult< double > solve_ivp_mass_matrix (RhsFunc &&rhs, MassFunc &&mass_matrix, std::pair< double, double > t_span, const NumericVector &y0, int n_eval=100, const MassMatrixIvpOptions &opts={})
 Solve M(t, y) y' = f(t, y) with a native numeric stiff integrator.
template<typename RhsFunc, typename MassFunc>
OdeResult< double > solve_ivp_mass_matrix (RhsFunc &&rhs, MassFunc &&mass_matrix, std::pair< double, double > t_span, std::initializer_list< double > y0_init, int n_eval=100, const MassMatrixIvpOptions &opts={})
 Convenience overload for mass-matrix IVPs using initializer lists.
OdeResult< double > solve_ivp_mass_matrix_expr (const SymbolicScalar &rhs_expr, const SymbolicScalar &mass_expr, const SymbolicScalar &t_var, const SymbolicScalar &y_var, std::pair< double, double > t_span, const NumericVector &y0, int n_eval=100, const MassMatrixIvpOptions &opts={})
 Solve a symbolic mass-matrix IVP using CasADi IDAS.
template<typename Func>
OdeResult< SymbolicScalarsolve_ivp_symbolic (Func &&fun, std::pair< double, double > t_span, const Eigen::VectorXd &y0, int n_eval=100, double abstol=1e-8, double reltol=1e-6)
 Solve IVP with symbolic ODE function (CasADi CVODES backend).
OdeResult< double > solve_ivp_expr (const SymbolicScalar &ode_expr, const SymbolicScalar &t_var, const SymbolicScalar &y_var, std::pair< double, double > t_span, const NumericVector &y0, int n_eval=100, double abstol=1e-8, double reltol=1e-6)
 Solve IVP with a symbolic expression directly (expression-based API).
template<typename DerivedF, typename DerivedX>
JanusVector< typename DerivedF::Scalar > integrate_discrete_intervals (const Eigen::MatrixBase< DerivedF > &f, const Eigen::MatrixBase< DerivedX > &x, bool multiply_by_dx=true, const std::string &method="trapezoidal", const std::string &method_endpoints="lower_order")
 Integrates discrete samples using reconstruction methods.
template<typename DerivedF, typename DerivedX>
JanusVector< typename DerivedF::Scalar > integrate_discrete_squared_curvature (const Eigen::MatrixBase< DerivedF > &f, const Eigen::MatrixBase< DerivedX > &x, const std::string &method="simpson")
 Computes the integral of squared curvature over each interval.
template<typename Scalar, typename Func>
JanusVector< Scalar > euler_step (Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
 Forward Euler integration step.
template<typename Scalar, typename Func>
JanusVector< Scalar > rk2_step (Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
 Heun's method (RK2) integration step.
template<typename Scalar, typename Func>
JanusVector< Scalar > rk4_step (Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
 Classic 4th-order Runge-Kutta integration step.
template<typename Scalar, typename AccelFunc>
SecondOrderStepResult< Scalar > stormer_verlet_step (AccelFunc &&acceleration, const JanusVector< Scalar > &q, const JanusVector< Scalar > &v, Scalar t, Scalar dt)
 Stormer-Verlet / velocity-Verlet step for q'' = a(t, q).
template<typename Scalar, typename AccelFunc>
SecondOrderStepResult< Scalar > rkn4_step (AccelFunc &&acceleration, const JanusVector< Scalar > &q, const JanusVector< Scalar > &v, Scalar t, Scalar dt)
 Classical 4th-order Runge-Kutta-Nystrom step for q'' = a(t, q).
template<typename Scalar, typename Func>
RK45Result< Scalar > rk45_step (Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
 Dormand-Prince RK45 integration step with embedded error estimate.
template<typename Scalar>
JanusVector< Scalar > interpn (const std::vector< NumericVector > &points, const NumericVector &values_flat, const JanusMatrix< Scalar > &xi, InterpolationMethod method=InterpolationMethod::Linear, std::optional< Scalar > fill_value=std::nullopt)
 N-dimensional interpolation on regular grids (backwards compatibility).
template<typename Scalar>
SymbolicVector interpn (const std::vector< NumericVector > &points, const SymbolicVector &values_flat, const JanusMatrix< Scalar > &xi, InterpolationMethod method=InterpolationMethod::Linear, std::optional< SymbolicScalar > fill_value=std::nullopt)
 N-dimensional interpolation with symbolic table values.
template<typename DerivedA, typename DerivedB>
auto solve (const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &b)
 Solves linear system Ax = b using the default backend policy.
template<typename DerivedA, typename DerivedB>
auto solve (const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &b, const LinearSolvePolicy &policy)
 Solves linear system Ax = b using an explicit backend policy.
template<typename DerivedB>
auto solve (const SparseMatrix &A, const Eigen::MatrixBase< DerivedB > &b)
 Solve a numeric sparse linear system with a sparse-aware default backend.
template<typename DerivedB>
auto solve (const SparseMatrix &A, const Eigen::MatrixBase< DerivedB > &b, const LinearSolvePolicy &policy)
 Solve a numeric sparse linear system using an explicit backend policy.
template<typename DerivedX, typename DerivedY>
auto outer (const Eigen::MatrixBase< DerivedX > &x, const Eigen::MatrixBase< DerivedY > &y)
 Computes outer product x * y^T.
template<typename DerivedA, typename DerivedB>
auto dot (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Computes dot product of two vectors.
template<typename DerivedA, typename DerivedB>
auto cross (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Computes 3D cross product.
template<typename Derived>
auto inv (const Eigen::MatrixBase< Derived > &A)
 Computes matrix inverse.
template<typename Derived>
auto det (const Eigen::MatrixBase< Derived > &A)
 Computes matrix determinant.
template<typename DerivedA, typename DerivedB>
auto inner (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Computes inner product of two vectors (dot product).
template<typename Derived>
auto pinv (const Eigen::MatrixBase< Derived > &A)
 Computes Moore-Penrose pseudo-inverse.
template<typename Derived>
auto norm (const Eigen::MatrixBase< Derived > &x, NormType type=NormType::L2)
 Computes vector/matrix norm.
template<typename Derived>
auto eig (const Eigen::MatrixBase< Derived > &A)
 Computes the eigendecomposition of a square matrix with a real spectrum.
template<typename Derived>
auto eig_symmetric (const Eigen::MatrixBase< Derived > &A)
 Computes the eigendecomposition of a symmetric matrix.
template<typename T>
std::tuple< T, T, T, T, T, T > inv_symmetric_3x3_explicit (const T &m11, const T &m22, const T &m33, const T &m12, const T &m23, const T &m13)
 Explicit inverse of a symmetric 3x3 matrix.
SparseMatrix sparse_from_triplets (int rows, int cols, const std::vector< SparseTriplet > &triplets)
 Create sparse matrix from triplets.
SparseMatrix to_sparse (const NumericMatrix &dense, double tol=0.0)
 Convert dense matrix to sparse.
NumericMatrix to_dense (const SparseMatrix &sparse)
 Convert sparse matrix to dense.
SparseMatrix sparse_identity (int n)
 Create identity sparse matrix.
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 DerivedCond, typename DerivedTrue, typename DerivedFalse>
auto where (const Eigen::ArrayBase< DerivedCond > &cond, const Eigen::MatrixBase< DerivedTrue > &if_true, const Eigen::MatrixBase< DerivedFalse > &if_false)
 Element-wise select.
template<JanusScalar T1, JanusScalar T2>
auto min (const T1 &a, const T2 &b)
 Computes minimum of two values.
template<typename Derived>
auto min (const Eigen::MatrixBase< Derived > &a, const Eigen::MatrixBase< Derived > &b)
 Computes minimum element-wise for a matrix/vector.
template<JanusScalar T1, JanusScalar T2>
auto max (const T1 &a, const T2 &b)
 Computes maximum of two values.
template<typename Derived>
auto max (const Eigen::MatrixBase< Derived > &a, const Eigen::MatrixBase< Derived > &b)
 Computes maximum element-wise for a matrix/vector.
template<JanusScalar T, JanusScalar TLow, JanusScalar THigh>
auto clamp (const T &val, const TLow &low, const THigh &high)
 Clamps value between low and high.
template<typename Derived, typename Scalar>
auto clamp (const Eigen::MatrixBase< Derived > &val, const Scalar &low, const Scalar &high)
 Clamps values element-wise for a matrix/vector.
template<typename DerivedA, typename DerivedB>
auto lt (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise less than comparison.
template<typename DerivedA, typename DerivedB>
auto gt (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise greater than comparison.
template<typename DerivedA, typename DerivedB>
auto le (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise less than or equal comparison.
template<typename DerivedA, typename DerivedB>
auto ge (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise greater than or equal comparison.
template<typename DerivedA, typename DerivedB>
auto eq (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise equality comparison.
template<typename DerivedA, typename DerivedB>
auto neq (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise inequality comparison.
template<JanusScalar T, JanusScalar TLow, JanusScalar THigh, JanusScalar Sharpness = double>
auto sigmoid_blend (const T &x, const TLow &val_low, const THigh &val_high, const Sharpness &sharpness=1.0)
 Smoothly blends between val_low and val_high using a sigmoid function blend = val_low + (val_high - val_low) * (1 / (1 + exp(-sharpness * x))).
template<typename Derived, typename Scalar>
auto sigmoid_blend (const Eigen::MatrixBase< Derived > &x, const Scalar &val_low, const Scalar &val_high, const Scalar &sharpness=1.0)
 Smoothly blends element-wise for a matrix using a sigmoid function.
template<JanusScalar T1, JanusScalar T2>
auto logical_and (const T1 &x1, const T2 &x2)
 Logical AND (x && y).
template<typename DerivedA, typename DerivedB>
auto logical_and (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise logical AND for matrices.
template<JanusScalar T1, JanusScalar T2>
auto logical_or (const T1 &x1, const T2 &x2)
 Logical OR (x || y).
template<typename DerivedA, typename DerivedB>
auto logical_or (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise logical OR for matrices.
template<JanusScalar T>
auto logical_not (const T &x)
 Logical NOT (!x).
template<typename Derived>
auto logical_not (const Eigen::MatrixBase< Derived > &a)
 Element-wise logical NOT for a matrix.
template<typename Derived>
auto all (const Eigen::MatrixBase< Derived > &a)
 Returns true if all elements are true (non-zero).
template<typename Derived>
auto any (const Eigen::MatrixBase< Derived > &a)
 Returns true if any element is true (non-zero).
template<typename CondType, typename Scalar>
Scalar select (const std::vector< CondType > &conditions, const std::vector< Scalar > &values, const Scalar &default_value)
 Multi-way conditional selection (cleaner alternative to nested where).
template<typename CondType, typename Scalar>
Scalar select (std::initializer_list< CondType > conditions, std::initializer_list< Scalar > values, const Scalar &default_value)
std::pair< double, double > legendre_poly (int n, double x)
 Evaluate Legendre polynomial P_n(x) and derivative P'_n(x).
std::pair< NumericVector, NumericVectorgauss_legendre_rule (int n)
 Gauss-Legendre nodes and weights on [-1, 1].
NumericVector legendre_poly_vec (int n, const NumericVector &x)
 Evaluate P_n(x) at each x in vector.
NumericVector lgl_nodes (int N)
 Compute Legendre-Gauss-Lobatto nodes on [-1, 1].
NumericVector cgl_nodes (int N)
 Compute Chebyshev-Gauss-Lobatto nodes on [-1, 1].
NumericVector lgl_weights (int N, const NumericVector &nodes)
 LGL quadrature weights.
NumericVector cgl_weights (int N, const NumericVector &nodes)
 CGL (Clenshaw-Curtis) quadrature weights on [-1, 1].
NumericVector barycentric_weights (const NumericVector &nodes)
 Compute barycentric interpolation weights for the given nodes.
double barycentric_basis_eval (const NumericVector &nodes, const NumericVector &bary_w, int j, double s)
 Evaluate the j-th Lagrange basis polynomial at s using barycentric form.
NumericMatrix birkhoff_integration_matrix (const NumericVector &nodes)
 Compute Birkhoff integration matrix B^a for the node set.
NumericMatrix spectral_diff_matrix (const NumericVector &nodes)
 Spectral differentiation matrix using barycentric weights.
PolynomialChaosDimension hermite_dimension ()
 Create a standard normal (Hermite) dimension.
PolynomialChaosDimension legendre_dimension ()
 Create a uniform (Legendre) dimension on [-1, 1].
PolynomialChaosDimension jacobi_dimension (double alpha, double beta)
 Create a Beta-family (Jacobi) dimension on [-1, 1].
PolynomialChaosDimension laguerre_dimension (double alpha=0.0)
 Create a Gamma-family (Laguerre) dimension on [0, inf).
template<JanusScalar Scalar>
Scalar pce_polynomial (const PolynomialChaosDimension &dimension, int degree, const Scalar &x, bool normalized=true)
 Evaluate a univariate chaos basis polynomial.
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>
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>
JanusMatrix< Scalar > pce_projection_coefficients (const PolynomialChaosBasis &basis, const NumericMatrix &samples, const NumericVector &weights, const JanusMatrix< Scalar > &sample_values)
 Compute PCE projection coefficients from weighted samples (matrix).
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).
template<JanusScalar Scalar>
JanusMatrix< Scalar > pce_regression_coefficients (const PolynomialChaosBasis &basis, const NumericMatrix &samples, const JanusMatrix< Scalar > &sample_values, double ridge=1e-12)
 Compute PCE coefficients via least-squares regression (matrix).
template<JanusScalar Scalar>
Scalar pce_mean (const JanusVector< Scalar > &coefficients)
 Extract PCE mean (zeroth coefficient).
template<JanusScalar Scalar>
Scalar pce_variance (const PolynomialChaosBasis &basis, const JanusVector< Scalar > &coefficients)
 Compute PCE variance from coefficients.
UnivariateQuadratureRule stochastic_quadrature_rule (const PolynomialChaosDimension &dimension, int order, StochasticQuadratureRule rule=StochasticQuadratureRule::Gauss)
 Build a one-dimensional stochastic quadrature rule with a fixed order.
UnivariateQuadratureRule stochastic_quadrature_level (const PolynomialChaosDimension &dimension, int level, StochasticQuadratureRule rule=StochasticQuadratureRule::AutoNested)
 Build a one-dimensional stochastic quadrature rule from a refinement level.
StochasticQuadratureGrid tensor_product_quadrature (const std::vector< UnivariateQuadratureRule > &rules)
 Build the tensor-product grid from a list of one-dimensional rules.
StochasticQuadratureGrid smolyak_sparse_grid (const std::vector< PolynomialChaosDimension > &dimensions, int level, SmolyakQuadratureOptions options={})
 Build a Smolyak sparse grid on probability measures.
template<JanusScalar Scalar>
JanusVector< Scalar > pce_projection_coefficients (const PolynomialChaosBasis &basis, const UnivariateQuadratureRule &rule, const JanusVector< Scalar > &sample_values)
 Compute PCE projection coefficients using a univariate quadrature rule (vector).
template<JanusScalar Scalar>
JanusMatrix< Scalar > pce_projection_coefficients (const PolynomialChaosBasis &basis, const UnivariateQuadratureRule &rule, const JanusMatrix< Scalar > &sample_values)
 Compute PCE projection coefficients using a univariate quadrature rule (matrix).
template<JanusScalar Scalar>
JanusVector< Scalar > pce_projection_coefficients (const PolynomialChaosBasis &basis, const StochasticQuadratureGrid &grid, const JanusVector< Scalar > &sample_values)
 Compute PCE projection coefficients using a stochastic quadrature grid (vector).
template<JanusScalar Scalar>
JanusMatrix< Scalar > pce_projection_coefficients (const PolynomialChaosBasis &basis, const StochasticQuadratureGrid &grid, const JanusMatrix< Scalar > &sample_values)
 Compute PCE projection coefficients using a stochastic quadrature grid (matrix).
template<typename Scalar>
Quaternion< Scalar > slerp (const Quaternion< Scalar > &q0, const Quaternion< Scalar > &q1, Scalar t)
 Spherical Linear Interpolation (full fidelity).
template<typename Scalar>
RootResult< Scalar > rootfinder (const janus::Function &F, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &x0, const RootFinderOptions &opts={})
 Solve F(x) = 0 for x given an initial guess.
janus::Function create_implicit_function (const janus::Function &G, const Eigen::VectorXd &x_guess, const RootFinderOptions &opts={}, const ImplicitFunctionOptions &implicit_opts={})
 Create a differentiable implicit solve wrapper for G(...) = 0.
template<typename T>
Mat2< T > rotation_matrix_2d (const T &theta)
 Creates a 2x2 rotation matrix.
template<typename T>
Mat3< T > rotation_matrix_3d (const T &theta, int axis)
 Creates a 3x3 rotation matrix about a principal axis.
template<typename T>
Mat3< T > rotation_matrix_from_euler_angles (const T &roll, const T &pitch, const T &yaw)
 Creates a 3x3 rotation matrix from Euler angles (Yaw-Pitch-Roll sequence).
template<typename Derived>
auto is_valid_rotation_matrix (const Eigen::MatrixBase< Derived > &a, double tol=1e-9)
 Checks if matrix is a valid rotation matrix Checks determinant approx 1 and orthogonality (A^T * A approx I).
template<typename T>
JanusVector< T > linspace (const T &start, const T &end, int n)
 Generates linearly spaced vector.
template<typename T>
JanusVector< T > cosine_spacing (const T &start, const T &end, int n)
 Generates cosine spaced vector (denser at ends).
template<typename T>
JanusVector< T > sinspace (const T &start, const T &end, int n, bool reverse_spacing=false)
 Generates sine spaced vector (denser at start by default).
template<typename T>
JanusVector< T > logspace (const T &start, const T &end, int n)
 Generates logarithmically spaced vector (base 10).
template<typename T>
JanusVector< T > geomspace (const T &start, const T &end, int n)
 Generates geometrically spaced vector.
template<typename T>
auto softmax (const std::vector< T > &args, double softness=1.0)
 Computes the smooth maximum (LogSumExp) of a collection of values.
template<typename T1, typename T2>
auto softmax (const T1 &a, const T2 &b, double softness=1.0)
template<typename T>
auto softmin (const std::vector< T > &args, double softness=1.0)
 Computes the smooth minimum of a collection of values. softmin(x) = -softmax(-x).
template<typename T1, typename T2>
auto softmin (const T1 &a, const T2 &b, double softness=1.0)
template<JanusScalar T>
auto softplus (const T &x, double beta=1.0, double=20.0)
template<typename Derived>
auto softplus (const Eigen::MatrixBase< Derived > &x, double beta=1.0, double threshold=20.0)
template<typename T>
auto smooth_abs (const T &x, double hardness=1.0)
 Smooth approximation of absolute value.
template<typename T1, typename T2>
auto smooth_max (const T1 &a, const T2 &b, double hardness=1.0)
 Pairwise smooth maximum.
template<typename T1, typename T2>
auto smooth_min (const T1 &a, const T2 &b, double hardness=1.0)
 Pairwise smooth minimum.
template<typename TX, typename TLow, typename THigh>
auto smooth_clamp (const TX &x, const TLow &low, const THigh &high, double hardness=1.0)
 Smooth approximation of clamp(x, low, high).
template<JanusScalar T>
auto ks_max (const std::vector< T > &values, double rho=1.0)
 Kreisselmeier-Steinhauser smooth maximum aggregator.
template<typename Derived>
auto ks_max (const Eigen::MatrixBase< Derived > &values, double rho=1.0)
template<typename T>
auto sigmoid (const T &x, SigmoidType type=SigmoidType::Tanh, double norm_min=0.0, double norm_max=1.0)
 Sigmoid function with normalization capability.
template<typename T>
auto swish (const T &x, double beta=1.0)
 Swish activation function: x / (1 + exp(-beta * x)).
template<typename TSwitch, typename THigh, typename TLow>
auto blend (const TSwitch &switch_val, const THigh &val_high, const TLow &val_low)
 Smoothly blends between two values based on a switch parameter.
template<JanusScalar T>
sin (const T &x)
 Computes sine of x.
template<typename Derived>
auto sin (const Eigen::MatrixBase< Derived > &x)
 Computes sine element-wise for a matrix.
template<JanusScalar T>
cos (const T &x)
 Computes cosine of x.
template<typename Derived>
auto cos (const Eigen::MatrixBase< Derived > &x)
 Computes cosine element-wise for a matrix.
template<JanusScalar T>
tan (const T &x)
 Computes tangent of x.
template<typename Derived>
auto tan (const Eigen::MatrixBase< Derived > &x)
 Computes tangent element-wise for a matrix.
template<JanusScalar T>
asin (const T &x)
 Computes arc sine of x.
template<typename Derived>
auto asin (const Eigen::MatrixBase< Derived > &x)
 Computes arc sine element-wise for a matrix.
template<JanusScalar T>
acos (const T &x)
 Computes arc cosine of x.
template<typename Derived>
auto acos (const Eigen::MatrixBase< Derived > &x)
 Computes arc cosine element-wise for a matrix.
template<JanusScalar T>
atan (const T &x)
 Computes arc tangent of x.
template<typename Derived>
auto atan (const Eigen::MatrixBase< Derived > &x)
 Computes arc tangent element-wise for a matrix.
template<JanusScalar T>
atan2 (const T &y, const T &x)
 Computes arc tangent of y/x using signs of both arguments.
template<JanusScalar T>
asinh (const T &x)
 Computes inverse hyperbolic sine of x.
template<typename Derived>
auto asinh (const Eigen::MatrixBase< Derived > &x)
 Computes inverse hyperbolic sine element-wise for a matrix.
template<JanusScalar T>
acosh (const T &x)
 Computes inverse hyperbolic cosine of x.
template<typename Derived>
auto acosh (const Eigen::MatrixBase< Derived > &x)
 Computes inverse hyperbolic cosine element-wise for a matrix.
template<JanusScalar T>
atanh (const T &x)
 Computes inverse hyperbolic tangent of x.
template<typename Derived>
auto atanh (const Eigen::MatrixBase< Derived > &x)
 Computes inverse hyperbolic tangent element-wise for a matrix.
bool solver_available (Solver solver)
 Check if a solver is available in the current CasADi build.
const char * solver_name (Solver solver)
 Get the CasADi solver name string.

Variables

template<typename Scalar>
constexpr bool is_numeric_scalar_v = std::is_floating_point_v<Scalar> || std::is_integral_v<Scalar>
 Compile-time check for numeric scalar types.

Typedef Documentation

◆ BooleanType_t

template<typename T>
using janus::BooleanType_t = typename BooleanType<T>::type

◆ JanusMatrix

template<typename Scalar>
using janus::JanusMatrix = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>

Dynamic-size matrix for both numeric and symbolic backends.

Template Parameters
ScalarElement type (double or casadi::MX)
Examples
/home/runner/work/janus/janus/include/janus/math/Interpolate.hpp.

◆ JanusVector

template<typename Scalar>
using janus::JanusVector = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>

Dynamic-size column vector for both numeric and symbolic backends.

Template Parameters
ScalarElement type (double or casadi::MX)
Examples
/home/runner/work/janus/janus/include/janus/math/Interpolate.hpp.

◆ Mat2

template<typename Scalar>
using janus::Mat2 = Eigen::Matrix<Scalar, 2, 2>

◆ Mat3

template<typename Scalar>
using janus::Mat3 = Eigen::Matrix<Scalar, 3, 3>

◆ Mat4

template<typename Scalar>
using janus::Mat4 = Eigen::Matrix<Scalar, 4, 4>

◆ NumericMatrix

Eigen::MatrixXd equivalent.

◆ NumericScalar

using janus::NumericScalar = double

Numeric scalar type.

◆ NumericVector

Eigen::VectorXd equivalent.

◆ SparseMatrix

using janus::SparseMatrix = Eigen::SparseMatrix<double>

Sparse matrix types for efficient storage of large, sparse numeric data.

Note
For symbolic sparsity analysis, use janus::SparsityPattern.
See also
SparsityPattern Sparse numeric matrix (CSC)

◆ SparseTriplet

using janus::SparseTriplet = Eigen::Triplet<double>

(row, col, value) triplet

◆ SymbolicMatrix

Eigen matrix of MX elements.

◆ SymbolicScalar

◆ SymbolicVector

Eigen vector of MX elements.

◆ Vec2

template<typename Scalar>
using janus::Vec2 = Eigen::Matrix<Scalar, 2, 1>

Fixed-size vectors and matrices for performance-critical code.

Template Parameters
ScalarElement type (double or casadi::MX)

◆ Vec3

template<typename Scalar>
using janus::Vec3 = Eigen::Matrix<Scalar, 3, 1>

◆ Vec4

template<typename Scalar>
using janus::Vec4 = Eigen::Matrix<Scalar, 4, 1>

Enumeration Type Documentation

◆ BirkhoffScheme

enum class janus::BirkhoffScheme
strong

Available Birkhoff node distributions.

Enumerator
LGL 

Legendre-Gauss-Lobatto nodes.

CGL 

Chebyshev-Gauss-Lobatto nodes.

◆ CheckpointInterpolation

enum class janus::CheckpointInterpolation
strong

Checkpoint interpolation recommendation for long-horizon adjoints.

Enumerator
None 
Hermite 
Polynomial 

◆ CollocationScheme

enum class janus::CollocationScheme
strong

Collocation scheme for dynamics discretization.

Enumerator
Trapezoidal 

2nd order, implicit midpoint rule

HermiteSimpson 

4th order, uses midpoint interpolation

◆ DeepGraphFormat

enum class janus::DeepGraphFormat
strong

Export format for deep graph visualization.

Enumerator
DOT 

Graphviz DOT text format.

HTML 

Self-contained interactive HTML.

PDF 

Rendered PDF via Graphviz.

◆ DenseLinearSolver

enum class janus::DenseLinearSolver
strong

Dense linear solver algorithm.

Enumerator
ColPivHouseholderQR 

Column-pivoted Householder QR (default, general).

PartialPivLU 

Partial-pivot LU (square only).

FullPivLU 

Full-pivot LU (square only).

LLT 

Cholesky (SPD only).

LDLT 

LDLT (symmetric only).

◆ ExtrapolationMode

enum class janus::ExtrapolationMode
strong

Controls behavior when query points fall outside grid bounds.

Enumerator
Clamp 

Clamp queries to grid bounds (default, safe).

Linear 

Linear extrapolation from boundary slope (1D only).

Examples
/home/runner/work/janus/janus/include/janus/math/Interpolate.hpp.

◆ IntegrationMethod

enum class janus::IntegrationMethod
strong

Integration/differentiation method for trajectory optimization.

Enumerator
ForwardEuler 

First-order forward difference: x[i+1] - x[i] = xdot[i] * dt.

BackwardEuler 

First-order backward difference: x[i+1] - x[i] = xdot[i+1] * dt.

Trapezoidal 

Second-order trapezoidal: x[i+1] - x[i] = 0.5 * (xdot[i] + xdot[i+1]) * dt.

Midpoint 

Alias for Trapezoidal (same formula).

◆ InterpolationMethod

enum class janus::InterpolationMethod
strong

Supported interpolation methods.

Controls the interpolation algorithm used for both 1D and N-D interpolation.

Enumerator
Linear 

Piecewise linear (C0 continuous) - fast, simple.

Hermite 

Cubic Hermite/Catmull-Rom (C1 continuous) - smooth gradients.

BSpline 

Cubic B-spline (C2 continuous) - smoothest, good for optimization.

Nearest 

Nearest neighbor - fast, non-differentiable.

Examples
/home/runner/work/janus/janus/include/janus/math/Interpolate.hpp.

◆ IterativeKrylovSolver

enum class janus::IterativeKrylovSolver
strong

Iterative Krylov solver algorithm.

Enumerator
BiCGSTAB 

Biconjugate gradient stabilized.

GMRES 

Generalized minimal residual.

◆ IterativePreconditioner

enum class janus::IterativePreconditioner
strong

Preconditioner for iterative solvers.

Enumerator
None 

No preconditioning.

Diagonal 

Jacobi (diagonal) preconditioner.

◆ LinearSolveBackend

enum class janus::LinearSolveBackend
strong

Backend selection for linear system solves.

Enumerator
Dense 

Dense matrix factorization.

SparseDirect 

Sparse direct factorization.

IterativeKrylov 

Iterative Krylov subspace method.

◆ MapParallelization

enum class janus::MapParallelization
strong

Batch mapping backend for janus::Function::map().

See also
Function::map
Enumerator
Parallel 

CasADi OpenMP map backend (falls back to serial if unavailable).

Serial 

CasADi serial map backend.

Unroll 

CasADi unrolled map backend.

◆ MassMatrixIntegratorMethod

Stepper selection for mass-matrix systems M(t, y) y' = f(t, y).

Enumerator
RosenbrockEuler 

One-stage linearly implicit Rosenbrock-Euler.

Bdf1 

Backward Euler / first-order BDF with Newton iterations.

◆ NormType

enum class janus::NormType
strong

Norm type selection.

Enumerator
L1 

L1 (Manhattan) norm.

L2 

L2 (Euclidean) norm.

Inf 

Infinity (max absolute) norm.

Frobenius 

Frobenius norm.

◆ PolynomialChaosFamily

enum class janus::PolynomialChaosFamily
strong

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

Enumerator
Hermite 

Standard normal random variable via probabilists' Hermite polynomials.

Legendre 

Uniform random variable on [-1, 1].

Jacobi 

Beta-family random variable on [-1, 1].

Laguerre 

Gamma / exponential-family random variable on [0, inf).

◆ PolynomialChaosTruncation

Multi-index truncation strategy for a multidimensional basis.

Enumerator
TotalOrder 
TensorProduct 

◆ PseudospectralScheme

enum class janus::PseudospectralScheme
strong

Available pseudospectral node distributions.

Enumerator
LGL 

Legendre-Gauss-Lobatto.

CGL 

Chebyshev-Gauss-Lobatto.

◆ RBFKernel

enum class janus::RBFKernel
strong

Radial basis function kernel types for scattered interpolation.

Enumerator
ThinPlateSpline 

r² log(r) - smooth, good default, no shape parameter

Multiquadric 

sqrt(1 + (ε*r)²) - adjustable shape parameter

Gaussian 

exp(-(ε*r)²) - localized influence

Linear 

r - simple, produces piecewise linear surface

Cubic 

r³ - smooth, commonly used

◆ RootSolveMethod

enum class janus::RootSolveMethod
strong

Numeric nonlinear solver method actually used.

Enumerator
None 

No method selected yet.

TrustRegionNewton 

Levenberg-Marquardt style trust-region Newton.

LineSearchNewton 

Exact-Jacobian Newton with backtracking line search.

QuasiNewtonBroyden 

Broyden updates after one exact Jacobian evaluation.

PseudoTransientContinuation 

Backward-Euler pseudo-transient continuation.

◆ RootSolveStrategy

enum class janus::RootSolveStrategy
strong

Numeric nonlinear solver strategy selection.

Enumerator
Auto 

Trust-region LM, then line-search Newton, Broyden, pseudo-transient.

TrustRegionNewton 

Levenberg-Marquardt style trust-region Newton.

LineSearchNewton 

Exact-Jacobian Newton with backtracking line search.

QuasiNewtonBroyden 

Broyden updates after one exact Jacobian evaluation.

PseudoTransientContinuation 

Backward-Euler pseudo-transient continuation.

◆ ScalingIssueKind

enum class janus::ScalingIssueKind
strong

Diagnostic category for a scaling issue.

Enumerator
Variable 

Issue with variable scaling.

Constraint 

Issue with constraint scaling.

Objective 

Issue with objective scaling.

Summary 

Aggregate issue across the problem.

◆ ScalingIssueLevel

enum class janus::ScalingIssueLevel
strong

Severity used by Opti scaling diagnostics.

See also
ScalingIssue for individual diagnostic items
Opti::analyze_scaling for generating diagnostics
Enumerator
Warning 

Potential scaling concern.

Critical 

Severe scaling issue likely to cause solver failure.

◆ SecondOrderIntegratorMethod

Stepper selection for second-order systems q'' = a(t, q).

Enumerator
StormerVerlet 

Symplectic Stormer-Verlet / velocity-Verlet.

RungeKuttaNystrom4 

Classical 4th-order Runge-Kutta-Nystrom.

◆ SensitivityRegime

enum class janus::SensitivityRegime
strong

Sensitivity regime selected for a Jacobian-like derivative workload.

Enumerator
Forward 

Many outputs, relatively few parameters.

Adjoint 

Few outputs, many parameters.

CheckpointedAdjoint 

Adjoint with checkpoint recommendations for long horizons.

◆ SigmoidType

enum class janus::SigmoidType
strong

Sigmoid shape selection.

Enumerator
Tanh 

Hyperbolic tangent.

Logistic 

Logistic / standard sigmoid.

Arctan 

Arc tangent based.

Polynomial 

Polynomial: x / sqrt(1 + x^2).

◆ Solver

enum class janus::Solver
strong

Available NLP solvers.

Solvers are provided via CasADi's nlpsol interface. IPOPT is always available. Others require separate installation.

See also
OptiOptions for solver configuration
Enumerator
Ipopt 

Interior Point OPTimizer (default, always available).

Snopt 

Sparse Nonlinear OPTimizer (requires license).

QpOases 

QP solver for QP subproblems.

◆ SparseDirectLinearSolver

Sparse direct solver algorithm.

Enumerator
SparseLU 

Sparse LU factorization.

SparseQR 

Sparse QR factorization.

SimplicialLLT 

Simplicial Cholesky (SPD only).

SimplicialLDLT 

Simplicial LDLT (symmetric only).

◆ SparseJacobianMode

enum class janus::SparseJacobianMode
strong

Preferred directional mode for a sparse Jacobian evaluator.

Enumerator
Forward 

Forward-mode (column compression).

Reverse 

Reverse-mode (row compression).

Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ StochasticQuadratureRule

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

Enumerator
Gauss 

Family-appropriate Gauss rule.

ClenshawCurtis 

Nested Clenshaw-Curtis-like rule on bounded support.

GaussKronrod15 

Embedded 7/15-point Legendre rule reused from quad(...).

AutoNested 

Use Clenshaw-Curtis on bounded families, Gauss otherwise.

◆ StructuralProperty

enum class janus::StructuralProperty
strong

Structural property being analyzed from a symbolic sensitivity pattern.

Enumerator
Observability 

State observability from outputs.

Identifiability 

Parameter identifiability from outputs.

Function Documentation

◆ abs() [1/2]

template<typename Derived>
auto janus::abs ( const Eigen::MatrixBase< Derived > & x)

Computes absolute value element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of absolute values

◆ abs() [2/2]

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() [1/2]

template<typename Derived>
auto janus::acos ( const Eigen::MatrixBase< Derived > & x)

Computes arc cosine element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of arc cosines

◆ acos() [2/2]

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)

◆ acosh() [1/2]

template<typename Derived>
auto janus::acosh ( const Eigen::MatrixBase< Derived > & x)

Computes inverse hyperbolic cosine element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of inverse hyperbolic cosines

◆ acosh() [2/2]

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

Computes inverse hyperbolic cosine of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value (must be >= 1)
Returns
Inverse hyperbolic cosine of x

◆ alias_eliminate()

AliasEliminationResult janus::alias_eliminate ( const Function & fn,
const StructuralTransformOptions & opts = {} )
inline

Eliminate trivial affine alias rows from a selected residual block.

Parameters
fnFunction containing the residual system
optsTransform options (input/output indices, alias thresholds)
Returns
Reduced function, reconstruction map, and substitution records
See also
block_triangularize, structural_analyze

◆ all()

template<typename Derived>
auto janus::all ( const Eigen::MatrixBase< Derived > & a)

Returns true if all elements are true (non-zero).

Parameters
aInput matrix/array
Returns
Boolean (numeric) or symbolic expression

◆ analyze_structural_diagnostics()

StructuralDiagnosticsReport janus::analyze_structural_diagnostics ( const Function & fn,
const StructuralDiagnosticsOptions & opts )
inline

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

◆ any()

template<typename Derived>
auto janus::any ( const Eigen::MatrixBase< Derived > & a)

Returns true if any element is true (non-zero).

Parameters
aInput matrix/array
Returns
Boolean (numeric) or symbolic expression

◆ as_mx()

SymbolicScalar janus::as_mx ( const SymbolicVector & v)
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.

Parameters
vSymbolicVector to convert
Returns
Single casadi::MX representing the vector
Examples
/home/runner/work/janus/janus/include/janus/math/Interpolate.hpp.

◆ 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() [1/2]

template<typename Derived>
auto janus::asin ( const Eigen::MatrixBase< Derived > & x)

Computes arc sine element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of arc sines

◆ asin() [2/2]

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)

◆ asinh() [1/2]

template<typename Derived>
auto janus::asinh ( const Eigen::MatrixBase< Derived > & x)

Computes inverse hyperbolic sine element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of inverse hyperbolic sines

◆ asinh() [2/2]

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

Computes inverse hyperbolic sine of x.

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

◆ atan() [1/2]

template<typename Derived>
auto janus::atan ( const Eigen::MatrixBase< Derived > & x)

Computes arc tangent element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of arc tangents

◆ atan() [2/2]

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])

◆ atanh() [1/2]

template<typename Derived>
auto janus::atanh ( const Eigen::MatrixBase< Derived > & x)

Computes inverse hyperbolic tangent element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of inverse hyperbolic tangents

◆ atanh() [2/2]

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

Computes inverse hyperbolic tangent of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value (must be in (-1, 1))
Returns
Inverse hyperbolic tangent of x

◆ backward_difference()

template<typename Scalar>
JanusVector< Scalar > janus::backward_difference ( const JanusVector< Scalar > & f,
const JanusVector< Scalar > & x )

Compute derivative using backward difference.

Returns vector of size N-1 where out[i] ≈ df/dx at point i+1

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
fFunction values (size N)
xGrid points (size N)
Returns
JanusVector<Scalar> derivative approximation (size N-1)

◆ backward_euler_weights()

template<typename Scalar>
std::pair< Scalar, Scalar > janus::backward_euler_weights ( Scalar h)

Backward Euler (implicit) differentiation weights.

For approximating df/dx at point i+1: df/dx ≈ (f[i+1] - f[i]) / h Same formula as forward, but used at i+1 instead of i

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
hStep size
Returns
Pair of weights [w_i, w_{i+1}]

◆ barycentric_basis_eval()

double janus::barycentric_basis_eval ( const NumericVector & nodes,
const NumericVector & bary_w,
int j,
double s )
inline

Evaluate the j-th Lagrange basis polynomial at s using barycentric form.

Parameters
nodesInterpolation nodes
bary_wBarycentric weights
jBasis index
sEvaluation point
Returns
Value of L_j(s)

◆ barycentric_weights()

NumericVector janus::barycentric_weights ( const NumericVector & nodes)
inline

Compute barycentric interpolation weights for the given nodes.

Parameters
nodesInterpolation nodes
Returns
Barycentric weight vector

◆ birkhoff_integration_matrix()

NumericMatrix janus::birkhoff_integration_matrix ( const NumericVector & nodes)
inline

Compute Birkhoff integration matrix B^a for the node set.

B^a_{ij} = integral_{nodes(0)}^{nodes(i)} ell_j(s) ds where ell_j is the j-th Lagrange basis polynomial.

Parameters
nodesInterpolation nodes
Returns
Integration matrix (N x N)

◆ blend()

template<typename TSwitch, typename THigh, typename TLow>
auto janus::blend ( const TSwitch & switch_val,
const THigh & val_high,
const TLow & val_low )

Smoothly blends between two values based on a switch parameter.

Parameters
switch_valControl value. 0 -> average, -inf -> low, +inf -> high.
val_highValue when switch is high
val_lowValue when switch is low
Returns
Blended value

◆ block_triangularize()

BLTDecomposition janus::block_triangularize ( const Function & fn,
const StructuralTransformOptions & opts = {} )
inline

Compute a block-triangular decomposition of a selected residual block.

Parameters
fnFunction with a square residual system
optsTransform options (input/output indices)
Returns
BLT decomposition with permutations and block structure
See also
alias_eliminate, structural_analyze

◆ cbrt() [1/2]

template<typename Derived>
auto janus::cbrt ( const Eigen::MatrixBase< Derived > & x)

Computes cube root element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of cube roots

◆ cbrt() [2/2]

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

Computes cube root of x.

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

◆ ceil() [1/2]

template<typename Derived>
auto janus::ceil ( const Eigen::MatrixBase< Derived > & x)

Computes ceiling element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of ceilings

◆ ceil() [2/2]

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

◆ central_difference()

template<typename Scalar>
JanusVector< Scalar > janus::central_difference ( const JanusVector< Scalar > & f,
const JanusVector< Scalar > & x )

Compute derivative using central difference.

Returns vector of size N-2 where out[i] ≈ df/dx at point i+1

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
fFunction values (size N)
xGrid points (size N)
Returns
JanusVector<Scalar> derivative approximation (size N-2)

◆ central_difference_weights()

template<typename Scalar>
std::pair< Scalar, Scalar > janus::central_difference_weights ( Scalar h)

Central difference differentiation weights.

For approximating df/dx at point i: df/dx ≈ (f[i+1] - f[i-1]) / (2h) Returns [weight_{i-1}, weight_{i+1}] = [-1/(2h), 1/(2h)]

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
hStep size
Returns
Pair of weights [w_{i-1}, w_{i+1}]

◆ cgl_nodes()

NumericVector janus::cgl_nodes ( int N)
inline

Compute Chebyshev-Gauss-Lobatto nodes on [-1, 1].

Parameters
NNumber of nodes (>= 2)
Returns
Node vector

◆ cgl_weights()

NumericVector janus::cgl_weights ( int N,
const NumericVector & nodes )
inline

CGL (Clenshaw-Curtis) quadrature weights on [-1, 1].

Parameters
NNumber of nodes
nodesCGL node vector
Returns
Weight vector

◆ clamp() [1/2]

template<typename Derived, typename Scalar>
auto janus::clamp ( const Eigen::MatrixBase< Derived > & val,
const Scalar & low,
const Scalar & high )

Clamps values element-wise for a matrix/vector.

Template Parameters
DerivedEigen matrix type
ScalarBounds type
Parameters
valInput matrix
lowLower bound
highUpper bound
Returns
Matrix of clamped values

◆ clamp() [2/2]

template<JanusScalar T, JanusScalar TLow, JanusScalar THigh>
auto janus::clamp ( const T & val,
const TLow & low,
const THigh & high )

Clamps value between low and high.

Parameters
valInput value
lowLower bound
highUpper bound
Returns
Clamped value

◆ copysign() [1/4]

template<typename Derived>
auto janus::copysign ( const Eigen::MatrixBase< Derived > & x,
const Eigen::MatrixBase< Derived > & y )

Copysign element-wise for matrices.

Template Parameters
DerivedEigen matrix type
Parameters
xMagnitude matrix
ySign matrix
Returns
Matrix with magnitudes from x and signs from y

◆ copysign() [2/4]

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

Returns magnitude of x with sign of y.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xMagnitude source
ySign source
Returns
|x| with sign of y

◆ copysign() [3/4]

template<JanusScalar T>
requires (!std::is_same_v<T, double>)
T janus::copysign ( const T & x,
double y )

Copysign with mixed types.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xMagnitude source
ySign source (double)
Returns
|x| with sign of y

◆ copysign() [4/4]

template<JanusScalar T>
requires (!std::is_same_v<T, double>)
T janus::copysign ( double x,
const T & y )

Copysign with mixed types (double magnitude).

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xMagnitude source (double)
ySign source
Returns
|x| with sign of y

◆ cos() [1/2]

template<typename Derived>
auto janus::cos ( const Eigen::MatrixBase< Derived > & x)

Computes cosine element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of cosines

◆ cos() [2/2]

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() [1/2]

template<typename Derived>
auto janus::cosh ( const Eigen::MatrixBase< Derived > & x)

Computes hyperbolic cosine element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of hyperbolic cosines

◆ cosh() [2/2]

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

◆ cosine_spacing()

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

Generates cosine spaced vector (denser at ends).

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

◆ create_implicit_function()

janus::Function janus::create_implicit_function ( const janus::Function & G,
const Eigen::VectorXd & x_guess,
const RootFinderOptions & opts = {},
const ImplicitFunctionOptions & implicit_opts = {} )
inline

Create a differentiable implicit solve wrapper for G(...) = 0.

All non-implicit inputs of G become inputs of the returned function, in their original order and original shapes. CasADi's rootfinder provides the implicit sensitivities, so the returned function remains differentiable with respect to every remaining input.

Parameters
GImplicit function containing the unknown input and residual output
x_guessFixed initial guess for the implicit solve
optsSolver options
implicit_optsSelects which input/output pair defines the rootfinding problem
Returns
janus::Function mapping the remaining inputs to x(...)

◆ cross()

template<typename DerivedA, typename DerivedB>
auto janus::cross ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Computes 3D cross product.

Parameters
aFirst 3-element vector
bSecond 3-element vector
Returns
Cross product vector
Exceptions
InvalidArgumentif vectors are not 3 elements

◆ cumtrapz() [1/2]

template<typename DerivedY, typename DerivedX>
auto janus::cumtrapz ( const Eigen::MatrixBase< DerivedY > & y,
const Eigen::MatrixBase< DerivedX > & x )

Computes the cumulative trapezoidal integral.

Returns a running integral with the same length as the inputs: out(0) = 0 and out(i) = integral from x(0) to x(i) using trapezoids.

Template Parameters
DerivedYEigen vector type for Y
DerivedXEigen vector type for X
Parameters
yValues of function at x points
xGrid points
Returns
Vector of cumulative trapezoidal integrals

◆ cumtrapz() [2/2]

template<typename DerivedY, JanusScalar Spacing = double>
auto janus::cumtrapz ( const Eigen::MatrixBase< DerivedY > & y,
const Spacing & dx = 1.0 )

Computes the cumulative trapezoidal integral with uniform spacing.

Returns a running integral with the same length as the input: out(0) = 0 and out(i) = integral over the first i intervals.

Template Parameters
DerivedYEigen vector type for Y
SpacingScalar spacing type
Parameters
yValues of function samples
dxUniform spacing between samples
Returns
Vector of cumulative trapezoidal integrals

◆ det()

template<typename Derived>
auto janus::det ( const Eigen::MatrixBase< Derived > & A)

Computes matrix determinant.

Parameters
AInput matrix
Returns
Determinant of A

◆ diff()

template<typename Derived>
auto janus::diff ( const Eigen::MatrixBase< Derived > & v)

Computes adjacent differences of a vector Returns a vector of size N-1 where out[i] = v[i+1] - v[i].

Template Parameters
DerivedEigen matrix type
Parameters
vInput vector
Returns
Difference vector

◆ disp()

template<typename Derived>
void janus::disp ( const std::string & label,
const Eigen::MatrixBase< Derived > & mat )

Deprecated alias for print.

Template Parameters
DerivedEigen expression type
Parameters
labelDescriptive label
matMatrix to display
See also
print

◆ dot()

template<typename DerivedA, typename DerivedB>
auto janus::dot ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Computes dot product of two vectors.

Parameters
aFirst vector
bSecond vector
Returns
Dot product

◆ eig()

template<typename Derived>
auto janus::eig ( const Eigen::MatrixBase< Derived > & A)

Computes the eigendecomposition of a square matrix with a real spectrum.

Returns eigenvalues in ascending order and eigenvectors as columns of the returned matrix. Numeric matrices use Eigen's general eigensolver. Symbolic MX matrices are not supported in the general case because CasADi does not expose a compatible MX eigendecomposition.

◆ eig_symmetric()

template<typename Derived>
auto janus::eig_symmetric ( const Eigen::MatrixBase< Derived > & A)

Computes the eigendecomposition of a symmetric matrix.

Returns eigenvalues in ascending order and orthonormal eigenvectors as columns. Numeric matrices delegate to Eigen's SelfAdjointEigenSolver. Symbolic MX matrices support only 1x1, 2x2, and 3x3 symmetric inputs.

◆ eq()

template<typename DerivedA, typename DerivedB>
auto janus::eq ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Element-wise equality comparison.

Template Parameters
DerivedAFirst matrix type
DerivedBSecond matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Boolean expression/mask where a == b

◆ euler_step()

template<typename Scalar, typename Func>
JanusVector< Scalar > janus::euler_step ( Func && f,
const JanusVector< Scalar > & x,
Scalar t,
Scalar dt )

Forward Euler integration step.

Computes x_{n+1} = x_n + dt * f(t_n, x_n)

Template Parameters
ScalarNumeric or symbolic scalar type
FuncCallable type f(t, x) -> dx/dt
Parameters
fRight-hand side function
xCurrent state vector
tCurrent time
dtTime step
Returns
State at t + dt
// Exponential decay: dy/dt = -y
auto y_next = janus::euler_step(
[](double t, const janus::NumericVector& y) {
janus::NumericVector dydt = -y; // Explicit return type
return dydt;
},
y, t, 0.01
);
JanusVector< NumericScalar > NumericVector
Eigen::VectorXd equivalent.
Definition JanusTypes.hpp:67
JanusVector< Scalar > euler_step(Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
Forward Euler integration step.
Definition IntegratorStep.hpp:62

◆ eval() [1/3]

template<typename Derived>
auto janus::eval ( const Eigen::MatrixBase< Derived > & mat)

Evaluate a symbolic matrix to a numeric Eigen matrix.

Template Parameters
DerivedEigen expression type
Parameters
matSymbolic or numeric matrix (must contain no free variables)
Returns
NumericMatrix with evaluated values

◆ eval() [2/3]

double janus::eval ( const SymbolicScalar & val)
inline

Evaluate a symbolic scalar to a double.

Parameters
valSymbolic scalar (must be 1x1 and contain no free variables)
Returns
Numeric value
Exceptions
RuntimeErrorif val is not 1x1 or contains free variables

◆ eval() [3/3]

template<typename T, std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
T janus::eval ( const T & val)

Passthrough eval for numeric types.

Template Parameters
TArithmetic type
Parameters
valNumeric value
Returns
Same value unchanged

◆ exp() [1/2]

template<typename Derived>
auto janus::exp ( const Eigen::MatrixBase< Derived > & x)

Computes exponential function element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of exponentials

◆ exp() [2/2]

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

◆ exp2() [1/2]

template<typename Derived>
auto janus::exp2 ( const Eigen::MatrixBase< Derived > & x)

Computes 2^x element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of 2^x values

◆ exp2() [2/2]

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

Computes 2^x.

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

◆ expm1() [1/2]

template<typename Derived>
auto janus::expm1 ( const Eigen::MatrixBase< Derived > & x)

Computes expm1 element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of expm1 values

◆ expm1() [2/2]

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

Computes exp(x) - 1, accurate for small x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
exp(x) - 1

◆ export_graph_deep()

void janus::export_graph_deep ( const casadi::Function & fn,
const std::string & filename,
DeepGraphFormat format = DeepGraphFormat::HTML,
const std::string & name = "" )
inline

Export a CasADi Function to deep graph format showing all operations.

This function expands the given Function to SX form, inlining all nested function calls, then exports the fully-expanded computational graph.

Parameters
fnThe CasADi Function to visualize
filenameOutput filename (without extension)
formatOutput format (DOT, HTML, or PDF)
nameOptional graph name

◆ export_graph_dot()

void janus::export_graph_dot ( const SymbolicScalar & expr,
const std::string & filename,
const std::string & name = "expression" )
inline

Export a symbolic expression to DOT format for visualization.

Creates a DOT file representing the computational graph of the expression. Traverses the full expression tree showing all intermediate operations.

Parameters
exprThe symbolic expression to visualize
filenameOutput filename (without extension, .dot will be added)
nameOptional graph name for DOT file

◆ export_graph_html()

void janus::export_graph_html ( const SymbolicScalar & expr,
const std::string & filename,
const std::string & name = "expression" )
inline

Export a symbolic expression to an interactive HTML file.

Creates a self-contained HTML file with embedded Viz.js for rendering the computational graph. Supports pan and zoom via mouse interaction.

Parameters
exprThe symbolic expression to visualize
filenameOutput filename (without extension, .html will be added)
nameOptional graph name

◆ export_sx_graph_dot()

void janus::export_sx_graph_dot ( const casadi::SX & expr,
const std::string & filename,
const std::string & name = "expression" )
inline

Export an SX expression to DOT format for deep visualization.

Traverses the full SX expression tree showing all primitive operations. Unlike MX graphs, this shows the fully-expanded computational graph.

Parameters
exprThe SX expression to visualize
filenameOutput filename (without extension, .dot will be added)
nameOptional graph name for DOT file

◆ export_sx_graph_html()

void janus::export_sx_graph_html ( const casadi::SX & expr,
const std::string & filename,
const std::string & name = "expression" )
inline

Export an SX expression to an interactive HTML file for deep visualization.

Creates a self-contained HTML file with embedded Viz.js for rendering the fully-expanded computational graph.

Parameters
exprThe SX expression to visualize
filenameOutput filename (without extension, .html will be added)
nameOptional graph name

◆ finite_difference_coefficients()

template<typename Scalar>
JanusVector< Scalar > janus::finite_difference_coefficients ( const JanusVector< Scalar > & x,
Scalar x0 = Scalar(0.0),
int derivative_degree = 1 )

Computes finite difference coefficients for arbitrary grids.

Based on Fornberg 1988: "Generation of Finite Difference Formulas on Arbitrarily Spaced Grids"

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
xGrid points (JanusVector<Scalar>)
x0Evaluation point
derivative_degreeOrder of derivative to approximate
Returns
JanusVector<Scalar> of coefficients matching x size

◆ floor() [1/2]

template<typename Derived>
auto janus::floor ( const Eigen::MatrixBase< Derived > & x)

Computes floor element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of floors

◆ floor() [2/2]

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

◆ fmod() [1/2]

template<typename Derived, typename Scalar>
auto janus::fmod ( const Eigen::MatrixBase< Derived > & x,
const Scalar & y )

Computes floating-point remainder element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
ScalarScalar type
Parameters
xNumerator matrix
yDenominator scalar
Returns
Matrix of remainders

◆ fmod() [2/2]

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

Computes floating-point remainder of x/y.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xNumerator
yDenominator
Returns
Remainder of x/y

◆ forward_difference()

template<typename Scalar>
JanusVector< Scalar > janus::forward_difference ( const JanusVector< Scalar > & f,
const JanusVector< Scalar > & x )

Compute derivative using forward difference.

Returns vector of size N-1 where out[i] ≈ df/dx at point i

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
fFunction values (size N)
xGrid points (size N)
Returns
JanusVector<Scalar> derivative approximation (size N-1)

◆ forward_euler_weights()

template<typename Scalar>
std::pair< Scalar, Scalar > janus::forward_euler_weights ( Scalar h)

Forward Euler (explicit) differentiation weights.

For approximating df/dx at point i: df/dx ≈ (f[i+1] - f[i]) / h Returns [weight_i, weight_i+1] = [-1/h, 1/h]

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
hStep size
Returns
Pair of weights [w_i, w_{i+1}]

◆ gauss_legendre_rule()

std::pair< NumericVector, NumericVector > janus::gauss_legendre_rule ( int n)
inline

Gauss-Legendre nodes and weights on [-1, 1].

Parameters
nNumber of quadrature points
Returns
Pair of (nodes, weights)

◆ ge()

template<typename DerivedA, typename DerivedB>
auto janus::ge ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Element-wise greater than or equal comparison.

Template Parameters
DerivedAFirst matrix type
DerivedBSecond matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Boolean expression/mask where a >= b

◆ geomspace()

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

Generates geometrically spaced vector.

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

◆ get_hessian_sparsity()

SparsityPattern janus::get_hessian_sparsity ( const Function & fn,
int output_idx = 0,
int input_idx = 0 )
inline

Get Hessian sparsity of a scalar janus::Function output.

Parameters
fnThe function
output_idxScalar output index (default 0)
input_idxInput index to differentiate with respect to (default 0)
Returns
SparsityPattern of the Hessian
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ get_jacobian_sparsity()

SparsityPattern janus::get_jacobian_sparsity ( const Function & fn,
int output_idx = 0,
int input_idx = 0 )
inline

Get sparsity of a janus::Function Jacobian.

Parameters
fnThe function
output_idxOutput index (default 0)
input_idxInput index (default 0)
Returns
SparsityPattern of the function's Jacobian
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ get_sparsity_in()

SparsityPattern janus::get_sparsity_in ( const Function & fn,
int input_idx = 0 )
inline

Get input sparsity of a janus::Function.

Parameters
fnThe function
input_idxInput index (default 0)
Returns
SparsityPattern of the input slot
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ get_sparsity_out()

SparsityPattern janus::get_sparsity_out ( const Function & fn,
int output_idx = 0 )
inline

Get output sparsity of a janus::Function.

Parameters
fnThe function
output_idxOutput index (default 0)
Returns
SparsityPattern of the output slot
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ 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)

◆ gradient_1d()

template<typename DerivedY, typename DerivedX>
auto janus::gradient_1d ( const Eigen::MatrixBase< DerivedY > & y,
const Eigen::MatrixBase< DerivedX > & x )

Computes gradient of 1D data using central differences.

Simple gradient with first-order boundaries. For more control over boundary accuracy and derivative order, use gradient() instead.

Returns vector of same size as inputs. Uses forward/backward difference at boundaries.

Parameters
yValues
xGrid points
Returns
Gradient vector

◆ gradient_periodic()

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

Computes gradient with periodic boundary conditions.

For data defined on a periodic domain, this computes the gradient assuming the final sample wraps around to the first sample. Samples should span one cycle without repeating the first point at the end; the wrap interval is inferred from period - covered_span.

Template Parameters
DerivedFEigen vector type
SpacingSpacing type (scalar or vector)
Parameters
fFunction values (vector)
dxSpacing
periodPeriod of the data (e.g., 360 for degrees)
edge_orderOrder of accuracy at boundaries (1 or 2)
nDerivative order (1 or 2)
Returns
Gradient vector

◆ gt()

template<typename DerivedA, typename DerivedB>
auto janus::gt ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Element-wise greater than comparison.

Template Parameters
DerivedAFirst matrix type
DerivedBSecond matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Boolean expression/mask where a > b

◆ hermite_dimension()

PolynomialChaosDimension janus::hermite_dimension ( )
inline

Create a standard normal (Hermite) dimension.

Returns
Hermite dimension descriptor

◆ hessian() [1/2]

SymbolicMatrix janus::hessian ( const SymbolicArg & expr,
const std::vector< SymbolicArg > & vars )
inline

Hessian with vector of variables.

◆ hessian() [2/2]

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_lagrangian() [1/2]

SymbolicMatrix janus::hessian_lagrangian ( const SymbolicArg & objective,
const SymbolicArg & constraints,
const std::vector< SymbolicArg > & vars,
const SymbolicArg & multipliers )
inline

Hessian of Lagrangian with vector inputs.

◆ hessian_lagrangian() [2/2]

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

Hessian of Lagrangian for constrained optimization.

Computes ∇²L where L = f(x) + λᵀg(x) This is the exact matrix needed for IPOPT's hessian_lagrangian callback.

Parameters
objectiveObjective function f(x) (scalar)
constraintsConstraint functions g(x) (vector)
varsDecision variables x (vector)
multipliersLagrange multipliers λ (vector, same size as constraints)
Returns
Hessian of Lagrangian (symmetric matrix)

◆ hessian_vector_product() [1/3]

Function janus::hessian_vector_product ( const Function & fn,
int output_idx = 0,
int input_idx = 0 )
inline

Build a matrix-free Hessian-vector product function for one scalar output/input block.

The returned function takes the original function inputs followed by one extra direction input matching the selected input block shape. Its single output is ∇²y_i / ∇x_j² times that direction, reshaped like the selected input block.

◆ hessian_vector_product() [2/3]

SymbolicMatrix janus::hessian_vector_product ( const SymbolicArg & expr,
const std::vector< SymbolicArg > & vars,
const SymbolicArg & direction )
inline

Hessian-vector product with vector of variables.

◆ hessian_vector_product() [3/3]

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

◆ hypot() [1/4]

template<typename Derived>
auto janus::hypot ( const Eigen::MatrixBase< Derived > & x,
const Eigen::MatrixBase< Derived > & y )

Computes hypot element-wise for matrices.

Template Parameters
DerivedEigen matrix type
Parameters
xFirst matrix
ySecond matrix
Returns
Matrix of hypotenuse values

◆ hypot() [2/4]

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

Computes sqrt(x^2 + y^2) without undue overflow/underflow.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xFirst value
ySecond value
Returns
Hypotenuse length

◆ hypot() [3/4]

template<JanusScalar T>
requires (!std::is_same_v<T, double>)
T janus::hypot ( const T & x,
double y )

Computes hypot(x, y) with mixed types.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xFirst value
ySecond value (double)
Returns
Hypotenuse length

◆ hypot() [4/4]

template<JanusScalar T>
requires (!std::is_same_v<T, double>)
T janus::hypot ( double x,
const T & y )

Computes hypot(x, y) with mixed types (double first).

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xFirst value (double)
ySecond value
Returns
Hypotenuse length

◆ inner()

template<typename DerivedA, typename DerivedB>
auto janus::inner ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Computes inner product of two vectors (dot product).

Parameters
xFirst vector
ySecond vector
Returns
Inner product

◆ integrate_discrete_intervals()

template<typename DerivedF, typename DerivedX>
JanusVector< typename DerivedF::Scalar > janus::integrate_discrete_intervals ( const Eigen::MatrixBase< DerivedF > & f,
const Eigen::MatrixBase< DerivedX > & x,
bool multiply_by_dx = true,
const std::string & method = "trapezoidal",
const std::string & method_endpoints = "lower_order" )

Integrates discrete samples using reconstruction methods.

Template Parameters
DerivedFEigen type for function values
DerivedXEigen type for grid points
Parameters
fFunction values
xGrid points
multiply_by_dxIf true, returns interval integrals; if false, returns average values
method"forward_euler", "backward_euler", "trapezoidal", "simpson", or "cubic"
method_endpoints"lower_order" or "ignore"
Returns
Vector of interval integrals or averages

◆ integrate_discrete_squared_curvature()

template<typename DerivedF, typename DerivedX>
JanusVector< typename DerivedF::Scalar > janus::integrate_discrete_squared_curvature ( const Eigen::MatrixBase< DerivedF > & f,
const Eigen::MatrixBase< DerivedX > & x,
const std::string & method = "simpson" )

Computes the integral of squared curvature over each interval.

Useful for regularization of smooth curves in optimization (penalizes high curvature).

Template Parameters
DerivedFEigen type for function values
DerivedXEigen type for grid points
Parameters
fFunction values
xGrid points
method"simpson" (default) or "hybrid_simpson_cubic"
Returns
Vector of squared-curvature integrals per interval

◆ integration_defects()

template<typename Scalar>
JanusVector< Scalar > janus::integration_defects ( const JanusVector< Scalar > & x,
const JanusVector< Scalar > & xdot,
const JanusVector< Scalar > & t,
IntegrationMethod method = IntegrationMethod::Trapezoidal )

Compute integration defects for derivative constraints.

Returns the "defects" that should be zero if the derivative relationship holds: defect[i] = (x[i+1] - x[i]) - integral(xdot) over [t[i], t[i+1]]

These defects are used as equality constraints in trajectory optimization.

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
xVariable values (size N)
xdotDerivative values (size N)
tTime grid (size N)
methodIntegration method
Returns
JanusVector<Scalar> defects (size N-1), should be zero when constraint is satisfied

◆ interpn() [1/2]

template<typename Scalar>
JanusVector< Scalar > janus::interpn ( const std::vector< NumericVector > & points,
const NumericVector & values_flat,
const JanusMatrix< Scalar > & xi,
InterpolationMethod method = InterpolationMethod::Linear,
std::optional< Scalar > fill_value = std::nullopt )

N-dimensional interpolation on regular grids (backwards compatibility).

Deprecated
Use Interpolator class instead for better performance (cached CasADi function)

This function creates a new Interpolator for each call. For repeated queries, construct an Interpolator once and reuse it.

Template Parameters
ScalarScalar type (double or casadi::MX)
Parameters
pointsVector of 1D coordinate arrays for each dimension
values_flatFlattened values in Fortran order (column-major)
xiQuery points, shape (n_points, n_dimensions)
methodInterpolation method
fill_valueOptional value for out-of-bounds queries (extrapolates if nullopt)
Returns
Vector of interpolated values at query points
Examples
/home/runner/work/janus/janus/include/janus/math/Interpolate.hpp.

◆ interpn() [2/2]

template<typename Scalar>
SymbolicVector janus::interpn ( const std::vector< NumericVector > & points,
const SymbolicVector & values_flat,
const JanusMatrix< Scalar > & xi,
InterpolationMethod method = InterpolationMethod::Linear,
std::optional< SymbolicScalar > fill_value = std::nullopt )

N-dimensional interpolation with symbolic table values.

This overload keeps the table coefficients symbolic so they can participate in optimization and automatic differentiation. It currently supports Linear and BSpline methods.

Template Parameters
ScalarQuery scalar type (double or casadi::MX)
Parameters
pointsVector of 1D coordinate arrays for each dimension
values_flatFlattened symbolic table values in Fortran order
xiQuery points, shape (n_points, n_dimensions)
methodInterpolation method
fill_valueOptional value for out-of-bounds queries
Returns
SymbolicVector of interpolated values at query points

◆ inv()

template<typename Derived>
auto janus::inv ( const Eigen::MatrixBase< Derived > & A)

Computes matrix inverse.

Parameters
AInput matrix
Returns
Inverse of A

◆ inv_symmetric_3x3_explicit()

template<typename T>
std::tuple< T, T, T, T, T, T > janus::inv_symmetric_3x3_explicit ( const T & m11,
const T & m22,
const T & m33,
const T & m12,
const T & m23,
const T & m13 )

Explicit inverse of a symmetric 3x3 matrix.

Input matrix: [m11, m12, m13] [m12, m22, m23] [m13, m23, m33]

Returns the six unique inverse coefficients in Eigen-compatible packed column-major order for the lower triangle: (0,0), (1,0), (2,0), (1,1), (2,1), (2,2), i.e. {a11, a12, a13, a22, a23, a33} for

[a11, a12, a13] [a12, a22, a23] [a13, a23, a33]

◆ is_valid_rotation_matrix()

template<typename Derived>
auto janus::is_valid_rotation_matrix ( const Eigen::MatrixBase< Derived > & a,
double tol = 1e-9 )

Checks if matrix is a valid rotation matrix Checks determinant approx 1 and orthogonality (A^T * A approx I).

Parameters
aInput matrix
tolTolerance
Returns
True (or symbolic condition) if valid

◆ 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() [1/2]

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)

◆ jacobian() [2/2]

auto janus::jacobian ( const std::vector< SymbolicArg > & expressions,
const std::vector< SymbolicArg > & variables )
inline

Computes Jacobian with vector arguments (expressions and variables).

Parameters
expressionsVector of symbolic expressions
variablesVector of symbolic variables
Returns
Jacobian matrix

◆ ks_max() [1/2]

template<typename Derived>
auto janus::ks_max ( const Eigen::MatrixBase< Derived > & values,
double rho = 1.0 )

◆ ks_max() [2/2]

template<JanusScalar T>
auto janus::ks_max ( const std::vector< T > & values,
double rho = 1.0 )

Kreisselmeier-Steinhauser smooth maximum aggregator.

Commonly used to aggregate many constraints into one smooth surrogate: ks_max(values, rho) = (1/rho) * log(sum(exp(rho * values_i)))

Parameters
valuesValues to aggregate
rhoAggregation sharpness. Higher values approach max(values).
Returns
Smooth maximum aggregate

◆ lagrangian_hessian_vector_product() [1/3]

Function janus::lagrangian_hessian_vector_product ( const Function & fn,
int objective_output_idx,
int constraint_output_idx,
int input_idx = 0 )
inline

Build a Lagrangian Hessian-vector product function for optimization workflows.

The returned function takes the original function inputs, then the constraint multipliers λ for the selected constraint output block, and finally the direction v for the selected input block. The output is ∇²L(x, λ) v, reshaped like the selected input block.

◆ lagrangian_hessian_vector_product() [2/3]

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

Lagrangian Hessian-vector product with vector of variables.

◆ lagrangian_hessian_vector_product() [3/3]

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()

PolynomialChaosDimension janus::laguerre_dimension ( double alpha = 0.0)
inline

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

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

◆ le()

template<typename DerivedA, typename DerivedB>
auto janus::le ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Element-wise less than or equal comparison.

Template Parameters
DerivedAFirst matrix type
DerivedBSecond matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Boolean expression/mask where a <= b

◆ legendre_dimension()

PolynomialChaosDimension janus::legendre_dimension ( )
inline

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

Returns
Legendre dimension descriptor

◆ legendre_poly()

std::pair< double, double > janus::legendre_poly ( int n,
double x )
inline

Evaluate Legendre polynomial P_n(x) and derivative P'_n(x).

Parameters
nPolynomial degree
xEvaluation point
Returns
Pair of (P_n(x), P'_n(x))

◆ legendre_poly_vec()

NumericVector janus::legendre_poly_vec ( int n,
const NumericVector & x )
inline

Evaluate P_n(x) at each x in vector.

Parameters
nPolynomial degree
xEvaluation points
Returns
Vector of P_n values

◆ lgl_nodes()

NumericVector janus::lgl_nodes ( int N)
inline

Compute Legendre-Gauss-Lobatto nodes on [-1, 1].

Parameters
NNumber of nodes (>= 2)
Returns
Node vector

◆ lgl_weights()

NumericVector janus::lgl_weights ( int N,
const NumericVector & nodes )
inline

LGL quadrature weights.

Parameters
NNumber of nodes
nodesLGL node vector
Returns
Weight vector

◆ 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() [1/2]

template<typename Derived>
auto janus::log ( const Eigen::MatrixBase< Derived > & x)

Computes natural logarithm element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of logarithms

◆ log() [2/2]

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() [1/2]

template<typename Derived>
auto janus::log10 ( const Eigen::MatrixBase< Derived > & x)

Computes base-10 logarithm element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of base-10 logarithms

◆ log10() [2/2]

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

◆ log1p() [1/2]

template<typename Derived>
auto janus::log1p ( const Eigen::MatrixBase< Derived > & x)

Computes log1p element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of log1p values

◆ log1p() [2/2]

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

Computes log(1 + x), accurate for small x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
log(1 + x)

◆ log2() [1/2]

template<typename Derived>
auto janus::log2 ( const Eigen::MatrixBase< Derived > & x)

Computes base-2 logarithm element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of base-2 logarithms

◆ log2() [2/2]

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

Computes base-2 logarithm of x.

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

◆ logical_and() [1/2]

template<typename DerivedA, typename DerivedB>
auto janus::logical_and ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Element-wise logical AND for matrices.

Template Parameters
DerivedAFirst matrix type
DerivedBSecond matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Boolean expression/mask

◆ logical_and() [2/2]

template<JanusScalar T1, JanusScalar T2>
auto janus::logical_and ( const T1 & x1,
const T2 & x2 )

Logical AND (x && y).

Parameters
x1First operand
x2Second operand
Returns
Boolean result (numeric) or symbolic expression

◆ logical_not() [1/2]

template<typename Derived>
auto janus::logical_not ( const Eigen::MatrixBase< Derived > & a)

Element-wise logical NOT for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
aInput matrix
Returns
Boolean expression/mask

◆ logical_not() [2/2]

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

Logical NOT (!x).

Parameters
xOperand
Returns
Boolean result (numeric) or symbolic expression

◆ logical_or() [1/2]

template<typename DerivedA, typename DerivedB>
auto janus::logical_or ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Element-wise logical OR for matrices.

Template Parameters
DerivedAFirst matrix type
DerivedBSecond matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Boolean expression/mask

◆ logical_or() [2/2]

template<JanusScalar T1, JanusScalar T2>
auto janus::logical_or ( const T1 & x1,
const T2 & x2 )

Logical OR (x || y).

Parameters
x1First operand
x2Second operand
Returns
Boolean result (numeric) or symbolic expression

◆ logspace()

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

Generates logarithmically spaced vector (base 10).

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
startStart exponent (10^start)
endEnd exponent (10^end)
nNumber of points
Returns
Vector of n log-spaced points

◆ lt()

template<typename DerivedA, typename DerivedB>
auto janus::lt ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Element-wise less than comparison.

Template Parameters
DerivedAFirst matrix type
DerivedBSecond matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Boolean expression/mask where a < b

◆ make_function() [1/2]

template<int NInputs, typename Func>
Function janus::make_function ( const std::string & name,
const std::vector< std::string > & input_names,
Func && fn )

Create a Function from a lambda with named inputs.

auto f = janus::make_function<2>("f", {"x", "y"}, [](auto x, auto y) {
return x*x + y*y;
});
Function make_function(const std::string &name, Func &&fn)
Create a Function from a lambda expression.
Definition Function.hpp:349
Template Parameters
NInputsNumber of inputs (must match input_names.size())
FuncLambda type
Parameters
nameFunction name
input_namesNames for input variables
fnLambda taking NInputs symbolic scalars
Returns
Function constructed from the lambda

◆ make_function() [2/2]

template<int NInputs, int NOutputs, typename Func>
Function janus::make_function ( const std::string & name,
Func && fn )

Create a Function from a lambda expression.

Automatically creates symbolic input variables and constructs a Function from the lambda's return value(s).

// Single output
auto f = janus::make_function<2, 1>("f", [](auto x, auto y) {
return x*x + y*y;
});
// Multiple outputs (return a tuple)
auto g = janus::make_function<2, 2>("g", [](auto x, auto y) {
return std::make_tuple(x + y, x - y);
});
Template Parameters
NInputsNumber of scalar inputs
NOutputsNumber of scalar outputs (for validation)
FuncLambda type
Parameters
nameFunction name
fnLambda taking NInputs symbolic scalars
Returns
Function constructed from the lambda

◆ max() [1/2]

template<typename Derived>
auto janus::max ( const Eigen::MatrixBase< Derived > & a,
const Eigen::MatrixBase< Derived > & b )

Computes maximum element-wise for a matrix/vector.

Template Parameters
DerivedEigen matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Matrix of maximums

◆ max() [2/2]

template<JanusScalar T1, JanusScalar T2>
auto janus::max ( const T1 & a,
const T2 & b )

Computes maximum of two values.

Parameters
aFirst value
bSecond value
Returns
Maximum value

◆ min() [1/2]

template<typename Derived>
auto janus::min ( const Eigen::MatrixBase< Derived > & a,
const Eigen::MatrixBase< Derived > & b )

Computes minimum element-wise for a matrix/vector.

Template Parameters
DerivedEigen matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Matrix of minimums

◆ min() [2/2]

template<JanusScalar T1, JanusScalar T2>
auto janus::min ( const T1 & a,
const T2 & b )

Computes minimum of two values.

Parameters
aFirst value
bSecond value
Returns
Minimum value

◆ nan_propagation_sparsity() [1/2]

SparsityPattern janus::nan_propagation_sparsity ( const Function & fn,
const NaNSparsityOptions & opts = {} )
inline

Detect Jacobian sparsity of a janus::Function using NaN propagation.

Convenience overload that uses the Function's internal structure.

Parameters
fnFunction to analyze (must have single vector input/output)
optsOptions for NaN propagation
Returns
SparsityPattern of the Jacobian

◆ nan_propagation_sparsity() [2/2]

template<typename Func>
SparsityPattern janus::nan_propagation_sparsity ( Func && fn,
int n_inputs,
int n_outputs,
const NaNSparsityOptions & opts = {} )

Detect Jacobian sparsity using NaN propagation.

This provides black-box sparsity detection for functions where symbolic sparsity analysis is not available. The algorithm:

  1. Evaluate f(x) at a reference point to get baseline outputs
  2. For each input i: set x[i] = NaN, evaluate f(x_perturbed)
  3. If output[j] becomes NaN, then df[j]/dx[i] ≠ 0 (structurally)
Note
This is a conservative estimate - it may report false positives if NaN propagates through unused code paths, but won't miss actual dependencies.
// Detect sparsity of element-wise function
[](const NumericVector& x) {
NumericVector y(x.size());
for (int i = 0; i < x.size(); ++i) y(i) = x(i) * x(i);
return y;
},
3, 3); // 3 inputs, 3 outputs
EXPECT_EQ(sp.nnz(), 3); // Diagonal pattern
SparsityPattern nan_propagation_sparsity(Func &&fn, int n_inputs, int n_outputs, const NaNSparsityOptions &opts={})
Detect Jacobian sparsity using NaN propagation.
Definition Sparsity.hpp:1123
Template Parameters
FuncFunction type: (const NumericVector&) -> NumericVector
Parameters
fnFunction to analyze
n_inputsNumber of scalar inputs
n_outputsNumber of scalar outputs
optsOptions (reference point, etc.)
Returns
SparsityPattern of the Jacobian (n_outputs x n_inputs)
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ neq()

template<typename DerivedA, typename DerivedB>
auto janus::neq ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )

Element-wise inequality comparison.

Template Parameters
DerivedAFirst matrix type
DerivedBSecond matrix type
Parameters
aFirst matrix
bSecond matrix
Returns
Boolean expression/mask where a != b

◆ norm()

template<typename Derived>
auto janus::norm ( const Eigen::MatrixBase< Derived > & x,
NormType type = NormType::L2 )

Computes vector/matrix norm.

Parameters
xInput vector/matrix
typeNorm type (L1, L2, Inf, Frobenius)
Returns
Norm value

◆ outer()

template<typename DerivedX, typename DerivedY>
auto janus::outer ( const Eigen::MatrixBase< DerivedX > & x,
const Eigen::MatrixBase< DerivedY > & y )

Computes outer product x * y^T.

Parameters
xFirst vector
ySecond vector
Returns
Outer product matrix

◆ parse_integration_method()

IntegrationMethod janus::parse_integration_method ( const std::string & method)
inline

Parse integration method from string.

Accepted names (case-sensitive):

Note
"midpoint" is treated as an alias for Trapezoidal (both use the same averaging formula).
Parameters
methodMethod name string
Returns
Corresponding IntegrationMethod enum value
Exceptions
InvalidArgumentif the method name is not recognized

◆ 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() [1/6]

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

Compute PCE projection coefficients from weighted samples (matrix).

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 (matrix)
Returns
PCE coefficient matrix

◆ pce_projection_coefficients() [2/6]

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_projection_coefficients() [3/6]

template<JanusScalar Scalar>
JanusMatrix< Scalar > janus::pce_projection_coefficients ( const PolynomialChaosBasis & basis,
const StochasticQuadratureGrid & grid,
const JanusMatrix< Scalar > & sample_values )

Compute PCE projection coefficients using a stochastic quadrature grid (matrix).

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
basisPolynomial chaos basis
gridStochastic quadrature grid
sample_valuesFunction values at grid points (matrix)
Returns
PCE coefficient matrix

◆ pce_projection_coefficients() [4/6]

template<JanusScalar Scalar>
JanusVector< Scalar > janus::pce_projection_coefficients ( const PolynomialChaosBasis & basis,
const StochasticQuadratureGrid & grid,
const JanusVector< Scalar > & sample_values )

Compute PCE projection coefficients using a stochastic quadrature grid (vector).

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
basisPolynomial chaos basis
gridStochastic quadrature grid
sample_valuesFunction values at grid points
Returns
PCE coefficient vector

◆ pce_projection_coefficients() [5/6]

template<JanusScalar Scalar>
JanusMatrix< Scalar > janus::pce_projection_coefficients ( const PolynomialChaosBasis & basis,
const UnivariateQuadratureRule & rule,
const JanusMatrix< Scalar > & sample_values )

Compute PCE projection coefficients using a univariate quadrature rule (matrix).

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
basisPolynomial chaos basis
ruleUnivariate quadrature rule
sample_valuesFunction values at quadrature nodes (matrix)
Returns
PCE coefficient matrix

◆ pce_projection_coefficients() [6/6]

template<JanusScalar Scalar>
JanusVector< Scalar > janus::pce_projection_coefficients ( const PolynomialChaosBasis & basis,
const UnivariateQuadratureRule & rule,
const JanusVector< Scalar > & sample_values )

Compute PCE projection coefficients using a univariate quadrature rule (vector).

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
basisPolynomial chaos basis
ruleUnivariate quadrature rule
sample_valuesFunction values at quadrature nodes
Returns
PCE coefficient vector

◆ pce_regression_coefficients() [1/2]

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

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

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

◆ pce_regression_coefficients() [2/2]

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

◆ pinv()

template<typename Derived>
auto janus::pinv ( const Eigen::MatrixBase< Derived > & A)

Computes Moore-Penrose pseudo-inverse.

Parameters
AInput matrix
Returns
Pseudo-inverse of A

◆ pow() [1/4]

template<typename Derived, typename Scalar>
auto janus::pow ( const Eigen::MatrixBase< Derived > & base,
const Scalar & exponent )

Computes power function element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
ScalarExponent type
Parameters
baseBase matrix
exponentExponent
Returns
Matrix of powers

◆ pow() [2/4]

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

◆ pow() [3/4]

template<JanusScalar T>
requires (!std::is_same_v<T, double>)
T janus::pow ( const T & base,
double exponent )

Computes power function base^exponent for scalars (mixed types).

Template Parameters
TNon-double Janus scalar (e.g., SymbolicScalar)
Parameters
baseBase value
exponentExponent value
Returns
base raised to exponent

◆ pow() [4/4]

template<JanusScalar T>
requires (!std::is_same_v<T, double>)
T janus::pow ( double base,
const T & exponent )

Computes power function base^exponent for scalars (mixed types: double base).

Template Parameters
TNon-double Janus scalar (e.g., SymbolicScalar)
Parameters
baseBase value
exponentExponent value
Returns
base raised to exponent

◆ print()

template<typename Derived>
void janus::print ( const std::string & label,
const Eigen::MatrixBase< Derived > & mat )

Print a matrix to stdout with a label.

Template Parameters
DerivedEigen expression type
Parameters
labelDescriptive label printed before the matrix
matMatrix to display

◆ quad() [1/2]

QuadResult< SymbolicScalar > janus::quad ( const SymbolicScalar & expr,
const SymbolicScalar & variable,
double a,
double b,
double abstol = 1e-8,
double reltol = 1e-6 )
inline

Compute definite integral of a symbolic expression using CasADi CVODES.

Parameters
exprSymbolic expression to integrate
variableVariable of integration (MX symbol)
aLower bound (numeric)
bUpper bound (numeric)
abstolAbsolute tolerance
reltolRelative tolerance
Returns
QuadResult<SymbolicScalar> with symbolic integral value

◆ quad() [2/2]

template<typename Func, typename T>
QuadResult< T > janus::quad ( Func && func,
T a,
T b,
double abstol = 1e-8,
double reltol = 1e-6 )

Compute definite integral using adaptive quadrature (numeric) or CVODES (symbolic).

Numeric backend uses Gauss-Kronrod adaptive quadrature. Symbolic backend wraps CasADi's CVODES integrator.

Parameters
funcFunction to integrate (callable taking Scalar, returning Scalar)
aLower bound
bUpper bound
abstolAbsolute tolerance (default 1e-8)
reltolRelative tolerance (default 1e-6)
Returns
QuadResult with integral value and error estimate
// Numeric integration
auto result = janus::quad([](double x) { return x*x; }, 0.0, 1.0);
// result.value ≈ 1/3
// Symbolic integration (generates CasADi graph)
auto x = janus::sym("x");
auto expr = x * x;
auto sym_result = janus::quad(expr, x, 0.0, 1.0);
QuadResult< T > quad(Func &&func, T a, T b, double abstol=1e-8, double reltol=1e-6)
Compute definite integral using adaptive quadrature (numeric) or CVODES (symbolic).
Definition Integrate.hpp:354
SymbolicScalar sym(const std::string &name)
Create a named symbolic scalar variable.
Definition JanusTypes.hpp:90

◆ render_graph()

bool janus::render_graph ( const std::string & dot_file,
const std::string & output_file )
inline

Export a janus::Function to DOT format for visualization.

Parameters
funcThe function to visualize (uses underlying CasADi function)
filenameOutput filename (without extension)

Render a DOT file to an image using Graphviz

Requires Graphviz to be installed and dot command available in PATH.

Parameters
dot_filePath to the DOT file (with .dot extension)
output_filePath for output image (extension determines format: .pdf, .png, .svg)
Returns
true if rendering succeeded, false otherwise
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ rk2_step()

template<typename Scalar, typename Func>
JanusVector< Scalar > janus::rk2_step ( Func && f,
const JanusVector< Scalar > & x,
Scalar t,
Scalar dt )

Heun's method (RK2) integration step.

Computes x_{n+1} using the average of Euler and corrector slopes: k1 = f(t, x) k2 = f(t + dt, x + dt * k1) x_{n+1} = x + dt/2 * (k1 + k2)

Template Parameters
ScalarNumeric or symbolic scalar type
FuncCallable type f(t, x) -> dx/dt
Parameters
fRight-hand side function
xCurrent state vector
tCurrent time
dtTime step
Returns
State at t + dt

◆ rk45_step()

template<typename Scalar, typename Func>
RK45Result< Scalar > janus::rk45_step ( Func && f,
const JanusVector< Scalar > & x,
Scalar t,
Scalar dt )

Dormand-Prince RK45 integration step with embedded error estimate.

Computes both 4th and 5th order solutions using the Dormand-Prince coefficients. The difference provides a local error estimate for adaptive step size control.

Template Parameters
ScalarNumeric or symbolic scalar type
FuncCallable type f(t, x) -> dx/dt
Parameters
fRight-hand side function
xCurrent state vector
tCurrent time
dtTime step
Returns
RK45Result with y5, y4, and error estimate
Note
For adaptive stepping, compare result.error against tolerance and adjust dt accordingly.

◆ rk4_step()

template<typename Scalar, typename Func>
JanusVector< Scalar > janus::rk4_step ( Func && f,
const JanusVector< Scalar > & x,
Scalar t,
Scalar dt )

Classic 4th-order Runge-Kutta integration step.

The workhorse of explicit integration. Computes: k1 = f(t, x) k2 = f(t + dt/2, x + dt/2 * k1) k3 = f(t + dt/2, x + dt/2 * k2) k4 = f(t + dt, x + dt * k3) x_{n+1} = x + dt/6 * (k1 + 2*k2 + 2*k3 + k4)

Template Parameters
ScalarNumeric or symbolic scalar type
FuncCallable type f(t, x) -> dx/dt
Parameters
fRight-hand side function
xCurrent state vector
tCurrent time
dtTime step
Returns
State at t + dt
// Harmonic oscillator: y'' = -ω²y => [y, v]' = [v, -ω²y]
double omega = 2.0;
auto state_next = janus::rk4_step(
[omega](double t, const janus::NumericVector& s) {
ds << s(1), -omega * omega * s(0);
return ds;
},
state, t, 0.01
);
JanusVector< Scalar > rk4_step(Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
Classic 4th-order Runge-Kutta integration step.
Definition IntegratorStep.hpp:131

◆ rkn4_step()

template<typename Scalar, typename AccelFunc>
SecondOrderStepResult< Scalar > janus::rkn4_step ( AccelFunc && acceleration,
const JanusVector< Scalar > & q,
const JanusVector< Scalar > & v,
Scalar t,
Scalar dt )

Classical 4th-order Runge-Kutta-Nystrom step for q'' = a(t, q).

This method targets second-order systems directly, avoiding the need to rewrite them as first-order state-space systems before stepping them.

Template Parameters
ScalarNumeric or symbolic scalar type
AccelFuncCallable type a(t, q) -> qdd
Parameters
accelerationAcceleration function
qCurrent generalized coordinates
vCurrent generalized velocities
tCurrent time
dtTime step
Returns
Coordinates and velocities at t + dt

◆ rootfinder()

template<typename Scalar>
RootResult< Scalar > janus::rootfinder ( const janus::Function & F,
const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > & x0,
const RootFinderOptions & opts = {} )

Solve F(x) = 0 for x given an initial guess.

Numeric mode uses Janus' globalization stack. Symbolic mode embeds CasADi's differentiable rootfinder.

Template Parameters
Scalardouble (numeric) or SymbolicScalar (symbolic)
Parameters
FFunction mapping x -> residual
x0Initial guess
optsSolver options
Returns
RootResult containing solution and diagnostics

◆ rotation_matrix_2d()

template<typename T>
Mat2< T > janus::rotation_matrix_2d ( const T & theta)

Creates a 2x2 rotation matrix.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
thetaRotation angle (radians)
Returns
2x2 Rotation matrix

◆ rotation_matrix_3d()

template<typename T>
Mat3< T > janus::rotation_matrix_3d ( const T & theta,
int axis )

Creates a 3x3 rotation matrix about a principal axis.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
thetaRotation angle (radians)
axisAxis index (0=X, 1=Y, 2=Z)
Returns
3x3 Rotation matrix

◆ rotation_matrix_from_euler_angles()

template<typename T>
Mat3< T > janus::rotation_matrix_from_euler_angles ( const T & roll,
const T & pitch,
const T & yaw )

Creates a 3x3 rotation matrix from Euler angles (Yaw-Pitch-Roll sequence).

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
rollRoll angle (X-axis, radians)
pitchPitch angle (Y-axis, radians)
yawYaw angle (Z-axis, radians)
Returns
3x3 Rotation matrix

◆ round() [1/2]

template<typename Derived>
auto janus::round ( const Eigen::MatrixBase< Derived > & x)

Rounds element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of rounded values

◆ round() [2/2]

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

Rounds x to the nearest integer.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
Nearest integer to x

◆ select() [1/2]

template<typename CondType, typename Scalar>
Scalar janus::select ( const std::vector< CondType > & conditions,
const std::vector< Scalar > & values,
const Scalar & default_value )

Multi-way conditional selection (cleaner alternative to nested where).

Evaluates conditions in order and returns the first matching value. Similar to NumPy's select() or a switch statement.

Example: select({x < 0, x < 10, x < 100}, {-1, 0, 1}, 2) // Returns: -1 if x<0, 0 if 0<=x<10, 1 if 10<=x<100, else 2

Template Parameters
CondTypeCondition type (result of comparison, e.g., bool or Scalar)
ScalarScalar type for values (numeric or symbolic)
Parameters
conditionsVector of conditions to check (in order)
valuesVector of values to return (same size as conditions)
default_valueValue to return if no condition matches
Returns
Result of first matching condition, or default

◆ select() [2/2]

template<typename CondType, typename Scalar>
Scalar janus::select ( std::initializer_list< CondType > conditions,
std::initializer_list< Scalar > values,
const Scalar & default_value )

◆ select_sensitivity_regime() [1/2]

SensitivityRecommendation janus::select_sensitivity_regime ( const Function & fn,
int output_idx = 0,
int input_idx = 0,
int horizon_length = 1,
bool stiff = false,
const SensitivitySwitchOptions & opts = SensitivitySwitchOptions() )
inline

Recommend a sensitivity regime for a selected janus::Function block.

◆ select_sensitivity_regime() [2/2]

SensitivityRecommendation janus::select_sensitivity_regime ( int parameter_count,
int output_count,
int horizon_length = 1,
bool stiff = false,
const SensitivitySwitchOptions & opts = SensitivitySwitchOptions() )
inline

Recommend a sensitivity regime from parameter/output counts.

◆ sensitivity_jacobian()

Function janus::sensitivity_jacobian ( const Function & fn,
int output_idx = 0,
int input_idx = 0,
int horizon_length = 1,
bool stiff = false,
const SensitivitySwitchOptions & opts = SensitivitySwitchOptions() )
inline

Build a Jacobian function for one output/input block using the recommended regime.

The returned Jacobian is always dense and uses column-major vectorization of the selected output and input blocks, matching CasADi/Eigen storage order.

◆ sigmoid()

template<typename T>
auto janus::sigmoid ( const T & x,
SigmoidType type = SigmoidType::Tanh,
double norm_min = 0.0,
double norm_max = 1.0 )

Sigmoid function with normalization capability.

Parameters
xInput value
typeType of sigmoid shape (Tanh, Arctan, Polynomial)
norm_minMinimum output value (asymptote at -inf)
norm_maxMaximum output value (asymptote at +inf)
Returns
Sigmoid value scaled to [norm_min, norm_max]

◆ sigmoid_blend() [1/2]

template<typename Derived, typename Scalar>
auto janus::sigmoid_blend ( const Eigen::MatrixBase< Derived > & x,
const Scalar & val_low,
const Scalar & val_high,
const Scalar & sharpness = 1.0 )

Smoothly blends element-wise for a matrix using a sigmoid function.

Template Parameters
DerivedEigen matrix type
ScalarScalar type
Parameters
xControl variable matrix
val_lowLow value
val_highHigh value
sharpnessSteepness
Returns
Matrix of blended values

◆ sigmoid_blend() [2/2]

template<JanusScalar T, JanusScalar TLow, JanusScalar THigh, JanusScalar Sharpness = double>
auto janus::sigmoid_blend ( const T & x,
const TLow & val_low,
const THigh & val_high,
const Sharpness & sharpness = 1.0 )

Smoothly blends between val_low and val_high using a sigmoid function blend = val_low + (val_high - val_low) * (1 / (1 + exp(-sharpness * x))).

Parameters
xControl variable (0 centers the sigmoid)
val_lowValue when x is negative large
val_highValue when x is positive large
sharpnessSteepness of the transition
Returns
Blended value

◆ sign() [1/2]

template<typename Derived>
auto janus::sign ( const Eigen::MatrixBase< Derived > & x)

Computes sign element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of signs

◆ sign() [2/2]

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

Computes sign of x.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
1.0 if x > 0, -1.0 if x < 0, 0.0 otherwise

◆ sin() [1/2]

template<typename Derived>
auto janus::sin ( const Eigen::MatrixBase< Derived > & x)

Computes sine element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of sines

◆ sin() [2/2]

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() [1/2]

template<typename Derived>
auto janus::sinh ( const Eigen::MatrixBase< Derived > & x)

Computes hyperbolic sine element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of hyperbolic sines

◆ sinh() [2/2]

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

◆ sinspace()

template<typename T>
JanusVector< T > janus::sinspace ( const T & start,
const T & end,
int n,
bool reverse_spacing = false )

Generates sine spaced vector (denser at start by default).

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
startStart value
endEnd value
nNumber of points
reverse_spacingIf true, bunches points at the end instead of start
Returns
Vector of n sine-spaced points

◆ slerp()

template<typename Scalar>
Quaternion< Scalar > janus::slerp ( const Quaternion< Scalar > & q0,
const Quaternion< Scalar > & q1,
Scalar t )

Spherical Linear Interpolation (full fidelity).

Shortest-path aware with nlerp fallback for near-identity angles.

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
q0Start quaternion
q1End quaternion
tInterpolation parameter in [0, 1]
Returns
Interpolated unit quaternion

◆ 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

◆ smooth_abs()

template<typename T>
auto janus::smooth_abs ( const T & x,
double hardness = 1.0 )

Smooth approximation of absolute value.

Implemented as smooth_max(x, -x), which is C-infinity and approaches |x| as hardness -> infinity.

Parameters
xInput value
hardnessSharpness parameter. Higher values approach abs(x).
Returns
Smooth approximation of |x|

◆ smooth_clamp()

template<typename TX, typename TLow, typename THigh>
auto janus::smooth_clamp ( const TX & x,
const TLow & low,
const THigh & high,
double hardness = 1.0 )

Smooth approximation of clamp(x, low, high).

Implemented by composing smooth_max and smooth_min.

Parameters
xInput value
lowLower bound
highUpper bound
hardnessSharpness parameter. Higher values approach hard clamping.
Returns
Smooth approximation of clamp(x, low, high)

◆ smooth_max()

template<typename T1, typename T2>
auto janus::smooth_max ( const T1 & a,
const T2 & b,
double hardness = 1.0 )

Pairwise smooth maximum.

Uses the identity max(a, b) = b + relu(a - b), replacing relu with softplus. This remains C-infinity and approaches max(a, b) as hardness -> infinity.

Parameters
aFirst value
bSecond value
hardnessSharpness parameter. Higher values approach max(a, b).
Returns
Smooth approximation of max(a, b)

◆ smooth_min()

template<typename T1, typename T2>
auto janus::smooth_min ( const T1 & a,
const T2 & b,
double hardness = 1.0 )

Pairwise smooth minimum.

Uses the identity min(a, b) = a - relu(a - b), replacing relu with softplus. This remains C-infinity and approaches min(a, b) as hardness -> infinity.

Parameters
aFirst value
bSecond value
hardnessSharpness parameter. Higher values approach min(a, b).
Returns
Smooth approximation of min(a, b)

◆ softmax() [1/2]

template<typename T>
auto janus::softmax ( const std::vector< T > & args,
double softness = 1.0 )

Computes the smooth maximum (LogSumExp) of a collection of values.

Approximation of max(x1, x2, ...) that is differentiable. out = softness * log(sum(exp(x_i / softness)))

Implemented with shift for numerical stability: out = max_val + softness * log(sum(exp((x_i - max_val) / softness)))

Parameters
argsVector of values (scalars or matrices)
softnessSmoothing parameter (default 1.0). Higher = smoother (further from max).
Returns
Smooth maximum

◆ softmax() [2/2]

template<typename T1, typename T2>
auto janus::softmax ( const T1 & a,
const T2 & b,
double softness = 1.0 )

◆ softmin() [1/2]

template<typename T>
auto janus::softmin ( const std::vector< T > & args,
double softness = 1.0 )

Computes the smooth minimum of a collection of values. softmin(x) = -softmax(-x).

Parameters
argsVector of values
softnessSmoothing parameter
Returns
Smooth minimum

◆ softmin() [2/2]

template<typename T1, typename T2>
auto janus::softmin ( const T1 & a,
const T2 & b,
double softness = 1.0 )

◆ softplus() [1/2]

template<typename Derived>
auto janus::softplus ( const Eigen::MatrixBase< Derived > & x,
double beta = 1.0,
double threshold = 20.0 )

◆ softplus() [2/2]

template<JanusScalar T>
auto janus::softplus ( const T & x,
double beta = 1.0,
double = 20.0 )

◆ solve() [1/4]

template<typename DerivedA, typename DerivedB>
auto janus::solve ( const Eigen::MatrixBase< DerivedA > & A,
const Eigen::MatrixBase< DerivedB > & b )

Solves linear system Ax = b using the default backend policy.

Numeric dense matrices default to column-pivoted Householder QR. Symbolic MX matrices keep CasADi's default linear solver selection.

Parameters
ACoefficient matrix
bRight-hand side vector
Returns
Solution vector x

◆ solve() [2/4]

template<typename DerivedA, typename DerivedB>
auto janus::solve ( const Eigen::MatrixBase< DerivedA > & A,
const Eigen::MatrixBase< DerivedB > & b,
const LinearSolvePolicy & policy )

Solves linear system Ax = b using an explicit backend policy.

◆ solve() [3/4]

template<typename DerivedB>
auto janus::solve ( const SparseMatrix & A,
const Eigen::MatrixBase< DerivedB > & b )

Solve a numeric sparse linear system with a sparse-aware default backend.

Sparse input defaults to SparseLU, since there was no previous sparse overload to preserve.

◆ solve() [4/4]

template<typename DerivedB>
auto janus::solve ( const SparseMatrix & A,
const Eigen::MatrixBase< DerivedB > & b,
const LinearSolvePolicy & policy )

Solve a numeric sparse linear system using an explicit backend policy.

◆ solve_ivp() [1/2]

template<typename Func>
OdeResult< double > janus::solve_ivp ( Func && fun,
std::pair< double, double > t_span,
const NumericVector & y0,
int n_eval = 100,
double abstol = 1e-8,
double reltol = 1e-6 )

Solve initial value problem: dy/dt = f(t, y), y(t0) = y0.

Numeric backend uses fixed-step RK4 integrator. Symbolic backend uses CasADi CVODES for automatic differentiation through the ODE.

Template Parameters
FuncCallable type f(t, y) -> dy/dt
Parameters
funRight-hand side function f(t, y) returning derivative
t_spanIntegration interval (t0, tf)
y0Initial state vector (NumericVector or initializer list)
n_evalNumber of output points (default 100)
abstolAbsolute tolerance
reltolRelative tolerance
Returns
OdeResult<double> with time points and solution
// Simple exponential decay: dy/dt = -0.5*y
auto sol = janus::solve_ivp(
[](double t, const janus::NumericVector& y) { return -0.5 * y; },
{0.0, 10.0}, // t_span
{2.5}, // y0 as initializer list
100 // n_eval
);
// Multi-state ODE (harmonic oscillator):
// dy/dt = v, dv/dt = -ω²y
double omega = 2.0;
auto sol = janus::solve_ivp(
[omega](double t, const janus::NumericVector& state) {
dydt << state(1), -omega * omega * state(0);
return dydt;
},
{0.0, M_PI / omega},
{1.0, 0.0}, // y=1, v=0
100
);
OdeResult< double > solve_ivp(Func &&fun, std::pair< double, double > t_span, const NumericVector &y0, int n_eval=100, double abstol=1e-8, double reltol=1e-6)
Solve initial value problem: dy/dt = f(t, y), y(t0) = y0.
Definition Integrate.hpp:481

◆ solve_ivp() [2/2]

template<typename Func>
OdeResult< double > janus::solve_ivp ( Func && fun,
std::pair< double, double > t_span,
std::initializer_list< double > y0_init,
int n_eval = 100,
double abstol = 1e-8,
double reltol = 1e-6 )

Convenience overload: solve_ivp with initializer list for y0.

auto sol = janus::solve_ivp(
[](double t, const janus::NumericVector& y) { return -0.5 * y; },
{0.0, 10.0},
{2.5} // Single-element initial state
);

◆ solve_ivp_expr()

OdeResult< double > janus::solve_ivp_expr ( const SymbolicScalar & ode_expr,
const SymbolicScalar & t_var,
const SymbolicScalar & y_var,
std::pair< double, double > t_span,
const NumericVector & y0,
int n_eval = 100,
double abstol = 1e-8,
double reltol = 1e-6 )
inline

Solve IVP with a symbolic expression directly (expression-based API).

This is the most flexible symbolic API, allowing the user to provide the ODE as a CasADi expression with explicit variable specification.

Parameters
ode_exprSymbolic ODE expression (dy/dt)
t_varTime variable (MX symbol)
y_varState variable(s) (MX symbol vector)
t_spanIntegration interval
y0Initial state
n_evalNumber of output points
abstolAbsolute tolerance
reltolRelative tolerance
Returns
OdeResult containing numeric time and solution values

◆ solve_ivp_mass_matrix() [1/2]

template<typename RhsFunc, typename MassFunc>
OdeResult< double > janus::solve_ivp_mass_matrix ( RhsFunc && rhs,
MassFunc && mass_matrix,
std::pair< double, double > t_span,
const NumericVector & y0,
int n_eval = 100,
const MassMatrixIvpOptions & opts = {} )

Solve M(t, y) y' = f(t, y) with a native numeric stiff integrator.

RosenbrockEuler is a one-stage linearly implicit method that handles stiff ODEs well when the mass matrix is nonsingular. Bdf1 works on the residual equation directly and also supports singular mass matrices that encode simple index-1 constrained systems.

Template Parameters
RhsFuncCallable type f(t, y) -> rhs
MassFuncCallable type M(t, y) -> mass matrix
Parameters
rhsRight-hand side function
mass_matrixMass matrix function
t_spanIntegration interval
y0Initial state
n_evalNumber of output points
optsIntegration options
Returns
OdeResult with solution samples

◆ solve_ivp_mass_matrix() [2/2]

template<typename RhsFunc, typename MassFunc>
OdeResult< double > janus::solve_ivp_mass_matrix ( RhsFunc && rhs,
MassFunc && mass_matrix,
std::pair< double, double > t_span,
std::initializer_list< double > y0_init,
int n_eval = 100,
const MassMatrixIvpOptions & opts = {} )

Convenience overload for mass-matrix IVPs using initializer lists.

◆ solve_ivp_mass_matrix_expr()

OdeResult< double > janus::solve_ivp_mass_matrix_expr ( const SymbolicScalar & rhs_expr,
const SymbolicScalar & mass_expr,
const SymbolicScalar & t_var,
const SymbolicScalar & y_var,
std::pair< double, double > t_span,
const NumericVector & y0,
int n_eval = 100,
const MassMatrixIvpOptions & opts = {} )
inline

Solve a symbolic mass-matrix IVP using CasADi IDAS.

The original real-time system M(t, y) y' = f(t, y) is converted into the semi-explicit DAE

x' = z 0 = M(t, x) z - f(t, x)

after the same time normalization already used by solve_ivp_expr.

Parameters
rhs_exprSymbolic right-hand side f(t, y)
mass_exprSymbolic mass matrix M(t, y)
t_varTime variable symbol
y_varState variable symbol(s)
t_spanIntegration interval
y0Initial state
n_evalNumber of output points
optsIntegration options
Returns
OdeResult with sampled numeric solution

◆ solve_ivp_symbolic()

template<typename Func>
OdeResult< SymbolicScalar > janus::solve_ivp_symbolic ( Func && fun,
std::pair< double, double > t_span,
const Eigen::VectorXd & y0,
int n_eval = 100,
double abstol = 1e-8,
double reltol = 1e-6 )

Solve IVP with symbolic ODE function (CasADi CVODES backend).

This overload accepts a callable that takes symbolic arguments and returns symbolic expressions, enabling automatic differentiation through the ODE.

Template Parameters
FuncCallable type f(MX t, MX y) -> MX dy/dt
Parameters
funSymbolic ODE function
t_spanIntegration interval (t0, tf)
y0Initial state (numeric, will be used for evaluation)
n_evalNumber of output points
abstolAbsolute tolerance
reltolRelative tolerance
Returns
OdeResult<SymbolicScalar> with symbolic solution

◆ solve_second_order_ivp() [1/2]

template<typename AccelFunc>
SecondOrderOdeResult< double > janus::solve_second_order_ivp ( AccelFunc && acceleration,
std::pair< double, double > t_span,
const NumericVector & q0,
const NumericVector & v0,
int n_eval = 100,
const SecondOrderIvpOptions & opts = {} )

Solve a second-order IVP q'' = a(t, q), q(t0) = q0, v(t0) = v0.

This interface targets mechanical and orbital systems directly instead of forcing them through a first-order state augmentation. StormerVerlet preserves the geometric structure of separable Hamiltonian systems, while RungeKuttaNystrom4 provides a higher-order non-symplectic alternative.

Template Parameters
AccelFuncCallable type a(t, q) -> qdd
Parameters
accelerationAcceleration function
t_spanIntegration interval
q0Initial generalized coordinates
v0Initial generalized velocities
n_evalNumber of output points
optsIntegration options
Returns
SecondOrderOdeResult with q(t) and v(t)

◆ solve_second_order_ivp() [2/2]

template<typename AccelFunc>
SecondOrderOdeResult< double > janus::solve_second_order_ivp ( AccelFunc && acceleration,
std::pair< double, double > t_span,
std::initializer_list< double > q0_init,
std::initializer_list< double > v0_init,
int n_eval = 100,
const SecondOrderIvpOptions & opts = {} )

Convenience overload for second-order IVPs using initializer lists.

◆ solver_available()

bool janus::solver_available ( Solver solver)
inline

Check if a solver is available in the current CasADi build.

Parameters
solverSolver to check
Returns
true if solver plugin is loaded and usable

Uses CasADi's nlpsol plugin system to check availability.

Parameters
solverSolver to check
Returns
true if solver plugin is loaded and usable

◆ solver_name()

const char * janus::solver_name ( Solver solver)
inline

Get the CasADi solver name string.

Parameters
solverSolver enum value
Returns
Solver name as expected by CasADi nlpsol

◆ sparse_from_triplets()

SparseMatrix janus::sparse_from_triplets ( int rows,
int cols,
const std::vector< SparseTriplet > & triplets )
inline

Create sparse matrix from triplets.

Triplets specify (row, col, value) entries. Duplicate entries are summed.

std::vector<janus::SparseTriplet> triplets;
triplets.emplace_back(0, 0, 1.0);
triplets.emplace_back(1, 1, 2.0);
auto sp = janus::sparse_from_triplets(2, 2, triplets);
SparseMatrix sparse_from_triplets(int rows, int cols, const std::vector< SparseTriplet > &triplets)
Create sparse matrix from triplets.
Definition Linalg.hpp:999
Parameters
rowsNumber of rows
colsNumber of columns
tripletsVector of (row, col, value) triplets
Returns
Compressed sparse matrix

◆ sparse_hessian() [1/3]

SparseHessianEvaluator janus::sparse_hessian ( const Function & fn,
int output_idx = 0,
int input_idx = 0,
const std::string & name = "" )
inline

Compile a sparse Hessian evaluator from a janus::Function.

Parameters
fnFunction with scalar output
output_idxScalar output index
input_idxInput index
nameOptional function name
Returns
Configured evaluator

◆ sparse_hessian() [2/3]

SparseHessianEvaluator janus::sparse_hessian ( const SymbolicArg & expression,
const std::vector< SymbolicArg > & variables,
const std::string & name = "" )
inline

Compile a sparse Hessian evaluator from vector arguments.

Parameters
expressionScalar expression
variablesInput variable blocks
nameOptional function name
Returns
Configured evaluator

◆ sparse_hessian() [3/3]

SparseHessianEvaluator janus::sparse_hessian ( const SymbolicArg & expression,
const SymbolicArg & variables,
const std::string & name = "" )
inline

Compile a sparse Hessian evaluator from symbolic expressions.

Parameters
expressionScalar expression
variablesInput variables
nameOptional function name
Returns
Configured evaluator
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ sparse_identity()

SparseMatrix janus::sparse_identity ( int n)
inline

Create identity sparse matrix.

Parameters
nSize (n x n)
Returns
Sparse identity matrix

◆ sparse_jacobian() [1/3]

SparseJacobianEvaluator janus::sparse_jacobian ( const Function & fn,
int output_idx = 0,
int input_idx = 0,
const std::string & name = "" )
inline

Compile a sparse Jacobian evaluator from a janus::Function.

Parameters
fnFunction to differentiate
output_idxOutput index
input_idxInput index
nameOptional function name
Returns
Configured evaluator

◆ sparse_jacobian() [2/3]

SparseJacobianEvaluator janus::sparse_jacobian ( const std::vector< SymbolicArg > & expressions,
const std::vector< SymbolicArg > & variables,
const std::string & name = "" )
inline

Compile a sparse Jacobian evaluator from vector arguments.

Parameters
expressionsOutput expressions
variablesInput variables
nameOptional function name
Returns
Configured evaluator

◆ sparse_jacobian() [3/3]

SparseJacobianEvaluator janus::sparse_jacobian ( const SymbolicArg & expression,
const SymbolicArg & variables,
const std::string & name = "" )
inline

Compile a sparse Jacobian evaluator from symbolic expressions.

Parameters
expressionOutput expression
variablesInput variables
nameOptional function name
Returns
Configured evaluator
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ sparsity_of_hessian()

SparsityPattern janus::sparsity_of_hessian ( const SymbolicScalar & expr,
const SymbolicScalar & vars )
inline

Get Hessian sparsity of a scalar expression.

Named sparsity_of_hessian to avoid collision with potential CasADi functions.

Parameters
exprScalar expression
varsVariables
Returns
SparsityPattern of the Hessian (symmetric)
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ sparsity_of_jacobian()

SparsityPattern janus::sparsity_of_jacobian ( const SymbolicScalar & expr,
const SymbolicScalar & vars )
inline

Get Jacobian sparsity without computing the full Jacobian.

This is more efficient than computing the Jacobian and extracting its sparsity. Named sparsity_of_jacobian to avoid collision with casadi::jacobian_sparsity.

Parameters
exprExpression to differentiate (output)
varsVariables to differentiate with respect to (input)
Returns
SparsityPattern of the Jacobian
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ spectral_diff_matrix()

NumericMatrix janus::spectral_diff_matrix ( const NumericVector & nodes)
inline

Spectral differentiation matrix using barycentric weights.

Parameters
nodesInterpolation nodes
Returns
Differentiation matrix (N x N)

◆ sqrt() [1/2]

template<typename Derived>
auto janus::sqrt ( const Eigen::MatrixBase< Derived > & x)

Computes square root element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of square roots

◆ sqrt() [2/2]

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

◆ square() [1/2]

template<typename Derived>
auto janus::square ( const Eigen::MatrixBase< Derived > & x)

Computes square element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of squared values

◆ square() [2/2]

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

Computes x^2 (more efficient than pow(x, 2)).

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

◆ 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

◆ stormer_verlet_step()

template<typename Scalar, typename AccelFunc>
SecondOrderStepResult< Scalar > janus::stormer_verlet_step ( AccelFunc && acceleration,
const JanusVector< Scalar > & q,
const JanusVector< Scalar > & v,
Scalar t,
Scalar dt )

Stormer-Verlet / velocity-Verlet step for q'' = a(t, q).

This method is symplectic for separable Hamiltonian systems where the acceleration depends only on the generalized coordinates. It is particularly useful for long-horizon orbital and mechanical propagation because it keeps energy error bounded instead of exhibiting the secular drift common to generic explicit Runge-Kutta methods.

Template Parameters
ScalarNumeric or symbolic scalar type
AccelFuncCallable type a(t, q) -> qdd
Parameters
accelerationAcceleration function
qCurrent generalized coordinates
vCurrent generalized velocities
tCurrent time
dtTime step
Returns
Coordinates and velocities at t + dt

◆ structural_analyze()

StructuralAnalysis janus::structural_analyze ( const Function & fn,
const StructuralTransformOptions & opts = {} )
inline

Run alias elimination followed by BLT decomposition.

Parameters
fnFunction containing the residual system
optsTransform options
Returns
Combined alias-elimination and BLT analysis
See also
alias_eliminate, block_triangularize

◆ swish()

template<typename T>
auto janus::swish ( const T & x,
double beta = 1.0 )

Swish activation function: x / (1 + exp(-beta * x)).

Parameters
xInput
betaBeta parameter
Returns
Swish value

◆ sym() [1/2]

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

Create a named symbolic scalar variable.

Parameters
nameName of the variable
Returns
SymbolicScalar (casadi::MX)
Examples
/home/runner/work/janus/janus/include/janus/core/Sparsity.hpp.

◆ sym() [2/2]

SymbolicScalar janus::sym ( const std::string & name,
int rows,
int cols = 1 )
inline

Create a named symbolic matrix variable.

Parameters
nameName of the variable
rowsNumber of rows
colsNumber of columns (default 1)
Returns
SymbolicScalar (casadi::MX) representing a matrix

◆ sym_gradient() [1/2]

SymbolicVector janus::sym_gradient ( const SymbolicArg & expr,
const std::vector< SymbolicArg > & vars )
inline

Symbolic gradient with vector of variables.

◆ sym_gradient() [2/2]

SymbolicVector janus::sym_gradient ( const SymbolicArg & expr,
const SymbolicArg & vars )
inline

Symbolic gradient (for scalar-output functions).

Computes the symbolic gradient of a scalar expression with respect to variables. Note: Named sym_gradient to distinguish from numerical gradient() in Calculus.hpp.

Parameters
exprScalar expression to differentiate
varsVariables to differentiate with respect to
Returns
Column vector of partial derivatives

◆ 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() [1/2]

template<typename Derived>
auto janus::tan ( const Eigen::MatrixBase< Derived > & x)

Computes tangent element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of tangents

◆ tan() [2/2]

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() [1/2]

template<typename Derived>
auto janus::tanh ( const Eigen::MatrixBase< Derived > & x)

Computes hyperbolic tangent element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of hyperbolic tangents

◆ tanh() [2/2]

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()

StochasticQuadratureGrid janus::tensor_product_quadrature ( const std::vector< UnivariateQuadratureRule > & rules)
inline

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

Parameters
rulesVector of univariate quadrature rules
Returns
Tensor-product grid

◆ to_dense()

NumericMatrix janus::to_dense ( const SparseMatrix & sparse)
inline

Convert sparse matrix to dense.

Parameters
sparseSparse matrix
Returns
Dense numeric matrix

◆ 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_eigen_vec()

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

Backwards compatibility alias for as_vector.

Parameters
mInput CasADi MX (column vector)
Returns
SymbolicVector
See also
as_vector

◆ 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)

◆ to_sparse()

SparseMatrix janus::to_sparse ( const NumericMatrix & dense,
double tol = 0.0 )
inline

Convert dense matrix to sparse.

Elements with absolute value <= tol are treated as zero.

Parameters
denseDense numeric matrix
tolTolerance for zero (default 0.0 = exact zeros only)
Returns
Sparse matrix

◆ trapezoidal_weights()

template<typename Scalar>
std::pair< Scalar, Scalar > janus::trapezoidal_weights ( Scalar h)

Trapezoidal integration weights.

For integrating: integral(f, x[i], x[i+1]) ≈ 0.5 * (f[i] + f[i+1]) * h Returns [weight_i, weight_{i+1}] for the two points

Template Parameters
ScalarScalar type (NumericScalar or SymbolicScalar)
Parameters
hStep size
Returns
Pair of weights [w_i, w_{i+1}]

◆ trapz()

template<typename DerivedY, typename DerivedX>
auto janus::trapz ( const Eigen::MatrixBase< DerivedY > & y,
const Eigen::MatrixBase< DerivedX > & x )

Computes trapezoidal integration Approximation of integral of y(x) using trapezoidal rule.

Template Parameters
DerivedYEigen matrix type for Y
DerivedXEigen matrix type for X
Parameters
yValues of function at x points
xGrid points
Returns
Integrated value

◆ trunc() [1/2]

template<typename Derived>
auto janus::trunc ( const Eigen::MatrixBase< Derived > & x)

Truncates element-wise for a matrix.

Template Parameters
DerivedEigen matrix type
Parameters
xInput matrix
Returns
Matrix of truncated values

◆ trunc() [2/2]

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

Truncates x toward zero.

Template Parameters
TScalar type (NumericScalar or SymbolicScalar)
Parameters
xInput value
Returns
x truncated toward zero

◆ visualize_graph()

bool janus::visualize_graph ( const SymbolicScalar & expr,
const std::string & output_base )
inline

Convenience function: export expression to DOT and render to PDF.

Creates both a .dot file and a .pdf file with the given base name.

Parameters
exprThe symbolic expression to visualize
output_baseBase filename (creates output_base.dot and output_base.pdf)
Returns
true if both export and render succeeded

◆ visualize_graph_deep()

bool janus::visualize_graph_deep ( const casadi::Function & fn,
const std::string & output_base )
inline

Convenience function: export Function to deep graph and render to PDF.

Parameters
fnThe CasADi Function to visualize
output_baseBase filename (creates output_base.dot and output_base.pdf)
Returns
true if both export and render succeeded

◆ where() [1/2]

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

◆ where() [2/2]

template<typename DerivedCond, typename DerivedTrue, typename DerivedFalse>
auto janus::where ( const Eigen::ArrayBase< DerivedCond > & cond,
const Eigen::MatrixBase< DerivedTrue > & if_true,
const Eigen::MatrixBase< DerivedFalse > & if_false )

Element-wise select.

Parameters
condCondition matrix/array
if_trueMatrix of values if true
if_falseMatrix of values if false
Returns
Result matrix

Variable Documentation

◆ is_numeric_scalar_v

template<typename Scalar>
bool janus::is_numeric_scalar_v = std::is_floating_point_v<Scalar> || std::is_integral_v<Scalar>
constexpr

Compile-time check for numeric scalar types.

This prevents confusing errors when someone tries to use sparse matrices with symbolic types in templated code.