summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2020-04-30 17:49:06 -0400
committerMarc-Andre Lafortune <github@marc-andre.ca>2020-05-01 03:25:05 -0400
commit7d360efe92d2db11a4e51820ed2f52de36b3257f (patch)
tree7891bffb9aee578d075ca8f0a4c6e23f24fadca8 /lib
parentc925cc01c5e8d595449156556416f067b914f6ca (diff)
[ruby/matrix] Fix Matrix#unitary? [#14]
Diffstat (limited to 'lib')
-rw-r--r--lib/matrix.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index a0f116095c..9d6650370d 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -983,11 +983,11 @@ class Matrix
#
def unitary?
raise ErrDimensionMismatch unless square?
- rows.each_with_index do |row, i|
- column_count.times do |j|
+ rows.each_with_index do |row_i, i|
+ rows.each_with_index do |row_j, j|
s = 0
row_count.times do |k|
- s += row[k].conj * rows[k][j]
+ s += row_i[k].conj * row_j[k]
end
return false unless s == (i == j ? 1 : 0)
end