sparseLU-class | R Documentation |

Objects of this class contain the components of the LU decomposition of a sparse square matrix.

Objects can be created by calls of the form ```
new("sparseLU",
...)
```

but are more commonly created by function `lu()`

applied to a sparse matrix, such as a matrix of class
`dgCMatrix`

.

`L`

:Object of class

`"dtCMatrix"`

, the lower triangular factor from the left.`U`

:Object of class

`"dtCMatrix"`

, the upper triangular factor from the right.`p`

:Object of class

`"integer"`

, permutation applied from the left.`q`

:Object of class

`"integer"`

, permutation applied from the right.`Dim`

:the dimension of the original matrix; inherited from class

`MatrixFactorization`

.

Class `"LU"`

, directly.
Class `"MatrixFactorization"`

, by class `"LU"`

.

- expand
`signature(x = "sparseLU")`

Returns a list with components`P`

,`L`

,`U`

, and`Q`

, where*P*and*Q*represent fill-reducing permutations, and*L*, and*U*the lower and upper triangular matrices of the decomposition. The original matrix corresponds to the product*P'LUQ*.

The decomposition is of the form

*A = P'LUQ,*

or equivalently *PAQ' = LU*,
where all matrices are sparse and of size *n by n*.
The matrices *P* and *Q*, and their transposes *P'* and
*Q'* are permutation matrices,
*L* is lower triangular and *U* is upper triangular.

`lu`

, `solve`

, `dgCMatrix`

## Extending the one in examples(lu), calling the matrix A, ## and confirming the factorization identities : A <- as(readMM(system.file("external/pores_1.mtx", package = "Matrix")), "CsparseMatrix") ## with dimnames(.) - to see that they propagate to L, U : dimnames(A) <- list(paste0("r", seq_len(nrow(A))), paste0("C", seq_len(ncol(A)))) str(luA <- lu(A)) # p is a 0-based permutation of the rows # q is a 0-based permutation of the columns xA <- expand(luA) ## which is simply doing stopifnot(identical(xA$ L, luA@L), identical(xA$ U, luA@U), identical(xA$ P, as(luA@p +1L, "pMatrix")), identical(xA$ Q, as(luA@q +1L, "pMatrix"))) P.LUQ <- with(xA, t(P) %*% L %*% U %*% Q) stopifnot(all.equal(unname(A), unname(P.LUQ), tolerance = 1e-12)) ## permute rows and columns of original matrix pA <- A[luA@p + 1L, luA@q + 1L] PAQ. <- with(xA, P %*% A %*% t(Q)) stopifnot(all.equal(unname(pA), unname(PAQ.), tolerance = 1e-12)) pLU <- drop0(luA@L %*% luA@U) # L %*% U -- dropping extra zeros stopifnot(all.equal(pA, pLU, tolerance = 1e-12))

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.