Utils
Index
In the examples in the documentation below, the methods are not prefixed by the module name even if they are private.
julia> using CTFlows
julia> x = 1
julia> private_fun(x) # throw an errormust be replaced by
julia> using CTFlows
julia> x = 1
julia> CTFlows.private_fun(x)However, if the method is reexported by another package, then, there is no need of prefixing.
julia> module OptimalControl
           import CTFlows: private_fun
           export private_fun
       end
julia> using OptimalControl
julia> x = 1
julia> private_fun(x)Documentation
CTFlows.ctgradient — Functionctgradient(f::Function, x::Real) -> Any
Compute the derivative of a scalar function f at a scalar point x.
Arguments
- f::Function: A scalar-valued function.
- x::ctNumber: A scalar input.
Returns
- The derivative of fevaluated atx.
Example
julia> ctgradient(x -> x^2, 3.0)  # returns 6.0ctgradient(f::Function, x) -> Any
Compute the gradient of a scalar function f at a vector point x.
Arguments
- f::Function: A scalar-valued function accepting a vector input.
- x: A vector of numbers.
Returns
- A vector representing the gradient ∇f(x).
Example
julia> ctgradient(x -> sum(x.^2), [1.0, 2.0])  # returns [2.0, 4.0]ctgradient(X::CTFlows.VectorField, x) -> Any
Compute the gradient of a VectorField at a given point.
Arguments
- X::VectorField: A vector field object with a callable function- X.f.
- x: A scalar or vector input.
Returns
- The derivative or gradient depending on the type of x.
Example
julia> X = VectorField(x -> x^2)
julia> ctgradient(X, 2.0)  # returns 4.0CTFlows.ctjacobian — Functionctjacobian(f::Function, x::Real) -> Any
Compute the Jacobian of a vector-valued function f at a scalar point x.
Arguments
- f::Function: A vector-valued function.
- x::ctNumber: A scalar input.
Returns
- A matrix representing the Jacobian Jf(x).
Example
julia> f(x) = [sin(x), cos(x)]
julia> ctjacobian(f, 0.0)  # returns a 2×1 matrixctjacobian(f::Function, x) -> Any
Compute the Jacobian of a vector-valued function f at a vector point x.
Arguments
- f::Function: A vector-valued function.
- x: A vector input.
Returns
- A matrix representing the Jacobian Jf(x).
Example
julia> f(x) = [x[1]^2, x[2]^2]
julia> ctjacobian(f, [1.0, 2.0])  # returns [2.0 0.0; 0.0 4.0]ctjacobian(X::CTFlows.VectorField, x) -> Any
Compute the Jacobian of a VectorField at a given point.
Arguments
- X::VectorField: A vector field object with a callable function- X.f.
- x: A scalar or vector input.
Returns
- A matrix representing the Jacobian of Xatx.
Example
julia> X = VectorField(x -> [x[1]^2, x[2]])
julia> ctjacobian(X, [1.0, 3.0])  # returns [2.0 0.0; 0.0 1.0]