17         struct EqualityConstraint
 
   20             friend std::ostream &operator<<(std::ostream &os, 
const EqualityConstraint &constraint);
 
   23         struct PositiveConstraint
 
   26             friend std::ostream &operator<<(std::ostream &os, 
const PositiveConstraint &constraint);
 
   34             friend std::ostream &operator<<(std::ostream &os, 
const BoxConstraint &constraint);
 
   37         struct SecondOrderConeConstraint
 
   39             std::vector<Affine> norm;
 
   41             friend std::ostream &operator<<(std::ostream &os, 
const SecondOrderConeConstraint &constraint);
 
   59         friend std::ostream &operator<<(std::ostream &os, 
const Constraint &constraint);
 
   69         void asEquality(
const internal::Affine &affine);
 
   70         void asPositive(
const internal::Affine &affine);
 
   71         void asBox(
const internal::Affine &lower, 
const internal::Affine &middle, 
const internal::Affine &upper);
 
   72         void asSecondOrderCone(
const std::vector<internal::Affine> &norm, 
const internal::Affine &affine);
 
   74         using constraint_variant_t = std::variant<internal::EqualityConstraint,
 
   75                                                   internal::PositiveConstraint,
 
   76                                                   internal::BoxConstraint,
 
   77                                                   internal::SecondOrderConeConstraint>;
 
   78         constraint_variant_t data;
 
  118     template <
typename Derived>
 
  119     std::vector<Constraint> 
equalTo(
const Eigen::MatrixBase<Derived> &lhs, 
const Scalar &rhs)
 
  121         static_assert(std::is_same_v<
typename Eigen::MatrixBase<Derived>::Scalar, 
Scalar>);
 
  123         std::vector<Constraint> constraints;
 
  125         for (
int row = 0; row < lhs.rows(); row++)
 
  127             for (
int col = 0; col < lhs.cols(); col++)
 
  129                 constraints.push_back(
equalTo(lhs(row, col), rhs));
 
  144     template <
typename Derived>
 
  145     std::vector<Constraint> 
equalTo(
const Scalar &lhs, 
const Eigen::MatrixBase<Derived> &rhs)
 
  159     template <
typename DerivedLhs, 
typename DerivedRhs>
 
  160     std::vector<Constraint> 
equalTo(
const Eigen::MatrixBase<DerivedLhs> &lhs, 
const Eigen::MatrixBase<DerivedRhs> &rhs)
 
  162         static_assert(std::is_same_v<
typename Eigen::MatrixBase<DerivedLhs>::Scalar, 
Scalar>);
 
  163         static_assert(std::is_same_v<
typename Eigen::MatrixBase<DerivedRhs>::Scalar, 
Scalar>);
 
  165         std::vector<Constraint> constraints;
 
  168         if (lhs.rows() != rhs.rows() or lhs.cols() != rhs.cols())
 
  170             throw std::runtime_error(
"Invalid dimensions in constraint.");
 
  173         for (
int row = 0; row < rhs.rows(); row++)
 
  175             for (
int col = 0; col < rhs.cols(); col++)
 
  177                 constraints.push_back(
equalTo(lhs(row, col), rhs(row, col)));
 
  192     template <
typename Derived>
 
  193     std::vector<Constraint> 
lessThan(
const Eigen::MatrixBase<Derived> &lhs, 
const Scalar &rhs)
 
  195         static_assert(std::is_same_v<
typename Eigen::MatrixBase<Derived>::Scalar, 
Scalar>);
 
  197         std::vector<Constraint> constraints;
 
  199         for (
int row = 0; row < lhs.rows(); row++)
 
  201             for (
int col = 0; col < lhs.cols(); col++)
 
  203                 constraints.push_back(
lessThan(lhs(row, col), rhs));
 
  218     template <
typename Derived>
 
  219     std::vector<Constraint> 
lessThan(
const Scalar &lhs, 
const Eigen::MatrixBase<Derived> &rhs)
 
  221         static_assert(std::is_same_v<
typename Eigen::MatrixBase<Derived>::Scalar, 
Scalar>);
 
  223         std::vector<Constraint> constraints;
 
  225         for (
int row = 0; row < rhs.rows(); row++)
 
  227             for (
int col = 0; col < rhs.cols(); col++)
 
  229                 constraints.push_back(
lessThan(lhs, rhs(row, col)));
 
  245     template <
typename DerivedLhs, 
typename DerivedRhs>
 
  246     std::vector<Constraint> 
lessThan(
const Eigen::MatrixBase<DerivedLhs> &lhs, 
const Eigen::MatrixBase<DerivedRhs> &rhs)
 
  248         static_assert(std::is_same_v<
typename Eigen::MatrixBase<DerivedLhs>::Scalar, 
Scalar>);
 
  249         static_assert(std::is_same_v<
typename Eigen::MatrixBase<DerivedRhs>::Scalar, 
Scalar>);
 
  251         std::vector<Constraint> constraints;
 
  253         if ((lhs.rows() != rhs.rows()) or
 
  254             (lhs.cols() != rhs.cols()))
 
  256             throw std::runtime_error(
"Invalid dimensions in constraint.");
 
  259         for (
int row = 0; row < rhs.rows(); row++)
 
  261             for (
int col = 0; col < rhs.cols(); col++)
 
  263                 constraints.push_back(
lessThan(lhs(row, col), rhs(row, col)));
 
  279     template <
typename DerivedLhs, 
typename DerivedRhs>
 
  280     std::vector<Constraint> 
greaterThan(
const Eigen::MatrixBase<DerivedLhs> &lhs, 
const Eigen::MatrixBase<DerivedRhs> &rhs)
 
  293     template <
typename Derived>
 
  307     template <
typename Derived>
 
  324     template <
typename DerivedLower, 
typename DerivedM
iddle, 
typename DerivedUpper>
 
  325     std::vector<Constraint> 
box(
const Eigen::MatrixBase<DerivedLower> &lower,
 
  326                                 const Eigen::MatrixBase<DerivedMiddle> &middle,
 
  327                                 const Eigen::MatrixBase<DerivedUpper> &upper)
 
  329         static_assert(std::is_same_v<
typename Eigen::MatrixBase<DerivedLower>::Scalar, 
Scalar>);
 
  330         static_assert(std::is_same_v<
typename Eigen::MatrixBase<DerivedMiddle>::Scalar, 
Scalar>);
 
  331         static_assert(std::is_same_v<
typename Eigen::MatrixBase<DerivedUpper>::Scalar, 
Scalar>);
 
  333         if (lower.rows() != middle.rows() or middle.rows() != upper.rows() or
 
  334             lower.cols() != middle.cols() or middle.cols() != upper.cols())
 
  336             throw std::runtime_error(
"Invalid dimensions in constraint.");
 
  339         std::vector<Constraint> constraints;
 
  341         for (
int row = 0; row < middle.rows(); row++)
 
  343             for (
int col = 0; col < middle.cols(); col++)
 
  345                 constraints.push_back(
box(lower(row, col),
 
  363     template <
typename Derived>
 
  365                                 const Eigen::MatrixBase<Derived> &middle,
 
  368         static_assert(std::is_same_v<
typename Eigen::MatrixBase<Derived>::Scalar, 
Scalar>);
 
  370         std::vector<Constraint> constraints;
 
  372         for (
int row = 0; row < middle.rows(); row++)
 
  374             for (
int col = 0; col < middle.cols(); col++)
 
  376                 constraints.push_back(
box(lower,