diff options
Diffstat (limited to 'internal/ceres/array_utils.h')
-rw-r--r-- | internal/ceres/array_utils.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/ceres/array_utils.h b/internal/ceres/array_utils.h index 742f439..7f56947 100644 --- a/internal/ceres/array_utils.h +++ b/internal/ceres/array_utils.h @@ -57,8 +57,31 @@ void InvalidateArray(int size, double* x); // equal to the "impossible" value used by InvalidateArray. bool IsArrayValid(int size, const double* x); +// If the array contains an invalid value, return the index for it, +// otherwise return size. +int FindInvalidValue(const int size, const double* x); + +// Utility routine to print an array of doubles to a string. If the +// array pointer is NULL, it is treated as an array of zeros. +void AppendArrayToString(const int size, const double* x, string* result); + extern const double kImpossibleValue; +// This routine takes an array of integer values, sorts and uniques +// them and then maps each value in the array to its position in the +// sorted+uniqued array. By doing this, if there are are k unique +// values in the array, each value is replaced by an integer in the +// range [0, k-1], while preserving their relative order. +// +// For example +// +// [1 0 3 5 0 1 5] +// +// gets mapped to +// +// [1 0 2 3 0 1 3] +void MapValuesToContiguousRange(int size, int* array); + } // namespace internal } // namespace ceres |