Project

General

Profile

Actions

Bug #2649

closed

Vector can't be coerced into Vector

Added by mame (Yusuke Endoh) over 15 years ago. Updated over 14 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-dev:40150]

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
  •  Vector.Raise WrongArgType, x.class, "Numeric or Matrix"
    
    else
    s, x = x.coerce(self)
    s * x

--
Yusuke ENDOH
=end

Actions #1

Updated by keiju (Keiju Ishitsuka) over 15 years ago

=begin
けいじゅ@いしつかです.

In [ruby-dev:40150] the message: "[ruby-dev:40150] [Bug:trunk] Vector can't be coerced into Vector", on Jan/26 00:22(JST)
Yusuke ENDOH writes:

遠藤です。

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 はかけられないので例外になるのは当然ですが、メッセージが
わかりにくいと思います。

おっしゃる通りです.

__
---------------------------------------------------->> 石塚 圭樹 <<---
---------------------------------->> e-mail: <<---

=end

Actions #2

Updated by keiju (Keiju Ishitsuka) over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r26448.
Yusuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0