This is the mail archive of the
gsl-discuss@sourceware.cygnus.com
mailing list for the GSL project.
Re: complex number API
- To: Mark Galassi <rosalia@cygnus.com>, gsl-discuss@sourceware.cygnus.com
- Subject: Re: complex number API
- From: Gerard Jungman <jungman@nnn.lanl.gov>
- Date: Mon, 08 Feb 1999 12:37:35 -0700
- Organization: LANL T-8
- References: <14014.61758.272551.239351@papageno.roadrunner.com>
Mark Galassi wrote:
> First of all, there should be separate macros for setting and
> retrieving the real and imaginary parts. Otherwise you end up using
> GSL_REAL(z) as a left-hand-side, which is bad form and can hurt down
> the line.
>
> I would add GSL_SET_REAL(z, x) and GSL_SET_IMAG(z, y).
Agreed.
> Second, GSL_COMPLEX_SET modifies its z argument, which makes the
> interface "magic" and is bad form, and could cause problems down the
> line. I would modify it to either return z or to take a zp (pointer
> to z).
Yes. For parallelism with the rest of the interfaces, I guess
it should be pointer to z. Vaguely annoying, but consistent for a
SET interface.
I would like to add another form as well, of the suggested
'return z' type, since that looks like it would be nicer to type.
I'm thinking something contructor-like
GSL_COMPLEX(x,y)
which could be used like
gsl_complex foo_z = GSL_COMPLEX(x,y);
Trivial as an inline function, but is it possible to do as
a macro too?