Struct ceres_solver::cost::CostFunction
source · pub struct CostFunction<'a>(_);Expand description
A cost function for ResidualBlock of the NllsProblem.
Implementations§
source§impl<'a> CostFunction<'a>
impl<'a> CostFunction<'a>
sourcepub fn new(
func: impl Into<CostFunctionType<'a>>,
parameter_sizes: impl Into<Vec<usize>>,
num_residuals: usize
) -> Self
pub fn new(
func: impl Into<CostFunctionType<'a>>,
parameter_sizes: impl Into<Vec<usize>>,
num_residuals: usize
) -> Self
Create a new cost function for ResidualBlock from a Rust function.
Arguments
- func - function to find residuals and Jacobian for the problem block. The function itself
must return false if it cannot compute Jacobian, true otherwise, and accept following
arguments:
- parameters - slice of f64 slices representing the current values of the parameters.
Each parameter is represented as a slice, the slice sizes are specified by
parameter_sizes. - residuals - mutable slice of f64 for residuals outputs, the size is specified by
num_residuals. - jacobians: JacobianType - represents a mutable
structure to output the Jacobian. Sometimes the solver doesn’t need the Jacobian or
some of its components, in this case the corresponding value is None. For the required
components it has a 3-D shape: top index is for the parameter index, middle index is for
the residual index, and the most inner dimension is for the given parameter component
index. So the size of top-level Some is defined by
parameter_sizes.len(), second-level Some’s slice length isnum_residuals, and the bottom-level slice has length ofparameter_sizes[i], whereiis the top-level index.
- parameters - slice of f64 slices representing the current values of the parameters.
Each parameter is represented as a slice, the slice sizes are specified by
- parameter_sizes - sizes of the parameter vectors.
- num_residuals - length of the residual vector, usually corresponds to the number of data points.
sourcepub fn parameter_sizes(&self) -> &[usize]
pub fn parameter_sizes(&self) -> &[usize]
Lengths of the parameter vectors.
sourcepub fn num_residuals(&self) -> usize
pub fn num_residuals(&self) -> usize
Length of the residual vector.
sourcepub fn num_parameters(&self) -> usize
pub fn num_parameters(&self) -> usize
Parameter count.