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

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.

— — —

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")
#> Virtual Class "nMatrix" [package "Matrix"]
#> 
#> Slots:
#>                         
#> Name:       Dim Dimnames
#> Class:  integer     list
#> 
#> Extends: 
#> Class "Matrix", directly
#> Class "replValueSp", by class "Matrix", distance 2
#> 
#> Known Subclasses: 
#> Class "ndenseMatrix", directly
#> Class "nsparseMatrix", directly
#> Class "ndiMatrix", directly
#> Class "ngeMatrix", by class "ndenseMatrix", distance 2
#> Class "ntrMatrix", by class "ndenseMatrix", distance 2
#> Class "nsyMatrix", by class "ndenseMatrix", distance 2
#> Class "ntpMatrix", by class "ndenseMatrix", distance 2
#> Class "nspMatrix", by class "ndenseMatrix", distance 2
#> Class "ngCMatrix", by class "nsparseMatrix", distance 2
#> Class "ntCMatrix", by class "nsparseMatrix", distance 2
#> Class "nsCMatrix", by class "nsparseMatrix", distance 2
#> Class "ngRMatrix", by class "nsparseMatrix", distance 2
#> Class "ntRMatrix", by class "nsparseMatrix", distance 2
#> Class "nsRMatrix", by class "nsparseMatrix", distance 2
#> Class "ngTMatrix", by class "nsparseMatrix", distance 2
#> Class "ntTMatrix", by class "nsparseMatrix", distance 2
#> Class "nsTMatrix", by class "nsparseMatrix", 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 "ntCMatrix"
#>           
#> [1,] . | |
#> [2,] . . |
#> [3,] . . .