Matrix Operations

  1. Scalar multiplication. Multiply every element of a matrix by a scalar $c$.

    Input: Matrix $A_{n \times m}$ and scalar $c$ (usually, $c \in \mathbb{R}$.)
    Output: $B = cA$, where $b_{i,j} = c \cdot a_{i,j}$.

    Algorithm:
    1. Create space for matrix $B_{n \times m}$.
    2. For every $1 \le i \le n$ and $1 \le j \le n$, set $b_{i,j} = c \cdot a_{i,j}$. Then, return matrix $B$.
    Runtime analysis: $\Theta(nm)$.