File: LU.R

package info (click to toggle)
rmatrix 1.3-2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,024 kB
  • sloc: ansic: 42,435; makefile: 330; sh: 180
file content (16 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
setMethod("expand", signature(x = "denseLU"),
	  function(x, ...) .Call(LU_expand, x))

setMethod("solve", signature(a = "denseLU", b = "missing"),
	  function(a, b, ...) {
	      ll <- expand(a) #-> list(L, U, P); orig  x = P %*% L %*% U
	      ## too expensive: with(lapply(ll, solve), U %*% L %*% P)
	      solve(ll$U, solve(ll$L, ll$P))
	  })

setMethod("expand", signature(x = "sparseLU"),
	  function(x, ...)
	  list(P = as(x@p + 1L, "pMatrix"),
	       L = x@L,
	       U = x@U,
	       Q = as(x@q + 1L, "pMatrix")))