From: Dave Baldwin Date: 2008-10-10T16:37:18+09:00 Subject: Re: Bug in Vector class? On 9 Oct 2008, at 18:12, Thomas B. wrote: > Dave Baldwin wrote: >> The Vector class doesn't seem to have any idea that it is >> representing >> a row or column vector and as the class stands now a vector * matrix >> will always fail. > > Vector.elements([1,2,3])*Matrix.identity(1) > #=> Matrix[[1], [2], [3]] > > Of course it's not much of a useful operation, but for me it's evident > from it that a vector assumes itself to be a vertical matrix each time > it is required to behave like a matrix. > > And now, what will be the result of the above operation if, as you > want, > a vector would auto-transpose when sent * with a matrix? A row or a > column matrix? For me, this proves that your idea is inconsistent. It > is not true that vector*matrix operation is never possible, so we > shouldn't automagically make it possible even if it is not. It > wouldn't > make debugging any easier. OK, so you demonstrated a degenerate case that is not much use as you point out. How would you do something more useful such as Vector[1,2,3]*Matrix.identity(3)? I don't think you can unless you convert the vector to a row vector aka a matrix with one row and do it as a matrix * matrix operation. Also a Vector * Matrix should return a Vector and not a Matrix (as the Matrix * Vector operation does). Thankfully with open classes I can get the behaviour I think is desirable. Dave. > > > TPR. > -- > Posted via http://www.ruby-forum.com/. >