Matrix Operations
- 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:
- Create space for matrix $B_{n \times m}$.
- 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)$.