[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gsl_function
From: |
Marek Nečada |
Subject: |
Re: gsl_function |
Date: |
Tue, 16 Jun 2020 11:45:09 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
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: pdupre@gmx.com
> Laboratoire interdisciplinaire Carnot de Bourgogne
> 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE
> Tel: +33 (0)380395988
> ===========================================================================
>
>
- gsl_function, Patrick Dupre, 2020/06/16
- Re: gsl_function,
Marek Nečada <=