help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gsl_function


From: Patrick Dupre
Subject: gsl_function
Date: Tue, 16 Jun 2020 10:29:06 +0200

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: pdupre@gmx.com
 Laboratoire interdisciplinaire Carnot de Bourgogne
 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE
 Tel: +33 (0)380395988
===========================================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]