Mercurial > repos > public > sbplib_julia
comparison ext/DiffinitiveSparseArrayKitExt.jl @ 1726:471a948cd2b2 rename_module
Rename project from Sbplib to Diffinitive
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Sat, 07 Sep 2024 12:11:53 -0700 |
parents | ext/SbplibSparseArrayKitExt.jl@7379f492c4b3 |
children |
comparison
equal
deleted
inserted
replaced
1725:8317252e4535 | 1726:471a948cd2b2 |
---|---|
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 |