View Source Integrator.Utils (Integrator v0.1.3)
Various utility functions used in Integrator
Summary
Functions
Returns the columns of a tensor as a list of vector tensors
Gets the epsilon for a particular Nx type
Performs a 3rd order Hermite interpolation. Adapted from function hermite_cubic_interpolation
in
runge_kutta_interpolate.m
Performs a 4th order Hermite interpolation. Used by an ODE solver to interpolate the
solution at the time t_out
. As proposed by Shampine in Lawrence, Shampine,
"Some Practical Runge-Kutta Formulas", 1986.
Implements the Kahan summation algorithm, also known as compensated summation. Based on this code in Octave. This is really a private function, but is made public so the docs are visible.
Returns the sign of the tensor as -1 or 1 (or 0 for zero tensors)
Given a list of elements, create a new list with only the unique elements from the list
Converts a Nx vector into a list of 1-D tensors
Functions
Returns the columns of a tensor as a list of vector tensors
E.g., a tensor of the form:
~M[
1 2 3 4
5 6 7 8
9 10 11 12
]s8
will return
[
~V[ 1 5 9 ]s8,
~V[ 2 6 10 ]s8,
~V[ 3 7 11 ]s8,
~V[ 4 8 12 ]s8
]
Gets the epsilon for a particular Nx type
Performs a 3rd order Hermite interpolation. Adapted from function hermite_cubic_interpolation
in
runge_kutta_interpolate.m
See Wikipedia
Performs a 4th order Hermite interpolation. Used by an ODE solver to interpolate the
solution at the time t_out
. As proposed by Shampine in Lawrence, Shampine,
"Some Practical Runge-Kutta Formulas", 1986.
Implements the Kahan summation algorithm, also known as compensated summation. Based on this code in Octave. This is really a private function, but is made public so the docs are visible.
The algorithm significantly reduces the numerical error in the total obtained by adding a sequence of finite precision floating point numbers compared to the straightforward approach. For more details see this Wikipedia entry. This function is called by AdaptiveStepsize.integrate to better catch equality comparisons.
The first input argument is the variable that will contain the summation.
This variable is also returned as the first output argument in order to
reuse it in subsequent calls to kahan_sum/3
function.
The second input argument contains the compensation term and is returned as the second output argument so that it can be reused in future calls of the same summation.
The third input argument term
is the variable to be added to sum
.
Returns the sign of the tensor as -1 or 1 (or 0 for zero tensors)
Given a list of elements, create a new list with only the unique elements from the list
Converts a Nx vector into a list of 1-D tensors
Is there an existing Nx way to do this? If so, swap the usage of this function and then delete this
Note that
vector |> Nx.as_list() |> Enum.map(& Nx.tensor(&1, type: Nx.type(vector)))
seems to introduce potential precision issues