[Numpy-discussion] Operations on integer matrices known to return integers

Six Silberman silberman.six@gmail....
Tue Jul 10 15:52:45 CDT 2012


We now have

>>> a = array([[1, 2], [3, 4]], dtype=int8)
array([[1, 2],
           [3, 4]], dtype=int8)

>>> d = linalg.det(a)

>>> d
-2.0000000000000004

>>> d.dtype
dtype('float64')

This is at least partly due to use of LU factorization in computing
the determinant.

Some operations on integer matrices always return integers. It
occurred to me that it might be nice to be able to ask functions
performing such operations to always return an integer.

We could do

>>> print d
-2.0

but this seems a little unfortunate.

If this has been discussed many times previously and you just groaned
inwardly, or if this is simply outside the scope of numpy, please let
me know and I'll move along.

Thanks very much,



six


More information about the NumPy-Discussion mailing list