Contents Previous Next Subchapters

Ordered Numeric And Logical Comparisons
Syntax left value < right value
left value > right value
left value <= right value
left value >= right value
(less than)
(greater than)
(less than or equal to)
(greater than or equal to)
See Also logical operators , equality , any , all and string order

Description
Compares two values that are integer, real, or double-precision. (One, but not both, of the values may be logical.)

You can compare a matrix with another matrix of the same dimension or with a scalar. The result is a logical matrix with the same dimension as the original matrix.

Tutorial

Comparing Scalars
If you enter
     x = 4
     y = 8
     print y > x
O-Matrix will respond
     T

Comparing Matrices
O-Matrix compares each element of the two matrices individually, and generates a logical matrix of the same dimension as the matrices being compared. For example, if you enter
     x = [1, 2, 3, 4, 8]
     y = [1, 2, 3, 5, 6]
     x < y
O-Matrix will respond
     [ F , F , F , T , F ]
because the first three elements of x and y are equal, the fourth element of x is less than the corresponding element of y, and the fifth element of x is greater than the fifth element of y.

Comparing Matrices With Scalars
When comparing a matrix with a scalar, the result has the same dimension as the matrix. Each element of the result corresponds to comparing an element of the matrix with the scalar. For example, if you enter
     x = {[1, 2], [3, 4]}
     x <= 2
O-Matrix will respond
     {
     [ T , T ]
     [ F , F ]
     }

Reference
If the matrix types do not agree, O-Matrix will coerce the values as detailed in the coercion section.