Module: BigMathR::EDF
- Defined in:
- ext/bigdecimal/math_r/edf.c,
ext/bigdecimal/math_r/math_r.c
Overview
A module that treats the exponential decomposition formula. It is used internally.
This formula was discovered by the author shortly afterwards. It will be proven in time.
- Reference
Class Method Summary collapse
-
.expxt(x, t, prec) ⇒ BigDecimal
Calculate the exponential function of
xwith baset. -
.logxt(x, t, prec) ⇒ BigDecimal
Computes fraction of
xwith its complementtin the exponential decomposition. -
.rcm10(x) ⇒ Array
Based on the radix complementation method, exponentially-decompose
xon radix 10. -
.rcm2(x) ⇒ Array
Based on the radix complementation method, exponentially-decompose
xon radix 2.
Class Method Details
.expxt(x, t, prec) ⇒ BigDecimal
Calculate the exponential function of x with base t.
55 56 57 58 59 |
# File 'ext/bigdecimal/math_r/edf.c', line 55
static VALUE
__impl_edf_expxt(VALUE unused_obj, VALUE x, VALUE t, VALUE prec)
{
return rb_bigmath_expxt(x, t, prec);
}
|
.logxt(x, t, prec) ⇒ BigDecimal
Computes fraction of x with its complement t in the exponential decomposition.
Complement is equal to the base x, and the decomposition varies depending on the value given.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'ext/bigdecimal/math_r/edf.c', line 137
static VALUE
__impl_edf_logxt(VALUE unused_obj, VALUE x, VALUE t, VALUE prec)
{
rb_check_precise(prec);
x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RAWVALUE);
if (rb_num_notequal_p(x, x) ||
rb_num_negative_p(x) ||
NUM2INT(rb_num_cmpeql(INT2FIX(1), x)) == 1 ||
NUM2INT(rb_num_cmpeql(x, t)) != -1)
{
if (rb_num_equal_p(x, t))
return BIG_ONE;
rb_raise(rb_eFloatDomainError, "Numerical arguments are out of range: (1 <= x <= t)");
}
t = rb_num_canonicalize(t, prec, ARG_REAL, ARG_RAWVALUE);
x = logxt_edf(x, t, prec);
return rb_num_round(x, prec);
}
|
.rcm10(x) ⇒ Array
Based on the radix complementation method, exponentially-decompose x on radix 10.
It behaves the same as frexp() in C, except that the radix is 10 and the value range is 1 leq y lt 10.
If x is not positive finite except 0, then it is inherently undefined. However, if x is negative finite, it will return a value range of -10 lt y leq -1.
112 113 114 115 116 117 118 |
# File 'ext/bigdecimal/math_r/edf.c', line 112
static VALUE
__impl_edf_rcm10(VALUE unused_obj, VALUE x)
{
VALUE exp, fra;
fra = rcm10_edf(x, &exp);
return rb_assoc_new(fra, exp);
}
|
.rcm2(x) ⇒ Array
Based on the radix complementation method, exponentially-decompose x on radix 2.
It behaves the same as frexp() in C, except that the value range is 1 leq y lt 2 with its exponent.
If x is not positive finite except 0, then it is inherently undefined. However, if x is negative finite, it will return a value range of -2 lt y leq -1.
82 83 84 85 86 87 88 |
# File 'ext/bigdecimal/math_r/edf.c', line 82
static VALUE
__impl_edf_rcm2(VALUE unused_obj, VALUE x)
{
VALUE exp, fra;
fra = rcm2_edf(x, &exp);
return rb_assoc_new(fra, exp);
}
|