[SciPy-user] Type handling of matrices

Robert Kern rkern at ucsd.edu
Thu Nov 11 03:30:25 CST 2004


Fernando Perez wrote:

> How about just using functions for everything?  I'd really hate to have 
> to remember that if A is sparse, A.is<foo> works, but if it's dense I 
> need to instead use is<foo>(A).

The big benefit for a property (not method) on sparse matrices is that 
one can set A.ishermitian on initialization and all get/set operations 
will obey that property.

A = sparse.dok_matrix()
A.ishermitian = True
A[1,2] = 1.
assert A[2,1] == 1.

Some sparse formats may be able to hold the property information and use 
it effectively without duplicating the individual elements themselves.

There should definitely be a function interface for querying these 
properties that will work for both dense and sparse matrices.

-- 
Robert Kern
rkern at ucsd.edu

"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