Mercurial > repos > public > sbplib_julia
comparison ext/SbplibSparseArraysExt.jl @ 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 |
comparison
equal
deleted
inserted
replaced
1699:3e9c3986930d | 1708:8787b2f9f5f8 |
---|---|
4 using Sbplib.LazyTensors | 4 using Sbplib.LazyTensors |
5 | 5 |
6 using SparseArrays | 6 using SparseArrays |
7 using Tokens | 7 using Tokens |
8 | 8 |
9 """ | |
10 sparse(t::LazyTensor) | |
11 | |
12 The sparse matrix representation of `t`. | |
13 | |
14 If `L` is a `LazyTensor` and `v` a tensor, then `A = sparse(L)` is constructed | |
15 so that `A*reshape(v,:) == reshape(L*v,:)`. | |
16 """ | |
9 function SparseArrays.sparse(t::LazyTensor) | 17 function SparseArrays.sparse(t::LazyTensor) |
10 v = ArrayToken(:v, prod(domain_size(t))) | 18 v = ArrayToken(:v, prod(domain_size(t))) |
11 | 19 |
12 v̄ = reshape(v,domain_size(t)...) | 20 v̄ = reshape(v,domain_size(t)...) |
13 tv = reshape(t*v̄, :) | 21 tv = reshape(t*v̄, :) |