[SciPy-user] f2py complex number problem

Robert Kern robert.kern at gmail.com
Fri Dec 9 13:36:32 CST 2005


Ryan Krauss wrote:
> I am trying to learn f2py and am running into a problem.  I need to
> take the sin, cos, sinh, and cosh of complex numbers.  My FORTRAN is
> quite rusty but this isn't working:
> 
>       subroutine test(s,out)
>       double complex s, out
> Cf2py intent(in) s
> Cf2py intent(out) out
>       out=cos(s)-cosh(s)+sin(s)-sinh(s)
>       END
> 
> 
> f2py output ends with:
> test.f: In subroutine `test':
> test.f:5:
>          out=cos(s)-cosh(s)+sin(s)-sinh(s)
>                     ^
> Reference to intrinsic `COSH' at (^) invalid -- one or more arguments
> have incorrect type

http://gcc.gnu.org/onlinedocs/gcc-3.4.1/g77/CosH-Intrinsic.html#CosH%20Intrinsic

The COSH intrinsic only takes REAL agruments, at least in g77. EXP,
however, works with COMPLEX arguments, so I suggest defining a ZCOSH
function from the definition of cosh(z) = 0.5*(exp(z)+exp(-z))

-- 
Robert Kern
robert.kern at gmail.com

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter



More information about the SciPy-user mailing list