From: Dave Baldwin Date: 2008-10-10T02:00:12+09:00 Subject: Re: Bug in Vector class? On 9 Oct 2008, at 16:13, Thomas B. wrote: > Dave Baldwin wrote: >> because the Vector#* method promotes self to a column vector when the >> argument is found to be a Matrix. I think it should be promoting >> self >> to a row vector and making this change removes the exception and >> gives >> the correct result. > > I think it should not. Either the programmer knows what he or she is > doing and is able to take care of the matrices dimensions, or no magic > auto-transpositions or other tricks are going to save their project > from > falling apart sooner or later. Vector is a column vector, and let it > be > this way. 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. The only way to achieve this operation is to manually convert the vector into a Matrix with one row but now you are really doing a matrix * matrix operation and not using the failing path in Vector. If the intent was for vector * matrix to fail then it would be better to raise an exception directly rather than rely on the Matrix class to catch a dimensional error. I still think it is better to treat it as a row vector in this case. Dave. > > > TPR. > -- > Posted via http://www.ruby-forum.com/. >