You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
det, transpose, trace and an entry of a name for a matrix #2427
#2180 computes det, transpose and the rest from a matrix that is written out. So det(A) of a name is refused, and transpose(A) * B can't be written. trace(A) parses as the product trace * A, and A[k, l] doesn't parse. #2422 compiles matrix arguments, but nothing can take their determinant, their trace or an entry.
Proposal:
Nodes det(A), transpose(A), trace(A) and A[k, l]. Indices count from 1, as in a_ij, Mathematica, Maple and MATLAB. The C# indexer keeps counting from 0.
Each operation is carried out once A is a matrix, by substitution, simplification, evaluation and compilation over T[,].
A non-square matrix has no determinant or trace, and an index out of range names no entry. Both stay unevaluated.
Until #1237, nothing else knows that A is a matrix. So:
a product with a transpose in it must not be reordered: transpose(A) * A - A * transpose(A) is not 0;
a name next to a written matrix must not be multiplied into its entries: det(A * [[2, 0], [0, 3]]) is not 6 * A^2.
Follows #2147, which decided that a written matrix is computed when parsed and left names open, and #2422.
Indices count from 1 in an expression.A[1, 1] is the first entry, as in a_ij, Mathematica, Maple, Maxima, MATLAB and Julia. SymPy counts from 0 only because Python does.
The C# indexer still counts from 0.Matrix's matrix[k] and matrix[x, y] have done so since 2021, as C# does, so M[k, l] in an expression is matrix[k - 1, l - 1] in code. The syntax page says so.
Indexing an expression is new. On master, "[[1, 2], [3, 4]][2, 1]" and "A[1, 1]" both throw UnhandledParseException.
The branch is ready. A full check and a chain run before the PR opens, after #2422 merges.
Activity
Rafael-SOWNet commentedon Nov 13, 2026
Decided for 2.7.0:
A[1, 1]is the first entry, as ina_ij, Mathematica, Maple, Maxima, MATLAB and Julia. SymPy counts from 0 only because Python does.Matrix'smatrix[k]andmatrix[x, y]have done so since 2021, as C# does, soM[k, l]in an expression ismatrix[k - 1, l - 1]in code. The syntax page says so."[[1, 2], [3, 4]][2, 1]"and"A[1, 1]"both throwUnhandledParseException.The branch is ready. A full check and a chain run before the PR opens, after #2422 merges.
Make det, transpose, trace and an entry nodes that apply to a matrix …
Make det, transpose, trace and an entry nodes that apply to a matrix …