[gnumeric] Complex: Goffice's go_complex_pow is fine now. Use it.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Complex: Goffice's go_complex_pow is fine now. Use it.
- Date: Tue, 9 Apr 2013 13:20:53 +0000 (UTC)
commit 12014b5da3393d8f76618657debe5c1fe1b102a8
Author: Morten Welinder <terra gnome org>
Date: Tue Apr 9 09:20:25 2013 -0400
Complex: Goffice's go_complex_pow is fine now. Use it.
ChangeLog | 4 +++
src/complex.c | 62 ---------------------------------------------------------
src/complex.h | 3 +-
3 files changed, 6 insertions(+), 63 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3017058..dae4d1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-09 Morten Welinder <terra gnome org>
+
+ * src/complex.c (complex_pow): Use Goffice's copy.
+
2013-04-05 Morten Welinder <terra gnome org>
* src/wbc-gtk.c (cb_screen_changed): Re-use the css provider for
diff --git a/src/complex.c b/src/complex.c
index 6183fd6..d7c0e35 100644
--- a/src/complex.c
+++ b/src/complex.c
@@ -139,68 +139,6 @@ complex_from_string (complex_t *dst, char const *src, char *imunit)
/* ------------------------------------------------------------------------- */
-/* Like complex_angle, but divide result by pi. */
-static gnm_float
-complex_angle_pi (complex_t const *src)
-{
- if (src->im == 0)
- return (src->re >= 0 ? 0 : -1);
-
- if (src->re == 0)
- return (src->im >= 0 ? 0.5 : -0.5);
-
- /* We could do quarters too */
-
- /* Fallback. */
- return complex_angle (src) / M_PIgnum;
-}
-
-
-void
-complex_pow (complex_t *dst, complex_t const *a, complex_t const *b)
-{
- if (complex_zero_p (a) && complex_real_p (b)) {
- if (b->re <= 0)
- complex_invalid (dst);
- else
- complex_real (dst, 0);
- } else {
- gnm_float res_r, res_a1, res_a2, res_a2_pi, r, arg;
- complex_t F;
-
- complex_to_polar (&r, &arg, a);
- res_r = gnm_pow (r, b->re) * gnm_exp (-b->im * arg);
- res_a1 = b->im * gnm_log (r);
- res_a2 = b->re * arg;
- res_a2_pi = b->re * complex_angle_pi (a);
-
- res_a2_pi = gnm_fmod (res_a2_pi, 2);
- if (res_a2_pi < 0) res_a2_pi += 2;
-
- /*
- * Problem: sometimes res_a2 is a nice fraction of pi.
- * Actually adding it will introduce pointless rounding
- * errors.
- */
- if (res_a2_pi == 0.5) {
- res_a2 = 0;
- complex_init (&F, 0, 1);
- } else if (res_a2_pi == 1) {
- res_a2 = 0;
- complex_real (&F, -1);
- } else if (res_a2_pi == 1.5) {
- res_a2 = 0;
- complex_init (&F, 0, -1);
- } else
- complex_real (&F, 1);
-
- complex_from_polar (dst, res_r, res_a1 + res_a2);
- complex_mul (dst, dst, &F);
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
int
complex_invalid_p (complex_t const *src)
{
diff --git a/src/complex.h b/src/complex.h
index bbed098..aca5d11 100644
--- a/src/complex.h
+++ b/src/complex.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
#define complex_sin go_complex_sinl
#define complex_cos go_complex_cosl
#define complex_tan go_complex_tanl
+#define complex_pow go_complex_powl
#define complex_scale_real go_complex_scale_reall
#define complex_to_polar go_complex_to_polarl
#define complex_from_polar go_complex_from_polarl
@@ -49,6 +50,7 @@ G_BEGIN_DECLS
#define complex_sin go_complex_sin
#define complex_cos go_complex_cos
#define complex_tan go_complex_tan
+#define complex_pow go_complex_pow
#define complex_scale_real go_complex_scale_real
#define complex_to_polar go_complex_to_polar
#define complex_from_polar go_complex_from_polar
@@ -63,7 +65,6 @@ char *complex_to_string (complex_t const *src, char const *reformat,
int complex_from_string (complex_t *dst, char const *src, char *imunit);
-void complex_pow (complex_t *dst, complex_t const *a, complex_t const *b);
int complex_invalid_p (complex_t const *src);
/* ------------------------------------------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]