ClikaRT::ops::diag
function
diag()
Rank-1 <-> rank-2 diagonal converter.
A vector of length L becomes an (L + |diagonal|) x (L + |diagonal|) matrix carrying it on the chosen diagonal (zeros elsewhere); a matrix input reads the chosen diagonal back out as a vector. diagonal: 0 = main, +k above, -k below. Copies.
Throws
ClikaRT::Error: (INVALID_ARGUMENT) when the input is not rank-1 or rank-2 (code_name()carries the reason).
Returns: a new matrix (rank-1 input) or vector (rank-2 input).
Declared in ClikaRT/compute/ops.h, line 3124