summaryrefslogtreecommitdiff
path: root/lib/matrix/eigenvalue_decomposition.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-13 05:50:34 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-13 05:50:34 +0000
commitad162055c41cbcb279705480c8405219688e34f2 (patch)
tree4aa4a08d2e6b57d2371c547e7f6032e038207ca8 /lib/matrix/eigenvalue_decomposition.rb
parent790e7f797b94d5bcbe79448a17189f845aca1498 (diff)
* 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
Diffstat (limited to 'lib/matrix/eigenvalue_decomposition.rb')
-rw-r--r--lib/matrix/eigenvalue_decomposition.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/matrix/eigenvalue_decomposition.rb b/lib/matrix/eigenvalue_decomposition.rb
index ab5888ff371..19494066870 100644
--- a/lib/matrix/eigenvalue_decomposition.rb
+++ b/lib/matrix/eigenvalue_decomposition.rb
@@ -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