X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=dunshire%2Fmatrices.py;h=66c21768403f19e8affa18fe23d1ffdf4f0ecd16;hb=97eddc6f61ca53ba39f547360ced35a2f69908cb;hp=6ed4f851487235dba117ef1521151bd432db9076;hpb=79d3d750bc463684646e3fbe26ecd0d555a4ec5f;p=dunshire.git diff --git a/dunshire/matrices.py b/dunshire/matrices.py index 6ed4f85..66c2176 100644 --- a/dunshire/matrices.py +++ b/dunshire/matrices.py @@ -209,7 +209,7 @@ def eigenvalues_re(anymat): 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. @@ -219,6 +219,10 @@ def identity(domain_dim): 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 ------- @@ -247,7 +251,7 @@ def identity(domain_dim): 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):