Learn R Programming

changepoints (version 1.1.0)

lowertri2mat: Transform a vector containing lower diagonal entries into a symmetric matrix of dimension p.

Description

Transform a vector containing lower diagonal entries into a symmetric matrix of dimension p.

Usage

lowertri2mat(lowertri_vec, p, diag = FALSE)

Value

A numeric p x p symmetric matrix.

Arguments

lowertri_vec

A numeric vector containing lower diagonal entries.

p

A integer scalar of dimensionality.

diag

A logic scalar indicating if the diagonal entries are contained in lowertri_vec.

Author

Haotian Xu

Examples

Run this code
A = matrix(1:16, 4, 4)
B = lowertri2mat(A[lower.tri(A)], 4, diag = FALSE)
C = lowertri2mat(A[lower.tri(A, diag = TRUE)], 4, diag = TRUE)

Run the code above in your browser using DataLab