The nMatrix class is the virtual “mother” class of all
non-zero pattern (or simply pattern)
matrices in the Matrix package.
Slots
Common to all matrix object in the package:
Dim:
Object of class "integer" - the dimensions
of the matrix - must be an integer vector with exactly two
non-negative values.
Dimnames:
list of length two; each component
containing NULL or a character vector length
equal the corresponding Dim element.
Methods
There is a bunch of coercion methods (for as(..)), e.g.,
coerce
signature(from = "matrix", to = "nMatrix"):
Note that these coercions (must) coerce NAs to
non-zero, hence conceptually TRUE.
This is particularly important when
sparseMatrix objects are coerced to
"nMatrix" and hence to nsparseMatrix.
coerce
signature(from = "dMatrix", to = "nMatrix"), and
coerce
signature(from = "lMatrix", to = "nMatrix"):
For dense matrices with NAs, these
coercions are valid since Matrix version 1.2.0 (still with
a warning or a message if
"Matrix.warn", or "Matrix.verbose"options are set.)
coerce
signature(from = "nMatrix", to = "matrix"): ...
coerce
signature(from = "nMatrix", to = "dMatrix"): ...
coerce
signature(from = "nMatrix", to = "lMatrix"): ...
— — —
Additional methods contain group methods, such as
Ops
signature(e1 = "nMatrix", e2 = "...."), ...
Arith
signature(e1 = "nMatrix", e2 = "...."), ...
Compare
signature(e1 = "nMatrix", e2 = "...."), ...
Logic
signature(e1 = "nMatrix", e2 = "...."), ...
Summary
signature(x = "nMatrix", "...."), ...
See Also
The classes lMatrix,
nsparseMatrix, and the mother class,
Matrix.
Examples
getClass("nMatrix")
L3 <- Matrix(upper.tri(diag(3)))
L3 # an "ltCMatrix"
as(L3, "nMatrix") # -> ntC*
## similar, not using Matrix()
as(upper.tri(diag(3)), "nMatrix")# currently "ngTMatrix"
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Matrix)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Matrix/nMatrix-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: nMatrix-class
> ### Title: Class "nMatrix" of Non-zero Pattern Matrices
> ### Aliases: nMatrix-class show,nMatrix-method coerce,matrix,nMatrix-method
> ### coerce,nMatrix,matrix-method coerce,nMatrix,dMatrix-method
> ### coerce,dMatrix,nMatrix-method coerce,nMatrix,lMatrix-method
> ### coerce,lMatrix,nMatrix-method Arith,logical,nMatrix-method
> ### Arith,nMatrix,logical-method Arith,nMatrix,numeric-method
> ### Arith,numeric,nMatrix-method Compare,logical,nMatrix-method
> ### Compare,nMatrix,logical-method Compare,nMatrix,nMatrix-method
> ### Compare,nMatrix,numeric-method Compare,numeric,nMatrix-method
> ### Logic,Matrix,nMatrix-method Logic,nMatrix,Matrix-method
> ### Logic,nMatrix,nMatrix-method Logic,nMatrix,logical-method
> ### Logic,nMatrix,numeric-method Logic,logical,nMatrix-method
> ### Logic,numeric,nMatrix-method Ops,lMatrix,nMatrix-method
> ### Ops,nMatrix,lMatrix-method Ops,nMatrix,numeric-method
> ### Ops,numeric,nMatrix-method Summary,nMatrix-method
> ### Keywords: classes algebra
>
> ### ** Examples
>
> getClass("nMatrix")
Virtual Class "nMatrix" [package "Matrix"]
Slots:
Name: Dim Dimnames
Class: integer list
Extends:
Class "Matrix", directly
Class "mMatrix", by class "Matrix", distance 2
Known Subclasses:
Class "ndenseMatrix", directly
Class "nsparseMatrix", directly
Class "ngeMatrix", by class "ndenseMatrix", distance 2
Class "ntrMatrix", by class "ndenseMatrix", distance 2
Class "ntpMatrix", by class "ndenseMatrix", distance 2
Class "nsyMatrix", by class "ndenseMatrix", distance 2
Class "nspMatrix", by class "ndenseMatrix", distance 2
>
> L3 <- Matrix(upper.tri(diag(3)))
> L3 # an "ltCMatrix"
3 x 3 sparse Matrix of class "ltCMatrix"
[1,] . | |
[2,] . . |
[3,] . . .
> as(L3, "nMatrix") # -> ntC*
3 x 3 sparse Matrix of class "ntCMatrix"
[1,] . | |
[2,] . . |
[3,] . . .
>
> ## similar, not using Matrix()
> as(upper.tri(diag(3)), "nMatrix")# currently "ngTMatrix"
3 x 3 sparse Matrix of class "ngTMatrix"
[1,] . | |
[2,] . . |
[3,] . . .
>
>
>
>
>
> dev.off()
null device
1
>