Actions
Bug #2649
closedVector can't be coerced into Vector
Bug #2649:
Vector can't be coerced into Vector
Description
=begin
遠藤です。
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
-
elseVector.Raise WrongArgType, x.class, "Numeric or Matrix"
s, x = x.coerce(self)
s * x
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Actions