Last data update: 2014.03.03

R: Packed Triangular Dense Matrices - "dtpMatrix"
dtpMatrix-classR 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"; see triangularMatrix.

x:

Object of class "numeric". The numeric values that constitute the matrix, stored in column-major order. For a packed square matrix of dimension d * d, length(x) is of length d(d+1)/2 (also when diag == "U"!).

Dim,Dimnames:

The dimension (a length-2 "integer") and corresponding names (or NULL), inherited from the Matrix, 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, see showMethods("%*%", class = "dtpMatrix").

coerce

signature(from = "dtpMatrix", to = "dtrMatrix")

coerce

signature(from = "dtpMatrix", to = "matrix")

determinant

signature(x = "dtpMatrix", logarithm = "logical"): the determinant(x) trivially is prod(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, see solve-methods.

t

signature(x = "dtpMatrix"): t(x) remains a "dtpMatrix", lower triangular if x is upper triangular, and vice versa.

See Also

Class dtrMatrix

Examples

showClass("dtrMatrix")

example("dtrMatrix-class", echo=FALSE)
(p1 <- as(T2, "dtpMatrix"))
str(p1)
(pp <- as(T, "dtpMatrix"))
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)))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Matrix)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Matrix/dtpMatrix-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: dtpMatrix-class
> ### Title: Packed Triangular Dense Matrices - "dtpMatrix"
> ### Aliases: dtpMatrix-class coerce,dtpMatrix,dtTMatrix-method
> ###   coerce,dtpMatrix,dtrMatrix-method coerce,dtpMatrix,ltpMatrix-method
> ###   coerce,dtpMatrix,matrix-method coerce,matrix,dtpMatrix-method
> ###   determinant,dtpMatrix,missing-method
> ###   determinant,dtpMatrix,logical-method diag,dtpMatrix-method
> ###   diag<-,dtpMatrix-method norm,dtpMatrix,character-method
> ###   norm,dtpMatrix,missing-method rcond,dtpMatrix,character-method
> ###   rcond,dtpMatrix,missing-method t,dtpMatrix-method
> ### Keywords: classes
> 
> ### ** Examples
> 
> showClass("dtrMatrix")
Class "dtrMatrix" [package "Matrix"]

Slots:
                                                        
Name:          x       Dim  Dimnames      uplo      diag
Class:   numeric   integer      list character character

Extends: 
Class "ddenseMatrix", directly
Class "triangularMatrix", directly
Class "dMatrix", by class "ddenseMatrix", distance 2
Class "denseMatrix", by class "ddenseMatrix", distance 2
Class "Matrix", by class "triangularMatrix", distance 2
Class "xMatrix", by class "dMatrix", distance 3
Class "mMatrix", by class "Matrix", distance 4

Known Subclasses: "Cholesky", "BunchKaufman"
> 
> example("dtrMatrix-class", echo=FALSE)
> (p1 <- as(T2, "dtpMatrix"))
2 x 2 Matrix of class "dtpMatrix"
     [,1] [,2]
[1,]    2    .
[2,]    3   -1
> str(p1)
Formal class 'dtpMatrix' [package "Matrix"] with 5 slots
  ..@ x       : num [1:3] 2 3 -1
  ..@ Dim     : int [1:2] 2 2
  ..@ Dimnames:List of 2
  .. ..$ : NULL
  .. ..$ : NULL
  ..@ uplo    : chr "L"
  ..@ diag    : chr "N"
> (pp <- as(T, "dtpMatrix"))
2 x 2 Matrix of class "dtpMatrix"
     [,1] [,2]
[1,]    2    3
[2,]    .   -1
> 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)))
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>