Class "spam"
spam-class.Rd
The spam
class is a representation of sparse matrices.
Objects from the Class
Objects can be created by calls of the form new("spam", entries, colindices,
rowpointes, dimension)
.
The standard "old Yale sparse format" is used to store sparse matrices.
The matrix
x
is stored in row form. The first element of row i
is
x@rowpointers[i]
. The length of row i
is determined by
x@rowpointers[i+1]-x@rowpointers[i]
. The column indices of x
are stored in
the x@colindices
vector. The column index for element x@entries[k]
is
x@colindices[k]
.
Slots
entries
:Object of class
"numeric"
contains the nonzero values.colindices
:Object of class
"integer"
ordered indices of the nonzero values.rowpointers
:Object of class
"integer"
pointer to the beginning of each row in the arraysentries
andcolindices
.dimension
:Object of class
"integer"
specifying the dimension of the matrix.
Methods
- as.matrix
signature(x = "spam")
: transforming a sparse matrix into a regular matrix.- as.vector
signature(x = "spam")
: transforming a sparse matrix into a vector (dependings onstructurebased
) seeas.vector.spam
for details.- as.spam
signature(x = "spam")
: cleaning of a sparse matrix.- [<-
signature(x = "spam", i,j, value)
: assigning a sparse matrix. The negative vectors are not implemented yet.- [
signature(x = "spam", i, j)
: subsetting a sparse matrix. The negative vectors are not implemented yet.- %*%
signature(x, y)
: matrix multiplication, all combinations of sparse with full matrices or vectors are implemented.- c
signature(x = "spam")
: vectorizes the sparse matrix and takes account of the zeros. Hence the lenght of the result isprod(dim(x))
.- cbind
signature(x = "spam")
: binds sparse matrices, seecbind
for details.- chol
signature(x = "spam")
: seechol
for details.- diag
signature(x = "spam")
: seediag
for details.- dim<-
signature(x = "spam")
: rearranges the matrix to reflect a new dimension.- dim
signature(x = "spam")
: gives the dimension of the sparse matrix.- pad<-
signature(x = "spam")
: truncates or augments the matrix seedim
for details.- image
signature(x = "spam")
: seeimage
for details.- display
signature(x = "spam")
: seedisplay
for details.
% \item{initialize}{\code{signature(.Object = "spam")}: ... }
- length<-
signature(x = "spam")
: Is not implemented and causes an error.- length
signature(x = "spam")
: gives the number of non-zero elements.- lower.tri
signature(x = "spam")
: seelower.tri
for details.- Math
signature(x = "spam")
: seeMath
for details.- Math2
signature(x = "spam")
: seeMath2
for details.- norm
signature(x = "spam")
: calculates the norm of a matrix.- plot
signature(x = "spam", y)
: same functionality as the ordinaryplot
.signature(x = "spam")
: seeprint
for details.- rbind
signature(x = "spam")
: binds sparse matrices, seecbind
for details.
% \item{show}{\code{signature(object = "spam")}: ... }
- solve
signature(a = "spam")
: seesolve
for details.- summary
signature(object = "spam")
: small summary statement of the sparse matrix.- Summary
signature(x = "spam")
: All functions of theSummary
class (likemin
,max
,range
...) operate on the vectorx@entries
and return the result thereof. See Examples orSummary
for details.- t
signature(x = "spam")
: transpose of a sparse matrix.- upper.tri
signature(x = "spam")
: seelower.tri
for details.
Details
The compressed sparse row (CSR) format is often described with the
vectors a
, ia
, ja
. To be a bit more
comprehensive, we have chosen longer slot names.
Note
The slots colindices
and rowpointers
are
tested for proper integer assignments. This is not true for
entries
.
Author
Reinhard Furrer, some of the Fortran code is based on A. George, J. Liu, E. S. Ng, B.W Peyton and Y. Saad (alphabetical)
Examples
showMethods("as.spam")
#> Function: as.spam (package spam)
#> x="ANY"
#> x="dist"
#> x="integer"
#> (inherited from: x="numeric")
#> x="list"
#> x="matrix"
#> x="numeric"
#> x="spam"
#> x="spam.chol.NgPeyton"
#>
smat <- diag.spam(runif(15))
range(smat)
#> [1] 0.000000 0.785562
cos(smat)
#> [1] 0.9464291 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [8] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [15] 1.0000000 1.0000000 0.7069909 1.0000000 1.0000000 1.0000000 1.0000000
#> [22] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [29] 1.0000000 1.0000000 1.0000000 1.0000000 0.9231173 1.0000000 1.0000000
#> [36] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [43] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.8883847
#> [50] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [57] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [64] 1.0000000 0.9847193 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [71] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [78] 1.0000000 1.0000000 1.0000000 0.7696644 1.0000000 1.0000000 1.0000000
#> [85] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [92] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.9243212 1.0000000
#> [99] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [106] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [113] 0.8929796 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [120] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [127] 1.0000000 1.0000000 0.9543847 1.0000000 1.0000000 1.0000000 1.0000000
#> [134] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [141] 1.0000000 1.0000000 1.0000000 1.0000000 0.9953006 1.0000000 1.0000000
#> [148] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [155] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.9979787
#> [162] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [169] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [176] 1.0000000 0.8867794 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [183] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [190] 1.0000000 1.0000000 1.0000000 0.9471237 1.0000000 1.0000000 1.0000000
#> [197] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [204] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.9719185 1.0000000
#> [211] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [218] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [225] 0.9857374
#> Class 'spam' (32-bit)