This is the mail archive of the gsl-discuss@sourceware.cygnus.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: complex number API


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]