* Get element from matrix at 1-based indices
( M: Expression, i: number, j: number, ce: ComputeEngine )
| 1889 | |
| 1890 | // Interpret a vector as a 1×n matrix (linear form), as `Kernel` does. |
| 1891 | const rowCount = shape.length === 1 ? 1 : shape[0]; |
| 1892 | const columnCount = shape.length === 1 ? shape[0] : shape[1]; |
| 1893 | |
| 1894 | // Exact path: for an exact integer/rational matrix, the rank is the |
| 1895 | // number of pivots in the exact RREF (no tolerance ambiguity). |
| 1896 | const rationalMatrix = tensorToRationalMatrix( |
| 1897 | op, |
| 1898 | rowCount, |
| 1899 | columnCount |
| 1900 | ); |
| 1901 | if (rationalMatrix) { |
| 1902 | const { pivotCols } = exactRationalRref(rationalMatrix); |
| 1903 | return ce.number(pivotCols.length); |
no test coverage detected