📄 gmpxx.h
字号:
static bool eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g) <= 0; }
static bool eval(mpf_srcptr f, unsigned long int l)
{ return mpf_cmp_ui(f, l) <= 0; }
static bool eval(unsigned long int l, mpf_srcptr f)
{ return mpf_cmp_ui(f, l) >= 0; }
static bool eval(mpf_srcptr f, signed long int l)
{ return mpf_cmp_si(f, l) <= 0; }
static bool eval(signed long int l, mpf_srcptr f)
{ return mpf_cmp_si(f, l) >= 0; }
static bool eval(mpf_srcptr f, double d)
{ return mpf_cmp_d(f, d) <= 0; }
static bool eval(double d, mpf_srcptr f)
{ return mpf_cmp_d(f, d) >= 0; }
#ifdef __MPFR_H
static bool eval(mpfr_srcptr f, mpfr_srcptr g)
{ return mpfr_cmp(f, g) <= 0; }
static bool eval(mpfr_srcptr f, unsigned long int l)
{ return mpfr_cmp_ui(f, l) <= 0; }
static bool eval(unsigned long int l, mpfr_srcptr f)
{ return mpfr_cmp_ui(f, l) >= 0; }
static bool eval(mpfr_srcptr f, signed long int l)
{
if (mpfr_sgn(f) >= 0)
{
if (l >= 0)
return mpfr_cmp_ui(f, l) <= 0;
else
return false;
}
else
{
if (l >= 0)
return true;
else
{
bool b;
mpfr_t temp;
mpfr_init2(temp, mpfr_get_prec(f));
mpfr_neg(temp, f, __gmp_default_rounding_mode);
b = (mpfr_cmp_ui(temp, -l) >= 0);
mpfr_clear(temp);
return b;
}
}
}
static bool eval(signed long int l, mpfr_srcptr f)
{
if (mpfr_sgn(f) >= 0)
{
if (l >= 0)
return mpfr_cmp_ui(f, l) >= 0;
else
return true;
}
else
{
if (l >= 0)
return false;
else
{
bool b;
mpfr_t temp;
mpfr_init2(temp, mpfr_get_prec(f));
mpfr_neg(temp, f, __gmp_default_rounding_mode);
b = (mpfr_cmp_ui(temp, -l) <= 0);
mpfr_clear(temp);
return b;
}
}
}
static bool eval(mpfr_srcptr f, double d)
{
bool b;
mpfr_t temp;
mpfr_init2(temp, 8*sizeof(double));
mpfr_set_d(temp, d, __gmp_default_rounding_mode);
b = (mpfr_cmp(f, temp) <= 0);
mpfr_clear(temp);
return b;
}
static bool eval(double d, mpfr_srcptr f)
{
bool b;
mpfr_t temp;
mpfr_init2(temp, 8*sizeof(double));
mpfr_set_d(temp, d, __gmp_default_rounding_mode);
b = (mpfr_cmp(temp, f) <= 0);
mpfr_clear(temp);
return b;
}
#endif
};
struct __gmp_binary_greater
{
static bool eval(mpz_srcptr z, mpz_srcptr w) { return mpz_cmp(z, w) > 0; }
static bool eval(mpz_srcptr z, unsigned long int l)
{ return mpz_cmp_ui(z, l) > 0; }
static bool eval(unsigned long int l, mpz_srcptr z)
{ return mpz_cmp_ui(z, l) < 0; }
static bool eval(mpz_srcptr z, signed long int l)
{ return mpz_cmp_si(z, l) > 0; }
static bool eval(signed long int l, mpz_srcptr z)
{ return mpz_cmp_si(z, l) < 0; }
static bool eval(mpz_srcptr z, double d)
{ return mpz_cmp_d(z, d) > 0; }
static bool eval(double d, mpz_srcptr z)
{ return mpz_cmp_d(z, d) < 0; }
static bool eval(mpq_srcptr q, mpq_srcptr r) { return mpq_cmp(q, r) > 0; }
static bool eval(mpq_srcptr q, unsigned long int l)
{ return mpq_cmp_ui(q, l, 1) > 0; }
static bool eval(unsigned long int l, mpq_srcptr q)
{ return mpq_cmp_ui(q, l, 1) < 0; }
static bool eval(mpq_srcptr q, signed long int l)
{ return mpq_cmp_si(q, l, 1) > 0; }
static bool eval(signed long int l, mpq_srcptr q)
{ return mpq_cmp_si(q, l, 1) < 0; }
static bool eval(mpq_srcptr q, double d)
{
bool b;
mpq_t temp;
mpq_init(temp);
mpq_set_d(temp, d);
b = (mpq_cmp(q, temp) > 0);
mpq_clear(temp);
return b;
}
static bool eval(double d, mpq_srcptr q)
{
bool b;
mpq_t temp;
mpq_init(temp);
mpq_set_d(temp, d);
b = (mpq_cmp(temp, q) > 0);
mpq_clear(temp);
return b;
}
static bool eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g) > 0; }
static bool eval(mpf_srcptr f, unsigned long int l)
{ return mpf_cmp_ui(f, l) > 0; }
static bool eval(unsigned long int l, mpf_srcptr f)
{ return mpf_cmp_ui(f, l) < 0; }
static bool eval(mpf_srcptr f, signed long int l)
{ return mpf_cmp_si(f, l) > 0; }
static bool eval(signed long int l, mpf_srcptr f)
{ return mpf_cmp_si(f, l) < 0; }
static bool eval(mpf_srcptr f, double d)
{ return mpf_cmp_d(f, d) > 0; }
static bool eval(double d, mpf_srcptr f)
{ return mpf_cmp_d(f, d) < 0; }
#ifdef __MPFR_H
static bool eval(mpfr_srcptr f, mpfr_srcptr g)
{ return mpfr_cmp(f, g) > 0; }
static bool eval(mpfr_srcptr f, unsigned long int l)
{ return mpfr_cmp_ui(f, l) > 0; }
static bool eval(unsigned long int l, mpfr_srcptr f)
{ return mpfr_cmp_ui(f, l) < 0; }
static bool eval(mpfr_srcptr f, signed long int l)
{
if (mpfr_sgn(f) >= 0)
{
if (l >= 0)
return mpfr_cmp_ui(f, l) > 0;
else
return true;
}
else
{
if (l >= 0)
return false;
else
{
bool b;
mpfr_t temp;
mpfr_init2(temp, mpfr_get_prec(f));
mpfr_neg(temp, f, __gmp_default_rounding_mode);
b = (mpfr_cmp_ui(temp, -l) < 0);
mpfr_clear(temp);
return b;
}
}
}
static bool eval(signed long int l, mpfr_srcptr f)
{
if (mpfr_sgn(f) >= 0)
{
if (l >= 0)
return mpfr_cmp_ui(f, l) < 0;
else
return false;
}
else
{
if (l >= 0)
return true;
else
{
bool b;
mpfr_t temp;
mpfr_init2(temp, mpfr_get_prec(f));
mpfr_neg(temp, f, __gmp_default_rounding_mode);
b = (mpfr_cmp_ui(temp, -l) > 0);
mpfr_clear(temp);
return b;
}
}
}
static bool eval(mpfr_srcptr f, double d)
{
bool b;
mpfr_t temp;
mpfr_init2(temp, 8*sizeof(double));
mpfr_set_d(temp, d, __gmp_default_rounding_mode);
b = (mpfr_cmp(f, temp) > 0);
mpfr_clear(temp);
return b;
}
static bool eval(double d, mpfr_srcptr f)
{
bool b;
mpfr_t temp;
mpfr_init2(temp, 8*sizeof(double));
mpfr_set_d(temp, d, __gmp_default_rounding_mode);
b = (mpfr_cmp(temp, f) > 0);
mpfr_clear(temp);
return b;
}
#endif
};
struct __gmp_binary_greater_equal
{
static bool eval(mpz_srcptr z, mpz_srcptr w) { return mpz_cmp(z, w) >= 0; }
static bool eval(mpz_srcptr z, unsigned long int l)
{ return mpz_cmp_ui(z, l) >= 0; }
static bool eval(unsigned long int l, mpz_srcptr z)
{ return mpz_cmp_ui(z, l) <= 0; }
static bool eval(mpz_srcptr z, signed long int l)
{ return mpz_cmp_si(z, l) >= 0; }
static bool eval(signed long int l, mpz_srcptr z)
{ return mpz_cmp_si(z, l) <= 0; }
static bool eval(mpz_srcptr z, double d)
{ return mpz_cmp_d(z, d) >= 0; }
static bool eval(double d, mpz_srcptr z)
{ return mpz_cmp_d(z, d) <= 0; }
static bool eval(mpq_srcptr q, mpq_srcptr r) { return mpq_cmp(q, r) >= 0; }
static bool eval(mpq_srcptr q, unsigned long int l)
{ return mpq_cmp_ui(q, l, 1) >= 0; }
static bool eval(unsigned long int l, mpq_srcptr q)
{ return mpq_cmp_ui(q, l, 1) <= 0; }
static bool eval(mpq_srcptr q, signed long int l)
{ return mpq_cmp_si(q, l, 1) >= 0; }
static bool eval(signed long int l, mpq_srcptr q)
{ return mpq_cmp_si(q, l, 1) <= 0; }
static bool eval(mpq_srcptr q, double d)
{
bool b;
mpq_t temp;
mpq_init(temp);
mpq_set_d(temp, d);
b = (mpq_cmp(q, temp) >= 0);
mpq_clear(temp);
return b;
}
static bool eval(double d, mpq_srcptr q)
{
bool b;
mpq_t temp;
mpq_init(temp);
mpq_set_d(temp, d);
b = (mpq_cmp(temp, q) >= 0);
mpq_clear(temp);
return b;
}
static bool eval(mpf_srcptr f, mpf_srcptr g) { return mpf_cmp(f, g) >= 0; }
static bool eval(mpf_srcptr f, unsigned long int l)
{ return mpf_cmp_ui(f, l) >= 0; }
static bool eval(unsigned long int l, mpf_srcptr f)
{ return mpf_cmp_ui(f, l) <= 0; }
static bool eval(mpf_srcptr f, signed long int l)
{ return mpf_cmp_si(f, l) >= 0; }
static bool eval(signed long int l, mpf_srcptr f)
{ return mpf_cmp_si(f, l) <= 0; }
static bool eval(mpf_srcptr f, double d)
{ return mpf_cmp_d(f, d) >= 0; }
static bool eval(double d, mpf_srcptr f)
{ return mpf_cmp_d(f, d) <= 0; }
#ifdef __MPFR_H
static bool eval(mpfr_srcptr f, mpfr_srcptr g)
{ return mpfr_cmp(f, g) >= 0; }
static bool eval(mpfr_srcptr f, unsigned long int l)
{ return mpfr_cmp_ui(f, l) >= 0; }
static bool eval(unsigned long int l, mpfr_srcptr f)
{ return mpfr_cmp_ui(f, l) <= 0; }
static bool eval(mpfr_srcptr f, signed long int l)
{
if (mpfr_sgn(f) >= 0)
{
if (l >= 0)
return mpfr_cmp_ui(f, l) >= 0;
else
return true;
}
else
{
if (l >= 0)
return false;
else
{
bool b;
mpfr_t temp;
mpfr_init2(temp, mpfr_get_prec(f));
mpfr_neg(temp, f, __gmp_default_rounding_mode);
b = (mpfr_cmp_ui(temp, -l) <= 0);
mpfr_clear(temp);
return b;
}
}
}
static bool eval(signed long int l, mpfr_srcptr f)
{
if (mpfr_sgn(f) >= 0)
{
if (l >= 0)
return mpfr_cmp_ui(f, l) <= 0;
else
return false;
}
else
{
if (l >= 0)
return true;
else
{
bool b;
mpfr_t temp;
mpfr_init2(temp, mpfr_get_prec(f));
mpfr_neg(temp, f, __gmp_default_rounding_mode);
b = (mpfr_cmp_ui(temp, -l) >= 0);
mpfr_clear(temp);
return b;
}
}
}
static bool eval(mpfr_srcptr f, double d)
{
bool b;
mpfr_t temp;
mpfr_init2(temp, 8*sizeof(double));
mpfr_set_d(temp, d, __gmp_default_rounding_mode);
b = (mpfr_cmp(f, temp) >= 0);
mpfr_clear(temp);
return b;
}
static bool eval(double d, mpfr_srcptr f)
{
bool b;
mpfr_t temp;
mpfr_init2(temp, 8*sizeof(double));
mpfr_set_d(temp, d, __gmp_default_rounding_mode);
b = (mpfr_cmp(temp, f) >= 0);
mpfr_clear(temp);
return b;
}
#endif
};
struct __gmp_unary_increment
{
static void eval(mpz_ptr z, mpz_srcptr w) { mpz_add_ui(z, w, 1); }
static void eval(mpq_ptr q, mpq_srcptr r)
{ mpz_add(mpq_numref(q), mpq_numref(r), mpq_denref(r)); }
static void eval(mpf_ptr f, mpf_srcptr g) { mpf_add_ui(f, g, 1); }
#ifdef __MPFR_H
static void eval(mpfr_ptr f, mpfr_srcptr g, mp_rnd_t mode)
{ mpfr_add_ui(f, g, 1, mode); }
#endif
};
struct __gmp_unary_decrement
{
static void eval(mpz_ptr z, mpz_srcptr w) { mpz_sub_ui(z, w, 1); }
static void eval(mpq_ptr q, mpq_srcptr r)
{ mpz_sub(mpq_numref(q), mpq_numref(r), mpq_denref(r)); }
static void eval(mpf_ptr f, mpf_srcptr g) { mpf_sub_ui(f, g, 1); }
#ifdef __MPFR_H
static void eval(mpfr_ptr f, mpfr_srcptr g, mp_rnd_t mode)
{ mpfr_sub_ui(f, g, 1, mode); }
#endif
};
struct __gmp_abs_function
{
static void eval(mpz_ptr z, mpz_srcptr w) { mpz_abs(z, w); }
static void eval(mpq_ptr q, mpq_srcptr r) { mpq_abs(q, r); }
static void eval(mpf_ptr f, mpf_srcptr g) { mpf_abs(f, g); }
#ifdef __MPFR_H
static void eval(mpfr_ptr f, mpfr_srcptr g, mp_rnd_t mode)
{ mpfr_abs(f, g, mode); }
#endif
};
struct __gmp_trunc_function
{
static void eval(mpf_ptr f, mpf_srcptr g) { mpf_trunc(f, g); }
#ifdef __MPFR_H
static void eval(mpfr_ptr f, mpfr_srcptr g, mp_rnd_t) { mpfr_trunc(f, g); }
#endif
};
struct __gmp_floor_function
{
static void eval(mpf_ptr f, mpf_srcptr g) { mpf_floor(f, g); }
#ifdef __MPFR_H
static void eval(mpfr_ptr f, mpfr_srcptr g, mp_rnd_t) { mpfr_floor(f, g); }
#endif
};
struct __gmp_ceil_function
{
static void eval(mpf_ptr f, mpf_srcptr g) { mpf_ceil(f, g); }
#ifdef __MPFR_H
static void eval(mpfr_ptr f, mpfr_srcptr g, mp_rnd_t) { mpfr_ceil(f, g); }
#endif
};
struct __gmp_sqrt_function
{
static void eval(mpz_ptr z, mpz_srcptr w) { mpz_sqrt(z, w); }
static void eval(mpf_ptr f, mpf_srcptr g) { mpf_sqrt(f, g); }
#ifdef __MPFR_H
static void eval(mpfr_ptr f, mpfr_srcptr g, mp_rnd_t mode)
{ mpfr_sqrt(f, g, mode); }
#endif
};
struct __gmp_hypot_function
{
static void eval(mpf_ptr f, mpf_srcptr g, mpf_srcptr h)
{
mpf_t temp;
mpf_init2(temp, mpf_get_prec(f));
mpf_mul(temp, g, g);
mpf_mul(f, h, h);
mpf_add(f, f, temp);
mpf_sqrt(f, f);
mpf_clear(temp);
}
static void eval(mpf_ptr f, mpf_srcptr g, unsigned long int l)
{
mpf_t temp;
mpf_init2(temp, mpf_get_prec(f));
mpf_mul(temp, g, g);
mpf_set_ui(f, l);
mpf_mul(f, f, f);
mpf_add(f, f, temp);
mpf_sqrt(f, f);
mpf_clear(temp);
}
static void eval(mpf_ptr f, unsigned long int l, mpf_srcptr g)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -