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 > =========================================================================== > >