[Numpy-discussion] Linear algebra functions on empty arrays

Sebastian Berg sebastian at sipsolutions.net
Mon Sep 15 07:26:05 EDT 2014


On Mo, 2014-09-15 at 07:07 -0400, josef.pktd at gmail.com wrote:
> On Mon, Sep 15, 2014 at 5:48 AM, Sebastian Berg
> <sebastian at sipsolutions.net> wrote:
> > Hey all,
> >
> > for https://github.com/numpy/numpy/pull/3861/files I would like to allow
> > 0-sized dimensions for generalized ufuncs, meaning that the gufunc has
> > to be able to handle this, but also that it *can* handle it at all.
> > However lapack does not support this, so it needs some explicit fixing.
> > Also some of the linalg functions currently explicitly allow and others
> > explicitly disallow empty arrays.
> >
> > For example the QR and eigvals does not allow it, but on the other hand
> > solve explicitly does (most probably never did, simply because lapack
> > does not). So I am wondering if there is some convention for this, or
> > what convention we should implement.
> 
> What does an empty square matrix/array look like?
> 
> np.linalg.solve   can have empty rhs, but shape of empty lhs, `a`, is ?
> 
> If I do a QR(arr)  with arr.shape=(0, 5), what is R supposed to be ?
> 

QR may be more difficult since R may itself could not be empty, begging
the question if you want to error out or fill it sensibly.
Cholesky would require (0, 0) for example and for eigenvalues it would
somewhat make sense too, the (0, 0) matrix has 0 eigenvalues.
I did not go through them all, but I would like to figure out whether we
should aim to generally allow it, or maybe just allow it for some
special ones.

- Sebastian

> 
> I just wrote some loops over linalg.qr, but I always initialized explicitly.
> 
> I didn't manage to figure out how empty arrays would be useful.
> 
> If an empty square matrix can only only be of shape (0, 0), then it's
> no use (in my applications).
> 
> 
> Josef
> 
> 
> >
> > Regards,
> >
> > Sebastian
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140915/670edc83/attachment.sig>


More information about the NumPy-Discussion mailing list