summaryrefslogtreecommitdiff
path: root/src/mp.c
diff options
context:
space:
mode:
authormbkma <[email protected]>2020-03-18 10:03:24 +0100
committerRobert Antoni Buj Gelonch <[email protected]>2020-03-18 21:11:17 +0100
commit197f53efa72f1710b95478f8960f0304a9b8f4cc (patch)
tree5c99bd90ff256e194360d9155cec4cc4c6436a65 /src/mp.c
parent19711cb06c5bffee50084d3cbbbad48bbb2688bb (diff)
downloadmate-calc-197f53efa72f1710b95478f8960f0304a9b8f4cc.tar.bz2
mate-calc-197f53efa72f1710b95478f8960f0304a9b8f4cc.tar.xz
add Riemann zeta function and Gauss error function
Diffstat (limited to 'src/mp.c')
-rw-r--r--src/mp.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/mp.c b/src/mp.c
index a25280b..1286f56 100644
--- a/src/mp.c
+++ b/src/mp.c
@@ -583,6 +583,40 @@ mp_xpowy_integer(const MPNumber *x, int64_t n, MPNumber *z)
mpc_pow_si(z->num, x->num, (long) n, MPC_RNDNN);
}
+void
+mp_erf(const MPNumber *x, MPNumber *z)
+{
+ if (mp_is_complex(x))
+ { /* Translators: Error displayed when error function (erf) value is undefined */
+ mperr(_("The error function is only defined for real numbers"));
+ mp_set_from_integer(0, z);
+ return;
+ }
+
+ mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+ mpfr_erf(mpc_realref(z->num), mpc_realref(x->num), MPFR_RNDN);
+}
+
+void
+mp_zeta(const MPNumber *x, MPNumber *z)
+{
+ MPNumber one = mp_new();
+
+ mp_set_from_integer(1, &one);
+ if (mp_is_complex(x) || mp_compare(x, &one) == 0)
+ { /* Translators: Error displayed when zeta function value is undefined */
+ mperr(_("The Riemann zeta function is only defined for real numbers ≠1"));
+ mp_set_from_integer(0, z);
+ mp_clear(&one);
+ return;
+ }
+
+ mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+ mpfr_zeta(mpc_realref(z->num), mpc_realref(x->num), MPFR_RNDN);
+
+ mp_clear(&one);
+}
+
GList*
mp_factorize(const MPNumber *x)
{