=============================================== Triangular Solver (for Matrix Vector Equations) [TOC] =============================================== As an example we consider the system of linear equations $Ax = b$ with ---- LATEX --------------------------------------------------------------------- A = \left(\begin{array}{ccc} 4 & 5 & 6 \\ 1 & 2 & 3 \\ 7 & 8 & 1 \\ \end{array}\right) \quad\text{and} \quad b = \left(\begin{array}{c} 32 \\ 14 \\ 26 \\ \end{array}\right) -------------------------------------------------------------------------------- An $LU$ factorization without pivoting is given by ---- LATEX --------------------------------------------------------------------- L = \left(\begin{array}{ccc} 1 & 0 & 0 \\ \frac{1}{4} & 1 & 0 \\ \frac{7}{4} & -1 & 1 \\ \end{array}\right) \quad\text{and} \quad U = \left(\begin{array}{ccc} 4 & 5 & 6 \\ 0 & \frac{3}{4} & \frac{3}{2} \\ 0 & 0 & -8 \\ \end{array}\right) \quad\text{and} -------------------------------------------------------------------------------- Hence the problem $Ax = LUx = b$ can be solved by first computing ---- LATEX --------------------------------------------------------------------- y = L^{-1} b -------------------------------------------------------------------------------- and then ---- LATEX --------------------------------------------------------------------- x = U^{-1} y -------------------------------------------------------------------------------- Skeleton for simple Example =========================== :import: session13/simple_dtrsv_ex.c [fold] Exercise: ========= - Solve the above system of linear equations with pencil and paper: - Solve $Ly = b$ with forward substitution. - Solve $Ux = y$ with backward substitution. - Make yourself familiar with the structure of the program. Compile and run it: - For testing the *col major case* compile it with ---- SHELL(path=session13) ------------------------------------------------- gcc -Wall -std=c11 -o simple_dtrsv_ex simple_dtrsv_ex.c ---------------------------------------------------------------------------- - For testing the *row major case* compile it with ---- SHELL(path=session13) ------------------------------------------------- gcc -Wall -std=c11 -o simple_dtrsv_ex -DCOLMAJOR=0 simple_dtrsv_ex.c ---------------------------------------------------------------------------- - Change the program such that $A$ gets initialized as ---- LATEX ------------------------------------------------------------------- A = \left(\begin{array}{rrrr} 4 & 5 & 6 & 32 \\ \frac{1}{4} & \frac{3}{4} & \frac{3}{2} & 14 \\ \frac{7}{4} & -1 & -8 & 26 \\ \end{array}\right) ------------------------------------------------------------------------------ - Implement function `dtrsv`. You implementation should be optimized for the row major and the col major case: - For col major cases it should be based on `daxpy` function calls. - For row major cases it should be based on `ddot` function calls.