| 4501 |
maechler |
1 |
%%----- Docu for *all* sparse vector classes ----------
|
| 4354 |
maechler |
2 |
\name{sparseVector-class}
|
|
|
3 |
\docType{class}
|
|
|
4 |
\title{Sparse Vector Classes}
|
|
|
5 |
\alias{sparseVector-class}
|
|
|
6 |
% sub classes
|
|
|
7 |
\alias{dsparseVector-class}
|
|
|
8 |
\alias{isparseVector-class}
|
|
|
9 |
\alias{lsparseVector-class}
|
|
|
10 |
\alias{nsparseVector-class}
|
|
|
11 |
\alias{zsparseVector-class}
|
| 4501 |
maechler |
12 |
\alias{xsparseVector-class}% the class union
|
| 4354 |
maechler |
13 |
%% Group methods
|
|
|
14 |
% \alias{Math,sparseVector-method}
|
|
|
15 |
% %\alias{Math2,sparseVector,numeric-method}
|
| 4371 |
maechler |
16 |
\alias{Arith,sparseVector,sparseVector-method}
|
|
|
17 |
\alias{Arith,dsparseVector,dsparseVector-method}
|
|
|
18 |
\alias{-,dsparseVector,missing-method}
|
|
|
19 |
\alias{Logic,sparseVector,sparseVector-method}
|
|
|
20 |
\alias{Logic,lsparseVector,lsparseVector-method}
|
|
|
21 |
\alias{Ops,ANY,sparseVector-method}
|
|
|
22 |
\alias{Ops,sparseVector,ANY-method}
|
|
|
23 |
\alias{Ops,sparseVector,atomicVector-method}
|
|
|
24 |
\alias{Ops,atomicVector,sparseVector-method}
|
| 4354 |
maechler |
25 |
%
|
|
|
26 |
\alias{coerce,ANY,sparseVector-method}
|
|
|
27 |
\alias{coerce,TsparseMatrix,sparseVector-method}
|
|
|
28 |
\alias{coerce,diagonalMatrix,sparseVector-method}
|
|
|
29 |
\alias{coerce,sparseMatrix,sparseVector-method}
|
|
|
30 |
\alias{coerce,atomicVector,sparseVector-method}
|
|
|
31 |
\alias{coerce,triangularVector,sparseVector-method}
|
|
|
32 |
\alias{coerce,sparseVector,vector-method}
|
| 4501 |
maechler |
33 |
\alias{coerce,xsparseVector,dsparseVector-method}
|
|
|
34 |
\alias{coerce,xsparseVector,isparseVector-method}
|
|
|
35 |
\alias{coerce,xsparseVector,lsparseVector-method}
|
|
|
36 |
\alias{coerce,xsparseVector,zsparseVector-method}
|
|
|
37 |
\alias{coerce,sparseVector,nsparseVector-method}
|
|
|
38 |
%
|
| 4354 |
maechler |
39 |
\alias{as.numeric,sparseVector-method}
|
|
|
40 |
\alias{as.vector,sparseVector,missing-method}
|
|
|
41 |
\alias{as.vector,sparseVector,character-method}
|
|
|
42 |
\alias{length,sparseVector-method}
|
|
|
43 |
\alias{show,sparseVector-method}
|
|
|
44 |
%
|
|
|
45 |
\alias{[,sparseVector,index,ANY,ANY-method}
|
| 4371 |
maechler |
46 |
\alias{[<-,sparseVector,index,missing,replValue-method}
|
| 4354 |
maechler |
47 |
%
|
|
|
48 |
\description{Sparse Vector Classes: The virtual mother class
|
|
|
49 |
\code{"sparseVector"} has the five actual daughter classes
|
|
|
50 |
\code{"dsparseVector"}, \code{"isparseVector"},
|
|
|
51 |
\code{"lsparseVector"}, \code{"nsparseVector"}, and
|
|
|
52 |
\code{"zsparseVector"}, where we've mainly implemented methods for
|
|
|
53 |
the \code{d*}, \code{l*} and \code{n*} ones.
|
|
|
54 |
}
|
|
|
55 |
\section{Slots}{
|
|
|
56 |
\describe{
|
|
|
57 |
\item{\code{length}:}{class \code{"integer"} - the \code{\link{length}}
|
|
|
58 |
of the sparse vector.}
|
|
|
59 |
\item{\code{i}:}{class \code{"integer"} - the (1-based) indices of
|
|
|
60 |
the non-zero entries.}
|
|
|
61 |
\item{\code{x}:}{(for all but \code{"nsparseVector"}):
|
|
|
62 |
the non-zero entries. This is of class \code{"numeric"} for class
|
|
|
63 |
\code{"dsparseVector"}, \code{"logical"} for class
|
|
|
64 |
\code{"lsparseVector"}, etc.
|
|
|
65 |
|
|
|
66 |
Note that \code{"nsparseVector"}s have no \code{x} slot.
|
| 4501 |
maechler |
67 |
Further, mainly for ease of method definitions, we've defined the
|
|
|
68 |
class union (see \code{\link{setClassUnion}}) of all sparse vector
|
|
|
69 |
classes which \emph{have} an \code{x} slot, as class \code{"xsparseVector"}.
|
| 4354 |
maechler |
70 |
}
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
\section{Methods}{
|
|
|
74 |
\describe{
|
|
|
75 |
\item{length}{\code{signature(x = "sparseVector")}: simply extracts
|
|
|
76 |
the \code{length} slot.}
|
|
|
77 |
\item{show}{\code{signature(object = "sparseVector")}: The
|
|
|
78 |
\code{\link{show}} method for sparse vectors prints
|
|
|
79 |
\emph{\dQuote{structural}} zeroes as \code{"."} using the
|
|
|
80 |
non-exported \code{prSpVector} function which allows further
|
|
|
81 |
customization such as replacing \code{"."} by \code{" "} (blank).
|
|
|
82 |
|
|
|
83 |
Note that \code{\link{options}(max.print)} will influence how many
|
|
|
84 |
entries of large sparse vectors are printed at all.}
|
|
|
85 |
\item{as.vector}{\code{signature(x = "sparseVector", mode = "character")}
|
|
|
86 |
coerces sparse vectors to \dQuote{regular}, i.e., atomic vectors.
|
|
|
87 |
This is the same as \code{as(x, "vector")}.
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
%\author{Martin}
|
|
|
92 |
\examples{
|
|
|
93 |
showClass("sparseVector")
|
|
|
94 |
showClass("dsparseVector")
|
| 4501 |
maechler |
95 |
showClass("xsparseVector")# those with an 'x' slot
|
| 4354 |
maechler |
96 |
|
|
|
97 |
sx <- c(0,0,3, 3.2, 0,0,0,-3:1,0,0,2,0,0,5,0,0)
|
|
|
98 |
(ss <- as(sx, "sparseVector"))
|
|
|
99 |
|
| 4501 |
maechler |
100 |
ix <- as.integer(round(sx))
|
|
|
101 |
(is <- as(ix, "sparseVector"))
|
|
|
102 |
%% FIXME: I'd want isparseVector
|
|
|
103 |
%%
|
|
|
104 |
as(is, "isparseVector") %% ERROR ## FIXME
|
|
|
105 |
|
| 4354 |
maechler |
106 |
%% FIXME: Explain and show spV2M() or its successor
|
|
|
107 |
|
| 4501 |
maechler |
108 |
|
| 4354 |
maechler |
109 |
}
|
|
|
110 |
\keyword{classes}
|