Module: BigMathR::Power
- Defined in:
- ext/bigdecimal/math_r/power.c,
ext/bigdecimal/math_r/math_r.c
Overview
A module that provides the power functions. It is used internally.
Synopsis
The function names defined are the same as those in the C/C++ standard.
-
Powers:
:pow:cpow -
Square root:
:sqrt:csqrt -
Cubic root:
:ccbrt
Follow, the name defined in C/C++ standard though, the function names are different.
-
Cubic root:
:cuberoot( cbrt() for C/C++ )
- Reference
-
C-gengo ni yoru hyoujun algorithm jiten (Japanese) - Haruhiko Okumura (Gijutu Hyouron-sha)
Class Method Summary collapse
-
.ccbrt(z, prec) ⇒ Complex
Computes complex cubic root of
z. -
.cpow(z, w, prec) ⇒ Complex
Computes the
wpower ofzin complex number. -
.csqrt(z, prec) ⇒ Complex
Computes complex square root of
z. -
.cuberoot(x, prec) ⇒ BigDecimal
Computes real-valued cubic root of
x. -
.pow(x, y, prec) ⇒ BigDecimal
Computes the
ypower ofx. -
.sqrt(x, prec) ⇒ BigDecimal
Computes square root of
x.
Class Method Details
.ccbrt(z, prec) ⇒ Complex
Computes complex cubic root of z.
171 172 173 174 175 176 |
# File 'ext/bigdecimal/math_r/power.c', line 171 static VALUE __impl_power_ccbrt(VALUE unused_obj, VALUE z, VALUE prec) { z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE); return ccbrt_formula(z, prec); } |
.cpow(z, w, prec) ⇒ Complex
Computes the w power of z in complex number.
90 91 92 93 94 |
# File 'ext/bigdecimal/math_r/power.c', line 90 static VALUE __impl_power_cpow(VALUE unused_obj, VALUE z, VALUE w, VALUE prec) { return cpow_formula(z, w, prec); } |
.csqrt(z, prec) ⇒ Complex
Computes complex square root of z.
130 131 132 133 134 135 |
# File 'ext/bigdecimal/math_r/power.c', line 130 static VALUE __impl_power_csqrt(VALUE unused_obj, VALUE z, VALUE prec) { z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE); return csqrt_formula(z, prec); } |
.cuberoot(x, prec) ⇒ BigDecimal
Computes real-valued cubic root of x.
150 151 152 153 154 155 |
# File 'ext/bigdecimal/math_r/power.c', line 150 static VALUE __impl_power_cuberoot(VALUE unused_obj, VALUE x, VALUE prec) { x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RAWVALUE); return cuberoot_newton(x, prec); } |
.pow(x, y, prec) ⇒ BigDecimal
Computes the y power of x.
69 70 71 72 73 |
# File 'ext/bigdecimal/math_r/power.c', line 69 static VALUE __impl_power_pow(VALUE unused_obj, VALUE x, VALUE y, VALUE prec) { return pow_formula(x, y, prec); } |
.sqrt(x, prec) ⇒ BigDecimal
Computes square root of x.
109 110 111 112 113 114 115 |
# File 'ext/bigdecimal/math_r/power.c', line 109 static VALUE __impl_power_sqrt(VALUE unused_obj, VALUE x, VALUE prec) { VALUE y; y = rb_bigmath_sqrt(x, prec); return rb_num_round(y, prec); } |