Algosim documentation: ReplaceSuperdiagonal

ReplaceSuperdiagonal

Returns a matrix with its superdiagonal replaced by a given vector.

Syntax

Description

If A is an m×n matrix and v a vector of dimension m if m < n and n − 1 if m ≥ n, then ReplaceSuperdiagonal(A, v) returns the matrix obtained from A by replacing its superdiagonal with the components of v (in order).

Examples

A ≔ ❨❨5, 1, 2, 3, 4❩, ❨4, 0, 2, 1, 7❩, ❨6, 3, 0, 4, 7❩, ❨4, 5, 2, 3, 9❩, ❨4, 0, 1, 2, 5❩❩
⎛5  1  2  3  4⎞
⎜4  0  2  1  7⎟
⎜6  3  0  4  7⎟
⎜4  5  2  3  9⎟
⎝4  0  1  2  5⎠
ReplaceSuperdiagonal(A, ❨i, i, i, i❩)
⎛5  i  2  3  4⎞
⎜4  0  i  1  7⎟
⎜6  3  0  i  7⎟
⎜4  5  2  3  i⎟
⎝4  0  1  2  5⎠

See also