[Numpy-discussion] pull request: generalized ufunc signature fix and lineal algebra generalized ufuncs
Wed Feb 20 12:31:28 CST 2013
On Thu, Jan 31, 2013 at 9:35 PM, Robert Kern <firstname.lastname@example.org> wrote:
> On Thu, Jan 31, 2013 at 7:44 PM, Nathaniel Smith <email@example.com> wrote:
>> On Thu, Jan 31, 2013 at 8:43 AM, Oscar Villellas
>> <firstname.lastname@example.org> wrote:
>>> At Continuum Analytics we've been working on a submodule implementing
>>> a set of lineal algebra operations as generalized ufuncs. This allows
>>> specifying arrays of lineal algebra problems to be computed with a
>>> single Python call, allowing broadcasting as well. As the
>>> vectorization is handled in the kernel, this gives a speed edge on the
>>> operations. We think this could be useful to the community and we want
>>> to share the work done.
>> It certainly does look useful. My question is -- why do we need two
>> complete copies of the linear algebra routine interfaces? Can we just
>> replace the existing linalg functions with these new implementations?
>> Or if not, what prevents it?
> The error reporting would have to be bodged back in.
Error reporting is one part of the equation. Right now the functions
in the linalg
module perform some baking of the data. For example, in linalg
eigenvalue functions for real
arrays check if all the eigenvalues/eigenvectors in the result are
real. If that's the case it returns arrays with a real dtype. There is
no way to handle that in a gufunc without a performance hit. The
gufunc version always returns a matrix with complex dtype (it will
involve copying otherwise).
So this provides the flexibility of being able to use linalg functions
as generalized ufuncs. It also provides some extra performance as
there is little python wrapper code and when used as gufuncs buffer
handling is quite efficient.
IMO it would be great if this could evolve into a complete replacement
for linalg, that's for sure, but right now it is missing functionality
and is not a drop-in replacement. In the other hand it provides value,
so it is a worthy addition.
More information about the NumPy-Discussion