Matrix Operations

Now that we got familiar with various matrix traits and with special types of matrices, we can introduce various matrix operations, which are computations we can perform using matrices.

  1. Matrix equality. We compare two matrices to see if they are equal.

    Input: Two matrices, $A$ and $B$.
    Output: A Boolean value (
    true
    ($= 1$), or
    false
    ($= 0$)).

    Algorithm (= description of the procedure of this matrix operation:)
    1. If the size of $A$ isn't equal to the size of $B$, return
      false
      . Otherwise:
    2. Check if the respective elements of $A$ and $B$ are equal. That is, given the matrices $A_{n \times m}$ and $B_{n \times m}$ (of the same size), check if $a_{i,j} = b_{i,j}$ for every $1 \le i \le n$ and every $1 \le j \le m$. If, for at least one pair of respective elements we have $a_{i,j} \neq b_{i,j}$, then return
      false
      . Otherwise (if all respective elements are equal), return
      true
      .