e$BO"Ej$9$_$^$;$s!#e(B
[ruby-dev:40149] e$B$HA4$/F1$8FbMF$G$9$,!"e(Bsubject e$B$Ke(B
[Bug:trunk] e$B$re(B
e$B$D$1K:$l$?$N$G:FAw$7$^$9!#e(B
=====
e$B1sF#$G$9!#e(B
Matrix::Scalar e$B$NDj5A$Ke(B 3 e$B$D$*$+$7$$$H$3$m$r8+$D$1$^$7$?!#e(B
nodoc e$B$J%/%i%9$G$9$,!"$I$l$bC1=c$JLdBj$@$H;W$&$N$GJs9p$7$^$9!#e(B
e$B!{e(B WrongArgType e$B$,L$Dj5Ae(B
$ ./ruby -rmatrix -e ‘Matrix[[0]].coerce(1).first + Matrix[[0]]’
/home/mame/work/ruby/lib/matrix.rb:979:in +': uninitialized constant Matrix::Scalar::WrongArgType (NameError) from -e:1:in
’
e$B$?$@$NDj5AK:$l$@$H;W$$$^$9!#e(B
e$B!{e(B Matrix#powered_by e$B$,L$Dj5Ae(B
$ ./ruby -rmatrix -e ‘2 ** Matrix[[1]]’
/home/mame/work/ruby/lib/matrix.rb:1032:in **': undefined method
powered_by’ for Matrix[[1]]:Matrix (NoMethodError)
from -e:1:in **' from -e:1:in
’
e$B$=$b$=$be(B 2 ** Matrix[[1]]
e$B$K0UL#$O$J$$$H;W$&$N$G!"e(BMatrix::Scalar#** e$B$Oe(B
e$B0z?t$,e(B Matrix e$B$@$C$?$iNc30$K$9$Y$-$G$O$J$$$G$7$g$&$+!#e(B
e$B!{e(B when Numeric e$B$N8e$Ke(B when Scalar e$B$,$"$ke(B
Scalar e$B$Oe(B Numeric e$B$N%5%V%/%i%9$J$N$G!"e(Bwhen Scalar
e$B$O<B9T$5$l$^$;$s!#e(B
e$B$b$7<B9T$5$l$k$h$&$K$J$C$?$H$7$F$b!“e(Bother.value
e$B$H$$$&5-=R$,$”$j!"e(B
Scalar e$B$Oe(B value e$B$H$$$&%a%=%C%I$rDs6!$7$F$$$J$$$N$Ge(B
NoMethodError e$B$K$J$ke(B
e$B$H;W$$$^$9!#e(B
— a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -27,6 +27,7 @@ module ExceptionForMatrix # :nodoc:
def_exception(“ErrDimensionMismatch”, “#{self.name} dimension
mismatch”)
def_exception(“ErrNotRegular”, “Not Regular Matrix”)
def_exception(“ErrOperationNotDefined”, “This operation(%s) can\'t
defined”)
- def_exception(“WrongArgType”, “wrong argument type %s (expected %s)”)
end
@@ -977,8 +978,6 @@ class Matrix
Scalar.new(@value + other)
when Vector, Matrix
Scalar.Raise WrongArgType, other.class, “Numeric or Scalar”
-
when Scalar
-
Scalar.new(@value + other.value) else x, y = other.coerce(self) x + y
@@ -991,8 +990,6 @@ class Matrix
Scalar.new(@value - other)
when Vector, Matrix
Scalar.Raise WrongArgType, other.class, “Numeric or Scalar”
-
when Scalar
-
Scalar.new(@value - other.value) else x, y = other.coerce(self) x - y
@@ -1029,10 +1026,8 @@ class Matrix
case other
when Numeric
Scalar.new(@value ** other)
-
when Vector
-
Scalar.Raise WrongArgType, other.class, "Numeric or Scalar or
Matrix"
-
when Matrix
-
other.powered_by(self)
-
when Vector, Matrix
-
Scalar.Raise WrongArgType, other.class, "Numeric or Scalar" else x, y = other.coerce(self) x ** y