SCM

SCM Repository

[matrix] Annotation of /pkg/man/sparseVector-class.Rd
ViewVC logotype

Annotation of /pkg/man/sparseVector-class.Rd

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : maechler 1922 %%----- Docu for *all* sparse vector classes ----------
2 : maechler 1845 \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}
12 : maechler 1922 \alias{xsparseVector-class}% the class union
13 : maechler 1845 %% Group methods
14 :     % \alias{Math,sparseVector-method}
15 :     % %\alias{Math2,sparseVector,numeric-method}
16 : maechler 1852 \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}
25 : maechler 1845 %
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}
33 : maechler 1922 \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 :     %
39 : maechler 1845 \alias{as.numeric,sparseVector-method}
40 :     \alias{as.vector,sparseVector,missing-method}
41 :     \alias{as.vector,sparseVector,character-method}
42 : mmaechler 2207 \alias{dim<-,sparseVector-method}
43 : maechler 1845 \alias{length,sparseVector-method}
44 : mmaechler 2207 \alias{rep,sparseVector-method}
45 : maechler 1845 \alias{show,sparseVector-method}
46 :     %
47 :     \alias{[,sparseVector,index,ANY,ANY-method}
48 : maechler 1852 \alias{[<-,sparseVector,index,missing,replValue-method}
49 : maechler 1845 %
50 :     \description{Sparse Vector Classes: The virtual mother class
51 :     \code{"sparseVector"} has the five actual daughter classes
52 :     \code{"dsparseVector"}, \code{"isparseVector"},
53 :     \code{"lsparseVector"}, \code{"nsparseVector"}, and
54 :     \code{"zsparseVector"}, where we've mainly implemented methods for
55 :     the \code{d*}, \code{l*} and \code{n*} ones.
56 :     }
57 :     \section{Slots}{
58 :     \describe{
59 :     \item{\code{length}:}{class \code{"integer"} - the \code{\link{length}}
60 :     of the sparse vector.}
61 :     \item{\code{i}:}{class \code{"integer"} - the (1-based) indices of
62 :     the non-zero entries.}
63 :     \item{\code{x}:}{(for all but \code{"nsparseVector"}):
64 :     the non-zero entries. This is of class \code{"numeric"} for class
65 :     \code{"dsparseVector"}, \code{"logical"} for class
66 :     \code{"lsparseVector"}, etc.
67 :    
68 :     Note that \code{"nsparseVector"}s have no \code{x} slot.
69 : maechler 1922 Further, mainly for ease of method definitions, we've defined the
70 :     class union (see \code{\link{setClassUnion}}) of all sparse vector
71 :     classes which \emph{have} an \code{x} slot, as class \code{"xsparseVector"}.
72 : maechler 1845 }
73 :     }
74 :     }
75 :     \section{Methods}{
76 :     \describe{
77 :     \item{length}{\code{signature(x = "sparseVector")}: simply extracts
78 :     the \code{length} slot.}
79 :     \item{show}{\code{signature(object = "sparseVector")}: The
80 :     \code{\link{show}} method for sparse vectors prints
81 :     \emph{\dQuote{structural}} zeroes as \code{"."} using the
82 :     non-exported \code{prSpVector} function which allows further
83 :     customization such as replacing \code{"."} by \code{" "} (blank).
84 :    
85 :     Note that \code{\link{options}(max.print)} will influence how many
86 :     entries of large sparse vectors are printed at all.}
87 :     \item{as.vector}{\code{signature(x = "sparseVector", mode = "character")}
88 :     coerces sparse vectors to \dQuote{regular}, i.e., atomic vectors.
89 : mmaechler 2207 This is the same as \code{as(x, "vector")}.}
90 :     \item{dim<-}{\code{signature(x = "sparseVector", value = "integer")}
91 :     coerces a sparse vector to a sparse Matrix, i.e., an object
92 :     inheriting from \code{\linkS4class{sparseMatrix}}, of the
93 :     appropriate dimension.}
94 :     \item{rep}{\code{signature(x = "sparseVector")} repeat \code{x},
95 :     with the same argument list \code{(x, times, length.out, each,
96 :     ...)} as the default method for rep().}
97 : maechler 1845 }
98 :     }
99 :     %\author{Martin}
100 :     \examples{
101 : mmaechler 2207 getClass("sparseVector")
102 :     getClass("dsparseVector")
103 :     getClass("xsparseVector")# those with an 'x' slot
104 : maechler 1845
105 :     sx <- c(0,0,3, 3.2, 0,0,0,-3:1,0,0,2,0,0,5,0,0)
106 :     (ss <- as(sx, "sparseVector"))
107 :    
108 : maechler 1922 ix <- as.integer(round(sx))
109 :     (is <- as(ix, "sparseVector"))
110 : mmaechler 2207 ## an "isparseVector" (!)
111 : maechler 1922
112 : mmaechler 2207 ## rep() works too:
113 :     rep(is, length.out= 25)
114 : maechler 1845
115 : mmaechler 2207 ## Using `dim<-` as in base R :
116 :     r <- ss
117 :     dim(r) <- c(4,5) # becomes a sparse Matrix:
118 :     r
119 : maechler 1922
120 : maechler 1845 }
121 :     \keyword{classes}

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