Since Python supports complex arithmetic, it is quite simple to apply the same approach as that for Fortran77. Specifically, all functions that need a definition or redefinition can be defined with a different name:
import sys, os, re, string, math
from cmath import *
from Numeric import *
def c_atan2(x,y):
a=x.real
b=x.imag
c=y.real
d=y.imag
return complex(math.atan2(a,c),(c*b-a*d)/(a**2+c**2))
def c_abs(x):
if x.real < 0:
return -x
else:
return x
def c_max(x,y):
if x.real < y.real:
return y
else:
return x
def c_min(x,y):
if x.real > y.real:
return y
else:
return x
def etc...
Although a more elegant approach based on function overloading is possible, we have not yet investigated it.