Complex numbers in Python
Python has built-in support for complex numbers. A complex number has
the form z = 2.0 + 5.0j (yes, j, as used by engineers...), and basic
arithmetic should be properly handled. For most functions you will
need to import cmath, and everything should work as expected!
Here is a simple program using Python
complex numbers. There should be no need to modify the source code
of tridiag.py, except that some arrays must be explicitly
declared as complex numpy arrays:
n = len(r)
u = np.zeros(n, dtype=complex)
gam = np.zeros(n, dtype=complex)