half.matrix: Interconvert Between a Symmetric Matrix and a Triangular...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Given a symmetric matrix, half.matrix converts the corresponding lower (upper) triangular matrix to a vector in row- (column-) major order. The vector is named using the convention row.column (for the lower interpretation) and is classed as halfmatrix. The function as.matrix.halfmatrix converts a halfmatrix-like vector to a symmetric matrix. The halfmatrix method for generic offdiag selects just the off-diagonal elements from the (named) vector of the corresponding class.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'matrix'
half(x,...)
## S3 method for class 'halfmatrix'
as.matrix(x,...)
## S3 method for class 'halfmatrix'
as.halfmatrix(x,...)
## Default S3 method:
as.halfmatrix(x,...)
## S3 method for class 'halfmatrix'
offdiag(x,...)
## S3 method for class 'halfmatrix'
print(x,...)

Arguments

x

symmetric matrix (half) or halfmatrix equivalent (as.matrix)

...

extra arguments, ignored

Details

It is an error if x is a matrix but not symmetric. If x is a vector of appropriate length it can be converted to a symmetric matrix by specifying the method explicitly, even if x is not classed as halfmatrix: as.matrix.halfmatrix(x). x can also be converted to halfmatrix explicitly, in which case as.matrix(x)) suffices.

Value

vector with as many elements as a triangular matrix corresponding to x (except as.matrix returns matrix)

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

1
2
3
4
5
6

metrumrg documentation built on May 2, 2019, 5:55 p.m.