diff options
Diffstat (limited to 'extern/libmv/third_party/ceres/internal/ceres/array_utils.cc')
-rw-r--r-- | extern/libmv/third_party/ceres/internal/ceres/array_utils.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/extern/libmv/third_party/ceres/internal/ceres/array_utils.cc b/extern/libmv/third_party/ceres/internal/ceres/array_utils.cc index 673baa4f70f..3eea042d511 100644 --- a/extern/libmv/third_party/ceres/internal/ceres/array_utils.cc +++ b/extern/libmv/third_party/ceres/internal/ceres/array_utils.cc @@ -32,7 +32,10 @@ #include <cmath> #include <cstddef> +#include <string> + #include "ceres/fpclassify.h" +#include "ceres/stringprintf.h" namespace ceres { namespace internal { @@ -55,6 +58,20 @@ bool IsArrayValid(const int size, const double* x) { return true; } +int FindInvalidValue(const int size, const double* x) { + if (x == NULL) { + return size; + } + + for (int i = 0; i < size; ++i) { + if (!IsFinite(x[i]) || (x[i] == kImpossibleValue)) { + return i; + } + } + + return size; +}; + void InvalidateArray(const int size, double* x) { if (x != NULL) { for (int i = 0; i < size; ++i) { @@ -63,5 +80,19 @@ void InvalidateArray(const int size, double* x) { } } +void AppendArrayToString(const int size, const double* x, string* result) { + for (int i = 0; i < size; ++i) { + if (x == NULL) { + StringAppendF(result, "Not Computed "); + } else { + if (x[i] == kImpossibleValue) { + StringAppendF(result, "Uninitialized "); + } else { + StringAppendF(result, "%12g ", x[i]); + } + } + } +} + } // namespace internal } // namespace ceres |