[gnumeric] Complex: add replacement for _zero_p
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Complex: add replacement for _zero_p
- Date: Wed, 24 Feb 2016 01:34:08 +0000 (UTC)
commit 571a6df477dd27cd135c896aa81e7225b69b617b
Author: Morten Welinder <terra gnome org>
Date: Tue Feb 23 18:53:55 2016 -0500
Complex: add replacement for _zero_p
plugins/fn-complex/functions.c | 4 ++--
src/complex.h | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/plugins/fn-complex/functions.c b/plugins/fn-complex/functions.c
index 5e3cd08..cae83ae 100644
--- a/plugins/fn-complex/functions.c
+++ b/plugins/fn-complex/functions.c
@@ -526,7 +526,7 @@ gnumeric_impower (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (value_get_as_complex (argv[1], &b, &imunit))
return value_new_error_NUM (ei->pos);
- if (gnm_complex_zero_p (&a) && gnm_complex_zero_p (&b))
+ if (GNM_CZEROP (a) && GNM_CZEROP (b))
return value_new_error_DIV0 (ei->pos);
return value_new_complexv (GNM_CPOW (a, b), imunit);
@@ -558,7 +558,7 @@ gnumeric_imdiv (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (value_get_as_complex (argv[1], &b, &imunit))
return value_new_error_NUM (ei->pos);
- if (gnm_complex_zero_p (&b))
+ if (GNM_CZEROP (b))
return value_new_error_DIV0 (ei->pos);
return value_new_complexv (GNM_CDIV (a, b), imunit);
diff --git a/src/complex.h b/src/complex.h
index ee49e04..e3e1921 100644
--- a/src/complex.h
+++ b/src/complex.h
@@ -100,11 +100,17 @@ static inline gnm_complex GNM_CMAKE (gnm_float re, gnm_float im)
}
#define GNM_CREAL(r) (GNM_CMAKE((r),0))
#define GNM_CREALP(c) (GNM_CIM((c)) == 0)
+#define GNM_CZEROP(c) (GNM_CEQ((c),GNM_C0))
#define GNM_C0 (GNM_CREAL (0))
#define GNM_C1 (GNM_CREAL (1))
#define GNM_CI (GNM_CMAKE (0, 1))
#define GNM_CNAN (GNM_CMAKE (gnm_nan, gnm_nan))
+static inline gboolean GNM_CEQ(gnm_complex c1, gnm_complex c2)
+{
+ return c1.re == c2.re && c1.im == c2.im;
+}
+
static inline gnm_complex GNM_CPOLAR (gnm_float mod, gnm_float angle)
{
gnm_complex res;
@@ -146,6 +152,11 @@ static inline gnm_complex GNM_CSCALE(gnm_complex c, gnm_float s)
{
return GNM_CMAKE (c.re * s, c.im * s);
}
+static inline gnm_complex GNM_CLDEXP(gnm_complex c, gnm_float e)
+{
+ int ie = (int)CLAMP (e, G_MININT, G_MAXINT);
+ return GNM_CMAKE (gnm_ldexp (c.re, ie), gnm_ldexp (c.im, ie));
+}
static inline gnm_complex GNM_CEXPPI(gnm_complex c)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]