aboutsummaryrefslogtreecommitdiff
path: root/internal/ceres/types.cc
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ceres/types.cc')
-rw-r--r--internal/ceres/types.cc150
1 files changed, 131 insertions, 19 deletions
diff --git a/internal/ceres/types.cc b/internal/ceres/types.cc
index fc33a4c..164185e 100644
--- a/internal/ceres/types.cc
+++ b/internal/ceres/types.cc
@@ -37,15 +37,14 @@
namespace ceres {
#define CASESTR(x) case x: return #x
-
#define STRENUM(x) if (value == #x) { *type = x; return true;}
-void UpperCase(string* input) {
+static void UpperCase(string* input) {
std::transform(input->begin(), input->end(), input->begin(), ::toupper);
}
-const char* LinearSolverTypeToString(LinearSolverType solver_type) {
- switch (solver_type) {
+const char* LinearSolverTypeToString(LinearSolverType type) {
+ switch (type) {
CASESTR(DENSE_NORMAL_CHOLESKY);
CASESTR(DENSE_QR);
CASESTR(SPARSE_NORMAL_CHOLESKY);
@@ -70,9 +69,8 @@ bool StringToLinearSolverType(string value, LinearSolverType* type) {
return false;
}
-const char* PreconditionerTypeToString(
- PreconditionerType preconditioner_type) {
- switch (preconditioner_type) {
+const char* PreconditionerTypeToString(PreconditionerType type) {
+ switch (type) {
CASESTR(IDENTITY);
CASESTR(JACOBI);
CASESTR(SCHUR_JACOBI);
@@ -94,8 +92,8 @@ bool StringToPreconditionerType(string value, PreconditionerType* type) {
}
const char* SparseLinearAlgebraLibraryTypeToString(
- SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type) {
- switch (sparse_linear_algebra_library_type) {
+ SparseLinearAlgebraLibraryType type) {
+ switch (type) {
CASESTR(SUITE_SPARSE);
CASESTR(CX_SPARSE);
default:
@@ -113,9 +111,8 @@ bool StringToSparseLinearAlgebraLibraryType(
return false;
}
-const char* TrustRegionStrategyTypeToString(
- TrustRegionStrategyType trust_region_strategy_type) {
- switch (trust_region_strategy_type) {
+const char* TrustRegionStrategyTypeToString(TrustRegionStrategyType type) {
+ switch (type) {
CASESTR(LEVENBERG_MARQUARDT);
CASESTR(DOGLEG);
default:
@@ -131,8 +128,8 @@ bool StringToTrustRegionStrategyType(string value,
return false;
}
-const char* DoglegTypeToString(DoglegType dogleg_type) {
- switch (dogleg_type) {
+const char* DoglegTypeToString(DoglegType type) {
+ switch (type) {
CASESTR(TRADITIONAL_DOGLEG);
CASESTR(SUBSPACE_DOGLEG);
default:
@@ -147,9 +144,124 @@ bool StringToDoglegType(string value, DoglegType* type) {
return false;
}
-const char* SolverTerminationTypeToString(
- SolverTerminationType termination_type) {
- switch (termination_type) {
+const char* MinimizerTypeToString(MinimizerType type) {
+ switch (type) {
+ CASESTR(TRUST_REGION);
+ CASESTR(LINE_SEARCH);
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool StringToMinimizerType(string value, MinimizerType* type) {
+ UpperCase(&value);
+ STRENUM(TRUST_REGION);
+ STRENUM(LINE_SEARCH);
+ return false;
+}
+
+const char* LineSearchDirectionTypeToString(LineSearchDirectionType type) {
+ switch (type) {
+ CASESTR(STEEPEST_DESCENT);
+ CASESTR(NONLINEAR_CONJUGATE_GRADIENT);
+ CASESTR(LBFGS);
+ CASESTR(BFGS);
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool StringToLineSearchDirectionType(string value,
+ LineSearchDirectionType* type) {
+ UpperCase(&value);
+ STRENUM(STEEPEST_DESCENT);
+ STRENUM(NONLINEAR_CONJUGATE_GRADIENT);
+ STRENUM(LBFGS);
+ STRENUM(BFGS);
+ return false;
+}
+
+const char* LineSearchTypeToString(LineSearchType type) {
+ switch (type) {
+ CASESTR(ARMIJO);
+ CASESTR(WOLFE);
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool StringToLineSearchType(string value, LineSearchType* type) {
+ UpperCase(&value);
+ STRENUM(ARMIJO);
+ STRENUM(WOLFE);
+ return false;
+}
+
+const char* LineSearchInterpolationTypeToString(
+ LineSearchInterpolationType type) {
+ switch (type) {
+ CASESTR(BISECTION);
+ CASESTR(QUADRATIC);
+ CASESTR(CUBIC);
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool StringToLineSearchInterpolationType(
+ string value,
+ LineSearchInterpolationType* type) {
+ UpperCase(&value);
+ STRENUM(BISECTION);
+ STRENUM(QUADRATIC);
+ STRENUM(CUBIC);
+ return false;
+}
+
+const char* NonlinearConjugateGradientTypeToString(
+ NonlinearConjugateGradientType type) {
+ switch (type) {
+ CASESTR(FLETCHER_REEVES);
+ CASESTR(POLAK_RIBIRERE);
+ CASESTR(HESTENES_STIEFEL);
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool StringToNonlinearConjugateGradientType(
+ string value,
+ NonlinearConjugateGradientType* type) {
+ UpperCase(&value);
+ STRENUM(FLETCHER_REEVES);
+ STRENUM(POLAK_RIBIRERE);
+ STRENUM(HESTENES_STIEFEL);
+ return false;
+}
+
+const char* CovarianceAlgorithmTypeToString(
+ CovarianceAlgorithmType type) {
+ switch (type) {
+ CASESTR(DENSE_SVD);
+ CASESTR(SPARSE_CHOLESKY);
+ CASESTR(SPARSE_QR);
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool StringToCovarianceAlgorithmType(
+ string value,
+ CovarianceAlgorithmType* type) {
+ UpperCase(&value);
+ STRENUM(DENSE_SVD);
+ STRENUM(SPARSE_CHOLESKY);
+ STRENUM(SPARSE_QR);
+ return false;
+}
+
+const char* SolverTerminationTypeToString(SolverTerminationType type) {
+ switch (type) {
CASESTR(NO_CONVERGENCE);
CASESTR(FUNCTION_TOLERANCE);
CASESTR(GRADIENT_TOLERANCE);
@@ -164,8 +276,8 @@ const char* SolverTerminationTypeToString(
}
const char* LinearSolverTerminationTypeToString(
- LinearSolverTerminationType termination_type) {
- switch (termination_type) {
+ LinearSolverTerminationType type) {
+ switch (type) {
CASESTR(TOLERANCE);
CASESTR(MAX_ITERATIONS);
CASESTR(STAGNATION);