3 #include <eigen3/Eigen/Core>
4 #include <eigen3/Eigen/Dense>
5 #include <eigen3/Eigen/StdVector>
9 using vector_t = Eigen::Matrix<Rational, Eigen::Dynamic, 1>;
10 using matrix_t = Eigen::Matrix<Rational, Eigen::Dynamic, Eigen::Dynamic>;
15 for (Eigen::Index index = 0; index < res.rows(); index++) {
16 res.row(index) = original.row(Eigen::Index(rowIndices[index]));
24 std::vector<std::size_t> remainingRows;
25 for (Eigen::Index i = 0; i < original.rows(); ++i) {
26 if (
std::find(rowIndices.begin(), rowIndices.end(), std::size_t(i)) == rowIndices.end()) {
27 remainingRows.emplace_back(i);
34 assert(row.rows() == original.cols());
35 original.conservativeResize(original.rows() + 1, original.cols());
36 original.row(original.rows() - 1) = row;
41 assert(original.cols() == other.cols());
42 Eigen::Index originalRowCount = original.rows();
43 original.conservativeResize(original.rows() + other.rows(), original.cols());
44 original.block(originalRowCount, 0, other.rows(), other.cols()) = other;
49 Eigen::Index originalRowCount = original.rows();
50 original.conservativeResize(original.rows() + other.rows(), original.cols());
51 original.block(originalRowCount, 0, other.rows(), other.cols()) = other;
56 original.conservativeResize(original.rows() + 1);
57 original(original.rows() - 1) = entry;
69 auto oldSize = original.rows();
70 original.conservativeResize(original.rows() + numberZeroes);
71 original.block(oldSize, 0, 1, numberZeroes) = vector_t::Zero(numberZeroes);
78 for (Eigen::Index index = 0; index < res.rows(); index++) {
79 res(index) = original(Eigen::Index(rowIndices[index]));
92 return original.block(0, 1, original.rows(), original.cols() - 1);
94 if (Eigen::Index(colIndex) == original.cols() - 1) {
95 return original.block(0, 0, original.rows(), original.cols() - 1);
98 res.block(0, 0, original.rows(), colIndex) = original.leftCols(colIndex);
99 res.block(0, colIndex, original.rows(), original.cols() - (colIndex + 1)) = original.rightCols(
100 original.cols() - (colIndex + 1));
107 for (Eigen::Index index = 0; index < res.cols(); index++) {
108 res.col(index) = original.col(Eigen::Index(colIndices[index]));
static bool find(V &ts, const T &t)
matrix_t & concatenateVertically(matrix_t &original, const matrix_t &other)
matrix_t removeRows(const matrix_t &original, const std::vector< std::size_t > &rowIndices)
matrix_t selectCols(const matrix_t &original, const std::vector< std::size_t > &colIndices)
Eigen::Matrix< Rational, Eigen::Dynamic, Eigen::Dynamic > matrix_t
Eigen::Matrix< Rational, Eigen::Dynamic, 1 > vector_t
matrix_t selectRows(const matrix_t &original, const std::vector< std::size_t > &rowIndices)
matrix_t & appendRow(matrix_t &original, const vector_t &row)
matrix_t removeCol(const matrix_t &original, std::size_t colIndex)
vector_t appendZeroes(vector_t &original, std::size_t numberZeroes)
Append a specified number of zeroes at the end of a vector_t.