Private API

This page lists non-exported (internal) symbols of CTFlows.Systems.


From CTFlows.Systems

HamIpAugRHS [Struct]

CTFlows.Systems.HamIpAugRHSType
struct HamIpAugRHS{F, TD, VD, B, CX, CP} <: CTFlows.Systems.AbstractIPHamRHS

In-place augmented RHS functor for Hamiltonian systems with variable costate.

This functor extends the standard Hamiltonian equations to include the variable costate evolution, used in sensitivity analysis and optimal control:

ẋ =  ∂H/∂p
ṗ = -∂H/∂x
ṽ = -∂H/∂v

The state vector is augmented as [x; p; v] where v is the variable costate.

Fields

  • h::Data.Hamiltonian{F,TD,VD}: The Hamiltonian function.
  • backend::B: The AD backend for gradient computation.
  • n_x::Int: State dimension (number of state variables).
  • n_v::Int: Variable dimension.
  • cache::C: Pre-allocated AD cache (or nothing for systems without AD).

Call Signature

(f::HamIpAugRHS)(du, u, λ, t)
  • du: Output vector (mutated in-place).
  • u: Augmented state vector [x; p; v].
  • λ: ODE parameters containing the variable value.
  • t: Time (for non-autonomous systems).

Notes

  • Supports batch mode with matrix inputs (checks batch size compatibility).
  • The AD cache is embedded in the functor for better composability.
  • This functor is created by CTFlows.Systems.build_rhs_augmented for Hamiltonian systems.

See also: CTFlows.Systems.HamIpRHS, CTFlows.Systems.HamOoPRHS.

HamIpRHS [Struct]

CTFlows.Systems.HamIpRHSType
struct HamIpRHS{F, TD, VD, B, CX, CP} <: CTFlows.Systems.AbstractIPHamRHS

In-place RHS functor for Hamiltonian systems with automatic differentiation.

This functor wraps a Hamiltonian and AD backend to compute the Hamiltonian gradient in-place, following the canonical Hamiltonian equations:

ẋ =  ∂H/∂p
ṗ = -∂H/∂x

Fields

  • h::Data.Hamiltonian{F,TD,VD}: The Hamiltonian function.
  • backend::B: The AD backend for gradient computation.
  • N::Int: State dimension (number of state variables).
  • cx::CX: State conversion function.
  • cp::CP: Costate conversion function.
  • cache::C: Pre-allocated AD cache (or nothing for systems without AD).

Call Signature

(f::HamIpRHS)(du, u, λ, t)
  • du: Output vector (mutated in-place).
  • u: State vector [x; p] (concatenated state and costate).
  • λ: ODE parameters containing the variable value.
  • t: Time (for non-autonomous systems).

Notes

  • The AD cache is embedded in the functor for better composability.
  • This functor is created by CTFlows.Systems.build_rhs for Hamiltonian systems.

See also: CTFlows.Systems.HamOoPRHS, CTFlows.Systems.HamIpAugRHS.

HamOoPRHS [Struct]

CTFlows.Systems.HamOoPRHSType
struct HamOoPRHS{F, TD, VD, B, CX, CP} <: CTFlows.Systems.AbstractOoPHamRHS

Out-of-place RHS functor for Hamiltonian systems with automatic differentiation.

This functor wraps a Hamiltonian and AD backend to compute the Hamiltonian gradient out-of-place, following the canonical Hamiltonian equations:

ẋ =  ∂H/∂p
ṗ = -∂H/∂x

Fields

  • h::Data.Hamiltonian{F,TD,VD}: The Hamiltonian function.
  • backend::B: The AD backend for gradient computation.
  • N::Int: State dimension (number of state variables).
  • cx::CX: State conversion function.
  • cp::CP: Costate conversion function.
  • cache::C: Pre-allocated AD cache (or nothing for systems without AD).

Call Signature

(f::HamOoPRHS)(u, λ, t) -> du
  • u: State vector [x; p] (concatenated state and costate).
  • λ: ODE parameters containing the variable value.
  • t: Time (for non-autonomous systems).
  • Returns: Output vector du = [∂p; -∂x].

Notes

  • The AD cache is embedded in the functor for better composability.
  • This functor is created by CTFlows.Systems.build_oop_rhs for Hamiltonian systems.

See also: CTFlows.Systems.HamIpRHS, CTFlows.Systems.HamIpAugRHS.

IPHVFIpAugRHS [Struct]

CTFlows.Systems.IPHVFIpAugRHSType
IPHVFIpAugRHS{F,TD,VD} <: AbstractIPHVFRHS

In-place augmented RHS functor for an in-place HamiltonianVectorField.

Wraps an in-place HamiltonianVectorField and provides an in-place interface for the augmented system (state + costate + variable costate).

Fields

  • hvf::HamiltonianVectorField{F,TD,VD,Traits.InPlace}: The wrapped vector field.
  • n_x::Int: State dimension.
  • n_v::Int: Variable costate dimension.

Call signature

(f::IPHVFIpAugRHS)(du, u, λ, t) -> nothing

IPHVFIpRHS [Struct]

CTFlows.Systems.IPHVFIpRHSType
IPHVFIpRHS{F,TD,VD,CX,CP} <: AbstractIPHVFRHS

In-place RHS functor for an in-place HamiltonianVectorField.

Wraps an in-place HamiltonianVectorField and provides an in-place interface by directly calling the function with pre-allocated buffers.

Fields

  • hvf::HamiltonianVectorField{F,TD,VD,Traits.InPlace}: The wrapped vector field.
  • N::Int: State dimension.
  • cx::CX: Coercion function for state (e.g., identity or only).
  • cp::CP: Coercion function for costate (e.g., identity or only).

Call signature

(f::IPHVFIpRHS)(du, u, λ, t) -> nothing

IPHVFOoPAugRHS [Struct]

CTFlows.Systems.IPHVFOoPAugRHSType
IPHVFOoPAugRHS{F,TD,VD} <: AbstractIPHVFRHS

In-place augmented RHS functor for an out-of-place HamiltonianVectorField.

Wraps an out-of-place HamiltonianVectorField and provides an in-place interface for the augmented system (state + costate + variable costate).

Fields

  • hvf::HamiltonianVectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped vector field.
  • n_x::Int: State dimension.
  • n_v::Int: Variable costate dimension.

Call signature

(f::IPHVFOoPAugRHS)(du, u, λ, t) -> nothing

IPHVFOoPRHS [Struct]

CTFlows.Systems.IPHVFOoPRHSType
IPHVFOoPRHS{F,TD,VD,CX,CP} <: AbstractIPHVFRHS

In-place RHS functor for an out-of-place HamiltonianVectorField.

Wraps an out-of-place HamiltonianVectorField and provides an in-place interface by allocating the result into the pre-allocated du buffer.

Fields

  • hvf::HamiltonianVectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped vector field.
  • N::Int: State dimension.
  • cx::CX: Coercion function for state (e.g., identity or only).
  • cp::CP: Coercion function for costate (e.g., identity or only).

Call signature

(f::IPHVFOoPRHS)(du, u, λ, t) -> nothing

IPVFIpRHS [Struct]

CTFlows.Systems.IPVFIpRHSType
IPVFIpRHS{F,TD,VD} <: AbstractIPRHS

In-place RHS functor for an in-place VectorField.

Wraps an in-place VectorField and provides an in-place interface by directly calling the VectorField.

Fields

  • vf::Data.VectorField{F,TD,VD,Traits.InPlace}: The wrapped VectorField

Call signature

(f::IPVFIpRHS)(du, u, λ, t) -> nothing

IPVFOoPRHS [Struct]

CTFlows.Systems.IPVFOoPRHSType
IPVFOoPRHS{F,TD,VD} <: AbstractIPRHS

In-place RHS functor for an out-of-place VectorField.

Wraps an out-of-place VectorField and provides an in-place interface by allocating the result into the pre-allocated du buffer.

Fields

  • vf::Data.VectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped VectorField

Call signature

(f::IPVFOoPRHS)(du, u, λ, t) -> nothing

OoPHVFIpFinalizeRHS [Struct]

CTFlows.Systems.OoPHVFIpFinalizeRHSType
OoPHVFIpFinalizeRHS{F,TD,VD,CX,CP} <: AbstractOoPHVFRHS

Out-of-place RHS functor for an in-place HamiltonianVectorField with type conversion.

Wraps an in-place HamiltonianVectorField and provides an out-of-place interface that converts the result to match the input type (e.g., Vector → SVector).

Fields

  • hvf::HamiltonianVectorField{F,TD,VD,Traits.InPlace}: The wrapped vector field.
  • N::Int: State dimension.
  • cx::CX: Coercion function for state (e.g., identity or only).
  • cp::CP: Coercion function for costate (e.g., identity or only).

Call signature

(f::OoPHVFIpFinalizeRHS)(u, λ, t) -> du

OoPHVFIpRHS [Struct]

CTFlows.Systems.OoPHVFIpRHSType
OoPHVFIpRHS{F,TD,VD,CX,CP} <: AbstractOoPHVFRHS

Out-of-place RHS functor for an in-place HamiltonianVectorField.

Wraps an in-place HamiltonianVectorField and provides an out-of-place interface by allocating temporary buffers on each call.

Fields

  • hvf::HamiltonianVectorField{F,TD,VD,Traits.InPlace}: The wrapped vector field.
  • N::Int: State dimension.
  • cx::CX: Coercion function for state (e.g., identity or only).
  • cp::CP: Coercion function for costate (e.g., identity or only).

Call signature

(f::OoPHVFIpRHS)(u, λ, t) -> du

OoPHVFOoPRHS [Struct]

CTFlows.Systems.OoPHVFOoPRHSType
OoPHVFOoPRHS{F,TD,VD,CX,CP} <: AbstractOoPHVFRHS

Out-of-place RHS functor for an out-of-place HamiltonianVectorField.

Wraps an out-of-place HamiltonianVectorField and provides an out-of-place interface by directly calling the function and concatenating the results.

Fields

  • hvf::HamiltonianVectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped vector field.
  • N::Int: State dimension.
  • cx::CX: Coercion function for state (e.g., identity or only).
  • cp::CP: Coercion function for costate (e.g., identity or only).

Call signature

(f::OoPHVFOoPRHS)(u, λ, t) -> du

OoPVFIpFinalizeRHS [Struct]

CTFlows.Systems.OoPVFIpFinalizeRHSType
OoPVFIpFinalizeRHS{F,TD,VD} <: AbstractOoPRHS

Out-of-place RHS functor for an in-place VectorField with type conversion.

Wraps an in-place VectorField and provides an out-of-place interface that converts the result to match the input type (e.g., Vector → SVector).

Fields

  • vf::Data.VectorField{F,TD,VD,Traits.InPlace}: The wrapped VectorField

Call signature

(f::OoPVFIpFinalizeRHS)(u, λ, t) -> du

OoPVFIpRHS [Struct]

CTFlows.Systems.OoPVFIpRHSType
OoPVFIpRHS{F,TD,VD} <: AbstractOoPRHS

Out-of-place RHS functor for an in-place VectorField.

Wraps an in-place VectorField and provides an out-of-place interface by allocating a temporary buffer on each call.

Fields

  • vf::Data.VectorField{F,TD,VD,Traits.InPlace}: The wrapped VectorField

Call signature

(f::OoPVFIpRHS)(u, λ, t) -> du

OoPVFOoPRHS [Struct]

CTFlows.Systems.OoPVFOoPRHSType
OoPVFOoPRHS{F,TD,VD} <: AbstractOoPRHS

Out-of-place RHS functor for an out-of-place VectorField.

Wraps an out-of-place VectorField and provides an out-of-place interface by directly calling the VectorField.

Fields

  • vf::Data.VectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped VectorField

Call signature

(f::OoPVFOoPRHS)(u, λ, t) -> du

_aug_assign! [Function]

CTFlows.Systems._aug_assign!Function
_aug_assign!(
    du::AbstractVector,
    dx,
    dp,
    dpv,
    n_x::Int64,
    n_v::Int64
) -> Any

Assign derivatives to the augmented derivative vector for Hamiltonian systems with variable costate.

The augmented derivative vector has the form [dx; dp; dpv] where:

  • dx is the state derivative (first n_x elements)
  • dp is the costate derivative (next n_x elements)
  • dpv is the variable costate derivative (last n_v elements)

Arguments

  • du::AbstractVector: Augmented derivative vector to fill [dx; dp; dpv].
  • dx: State derivative.
  • dp: Costate derivative.
  • dpv: Variable costate derivative.
  • n_x::Int: State dimension.
  • n_v::Int: Variable dimension.

Returns

  • nothing.

Notes

  • Performs in-place assignment using broadcasting.
  • For matrix inputs, broadcasts over columns.
  • Used internally by CTFlows.Systems.HamIpAugRHS.

See also: CTFlows.Systems._aug_split, CTFlows.Systems.HamIpAugRHS.

_aug_split [Function]

CTFlows.Systems._aug_splitFunction
_aug_split(
    u::AbstractVector,
    n_x::Int64,
    n_v::Int64
) -> Tuple{Any, Any, Any}

Split an augmented state vector into state, costate, and variable costate components.

The augmented state vector has the form [x; p; pv] where:

  • x is the state (first n_x elements)
  • p is the costate (next n_x elements)
  • pv is the variable costate (last n_v elements)

Arguments

  • u::AbstractVector: Augmented state vector [x; p; pv].
  • n_x::Int: State dimension.
  • n_v::Int: Variable dimension.

Returns

  • Tuple: (x, p, pv) where each component is a @view slice.

Notes

  • Always returns views (never scalars), consistent with _ham_split.
  • For matrix inputs, returns column views.
  • Used internally by CTFlows.Systems.HamIpAugRHS.

See also: CTFlows.Systems._aug_assign!, CTFlows.Systems.HamIpAugRHS.

_check_aug_batch_compat [Function]

CTFlows.Systems._check_aug_batch_compatFunction

Check batch size compatibility for augmented Hamiltonian RHS with matrix inputs.

When using batch mode with matrix inputs, ensures that the state matrix u and variable matrix v have compatible batch sizes (same number of columns).

Arguments

  • u::AbstractMatrix: State matrix with shape (n, batch_size).
  • v::AbstractMatrix: Variable matrix with shape (m, batch_size).

Returns

  • nothing if batch sizes match.

Throws

  • Exceptions.PreconditionError: If size(u, 2) ≠ size(v, 2).

Notes

See also: CTFlows.Systems.HamIpAugRHS, CTFlows.Systems._aug_split.

No-op version of batch compatibility check for non-matrix inputs.

Arguments

  • u: State input (vector or scalar).
  • v: Variable input (vector or scalar).

Returns

  • nothing.

Notes

_check_vf_scalar_inplace [Function]

CTFlows.Systems._check_vf_scalar_inplaceFunction
_check_vf_scalar_inplace(sys::VectorFieldSystem{F, TD, VD, Traits.InPlace}, u0::Number)

Raise an error if an in-place vector field is used with a scalar initial condition. This combination is unsupported because in-place functions require mutable arrays.

Arguments

  • sys::VectorFieldSystem: The vector field system.
  • u0: The initial condition.

Throws

  • ArgumentError if sys is in-place and u0 is a scalar.

_ham_assign! [Function]

CTFlows.Systems._ham_assign!Function
_ham_assign!(du::AbstractVector, dx, dp, N::Int64) -> Any

Assign derivatives dx and dp to the combined derivative du for Hamiltonian systems.

Dispatches on the array type (AbstractVector or AbstractMatrix) and the known dimension N (or nothing for runtime inference).

Arguments

  • du::AbstractVector or AbstractMatrix: Combined derivative to fill [dx; dp].
  • dx: State derivative (same shape as state part of du).
  • dp: Costate derivative (same shape as costate part of du).
  • N::Int or nothing: State dimension. If nothing, infers as size(du, 1) ÷ 2.

Returns

  • nothing

Notes

  • Internal helper used by RHS builders for Hamiltonian systems.
  • Performs in-place assignment using broadcasting.

_ham_split [Function]

CTFlows.Systems._ham_splitFunction
_ham_split(u::AbstractVector, N::Int64) -> Tuple{Any, Any}

Split a combined state u into state x and costate p views for Hamiltonian systems.

Dispatches on the array type (AbstractVector or AbstractMatrix) and the known dimension N (or nothing for runtime inference).

Arguments

  • u::AbstractVector or AbstractMatrix: Combined state vector/matrix [x; p].
  • N::Int or nothing: State dimension. If nothing, infers as size(u, 1) ÷ 2.

Returns

  • Tuple: Tuple of views (x_view, p_view) where:
    • For vectors: x_view = @view(u[1:N]), p_view = @view(u[N+1:2N])
    • For matrices: x_view = @view(u[1:N, :]), p_view = @view(u[N+1:2N, :])

Notes

  • Internal helper used by RHS builders for Hamiltonian systems.
  • The CTFlowsStaticArrays extension provides a type-stable method for StaticVector.

Type-stable split of a SVector into state and costate components.

Arguments

  • u::SVector: Combined state vector [x; p].
  • N::Int: Known state dimension (compile-time).

Returns

  • Tuple{SVector{N}, SVector{N}}: Tuple of (x, p) as SVectors.

Notes

  • This method provides type stability for SciML's out-of-place ODE solvers when using StaticArrays.
  • Used automatically when the CTFlowsStaticArrays extension is loaded.

Type-stable split of a SMatrix into state and costate components.

Arguments

  • u::SMatrix{NN,M,T}: Combined state matrix stacked vertically [X; P].
  • N::Int: Known state dimension.

Returns

  • Tuple{SMatrix{N,M,T}, SMatrix{N,M,T}}: Tuple of (X, P) as SMatrixs.

Notes

  • This method provides type stability for SciML's out-of-place ODE solvers when using StaticArrays for matrix initial conditions.
  • Constructs new SMatrix objects since views don't work with immutable static arrays.
  • Uses 1D column-major linear indexing to enumerate elements: for result element k (1-based), row = (k-1) % N + 1, col = (k-1) ÷ N + 1.
  • Used automatically when the CTFlowsStaticArrays extension is loaded.

_make_ip_hvf [Function]

CTFlows.Systems._make_ip_hvfFunction
_make_ip_hvf(
    h,
    backend,
    _::Type{CTBase.Traits.Autonomous},
    _::Type{CTBase.Traits.Fixed}
) -> CTFlows.Systems.var"#_make_ip_hvf##0#_make_ip_hvf##1"

Create an in-place Hamiltonian vector field closure for the Autonomous/Fixed case.

The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for an autonomous Hamiltonian system with fixed parameters, writing the result in-place. The signature is (dx, dp, x, p) -> nothing and fills dx .= ∂p, dp .= -∂x.

Arguments

  • h::Data.Hamiltonian: The scalar Hamiltonian function.
  • backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.
  • ::Type{Traits.Autonomous}: Type parameter indicating autonomous time dependence.
  • ::Type{Traits.Fixed}: Type parameter indicating fixed variable dependence.

Returns

  • Function: A closure (dx, dp, x, p) -> nothing that fills the output arrays in-place.

Notes

  • This is an internal factory function used by CTFlows.Systems.hamiltonian_vector_field.
  • The closure uses automatic differentiation via the provided backend to compute gradients.
  • Output arrays dx and dp must be pre-allocated with the correct dimensions.

See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient

_make_ip_hvf(
    h,
    backend,
    _::Type{CTBase.Traits.NonAutonomous},
    _::Type{CTBase.Traits.Fixed}
) -> CTFlows.Systems.var"#_make_ip_hvf##2#_make_ip_hvf##3"

Create an in-place Hamiltonian vector field closure for the NonAutonomous/Fixed case.

The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for a non-autonomous Hamiltonian system with fixed parameters, writing the result in-place. The signature is (dx, dp, t, x, p) -> nothing and fills dx .= ∂p, dp .= -∂x.

Arguments

  • h::Data.Hamiltonian: The scalar Hamiltonian function.
  • backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.
  • ::Type{Traits.NonAutonomous}: Type parameter indicating non-autonomous time dependence.
  • ::Type{Traits.Fixed}: Type parameter indicating fixed variable dependence.

Returns

  • Function: A closure (dx, dp, t, x, p) -> nothing that fills the output arrays in-place.

Notes

  • This is an internal factory function used by CTFlows.Systems.hamiltonian_vector_field.
  • The closure uses automatic differentiation via the provided backend to compute gradients.
  • Output arrays dx and dp must be pre-allocated with the correct dimensions.

See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient

_make_ip_hvf(
    h,
    backend,
    _::Type{CTBase.Traits.Autonomous},
    _::Type{CTBase.Traits.NonFixed}
) -> CTFlows.Systems.var"#_make_ip_hvf##4#_make_ip_hvf##5"{CTFlows.Systems.var"#_make_ip_hvf##6#_make_ip_hvf##7"{h, backend}} where {h, backend}

Create an in-place Hamiltonian vector field closure for the Autonomous/NonFixed case.

The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for an autonomous Hamiltonian system with variable parameters, writing the result in-place. The signature is (dx, dp, x, p, v) -> nothing and fills dx .= ∂p, dp .= -∂x.

Arguments

  • h::Data.Hamiltonian: The scalar Hamiltonian function.
  • backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.
  • ::Type{Traits.Autonomous}: Type parameter indicating autonomous time dependence.
  • ::Type{Traits.NonFixed}: Type parameter indicating non-fixed variable dependence.

Returns

  • Function: A closure (dx, dp, x, p, v; dpv=nothing, variable_costate=false) -> nothing that fills the output arrays in-place.

Notes

  • This is an internal factory function used by CTFlows.Systems.hamiltonian_vector_field.
  • The closure uses automatic differentiation via the provided backend to compute gradients.
  • Output arrays dx and dp must be pre-allocated with the correct dimensions.
  • When variable_costate=true, dpv must be a pre-allocated mutable array matching the shape of v; it is filled with -∂H/∂v.

Throws

  • Exceptions.PreconditionError: When variable_costate=true && dpv === nothing.

See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient, CTBase.Differentiation.variable_gradient

_make_ip_hvf(
    h,
    backend,
    _::Type{CTBase.Traits.NonAutonomous},
    _::Type{CTBase.Traits.NonFixed}
) -> CTFlows.Systems.var"#_make_ip_hvf##8#_make_ip_hvf##9"{CTFlows.Systems.var"#_make_ip_hvf##10#_make_ip_hvf##11"{h, backend}} where {h, backend}

Create an in-place Hamiltonian vector field closure for the NonAutonomous/NonFixed case.

The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for a non-autonomous Hamiltonian system with variable parameters, writing the result in-place. The signature is (dx, dp, t, x, p, v) -> nothing and fills dx .= ∂p, dp .= -∂x.

Arguments

  • h::Data.Hamiltonian: The scalar Hamiltonian function.
  • backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.
  • ::Type{Traits.NonAutonomous}: Type parameter indicating non-autonomous time dependence.
  • ::Type{Traits.NonFixed}: Type parameter indicating non-fixed variable dependence.

Returns

  • Function: A closure (dx, dp, t, x, p, v; dpv=nothing, variable_costate=false) -> nothing that fills the output arrays in-place.

Notes

  • This is an internal factory function used by CTFlows.Systems.hamiltonian_vector_field.
  • The closure uses automatic differentiation via the provided backend to compute gradients.
  • Output arrays dx and dp must be pre-allocated with the correct dimensions.
  • When variable_costate=true, dpv must be a pre-allocated mutable array matching the shape of v; it is filled with -∂H/∂v.

Throws

  • Exceptions.PreconditionError: When variable_costate=true && dpv === nothing.

See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient, CTBase.Differentiation.variable_gradient

_make_oop_hvf [Function]

CTFlows.Systems._make_oop_hvfFunction
_make_oop_hvf(
    h,
    backend,
    _::Type{CTBase.Traits.Autonomous},
    _::Type{CTBase.Traits.Fixed}
) -> CTFlows.Systems.var"#_make_oop_hvf##0#_make_oop_hvf##1"

Create an out-of-place Hamiltonian vector field closure for the Autonomous/Fixed case.

The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for an autonomous Hamiltonian system with fixed parameters. The signature is (x, p) -> (∂p, -∂x).

Arguments

  • h::Data.Hamiltonian: The scalar Hamiltonian function.
  • backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.
  • `::Type{Traits.Autonomous}: Type parameter indicating autonomous time dependence.
  • ::Type{Traits.Fixed}: Type parameter indicating fixed variable dependence.

Returns

  • Function: A closure (x, p) -> (∂p, -∂x) computing the Hamiltonian vector field.

Notes

See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient

_make_oop_hvf(
    h,
    backend,
    _::Type{CTBase.Traits.NonAutonomous},
    _::Type{CTBase.Traits.Fixed}
) -> CTFlows.Systems.var"#_make_oop_hvf##2#_make_oop_hvf##3"

Create an out-of-place Hamiltonian vector field closure for the NonAutonomous/Fixed case.

The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for a non-autonomous Hamiltonian system with fixed parameters. The signature is (t, x, p) -> (∂p, -∂x).

Arguments

  • h::Data.Hamiltonian: The scalar Hamiltonian function.
  • backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.
  • ::Type{Traits.NonAutonomous}: Type parameter indicating non-autonomous time dependence.
  • ::Type{Traits.Fixed}: Type parameter indicating fixed variable dependence.

Returns

  • Function: A closure (t, x, p) -> (∂p, -∂x) computing the Hamiltonian vector field.

Notes

See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient

_make_oop_hvf(
    h,
    backend,
    _::Type{CTBase.Traits.Autonomous},
    _::Type{CTBase.Traits.NonFixed}
) -> CTFlows.Systems.var"#_make_oop_hvf##4#_make_oop_hvf##5"{CTFlows.Systems.var"#_make_oop_hvf##6#_make_oop_hvf##7"{h, backend}} where {h, backend}

Create an out-of-place Hamiltonian vector field closure for the Autonomous/NonFixed case.

The closure computes the Hamiltonian vector field XH = (∂H/∂p, -∂H/∂x) for an autonomous Hamiltonian system with variable parameters. The signature is `(x, p, v; variablecostate=false) -> (∂p, -∂x)or(x, p, v; variable_costate=true) -> (∂p, -∂x, -∂v)` when the variable costate is requested.

Arguments

  • h::Data.Hamiltonian: The scalar Hamiltonian function.
  • backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.
  • ::Type{Traits.Autonomous}: Type parameter indicating autonomous time dependence.
  • ::Type{Traits.NonFixed}: Type parameter indicating non-fixed variable dependence.

Returns

  • Function: A closure (x, p, v; variable_costate=false) computing the Hamiltonian vector field.

Notes

  • This is an internal factory function used by CTFlows.Systems.hamiltonian_vector_field.
  • When variable_costate=true, the closure also returns -∂H/∂v (the negative gradient with respect to variables).
  • The closure uses automatic differentiation via the provided backend to compute gradients.

See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient, CTBase.Differentiation.variable_gradient

_make_oop_hvf(
    h,
    backend,
    _::Type{CTBase.Traits.NonAutonomous},
    _::Type{CTBase.Traits.NonFixed}
) -> CTFlows.Systems.var"#_make_oop_hvf##8#_make_oop_hvf##9"{CTFlows.Systems.var"#_make_oop_hvf##10#_make_oop_hvf##11"{h, backend}} where {h, backend}

Create an out-of-place Hamiltonian vector field closure for the NonAutonomous/NonFixed case.

The closure computes the Hamiltonian vector field XH = (∂H/∂p, -∂H/∂x) for a non-autonomous Hamiltonian system with variable parameters. The signature is `(t, x, p, v; variablecostate=false) -> (∂p, -∂x)or(t, x, p, v; variable_costate=true) -> (∂p, -∂x, -∂v)` when the variable costate is requested.

Arguments

  • h::Data.Hamiltonian: The scalar Hamiltonian function.
  • backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.
  • ::Type{Traits.NonAutonomous}: Type parameter indicating non-autonomous time dependence.
  • ::Type{Traits.NonFixed}: Type parameter indicating non-fixed variable dependence.

Returns

  • Function: A closure (t, x, p, v; variable_costate=false) computing the Hamiltonian vector field.

Notes

  • This is an internal factory function used by CTFlows.Systems.hamiltonian_vector_field.
  • When variable_costate=true, the closure also returns -∂H/∂v (the negative gradient with respect to variables).
  • The closure uses automatic differentiation via the provided backend to compute gradients.

See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient, CTBase.Differentiation.variable_gradient

_rhs_conversion_label [Function]

_state_dim [Function]

CTFlows.Systems._state_dimFunction
_state_dim(x0::Number) = 1
_state_dim(x0::AbstractVector) = length(x0)
_state_dim(x0::AbstractMatrix) = size(x0, 1)

Infer the state dimension from the initial condition shape.