You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CostFunction* cost_function
= new AutoDiffCostFunction<MyScalarCostFunctor, 1, 2, 2>(
new MyScalarCostFunctor(1.0)); ^ ^ ^
| | |
Dimension of residual -----+ | |
Dimension of x ---------------+ |
Dimension of y ------------------+
conditioned_cost_function
Sometimes, need to apply more weight to specific residuals
Use this functor when need more detail than other cost functor
cost function creation
// my_cost_function produces N residuals
CostFunction* my_cost_function = ...
CHECK_EQ(N, my_cost_function->num_residuals());
vector<CostFunction*> conditioners;
// Make N 1x1 cost functions (1 parameter, 1 residual)
CostFunction* f_1 = ...
conditioners.push_back(f_1);
...
CostFunction* f_N = ...
conditioners.push_back(f_N);
ConditionedCostFunction* ccf =
new ConditionedCostFunction(my_cost_function, conditioners);
// Now ccf's residual i (i=0..N-1) will be passed though the i'th conditioner.
ccf_residual[i] = f_i(my_cost_function_residual[i])
// and the Jacobian will be affected appropriately.
Variable sized(dynamic) parameter Cost function
These can change parameter numbers and size later
To set paramter number and size, need more setup functions
dynamic_autodiff_cost_function
prototype
structMyCostFunctor {
template<typename T>
booloperator()(T const* const* parameters, T* residuals) const {
// Use parameters[i] to access the i'th parameter block.
}
};
Creation and setup parameters
DynamicAutoDiffCostFunction<MyCostFunctor, 3> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(5);
cost_function.AddParameterBlock(10);
cost_function.SetNumResiduals(21);
dynamic_numeric_diff_cost_function
prototype
structMyCostFunctor {
booloperator()(doubleconst* const* parameters, double* residuals) const {
// Use parameters[i] to access the i'th parameter block.
}
}
Creation and setup parameters
DynamicAutoDiffCostFunction<MyCostFunctor, CENTRAL> cost_function(
new MyCostFunctor());
cost_function.AddParameterBlock(5);
cost_function.AddParameterBlock(10);
cost_function.SetNumResiduals(21);