14 std::is_base_of<Eigen::DenseBase<T>, T>::value;
18 std::is_base_of<Eigen::MatrixBase<T>, T>::value;
20template <
typename T,
typename T2 =
void>
26#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar) \
27 using VectorXs = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>; \
28 using MatrixXs = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>; \
29 using VectorOfVectors = std::vector<VectorXs>; \
30 using VectorRef = Eigen::Ref<VectorXs>; \
31 using MatrixRef = Eigen::Ref<MatrixXs>; \
32 using ConstVectorRef = Eigen::Ref<const VectorXs>; \
33 using ConstMatrixRef = Eigen::Ref<const MatrixXs>; \
34 using VectorOfRef = std::vector<VectorRef>; \
35 using Vector3s = Eigen::Matrix<Scalar, 3, 1>; \
36 using Vector6s = Eigen::Matrix<Scalar, 6, 1>; \
37 using Matrix3Xs = Eigen::Matrix<Scalar, 3, Eigen::Dynamic>; \
38 using Matrix6Xs = Eigen::Matrix<Scalar, 6, Eigen::Dynamic>; \
39 using Matrix6s = Eigen::Matrix<Scalar, 6, 6>
50template <
typename MatType>
51typename MatType::Scalar
infty_norm(
const Eigen::MatrixBase<MatType> &z) {
52 if (z.rows() == 0 || z.cols() == 0) {
55 return z.template lpNorm<Eigen::Infinity>();
59template <
typename MatType>
60typename MatType::Scalar
infty_norm(
const std::vector<MatType> &z) {
61 const std::size_t n = z.size();
62 typename MatType::Scalar out = 0.;
63 for (std::size_t i = 0; i < n; i++) {
70template <
typename Scalar>
inline bool check_scalar(
const Scalar value) {
71 return std::isnan(value) || std::isinf(value);
78template <
typename Scalar>
80 const Scalar prec = std::numeric_limits<Scalar>::epsilon()) {
81 return std::abs(a - b) < prec * (1 + std::max(std::abs(a), std::abs(b)));
84template <typename T, typename = std::enable_if_t<std::is_scalar<T>::value>>
86 static_assert(std::is_scalar<T>::value,
"Parameter T should be scalar.");
90template <
typename MatrixType>
92 return (x.hasNaN() || (!x.allFinite()));
95template <
typename T> T
sign(
const T &x) {
96 static_assert(std::is_scalar<T>::value,
"Parameter T should be scalar.");
97 return T((x > T(0)) - (x < T(0)));
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
bool check_scalar(const Scalar value)
Check that a scalar is neither inf, nor NaN.
MatType::Scalar infty_norm(const Eigen::MatrixBase< MatType > &z)
bool check_value(const T &x)
bool scalar_close(const Scalar a, const Scalar b, const Scalar prec=std::numeric_limits< Scalar >::epsilon())
Tests whether a and b are close, within absolute and relative precision prec.
std::enable_if_t< is_eigen_dense_type< T >, T2 > enable_if_eigen_dense
constexpr bool is_eigen_matrix_type
constexpr bool is_eigen_dense_type
Typedefs for math (Eigen vectors, matrices) depending on scalar type.