Contents Previous Next Subchapters Current Chapters-> positive negative addition coercion subtraction multiplication division equality ordered logicalOperator matrixMultiplication matrixDivision exponentiation transpose norm stringEquality stringOrdered sequence operationOrder Parent Chapters-> Omatrix6 expression equality Search Tools-> contents reference index search

Testing Numeric And Logical Equality
 Syntax left value` == `right value``` ```left value` <> `right value (equal) ``` ```(not equal) See Also ordered , equal , all , any , and string ==

Description
Tests the equality of two logical, integer, real, double-precision or complex values. ``` ```Comparisons using the equal (`==`) and not equal (`<>`) operators return logical matrices with dimensions equal to the matrices being compared. An element of the result is true (which O-Matrix prints as T) if the condition is true for the corresponding elements of the two matrices, or false (which O-Matrix prints as F) if it is not. If a matrix is compared with a scalar, O-Matrix compares the scalar value with the value of each individual element of the matrix.

Tutorial

Comparing Scalars
If you enter ```      x = 4      y = 8      print y == x ``` O-Matrix will respond ```      F ``` O-Matrix does not consider matrix type when testing equality (because it performs coercion before making the test). If you enter ```      x = 1      y = 1.      print y == x ``` O-Matrix will respond ```      T ``` even though x is an integer and y is a real number.

Assigning Logical Values
Variables can be set equal to logical values. If you enter ```      z = 2 <> 3      z ``` O-Matrix will respond ```      T ``` Variables can also be directly assigned the logical values true or false. Entering ```      x = true      x ``` results in ```      T ```
Comparing Matrices
When testing the equality of two non-scalars, O-Matrix returns a matrix of the same dimension as the matrices being compared. For example, if you enter ```      u = { 4, 3, 2, 1, 9 }      v = { 9, 2, 2, 2, 9 }      u == v ``` O-Matrix will respond ```      {      F      F      T      F      T      } ``` If you enter ```      x = {[1, 2], [2, 1]}      y = {[2, 1], [2, 1]}      x == y ``` O-Matrix will respond ```      {      [ F , F ]      [ T , T ]      } ```
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 ```      {      [ F , T ]      [ F , F ]      } ```
Reference
If the value types do not agree, O-Matrix will coerce the values as detailed in the coercion section.