Matrix construction and access
Construct matrices from ordered rows or from identity, zero, and diagonal families. Shape and entry access preserve row-major ordering.
Constructors#
matrix#
Explicit context
matrix(rows: Iterable<Iterable<ExpressionLike>>): MatrixCalling forms
Raw WebAssembly: Explicit context: Context.matrix
matrix(rows: number, columns: number, entries: Expression[]): MatrixSymiFacade method: SymiFacade.matrix
matrix(rows: Iterable<Iterable<ExpressionLike>>): MatrixBuild a matrix from ordered rows. Direct Python construction and the facade
module function use the shared default context. The raw wasm-bindgen
compatibility layer retains (rows, columns, flat_entries); new JavaScript
code should use the nested facade form.
matrix_identity#
Not exposed by the WASM / JavaScript bindings. Available as Context.matrix_identity in Python, UniffiSession.matrixIdentity in Kotlin, UniffiSession.matrixIdentity in Swift, api::Session::matrix_identity in Rust.
The identity; size 0 raises.
matrix_zero#
Not exposed by the WASM / JavaScript bindings. Available as Context.matrix_zero in Python, UniffiSession.matrixZero in Kotlin, UniffiSession.matrixZero in Swift, api::Session::matrix_zero in Rust.
The zero matrix.
matrix_diagonal#
Not exposed by the WASM / JavaScript bindings. Available as Context.matrix_diagonal in Python, UniffiSession.matrixDiagonal in Kotlin, UniffiSession.matrixDiagonal in Swift, api::Session::matrix_diagonal in Rust.
Square matrix with the given main diagonal and zeros elsewhere; the empty list raises.
Shape and access#
rows#
Matrix property
readonly rows: numbercolumns#
Matrix property
readonly columns: numberentry#
Matrix method
entry(row: number, column: number): ExpressionCalling forms
Raw WebAssembly: Matrix method: Matrix.entry
entry(row: number, column: number): ExpressionElement access. Notes: Python uses indexing m[row, column] instead.
Example#
Build matrices from rows or from a structured constructor.
const x = symi.symbol("x");
const matrix = symi.matrix([[1, x], [x, 1]]);
console.log(matrix.rows(), matrix.columns());
console.log(matrix.entry(0, 1).toString());Additional API#
diagonalMatrix#
Raw WebAssembly: Default context
diagonalMatrix(subject: Matrix): AssumptionPropositionBuild a diagonal-matrix proposition in the default context.
Calling forms
Explicit context: Context.diagonalMatrix
diagonalMatrix(value: Matrix): AssumptionPropositionRaw WebAssembly: Explicit context: Context.diagonalMatrix
diagonalMatrix(subject: Matrix): AssumptionPropositionSymiFacade method: SymiFacade.diagonalMatrix
diagonalMatrix(value: Matrix): AssumptionPropositionidentityMatrix#
Raw WebAssembly: Default context
identityMatrix(subject: Matrix): AssumptionPropositionBuild an identity-matrix proposition in the default context.
Calling forms
Explicit context: Context.identityMatrix
identityMatrix(value: Matrix): AssumptionPropositionRaw WebAssembly: Explicit context: Context.identityMatrix
identityMatrix(subject: Matrix): AssumptionPropositionSymiFacade method: SymiFacade.identityMatrix
identityMatrix(value: Matrix): AssumptionPropositionmatrixDiagonal#
Raw WebAssembly: Default context
matrixDiagonal(entries: Expression[]): MatrixSquare matrix with the given main diagonal and zeros elsewhere; the empty list raises.
Calling forms
Raw WebAssembly: Explicit context: Context.matrixDiagonal
matrixDiagonal(entries: Expression[]): MatrixmatrixIdentity#
Raw WebAssembly: Default context
matrixIdentity(size: number): MatrixThe identity; size 0 raises.
Calling forms
Raw WebAssembly: Explicit context: Context.matrixIdentity
matrixIdentity(size: number): MatrixmatrixZero#
Raw WebAssembly: Default context
matrixZero(rows: number, columns: number): MatrixThe zero matrix.
Calling forms
Raw WebAssembly: Explicit context: Context.matrixZero
matrixZero(rows: number, columns: number): MatrixzeroMatrix#
Raw WebAssembly: Default context
zeroMatrix(subject: Matrix): AssumptionPropositionBuild a zero-matrix proposition in the default context.