Implements and evaluates four column-oriented algorithms for computing matrix-vector and matrix-matrix products, exploiting the structure of triangular and banded matrices for computational efficiency. Each algorithm is validated against MATLAB's built-in operations by comparing absolute and relative error across dimensions n = 30 to n = 100.
Subroutine 1 — Unit lower triangular matrix-vector product (Lvmult_col)
Computes z = Lv where L is a unit lower triangular matrix. Complexity: O(n²)
Subroutine 2 — Compressed unit lower triangular matrix-vector product (Lvmult_col_compressed)
Computes the same product as Subroutine 1 but stores only the nonzero sub-diagonal
elements of L in a 1-D array to reduce memory usage. Complexity: O(n²)
Subroutine 3 — Banded unit lower triangular matrix-vector product (Lvmult_col_banded)
Computes
with the conditions
Subroutine 4 — LU matrix-matrix product (LUmult)
Given a matrix A, decomposes it into a unit lower triangular matrix L and upper
triangular matrix U, then computes M = LU using the middle product:
The upper limit is reduced to min(i, j) to skip zero elements. Complexity: O(n³)
Each algorithm is column-oriented, looping over columns j before rows i. Nonzero entries of all input matrices and vectors are drawn from a normal distribution with mean 0 and standard deviation 500. Results are compared against MATLAB built-ins using absolute and relative error:
Relative error for all four algorithms at n = 100 falls in the range of
MATLAB
- Ensure all five
.mfiles are in the same directory - Open the driver file in MATLAB
- Follow the instructions at the top of the driver file to run each subroutine
- The driver will test each algorithm across dimensions n = 30 to n = 100 and plot the mean and maximum relative error for each