Category talk:Wren-gmp: Difference between revisions
Content added Content deleted
(Added preamble and source code for new Wren-gmp module.) |
(→Source code (Wren): Added some more methods to Mpf class.) |
||
Line 801: | Line 801: | ||
static phi(prec) { from(5, prec).sqrt.add(1).div(2) } // Phi (golden ratio) |
static phi(prec) { from(5, prec).sqrt.add(1).div(2) } // Phi (golden ratio) |
||
static sqrt2(prec) { from(2, prec).sqrt } // Square root of 2 |
static sqrt2(prec) { from(2, prec).sqrt } // Square root of 2 |
||
static euler(prec) { from(1, prec).digamma.neg } // Euler's constant |
|||
// Convenience versions of the above constants whihc use the default precision. |
|||
static e { from(1).exp } |
|||
static ln2 { from(2).log } |
|||
static ln10 { from(10).log } |
|||
static pi { new().acos(Mpf.zero).mul(2) } |
|||
static tau { new().acos(Mpf.zero).mul(4) } |
|||
static phi { from(5).sqrt.add(1).div(2) } |
|||
static sqrt2 { from(2).sqrt } |
|||
static euler { from(1).digamma.neg } |
|||
// Swaps the values of two Mpf objects. |
// Swaps the values of two Mpf objects. |
||
Line 993: | Line 1,004: | ||
foreign atan(op) // arc-tangent of op |
foreign atan(op) // arc-tangent of op |
||
foreign atan2(y, x) // arc-tangent 2 of y and x |
foreign atan2(y, x) // arc-tangent 2 of y and x |
||
foreign cosh(op) // hyperbolic cosine of op |
|||
foreign sinh(op) // hyperbolic sine of op |
|||
foreign tanh(op) // hyperbolic tangent of op |
|||
foreign gamma(op) // gamma function of op |
|||
foreign digamma(op) // digamma (or psi) function of op |
|||
/* As above methods where the first (or only) argument is 'this'. |
/* As above methods where the first (or only) argument is 'this'. |
||
Unless otherwise noted, any other argument must either be another Mpf object or a uint. |
Unless otherwise noted, any other argument must either be another Mpf object or a uint. |
||
Line 1,042: | Line 1,058: | ||
atan { atan(this) } |
atan { atan(this) } |
||
atan2(x) { atan2(this, x) } |
atan2(x) { atan2(this, x) } |
||
acosh { acosh(this) } |
|||
asinh { asinh(this) } |
|||
atanh { atanh(this) } |
|||
gamma { gamma(this) } |
|||
digamma { digamma(this) } |
|||
/* As above methods where the first (or only) argument is 'this' |
/* As above methods where the first (or only) argument is 'this' |
||
Line 1,112: | Line 1,133: | ||
static max(sf) { sf.reduce { |acc, x| (x < acc) ? x : acc } } |
static max(sf) { sf.reduce { |acc, x| (x < acc) ? x : acc } } |
||
}</lang> |
}</lang> |
||
==Source code (C)== |
==Source code (C)== |
||
<lang c>/* gcc -O3 wren-gmp.c -o wren-gmp -lmpfr -lgmp -lwren -lm */ |
<lang c>/* gcc -O3 wren-gmp.c -o wren-gmp -lmpfr -lgmp -lwren -lm */ |