vech2tri: Vector to Triangular Matrix

Description Usage Arguments Author(s) Examples

View source: R/mat.R

Description

Fills a matrix with a vector that represents the triangular elements. The function can produce a strictly triangular matrix, that is, the diagonal elements are set to zero or a triangular matrix with diagonal values supplied by the argument x. Note that the matrix is filled by column.

Usage

1
vech2tri(x, lower = TRUE, diag = FALSE)

Arguments

x

A vector.

lower

Logical. If TRUE, creates a lower triangular matrix. If FALSE, creates an upper triangular matrix.

diag

Logical. If TRUE, values of the diagonal as supplied by x. If FALSE, diagonals are set to zero and x fills only the off-diagonal elements of the matrix producing a strictly triangular matrix.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Stricly lower triangular matrix
vech2tri(1:10, lower = TRUE, diag = FALSE)
# Lower triangular matrix with diagonal and off-diagonal values
# supplied by the argument x
vech2tri(1:10, lower = TRUE, diag = TRUE)
# Stricly upper triangular matrix
vech2tri(1:10, lower = FALSE, diag = FALSE)
# Upper triangular matrix with diagonal and off-diagonal values
# supplied by the argument x
vech2tri(1:10, lower = FALSE, diag = TRUE)

jeksterslabds/jeksterslabRds documentation built on July 16, 2020, 3:41 p.m.