14#ifndef OR_TOOLS_MATH_OPT_VALIDATORS_SPARSE_VECTOR_VALIDATOR_H_
15#define OR_TOOLS_MATH_OPT_VALIDATORS_SPARSE_VECTOR_VALIDATOR_H_
18#include "absl/status/status.h"
19#include "absl/strings/str_cat.h"
20#include "absl/strings/string_view.h"
31 absl::string_view value_name =
"values") {
33 return absl::InvalidArgumentError(absl::StrCat(
34 "Ids size= ", vector_view.
ids_size(),
" should be equal to ",
37 return absl::OkStatus();
41 typename = std::enable_if_t<!std::is_floating_point<T>::value> >
43 absl::string_view value_name =
"values") {
45 return absl::OkStatus();
49 typename = std::enable_if_t<!std::is_floating_point<T>::value> >
51 absl::string_view value_name =
"values") {
54 return absl::OkStatus();
58 typename = std::enable_if_t<std::is_floating_point<T>::value> >
61 absl::string_view value_name =
"values") {
63 for (
int i = 0, length = vector_view.
values_size(); i < length; ++i) {
65 << absl::StrCat(
" in: ", value_name,
" for id: ", vector_view.
ids(i),
66 " (at index: ", i,
")");
68 return absl::OkStatus();
72 typename = std::enable_if_t<std::is_floating_point<T>::value> >
75 absl::string_view value_name =
"values") {
78 return absl::OkStatus();
#define RETURN_IF_ERROR(expr)
absl::Span< const int64_t > ids() const
absl::Span< const T > values() const
absl::Status CheckIdsAndValuesSize(const SparseVectorView< T > &vector_view, absl::string_view value_name="values")
absl::Status CheckValues(const SparseVectorView< T > &vector_view, absl::string_view value_name="values")
absl::Status CheckIdsAndValues(const SparseVectorView< T > &vector_view, absl::string_view value_name="values")
absl::Status CheckScalar(const double value, const DoubleOptions &options)
Checks value is not NaN and satisfies the additional conditions in options.
absl::Status CheckIdsRangeAndStrictlyIncreasing(absl::Span< const int64_t > ids)
In SWIG mode, we don't want anything besides these top-level includes.