25_block_matrices: Block Matrices

Description Usage Arguments Details Value See Also Examples

Description

Block matrices.
(NestMatrix and PartMatrix objects).

PartMatrix objects are generalized by SectMatrix objects, which allow overlapping sections.

Note that PartMatrix objects maybe removed or deprecated, in the future.

NOTE:
INTERNAL STRUCTURE OF OBJECTS IS SUBJECT TO CHANGE.
DO NOT USE SLOTS, DIRECTLY.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
VMap (n)

NestMatrix (nr, nc, ..., rnames, cnames, conform=TRUE, recursive=FALSE,
    default.value=ZERO)
as.NestMatrix (v, ..., rnames, cnames, conform=TRUE, recursive=FALSE)

PartMatrix (nr, nc, rsep, csep, ..., rnames, cnames, default.value=0)
SectMatrix (nr, nc, ..., vmap, rnames, cnames, default.value=0)

as.PartMatrix (v, rsep, csep, ..., rnames, cnames)
as.SectMatrix (v, ..., vmap, rnames, cnames)

n22 (...)

Arguments

n

Integer, the number of submatrices.

nr, nc

Integers, the number or rows and columns

rsep, csep

Optional integer vectors, the inter-row and inter-column indices.
Ignored, if v is a NestMatrix.

vmap

A VMap object.

rnames, cnames

Character vectors of nr row names and nc column names.
May be NULL.
Currently ignored, when a NestMatrix is constructed from a PartMatrix.

default.value

The default value of entries in the matrix.

v

A matrix or data.frame.
as.PartMatrix also allows a NestMatrix, if it has conformable submatrices and is non-recursive.

conform

Logical, if true, submatrices are required to have conformable dimensions.
Note that a NestMatrix may contain ZERO(s) regardless of the whether there's a conformable requirement or not.

recursive

Logical, if true, subelements can be nested matrices.
Otherwise, they must be ZERO or standard matrices.

...

Ignored.

Details

A NestMatrix is a subclass of an ObjectArray that contains ZERO or standard matrices.
If recursive is true, then it may also contain other NestMatrix objects.

Note that NestMatrix elements can have a scalar value assigned, but it will be converted to a 1x1 matrix.

A PartMatrix is a subclass of a SectMatrix.
(These are similar to NestMatrix).

A PartMatrix contains a matrix, along with a set of separator lines.
(These lines are included, when the object is printed/formatted).

A SectMatrix is similar, but allows arbitrary rectangular sections, defined by the vmap argument.

A VMap object is a subclass of ObjectArray, that requires one or more two by two integer matrices.
Each two by two matrices defines the indices of the section.
The top row is the start and end indices for the rows, and the bottom row is the start and end indices for the columns.

A VMap can have more than one dimensions.
And a VMap is created by the PartMatrix constructor, which is two dimensional.

The n22 function is a convenience function for constructing a one dimensional VMap.
It takes a integer vector, where the length is a multiple of four.

Each consecutive set of four defines the indices for one section.
Within each set, each value describes the row start, row end, column start and column end, in that order.

Value

VMap, NestMatrix, PartMatrix and SectMatrix are constructors for object of their classes.

n22 returns a VMAP object.

See Also

ObjectArray

Subsetting Operators

Standard Methods

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
x <- matrix (1:100, 10, 10)

###########
#NestMatrix
###########
msub <- NestMatrix (4, 4)

nm1 <- NestMatrix (4, 4)
nm2 <- NestMatrix (4, 4, recursive=TRUE, default.value=msub)
nm3 <- as.NestMatrix (PartMatrix (5, 5, 2:4, 2:4) )

nm1
nm2
nm3

###########
#PartMatrix
###########
pm <- as.PartMatrix (x, 5, c (2, 4, 6, 8) )
pm

pm [[1, 4]]

###########
#SectMatrix
###########
vmap <- n22 (
    1, 10, #1
    1, 10,
    3, 10, #2
    3, 10,
    5, 10, #3
    5, 10,
    7, 10, #4
    7, 10,
    9, 10, #5
    9, 10)
sm <- as.SectMatrix (x, vmap=vmap)
sm

getSect (sm, 4)

vectools documentation built on June 7, 2021, 9:08 a.m.