LinkedMatrix: Create an Empty, Prespecified LinkedMatrix Object

Description Usage Arguments Value See Also Examples

View source: R/LinkedMatrix.R

Description

This function creates an empty LinkedMatrix object of a certain size, a certain number of nodes, and certain types of nodes.

Usage

1
LinkedMatrix(nrow, ncol, nNodes, linkedBy, nodeInitializer, ...)

Arguments

nrow

The number of rows of the whole matrix.

ncol

The number of columns of the whole matrix.

nNodes

The number of nodes.

linkedBy

Whether the matrix is linked by columns or rows.

nodeInitializer

The name of a function or a function (nodeIndex, nrow, ncol, ...) where nodeIndex is the index of the node, nrow is a partition of the total number of rows, ncol is a partition of the total number of columns, and ... are additional parameters passed into the function. The function is expected to return a matrix-like object of dimensions nrow and ncol. Pre-defined node initializers include matrixNodeInitializer to initialize matrices and ffNodeInitializer to initialize ff objects.

...

Additional arguments passed into the nodeInitializer function.

Value

A ColumnLinkedMatrix object if linkedBy is columns or a RowLinkedMatrix object if linkedBy is rows.

See Also

ColumnLinkedMatrix and RowLinkedMatrix to create ColumnLinkedMatrix and RowLinkedMatrix objects from a list of matrix-like objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Create an empty 15x10 RowLinkedMatrix with 3 matrix nodes
m1 <- LinkedMatrix(nrow = 15, ncol = 10, nNodes = 3, linkedBy = "rows",
                   nodeInitializer = "matrixNodeInitializer")
dim(m1)
nNodes(m1)
all(sapply(m1, inherits, "matrix"))

# Create an empty 15x10 RowLinkedMatrix with 3 ff nodes
m2 <- LinkedMatrix(nrow = 15, ncol = 10, nNodes = 3, linkedBy = "rows",
                   nodeInitializer = "ffNodeInitializer", vmode = "byte")
dim(m2)
nNodes(m2)
all(sapply(m2, inherits, "ff_matrix"))

# Create an empty 15x10 RowLinkedMatrix with 3 big.matrix nodes
m3 <- LinkedMatrix(nrow = 15, ncol = 10, nNodes = 3, linkedBy = "rows",
                   nodeInitializer = function(nodeIndex, nrow, ncol, ...) {
                       bigmemory::big.matrix(nrow = nrow, ncol = ncol)
                   })
dim(m3)
nNodes(m3)
all(sapply(m3, inherits, "big.matrix"))

QuantGen/LinkedMatrix documentation built on May 28, 2020, 10:51 p.m.