DiagMat: Extract Diagonal from a Matrix

DiagMatR Documentation

Extract Diagonal from a Matrix

Description

Extracts the k-th diagonal of a square matrix as a column vector.

Usage

DiagMat(x, k = 0L, id = NULL)

Arguments

x

A CVXR expression (square matrix).

k

Integer diagonal offset. k = 0 (default) is the main diagonal, k > 0 is above, k < 0 is below.

id

Optional integer ID.

Value

A DiagMat expression of shape c(n - abs(k), 1).

See Also

DiagVec


CVXR documentation built on March 6, 2026, 9:10 a.m.