Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 1098:6f51160c7ca7 feature/dissipation_operators
Merge refactor/sbpoperators/inflation
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 10 May 2022 21:15:55 +0200 |
parents | 95464a1af340 2278730f9cee |
children | 6567e38b05ca 102ebdaf7c11 |
comparison
equal
deleted
inserted
replaced
1097:95464a1af340 | 1098:6f51160c7ca7 |
---|---|
267 LazyOuterProduct(t1::IdentityTensor, t2::LazyTensor) = InflatedTensor(t1, t2) | 267 LazyOuterProduct(t1::IdentityTensor, t2::LazyTensor) = InflatedTensor(t1, t2) |
268 | 268 |
269 LazyOuterProduct(tms::Vararg{LazyTensor}) = foldl(LazyOuterProduct, tms) | 269 LazyOuterProduct(tms::Vararg{LazyTensor}) = foldl(LazyOuterProduct, tms) |
270 | 270 |
271 | 271 |
272 # REVIEW: Address TODO below | 272 |
273 """ | 273 """ |
274 inflate(tm, sz, dir) | 274 inflate(tm::LazyTensor, sz, dir) |
275 | 275 |
276 Inflate `tm` with identity tensors in all directions `d` for `d != dir`. | 276 Inflate `tm` such that it gets the size `sz` in all directions except `dir`. |
277 | 277 Here `sz[dir]` is ignored and replaced with the range and domains size of |
278 # TODO: Describe when it is useful | 278 `tm`. |
279 | |
280 An example of when this operation is useful is when extending a one | |
281 dimensional difference operator `D` to a 2D grid of a ceratin size. In that | |
282 case we could have | |
283 | |
284 ```julia | |
285 Dx = inflate(D, (10,10), 1) | |
286 Dy = inflate(D, (10,10), 2) | |
287 ``` | |
279 """ | 288 """ |
280 function inflate(tm::LazyTensor, sz, dir) | 289 function inflate(tm::LazyTensor, sz, dir) |
281 Is = IdentityTensor{eltype(tm)}.(sz) | 290 Is = IdentityTensor{eltype(tm)}.(sz) |
282 parts = Base.setindex(Is, tm, dir) | 291 parts = Base.setindex(Is, tm, dir) |
283 return foldl(⊗, parts) | 292 return foldl(⊗, parts) |