mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/matrix.rb: suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7123baaf14
commit
a967f738c8
9 changed files with 46 additions and 34 deletions
|
@ -1,3 +1,7 @@
|
|||
Tue Jan 26 07:06:05 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* lib/matrix.rb: suppress warnings.
|
||||
|
||||
Tue Jan 26 03:16:45 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* cont.c, vm_core.h, eval.c: because rb_protect must not be jumped by
|
||||
|
|
|
@ -54,6 +54,7 @@ class Bignum
|
|||
end
|
||||
|
||||
class Rational
|
||||
remove_method :**
|
||||
def ** (other)
|
||||
if other.kind_of?(Rational)
|
||||
other2 = other
|
||||
|
@ -188,6 +189,9 @@ module Math
|
|||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
remove_method(:sqrt)
|
||||
end
|
||||
module_function :sqrt
|
||||
module_function :rsqrt
|
||||
end
|
||||
|
|
|
@ -603,16 +603,16 @@ class Matrix
|
|||
end
|
||||
akk = a[k][k]
|
||||
|
||||
size.times do |i|
|
||||
next if i == k
|
||||
q = a[i][k].quo(akk)
|
||||
a[i][k] = 0
|
||||
size.times do |ii|
|
||||
next if ii == k
|
||||
q = a[ii][k].quo(akk)
|
||||
a[ii][k] = 0
|
||||
|
||||
(k + 1 ... size).each do |j|
|
||||
a[i][j] -= a[k][j] * q
|
||||
a[ii][j] -= a[k][j] * q
|
||||
end
|
||||
size.times do |j|
|
||||
@rows[i][j] -= @rows[k][j] * q
|
||||
@rows[ii][j] -= @rows[k][j] * q
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -678,19 +678,19 @@ class Matrix
|
|||
det = 1
|
||||
size.times do |k|
|
||||
if (akk = a[k][k]) == 0
|
||||
i = (k+1 ... size).find {|i|
|
||||
a[i][k] != 0
|
||||
i = (k+1 ... size).find {|ii|
|
||||
a[ii][k] != 0
|
||||
}
|
||||
return 0 if i.nil?
|
||||
a[i], a[k] = a[k], a[i]
|
||||
return 0 if ii.nil?
|
||||
a[ii], a[k] = a[k], a[ii]
|
||||
akk = a[k][k]
|
||||
det *= -1
|
||||
end
|
||||
|
||||
(k + 1 ... size).each do |i|
|
||||
q = a[i][k].quo(akk)
|
||||
(k + 1 ... size).each do |ii|
|
||||
q = a[ii][k].quo(akk)
|
||||
(k + 1 ... size).each do |j|
|
||||
a[i][j] -= a[k][j] * q
|
||||
a[ii][j] -= a[k][j] * q
|
||||
end
|
||||
end
|
||||
det *= akk
|
||||
|
@ -718,21 +718,21 @@ class Matrix
|
|||
det = 1
|
||||
size.times do |k|
|
||||
if a[k][k].zero?
|
||||
i = (k+1 ... size).find {|i|
|
||||
a[i][k] != 0
|
||||
i = (k+1 ... size).find {|ii|
|
||||
a[ii][k] != 0
|
||||
}
|
||||
return 0 if i.nil?
|
||||
a[i], a[k] = a[k], a[i]
|
||||
det *= -1
|
||||
end
|
||||
|
||||
(k + 1 ... size).each do |i|
|
||||
q = a[i][k].quo(a[k][k])
|
||||
(k + 1 ... size).each do |ii|
|
||||
q = a[ii][k].quo(a[k][k])
|
||||
(k ... size).each do |j|
|
||||
a[i][j] -= a[k][j] * q
|
||||
a[ii][j] -= a[k][j] * q
|
||||
end
|
||||
unless a[i][k].zero?
|
||||
a[i], a[k] = a[k], a[i]
|
||||
unless a[ii][k].zero?
|
||||
a[ii], a[k] = a[k], a[ii]
|
||||
det *= -1
|
||||
redo
|
||||
end
|
||||
|
@ -764,15 +764,15 @@ class Matrix
|
|||
rank = 0
|
||||
a_column_size.times do |k|
|
||||
if (akk = a[k][k]) == 0
|
||||
i = (k+1 ... a_row_size).find {|i|
|
||||
a[i][k] != 0
|
||||
i = (k+1 ... a_row_size).find {|ii|
|
||||
a[ii][k] != 0
|
||||
}
|
||||
if i
|
||||
a[i], a[k] = a[k], a[i]
|
||||
akk = a[k][k]
|
||||
else
|
||||
i = (k+1 ... a_column_size).find {|i|
|
||||
a[k][i] != 0
|
||||
i = (k+1 ... a_column_size).find {|ii|
|
||||
a[k][ii] != 0
|
||||
}
|
||||
next if i.nil?
|
||||
(k ... a_column_size).each do |j|
|
||||
|
@ -782,10 +782,10 @@ class Matrix
|
|||
end
|
||||
end
|
||||
|
||||
(k + 1 ... a_row_size).each do |i|
|
||||
q = a[i][k].quo(akk)
|
||||
(k + 1 ... a_row_size).each do |ii|
|
||||
q = a[ii][k].quo(akk)
|
||||
(k + 1... a_column_size).each do |j|
|
||||
a[i][j] -= a[k][j] * q
|
||||
a[ii][j] -= a[k][j] * q
|
||||
end
|
||||
end
|
||||
rank += 1
|
||||
|
|
|
@ -15,7 +15,7 @@ class TestFileUtilsDryRun < Test::Unit::TestCase
|
|||
"FileUtils::DryRun.#{m} not public"
|
||||
end
|
||||
FileUtils::METHODS.each do |m|
|
||||
assert_equal true, respond_to?(m, true)
|
||||
assert_equal true, respond_to?(m, true),
|
||||
"FileUtils::DryRun\##{m} is not defined"
|
||||
assert_equal true, FileUtils::DryRun.private_method_defined?(m),
|
||||
"FileUtils::DryRun\##{m} is not private"
|
||||
|
|
|
@ -726,7 +726,7 @@ class TestFileUtils
|
|||
Dir.rmdir "tmp-first-line\ntmp-second-line"
|
||||
end if lf_in_path_allowed?
|
||||
|
||||
def test_mkdir_pathname
|
||||
def test_mkdir_pathname
|
||||
# pathname
|
||||
assert_nothing_raised {
|
||||
mkdir Pathname.new('tmp/tmpdirtmp')
|
||||
|
|
|
@ -57,11 +57,11 @@ class TestCase < Test::Unit::TestCase
|
|||
|
||||
def test_deoptimization
|
||||
assert_in_out_err(['-e', <<-EOS], '', %w[42], [])
|
||||
class Symbol; def ===(o); p 42; true; end; end; case :foo; when :foo; end
|
||||
class Symbol; undef ===; def ===(o); p 42; true; end; end; case :foo; when :foo; end
|
||||
EOS
|
||||
|
||||
assert_in_out_err(['-e', <<-EOS], '', %w[42], [])
|
||||
class Fixnum; def ===(o); p 42; true; end; end; case 1; when 1; end
|
||||
class Fixnum; undef ===; def ===(o); p 42; true; end; end; case 1; when 1; end
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,10 +38,14 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_warning
|
||||
save_rubyopt = ENV['RUBYOPT']
|
||||
ENV['RUBYOPT'] = nil
|
||||
assert_in_out_err(%w(-W0 -e) + ['p $-W'], "", %w(0), [])
|
||||
assert_in_out_err(%w(-W1 -e) + ['p $-W'], "", %w(1), [])
|
||||
assert_in_out_err(%w(-Wx -e) + ['p $-W'], "", %w(1), [])
|
||||
assert_in_out_err(%w(-W -e) + ['p $-W'], "", %w(2), [])
|
||||
ensure
|
||||
ENV['RUBYOPT'] = save_rubyopt
|
||||
end
|
||||
|
||||
def test_safe_level
|
||||
|
@ -271,7 +275,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
|
||||
def test_sflag
|
||||
assert_in_out_err(%w(- -abc -def=foo -ghi-jkl -- -xyz),
|
||||
"#!ruby -s\np [$abc, $def, $ghi_jkl, $xyz]\n",
|
||||
"#!ruby -s\np [$abc, $def, $ghi_jkl, defined?($xyz)]\n",
|
||||
['[true, "foo", true, nil]'], [])
|
||||
|
||||
assert_in_out_err(%w(- -#), "#!ruby -s\n", [],
|
||||
|
|
|
@ -909,7 +909,7 @@ class TestTranscode < Test::Unit::TestCase
|
|||
assert_raise(Encoding::UndefinedConversionError) { "\xFF".encode("utf-8", 'TIS-620') }
|
||||
end
|
||||
|
||||
def test_CP850
|
||||
def test_CP850
|
||||
check_both_ways("\u00C7", "\x80", 'CP850') # Ç
|
||||
check_both_ways("\u00C5", "\x8F", 'CP850') # Å
|
||||
check_both_ways("\u00C9", "\x90", 'CP850') # É
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
|
|||
UNIXSocket.pair {|s1, s2|
|
||||
begin
|
||||
ret = s1.sendmsg("\0", 0, nil, [Socket::SOL_SOCKET, Socket::SCM_RIGHTS,
|
||||
send_io_ary.map {|io| io.fileno }.pack("i!*")])
|
||||
send_io_ary.map {|io2| io2.fileno }.pack("i!*")])
|
||||
rescue NotImplementedError
|
||||
return
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue