mirror of
https://github.com/Z3Prover/z3
synced 2025-04-08 10:25:18 +00:00
avoid some bignum overhead in addmul
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
53e49eb428
commit
7387fc9dec
|
@ -23,6 +23,10 @@ Revision History:
|
|||
#include "math/lp/static_matrix.h"
|
||||
namespace lp {
|
||||
// each assignment for this matrix should be issued only once!!!
|
||||
|
||||
inline void addmul(double& r, double a, double b) { r += a*b; }
|
||||
inline void addmul(mpq& r, mpq const& a, mpq const& b) { r.addmul(a, b); }
|
||||
|
||||
template <typename T, typename X>
|
||||
void static_matrix<T, X>::init_row_columns(unsigned m, unsigned n) {
|
||||
lp_assert(m_rows.size() == 0 && m_columns.size() == 0);
|
||||
|
@ -54,14 +58,14 @@ template <typename T, typename X> bool static_matrix<T, X>::pivot_row_to_row_giv
|
|||
for (const auto & iv : m_rows[i]) {
|
||||
unsigned j = iv.var();
|
||||
if (j == pivot_col) continue;
|
||||
T alv = alpha * iv.coeff();
|
||||
lp_assert(!is_zero(iv.coeff()));
|
||||
int j_offs = m_vector_of_row_offsets[j];
|
||||
if (j_offs == -1) { // it is a new element
|
||||
T alv = alpha * iv.coeff();
|
||||
add_new_element(ii, j, alv);
|
||||
}
|
||||
else {
|
||||
rowii[j_offs].coeff() += alv;
|
||||
addmul(rowii[j_offs].coeff(), iv.coeff(), alpha);
|
||||
}
|
||||
}
|
||||
// clean the work vector
|
||||
|
|
|
@ -335,6 +335,10 @@ public:
|
|||
operator+=(k);
|
||||
else if (c.is_minus_one())
|
||||
operator-=(k);
|
||||
else if (k.is_one())
|
||||
operator+=(c);
|
||||
else if (k.is_minus_one())
|
||||
operator-=(c);
|
||||
else {
|
||||
rational tmp(k);
|
||||
tmp *= c;
|
||||
|
|
Loading…
Reference in a new issue