7#include <proxsuite-nlp/math.hpp>
9#define ALIGATOR_RAISE_IF_NAN(value) \
10 if (::aligator::math::check_value(value)) \
11 ALIGATOR_RUNTIME_ERROR("Encountered NaN.\n")
13#define ALIGATOR_RAISE_IF_NAN_NAME(value, name) \
14 if (::aligator::math::check_value(value)) \
15 ALIGATOR_RUNTIME_ERROR( \
16 fmt::format("Encountered NaN for variable {:s}\n", name))
18#define ALIGATOR_DYNAMIC_TYPEDEFS(Scalar) PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
20#define ALIGATOR_DYNAMIC_TYPEDEFS_WITH_ROW_TYPES(Scalar) \
21 ALIGATOR_DYNAMIC_TYPEDEFS(Scalar); \
22 using RowMatrixXs = typename Eigen::Transpose<MatrixXs>::PlainObject; \
23 using RowMatrixRef = Eigen::Ref<RowMatrixXs>; \
24 using ConstRowMatrixRef = Eigen::Ref<const RowMatrixXs>
29using proxsuite::nlp::math_types;
37 const std::string &text) {
38 Eigen::IOFormat ft = EIGEN_DEFAULT_IO_FORMAT;
41 int i = int(text.length()) - 1;
43 if (text[
size_t(i)] !=
'\n')
47 return mat.derived().format(ft);
54using proxsuite::nlp::math::check_scalar;
55using proxsuite::nlp::math::check_value;
56using proxsuite::nlp::math::infty_norm;
57using proxsuite::nlp::math::scalar_close;
61template <
typename T>
bool check_value(
const std::vector<T> &xs) {
62 const std::size_t n = xs.size();
63 for (std::size_t i = 0; i < n; i++) {
64 if (check_value<T>(xs[i]))
70template <
typename T>
void setZero(std::vector<T> &mats) {
71 for (std::size_t i = 0; i < mats.size(); i++) {
77template <
typename A,
typename B,
typename OutType,
typename Scalar>
79 std::vector<OutType> &c,
const Scalar alpha) {
80 assert(a.size() == b.size());
81 assert(a.size() == c.size());
82 const std::size_t N = a.size();
83 for (std::size_t i = 0; i < N; i++) {
84 c[i] = a[i] + alpha * b[i];
void setZero(std::vector< T > &mats)
void vectorMultiplyAdd(const std::vector< A > &a, const std::vector< B > &b, std::vector< OutType > &c, const Scalar alpha)
Compute zi = xi + alpha * yi for all i.
bool check_value(const std::vector< T > &xs)
Check if a std::vector of numerical objects has invalid values.
auto eigenPrintWithPreamble(const Eigen::EigenBase< D > &mat, const std::string &text)