| 1 |
/* ---------------------------------------------------------------------------- |
| 2 |
* SymForce - Copyright 2025, Skydio, Inc. |
| 3 |
* This source code is under the Apache 2.0 license found in the LICENSE file. |
| 4 |
* ---------------------------------------------------------------------------- */ |
| 5 |
|
| 6 |
#pragma once |
| 7 |
|
| 8 |
namespace caspar { |
| 9 |
|
| 10 |
template <typename T> |
| 11 |
struct SolverParams { |
| 12 |
T diag_init = 1.0; |
| 13 |
T diag_scaling_up = 2.0; |
| 14 |
T diag_scaling_down = 0.333333f; |
| 15 |
T diag_exit_value = 1e3; |
| 16 |
T diag_min = 1e-12; |
| 17 |
T score_exit_value = 0.0f; |
| 18 |
int solver_iter_max = 100; |
| 19 |
int pcg_iter_max = 20; |
| 20 |
T pcg_rel_error_exit = 1e-4; |
| 21 |
T pcg_rel_score_exit = -1.0f; // disabled if == -1.0f |
| 22 |
T pcg_rel_decrease_min = -1.0f; // disabled if == -1.0f |
| 23 |
T solver_rel_decrease_min = 1.0f; |
| 24 |
|
| 25 |
// Templated conversion constructor to enable automatic type conversion |
| 26 |
SolverParams() = default; |
| 27 |
|
| 28 |
template <typename U> |
| 29 |
SolverParams(const SolverParams<U>& other) |
| 30 |
: diag_init(static_cast<T>(other.diag_init)), |
| 31 |
diag_scaling_up(static_cast<T>(other.diag_scaling_up)), |
| 32 |
diag_scaling_down(static_cast<T>(other.diag_scaling_down)), |
| 33 |
diag_exit_value(static_cast<T>(other.diag_exit_value)), |
| 34 |
diag_min(static_cast<T>(other.diag_min)), |
| 35 |
score_exit_value(static_cast<T>(other.score_exit_value)), |
| 36 |
solver_iter_max(other.solver_iter_max), |
| 37 |
pcg_iter_max(other.pcg_iter_max), |
| 38 |
pcg_rel_error_exit(static_cast<T>(other.pcg_rel_error_exit)), |
| 39 |
pcg_rel_score_exit(static_cast<T>(other.pcg_rel_score_exit)), |
| 40 |
pcg_rel_decrease_min(static_cast<T>(other.pcg_rel_decrease_min)), |
| 41 |
solver_rel_decrease_min(static_cast<T>(other.solver_rel_decrease_min)) {} |
| 42 |
}; |
| 43 |
} // namespace caspar |