3 #include <carl-arith/numbers/numbers.h>
29 using Column = std::vector<ColEntry>;
59 Matrix(std::size_t expected_rows, std::size_t expected_cols) :
m_cols(expected_cols) {
79 if (
m_data[cur].col_index == j)
return m_data[cur].value;
94 for (It it = begin; it != end; ++it) {
108 std::vector<RowEntry>
result;
115 while (idx_1 != end_1 && idx_2 != end_2) {
116 if (
m_data[idx_1].col_index <
m_data[idx_2].col_index) {
119 }
else if (
m_data[idx_2].col_index <
m_data[idx_1].col_index) {
124 if (!carl::is_zero(new_value)) {
125 result.emplace_back(
m_data[idx_1].col_index, new_value);
132 for (; idx_1 != end_1; ++idx_1)
134 for (; idx_2 != end_2; ++idx_2)
181 col_iterator(Column::const_iterator it,
const std::vector<RowEntry>& data)
215 for (
const auto& e : row) {
220 if (!carl::is_one(scale)) {
221 for (
auto& e : row) e.value *= scale;
std::vector< DataIndex > m_row_starts
Rational coeff(const RowIndex i, const ColIndex j) const
std::vector< ColEntry > Column
std::size_t non_zeros_in_row(const RowIndex ri) const
std::vector< RowEntry > m_data
col_iterator col_begin(ColIndex c) const
Matrix(const Matrix &other)=default
col_view col_entries(const ColIndex ci) const
Matrix(std::size_t expected_rows, std::size_t expected_cols)
col_iterator col_end(ColIndex c) const
std::size_t non_zeros_total() const
std::vector< RowEntry > combine(const RowIndex row_idx_1, const Rational &scale_1, const RowIndex row_idx_2, const Rational &scale_2) const
Computes scale_1*A_(i,-) + scale_2*A_(j,-) where i=row_idx_1, j=row_idx_2.
std::size_t n_cols() const
DataIndex row_end_idx(const RowIndex ri) const
Matrix & operator=(const Matrix &other)=default
std::size_t row_size(const RowIndex ri) const
row_view row_entries(const RowIndex ri) const
row_iterator row_end(RowIndex r) const
void reserve(std::size_t n)
row_iterator row_begin(RowIndex r) const
RowIndex append_row(const It &begin, const It &end)
Appends the row contained in the range between begin and end to the matrix.
std::size_t n_rows() const
Matrix(Matrix &&other)=default
std::size_t non_zeros_in_col(const ColIndex ci) const
std::vector< Column > m_cols
DataIndex row_start_idx(const RowIndex ri) const
void gcd_normalize(std::vector< typename Matrix::RowEntry > &row)
Numeric lcm(const Numeric &_valueA, const Numeric &_valueB)
Calculates the least common multiple of the two arguments.
Numeric gcd(const Numeric &_valueA, const Numeric &_valueB)
Calculates the greatest common divisor of the two arguments.
RowEntry(ColIndex col, const Rational &v)
const std::vector< RowEntry > & mr_data
col_iterator & operator++()
bool operator!=(const col_iterator &other) const
const RowEntry * operator->() const
Column::const_iterator m_it
const RowEntry & operator*() const
col_iterator(Column::const_iterator it, const std::vector< RowEntry > &data)
bool operator==(const col_iterator &other) const
col_view(const Matrix &m, const ColIndex ci)
bool operator==(const row_iterator &it) const
row_iterator(const std::vector< RowEntry > &data, DataIndex idx)
const std::vector< RowEntry > & mr_data
bool operator!=(const row_iterator &it) const
row_iterator & operator++()
const RowEntry & operator*() const
const RowEntry * operator->() const
row_view(const Matrix &m, const RowIndex ri)