comparison ext/DiffinitiveSparseArrayKitExt.jl @ 1858:4a9be96f2569 feature/documenter_logo

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 12 Jan 2025 21:18:44 +0100
parents 471a948cd2b2
children
comparison
equal deleted inserted replaced
1857:ffde7dad9da5 1858:4a9be96f2569
1 module DiffinitiveSparseArrayKitExt
2
3 using Diffinitive
4 using Diffinitive.LazyTensors
5
6 using SparseArrayKit
7 using Tokens
8
9 """
10 SparseArray(t::LazyTensor)
11
12 The sparse tensor representation of `t` with range dimensions to the left and
13 domain dimensions to the right. If `L` is a `LazyTensor` with range and
14 domain dimension 2 and `v` a 2-tensor, then `A = SparseArray(t)` is
15 constructed so that `∑ₖ∑ₗA[i,j,k,l]*v[k,l] == L*v`.
16 """
17 function SparseArrayKit.SparseArray(t::LazyTensor)
18 v = ArrayToken(:v, domain_size(t)...)
19 return Tokens._to_tensor(t*v, range_size(t), domain_size(t))
20 end
21
22 end