SCM

SCM Repository

[matrix] Annotation of /pkg/Matrix/man/boolean-matprod.Rd
ViewVC logotype

Annotation of /pkg/Matrix/man/boolean-matprod.Rd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3093 - (view) (download) (as text)

1 : mmaechler 3069 \name{\%&\%-methods}
2 :     \title{Boolean Arithmetic Matrix Products: \code{\%&\%} and Methods}
3 :     \docType{methods}
4 :     \alias{\%&\%}
5 :     \alias{\%&\%-methods}
6 :     \alias{\%&\%,ANY,ANY-method}
7 :     \alias{\%&\%,ANY,matrix-method}
8 :     \alias{\%&\%,ANY,Matrix-method}
9 :     \alias{\%&\%,matrix,ANY-method}
10 :     \alias{\%&\%,Matrix,ANY-method}
11 :     \alias{\%&\%,matrix,matrix-method}
12 :     \alias{\%&\%,Matrix,Matrix-method}
13 :     \alias{\%&\%,mMatrix,mMatrix-method}
14 :     \alias{\%&\%,mMatrix,nMatrix-method}
15 :     \alias{\%&\%,nMatrix,mMatrix-method}
16 :     \alias{\%&\%,nMatrix,nMatrix-method}
17 :     \alias{\%&\%,nMatrix,nsparseMatrix-method}
18 :     \alias{\%&\%,nsparseMatrix,nMatrix-method}
19 :     \alias{\%&\%,nsparseMatrix,nsparseMatrix-method}
20 :     \alias{\%&\%,nCsparseMatrix,nCsparseMatrix-method}
21 :     \alias{\%&\%,nCsparseMatrix,nsparseMatrix-method}
22 :     \alias{\%&\%,nsparseMatrix,nCsparseMatrix-method}
23 :     \alias{\%&\%,diagonalMatrix,geMatrix-method}
24 :     \alias{\%&\%,geMatrix,diagonalMatrix-method}
25 :     \alias{\%&\%,CsparseMatrix,diagonalMatrix-method}
26 :     \alias{\%&\%,diagonalMatrix,CsparseMatrix-method}
27 :     \alias{\%&\%,diagonalMatrix,diagonalMatrix-method}
28 :     \alias{\%&\%,diagonalMatrix,sparseMatrix-method}
29 :     \alias{\%&\%,sparseMatrix,diagonalMatrix-method}
30 : mmaechler 3092 \alias{\%&\%,mMatrix,sparseVector-method}
31 :     \alias{\%&\%,numLike,sparseVector-method}
32 :     \alias{\%&\%,sparseVector,mMatrix-method}
33 :     \alias{\%&\%,sparseVector,numLike-method}
34 :     \alias{\%&\%,sparseVector,sparseVector-method}
35 : mmaechler 3069
36 :     \description{
37 : mmaechler 3092 For boolean or \dQuote{patter\bold{n}} matrices, i.e., \R objects of
38 : mmaechler 3069 class \code{\linkS4class{nMatrix}}, it is natural to allow matrix
39 :     products using boolean instead of numerical arithmetic.
40 :    
41 : mmaechler 3092 In package \pkg{Matrix}, we use the binary operator \code{\%&\%} (aka
42 :     \dQuote{infix}) function) for this and provide methods for all our
43 : mmaechler 3069 matrices and the traditional \R matrices (see \code{\link{matrix}}).
44 :     }
45 :     \section{Methods}{
46 :     We provide methods for both the \dQuote{traditional} (\R base) matrices
47 : mmaechler 3092 and numeric vectors and conceptually all matrices and
48 :     \code{\linkS4class{sparseVector}}s in package \pkg{Matrix}.
49 : mmaechler 3069 \describe{
50 : mmaechler 3092 \item{\code{signature(x = "ANY", y = "ANY")}}{ }
51 :     \item{\code{signature(x = "ANY", y = "Matrix")}}{ }
52 :     \item{\code{signature(x = "Matrix", y = "ANY")}}{ }
53 :     \item{\code{signature(x = "mMatrix", y = "mMatrix")}}{ }
54 :     \item{\code{signature(x = "nMatrix", y = "nMatrix")}}{ }
55 :     \item{\code{signature(x = "nMatrix", y = "nsparseMatrix")}}{ }
56 :     \item{\code{signature(x = "nsparseMatrix", y = "nMatrix")}}{ }
57 :     \item{\code{signature(x = "nsparseMatrix", y = "nsparseMatrix")}}{ }
58 :     \item{\code{signature(x = "sparseVector", y = "mMatrix")}}{ }
59 :     \item{\code{signature(x = "mMatrix", y = "sparseVector")}}{ }
60 :     \item{\code{signature(x = "sparseVector", y = "sparseVector")}}{ }
61 : mmaechler 3069 }% {describe}
62 :     }% {Methods}
63 : mmaechler 3092 \note{
64 :     The current implementation ends up coercing both \code{x} and \code{y}
65 : mmaechler 3093 to (virtual) class \code{\linkS4class{nsparseMatrix}} which may be
66 :     quite inefficient. A future implementation may well return a matrix
67 :     with \bold{different} class, but the \dQuote{same} content, i.e., the
68 :     same matrix entries \eqn{m_ij}{m[i,j]}.
69 : mmaechler 3092 }
70 : mmaechler 3069 \value{
71 :     a pattern matrix, i.e., inheriting from \code{"\linkS4class{nMatrix}"},
72 :     or an \code{"\linkS4class{ldiMatrix}"} in case of a diagonal matrix.
73 :     }
74 :     \examples{
75 :     set.seed(7)
76 :     L <- Matrix(rnorm(20) > 1, 4,5)
77 :     (N <- as(L, "nMatrix"))
78 :     D <- Matrix(round(rnorm(30)), 5,6) # -> values in -1:1 (for this seed)
79 :     L \%&\% D
80 :     stopifnot(identical(L \%&\% D, N \%&\% D),
81 : mmaechler 3072 all(L \%&\% D == as((L \%*\% abs(D)) > 0, "sparseMatrix")))
82 : mmaechler 3092
83 :     ## cross products , possibly with boolArith = TRUE :
84 : mmaechler 3072 crossprod(N) # -> sparse patter'n' (TRUE/FALSE : boolean arithmetic)
85 :     crossprod(N +0) # -> numeric Matrix (with same "pattern")
86 : mmaechler 3079 stopifnot(all(crossprod(N) == t(N) \%&\% N),
87 :     identical(crossprod(N), crossprod(N +0, boolArith=TRUE)),
88 :     identical(crossprod(L), crossprod(N , boolArith=FALSE)))
89 :     crossprod(D, boolArith = TRUE) # pattern: "nsCMatrix"
90 :     crossprod(L, boolArith = TRUE) # ditto
91 : mmaechler 3072 crossprod(L, boolArith = FALSE) # numeric: "dsCMatrix"
92 : mmaechler 3069 }
93 :     \keyword{methods}

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge