return [eig.real for eig in eigs]
-def identity(domain_dim):
+def identity(domain_dim, typecode='i'):
"""
Create an identity matrix of the given dimensions.
domain_dim : int
The dimension of the vector space on which the identity will act.
+ typecode : {'i', 'd', 'z'}, optional
+ The type code for the returned matrix, defaults to 'i' for integers.
+ Can also be 'd' for real double, or 'z' for complex double.
+
Returns
-------
entries = [int(i == j)
for i in range(domain_dim)
for j in range(domain_dim)]
- return matrix(entries, (domain_dim, domain_dim))
+ return matrix(entries, (domain_dim, domain_dim), tc=typecode)
def inner_product(vec1, vec2):