Learn R Programming

TFORGE (version 0.1.16)

vecd: Flatten a symmetric matrix into a vector preserving Frobenius norm.

Description

The vecd operator as used by schwartzman2008in;textualTFORGE flattens a symmetric matrix into a vector of unique elements such that the Frobenius norm of the matrix equals the Euclidean norm of the vector. This means that the off-diagonal elements are scaled by \(\sqrt{2}\). In the returned vector the diagonal elements are first then the (scaled) off-diagonal elements; this ordering is different to vech().

Usage

vecd(m)

Value

A vector.

Arguments

m

A symmetric matrix

Details

The vecd() function has a single line of code:

c(diag(m), sqrt(2) * m[lower.tri(m, diag = FALSE)])

The matrix m is not checked for symmetry.

References

Examples

Run this code
m <- inv_vech(1:6)
vecd(m)

Run the code above in your browser using DataLab