Skip to content

Fix failing trsm test #10

Description

@amklinv-nnl

The failing trsm test tries to solve the following triangular system

$$ B A^{-1} = X $$

This is equivalent to

$$ \left(B A^{-1}\right)^T = X^T $$

$$ A^{-T} B^T = X^T $$

$$ B^T = A^T X^T $$

For this test,

$$ A = \begin{bmatrix} 8 & 0 & 0 \\ 2 & 8 & 0 \\ 1 & 2 & 8 \\ \end{bmatrix} $$

and

$$ B = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ 10 & 11 & 12 \end{bmatrix} $$

$$ X = \begin{bmatrix} x_{0,0} & x_{0,1} & x_{0,2} \\ x_{1,0} & x_{1,1} & x_{1,2} \\ x_{2,0} & x_{2,1} & x_{2,2} \\ x_{3,0} & x_{3,1} & x_{3,2} \end{bmatrix} $$

so

$$ \begin{bmatrix} 8 & 0 & 0 \\ 2 & 8 & 0 \\ 1 & 2 & 8 \\ \end{bmatrix}^T \begin{bmatrix} x_{0,0} & x_{0,1} & x_{0,2} \\ x_{1,0} & x_{1,1} & x_{1,2} \\ x_{2,0} & x_{2,1} & x_{2,2} \\ x_{3,0} & x_{3,1} & x_{3,2} \end{bmatrix}^T = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ 10 & 11 & 12 \end{bmatrix}^T $$

$$ \begin{bmatrix} 8 & 2 & 1 \\ 0 & 8 & 2 \\ 0 & 0 & 8 \end{bmatrix} \begin{bmatrix} x_{0,0} & x_{1,0} & x_{2,0} & x_{3,0} \\ x_{0,1} & x_{1,1} & x_{2,1} & x_{3,1} \\ x_{0,2} & x_{1,2} & x_{2,2} & x_{3,2} \end{bmatrix} = \begin{bmatrix} 1 & 4 & 7 & 10 \\ 2 & 5 & 8 & 11 \\ 3 & 6 & 9 & 12 \end{bmatrix} $$

The last column of X should be the easiest to compute because

$$ 8 \begin{bmatrix} x_{0,2} & x_{1,2} & x_{2,2} & x_{3,2} \end{bmatrix} = \begin{bmatrix} 3 & 6 & 9 & 12 \end{bmatrix} $$

meaning

$$ \begin{bmatrix} x_{0,2} & x_{1,2} & x_{2,2} & x_{3,2} \end{bmatrix} = \begin{bmatrix} 0.375 & 0.75 & 1.125 & 1.5 \end{bmatrix} $$

The first thing I would check:

  • Is the last column of X being computed correctly?

If not,

  • Is the code assuming a unit diagonal? i.e.

$$ A = \begin{bmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 1 & 2 & 1 \end{bmatrix} $$

If so, you'll get

$$ \begin{bmatrix} x_{0,2} & x_{1,2} & x_{2,2} & x_{3,2} \end{bmatrix} = \begin{bmatrix} 3 & 6 & 9 & 12 \end{bmatrix} $$

Alternatively,

  • Is the code accidentally transposing the matrix? i.e.

$$ A = \begin{bmatrix} 8 & 2 & 1 \\ 0 & 8 & 2 \\ 0 & 0 & 8 \end{bmatrix} $$

This would result in

$$ 8 \begin{bmatrix} x_{0,0} & x_{1,0} & x_{2,0} & x_{3,0} \end{bmatrix} = \begin{bmatrix} 1 & 4 & 7 & 10 \end{bmatrix} $$

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions