[Numpy-discussion] Linear algebra functions on empty arrays
josef.pktd at gmail.com
josef.pktd at gmail.com
Mon Sep 15 08:08:08 EDT 2014
On Mon, Sep 15, 2014 at 7:26 AM, Sebastian Berg
<sebastian at sipsolutions.net> wrote:
> 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.
I shouldn't have tried it again (I got this a few times last week):
>>> ze = np.ones((z.shape, 0))
** On entry to DGEQRF parameter number 7 had an illegal value
z.shape is 3
I think, I would prefer an exception if the output would require a
empty square matrix with shape > (0, 0)
I don't see any useful fill value.
> 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.
If the return square array has shape (0, 0), then it would make sense,
but I haven't run into a case for it yet.
np.cholesky(np.ones((0, 0))) ?
(I didn't try since my interpreter is crashed. :)
> - 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).
>> > 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
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion