https://github.com/cran/Matrix
Raw File
Tip revision: 5e7c7ad79b730d8e11c6875dadd6733d46a69004 authored by Doug and Martin on 21 October 2010, 00:00:00 UTC
version 0.999375-45
Tip revision: 5e7c7ad
lu.R
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")))
back to top