File: MatrixFactorization.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 (34 lines) | stat: -rw-r--r-- 1,295 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#### The "mother" of all  Matrix factorizations

## use a "fits all" bail-out method -- eventually this should not happen anymore
setMethod("expand", "MatrixFactorization",
          function(x, ...) .bail.out.1(.Generic, class(x)))

setMethod("show", "MatrixFactorization",
	  function(object) { ## cheap one -- can have better for sub-classes
	      ## cl <- class(object)
	      ## cat(sprintf("'MatrixFactorization' of class \"%s\"\n", cl))
	      cat("'MatrixFactorization' of ")
	      str(object)
	  })
setMethod("show", "BunchKaufman",
	  function(object) {
	      cat("'Bunch-Kaufman' factorization of ")
	      str(object)
	  })
setMethod("show", "pBunchKaufman",
	  function(object) {
	      cat("packed 'Bunch-Kaufman' factorization of ")
	      str(object)
	  })

setMethod("dim", "MatrixFactorization", function(x) x@Dim)

## e.g., for (CHMfactor, <num>):
setMethod("solve", signature(a = "MatrixFactorization", b = "numeric"),
	  function(a, b, ...) callGeneric(a, Matrix(b)))
## catch others, otherwise base::solve is.
setMethod("solve", signature(a = "MatrixFactorization", b = "ANY"),
	  function(a, b, ...) .bail.out.2("solve", class(a), class(b)))
setMethod("solve", signature(a = "MatrixFactorization", b = "missing"),
	  function(a, b, ...) .bail.out.1("solve", class(a)))