From: Yusuke ENDOH Date: 2010-01-26T00:22:54+09:00 Subject: [ruby-dev:40150] [Bug:trunk] Vector can't be coerced into Vector 遠藤です。 Vector に Vector をかけると Vector can't be coerced into Vector という 例外が出ます。 $ ./ruby -rmatrix -e 'Vector[1, 2, 3] * Vector[4, 5, 6]' /home/mame/work/ruby/lib/ruby/1.9.1/matrix.rb:1344:in `coerce': Vector can't be coerced into Vector (TypeError) from /home/mame/work/ruby/lib/ruby/1.9.1/matrix.rb:1218:in `*' from -e:1:in `
' Vector に Vector はかけられないので例外になるのは当然ですが、メッセージが わかりにくいと思います。 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -1214,6 +1209,8 @@ class Vector Vector.elements(els, false) when Matrix Matrix.column_vector(self) * x + when Vector + Vector.Raise WrongArgType, x.class, "Numeric or Matrix" else s, x = x.coerce(self) s * x -- Yusuke ENDOH