1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/matrix/eigenvalue_decomposition: Fix eigensystem with complex

eigenvectors. Patch by pypypy567.
  [Bug #7208] [ruby-dev:46251] [rubyspec:242f8e55bd]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2013-01-13 05:50:34 +00:00
parent 790e7f797b
commit ad162055c4
2 changed files with 8 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Sun Jan 13 14:48:55 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/matrix/eigenvalue_decomposition: Fix eigensystem with complex
eigenvectors. Patch by pypypy567.
[Bug #7208] [ruby-dev:46251] [rubyspec:242f8e55bd]
Sun Jan 13 14:06:00 2013 Zachary Scott <zachary@zacharyscott.net>
* lib/irb.rb, lib/prime.rb: Typos in overview

View file

@ -84,14 +84,14 @@ class Matrix
private
def build_eigenvectors
# JAMA stores complex eigenvectors in a strange way
# See http://cio.nist.gov/esd/emaildir/lists/jama/msg01021.html
# See http://web.archive.org/web/20111016032731/http://cio.nist.gov/esd/emaildir/lists/jama/msg01021.html
@e.each_with_index.map do |imag, i|
if imag == 0
Array.new(@size){|j| @v[j][i]}
elsif imag > 0
Array.new(@size){|j| Complex(@v[j][i], @v[j][i+1])}
else
Array.new(@size){|j| Complex(@v[j][i], -@v[j][i-1])}
Array.new(@size){|j| Complex(@v[j][i-1], -@v[j][i])}
end
end
end