Algosim documentation: ReplaceCol

ReplaceCol

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

Syntax

Description

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

See also