Private API

This page lists non-exported (internal) symbols of CTModels.Utils.


From CTModels.Utils

@ensure

CTModels.Utils.@ensureMacro
@ensure condition exception

Throws the provided exception if condition is false.

Usage

julia> @ensure true Exceptions.IncorrectArgument("This won't throw")
julia> @ensure false Exceptions.IncorrectArgument("This will throw")
ERROR: IncorrectArgument("This will throw")

Arguments

  • condition: A Boolean expression to test.
  • exception: An instance of an exception to throw if condition is false.

Throws

  • The provided exception if the condition is not satisfied.

__matrix_dimension_storage

CTModels.Utils.__matrix_dimension_storageFunction
__matrix_dimension_storage() -> Int64

Return the default value for matrix dimension storage.

Used to set the default value of the storage of elements in a matrix. The default value is 1.

to_out_of_place

CTModels.Utils.to_out_of_placeFunction
to_out_of_place(
    f!,
    n;
    T
) -> Union{Nothing, CTModels.Utils.var"#f#3"{CTModels.Utils.var"#f#2#4"{Type{Float64}, _A, _B}} where {_A, _B}}

Convert an in-place function f! to an out-of-place function f.

The resulting function f returns a vector of type T and length n by first allocating memory and then calling f! to fill it.

Arguments

  • f!: An in-place function of the form f!(result, args...).
  • n: The length of the output vector.
  • T: The element type of the output vector (default is Float64).

Returns

An out-of-place function f(args...; kwargs...) that returns the result as a vector or scalar, depending on n.

Example

julia> f!(r, x) = (r[1] = sin(x); r[2] = cos(x))
julia> f = to_out_of_place(f!, 2)
julia> f(π/4)  # returns approximately [0.707, 0.707]