dtpMatrix-class {Matrix} | R Documentation |
Packed Triangular Dense Matrices - "dtpMatrix"
Description
The "dtpMatrix"
class is the class of triangular,
dense, numeric matrices in packed storage. The "dtrMatrix"
class is the same except in nonpacked storage.
Objects from the Class
Objects can be created by calls of the form new("dtpMatrix",
...)
or by coercion from other classes of matrices.
Slots
uplo
:Object of class
"character"
. Must be either "U", for upper triangular, and "L", for lower triangular.diag
:Object of class
"character"
. Must be either"U"
, for unit triangular (diagonal is all ones), or"N"
; seetriangularMatrix
.x
:Object of class
"numeric"
. The numeric values that constitute the matrix, stored in column-major order. For a packed square matrix of dimensiond \times d
,length(x)
is of lengthd(d+1)/2
(also whendiag == "U"
!).Dim
,Dimnames
:The dimension (a length-2
"integer"
) and corresponding names (orNULL
), inherited from theMatrix
, see there.
Extends
Class "ddenseMatrix"
, directly.
Class "triangularMatrix"
, directly.
Class "dMatrix"
and more by class "ddenseMatrix"
etc, see
the examples.
Methods
- %*%
signature(x = "dtpMatrix", y = "dgeMatrix")
: Matrix multiplication; ditto for several other signature combinations, seeshowMethods("%*%", class = "dtpMatrix")
.- determinant
signature(x = "dtpMatrix", logarithm = "logical")
: thedeterminant(x)
trivially isprod(diag(x))
, but computed on log scale to prevent over- and underflow.- diag
signature(x = "dtpMatrix")
: ...- norm
signature(x = "dtpMatrix", type = "character")
: ...- rcond
signature(x = "dtpMatrix", norm = "character")
: ...- solve
signature(a = "dtpMatrix", b = "...")
: efficiently using internal backsolve or forwardsolve, seesolve-methods
.- t
signature(x = "dtpMatrix")
:t(x)
remains a"dtpMatrix"
, lower triangular ifx
is upper triangular, and vice versa.
See Also
Class dtrMatrix
Examples
showClass("dtrMatrix")
example("dtrMatrix-class", echo=FALSE)
(p1 <- pack(T2))
str(p1)
(pp <- pack(T))
ip1 <- solve(p1)
stopifnot(length(p1@x) == 3, length(pp@x) == 3,
p1 @ uplo == T2 @ uplo, pp @ uplo == T @ uplo,
identical(t(pp), p1), identical(t(p1), pp),
all((l.d <- p1 - T2) == 0), is(l.d, "dtpMatrix"),
all((u.d <- pp - T ) == 0), is(u.d, "dtpMatrix"),
l.d@uplo == T2@uplo, u.d@uplo == T@uplo,
identical(t(ip1), solve(pp)), is(ip1, "dtpMatrix"),
all.equal(as(solve(p1,p1), "diagonalMatrix"), Diagonal(2)))