Re: (Probably) easy question about inheritance
Joshua Cranmer wrote:
....
Think carefully before you have a Vector subclass Matrix -- is there
anything that a generic matrix can do that a vector can't do? AFAIK, the
answer is no (well, a transpose of a column vector is a row vector so
one could make the case that v.transpose().equals(v) should be true, but
in general usage that is probably not going to be expected), but be
careful before you make assumptions.
....
If the subsystem involves both matrices and vectors, treating row and
column vectors as equivalent may not be a good idea. They behave
differently when interacting with matrix operations.
For example, for an n by n matrix, m, and a length n vector, v, m*v is
defined if v is a column vector, but not if it is a row vector.
It is probably better to take one of two views:
A. A vector has only one dimension, and is not a matrix. This is
compatible with having methods to generate a matrix from a vector, or
turn a row or column of a matrix into a vector.
B. A vector is a matrix with one dimension equal to 1. In that case, it
is either a row or a column, depending on which dimension is 1. It
participates in matrix arithmetic as an n by 1 or a 1 by n matrix.
Patricia