[Numpy-discussion] matrix default to column vector?
Sat Jun 6 15:30:38 CDT 2009
On Sat, Jun 6, 2009 at 14:59, Alan G Isaac <firstname.lastname@example.org> wrote:
> On 6/6/2009 2:58 PM Charles R Harris apparently wrote:
>> How about the common expression
>> do you expect a matrix exponential here?
> I take your point that there are conveniences
> to treating a 1 by 1 matrix as a scalar.
> Most matrix programming languages do this, I think.
> For sure GAUSS does. The result of x' * A * x
> is a "matrix" (it has one row and one column) but
> it functions like a scalar (and even more,
> since right multiplication by it is also allowed).
> While I think this is "wrong", especially in a
> language that readily distinguishes scalars
> and matrices, I recognize that many others have
> found the behavior useful. And I confess that
> when I talk about quadratic forms, I do treat
> x.T * A * x as if it were scalar.
The old idea of introducing RowVector and ColumnVector would help
here. If x were a ColumnVector and A a Matrix, then you can introduce
the following rules:
x.T is a RowVector
RowVector * ColumnVector is a scalar
RowVector * Matrix is a RowVector
Matrix * ColumnVector is a ColumnVector
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion