27 using Column = std::vector<ColEntry>;
57 Matrix(std::size_t expected_rows, std::size_t expected_cols) :
m_cols(expected_cols) {
77 if (
m_data[cur].col_index == j)
return m_data[cur].value;
92 for (It it = begin; it != end; ++it) {
106 std::vector<RowEntry>
result;
113 while (idx_1 != end_1 && idx_2 != end_2) {
114 if (
m_data[idx_1].col_index <
m_data[idx_2].col_index) {
117 }
else if (
m_data[idx_2].col_index <
m_data[idx_1].col_index) {
122 if (!carl::is_zero(new_value)) {
123 result.emplace_back(
m_data[idx_1].col_index, new_value);
130 for (; idx_1 != end_1; ++idx_1)
132 for (; idx_2 != end_2; ++idx_2)
179 col_iterator(Column::const_iterator it,
const std::vector<RowEntry>& data)
218 for (
const auto& e : row) {
223 if (!carl::is_one(scale)) {
224 for (
auto& e : row) e.value *= scale;
void reserve(std::size_t n)
std::vector< Column > m_cols
std::size_t non_zeros_in_row(const RowIndex ri) const
col_iterator col_end(ColIndex c) 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.
Matrix(Matrix &&other)=default
std::size_t non_zeros_in_col(const ColIndex ci) const
DataIndex row_end_idx(const RowIndex ri) const
col_view col_entries(const ColIndex ci) const
Matrix(std::size_t expected_rows, std::size_t expected_cols)
std::vector< DataIndex > m_row_starts
std::size_t n_rows() 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_cols() const
Matrix(const Matrix &other)=default
std::size_t non_zeros_total() const
std::vector< RowEntry > m_data
Matrix & operator=(const Matrix &other)=default
row_iterator row_end(RowIndex r) const
DataIndex row_start_idx(const RowIndex ri) const
std::vector< ColEntry > Column
std::size_t row_size(const RowIndex ri) const
col_iterator col_begin(ColIndex c) const
row_view row_entries(const RowIndex ri) const
row_iterator row_begin(RowIndex r) const
Rational coeff(const RowIndex i, const ColIndex j) const
auto get(const It &it, level)
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.
std::ostream & operator<<(std::ostream &os, const Matrix::RowEntry &e)
void gcd_normalize(std::vector< Matrix::RowEntry > &row)
RowEntry(ColIndex col, const Rational &v)
col_iterator & operator++()
const RowEntry & operator*() const
col_iterator(Column::const_iterator it, const std::vector< RowEntry > &data)
Column::const_iterator m_it
bool operator==(const col_iterator &other) const
const std::vector< RowEntry > & mr_data
bool operator!=(const col_iterator &other) const
const RowEntry * operator->() const
col_view(const Matrix &m, const ColIndex ci)
row_iterator(const std::vector< RowEntry > &data, DataIndex idx)
bool operator!=(const row_iterator &it) const
const std::vector< RowEntry > & mr_data
const RowEntry & operator*() const
bool operator==(const row_iterator &it) const
const RowEntry * operator->() const
row_iterator & operator++()
row_view(const Matrix &m, const RowIndex ri)