diag_of_vech: Diagonals of A from vech(A)

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

View source: R/linearAlgebra-diag_of_vech.R

Description

Diagonals of a matrix from its half-vectorization.

Usage

1
diag_of_vech(x, loc = FALSE)

Arguments

x

Vector. Half-vectorization of a k by k matrix.

loc

Logical. If loc = TRUE, return the location of the diagonal elements in the input vector. If loc = FALSE, return the values of the diagonal elements.

Details

Generates a vector of length k of diagonal elements or location in the input vector of an k \times k matrix.

Author(s)

Ivan Jacob Agaloos Pesigan

References

Wikipedia: Half-vectorization

See Also

Other Vectorization Functions: vec_mean(), vechnames(), vechsnames(), vechs(), vech(), vec()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
A <- matrix(
  data = c(
    1.0, 0.5, 0.4,
    0.5, 1.0, 0.6,
    0.4, 0.6, 1.0
  ),
  ncol = 3
)
vechA <- c(1.0, 0.5, 0.4, 1.0, 0.6, 1.0)

diag_of_vech(vechA, loc = FALSE)
diag_of_vech(vechA, loc = TRUE)

jeksterslab/linearAlgebra documentation built on Dec. 20, 2021, 10:10 p.m.