Algosim documentation: ReplaceRow

ReplaceRow

Returns a matrix with one of its rows replaced by a given vector.

Syntax

Description

If A is an m×n matrix, i a valid row index in A, and v a vector of dimension n, then ReplaceRow(A, i, v) returns the matrix obtained from A by replacing its ith row 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⎠
ReplaceRow(A, 3, ❨1, 2, 3, 4, 5❩)
⎛5  1  2  3  4⎞
⎜4  0  2  1  7⎟
⎜1  2  3  4  5⎟
⎜4  5  2  3  9⎟
⎝4  0  1  2  5⎠

See also