[gnumeric] Complex: namespace
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Complex: namespace
- Date: Wed, 20 Jan 2016 16:15:14 +0000 (UTC)
commit 83d90bd36b7b61958b1efc33c5a6104e4d604e4b
Author: Morten Welinder <terra gnome org>
Date: Wed Jan 20 11:13:25 2016 -0500
Complex: namespace
ChangeLog | 4 +
plugins/fn-complex/functions.c | 158 +++++++++++++++++++-------------------
plugins/fn-complex/gsl-complex.c | 96 ++++++++++++------------
plugins/fn-complex/gsl-complex.h | 40 +++++-----
plugins/fn-math/functions.c | 6 +-
plugins/fn-tsa/functions.c | 30 ++++----
src/complex.c | 14 ++--
src/complex.h | 94 +++++++++++-----------
src/sf-gamma.c | 142 +++++++++++++++++-----------------
src/sf-gamma.h | 6 +-
10 files changed, 297 insertions(+), 293 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 402ac20..ae92693 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-01-20 Morten Welinder <terra gnome org>
+
+ * src/complex.h: Namespace. Mostly for macros.
+
2016-01-16 Morten Welinder <terra gnome org>
* src/gnumeric-simple-canvas.c (gnm_simple_canvas_ungrab): Drop
diff --git a/plugins/fn-complex/functions.c b/plugins/fn-complex/functions.c
index d69921d..40b9fc9 100644
--- a/plugins/fn-complex/functions.c
+++ b/plugins/fn-complex/functions.c
@@ -49,28 +49,28 @@ GNM_PLUGIN_MODULE_HEADER;
* 1 if an error occurred.
*/
static int
-value_get_as_complex (GnmValue const *val, complex_t *res, char *imunit)
+value_get_as_complex (GnmValue const *val, gnm_complex *res, char *imunit)
{
if (VALUE_IS_NUMBER (val)) {
- complex_real (res, value_get_as_float (val));
+ gnm_complex_real (res, value_get_as_float (val));
*imunit = 'i';
return 0;
} else {
- return complex_from_string (res,
+ return gnm_complex_from_string (res,
value_peek_string (val),
imunit);
}
}
static GnmValue *
-value_new_complex (complex_t const *c, char imunit)
+value_new_complex (gnm_complex const *c, char imunit)
{
- if (complex_invalid_p (c))
+ if (gnm_complex_invalid_p (c))
return value_new_error_NUM (NULL);
- else if (complex_real_p (c))
+ else if (gnm_complex_real_p (c))
return value_new_float (c->re);
else
- return value_new_string_nocopy (complex_to_string (c, imunit));
+ return value_new_string_nocopy (gnm_complex_to_string (c, imunit));
}
/***************************************************************************/
@@ -89,10 +89,10 @@ static GnmFuncHelp const help_complex[] = {
static GnmValue *
gnumeric_complex (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c;
+ gnm_complex c;
char const *suffix;
- complex_init (&c,
+ gnm_complex_init (&c,
value_get_as_float (argv[0]),
value_get_as_float (argv[1]));
suffix = argv[2] ? value_peek_string (argv[2]) : "i";
@@ -118,7 +118,7 @@ static GnmFuncHelp const help_imaginary[] = {
static GnmValue *
gnumeric_imaginary (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c;
+ gnm_complex c;
char imunit;
if (VALUE_IS_NUMBER (argv[0]))
@@ -145,13 +145,13 @@ static GnmFuncHelp const help_imabs[] = {
static GnmValue *
gnumeric_imabs (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c;
+ gnm_complex c;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- return value_new_float (complex_mod (&c));
+ return value_new_float (gnm_complex_mod (&c));
}
/***************************************************************************/
@@ -169,7 +169,7 @@ static GnmFuncHelp const help_imreal[] = {
static GnmValue *
gnumeric_imreal (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c;
+ gnm_complex c;
char imunit;
if (VALUE_IS_NUMBER (argv[0]))
@@ -196,13 +196,13 @@ static GnmFuncHelp const help_imconjugate[] = {
static GnmValue *
gnumeric_imconjugate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_conj (&res, &c);
+ gnm_complex_conj (&res, &c);
return value_new_complex (&res, imunit);
}
@@ -219,7 +219,7 @@ static GnmFuncHelp const help_iminv[] = {
static GnmValue *
gnumeric_iminv (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -242,7 +242,7 @@ static GnmFuncHelp const help_imneg[] = {
static GnmValue *
gnumeric_imneg (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -268,13 +268,13 @@ static GnmFuncHelp const help_imcos[] = {
static GnmValue *
gnumeric_imcos (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_cos (&res, &c);
+ gnm_complex_cos (&res, &c);
return value_new_complex (&res, imunit);
}
@@ -294,13 +294,13 @@ static GnmFuncHelp const help_imtan[] = {
static GnmValue *
gnumeric_imtan (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_tan (&res, &c);
+ gnm_complex_tan (&res, &c);
return value_new_complex (&res, imunit);
}
@@ -320,13 +320,13 @@ static GnmFuncHelp const help_imsec[] = {
static GnmValue *
gnumeric_imsec (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_cos (&res, &c);
+ gnm_complex_cos (&res, &c);
gsl_complex_inverse (&res, &res);
return value_new_complex (&res, imunit);
}
@@ -346,13 +346,13 @@ static GnmFuncHelp const help_imcsc[] = {
static GnmValue *
gnumeric_imcsc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_sin (&res, &c);
+ gnm_complex_sin (&res, &c);
gsl_complex_inverse (&res, &res);
return value_new_complex (&res, imunit);
}
@@ -373,13 +373,13 @@ static GnmFuncHelp const help_imcot[] = {
static GnmValue *
gnumeric_imcot (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_tan (&res, &c);
+ gnm_complex_tan (&res, &c);
gsl_complex_inverse (&res, &res);
return value_new_complex (&res, imunit);
}
@@ -401,13 +401,13 @@ static GnmFuncHelp const help_imexp[] = {
static GnmValue *
gnumeric_imexp (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_exp (&res, &c);
+ gnm_complex_exp (&res, &c);
return value_new_complex (&res, imunit);
}
@@ -426,13 +426,13 @@ static GnmFuncHelp const help_imargument[] = {
static GnmValue *
gnumeric_imargument (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c;
+ gnm_complex c;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- return value_new_float (complex_angle (&c));
+ return value_new_float (gnm_complex_angle (&c));
}
/***************************************************************************/
@@ -453,13 +453,13 @@ static GnmFuncHelp const help_imln[] = {
static GnmValue *
gnumeric_imln (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_ln (&res, &c);
+ gnm_complex_ln (&res, &c);
return value_new_complex (&res, imunit);
}
@@ -479,14 +479,14 @@ static GnmFuncHelp const help_imlog2[] = {
static GnmValue *
gnumeric_imlog2 (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_ln (&res, &c);
- complex_scale_real (&res, 1 / M_LN2gnum);
+ gnm_complex_ln (&res, &c);
+ gnm_complex_scale_real (&res, 1 / M_LN2gnum);
return value_new_complex (&res, imunit);
}
@@ -505,14 +505,14 @@ static GnmFuncHelp const help_imlog10[] = {
static GnmValue *
gnumeric_imlog10 (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_ln (&res, &c);
- complex_scale_real (&res, 1 / M_LN10gnum);
+ gnm_complex_ln (&res, &c);
+ gnm_complex_scale_real (&res, 1 / M_LN10gnum);
return value_new_complex (&res, imunit);
}
@@ -532,7 +532,7 @@ static GnmFuncHelp const help_impower[] = {
static GnmValue *
gnumeric_impower (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t a, b, res;
+ gnm_complex a, b, res;
char imunit;
if (value_get_as_complex (argv[0], &a, &imunit))
@@ -541,11 +541,11 @@ 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 (complex_zero_p (&a) && complex_zero_p (&b))
+ if (gnm_complex_zero_p (&a) && gnm_complex_zero_p (&b))
return value_new_error_DIV0 (ei->pos);
- complex_pow (&res, &a, &b);
- if (complex_invalid_p (&res))
+ gnm_complex_pow (&res, &a, &b);
+ if (gnm_complex_invalid_p (&res))
return value_new_error_NUM (ei->pos);
return value_new_complex (&res, imunit);
@@ -568,7 +568,7 @@ static GnmFuncHelp const help_imdiv[] = {
static GnmValue *
gnumeric_imdiv (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t a, b, res;
+ gnm_complex a, b, res;
char imunit;
if (value_get_as_complex (argv[0], &a, &imunit))
@@ -577,10 +577,10 @@ 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 (complex_zero_p (&b))
+ if (gnm_complex_zero_p (&b))
return value_new_error_DIV0 (ei->pos);
- complex_div (&res, &a, &b);
+ gnm_complex_div (&res, &a, &b);
return value_new_complex (&res, imunit);
}
@@ -599,13 +599,13 @@ static GnmFuncHelp const help_imsin[] = {
static GnmValue *
gnumeric_imsin (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_sin (&res, &c);
+ gnm_complex_sin (&res, &c);
return value_new_complex (&res, imunit);
}
@@ -623,7 +623,7 @@ static GnmFuncHelp const help_imsinh[] = {
static GnmValue *
gnumeric_imsinh (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -648,7 +648,7 @@ static GnmFuncHelp const help_imcosh[] = {
static GnmValue *
gnumeric_imcosh (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -673,7 +673,7 @@ static GnmFuncHelp const help_imtanh[] = {
static GnmValue *
gnumeric_imtanh (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -697,7 +697,7 @@ static GnmFuncHelp const help_imsech[] = {
static GnmValue *
gnumeric_imsech (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -722,7 +722,7 @@ static GnmFuncHelp const help_imcsch[] = {
static GnmValue *
gnumeric_imcsch (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -746,7 +746,7 @@ static GnmFuncHelp const help_imcoth[] = {
static GnmValue *
gnumeric_imcoth (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -773,7 +773,7 @@ static GnmFuncHelp const help_imarcsin[] = {
static GnmValue *
gnumeric_imarcsin (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -800,7 +800,7 @@ static GnmFuncHelp const help_imarccos[] = {
static GnmValue *
gnumeric_imarccos (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -827,7 +827,7 @@ static GnmFuncHelp const help_imarctan[] = {
static GnmValue *
gnumeric_imarctan (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -851,7 +851,7 @@ static GnmFuncHelp const help_imarcsec[] = {
static GnmValue *
gnumeric_imarcsec (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -876,7 +876,7 @@ static GnmFuncHelp const help_imarccsc[] = {
static GnmValue *
gnumeric_imarccsc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -900,7 +900,7 @@ static GnmFuncHelp const help_imarccot[] = {
static GnmValue *
gnumeric_imarccot (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -927,7 +927,7 @@ static GnmFuncHelp const help_imarcsinh[] = {
static GnmValue *
gnumeric_imarcsinh (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -955,7 +955,7 @@ static GnmFuncHelp const help_imarccosh[] = {
static GnmValue *
gnumeric_imarccosh (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -983,7 +983,7 @@ static GnmFuncHelp const help_imarctanh[] = {
static GnmValue *
gnumeric_imarctanh (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -1007,7 +1007,7 @@ static GnmFuncHelp const help_imarcsech[] = {
static GnmValue *
gnumeric_imarcsech (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -1032,7 +1032,7 @@ static GnmFuncHelp const help_imarccsch[] = {
static GnmValue *
gnumeric_imarccsch (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -1057,7 +1057,7 @@ static GnmFuncHelp const help_imarccoth[] = {
static GnmValue *
gnumeric_imarccoth (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -1083,13 +1083,13 @@ static GnmFuncHelp const help_imsqrt[] = {
static GnmValue *
gnumeric_imsqrt (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
return value_new_error_NUM (ei->pos);
- complex_sqrt (&res, &c);
+ gnm_complex_sqrt (&res, &c);
return value_new_complex (&res, imunit);
}
@@ -1108,7 +1108,7 @@ static GnmFuncHelp const help_imfact[] = {
static GnmValue *
gnumeric_imfact (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -1133,7 +1133,7 @@ static GnmFuncHelp const help_imgamma[] = {
static GnmValue *
gnumeric_imgamma (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t c, res;
+ gnm_complex c, res;
char imunit;
if (value_get_as_complex (argv[0], &c, &imunit))
@@ -1162,7 +1162,7 @@ static GnmFuncHelp const help_imigamma[] = {
static GnmValue *
gnumeric_imigamma (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t res, a, z;
+ gnm_complex res, a, z;
char imunit;
gboolean lower = argv[2] ? value_get_as_checked_bool (argv[2]) : TRUE;
gboolean reg = argv[3] ? value_get_as_checked_bool (argv[3]) : TRUE;
@@ -1193,7 +1193,7 @@ static GnmFuncHelp const help_imsub[] = {
static GnmValue *
gnumeric_imsub (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
{
- complex_t a, b, res;
+ gnm_complex a, b, res;
char imunit;
if (value_get_as_complex (argv[0], &a, &imunit))
@@ -1202,7 +1202,7 @@ gnumeric_imsub (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (value_get_as_complex (argv[1], &b, &imunit))
return value_new_error_NUM (ei->pos);
- complex_sub (&res, &a, &b);
+ gnm_complex_sub (&res, &a, &b);
return value_new_complex (&res, imunit);
}
@@ -1225,7 +1225,7 @@ typedef enum {
} eng_imoper_type_t;
typedef struct {
- complex_t res;
+ gnm_complex res;
char imunit;
eng_imoper_type_t type;
} eng_imoper_t;
@@ -1234,7 +1234,7 @@ static GnmValue *
callback_function_imoper (GnmEvalPos const *ep, GnmValue const *value, void *closure)
{
eng_imoper_t *result = closure;
- complex_t c;
+ gnm_complex c;
char *imptr, dummy;
imptr = VALUE_IS_NUMBER (value) ? &dummy : &result->imunit;
@@ -1243,10 +1243,10 @@ callback_function_imoper (GnmEvalPos const *ep, GnmValue const *value, void *clo
switch (result->type) {
case Improduct:
- complex_mul (&result->res, &result->res, &c);
+ gnm_complex_mul (&result->res, &result->res, &c);
break;
case Imsum:
- complex_add (&result->res, &result->res, &c);
+ gnm_complex_add (&result->res, &result->res, &c);
break;
default:
abort ();
@@ -1263,7 +1263,7 @@ gnumeric_improduct (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
p.type = Improduct;
p.imunit = 'j';
- complex_real (&p.res, 1);
+ gnm_complex_real (&p.res, 1);
v = function_iterate_argument_values
(ei->pos, callback_function_imoper, &p,
@@ -1297,7 +1297,7 @@ gnumeric_imsum (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
p.type = Imsum;
p.imunit = 'j';
- complex_real (&p.res, 0);
+ gnm_complex_real (&p.res, 0);
v = function_iterate_argument_values
(ei->pos, callback_function_imoper, &p,
diff --git a/plugins/fn-complex/gsl-complex.c b/plugins/fn-complex/gsl-complex.c
index 8c0b95a..711f61f 100644
--- a/plugins/fn-complex/gsl-complex.c
+++ b/plugins/fn-complex/gsl-complex.c
@@ -71,23 +71,23 @@
***********************************************************************/
static inline void
-gsl_complex_mul_imag (complex_t const *a, gnm_float y, complex_t *res)
+gsl_complex_mul_imag (gnm_complex const *a, gnm_float y, gnm_complex *res)
{ /* z=a*iy */
- complex_init (res, -y * GSL_IMAG (a), y * GSL_REAL (a));
+ gnm_complex_init (res, -y * GSL_IMAG (a), y * GSL_REAL (a));
}
void
-gsl_complex_inverse (complex_t const *a, complex_t *res)
+gsl_complex_inverse (gnm_complex const *a, gnm_complex *res)
{ /* z=1/a */
- gnm_float s = 1.0 / complex_mod (a);
+ gnm_float s = 1.0 / gnm_complex_mod (a);
- complex_init (res, (GSL_REAL (a) * s) * s, -(GSL_IMAG (a) * s) * s);
+ gnm_complex_init (res, (GSL_REAL (a) * s) * s, -(GSL_IMAG (a) * s) * s);
}
void
-gsl_complex_negative (complex_t const *a, complex_t *res)
+gsl_complex_negative (gnm_complex const *a, gnm_complex *res)
{
- complex_init (res, -GSL_REAL (a), -GSL_IMAG (a));
+ gnm_complex_init (res, -GSL_REAL (a), -GSL_IMAG (a));
}
/**********************************************************************
@@ -95,21 +95,21 @@ gsl_complex_negative (complex_t const *a, complex_t *res)
**********************************************************************/
static void
-gsl_complex_arcsin_real (gnm_float a, complex_t *res)
+gsl_complex_arcsin_real (gnm_float a, gnm_complex *res)
{ /* z = arcsin(a) */
if (gnm_abs (a) <= 1.0) {
- complex_init (res, gnm_asin (a), 0.0);
+ gnm_complex_init (res, gnm_asin (a), 0.0);
} else {
if (a < 0.0) {
- complex_init (res, -M_PI_2gnum, gnm_acosh (-a));
+ gnm_complex_init (res, -M_PI_2gnum, gnm_acosh (-a));
} else {
- complex_init (res, M_PI_2gnum, -gnm_acosh (a));
+ gnm_complex_init (res, M_PI_2gnum, -gnm_acosh (a));
}
}
}
void
-gsl_complex_arcsin (complex_t const *a, complex_t *res)
+gsl_complex_arcsin (gnm_complex const *a, gnm_complex *res)
{ /* z = arcsin(a) */
gnm_float R = GSL_REAL (a), I = GSL_IMAG (a);
@@ -158,27 +158,27 @@ gsl_complex_arcsin (complex_t const *a, complex_t *res)
imag = gnm_log (A + gnm_sqrt (A * A - 1));
}
- complex_init (res, (R >= 0) ? real : -real, (I >= 0) ?
+ gnm_complex_init (res, (R >= 0) ? real : -real, (I >= 0) ?
imag : -imag);
}
}
static void
-gsl_complex_arccos_real (gnm_float a, complex_t *res)
+gsl_complex_arccos_real (gnm_float a, gnm_complex *res)
{ /* z = arccos(a) */
if (gnm_abs (a) <= 1.0) {
- complex_init (res, gnm_acos (a), 0);
+ gnm_complex_init (res, gnm_acos (a), 0);
} else {
if (a < 0.0) {
- complex_init (res, M_PIgnum, -gnm_acosh (-a));
+ gnm_complex_init (res, M_PIgnum, -gnm_acosh (-a));
} else {
- complex_init (res, 0, gnm_acosh (a));
+ gnm_complex_init (res, 0, gnm_acosh (a));
}
}
}
void
-gsl_complex_arccos (complex_t const *a, complex_t *res)
+gsl_complex_arccos (gnm_complex const *a, gnm_complex *res)
{ /* z = arccos(a) */
gnm_float R = GSL_REAL (a), I = GSL_IMAG (a);
@@ -228,18 +228,18 @@ gsl_complex_arccos (complex_t const *a, complex_t *res)
imag = gnm_log (A + gnm_sqrt (A * A - 1));
}
- complex_init (res, (R >= 0) ? real : M_PIgnum - real, (I >= 0) ?
+ gnm_complex_init (res, (R >= 0) ? real : M_PIgnum - real, (I >= 0) ?
-imag : imag);
}
}
void
-gsl_complex_arctan (complex_t const *a, complex_t *res)
+gsl_complex_arctan (gnm_complex const *a, gnm_complex *res)
{ /* z = arctan(a) */
gnm_float R = GSL_REAL (a), I = GSL_IMAG (a);
if (I == 0) {
- complex_init (res, gnm_atan (R), 0);
+ gnm_complex_init (res, gnm_atan (R), 0);
} else {
/* FIXME: This is a naive implementation which does not fully
* take into account cancellation errors, overflow, underflow
@@ -263,14 +263,14 @@ gsl_complex_arctan (complex_t const *a, complex_t *res)
}
if (R == 0) {
if (I > 1) {
- complex_init (res, M_PI_2gnum, imag);
+ gnm_complex_init (res, M_PI_2gnum, imag);
} else if (I < -1) {
- complex_init (res, -M_PI_2gnum, imag);
+ gnm_complex_init (res, -M_PI_2gnum, imag);
} else {
- complex_init (res, 0, imag);
+ gnm_complex_init (res, 0, imag);
}
} else {
- complex_init (res, 0.5 * gnm_atan2 (2 * R,
+ gnm_complex_init (res, 0.5 * gnm_atan2 (2 * R,
((1 + r) * (1 - r))),
imag);
}
@@ -278,24 +278,24 @@ gsl_complex_arctan (complex_t const *a, complex_t *res)
}
void
-gsl_complex_arcsec (complex_t const *a, complex_t *res)
+gsl_complex_arcsec (gnm_complex const *a, gnm_complex *res)
{ /* z = arcsec(a) */
gsl_complex_inverse (a, res);
gsl_complex_arccos (res, res);
}
void
-gsl_complex_arccsc (complex_t const *a, complex_t *res)
+gsl_complex_arccsc (gnm_complex const *a, gnm_complex *res)
{ /* z = arccsc(a) */
gsl_complex_inverse (a, res);
gsl_complex_arcsin (res, res);
}
void
-gsl_complex_arccot (complex_t const *a, complex_t *res)
+gsl_complex_arccot (gnm_complex const *a, gnm_complex *res)
{ /* z = arccot(a) */
if (GSL_REAL (a) == 0.0 && GSL_IMAG (a) == 0.0) {
- complex_init (res, M_PI_2gnum, 0);
+ gnm_complex_init (res, M_PI_2gnum, 0);
} else {
gsl_complex_inverse (a, res);
gsl_complex_arctan (res, res);
@@ -307,23 +307,23 @@ gsl_complex_arccot (complex_t const *a, complex_t *res)
**********************************************************************/
void
-gsl_complex_sinh (complex_t const *a, complex_t *res)
+gsl_complex_sinh (gnm_complex const *a, gnm_complex *res)
{ /* z = sinh(a) */
gnm_float R = GSL_REAL (a), I = GSL_IMAG (a);
- complex_init (res, gnm_sinh (R) * gnm_cos (I), cosh (R) * gnm_sin (I));
+ gnm_complex_init (res, gnm_sinh (R) * gnm_cos (I), cosh (R) * gnm_sin (I));
}
void
-gsl_complex_cosh (complex_t const *a, complex_t *res)
+gsl_complex_cosh (gnm_complex const *a, gnm_complex *res)
{ /* z = cosh(a) */
gnm_float R = GSL_REAL (a), I = GSL_IMAG (a);
- complex_init (res, cosh (R) * gnm_cos (I), gnm_sinh (R) * gnm_sin (I));
+ gnm_complex_init (res, cosh (R) * gnm_cos (I), gnm_sinh (R) * gnm_sin (I));
}
void
-gsl_complex_tanh (complex_t const *a, complex_t *res)
+gsl_complex_tanh (gnm_complex const *a, gnm_complex *res)
{ /* z = tanh(a) */
gnm_float R = GSL_REAL (a), I = GSL_IMAG (a);
@@ -332,7 +332,7 @@ gsl_complex_tanh (complex_t const *a, complex_t *res)
gnm_pow (gnm_cos (I), 2.0) +
gnm_pow (gnm_sinh (R), 2.0);
- complex_init (res, gnm_sinh (R) * cosh (R) / D,
+ gnm_complex_init (res, gnm_sinh (R) * cosh (R) / D,
0.5 * gnm_sin (2 * I) / D);
} else {
gnm_float D =
@@ -340,27 +340,27 @@ gsl_complex_tanh (complex_t const *a, complex_t *res)
gnm_pow (gnm_sinh (R), 2.0);
gnm_float F = 1 + gnm_pow (gnm_cos (I) / gnm_sinh (R), 2.0);
- complex_init (res, 1.0 / (gnm_tanh (R) * F),
+ gnm_complex_init (res, 1.0 / (gnm_tanh (R) * F),
0.5 * gnm_sin (2 * I) / D);
}
}
void
-gsl_complex_sech (complex_t const *a, complex_t *res)
+gsl_complex_sech (gnm_complex const *a, gnm_complex *res)
{ /* z = sech(a) */
gsl_complex_cosh (a, res);
gsl_complex_inverse (res, res);
}
void
-gsl_complex_csch (complex_t const *a, complex_t *res)
+gsl_complex_csch (gnm_complex const *a, gnm_complex *res)
{ /* z = csch(a) */
gsl_complex_sinh (a, res);
gsl_complex_inverse (res, res);
}
void
-gsl_complex_coth (complex_t const *a, complex_t *res)
+gsl_complex_coth (gnm_complex const *a, gnm_complex *res)
{ /* z = coth(a) */
gsl_complex_tanh (a, res);
gsl_complex_inverse (res, res);
@@ -371,7 +371,7 @@ gsl_complex_coth (complex_t const *a, complex_t *res)
**********************************************************************/
void
-gsl_complex_arcsinh (complex_t const *a, complex_t *res)
+gsl_complex_arcsinh (gnm_complex const *a, gnm_complex *res)
{ /* z = arcsinh(a) */
gsl_complex_mul_imag (a, 1.0, res);
gsl_complex_arcsin (res, res);
@@ -379,25 +379,25 @@ gsl_complex_arcsinh (complex_t const *a, complex_t *res)
}
void
-gsl_complex_arccosh (complex_t const *a, complex_t *res)
+gsl_complex_arccosh (gnm_complex const *a, gnm_complex *res)
{ /* z = arccosh(a) */
gsl_complex_arccos (a, res);
gsl_complex_mul_imag (res, GSL_IMAG (res) > 0 ? -1.0 : 1.0, res);
}
static void
-gsl_complex_arctanh_real (gnm_float a, complex_t *res)
+gsl_complex_arctanh_real (gnm_float a, gnm_complex *res)
{ /* z = arctanh(a) */
if (a > -1.0 && a < 1.0) {
- complex_init (res, gnm_atanh (a), 0);
+ gnm_complex_init (res, gnm_atanh (a), 0);
} else {
- complex_init (res, gnm_atanh (1 / a),
+ gnm_complex_init (res, gnm_atanh (1 / a),
(a < 0) ? M_PI_2gnum : -M_PI_2gnum);
}
}
void
-gsl_complex_arctanh (complex_t const *a, complex_t *res)
+gsl_complex_arctanh (gnm_complex const *a, gnm_complex *res)
{ /* z = arctanh(a) */
if (GSL_IMAG (a) == 0.0) {
gsl_complex_arctanh_real (GSL_REAL (a), res);
@@ -409,21 +409,21 @@ gsl_complex_arctanh (complex_t const *a, complex_t *res)
}
void
-gsl_complex_arcsech (complex_t const *a, complex_t *res)
+gsl_complex_arcsech (gnm_complex const *a, gnm_complex *res)
{ /* z = arcsech(a); */
gsl_complex_inverse (a, res);
gsl_complex_arccosh (res, res);
}
void
-gsl_complex_arccsch (complex_t const *a, complex_t *res)
+gsl_complex_arccsch (gnm_complex const *a, gnm_complex *res)
{ /* z = arccsch(a); */
gsl_complex_inverse (a, res);
gsl_complex_arcsinh (res, res);
}
void
-gsl_complex_arccoth (complex_t const *a, complex_t *res)
+gsl_complex_arccoth (gnm_complex const *a, gnm_complex *res)
{ /* z = arccoth(a); */
gsl_complex_inverse (a, res);
gsl_complex_arctanh (res, res);
diff --git a/plugins/fn-complex/gsl-complex.h b/plugins/fn-complex/gsl-complex.h
index 071fd8e..0f5c700 100644
--- a/plugins/fn-complex/gsl-complex.h
+++ b/plugins/fn-complex/gsl-complex.h
@@ -1,25 +1,25 @@
#ifndef __GSL_COMPLEX_H__
#define __GSL_COMPLEX_H__
-void gsl_complex_inverse (complex_t const *a, complex_t *res);
-void gsl_complex_negative (complex_t const *a, complex_t *res);
-void gsl_complex_arcsin (complex_t const *a, complex_t *res);
-void gsl_complex_arccos (complex_t const *a, complex_t *res);
-void gsl_complex_arctan (complex_t const *a, complex_t *res);
-void gsl_complex_arcsec (complex_t const *a, complex_t *res);
-void gsl_complex_arccsc (complex_t const *a, complex_t *res);
-void gsl_complex_arccot (complex_t const *a, complex_t *res);
-void gsl_complex_sinh (complex_t const *a, complex_t *res);
-void gsl_complex_cosh (complex_t const *a, complex_t *res);
-void gsl_complex_tanh (complex_t const *a, complex_t *res);
-void gsl_complex_sech (complex_t const *a, complex_t *res);
-void gsl_complex_csch (complex_t const *a, complex_t *res);
-void gsl_complex_coth (complex_t const *a, complex_t *res);
-void gsl_complex_arcsinh (complex_t const *a, complex_t *res);
-void gsl_complex_arccosh (complex_t const *a, complex_t *res);
-void gsl_complex_arctanh (complex_t const *a, complex_t *res);
-void gsl_complex_arcsech (complex_t const *a, complex_t *res);
-void gsl_complex_arccsch (complex_t const *a, complex_t *res);
-void gsl_complex_arccoth (complex_t const *a, complex_t *res);
+void gsl_complex_inverse (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_negative (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arcsin (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arccos (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arctan (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arcsec (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arccsc (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arccot (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_sinh (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_cosh (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_tanh (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_sech (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_csch (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_coth (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arcsinh (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arccosh (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arctanh (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arcsech (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arccsch (gnm_complex const *a, gnm_complex *res);
+void gsl_complex_arccoth (gnm_complex const *a, gnm_complex *res);
#endif
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 7533739..595a16c 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -1032,10 +1032,10 @@ gnumeric_igamma (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gboolean lower = argv[2] ? value_get_as_checked_bool (argv[2]) : TRUE;
gboolean reg = argv[3] ? value_get_as_checked_bool (argv[3]) : TRUE;
gboolean re = argv[4] ? value_get_as_checked_bool (argv[4]) : TRUE;
- complex_t ig, ca, cz;
+ gnm_complex ig, ca, cz;
- complex_init (&ca, a, 0);
- complex_init (&cz, z, 0);
+ gnm_complex_init (&ca, a, 0);
+ gnm_complex_init (&cz, z, 0);
complex_igamma (&ig, &ca, &cz, lower, reg);
return value_new_float (re ? ig.re : ig.im);
diff --git a/plugins/fn-tsa/functions.c b/plugins/fn-tsa/functions.c
index e24f566..25ad280 100644
--- a/plugins/fn-tsa/functions.c
+++ b/plugins/fn-tsa/functions.c
@@ -105,14 +105,14 @@ enum {
/**************************************************************************/
static void
-gnm_fourier_fft (complex_t const *in, int n, int skip, complex_t **fourier, gboolean inverse)
+gnm_fourier_fft (gnm_complex const *in, int n, int skip, gnm_complex **fourier, gboolean inverse)
{
- complex_t *fourier_1, *fourier_2;
+ gnm_complex *fourier_1, *fourier_2;
int i;
int nhalf = n / 2;
gnm_float argstep;
- *fourier = g_new (complex_t, n);
+ *fourier = g_new (gnm_complex, n);
if (n == 1) {
(*fourier)[0] = in[0];
@@ -124,16 +124,16 @@ gnm_fourier_fft (complex_t const *in, int n, int skip, complex_t **fourier, gboo
argstep = (inverse ? M_PIgnum : -M_PIgnum) / nhalf;
for (i = 0; i < nhalf; i++) {
- complex_t dir, tmp;
+ gnm_complex dir, tmp;
- complex_from_polar (&dir, 1, argstep * i);
- complex_mul (&tmp, &fourier_2[i], &dir);
+ gnm_complex_from_polar (&dir, 1, argstep * i);
+ gnm_complex_mul (&tmp, &fourier_2[i], &dir);
- complex_add (&((*fourier)[i]), &fourier_1[i], &tmp);
- complex_scale_real (&((*fourier)[i]), 0.5);
+ gnm_complex_add (&((*fourier)[i]), &fourier_1[i], &tmp);
+ gnm_complex_scale_real (&((*fourier)[i]), 0.5);
- complex_sub (&((*fourier)[i + nhalf]), &fourier_1[i], &tmp);
- complex_scale_real (&((*fourier)[i + nhalf]), 0.5);
+ gnm_complex_sub (&((*fourier)[i + nhalf]), &fourier_1[i], &tmp);
+ gnm_complex_scale_real (&((*fourier)[i + nhalf]), 0.5);
}
g_free (fourier_1);
@@ -597,7 +597,7 @@ gnumeric_periodogram (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GnmValue const * const Pt = argv[0];
int i;
GSList *missing0 = NULL, *missing1 = NULL;
- complex_t *in, *out = NULL;
+ gnm_complex *in, *out = NULL;
int const cols = value_area_get_width (Pt, ep);
int const rows = value_area_get_height (Pt, ep);
@@ -795,7 +795,7 @@ no_absc:
}
/* Transform and return the result */
- in = g_new0 (complex_t, nb);
+ in = g_new0 (gnm_complex, nb);
for (i = 0; i < n0; i++){
in[i].re = ord[i];
}
@@ -848,7 +848,7 @@ gnumeric_fourier (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GnmValue const * const Pt = argv[0];
int i;
GSList *missing0 = NULL;
- complex_t *in, *out = NULL;
+ gnm_complex *in, *out = NULL;
int const cols = value_area_get_width (Pt, ep);
int const rows = value_area_get_height (Pt, ep);
@@ -890,7 +890,7 @@ gnumeric_fourier (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
nb *= 2;
/* Transform and return the result */
- in = g_new0 (complex_t, nb);
+ in = g_new0 (gnm_complex, nb);
for (i = 0; i < n0; i++)
in[i].re = ord[i];
g_free (ord);
@@ -901,7 +901,7 @@ gnumeric_fourier (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
res = value_new_array_empty (1 , nb);
for (i = 0; i < nb; i++)
res->v_array.vals[0][i] = value_new_string_nocopy
- (complex_to_string (&(out[i]), 'i'));
+ (gnm_complex_to_string (&(out[i]), 'i'));
g_free (out);
} else if (out && sep_columns) {
res = value_new_array_empty (2 , nb);
diff --git a/src/complex.c b/src/complex.c
index 799c324..a9c040a 100644
--- a/src/complex.c
+++ b/src/complex.c
@@ -19,7 +19,7 @@
/* ------------------------------------------------------------------------- */
char *
-complex_to_string (complex_t const *src, char imunit)
+gnm_complex_to_string (gnm_complex const *src, char imunit)
{
char *re_buffer = NULL;
char *im_buffer = NULL;
@@ -86,7 +86,7 @@ complex_to_string (complex_t const *src, char imunit)
} while (0)
/**
- * complex_from_string:
+ * gnm_complex_from_string:
* @dst: return location
* @src: string to parse
* @imunit: (out): return location of imaginary unit.
@@ -100,7 +100,7 @@ complex_to_string (complex_t const *src, char imunit)
* (2) We do not allow a thousands separator as in "1,000i".
*/
int
-complex_from_string (complex_t *dst, char const *src, char *imunit)
+gnm_complex_from_string (gnm_complex *dst, char const *src, char *imunit)
{
gnm_float x, y;
char *end;
@@ -124,7 +124,7 @@ complex_from_string (complex_t *dst, char const *src, char *imunit)
/* Case: "42", "+42", "-42", ... */
if (*src == 0) {
- complex_real (dst, x);
+ gnm_complex_real (dst, x);
*imunit = 'i';
return 0;
}
@@ -134,7 +134,7 @@ complex_from_string (complex_t *dst, char const *src, char *imunit)
*imunit = *src++;
EAT_SPACES (src);
if (*src == 0) {
- complex_init (dst, 0, x);
+ gnm_complex_init (dst, 0, x);
return 0;
} else
return -1;
@@ -161,7 +161,7 @@ complex_from_string (complex_t *dst, char const *src, char *imunit)
*imunit = *src++;
EAT_SPACES (src);
if (*src == 0) {
- complex_init (dst, x, y);
+ gnm_complex_init (dst, x, y);
return 0;
}
}
@@ -172,7 +172,7 @@ complex_from_string (complex_t *dst, char const *src, char *imunit)
/* ------------------------------------------------------------------------- */
int
-complex_invalid_p (complex_t const *src)
+gnm_complex_invalid_p (gnm_complex const *src)
{
return !(gnm_finite (src->re) && gnm_finite (src->im));
}
diff --git a/src/complex.h b/src/complex.h
index a4a78e1..55908f5 100644
--- a/src/complex.h
+++ b/src/complex.h
@@ -9,60 +9,60 @@
G_BEGIN_DECLS
#ifdef GNM_WITH_LONG_DOUBLE
-#define complex_t GOComplexl
-#define complex_init go_complex_initl
-#define complex_add go_complex_addl
-#define complex_sub go_complex_subl
-#define complex_mul go_complex_mull
-#define complex_div go_complex_divl
-#define complex_mod go_complex_modl
-#define complex_angle go_complex_anglel
-#define complex_real go_complex_reall
-#define complex_real_p go_complex_real_pl
-#define complex_zero_p go_complex_zero_pl
-#define complex_conj go_complex_conjl
-#define complex_exp go_complex_expl
-#define complex_ln go_complex_lnl
-#define complex_sqrt go_complex_sqrtl
-#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
+#define gnm_complex GOComplexl
+#define gnm_complex_init go_complex_initl
+#define gnm_complex_add go_complex_addl
+#define gnm_complex_sub go_complex_subl
+#define gnm_complex_mul go_complex_mull
+#define gnm_complex_div go_complex_divl
+#define gnm_complex_mod go_complex_modl
+#define gnm_complex_angle go_complex_anglel
+#define gnm_complex_real go_complex_reall
+#define gnm_complex_real_p go_complex_real_pl
+#define gnm_complex_zero_p go_complex_zero_pl
+#define gnm_complex_conj go_complex_conjl
+#define gnm_complex_exp go_complex_expl
+#define gnm_complex_ln go_complex_lnl
+#define gnm_complex_sqrt go_complex_sqrtl
+#define gnm_complex_sin go_complex_sinl
+#define gnm_complex_cos go_complex_cosl
+#define gnm_complex_tan go_complex_tanl
+#define gnm_complex_pow go_complex_powl
+#define gnm_complex_scale_real go_complex_scale_reall
+#define gnm_complex_to_polar go_complex_to_polarl
+#define gnm_complex_from_polar go_complex_from_polarl
#else
-#define complex_t GOComplex
-#define complex_init go_complex_init
-#define complex_add go_complex_add
-#define complex_sub go_complex_sub
-#define complex_mul go_complex_mul
-#define complex_div go_complex_div
-#define complex_mod go_complex_mod
-#define complex_angle go_complex_angle
-#define complex_real go_complex_real
-#define complex_real_p go_complex_real_p
-#define complex_zero_p go_complex_zero_p
-#define complex_conj go_complex_conj
-#define complex_exp go_complex_exp
-#define complex_ln go_complex_ln
-#define complex_sqrt go_complex_sqrt
-#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
+#define gnm_complex GOComplex
+#define gnm_complex_init go_complex_init
+#define gnm_complex_add go_complex_add
+#define gnm_complex_sub go_complex_sub
+#define gnm_complex_mul go_complex_mul
+#define gnm_complex_div go_complex_div
+#define gnm_complex_mod go_complex_mod
+#define gnm_complex_angle go_complex_angle
+#define gnm_complex_real go_complex_real
+#define gnm_complex_real_p go_complex_real_p
+#define gnm_complex_zero_p go_complex_zero_p
+#define gnm_complex_conj go_complex_conj
+#define gnm_complex_exp go_complex_exp
+#define gnm_complex_ln go_complex_ln
+#define gnm_complex_sqrt go_complex_sqrt
+#define gnm_complex_sin go_complex_sin
+#define gnm_complex_cos go_complex_cos
+#define gnm_complex_tan go_complex_tan
+#define gnm_complex_pow go_complex_pow
+#define gnm_complex_scale_real go_complex_scale_real
+#define gnm_complex_to_polar go_complex_to_polar
+#define gnm_complex_from_polar go_complex_from_polar
#endif
/* ------------------------------------------------------------------------- */
-char *complex_to_string (complex_t const *src, char imunit);
+char *gnm_complex_to_string (gnm_complex const *src, char imunit);
-int complex_from_string (complex_t *dst, char const *src, char *imunit);
+int gnm_complex_from_string (gnm_complex *dst, char const *src, char *imunit);
-int complex_invalid_p (complex_t const *src);
+int gnm_complex_invalid_p (gnm_complex const *src);
/* ------------------------------------------------------------------------- */
diff --git a/src/sf-gamma.c b/src/sf-gamma.c
index aa283d6..cbebbcd 100644
--- a/src/sf-gamma.c
+++ b/src/sf-gamma.c
@@ -1187,116 +1187,116 @@ static const guint32 lanczos_denom[G_N_ELEMENTS(lanczos_num)] = {
};
void
-complex_gamma (complex_t *dst, complex_t const *src)
+complex_gamma (gnm_complex *dst, gnm_complex const *src)
{
- if (complex_real_p (src)) {
- complex_init (dst, gnm_gamma (src->re), 0);
+ if (gnm_complex_real_p (src)) {
+ gnm_complex_init (dst, gnm_gamma (src->re), 0);
} else if (src->re < 0) {
/* Gamma(z) = pi / (sin(pi*z) * Gamma(-z+1)) */
- complex_t a, b, mz;
+ gnm_complex a, b, mz;
- complex_init (&mz, -src->re, -src->im);
+ gnm_complex_init (&mz, -src->re, -src->im);
complex_fact (&a, &mz);
- complex_init (&b,
+ gnm_complex_init (&b,
M_PIgnum * gnm_fmod (src->re, 2),
M_PIgnum * src->im);
/* Hmm... sin overflows when b.im is large. */
- complex_sin (&b, &b);
+ gnm_complex_sin (&b, &b);
- complex_mul (&a, &a, &b);
+ gnm_complex_mul (&a, &a, &b);
- complex_init (&b, M_PIgnum, 0);
+ gnm_complex_init (&b, M_PIgnum, 0);
- complex_div (dst, &b, &a);
+ gnm_complex_div (dst, &b, &a);
} else {
- complex_t zmh, zmhd2, zmhpg, f, f2, p, q, pq;
+ gnm_complex zmh, zmhd2, zmhpg, f, f2, p, q, pq;
int i;
i = G_N_ELEMENTS(lanczos_num) - 1;
- complex_init (&p, lanczos_num[i], 0);
- complex_init (&q, lanczos_denom[i], 0);
+ gnm_complex_init (&p, lanczos_num[i], 0);
+ gnm_complex_init (&q, lanczos_denom[i], 0);
while (--i >= 0) {
- complex_mul (&p, &p, src);
+ gnm_complex_mul (&p, &p, src);
p.re += lanczos_num[i];
- complex_mul (&q, &q, src);
+ gnm_complex_mul (&q, &q, src);
q.re += lanczos_denom[i];
}
- complex_div (&pq, &p, &q);
+ gnm_complex_div (&pq, &p, &q);
- complex_init (&zmh, src->re - 0.5, src->im);
- complex_init (&zmhpg, zmh.re + lanczos_g, zmh.im);
- complex_init (&zmhd2, zmh.re * 0.5, zmh.im * 0.5);
- complex_pow (&f, &zmhpg, &zmhd2);
+ gnm_complex_init (&zmh, src->re - 0.5, src->im);
+ gnm_complex_init (&zmhpg, zmh.re + lanczos_g, zmh.im);
+ gnm_complex_init (&zmhd2, zmh.re * 0.5, zmh.im * 0.5);
+ gnm_complex_pow (&f, &zmhpg, &zmhd2);
zmh.re = -zmh.re; zmh.im = -zmh.im;
- complex_exp (&f2, &zmh);
- complex_mul (&f2, &f, &f2);
- complex_mul (&f2, &f2, &f);
+ gnm_complex_exp (&f2, &zmh);
+ gnm_complex_mul (&f2, &f, &f2);
+ gnm_complex_mul (&f2, &f2, &f);
- complex_mul (dst, &f2, &pq);
+ gnm_complex_mul (dst, &f2, &pq);
}
}
/* ------------------------------------------------------------------------- */
void
-complex_fact (complex_t *dst, complex_t const *src)
+complex_fact (gnm_complex *dst, gnm_complex const *src)
{
- if (complex_real_p (src)) {
- complex_init (dst, gnm_fact (src->re), 0);
+ if (gnm_complex_real_p (src)) {
+ gnm_complex_init (dst, gnm_fact (src->re), 0);
} else {
/*
* This formula is valid for all arguments except zero
* which we conveniently handled above.
*/
- complex_t gz;
+ gnm_complex gz;
complex_gamma (&gz, src);
- complex_mul (dst, &gz, src);
+ gnm_complex_mul (dst, &gz, src);
}
}
/* ------------------------------------------------------------------------- */
static void
-igamma_cf (complex_t *dst, const complex_t *a, const complex_t *z)
+igamma_cf (gnm_complex *dst, const gnm_complex *a, const gnm_complex *z)
{
- complex_t A0, A1, B0, B1;
+ gnm_complex A0, A1, B0, B1;
int i;
const gboolean debug_cf = FALSE;
- complex_init (&A0, 1, 0);
- complex_init (&A1, 0, 0);
- complex_init (&B0, 0, 0);
- complex_init (&B1, 1, 0);
+ gnm_complex_init (&A0, 1, 0);
+ gnm_complex_init (&A1, 0, 0);
+ gnm_complex_init (&B0, 0, 0);
+ gnm_complex_init (&B1, 1, 0);
for (i = 1; i < 100; i++) {
- complex_t ai, bi, t1, t2, c1, c2, A2, B2;
+ gnm_complex ai, bi, t1, t2, c1, c2, A2, B2;
gnm_float m;
const gnm_float BIG = GNM_const(18446744073709551616.0);
if (i == 1)
- complex_init (&ai, 1, 0);
+ gnm_complex_init (&ai, 1, 0);
else if (i & 1) {
gnm_float f = (i >> 1);
- complex_init (&ai, z->re * f, z->im * f);
+ gnm_complex_init (&ai, z->re * f, z->im * f);
} else {
- complex_t f;
- complex_init (&f, -(a->re + ((i >> 1) - 1)), -a->im);
- complex_mul (&ai, &f, z);
+ gnm_complex f;
+ gnm_complex_init (&f, -(a->re + ((i >> 1) - 1)), -a->im);
+ gnm_complex_mul (&ai, &f, z);
}
- complex_init (&bi, a->re + (i - 1), a->im);
+ gnm_complex_init (&bi, a->re + (i - 1), a->im);
/* Update A. */
- complex_mul (&t1, &bi, &A1);
- complex_mul (&t2, &ai, &A0);
- complex_add (&A2, &t1, &t2);
+ gnm_complex_mul (&t1, &bi, &A1);
+ gnm_complex_mul (&t2, &ai, &A0);
+ gnm_complex_add (&A2, &t1, &t2);
A0 = A1; A1 = A2;
/* Update B. */
- complex_mul (&t1, &bi, &B1);
- complex_mul (&t2, &ai, &B0);
- complex_add (&B2, &t1, &t2);
+ gnm_complex_mul (&t1, &bi, &B1);
+ gnm_complex_mul (&t2, &ai, &B0);
+ gnm_complex_add (&B2, &t1, &t2);
B0 = B1; B1 = B2;
/* Rescale */
@@ -1315,13 +1315,13 @@ igamma_cf (complex_t *dst, const complex_t *a, const complex_t *z)
}
/* Check for convergence */
- complex_mul (&t1, &A1, &B0);
- complex_mul (&t2, &A0, &B1);
- complex_sub (&c1, &t1, &t2);
+ gnm_complex_mul (&t1, &A1, &B0);
+ gnm_complex_mul (&t2, &A0, &B1);
+ gnm_complex_sub (&c1, &t1, &t2);
- complex_mul (&c2, &B0, &B1);
+ gnm_complex_mul (&c2, &B0, &B1);
- complex_div (&t1, &A1, &B1);
+ gnm_complex_div (&t1, &A1, &B1);
if (debug_cf) {
g_printerr (" a : %.20g + %.20g I\n", ai.re, ai.im);
g_printerr (" b : %.20g + %.20g I\n", bi.re, bi.im);
@@ -1330,7 +1330,7 @@ igamma_cf (complex_t *dst, const complex_t *a, const complex_t *z)
g_printerr ("%3d : %.20g + %.20g I\n", i, t1.re, t1.im);
}
- if (complex_mod (&c1) <= complex_mod (&c2) * (16 * GNM_EPSILON))
+ if (gnm_complex_mod (&c1) <= gnm_complex_mod (&c2) * (16 * GNM_EPSILON))
break;
}
@@ -1341,31 +1341,31 @@ igamma_cf (complex_t *dst, const complex_t *a, const complex_t *z)
return;
}
- complex_div (dst, &A1, &B1);
+ gnm_complex_div (dst, &A1, &B1);
}
void
-complex_igamma (complex_t *dst, const complex_t *a, const complex_t *z,
+complex_igamma (gnm_complex *dst, const gnm_complex *a, const gnm_complex *z,
gboolean lower, gboolean regularized)
{
- complex_t res, f, mz;
+ gnm_complex res, f, mz;
- if (complex_zero_p (a)) {
+ if (gnm_complex_zero_p (a)) {
if (!lower && !regularized)
complex_gamma (dst, z);
else
- complex_init (dst, lower ? 0 : 1, 0);
+ gnm_complex_init (dst, lower ? 0 : 1, 0);
return;
}
- if (complex_real_p (a) && a->re >= 0 &&
- complex_real_p (z) && z->re >= 0) {
- complex_init (&res, pgamma (z->re, a->re, 1, lower, FALSE), 0);
+ if (gnm_complex_real_p (a) && a->re >= 0 &&
+ gnm_complex_real_p (z) && z->re >= 0) {
+ gnm_complex_init (&res, pgamma (z->re, a->re, 1, lower, FALSE), 0);
if (!regularized) {
- complex_t g;
+ gnm_complex g;
complex_gamma (&g, a);
- complex_mul (&res, &res, &g);
+ gnm_complex_mul (&res, &res, &g);
}
*dst = res;
return;
@@ -1379,24 +1379,24 @@ complex_igamma (complex_t *dst, const complex_t *a, const complex_t *z,
*/
mz.re = -z->re, mz.im = -z->im;
- complex_exp (&f, &mz);
- complex_mul (&res, &res, &f);
- complex_pow (&f, z, a);
- complex_mul (&res, &res, &f);
+ gnm_complex_exp (&f, &mz);
+ gnm_complex_mul (&res, &res, &f);
+ gnm_complex_pow (&f, z, a);
+ gnm_complex_mul (&res, &res, &f);
if (!regularized && lower) {
/* Nothing */
} else {
- complex_t g;
+ gnm_complex g;
complex_gamma (&g, a);
if (regularized) {
- complex_div (&res, &res, &g);
+ gnm_complex_div (&res, &res, &g);
if (!lower)
res.re = 1 - res.re;
} else {
/* !lower here */
- complex_sub (&res, &g, &res);
+ gnm_complex_sub (&res, &g, &res);
}
}
diff --git a/src/sf-gamma.h b/src/sf-gamma.h
index 3230bbf..7f6b02f 100644
--- a/src/sf-gamma.h
+++ b/src/sf-gamma.h
@@ -10,9 +10,9 @@ gnm_float stirlerr(gnm_float n);
gnm_float gnm_gamma (gnm_float x);
gnm_float gnm_fact (gnm_float x);
int qfactf (gnm_float x, GnmQuad *mant, int *exp2);
-void complex_gamma (complex_t *dst, complex_t const *src);
-void complex_fact (complex_t *dst, complex_t const *src);
-void complex_igamma (complex_t *dst, complex_t const *a, complex_t const *z,
+void complex_gamma (gnm_complex *dst, gnm_complex const *src);
+void complex_fact (gnm_complex *dst, gnm_complex const *src);
+void complex_igamma (gnm_complex *dst, gnm_complex const *a, gnm_complex const *z,
gboolean lower, gboolean regularized);
gnm_float gnm_lbeta (gnm_float a, gnm_float b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]