Edmund Jackson writes:
> So to follow on:
> - In linear algebra a vector is always 1xn on nx1. So operations like x'*x and x*x'
> (where ' denotes transpose and * matrix multiplication) are distinct operations. How
> does a Vector behave in these operations, or do they not apply ? In general what is a
> Vector in terms of linear algebra ?
There are two conventions in use. The proponents of each one consider
theirs the "obviously right" one and the other one "strange".
One convention is the one you describe: linear algebra deals with
matrices, which are 2D objects. There are "row vectors" and "column vectors"
which are special cases of matrices having only one row/column. This convention
is probably the most familiar one because it is most frequently used in textbooks
for scientists and engineers.
The other convention starts from the definition of a vector space,
whose elements are vectors, and goes on to define transformations and
mappings, which transform one vector to another vector and thus need
two indices. Higher-order operations (-> tensors) take even more
indices. Vectors and transformations are abstract objects,
representations are defined in a second step. In numerical
applications, these representations are 1D and 2D arrays usually
called "vectors" and "matrices". The terms "row vector" and "column
vector" are never used, nor are transposes of vectors.
The difficulty for language implementers is that they have to choose
between the approach that is familiar to most potential users (the
first one) and the one that is more flexible because it extends to
higher dimensions (the second one). Matlab and R have chosen the first
one, APL and NumPy the second one. NumPy has later added a "Matrix"
class, which is a wrapper around arrays, to cater for adepts of the
first convention, but I don't see it much used in practice.
I have been arguing for the second approach on this list since the
beginning for two reasons: First, I need it because I work a lot with
higher-dimensional arrays. Second, it is more flexible, to the point
that one can always define an additional API layer implementing the
first convention in terms of the second one.
> - When should a user expect/use a Vector rather than a row/column matrix ?
When the result of an operation is by definition one-dimensional, it
should be a vector. Matrices with a single column or row should only occur
as special cases of general matrices.
For example, matrix-vector multiplication should return a vector and
matrix-matrix multiplication should return a matrix, such that the
rank of the input arguments determines the rank of the result, no
matter what the concrete shapes are.
Konrad.