Algosim documentation: ReplaceAntidiagonal

ReplaceAntidiagonal

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

Syntax

Description

If A is an n×n matrix and v a vector of dimension n, then ReplaceAntidiagonal(A, v) returns the matrix obtained from A by replacing its antidiagonal with the components of v (in order, from the top-right to the bottom-left corner of A).

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⎠
ReplaceAntidiagonal(A, ❨0, 0, 0, 0, i❩)
⎛5  1  2  3  0⎞
⎜4  0  2  0  7⎟
⎜6  3  0  4  7⎟
⎜4  0  2  3  9⎟
⎝i  0  1  2  5⎠

See also