[Numpy-discussion] Confused by spec of numpy.linalg.solve

Sebastian Berg sebastian at sipsolutions.net
Tue Apr 1 16:50:36 EDT 2014

On Di, 2014-04-01 at 16:25 +0100, Nathaniel Smith wrote:
> On Tue, Apr 1, 2014 at 3:57 PM, Sebastian Berg
> <sebastian at sipsolutions.net> wrote:
> > If `a` has exactly one dimension more then `b`, the first case is used.
> > Otherwise (..., M, K) is used instead. To make sure you always get the
> > expected result, it may be best to make sure that the number of
> > broadcasting (...) dimensions of `a` and `b` are identical (I am not
> > sure if you expect this to be the case or not). The shape itself does
> > not matter, only the (relative) number of dimensions does for the
> > decision which of the two signatures is used.

Since b is a system of equations if it is 2-dim, I think it basically
doesn't make sense to have a (M, K) shaped b anyway, since you could use
a (K, M) shaped b with broadcasting logic (though I guess that is slower
unless you add extra logic).

- Sebastian

> Oh, really? This seems really unfortunate -- AFAICT it makes it
> impossible to write a generic broadcasting matrix-solve or
> vector-solve :-/ (except by explicitly checking shapes and prepending
> ones by hand, more or less doing the broadcasting manually). Surely it
> would be better to use PEP 467 style broadcasting, where the only
> special case is if `b` has exactly 1 dimension?
> -n

More information about the NumPy-Discussion mailing list