JSMDUtils API

Math

JSMDUtils.Math.InterpAkimaType
InterpAkima{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 values
  • c – Akima polynomial coefficients.
source
JSMDUtils.Math.InterpAkimaMethod
InterpAkima(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:
source
JSMDUtils.Math.InterpCubicSplinesType
InterpCubicSplines(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.
source
JSMDUtils.Math.InterpCubicSplinesType
InterpCubicSplines{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.
source
JSMDInterfaces.Math.interpolateMethod
interpolate(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.

source
JSMDInterfaces.Math.interpolateMethod
interpolate(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.

source
JSMDUtils.Math.D²Method
D²(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}).

source
JSMDUtils.Math.D³Method
D³(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}).

source
JSMDUtils.Math.D¹Method
D¹(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}).

source
JSMDUtils.Math._3angles_to_δdcmMethod
_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.

source
JSMDUtils.Math._3angles_to_δ²dcmMethod
_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.

source
JSMDUtils.Math._3angles_to_δ³dcmMethod
_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.

source
JSMDUtils.Math.angle_to_δdcmFunction
angle_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
Note

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

source
JSMDUtils.Math.angle_to_δ²dcmFunction
angle_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
Note

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

source
JSMDUtils.Math.angle_to_δ³dcmFunction
angle_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
Note

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

source
JSMDUtils.Math.angleplaneMethod
angleplane(v1::AbstractArray, n::AbstractArray)

Compute the angle between a vector v1 and (its projection on) a plane with normal n, in rad.

source
JSMDUtils.Math.angleplanedMethod
angleplaned(v1::AbstractArray, n::AbstractArray)

Compute the angle between a vector v1 and (its projection on) a plane with normal n, in deg.

source
JSMDUtils.Math.cross12Method
cross12(x::AbstractVector, y::AbstractVector)

Compute the cross product between x and y and its 1st, 2nd and 3rd order time derivatives.

Note

x and y must be 12-elements state vectors (position, velocity and acceleration)

source
JSMDUtils.Math.cross3Method
cross3(x::AbstractVector, y::AbstractVector)

Compute the cross product between x and y, considering only their first 3 elements.

source
JSMDUtils.Math.cross6Method
cross6(x::AbstractVector, y::AbstractVector)

Compute the cross product between x and y and its time derivative.

Note

x and y must be 6-elements state vectors, with the last elements of each vector representing the time derivatives of the first three.

source
JSMDUtils.Math.cross9Method
cross9(x::AbstractVector, y::AbstractVector)

Compute the cross product between x and y and its 1st and 2nd-order time derivatives.

Note

x and y must be 9-elements state vectors (position, velocity and acceleration)

source
JSMDUtils.Math.projplaneMethod
projplane(v1::AbstractArray, n::AbstractArray)

Compute the orthogonal projection of a vector v1 on a plane with normal n.

source
JSMDUtils.Math.projvecMethod
projvec(v1::AbstractArray, v2::AbstractArray)

Compute the orthogonal projection of a vector v1 on a vector v2.

source

Autodiff

JSMDUtils.Autodiff.AutoHessianConfigMethod
AutoHessianConfig(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.

Warning

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!.

source
JSMDUtils.Autodiff.AutoGradientConfigMethod
AutoGradientConfig(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.

Warning

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!

source
JSMDUtils.Autodiff.AutoJacobianConfigMethod
AutoJacobianConfig(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).

Warning

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!.

source
JSMDUtils.Autodiff.derivativeMethod
derivative(f, x::Number)

Return df/dx evaluated at x, assuming f is called as f(x).

Note

This function assumes that isa(f(x), Union{Real, AbstractArray}).

Warning

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!

source
JSMDUtils.Autodiff.gradient!Method
gradient!(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.

Note

This function assumes that isa(f(x), Real).

Warning

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

source
JSMDUtils.Autodiff.hessian!Method
hessian!(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.

Note

This function assumes that isa(f(x), Real).

Warning

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.

source
JSMDUtils.Autodiff.jacobian!Method
jacobian!(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.

Note

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.

Warning

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

source

FileUtils

JSMDUtils.FileUtils.JSONType
JSMDUtils.FileUtils.JSON <: JSMDInterfaces.FilesIO.AbstractFile

A type representing JSMDUtils.FileUtils.JSON files.

source
JSMDUtils.FileUtils.TXTType
JSMDUtils.FileUtils.TXT <: JSMDInterfaces.FilesIO.AbstractFile

A type representing JSMDUtils.FileUtils.TXT files.

source
JSMDUtils.FileUtils.YAMLType
JSMDUtils.FileUtils.YAML <: JSMDInterfaces.FilesIO.AbstractFile

A type representing JSMDUtils.FileUtils.YAML files.

source

Miscellaneous

JSMDUtils.format_camelcaseMethod
format_camelcase(str::AbstractString)

Format str in CamelCase, such that the first letter of each word in the sentence is capitalized and spaces are removed.

source
JSMDUtils.format_snakecaseMethod
format_snakecase(str::AbstractString)

Format str in SnakeCase, such that all the letters are in lower case and spaces are replaced with underscores.

source