EVOLUTION-MANAGER
Edit File: dtCMatrix-class.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Triangular, (compressed) sparse column matrices</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for dtCMatrix-class {Matrix}"><tr><td>dtCMatrix-class {Matrix}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Triangular, (compressed) sparse column matrices</h2> <h3>Description</h3> <p>The <code>"dtCMatrix"</code> class is a class of triangular, sparse matrices in the compressed, column-oriented format. In this implementation the non-zero elements in the columns are sorted into increasing row order. </p> <p>The <code>"dtTMatrix"</code> class is a class of triangular, sparse matrices in triplet format. </p> <h3>Objects from the Class</h3> <p>Objects can be created by calls of the form <code>new("dtCMatrix", ...)</code> or calls of the form <code>new("dtTMatrix", ...)</code>, but more typically automatically via <code><a href="Matrix.html">Matrix</a>()</code> or coercion such as <code>as(x, "triangularMatrix")</code>, or <code>as(x, "dtCMatrix")</code>. </p> <h3>Slots</h3> <dl> <dt><code>uplo</code>:</dt><dd><p>Object of class <code>"character"</code>. Must be either "U", for upper triangular, and "L", for lower triangular.</p> </dd> <dt><code>diag</code>:</dt><dd><p>Object of class <code>"character"</code>. Must be either <code>"U"</code>, for unit triangular (diagonal is all ones), or <code>"N"</code>; see <code><a href="triangularMatrix-class.html">triangularMatrix</a></code>.</p> </dd> <dt><code>p</code>:</dt><dd><p>(only present in <code>"dtCMatrix"</code>:) an <code><a href="../../base/html/integer.html">integer</a></code> vector for providing pointers, one for each column, see the detailed description in <code><a href="CsparseMatrix-class.html">CsparseMatrix</a></code>.</p> </dd> <dt><code>i</code>:</dt><dd><p>Object of class <code>"integer"</code> of length nnzero (number of non-zero elements). These are the row numbers for each non-zero element in the matrix.</p> </dd> <dt><code>j</code>:</dt><dd><p>Object of class <code>"integer"</code> of length nnzero (number of non-zero elements). These are the column numbers for each non-zero element in the matrix. (Only present in the <code>dtTMatrix</code> class.)</p> </dd> <dt><code>x</code>:</dt><dd><p>Object of class <code>"numeric"</code> - the non-zero elements of the matrix.</p> </dd> <dt><code>Dim</code>,<code>Dimnames</code>:</dt><dd><p>The dimension (a length-2 <code>"integer"</code>) and corresponding names (or <code>NULL</code>), inherited from the <code><a href="Matrix-class.html">Matrix</a></code>, see there.</p> </dd> </dl> <h3>Extends</h3> <p>Class <code>"dgCMatrix"</code>, directly. Class <code>"triangularMatrix"</code>, directly. Class <code>"dMatrix"</code>, <code>"sparseMatrix"</code>, and more by class <code>"dgCMatrix"</code> etc, see the examples. </p> <h3>Methods</h3> <dl> <dt>coerce</dt><dd><p><code>signature(from = "dtCMatrix", to = "dgTMatrix")</code></p> </dd> <dt>coerce</dt><dd><p><code>signature(from = "dtCMatrix", to = "dgeMatrix")</code></p> </dd> <dt>coerce</dt><dd><p><code>signature(from = "dtTMatrix", to = "dgeMatrix")</code></p> </dd> <dt>coerce</dt><dd><p><code>signature(from = "dtTMatrix", to = "dtrMatrix")</code></p> </dd> <dt>coerce</dt><dd><p><code>signature(from = "dtTMatrix", to = "matrix")</code></p> </dd> <dt>solve</dt><dd><p><code>signature(a = "dtCMatrix", b = "....")</code>: sparse triangular solve (aka “backsolve” or “forwardsolve”), see <code><a href="solve-methods.html">solve-methods</a></code>.</p> </dd> <dt>t</dt><dd><p><code>signature(x = "dtCMatrix")</code>: returns the transpose of <code>x</code></p> </dd> <dt>t</dt><dd><p><code>signature(x = "dtTMatrix")</code>: returns the transpose of <code>x</code></p> </dd> </dl> <h3>See Also</h3> <p>Classes <code><a href="dgCMatrix-class.html">dgCMatrix</a></code>, <code><a href="dgTMatrix-class.html">dgTMatrix</a></code>, <code><a href="dgeMatrix-class.html">dgeMatrix</a></code>, and <code><a href="dtrMatrix-class.html">dtrMatrix</a></code>. </p> <h3>Examples</h3> <pre> showClass("dtCMatrix") showClass("dtTMatrix") t1 <- new("dtTMatrix", x= c(3,7), i= 0:1, j=3:2, Dim= as.integer(c(4,4))) t1 ## from 0-diagonal to unit-diagonal {low-level step}: tu <- t1 ; tu@diag <- "U" tu (cu <- as(tu, "dtCMatrix")) str(cu)# only two entries in @i and @x stopifnot(cu@i == 1:0, all(2 * symmpart(cu) == Diagonal(4) + forceSymmetric(cu))) t1[1,2:3] <- -1:-2 diag(t1) <- 10*c(1:2,3:2) t1 # still triangular (it1 <- solve(t1)) t1. <- solve(it1) all(abs(t1 - t1.) < 10 * .Machine$double.eps) ## 2nd example U5 <- new("dtCMatrix", i= c(1L, 0:3), p=c(0L,0L,0:2, 5L), Dim = c(5L, 5L), x = rep(1, 5), diag = "U") U5 (iu <- solve(U5)) # contains one '0' validObject(iu2 <- solve(U5, Diagonal(5)))# failed in earlier versions I5 <- iu %*% U5 # should equal the identity matrix i5 <- iu2 %*% U5 m53 <- matrix(1:15, 5,3, dimnames=list(NULL,letters[1:3])) asDiag <- function(M) as(drop0(M), "diagonalMatrix") stopifnot( all.equal(Diagonal(5), asDiag(I5), tolerance=1e-14) , all.equal(Diagonal(5), asDiag(i5), tolerance=1e-14) , identical(list(NULL, dimnames(m53)[[2]]), dimnames(solve(U5, m53))) ) </pre> <hr /><div style="text-align: center;">[Package <em>Matrix</em> version 1.2-17 <a href="00Index.html">Index</a>]</div> </body></html>