JSMDUtils API
Math
JSMDUtils.Math.InterpAkima
— TypeInterpAkima{T, N} <: AbstractInterpolationMethod
Type storing an Akima spline nodes and coefficient. T
is the interpolation data type and N
is the spline dimension (i.e., the number of interpolated functions).
Fields
n
– Number of node points.xn
– Interpolated node points.yn
– Node points function valuesc
– Akima polynomial coefficients.
JSMDUtils.Math.InterpAkima
— MethodInterpAkima(x::AbstractVector, y::AbstractArray)
Construct an Akima spline interpolant from a set of data points x
and their values y
. Multi-dimensional splines can be constructed passing y
as a subtype of AbstractMatrix
such that each row contains a different set of values to be interpolated and the number of columns equals the number of data points.
References
- Akima, H. (1970), A New Method of Interpolation and Smooth Curve Fitting Based on Local Procedures, Journal of the ACM, DOI:
JSMDUtils.Math.InterpCubicSplines
— TypeInterpCubicSplines(x::AbstractVector, y::AbstractArray, type::Symbol=:Natural)
Construct a cubic spline interpolant from a set of data points x
and their values y
. Multi-dimensional splines can be constructed by passing y
as a subtype of AbstractMatrix
, such that each row contains a different set of values to be interpolated and the number of columns equals the number of data points.
Different boundary conditions can be applied based on the specified type
:
- :Natural: the second derivative of the first and the last polynomial are equal to zero at the boundary points.
- :NotAKnot: the third derivatives of the first and last two polynomials are equal in the points where they meet each other.
- :Periodic: the first and second derivatives at the initial and final points are equal.
- :Quadratic: the first and the last polynomial are quadratic.
JSMDUtils.Math.InterpCubicSplines
— TypeInterpCubicSplines{T, N} <: AbstractInterpolationMethod
Type storing a cubic spline nodes and coefficients. T
is the spline data type and N
is the spline dimension (i.e., the number of interpolated functions).
Fields
n
– Number of node points.m
– Size of the interpolated element.xn
– Interpolated node points.yn
– Node points function values.c
– Spline polynomials coefficients.type
– Boundary conditions type.
JSMDInterfaces.Math.interpolate
— Methodinterpolate(ak::InterpAkima, x::Number, flat::Bool=true)
Interpolate the Akima spline ak
at point x
. If the spline has a single dimension (e.g., InterpAkima{T, 1}
), a scalar value is returned. Otherwise, an SVector
is computed.
If x
is outside the boundary range of sp
a flat extrapolation is used by default. If the flat
argument is false
, the first and last polynomials will be used to compute all the outside values.
JSMDInterfaces.Math.interpolate
— Methodinterpolate(sp::InterpCubicSplines, x::Number, flat::Bool=true)
Interpolate the cubic spline sp
at point x
. If the spline has a single dimension (e.g., InterpCubicSpline{T, 1}
), a scalar value is returned. Otherwise, an SVector
is computed.
If x
is outside the boundary range of sp
a flat extrapolation is used by default. If the flat
argument is false
, the first and last polynomials will be used to compute all the outside values.
JSMDUtils.Math.D²
— MethodD²(f, x::Real)
Return d²f/dx²
evaluated at x
using ForwardDiff, assuming f
is called as f(x)
.
This method assumes that isa(f(x), Union{Real, AbstractArray})
.
JSMDUtils.Math.D³
— MethodD³(f, x::Real)
Return d³f/dx³
evaluated at x
using ForwardDiff, assuming f
is called as f(x)
.
This method assumes that isa(f(x), Union{Real, AbstractArray})
.
JSMDUtils.Math.D¹
— MethodD¹(f, x::Real)
Return df/dx
evaluated at x
using ForwardDiff, assuming f
is called as f(x)
.
This method assumes that isa(f(x), Union{Real, AbstractArray})
.
JSMDUtils.Math._3angles_to_δdcm
— Method_3angles_to_δdcm(θ, rot_seq::Symbol)
Compute the time derivative of the DCM with all the angles stored in a single vector to optimise computations.
JSMDUtils.Math._3angles_to_δ²dcm
— Method_3angles_to_δ²dcm(θ, rot_seq::Symbol)
Compute the 2nd time derivative of the DCM with all the angles stored in a single vector to optimise computations.
JSMDUtils.Math._3angles_to_δ³dcm
— Method_3angles_to_δ³dcm(θ, rot_seq::Symbol)
Compute the 3rd order time derivative of the DCM with all the angles stored in a single vector to optimise computations.
JSMDUtils.Math.angle_to_δdcm
— Functionangle_to_δdcm(θ[, ϕ[, γ]], rot_seq::Symbol = :ZYX)
Compute the derivative of the direction cosine matrix that perform a set of rotations (θ
, ϕ
, γ
) about the coordinate axes in rot_seq
. Each rotation input must be an indexable objected which includes the angle and its first time derivative.
The rotation sequence is defined by a Symbol
specifing the rotation axes. The possible values depend on the number of rotations as follows:
- 1 rotation (
θ₁
)::X
,:Y
, or:Z
. - 2 rotations (
θ₁
,θ₂
)::XY
,:XZ
,:YX
,:YZ
,:ZX
, or:ZY
. - 3 rotations (
θ₁
,θ₂
,θ₃
)::XYX
,XYZ
,:XZX
,:XZY
,:YXY
,:YXZ
,:YZX
,:YZY
,:ZXY
,:ZXZ
,:ZYX
, or:ZYZ
This function assigns dcm = A3 * A2 * A1
in which Ai
is the DCM related with the i-th rotation, i Є [1,2,3]
. If the i-th rotation is not specified, then Ai = I
.
See also
See also angle_to_δ²dcm
JSMDUtils.Math.angle_to_δ²dcm
— Functionangle_to_δ²dcm(θ[, ϕ[, γ]], rot_seq::Symbol = :ZYX)
Compute the second order time derivative of the direction cosine matrix that perform a set of rotations (θ
, ϕ
, γ
) about the coordinate axes in rot_seq
. Each rotation input must be an indexable objected which includes the angle and its first and second order time derivatives.
The rotation sequence is defined by a Symbol
specifing the rotation axes. The possible values depend on the number of rotations as follows:
- 1 rotation (
θ₁
)::X
,:Y
, or:Z
. - 2 rotations (
θ₁
,θ₂
)::XY
,:XZ
,:YX
,:YZ
,:ZX
, or:ZY
. - 3 rotations (
θ₁
,θ₂
,θ₃
)::XYX
,XYZ
,:XZX
,:XZY
,:YXY
,:YXZ
,:YZX
,:YZY
,:ZXY
,:ZXZ
,:ZYX
, or:ZYZ
This function assigns dcm = A3 * A2 * A1
in which Ai
is the DCM related with the i-th rotation, i Є [1,2,3]
. If the i-th rotation is not specified, then Ai = I
.
See also
See also angle_to_δdcm
JSMDUtils.Math.angle_to_δ³dcm
— Functionangle_to_δ³dcm(θ::Number[, ϕ::Number[, γ::Number]], rot_seq::Symbol = :Z)
Compute the second order time derivative of the direction cosine matrix that perform a set of rotations (θ
, ϕ
, γ
) about the coordinate axes in rot_seq
. Each rotation input must be an indexable objected which includes the angle and its time derivatives up to order 3 (jerk).
The rotation sequence is defined by a Symbol
specifing the rotation axes. The possible values depend on the number of rotations as follows:
- 1 rotation (
θ₁
)::X
,:Y
, or:Z
. - 2 rotations (
θ₁
,θ₂
)::XY
,:XZ
,:YX
,:YZ
,:ZX
, or:ZY
. - 3 rotations (
θ₁
,θ₂
,θ₃
)::XYX
,XYZ
,:XZX
,:XZY
,:YXY
,:YXZ
,:YZX
,:YZY
,:ZXY
,:ZXZ
,:ZYX
, or:ZYZ
This function assigns dcm = A3 * A2 * A1
in which Ai
is the DCM related with the i-th rotation, i Є [1,2,3]
. If the i-th rotation is not specified, then Ai = I
.
See also
See also angle_to_δdcm
JSMDUtils.Math.angleplane
— Methodangleplane(v1::AbstractArray, n::AbstractArray)
Compute the angle between a vector v1
and (its projection on) a plane with normal n
, in rad.
JSMDUtils.Math.angleplaned
— Methodangleplaned(v1::AbstractArray, n::AbstractArray)
Compute the angle between a vector v1
and (its projection on) a plane with normal n
, in deg.
JSMDUtils.Math.anglevec
— Methodanglevec(v1::AbstractArray, v2::AbstractArray)
Compute the angle between two vectors v1
and v2
, in rad.
JSMDUtils.Math.anglevecd
— Methodanglevecd(v1::AbstractArray, v2::AbstractArray)
Compute the angle between two vectors v1
and v2
, in deg.
JSMDUtils.Math.cross12
— Methodcross12(x::AbstractVector, y::AbstractVector)
Compute the cross product between x
and y
and its 1st, 2nd and 3rd order time derivatives.
x
and y
must be 12-elements state vectors (position, velocity and acceleration)
JSMDUtils.Math.cross3
— Methodcross3(x::AbstractVector, y::AbstractVector)
Compute the cross product between x
and y
, considering only their first 3 elements.
JSMDUtils.Math.cross6
— Methodcross6(x::AbstractVector, y::AbstractVector)
Compute the cross product between x
and y
and its time derivative.
x
and y
must be 6-elements state vectors, with the last elements of each vector representing the time derivatives of the first three.
JSMDUtils.Math.cross9
— Methodcross9(x::AbstractVector, y::AbstractVector)
Compute the cross product between x
and y
and its 1st and 2nd-order time derivatives.
x
and y
must be 9-elements state vectors (position, velocity and acceleration)
JSMDUtils.Math.projplane
— Methodprojplane(v1::AbstractArray, n::AbstractArray)
Compute the orthogonal projection of a vector v1
on a plane with normal n
.
JSMDUtils.Math.projvec
— Methodprojvec(v1::AbstractArray, v2::AbstractArray)
Compute the orthogonal projection of a vector v1
on a vector v2
.
JSMDUtils.Math.skew
— Methodskew(a)
Create a skew matrix from the vector v
.
JSMDUtils.Math.unitcross
— Methodunitcross(v1::AbstractArray, v2::AbstractArray)
Compute the normalized cross product of v1
and v2
.
JSMDUtils.Math.unitvec
— Methodunitvec(v::AbstractVector)
Normalise the vector v
.
JSMDUtils.Math.δunitvec
— Methodδunitvec(v::AbstractVector)
Compute the time derivative of a unit vector v
.
JSMDUtils.Math.δ²unitvec
— Methodδ²unitvec(v::AbstractVector)
Compute the 2nd-order time derivative of a unit vector v
.
JSMDUtils.Math.δ³unitvec
— Methodδ³unitvec(v::AbstractVector)
Compute the 3rd-order time derivative of a unit vector v
.
Autodiff
JSMDUtils.Autodiff.AutoHessianConfig
— TypeAutoHessianConfig
Wrapper object around a ForwardDiff.HessianConfig
type.
JSMDUtils.Autodiff.AutoHessianConfig
— MethodAutoHessianConfig(x)
Generate a Autodiff.AutoHessianConfig
instance based on the type and shape of the input vector x
.
The returned AutoHessianConfig
instance contains all the work buffers required by Autodiff.hessian!
when the target function takes the form f(x)
. The chunk size is automatically set to 1 since it is part of the type. Having a larger chunk-size improves performance but would require a greater number of dispatches for the function wrappers.
The dual numbers that are generated from this instance all share the Autodiff.JSMDDiffTag
tag, which could lead to perturbation confusion if the hessian operation is not used with care.
See Also
See also Autodiff.hessian!
.
JSMDUtils.Autodiff.JSMDDiffTag
— TypeJSMDDiffTag
Singleton to be used as a ForwardDiff tag for the JSMD ecosystem.
JSMDUtils.Autodiff.AutoGradientConfig
— MethodAutoGradientConfig(x)
Generate a ForwardDiff.GradientConfig
instance based on the type and shape of the input x
.
The returned GradientConfig
instance contains all the work buffers required by Autodiff.gradient!
. The chunk size is automatically set to 1 since it is part of the type. Having a larger chunk-size improves performance but would require a greater number of dispatches for the function wrappers.
The dual numbers that are generated from this instance all share the Autodiff.JSMDDiffTag
tag, which could lead to perturbation confusion if the gradient operation is not used with care.
See also
See also Autodiff.gradient!
JSMDUtils.Autodiff.AutoJacobianConfig
— MethodAutoJacobianConfig(x)
Generate a ForwardDiff.JacobianConfig
instance based on the type and shape of the input vector x
.
The returned JacobianConfig
instance contains all the work buffers required by Autodiff.jacobian!
when the target function takes the form f(x)
. The chunk size is automatically set to 1 since it is part of the type. Having a larger chunk-size improves performance but would require a greater number of dispatches for the function wrappers.
AutoJacobianConfig(y, x)
Generate a ForwardDiff.JacobianConfig
instance based on the type and shape of the input vector x
and the output vector y
.
The returned JacobianConfig
instance contains all the work buffers required by Autodiff.jacobian!
when the target function takes the in-place form f!(y, x).
The dual numbers that are generated from this instance all share the Autodiff.JSMDDiffTag
tag, which could lead to perturbation confusion if the gradient operation is not used with care.
See Also
See also Autodiff.jacobian!
.
JSMDUtils.Autodiff.derivative
— Methodderivative(f, x::Number)
Return df/dx
evaluated at x
, assuming f
is called as f(x)
.
This function assumes that isa(f(x), Union{Real, AbstractArray})
.
The dual numbers generated by this function are tagged with the Autodiff.JSMDDiffTag
which could lead to perturbation confusion in certain scenarios. Hence, this derivative operation should be used with care.
See also
See also Autodiff.gradient!
and Autodiff.hessian!
JSMDUtils.Autodiff.gentag
— Methodgentag(x)
Generate a dual tag for the element type of x
.
JSMDUtils.Autodiff.gradient!
— Methodgradient!(res, f, x)
gradient!(res, f, x, cfg::GradientConfig)
Compute ∇f
evaluated at x
and store the output in res
, assuming f
is called as f(x)
. To avoid runtime allocations, a GradientConfig
instance must be provided.
This function assumes that isa(f(x), Real)
.
If the gradient config has been setup with Autodiff.AutoGradientConfig
, the dual numbers generated by this function are tagged with the Autodiff.JSMDDiffTag
which could lead to perturbation confusion in certain scenarios. Hence, this gradient operation should be used with care.
See Also
See also Autodiff.AutoGradientConfig
JSMDUtils.Autodiff.hessian!
— Methodhessian!(res, f, x)
hessian!(res, f, x, ahc::AutoHessianConfig)
Compute H(f)
(i.e., J(∇(f))
) evaluated at x
and store the output in res
, assuming f
is called as f(x)
. To avoid runtime allocations, an Autodiff.AutoHessianConfig
instance must be provided.
This function assumes that isa(f(x), Real)
.
The dual numbers generated by this function are tagged with the Autodiff.JSMDDiffTag
which could lead to perturbation confusion in certain scenarios. Hence, this hessian operation should be used with care.
See Also
See also Autodiff.AutoHessianConfig
.
JSMDUtils.Autodiff.jacobian!
— Methodjacobian!(res, f, x)
jacobian!(res, f, x, cfg::JacobianConfig)
Compute J(f)
evaluated at the input vector x
and store the result in res
, assuming f
is called as f(x)
. To avoid runtime allocations, a JacobianConfig
instance must be provided.
This function assumes that isa(f(x), Union{AbstractArray})
.
jacobian!(res, f!, y, x) jacobian!(res, f!, y, x, cfg::JacobianConfig)
Compute J(f)
evaluated at the input vector x
and store the result in res
, assuming f
is called as f!(y, x)
, where the result is stored in y
. To avoid runtime allocations, a JacobianConfig
instance must be provided.
If the jacobian config has been setup with Autodiff.AutoJacobianConfig
, the dual numbers generated by this function are tagged with the Autodiff.JSMDDiffTag
which could lead to perturbation confusion in certain scenarios. Hence, this jacobian operation should be used with care.
See Also
See also Autodiff.AutoJacobianConfig
FileUtils
JSMDUtils.FileUtils.JSON
— TypeJSMDUtils.FileUtils.JSON <: JSMDInterfaces.FilesIO.AbstractFile
A type representing JSMDUtils.FileUtils.JSON files.
JSMDUtils.FileUtils.TXT
— TypeJSMDUtils.FileUtils.TXT <: JSMDInterfaces.FilesIO.AbstractFile
A type representing JSMDUtils.FileUtils.TXT files.
JSMDUtils.FileUtils.YAML
— TypeJSMDUtils.FileUtils.YAML <: JSMDInterfaces.FilesIO.AbstractFile
A type representing JSMDUtils.FileUtils.YAML files.
JSMDInterfaces.FilesIO.load
— Methodload(file::JSON{1})
Open a JSON file and parse its data in a dictionary.
JSMDInterfaces.FilesIO.load
— Methodload(file::TXT{1})
Open a TEXT file and parse its data in a list of strings.
JSMDInterfaces.FilesIO.load
— Methodload(file::YAML{1})
Open a YAML file and parse its data in a dictionary.
Miscellaneous
JSMDUtils.NullEphemerisProvider
— TypeEmptyEphemerisProvider <: AbstractEphemerisProvider
Empty provider to initialise the frame system without loading ephemeris files.
JSMDUtils.format_camelcase
— Methodformat_camelcase(str::AbstractString)
Format str
in CamelCase, such that the first letter of each word in the sentence is capitalized and spaces are removed.
JSMDUtils.format_snakecase
— Methodformat_snakecase(str::AbstractString)
Format str
in SnakeCase, such that all the letters are in lower case and spaces are replaced with underscores.