summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2020-04-30 18:00:47 -0400
committerMarc-Andre Lafortune <github@marc-andre.ca>2020-05-01 03:25:11 -0400
commit3cb038cc7a9b1e01685a7e8a513e7ac7fb56b112 (patch)
tree879208c7c3bde20cd860eef55a9780f1a1b854e1 /lib
parent7d360efe92d2db11a4e51820ed2f52de36b3257f (diff)
[ruby/matrix] Fix Matrix#orthogonal?
Diffstat (limited to 'lib')
-rw-r--r--lib/matrix.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 9d6650370d..7d35b61fc5 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -890,11 +890,12 @@ class Matrix
#
def orthogonal?
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] * rows[k][j]
+ s += row_i[k] * row_j[k]
end
return false unless s == (i == j ? 1 : 0)
end