# How to avoid unnecessary checks when inverting this LU decomposition

Background for the question

I am currently working on a Matlab code in which the systems of linear equations $$Ax_1 = b_1$$, $$Ax_2 = b_2$$, ... have to be solved. As the matrix $$A$$ is constant during the simulation, I LU-decompose it once and for all at the beginning and solve the $$n$$th system as

xn = U\(L\bn);

At this point it is probably worth mentioning that I only know the $$b$$-vectors one at a time, meaning that i cannnot solve the equations all at once.

As can be seen in the figures below, the matrices $$L$$ and $$U$$ very sparse and I therefore store them in sparse format. Moreover, they are upper an lower triangular. By looking at the documentation for the operator "\" it can be seen that Matlab will end up using a triangular solver to solve the systems. Before it gets to that, it however has to see if $$L$$ and $$U$$ are square, compute their bandwidth, see if they are diagonal, check if they look triangular and then finally check that they actually are triangular before using the triangular solver.

The actual question

My question is whether there is a way of bypassing all these checks and go directly to the triangular solver?

What have I tried so far

So far I have looked into the functions "linsolve" and creating upper and lower triangular solvers using "dsp.LowerTriangularSolver" and "dsp.UpperTriangularSolver". Unfortunately, all of these only work on full matrices.

• If your matrix is triangular, why do you compute an LU decomposition at all? If it is lower triangular, then $L=A$ and $U=I$. – Wolfgang Bangerth Sep 20 '19 at 16:11
• The matrix $A$, which I LU-decompose, is not triangular. – Mathias Klahn Sep 20 '19 at 16:17
• So what do the pictures correspond to, then? – Wolfgang Bangerth Sep 23 '19 at 22:01
• The pictures show the sparsity patterns of $L$ and $U$. – Mathias Klahn Sep 24 '19 at 12:29