Complexity of sparse back substitution

777 Views Asked by At

What is the complexity of sparse backsubstitution $Rx = b$, given $n$, the dimensions of dense $x$ and $b$ as well as of the sparse $R$ and $nnz$, the number of nonzero entries in $R$?

1

There are 1 best solutions below

0
On BEST ANSWER

Based on source code from Timothy Davis' CSparse library, the answer is $O(nnz)$ if you count divisions and multiply-subtract equally as unit operations:

/* solve Ux=b where x and b are dense.  x=b on input, solution on output. */
csi cs_usolve (const cs *U, double *x)
{
    csi p, j, n, *Up, *Ui ;
    double *Ux ;
    if (!CS_CSC (U) || !x) return (0) ;                     /* check inputs */
    n = U->n ; Up = U->p ; Ui = U->i ; Ux = U->x ;
    for (j = n-1 ; j >= 0 ; j--) { // for each column
        x [j] /= Ux [Up [j+1]-1] ; // diagonal element
        for (p = Up [j] ; p < Up [j+1]-1 ; p++) {
            x [Ui [p]] -= Ux [p] * x [j] ; // all other elements in this column
        }
    }
    return (1) ;
}

Otherwise, it takes $n$ divisions and $nnz - n$ multiplications and subtractions.