-
Notifications
You must be signed in to change notification settings - Fork 2
Matrix Comparators
Sergey Duyunov edited this page Nov 16, 2019
·
1 revision
Checking matrices for equality.
m1 = Matrix[[1, 2], [3, 4]]
m2 = Matrix[[1, 2], [3, 4]]
m1.eql?(m2)
# => true
m1 = Matrix[[1, 2], [3, 4]]
m2 = Matrix[[1, 2], [3, 4], [5, 6]]
m1.eql?(m2)
# => false
Checking matrices for equality. Works not only with FastMatrix:: Matrix.
require 'matrix'
m1 = FastMatrix::Matrix[[1, 2], [3, 4]]
m2 = ::Matrix[[1, 2], [3, 4]]
m1 == m2
# => true
Returns true if each element of the first Matrix is greater than or equal to the corresponding element of the second.
m1 = Matrix[[1, 2, 3], [-3, 2, 1]]
m2 = Matrix[[1, 2, 3], [-3, 2, 1]]
m2 >= m1
# => true
m1 = Matrix[[1, 2, 3], [3, 2, 1]]
m2 = Matrix[[3, 3, 3], [-3, 3, 3]]
m2 >= m1
# => false
Returns true if each element of the first Matrix is less than or equal to the corresponding element of the second.
m1 = Matrix[[1, 2, 3], [3, 2, 1]]
m2 = Matrix[[1, 1, 1], [1, 1, 1]]
m2 <= m1
# => true
m1 = Matrix[[1, 2, 3], [3, 2, 1]]
m2 = Matrix[[3, 3, 3], [-3, 3, 3]]
m2 <= m1
# => false
Returns true if each element of the first matrix is greater than the corresponding element of the second.
m1 = Matrix[[1, 2, 3], [3, 2, 1]]
m2 = Matrix[[2, 3, 6], [4, 4, 4]]
m2 > m1
# => true
m1 = Matrix[[1, 2, 3], [3, 2, 1]]
m2 = Matrix[[2, 3, 3], [4, 4, 4]]
m2 > m1
# => false
Returns true if each element of the first matrix is less than the corresponding element of the second.
m1 = Matrix[[1, 2, 3], [-3, 2, 1]]
m2 = Matrix[[0, 1, 0], [-5, 1, -1]]
m2 < m1
# => true
m1 = Matrix[[1, 2, 3], [-3, 2, 1]]
m2 = Matrix[[1, 2, 3], [-3, 2, 1]]
m2 < m1
# => false