mirror of
https://github.com/Z3Prover/z3
synced 2025-10-21 06:40:31 +00:00
Api (#7097)
* rename ul_pair to column Signed-off-by: Lev Nachmanson <levnach@hotmail.com> * t Signed-off-by: Lev Nachmanson <levnach@hotmail.com> * simple test passed * remove an assert * relax an assertion * remove an obsolete function Signed-off-by: Lev Nachmanson <levnach@hotmail.com> * access a term by the term column * remove the column index from colunm.h * remove an unused method * remove debug code * fix the build of lp_tst Signed-off-by: Lev Nachmanson <levnach@hotmail.com> --------- Signed-off-by: Lev Nachmanson <levnach@hotmail.com> Co-authored-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
133546625c
commit
bdb9106f99
45 changed files with 587 additions and 973 deletions
|
@ -26,8 +26,12 @@ namespace lp {
|
|||
class lar_term {
|
||||
typedef unsigned lpvar;
|
||||
u_map<mpq> m_coeffs;
|
||||
// the column index related to the term
|
||||
lpvar m_j = -1;
|
||||
public:
|
||||
lar_term() {}
|
||||
// the column index related to the term
|
||||
lpvar j() const { return m_j; }
|
||||
lpvar& j() { return m_j; }
|
||||
void add_monomial(const mpq& c, unsigned j) {
|
||||
if (c.is_zero())
|
||||
return;
|
||||
|
@ -62,10 +66,11 @@ public:
|
|||
mpq a = it->get_data().m_value;
|
||||
this->m_coeffs.erase(term_column);
|
||||
for (auto p : t) {
|
||||
this->add_monomial(a * p.coeff(), p.column());
|
||||
this->add_monomial(a * p.coeff(), p.j());
|
||||
}
|
||||
}
|
||||
|
||||
// constructors
|
||||
lar_term() {}
|
||||
lar_term(const vector<std::pair<mpq, unsigned>>& coeffs) {
|
||||
for (auto const& p : coeffs) {
|
||||
add_monomial(p.first, p.second);
|
||||
|
@ -150,11 +155,11 @@ public:
|
|||
}
|
||||
|
||||
class ival {
|
||||
unsigned m_var;
|
||||
lpvar m_var;
|
||||
const mpq & m_coeff;
|
||||
public:
|
||||
ival(unsigned var, const mpq & val) : m_var(var), m_coeff(val) { }
|
||||
column_index column() const { return column_index(m_var); }
|
||||
ival(lpvar var, const mpq & val) : m_var(var), m_coeff(val) { }
|
||||
lpvar j() const { return m_var; }
|
||||
const mpq & coeff() const { return m_coeff; }
|
||||
};
|
||||
|
||||
|
@ -173,13 +178,13 @@ public:
|
|||
lpvar min_var = -1;
|
||||
mpq c;
|
||||
for (ival p : *this) {
|
||||
if (p.column() < min_var) {
|
||||
min_var = p.column();
|
||||
if (p.j() < min_var) {
|
||||
min_var = p.j();
|
||||
}
|
||||
}
|
||||
lar_term r;
|
||||
for (ival p : *this) {
|
||||
if (p.column() == min_var) {
|
||||
if (p.j() == min_var) {
|
||||
return p.coeff().is_one();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue