summaryrefslogtreecommitdiff
path: root/lib/matrix.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-10 04:49:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-10 04:49:24 +0000
commitc67a74570dd056569763f5015e0aafa7d454fca7 (patch)
treef1dda39296b6911752cd4b6446a21f2e54ff68e1 /lib/matrix.rb
parent3043170b14875ce53f3a951d665279b12c2c63a8 (diff)
downloadruby-c67a74570dd056569763f5015e0aafa7d454fca7.tar.gz
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/matrix.rb')
-rw-r--r--lib/matrix.rb58
1 files changed, 29 insertions, 29 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 9de7dcb3a2..223bf70869 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -37,7 +37,7 @@
# creates a matrix where `rows' indicates rows.
# `rows' is an array of arrays,
# e.g, Matrix[[11, 12], [21, 22]]
-# Matrix.rows(rows, copy = TRUE)
+# Matrix.rows(rows, copy = true)
# creates a matrix where `rows' indicates rows.
# if optional argument `copy' is false, use the array as
# internal structure of the metrix without copying.
@@ -143,7 +143,7 @@
#
# INSTANCE CREATION:
# Vector.[](*array)
-# Vector.elements(array, copy = TRUE)
+# Vector.elements(array, copy = true)
# ACCSESSING:
# [](i)
# size
@@ -193,10 +193,10 @@ class Matrix
private_class_method :new
def Matrix.[](*rows)
- new(:init_rows, rows, FALSE)
+ new(:init_rows, rows, false)
end
- def Matrix.rows(rows, copy = TRUE)
+ def Matrix.rows(rows, copy = true)
new(:init_rows, rows, copy)
end
@@ -208,7 +208,7 @@ class Matrix
columns[j][i]
}
}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
def Matrix.diagonal(*values)
@@ -220,7 +220,7 @@ class Matrix
row
}
self
- rows(rows, FALSE)
+ rows(rows, false)
end
def Matrix.scalar(n, value)
@@ -242,11 +242,11 @@ class Matrix
def Matrix.row_vector(row)
case row
when Vector
- Matrix.rows([row.to_a], FALSE)
+ Matrix.rows([row.to_a], false)
when Array
- Matrix.rows([row.dup], FALSE)
+ Matrix.rows([row.dup], false)
else
- Matrix.row([[row]], FALSE)
+ Matrix.row([[row]], false)
end
end
@@ -311,13 +311,13 @@ class Matrix
|i|
@rows[i][j]
}
- Vector.elements(col, FALSE)
+ Vector.elements(col, false)
end
end
def collect
rows = @rows.collect{|row| row.collect{|e| yield e}}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
alias map collect
@@ -345,7 +345,7 @@ class Matrix
|row|
row[from_col, size_col]
}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
# TESTING
@@ -363,20 +363,20 @@ class Matrix
# COMPARING
def ==(other)
- return FALSE unless Matrix === other
+ return false unless Matrix === other
other.compare_by_row_vectors(@rows)
end
alias eql? ==
def compare_by_row_vectors(rows)
- return FALSE unless @rows.size == rows.size
+ return false unless @rows.size == rows.size
0.upto(@rows.size - 1) do
|i|
- return FALSE unless @rows[i] == rows[i]
+ return false unless @rows[i] == rows[i]
end
- TRUE
+ true
end
def clone
@@ -405,7 +405,7 @@ class Matrix
e * m
}
}
- return Matrix.rows(rows, FALSE)
+ return Matrix.rows(rows, false)
when Vector
m = Matrix.column_vector(m)
r = self * m
@@ -425,7 +425,7 @@ class Matrix
vij
}
}
- return Matrix.rows(rows, FALSE)
+ return Matrix.rows(rows, false)
else
x, y = m.coerce(self)
return x * y
@@ -453,7 +453,7 @@ class Matrix
self[i, j] + m[i, j]
}
}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
def -(m)
@@ -477,7 +477,7 @@ class Matrix
self[i, j] - m[i, j]
}
}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
def /(other)
@@ -490,7 +490,7 @@ class Matrix
e / other
}
}
- return Matrix.rows(rows, FALSE)
+ return Matrix.rows(rows, false)
when Matrix
return self * other.inverse
else
@@ -825,10 +825,10 @@ class Vector
private_class_method :new
def Vector.[](*array)
- new(:init_elements, array, copy = FALSE)
+ new(:init_elements, array, copy = false)
end
- def Vector.elements(array, copy = TRUE)
+ def Vector.elements(array, copy = true)
new(:init_elements, array, copy)
end
@@ -873,7 +873,7 @@ class Vector
# COMPARING
def ==(other)
- return FALSE unless Vector === other
+ return false unless Vector === other
other.compare_by(@elements)
end
@@ -897,7 +897,7 @@ class Vector
case x
when Numeric
els = @elements.collect{|e| e * x}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
when Matrix
self.covector * x
else
@@ -914,7 +914,7 @@ class Vector
|v1, v2|
v1 + v2
}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
when Matrix
Matrix.column_vector(self) + v
else
@@ -931,7 +931,7 @@ class Vector
|v1, v2|
v1 - v2
}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
when Matrix
Matrix.column_vector(self) - v
else
@@ -958,7 +958,7 @@ class Vector
|v|
yield v
}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
end
alias map collect
@@ -967,7 +967,7 @@ class Vector
|v1, v2|
yield v1, v2
}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
end
def r