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

Nathaniel Smith njs at pobox.com
Tue Apr 1 17:15:40 EDT 2014

On Tue, Apr 1, 2014 at 9:50 PM, Sebastian Berg
<sebastian at sipsolutions.net> wrote:
> 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).

Not sure I'm following your point exactly, but the argument for having
(M, M) `a` and (M, K) `b` is that solve(a, b) is the same as
dot(inv(a), b), which obviously accepts 2d `a` and `b`...

Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh

More information about the NumPy-Discussion mailing list