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
Commit afe7966
Browse filesBrowse the repository at this point in the historyBrowse files
A matrix compiles to a GenTensor over its elements' type, and the arithmetic on it to GenericTensor's operations (#1425)
* A matrix compiles to a GenTensor over its elements' type, and the arithmetic on it to GenericTensor's operations
#526: "just run GenericTensor through our functions". Under the LINQ compiler a Matrix node is
a GenTensor<T, TWrapper> over the common type of its compiled elements, filled element by
element, and a sum, difference, product, quotient or whole power with a matrix in it is the
tensor operation of that name -- PiecewiseAdd, PiecewiseSubtract, MatrixMultiply, the
piecewise operations by a scalar converted to the element type, MatrixPower -- so that
"A * B" compiled over two tensors is the matrix product and "2 A + B - 1" scales, adds and
shifts. GenericTensor takes its element arithmetic from a struct and ships none for the
numeric types, so DoubleOperations, SingleOperations, ComplexOperations, Int32Operations,
Int64Operations and BigIntegerOperations are here, in AngouriMath.Core.Compilation.IntoLinq,
and GenTensor<double, DoubleOperations> is the type to compile to and to pass a matrix in as.
The methods the compiled tree calls are closed over each element type at compile time and
named through expression trees, the way the protocol keeps its own tables: nothing generic is
constructed at run time, which the trimming and NativeAOT analyzers refuse (#363). A matrix
as a number, a number as a matrix, and a function of a matrix are UncompilableNodeException
with a message that says so, where sin(A) was a KeyNotFoundException out of a type table.
An expression of matrices with a scalar value still simplifies to the scalar first, as #425
made it.
Closes#526.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
* The compiled matrix arithmetic is plain loops over the wrapper, not GenericTensor's expression-compiled ones, so the NativeAOT gate passes
The first push failed TrimmingAndAot on both platforms: GenTensor.PiecewiseAdd, MatrixMultiply
and the rest build and compile an expression tree for their loops, which ILC reports as IL3050
the moment they are reachable -- and Kit.For roots them for six element types. Add, Subtract,
Multiply, the scalar operations and Power are now loops over the wrapper's Add and Multiply, and
Power is by repeated squaring, refusing a negative exponent. GenTensor stays the container.
The smoke test compiles a matrix expression now, so the gate covers this path from here on.
Published natively and run locally: 45 checks, 0 failed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments