[goffice] Complex: improve div
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Complex: improve div
- Date: Sat, 6 Feb 2016 16:42:22 +0000 (UTC)
commit a978bf4603fa3499985c0b1bdd1478fde94f3ae5
Author: Morten Welinder <terra gnome org>
Date: Sat Feb 6 11:27:37 2016 -0500
Complex: improve div
ChangeLog | 6 ++++++
NEWS | 1 +
goffice/math/go-complex.c | 6 +++---
goffice/math/go-complex.h | 2 ++
4 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9a175d0..d3d2116 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,13 @@
+2016-02-06 Morten Welinder <terra gnome org>
+
+ * goffice/math/go-complex.c (go_complex_from_polar_pi): Make this
+ public.
+
2016-02-02 Morten Welinder <terra gnome org>
* goffice/math/go-complex.c (go_complex_powl): Fix real case
accuracy.
+ (go_complex_div): Avoid intermediate underflow when possible.
2016-01-29 Jean Brefort <jean brefort normalesup org>
diff --git a/NEWS b/NEWS
index 71dc8d7..6e65e0c 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Jean:
* Add title to axis lines. [#760675]
Morten:
* Fix go_complex_powl accuracy for real case.
+ * Fix go_complex_div for very small divisor.
--------------------------------------------------------------------------
goffice 0.10.26:
diff --git a/goffice/math/go-complex.c b/goffice/math/go-complex.c
index f1765be..abab90e 100644
--- a/goffice/math/go-complex.c
+++ b/goffice/math/go-complex.c
@@ -195,7 +195,7 @@ SUFFIX(go_complex_from_polar) (COMPLEX *dst, DOUBLE mod, DOUBLE angle)
mod * SUFFIX(sin) (angle));
}
-static void
+void
SUFFIX(go_complex_from_polar_pi) (COMPLEX *dst, DOUBLE mod, DOUBLE angle)
{
SUFFIX(go_complex_init) (dst,
@@ -220,8 +220,8 @@ SUFFIX(go_complex_div) (COMPLEX *dst, COMPLEX const *a, COMPLEX const *b)
{
DOUBLE bmod = SUFFIX(go_complex_mod) (b);
- if (bmod >= GO_const(1e10)) {
- /* Ok, it's big. */
+ if (bmod >= GO_const(1e10) || bmod < GO_const(1e-10)) {
+ /* Ok, it's very big or very small. */
DOUBLE a_re = a->re / bmod;
DOUBLE a_im = a->im / bmod;
DOUBLE b_re = b->re / bmod;
diff --git a/goffice/math/go-complex.h b/goffice/math/go-complex.h
index 7620c64..9746883 100644
--- a/goffice/math/go-complex.h
+++ b/goffice/math/go-complex.h
@@ -28,6 +28,7 @@ int go_complex_from_string (GOComplex *dst, char const *src, char *imunit);
void go_complex_to_polar (double *mod, double *angle, GOComplex const *src);
void go_complex_from_polar (GOComplex *dst, double mod, double angle);
+void go_complex_from_polar_pi (GOComplex *dst, double mod, double angle);
void go_complex_mul (GOComplex *dst, GOComplex const *a, GOComplex const *b);
void go_complex_div (GOComplex *dst, GOComplex const *a, GOComplex const *b);
void go_complex_pow (GOComplex *dst, GOComplex const *a, GOComplex const *b);
@@ -63,6 +64,7 @@ int go_complex_from_stringl (GOComplexl *dst, char const *src, char *imunit);
void go_complex_to_polarl (long double *mod, long double *angle, GOComplexl const *src);
void go_complex_from_polarl (GOComplexl *dst, long double mod, long double angle);
+void go_complex_from_polar_pil (GOComplexl *dst, long double mod, long double angle);
void go_complex_mull (GOComplexl *dst, GOComplexl const *a, GOComplexl const *b);
void go_complex_divl (GOComplexl *dst, GOComplexl const *a, GOComplexl const *b);
void go_complex_powl (GOComplexl *dst, GOComplexl const *a, GOComplexl const *b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]