Mercurial > repos > public > sbplib_julia
changeset 1708:8787b2f9f5f8 feature/lazy_tensors/sparse_conversions
Add docstrings
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 04 Sep 2024 22:47:41 +0200 |
parents | 3e9c3986930d |
children | 40dffe6e2ecb |
files | ext/SbplibSparseArrayKitExt.jl ext/SbplibSparseArraysExt.jl |
diffstat | 2 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ext/SbplibSparseArrayKitExt.jl Mon Sep 02 15:35:54 2024 +0200 +++ b/ext/SbplibSparseArrayKitExt.jl Wed Sep 04 22:47:41 2024 +0200 @@ -6,6 +6,14 @@ using SparseArrayKit using Tokens +""" + SparseArray(t::LazyTensor) + +The sparse tensor representation of `t` with range dimensions to the left and +domain dimensions to the right. If `L` is a `LazyTensor` with range and +domain dimension 2 and `v` a 2-tensor, then `A = SparseArray(t)` is +constructed so that `∑ₖ∑ₗA[i,j,k,l]*v[k,l] == L*v`§ +""" function SparseArrayKit.SparseArray(t::LazyTensor) v = ArrayToken(:v, domain_size(t)...) return Tokens._to_tensor(t*v, range_size(t), domain_size(t))
--- a/ext/SbplibSparseArraysExt.jl Mon Sep 02 15:35:54 2024 +0200 +++ b/ext/SbplibSparseArraysExt.jl Wed Sep 04 22:47:41 2024 +0200 @@ -6,6 +6,14 @@ using SparseArrays using Tokens +""" + sparse(t::LazyTensor) + +The sparse matrix representation of `t`. + +If `L` is a `LazyTensor` and `v` a tensor, then `A = sparse(L)` is constructed +so that `A*reshape(v,:) == reshape(L*v,:)`. +""" function SparseArrays.sparse(t::LazyTensor) v = ArrayToken(:v, prod(domain_size(t)))