int main (int argc, char *argv[]) { tests_start_mpfr (); special (); test_specialz (mpfr_add_z, mpz_add, "add"); test_specialz (mpfr_sub_z, mpz_sub, "sub"); test_specialz (mpfr_mul_z, mpz_mul, "mul"); test_genericz (2, 100, 100, mpfr_add_z, "add"); test_genericz (2, 100, 100, mpfr_sub_z, "sub"); test_genericz (2, 100, 100, mpfr_mul_z, "mul"); test_genericz (2, 100, 100, mpfr_div_z, "div"); test_genericq (2, 100, 100, mpfr_add_q, "add"); test_genericq (2, 100, 100, mpfr_sub_q, "sub"); test_genericq (2, 100, 100, mpfr_mul_q, "mul"); test_genericq (2, 100, 100, mpfr_div_q, "div"); test_specialq (2, 100, 100, mpfr_mul_q, mpq_mul, "mul"); test_specialq (2, 100, 100, mpfr_div_q, mpq_div, "div"); test_specialq (2, 100, 100, mpfr_add_q, mpq_add, "add"); test_specialq (2, 100, 100, mpfr_sub_q, mpq_sub, "sub"); test_cmp_z (2, 100, 100); test_cmp_q (2, 100, 100); test_cmp_f (2, 100, 100); check_for_zero (); tests_end_mpfr (); return 0; }
bool affine_propagator::process_all_eqs(const affine r[], const affine vars[], double& maxProgress) { for (int p=0; p<n_vars; ++p) { bool has_converged = check_for_convergence(vars); if (has_converged) { maxProgress = 2.0; return false; } const affine& aa = r[p]; //cout << scientific; //cout << endl << "Eq. #" << p << endl << aa << endl; const bool to_discard = process_vars_in_eq(aa, vars); if (to_discard) { affine::isValid = false; return true; } if (!check_for_zero(r, p, p)) { //cout << "Deleted" << endl; affine::isValid = false; return true; } } return false; }
int main (int argc, char *argv[]) { tests_start_mpfr (); special (); test_specialz (mpfr_add_z, mpz_add, "add"); test_specialz (mpfr_sub_z, mpz_sub, "sub"); test_specialz (mpfr_mul_z, mpz_mul, "mul"); test_genericz (2, 100, 100, mpfr_add_z, "add"); test_genericz (2, 100, 100, mpfr_sub_z, "sub"); test_genericz (2, 100, 100, mpfr_mul_z, "mul"); test_genericz (2, 100, 100, mpfr_div_z, "div"); test_special2z (mpfr_z_sub, mpz_sub, "sub"); test_generic2z (2, 100, 100, mpfr_z_sub, "sub"); test_genericq (2, 100, 100, mpfr_add_q, "add"); test_genericq (2, 100, 100, mpfr_sub_q, "sub"); test_genericq (2, 100, 100, mpfr_mul_q, "mul"); test_genericq (2, 100, 100, mpfr_div_q, "div"); test_specialq (2, 100, 100, mpfr_mul_q, mpq_mul, "mul"); test_specialq (2, 100, 100, mpfr_div_q, mpq_div, "div"); test_specialq (2, 100, 100, mpfr_add_q, mpq_add, "add"); test_specialq (2, 100, 100, mpfr_sub_q, mpq_sub, "sub"); test_cmp_z (2, 100, 100); test_cmp_q (2, 100, 100); test_cmp_f (2, 100, 100); check_for_zero (); bug_mul_q_20100810 (); bug_div_q_20100810 (); bug_mul_div_q_20100818 (); reduced_expo_range (); addsubq_overflow (); coverage_mpfr_mul_q_20110218 (); tests_end_mpfr (); return 0; }
// maxProgress >=0, <= 1; ==2; void affine_propagator::prune(const affine r[], affine vars[], const int num_of_vars, bool& toDelete, double& maxProgress) { assert ( num_of_vars == n_vars ) ; maxProgress = 0.0; if (!affine::isValid) { //cout << "Deleted" << endl; toDelete = true; return; } reset_arrays(); bool to_discard = process_all_eqs(r, vars, maxProgress); if (to_discard) { affine::isValid = false; toDelete = true; return; } if (!check_for_zero(r, 0, n_vars-1)) { //cout << "Deleted" << endl; affine::isValid = false; toDelete = true; return; } bool has_changed = write_back(vars, maxProgress); if (!has_changed) maxProgress = 0.0; }
void mod_on_help_unsigned(small_type &us, int unb, int und, sc_digit *ud, int /* vnb */, int vnd, const sc_digit *vd) { #define COPY_DIGITS copy_digits_unsigned { // Body of mod_on_help int old_und = und; und = vec_skip_leading_zeros(und, ud); vnd = vec_skip_leading_zeros(vnd, vd); int cmp_res = vec_cmp(und, ud, vnd, vd); // u < v => u % v = u - case 4 if (cmp_res < 0) return; // u = v => u % v = 0 - case 3 if (cmp_res == 0) { us = SC_ZERO; vec_zero(old_und, ud); return; } // else if u > v - case 5 sc_digit vd0 = (*vd); if ((vnd == 1) && (vd0 == 1)) { us = SC_ZERO; vec_zero(old_und, ud); return; } // One extra digit for d is allocated to simplify vec_div_*(). int nd = sc_max(und, vnd) + 1; #ifdef SC_MAX_NBITS sc_digit d[MAX_NDIGITS + 1]; #else sc_digit *d = new sc_digit[nd]; #endif vec_zero(nd, d); if ((vnd == 1) && (und == 1)) d[0] = (*ud) % vd0; if ((vnd == 1) && (vd0 < HALF_DIGIT_RADIX)) d[0] = vec_rem_small(und, ud, vd0); else vec_rem_large(und, ud, vnd, vd, d); us = check_for_zero(us, nd - 1, d); if (us == SC_ZERO) vec_zero(old_und, ud); else COPY_DIGITS(us, unb, old_und, ud, sc_min(unb, vnd), nd - 1, d); #ifndef SC_MAX_NBITS delete [] d; #endif } #undef COPY_DIGITS }