From Hamiltonian and Hamiltonian vector field: add a function f in __Hamiltonian_Flow with a MyNumber as x0 and p0. We have simply to overload the function which already exists since we have to give vectors to Hamiltonian and HamiltonianVectorField functions:
function f(t, x0::MyNumber, p0::MyNumber, args...; kwargs...)
return f(t, [x0], [p0], args...; kwargs...)
end
In the vector field case, we should have:
V(x) = -x # x scalar
f = Flow(VectorField{:autonomous, :scalar}(V)) # V must return a scalar if x is scalar
t0 = 0.0
tf = 1.0
x0 = 1.0
xf = f(t0, x0, tf)
# xf should be scalar if x0 is scalar and if the vector field has been constructed with scalar usage
# VectorField{:autonomous, :scalar}(V)
The VectorField function from CTBase.jl should assume that the function V returns a scalar if x is scalar and the usage is :scalar. But, the VectorField function returns always a vector when it takes a vector as input.
Scalar usage:
From Hamiltonian and Hamiltonian vector field: add a function
f
in__Hamiltonian_Flow
with aMyNumber
asx0
andp0
. We have simply to overload the function which already exists since we have to give vectors toHamiltonian
andHamiltonianVectorField
functions:In the vector field case, we should have:
The
VectorField
function fromCTBase.jl
should assume that the functionV
returns a scalar ifx
is scalar and the usage is:scalar
. But, theVectorField
function returns always a vector when it takes a vector as input.