Thanks for the feedback. Humm, Can I void to make the same calculation twice? One time to integrate the real part, and one time to integrate the imaginary part?
Thanks. =========================================================================== Patrick DUPRÉ | | email: pdu...@gmx.com Laboratoire interdisciplinaire Carnot de Bourgogne 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE Tel: +33 (0)380395988 =========================================================================== > Sent: Tuesday, June 16, 2020 at 10:45 AM > From: "Marek Nečada" <ma...@necada.org> > To: "Patrick Dupre" <pdu...@gmx.com> > Cc: help-gsl@gnu.org > Subject: Re: gsl_function > > Hi Patrick, > > you can't return a complex with gsl_function. > > Integrate the real and imaginary parts separately. > > Best regards, > Marek Nečada > > > > Patrick Dupre kirjoitti 16.6.2020 klo 11.29: > > Hello, > > > > I need to return a complex with a gsl_function. > > How can I do? > > > > Here is an example > > > > #include <math.h> > > #include <stdio.h> > > #include <complex.h> > > #include <gsl/gsl_integration.h> > > > > double complex tt (double complex z) { > > double complex y = 0 ; > > for (unsigned short int i = 0 ; i < 5 ; i++) { > > y += z ; > > } > > return y ; > > } > > > > main () { > > gsl_function fcn ; > > double complex y0 = 1 + I * 0.5 ; > > fcn.function = &tt ; > > double complex z = tt (y0) ; > > double complex zz = (double complex) fcn.function (y0, fcn.params) ; > > printf ("%g %g, %g %g\n", z, zz) ; > > } > > > > Result (zz is not correct) > > 5 2.5, 5 0 > > > > Some ideas? > > > > Thanks > > > > =========================================================================== > > Patrick DUPRÉ | | email: pdu...@gmx.com > > Laboratoire interdisciplinaire Carnot de Bourgogne > > 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE > > Tel: +33 (0)380395988 > > =========================================================================== > > > > >