companion_matrix: Create a companion matrix from a vector

View source: R/mixAR.R

companion_matrixR Documentation

Create a companion matrix from a vector

Description

Create a companion matrix from a vector.

Usage

companion_matrix(v, ncol = length(v), nrow = ncol)

Arguments

v

the first row of the matrix, a numeric vector or a matrix with one row.

ncol

number of columns, a number.

nrow

number of rows, a number.

Details

With the default settings, a square m x m matrix is returned, where m is the length of v. If ncol>m, the vector is amended with 0's. It is an error for ncol to be smaller than m.

Argument nrow may be used to get a rectangular matrix, although the term "companion" is normally used only for square matrices.

Value

a matrix

Examples

companion_matrix(4:1)
companion_matrix(4:1, ncol=6)
companion_matrix(4:1, ncol=6, nrow=3)

GeoBosh/mixAR documentation built on May 9, 2022, 7:36 a.m.