\HeaderA{lsparseMatrix-classes}{Sparse logical matrices}{lsparseMatrix.Rdash.classes}
\aliasA{"!,lsparseMatrix-method}{lsparseMatrix-classes}{"!,lsparseMatrix.Rdash.method}
\aliasA{-,lsparseMatrix,missing-method}{lsparseMatrix-classes}{.Rdash.,lsparseMatrix,missing.Rdash.method}
\aliasA{Arith,lgCMatrix,lgCMatrix-method}{lsparseMatrix-classes}{Arith,lgCMatrix,lgCMatrix.Rdash.method}
\aliasA{Arith,lgTMatrix,lgTMatrix-method}{lsparseMatrix-classes}{Arith,lgTMatrix,lgTMatrix.Rdash.method}
\aliasA{Arith,lsparseMatrix,Matrix-method}{lsparseMatrix-classes}{Arith,lsparseMatrix,Matrix.Rdash.method}
\aliasA{Arith,Matrix,lsparseMatrix-method}{lsparseMatrix-classes}{Arith,Matrix,lsparseMatrix.Rdash.method}
\aliasA{coerce,lgCMatrix,dgCMatrix-method}{lsparseMatrix-classes}{coerce,lgCMatrix,dgCMatrix.Rdash.method}
\aliasA{coerce,lgCMatrix,lgeMatrix-method}{lsparseMatrix-classes}{coerce,lgCMatrix,lgeMatrix.Rdash.method}
\aliasA{coerce,lgCMatrix,lgTMatrix-method}{lsparseMatrix-classes}{coerce,lgCMatrix,lgTMatrix.Rdash.method}
\aliasA{coerce,lgCMatrix,lsCMatrix-method}{lsparseMatrix-classes}{coerce,lgCMatrix,lsCMatrix.Rdash.method}
\aliasA{coerce,lgCMatrix,ltCMatrix-method}{lsparseMatrix-classes}{coerce,lgCMatrix,ltCMatrix.Rdash.method}
\aliasA{coerce,lgCMatrix,matrix-method}{lsparseMatrix-classes}{coerce,lgCMatrix,matrix.Rdash.method}
\aliasA{coerce,lgTMatrix,dgTMatrix-method}{lsparseMatrix-classes}{coerce,lgTMatrix,dgTMatrix.Rdash.method}
\aliasA{coerce,lgTMatrix,lgCMatrix-method}{lsparseMatrix-classes}{coerce,lgTMatrix,lgCMatrix.Rdash.method}
\aliasA{coerce,lgTMatrix,lgeMatrix-method}{lsparseMatrix-classes}{coerce,lgTMatrix,lgeMatrix.Rdash.method}
\aliasA{coerce,lgTMatrix,lsCMatrix-method}{lsparseMatrix-classes}{coerce,lgTMatrix,lsCMatrix.Rdash.method}
\aliasA{coerce,lgTMatrix,ltTMatrix-method}{lsparseMatrix-classes}{coerce,lgTMatrix,ltTMatrix.Rdash.method}
\aliasA{coerce,lgTMatrix,matrix-method}{lsparseMatrix-classes}{coerce,lgTMatrix,matrix.Rdash.method}
\aliasA{coerce,lsCMatrix,dgTMatrix-method}{lsparseMatrix-classes}{coerce,lsCMatrix,dgTMatrix.Rdash.method}
\aliasA{coerce,lsCMatrix,dsCMatrix-method}{lsparseMatrix-classes}{coerce,lsCMatrix,dsCMatrix.Rdash.method}
\aliasA{coerce,lsCMatrix,generalMatrix-method}{lsparseMatrix-classes}{coerce,lsCMatrix,generalMatrix.Rdash.method}
\aliasA{coerce,lsCMatrix,lgCMatrix-method}{lsparseMatrix-classes}{coerce,lsCMatrix,lgCMatrix.Rdash.method}
\aliasA{coerce,lsCMatrix,lgTMatrix-method}{lsparseMatrix-classes}{coerce,lsCMatrix,lgTMatrix.Rdash.method}
\aliasA{coerce,lsCMatrix,lsTMatrix-method}{lsparseMatrix-classes}{coerce,lsCMatrix,lsTMatrix.Rdash.method}
\aliasA{coerce,lsCMatrix,matrix-method}{lsparseMatrix-classes}{coerce,lsCMatrix,matrix.Rdash.method}
\aliasA{coerce,lsparseMatrix,dsparseMatrix-method}{lsparseMatrix-classes}{coerce,lsparseMatrix,dsparseMatrix.Rdash.method}
\aliasA{coerce,lsparseMatrix,matrix-method}{lsparseMatrix-classes}{coerce,lsparseMatrix,matrix.Rdash.method}
\aliasA{coerce,lsTMatrix,dsTMatrix-method}{lsparseMatrix-classes}{coerce,lsTMatrix,dsTMatrix.Rdash.method}
\aliasA{coerce,lsTMatrix,lgCMatrix-method}{lsparseMatrix-classes}{coerce,lsTMatrix,lgCMatrix.Rdash.method}
\aliasA{coerce,lsTMatrix,lgTMatrix-method}{lsparseMatrix-classes}{coerce,lsTMatrix,lgTMatrix.Rdash.method}
\aliasA{coerce,lsTMatrix,lsCMatrix-method}{lsparseMatrix-classes}{coerce,lsTMatrix,lsCMatrix.Rdash.method}
\aliasA{coerce,lsTMatrix,lsyMatrix-method}{lsparseMatrix-classes}{coerce,lsTMatrix,lsyMatrix.Rdash.method}
\aliasA{coerce,lsTMatrix,matrix-method}{lsparseMatrix-classes}{coerce,lsTMatrix,matrix.Rdash.method}
\aliasA{coerce,ltCMatrix,dMatrix-method}{lsparseMatrix-classes}{coerce,ltCMatrix,dMatrix.Rdash.method}
\aliasA{coerce,ltCMatrix,dtCMatrix-method}{lsparseMatrix-classes}{coerce,ltCMatrix,dtCMatrix.Rdash.method}
\aliasA{coerce,ltCMatrix,lgCMatrix-method}{lsparseMatrix-classes}{coerce,ltCMatrix,lgCMatrix.Rdash.method}
\aliasA{coerce,ltCMatrix,ltTMatrix-method}{lsparseMatrix-classes}{coerce,ltCMatrix,ltTMatrix.Rdash.method}
\aliasA{coerce,ltCMatrix,matrix-method}{lsparseMatrix-classes}{coerce,ltCMatrix,matrix.Rdash.method}
\aliasA{coerce,ltTMatrix,dtTMatrix-method}{lsparseMatrix-classes}{coerce,ltTMatrix,dtTMatrix.Rdash.method}
\aliasA{coerce,ltTMatrix,generalMatrix-method}{lsparseMatrix-classes}{coerce,ltTMatrix,generalMatrix.Rdash.method}
\aliasA{coerce,ltTMatrix,lgCMatrix-method}{lsparseMatrix-classes}{coerce,ltTMatrix,lgCMatrix.Rdash.method}
\aliasA{coerce,ltTMatrix,lgTMatrix-method}{lsparseMatrix-classes}{coerce,ltTMatrix,lgTMatrix.Rdash.method}
\aliasA{coerce,ltTMatrix,ltCMatrix-method}{lsparseMatrix-classes}{coerce,ltTMatrix,ltCMatrix.Rdash.method}
\aliasA{coerce,ltTMatrix,ltrMatrix-method}{lsparseMatrix-classes}{coerce,ltTMatrix,ltrMatrix.Rdash.method}
\aliasA{coerce,ltTMatrix,matrix-method}{lsparseMatrix-classes}{coerce,ltTMatrix,matrix.Rdash.method}
\aliasA{coerce,matrix,lgCMatrix-method}{lsparseMatrix-classes}{coerce,matrix,lgCMatrix.Rdash.method}
\aliasA{coerce,matrix,lgTMatrix-method}{lsparseMatrix-classes}{coerce,matrix,lgTMatrix.Rdash.method}
\aliasA{coerce,matrix,lsCMatrix-method}{lsparseMatrix-classes}{coerce,matrix,lsCMatrix.Rdash.method}
\aliasA{coerce,matrix,ltCMatrix-method}{lsparseMatrix-classes}{coerce,matrix,ltCMatrix.Rdash.method}
\aliasA{coerce,matrix,ltTMatrix-method}{lsparseMatrix-classes}{coerce,matrix,ltTMatrix.Rdash.method}
\aliasA{Compare,lsparseMatrix,lsparseMatrix-method}{lsparseMatrix-classes}{Compare,lsparseMatrix,lsparseMatrix.Rdash.method}
\aliasA{crossprod,ldenseMatrix,lsparseMatrix-method}{lsparseMatrix-classes}{crossprod,ldenseMatrix,lsparseMatrix.Rdash.method}
\aliasA{crossprod,lgCMatrix,missing-method}{lsparseMatrix-classes}{crossprod,lgCMatrix,missing.Rdash.method}
\aliasA{crossprod,lgTMatrix,missing-method}{lsparseMatrix-classes}{crossprod,lgTMatrix,missing.Rdash.method}
\aliasA{crossprod,lsparseMatrix,ldenseMatrix-method}{lsparseMatrix-classes}{crossprod,lsparseMatrix,ldenseMatrix.Rdash.method}
\aliasA{crossprod,lsparseMatrix,lsparseMatrix-method}{lsparseMatrix-classes}{crossprod,lsparseMatrix,lsparseMatrix.Rdash.method}
\aliasA{crossprod,lsparseMatrix,missing-method}{lsparseMatrix-classes}{crossprod,lsparseMatrix,missing.Rdash.method}
\aliasA{crossprod,lsparseMatrix-method}{lsparseMatrix-classes}{crossprod,lsparseMatrix.Rdash.method}
\aliasA{lgCMatrix-class}{lsparseMatrix-classes}{lgCMatrix.Rdash.class}
\aliasA{lgRMatrix-class}{lsparseMatrix-classes}{lgRMatrix.Rdash.class}
\aliasA{lgTMatrix-class}{lsparseMatrix-classes}{lgTMatrix.Rdash.class}
\aliasA{Logic,lgCMatrix,lgCMatrix-method}{lsparseMatrix-classes}{Logic,lgCMatrix,lgCMatrix.Rdash.method}
\aliasA{Logic,lgTMatrix,lgTMatrix-method}{lsparseMatrix-classes}{Logic,lgTMatrix,lgTMatrix.Rdash.method}
\aliasA{Logic,lsCMatrix,lsCMatrix-method}{lsparseMatrix-classes}{Logic,lsCMatrix,lsCMatrix.Rdash.method}
\aliasA{Logic,lsparseMatrix,lsparseMatrix-method}{lsparseMatrix-classes}{Logic,lsparseMatrix,lsparseMatrix.Rdash.method}
\aliasA{Logic,ltCMatrix,ltCMatrix-method}{lsparseMatrix-classes}{Logic,ltCMatrix,ltCMatrix.Rdash.method}
\aliasA{lsCMatrix-class}{lsparseMatrix-classes}{lsCMatrix.Rdash.class}
\aliasA{lsparseMatrix-class}{lsparseMatrix-classes}{lsparseMatrix.Rdash.class}
\aliasA{lsRMatrix-class}{lsparseMatrix-classes}{lsRMatrix.Rdash.class}
\aliasA{lsTMatrix-class}{lsparseMatrix-classes}{lsTMatrix.Rdash.class}
\aliasA{ltCMatrix-class}{lsparseMatrix-classes}{ltCMatrix.Rdash.class}
\aliasA{ltRMatrix-class}{lsparseMatrix-classes}{ltRMatrix.Rdash.class}
\aliasA{ltTMatrix-class}{lsparseMatrix-classes}{ltTMatrix.Rdash.class}
\aliasA{Ops,lsparseMatrix,lsparseMatrix-method}{lsparseMatrix-classes}{Ops,lsparseMatrix,lsparseMatrix.Rdash.method}
\aliasA{t,lgCMatrix-method}{lsparseMatrix-classes}{t,lgCMatrix.Rdash.method}
\aliasA{t,lgTMatrix-method}{lsparseMatrix-classes}{t,lgTMatrix.Rdash.method}
\aliasA{t,lsCMatrix-method}{lsparseMatrix-classes}{t,lsCMatrix.Rdash.method}
\aliasA{t,lsTMatrix-method}{lsparseMatrix-classes}{t,lsTMatrix.Rdash.method}
\aliasA{t,ltCMatrix-method}{lsparseMatrix-classes}{t,ltCMatrix.Rdash.method}
\aliasA{t,ltTMatrix-method}{lsparseMatrix-classes}{t,ltTMatrix.Rdash.method}
\aliasA{tcrossprod,lgCMatrix,missing-method}{lsparseMatrix-classes}{tcrossprod,lgCMatrix,missing.Rdash.method}
\aliasA{tcrossprod,lgTMatrix,missing-method}{lsparseMatrix-classes}{tcrossprod,lgTMatrix,missing.Rdash.method}
\aliasA{tcrossprod,lsparseMatrix,missing-method}{lsparseMatrix-classes}{tcrossprod,lsparseMatrix,missing.Rdash.method}
\aliasA{\%*\%,ldenseMatrix,lsparseMatrix-method}{lsparseMatrix-classes}{.Rpcent.*.Rpcent.,ldenseMatrix,lsparseMatrix.Rdash.method}
\aliasA{\%*\%,lgCMatrix,lgCMatrix-method}{lsparseMatrix-classes}{.Rpcent.*.Rpcent.,lgCMatrix,lgCMatrix.Rdash.method}
\aliasA{\%*\%,lsparseMatrix,ldenseMatrix-method}{lsparseMatrix-classes}{.Rpcent.*.Rpcent.,lsparseMatrix,ldenseMatrix.Rdash.method}
\aliasA{\%*\%,lsparseMatrix,lsparseMatrix-method}{lsparseMatrix-classes}{.Rpcent.*.Rpcent.,lsparseMatrix,lsparseMatrix.Rdash.method}
\keyword{classes}{lsparseMatrix-classes}
\keyword{algebra}{lsparseMatrix-classes}
\begin{Description}\relax
The \code{lsparseMatrix} class is a virtual class of sparse
matrices with \code{TRUE}/\code{FALSE} entries.  Only the positions of the
elements that are \code{TRUE} are stored.  These can be stored in the
``triplet'' form (classes \code{lgTMatrix}, \code{lsTMatrix}, and
\code{ltTMatrix} which really contain pairs, not triplets) or in
compressed column-oriented form (classes \code{lgCMatrix},
\code{lsCMatrix}, and \code{ltCMatrix}) or in compressed row-oriented
form (classes \code{lgRMatrix}, \code{lsRMatrix}, and
\code{ltRMatrix}).  The second letter in the name of these non-virtual
classes indicates \code{g}eneral, \code{s}ymmetric, or \code{t}riangular.
\end{Description}
\begin{Section}{Objects from the Class}
Objects can be created by calls of the form \code{new("lgCMatrix",
    ...)} and so on.  More frequently objects are created by coercion of
a numeric sparse matrix to the logical form for use in
the symbolic analysis phase
of an algorithm involving sparse matrices.  Such algorithms often
involve two phases: a symbolic phase wherein the positions of the
non-zeros in the result are determined and a numeric phase wherein the
actual results are calculated.  During the symbolic phase only the
positions of the non-zero elements in any operands are of interest,
hence any numeric sparse matrices can be treated as logical sparse
matrices.
\end{Section}
\begin{Section}{Slots}
\describe{
\item[\code{x}:] Object of class \code{"logical"}, i.e., either
\code{TRUE}, \code{\LinkA{NA}{NA}}, or \code{FALSE}.
\item[\code{uplo}:] Object of class \code{"character"}. Must be
either "U", for upper triangular, and "L", for lower
triangular. Present in the triangular and symmetric classes but not
in the general class.
\item[\code{diag}:] Object of class \code{"character"}. Must be
either \code{"U"}, for unit triangular (diagonal is all ones), or
\code{"N"} for non-unit.  The implicit diagonal elements are not
explicitly stored when \code{diag} is \code{"U"}.  Present in the
triangular classes only.
\item[\code{p}:] Object of class \code{"integer"} of pointers, one
for each column (row), to the initial (zero-based) index of elements in
the column.  Present in compressed column-oriented and compressed
row-oriented forms only.
\item[\code{i}:] Object of class \code{"integer"} of length nnzero
(number of non-zero elements).  These are the row numbers for
each TRUE element in the matrix.  All other elements are FALSE.
Present in triplet and compressed column-oriented forms only.
\item[\code{j}:] Object of class \code{"integer"} of length nnzero
(number of non-zero elements).  These are the column numbers for
each TRUE element in the matrix.  All other elements are FALSE.
Present in triplet and compressed column-oriented forms only.
\item[\code{Dim}:] Object of class \code{"integer"} - the dimensions
of the matrix.
}
\end{Section}
\begin{Section}{Methods}
\describe{
\item[coerce] \code{signature(from = "dgCMatrix", to = "lgCMatrix")}
\item[t] \code{signature(x = "lgCMatrix")}: returns the transpose
of \code{x}
}
\end{Section}
\begin{SeeAlso}\relax
the class \code{\LinkA{dgCMatrix}{dgCMatrix.Rdash.class}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
(m <- Matrix(c(0,0,2:0), 3,5, dimnames=list(LETTERS[1:3],NULL)))
(lm <- (m > 1)) # lgC
!lm     # no longer sparse
stopifnot(is(lm,"lsparseMatrix"),
          identical(!lm, m <= 1))

data(KNex)
str(mmG.1 <- (KNex $ mm) > 0.1)# "lgC..."
table(mmG.1@x)# however with many ``non-structural zeros''
## from logical to nz_pattern -- okay when there are no NA's :
nmG.1 <- as(mmG.1, "nMatrix") # <<< has "TRUE" also where mmG.1 had FALSE
## from logical to "double"
dmG.1 <- as(mmG.1, "dMatrix") # has '0' and back:
lmG.1 <- as(dmG.1, "lMatrix") # has no extra FALSE, i.e. drop0() included
stopifnot(identical(nmG.1, as((KNex $ mm) != 0,"nMatrix")),
          validObject(lmG.1), all(lmG.1@x),
          # same "logical" but lmG.1 has no 'FALSE' in x slot:
          all(lmG.1 == mmG.1))

class(xnx <- crossprod(nmG.1))# "nsC.."
class(xlx <- crossprod(mmG.1))# "dsC.." : numeric
is0 <- (xlx == 0)
mean(as.vector(is0))# 99.3% zeros: quite sparse, but
table(xlx@x == 0)# more than half of the entries are (non-structural!) 0
stopifnot(isSymmetric(xlx), isSymmetric(xnx),
          ## compare xnx and xlx : have the *same* non-structural 0s :
          sapply(slotNames(xnx),
                 function(n) identical(slot(xnx, n), slot(xlx, n))))
\end{ExampleCode}
\end{Examples}

