vechinv {lazy.mat}R Documentation

Recover the Symmetric Matrix from its lower or upper half elements stored in a vector created by vech function.

Description

Recover the Symmetric Matrix from its lower or upper half elements stored in a vector created by vech function.

Usage

vechinv(v, nodiag = 0, byrow = 1, lowerh = 1, diagval = 0, array = 0)

Arguments

v

Input column vector or matrix which contain the lower-half elements of symmetric matrix or matrices.

nodiag

= 1 if the input vector does not have the diagonal elements.

byrow

= 0 if the input vector is in col-major order

lowerh

= 0 if the input vector consists of the upper-half

diagval

Diagonal elements in a vector when nodiag=1

array

= 1 to make the result an array

Details

Let M be 4 x 4.
The vech function stores the data as follows:
When byrow=1 and lowerh=1,

vech(M)=c( m11, m21, m22, m31, m32, m33, ..., mn1, mn2, ..., mnn )

When byrow=1 and lowerh=0,

vech(M)=c( m11, m12, m13, ..., m1n, m22, m23, m24, ..., m2n, ..., mnn )

When byrow=0 and lowerh=1, the upper half of the matrix will be vectorized in row major order as:

vech(M)=c( m11, m21, m31, ..., mn1, m22, m32, ..., mn2, m33, ...., mnn )

When byrow=0 and lowerh=0, the upper half of the matrix will be vectorized in row major order as:

vech(M)=c( m11, m12, m22, m13, m23, m33, m14, ..., m44, m1n, m2n, ..., mnn )

Value

A matrix when v is a vector, or an array when v is a matrix.

Examples

vechinv( vech(demomat(3,3,2)) )

ndim=4
M=demomat(ndim,ndim,root="m")
cat( "nodiag=0:  byrow=1, lower=1  and  byrow=0, lower=1\n" )
Print( vechinv(vech(M,0,1,1),0,1,1), vechinv(vech(M,0,0,1),0,0,1) )
cat( "nodiag=0:  byrow=1, lower=0  and  byrow=0, lower=0\n" )
Print( vechinv(vech(M,0,1,0),0,1,0),vechinv(vech(M,0,0,0),0,0,0) )

cat( "nodiag=1:  byrow=1, lower=1  and  byrow=0, lower=1\n" )
Print( vechinv(vech(M,1,1,1),1,1,1), vechinv(vech(M,1,0,1),1,0,1) )
cat( "nodiag=1:  byrow=1, lower=0  and  byrow=0, lower=0\n" )
Print( vechinv(vech(M,1,1,0),1,1,0),vechinv(vech(M,1,0,0),1,0,0) )



[Package lazy.mat version 0.1.4 Index]