# SCM Repository

[matrix] Diff of /pkg/man/Matrix.Rd
 [matrix] / pkg / man / Matrix.Rd

# Diff of /pkg/man/Matrix.Rd

revision 1617, Fri Oct 6 15:42:12 2006 UTC revision 1618, Fri Oct 6 15:44:01 2006 UTC
# Line 59  Line 59
59  \examples{  \examples{
60  Matrix(0, 3, 2)             # 3 by 2 matrix of zeros -> sparse  Matrix(0, 3, 2)             # 3 by 2 matrix of zeros -> sparse
61  Matrix(0, 3, 2, sparse=FALSE)# forced 'dense'  Matrix(0, 3, 2, sparse=FALSE)# forced 'dense'
62  Matrix(1:6, 3, 2)           # a 3 by 2 matrix  Matrix(1:6, 3, 2)           # a 3 by 2 matrix (+ integer warning)
63  Matrix(1:6, nrow=3)  Matrix(1:6 + 1, nrow=3)
Matrix(1:6, ncol=2)
64
65  ## logical ones:  ## logical ones:
66  Matrix(diag(4) >  0)# -> "ldiMatrix" with diag = "U"  Matrix(diag(4) >  0)# -> "ldiMatrix" with diag = "U"
67  Matrix(diag(4) >= 0)# -> "lsyMatrix"  Matrix(diag(4) >  0, sparse=TRUE)# -> sparse...
68    Matrix(diag(4) >= 0)# -> "lsyMatrix" (of all 'TRUE')
69    ## triangular
70  l3 <- upper.tri(matrix(,3,3))  l3 <- upper.tri(matrix(,3,3))
71  Matrix(l3)  # -> "ltCMatrix"  Matrix(l3)  # -> "ltCMatrix"
72  Matrix(! l3)# -> "ltrMatrix"  Matrix(! l3)# -> "ltrMatrix"
73    as(l3, "CsparseMatrix")
74
75  Matrix(1:9, nrow=3,  Matrix(1:9, nrow=3,
76         dimnames = list(c("a", "b", "c"), c("A", "B", "C")))         dimnames = list(c("a", "b", "c"), c("A", "B", "C")))
# Line 78  Line 80
80  (A <- cbind(a=c(2,1), b=1:2))# symmetric *apart* from dimnames  (A <- cbind(a=c(2,1), b=1:2))# symmetric *apart* from dimnames
81  Matrix(A)                    # hence 'dgeMatrix'  Matrix(A)                    # hence 'dgeMatrix'
82  (As <- Matrix(A, dimnames = list(NULL,NULL)))# -> symmetric  (As <- Matrix(A, dimnames = list(NULL,NULL)))# -> symmetric
83  stopifnot(is(As, "symmetricMatrix"))  stopifnot(is(As, "symmetricMatrix"),
84              is(Matrix(0, 3,3), "sparseMatrix"),
85              is(Matrix(FALSE, 1,1), "sparseMatrix"))
86  }  }
87  \keyword{array}  \keyword{array}
88  \keyword{algebra}  \keyword{algebra}

Legend:
 Removed from v.1617 changed lines Added in v.1618