Algosim documentation: PivotPos

PivotPos

Returns the column index of the first non-zero entry on a matrix row.

Syntax

Description

If A is a matrix and n a valid row index of A, then PivotPos(A, n, ε) returns the column index of the first non-zero entry on the nth row of A, comparing values against zero using epsilon ε. If the nth row consists only of zeros, 0 is returned.

Examples

A ≔ ❨❨5, 1, 2, 3, 4❩, ❨0, 0, 2, 1, 2❩, ❨0, 0, 0, 5, 1❩, ❨0, 0, 0, 0, 0❩❩
⎛5  1  2  3  4⎞
⎜0  0  2  1  2⎟
⎜0  0  0  5  1⎟
⎝0  0  0  0  0⎠
compute(PivotPos(A, n), n, 1, size(A).rows)
1
3
4
0

See also