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>
|
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
|
* cont.c, vm_core.h, eval.c: because rb_protect must not be jumped by
|
||||||
|
|
|
@ -54,6 +54,7 @@ class Bignum
|
||||||
end
|
end
|
||||||
|
|
||||||
class Rational
|
class Rational
|
||||||
|
remove_method :**
|
||||||
def ** (other)
|
def ** (other)
|
||||||
if other.kind_of?(Rational)
|
if other.kind_of?(Rational)
|
||||||
other2 = other
|
other2 = other
|
||||||
|
@ -188,6 +189,9 @@ module Math
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class << self
|
||||||
|
remove_method(:sqrt)
|
||||||
|
end
|
||||||
module_function :sqrt
|
module_function :sqrt
|
||||||
module_function :rsqrt
|
module_function :rsqrt
|
||||||
end
|
end
|
||||||
|
|
|
@ -603,16 +603,16 @@ class Matrix
|
||||||
end
|
end
|
||||||
akk = a[k][k]
|
akk = a[k][k]
|
||||||
|
|
||||||
size.times do |i|
|
size.times do |ii|
|
||||||
next if i == k
|
next if ii == k
|
||||||
q = a[i][k].quo(akk)
|
q = a[ii][k].quo(akk)
|
||||||
a[i][k] = 0
|
a[ii][k] = 0
|
||||||
|
|
||||||
(k + 1 ... size).each do |j|
|
(k + 1 ... size).each do |j|
|
||||||
a[i][j] -= a[k][j] * q
|
a[ii][j] -= a[k][j] * q
|
||||||
end
|
end
|
||||||
size.times do |j|
|
size.times do |j|
|
||||||
@rows[i][j] -= @rows[k][j] * q
|
@rows[ii][j] -= @rows[k][j] * q
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -678,19 +678,19 @@ class Matrix
|
||||||
det = 1
|
det = 1
|
||||||
size.times do |k|
|
size.times do |k|
|
||||||
if (akk = a[k][k]) == 0
|
if (akk = a[k][k]) == 0
|
||||||
i = (k+1 ... size).find {|i|
|
i = (k+1 ... size).find {|ii|
|
||||||
a[i][k] != 0
|
a[ii][k] != 0
|
||||||
}
|
}
|
||||||
return 0 if i.nil?
|
return 0 if ii.nil?
|
||||||
a[i], a[k] = a[k], a[i]
|
a[ii], a[k] = a[k], a[ii]
|
||||||
akk = a[k][k]
|
akk = a[k][k]
|
||||||
det *= -1
|
det *= -1
|
||||||
end
|
end
|
||||||
|
|
||||||
(k + 1 ... size).each do |i|
|
(k + 1 ... size).each do |ii|
|
||||||
q = a[i][k].quo(akk)
|
q = a[ii][k].quo(akk)
|
||||||
(k + 1 ... size).each do |j|
|
(k + 1 ... size).each do |j|
|
||||||
a[i][j] -= a[k][j] * q
|
a[ii][j] -= a[k][j] * q
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
det *= akk
|
det *= akk
|
||||||
|
@ -718,21 +718,21 @@ class Matrix
|
||||||
det = 1
|
det = 1
|
||||||
size.times do |k|
|
size.times do |k|
|
||||||
if a[k][k].zero?
|
if a[k][k].zero?
|
||||||
i = (k+1 ... size).find {|i|
|
i = (k+1 ... size).find {|ii|
|
||||||
a[i][k] != 0
|
a[ii][k] != 0
|
||||||
}
|
}
|
||||||
return 0 if i.nil?
|
return 0 if i.nil?
|
||||||
a[i], a[k] = a[k], a[i]
|
a[i], a[k] = a[k], a[i]
|
||||||
det *= -1
|
det *= -1
|
||||||
end
|
end
|
||||||
|
|
||||||
(k + 1 ... size).each do |i|
|
(k + 1 ... size).each do |ii|
|
||||||
q = a[i][k].quo(a[k][k])
|
q = a[ii][k].quo(a[k][k])
|
||||||
(k ... size).each do |j|
|
(k ... size).each do |j|
|
||||||
a[i][j] -= a[k][j] * q
|
a[ii][j] -= a[k][j] * q
|
||||||
end
|
end
|
||||||
unless a[i][k].zero?
|
unless a[ii][k].zero?
|
||||||
a[i], a[k] = a[k], a[i]
|
a[ii], a[k] = a[k], a[ii]
|
||||||
det *= -1
|
det *= -1
|
||||||
redo
|
redo
|
||||||
end
|
end
|
||||||
|
@ -764,15 +764,15 @@ class Matrix
|
||||||
rank = 0
|
rank = 0
|
||||||
a_column_size.times do |k|
|
a_column_size.times do |k|
|
||||||
if (akk = a[k][k]) == 0
|
if (akk = a[k][k]) == 0
|
||||||
i = (k+1 ... a_row_size).find {|i|
|
i = (k+1 ... a_row_size).find {|ii|
|
||||||
a[i][k] != 0
|
a[ii][k] != 0
|
||||||
}
|
}
|
||||||
if i
|
if i
|
||||||
a[i], a[k] = a[k], a[i]
|
a[i], a[k] = a[k], a[i]
|
||||||
akk = a[k][k]
|
akk = a[k][k]
|
||||||
else
|
else
|
||||||
i = (k+1 ... a_column_size).find {|i|
|
i = (k+1 ... a_column_size).find {|ii|
|
||||||
a[k][i] != 0
|
a[k][ii] != 0
|
||||||
}
|
}
|
||||||
next if i.nil?
|
next if i.nil?
|
||||||
(k ... a_column_size).each do |j|
|
(k ... a_column_size).each do |j|
|
||||||
|
@ -782,10 +782,10 @@ class Matrix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
(k + 1 ... a_row_size).each do |i|
|
(k + 1 ... a_row_size).each do |ii|
|
||||||
q = a[i][k].quo(akk)
|
q = a[ii][k].quo(akk)
|
||||||
(k + 1... a_column_size).each do |j|
|
(k + 1... a_column_size).each do |j|
|
||||||
a[i][j] -= a[k][j] * q
|
a[ii][j] -= a[k][j] * q
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rank += 1
|
rank += 1
|
||||||
|
|
|
@ -15,7 +15,7 @@ class TestFileUtilsDryRun < Test::Unit::TestCase
|
||||||
"FileUtils::DryRun.#{m} not public"
|
"FileUtils::DryRun.#{m} not public"
|
||||||
end
|
end
|
||||||
FileUtils::METHODS.each do |m|
|
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"
|
"FileUtils::DryRun\##{m} is not defined"
|
||||||
assert_equal true, FileUtils::DryRun.private_method_defined?(m),
|
assert_equal true, FileUtils::DryRun.private_method_defined?(m),
|
||||||
"FileUtils::DryRun\##{m} is not private"
|
"FileUtils::DryRun\##{m} is not private"
|
||||||
|
|
|
@ -726,7 +726,7 @@ class TestFileUtils
|
||||||
Dir.rmdir "tmp-first-line\ntmp-second-line"
|
Dir.rmdir "tmp-first-line\ntmp-second-line"
|
||||||
end if lf_in_path_allowed?
|
end if lf_in_path_allowed?
|
||||||
|
|
||||||
def test_mkdir_pathname
|
def test_mkdir_pathname
|
||||||
# pathname
|
# pathname
|
||||||
assert_nothing_raised {
|
assert_nothing_raised {
|
||||||
mkdir Pathname.new('tmp/tmpdirtmp')
|
mkdir Pathname.new('tmp/tmpdirtmp')
|
||||||
|
|
|
@ -57,11 +57,11 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_deoptimization
|
def test_deoptimization
|
||||||
assert_in_out_err(['-e', <<-EOS], '', %w[42], [])
|
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
|
EOS
|
||||||
|
|
||||||
assert_in_out_err(['-e', <<-EOS], '', %w[42], [])
|
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
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,10 +38,14 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_warning
|
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(-W0 -e) + ['p $-W'], "", %w(0), [])
|
||||||
assert_in_out_err(%w(-W1 -e) + ['p $-W'], "", %w(1), [])
|
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(-Wx -e) + ['p $-W'], "", %w(1), [])
|
||||||
assert_in_out_err(%w(-W -e) + ['p $-W'], "", %w(2), [])
|
assert_in_out_err(%w(-W -e) + ['p $-W'], "", %w(2), [])
|
||||||
|
ensure
|
||||||
|
ENV['RUBYOPT'] = save_rubyopt
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_safe_level
|
def test_safe_level
|
||||||
|
@ -271,7 +275,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_sflag
|
def test_sflag
|
||||||
assert_in_out_err(%w(- -abc -def=foo -ghi-jkl -- -xyz),
|
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]'], [])
|
['[true, "foo", true, nil]'], [])
|
||||||
|
|
||||||
assert_in_out_err(%w(- -#), "#!ruby -s\n", [],
|
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') }
|
assert_raise(Encoding::UndefinedConversionError) { "\xFF".encode("utf-8", 'TIS-620') }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_CP850
|
def test_CP850
|
||||||
check_both_ways("\u00C7", "\x80", 'CP850') # Ç
|
check_both_ways("\u00C7", "\x80", 'CP850') # Ç
|
||||||
check_both_ways("\u00C5", "\x8F", 'CP850') # Å
|
check_both_ways("\u00C5", "\x8F", 'CP850') # Å
|
||||||
check_both_ways("\u00C9", "\x90", 'CP850') # É
|
check_both_ways("\u00C9", "\x90", 'CP850') # É
|
||||||
|
|
|
@ -43,7 +43,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
|
||||||
UNIXSocket.pair {|s1, s2|
|
UNIXSocket.pair {|s1, s2|
|
||||||
begin
|
begin
|
||||||
ret = s1.sendmsg("\0", 0, nil, [Socket::SOL_SOCKET, Socket::SCM_RIGHTS,
|
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
|
rescue NotImplementedError
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue