Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 1022:bbbc31953367 refactor/sbpoperators/inflation
Introduce an inflate function in lazy tensors and use it in volume_operator and boundary_operator
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 18 Mar 2022 16:57:00 +0100 |
parents | 043d13ef8898 |
children | 52f07c77299d |
comparison
equal
deleted
inserted
replaced
988:83046af6143a | 1022:bbbc31953367 |
---|---|
411 LazyOuterProduct(tms::Vararg{TensorMapping}) = foldl(LazyOuterProduct, tms) | 411 LazyOuterProduct(tms::Vararg{TensorMapping}) = foldl(LazyOuterProduct, tms) |
412 | 412 |
413 ⊗(a::TensorMapping, b::TensorMapping) = LazyOuterProduct(a,b) | 413 ⊗(a::TensorMapping, b::TensorMapping) = LazyOuterProduct(a,b) |
414 | 414 |
415 | 415 |
416 """ | |
417 inflate(tm, sz, dir) | |
418 | |
419 Inflate `tm` with identity tensors in all directions `d` for `d != dir`. | |
420 | |
421 # TODO: Describe when it is useful | |
422 """ | |
423 function inflate(tm::TensorMapping, sz, dir) | |
424 Is = IdentityMapping{eltype(tm)}.(sz) | |
425 parts = Base.setindex(Is, tm, dir) | |
426 return foldl(⊗, parts) | |
427 end | |
428 | |
416 function check_domain_size(tm::TensorMapping, sz) | 429 function check_domain_size(tm::TensorMapping, sz) |
417 if domain_size(tm) != sz | 430 if domain_size(tm) != sz |
418 throw(SizeMismatch(tm,sz)) | 431 throw(SizeMismatch(tm,sz)) |
419 end | 432 end |
420 end | 433 end |