Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 493:df566372bb4f feature/avoid_nested_inflated_tensormappings
Implement constructors to avoid creating nested InflatedTensorMappings
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 05 Nov 2020 13:18:24 +0100 |
parents | 6a6b7eaf9edf |
children | 5a600ec40ccc |
comparison
equal
deleted
inserted
replaced
490:7e698030c170 | 493:df566372bb4f |
---|---|
219 InflatedTensorMapping(tm,after) | 219 InflatedTensorMapping(tm,after) |
220 | 220 |
221 The outer product of `before`, `tm` and `after`, where `before` and `after` are `IdentityMapping`s. | 221 The outer product of `before`, `tm` and `after`, where `before` and `after` are `IdentityMapping`s. |
222 | 222 |
223 If one of `before` or `after` is left out, a 0-dimensional `IdentityMapping` is used as the default value. | 223 If one of `before` or `after` is left out, a 0-dimensional `IdentityMapping` is used as the default value. |
224 | |
225 If `tm` already is an `InflatedTensorMapping`, `before` and `after` will be extended instead of | |
226 creating a nested `InflatedTensorMapping`. | |
224 """ | 227 """ |
225 InflatedTensorMapping(::IdentityMapping, ::TensorMapping, ::IdentityMapping) | 228 InflatedTensorMapping(::IdentityMapping, ::TensorMapping, ::IdentityMapping) |
229 | |
230 function InflatedTensorMapping(before, itm::InflatedTensorMapping, after) | |
231 return InflatedTensorMapping( | |
232 IdentityMapping(before.size..., itm.before.size...), | |
233 itm.tm, | |
234 IdentityMapping(itm.after.size..., after.size...), | |
235 ) | |
236 end | |
237 | |
226 InflatedTensorMapping(before::IdentityMapping, tm::TensorMapping{T}) where T = InflatedTensorMapping(before,tm,IdentityMapping{T}()) | 238 InflatedTensorMapping(before::IdentityMapping, tm::TensorMapping{T}) where T = InflatedTensorMapping(before,tm,IdentityMapping{T}()) |
227 InflatedTensorMapping(tm::TensorMapping{T}, after::IdentityMapping) where T = InflatedTensorMapping(IdentityMapping{T}(),tm,after) | 239 InflatedTensorMapping(tm::TensorMapping{T}, after::IdentityMapping) where T = InflatedTensorMapping(IdentityMapping{T}(),tm,after) |
228 # Resolve ambiguity between the two previous methods | 240 # Resolve ambiguity between the two previous methods |
229 InflatedTensorMapping(I1::IdentityMapping{T}, I2::IdentityMapping{T}) where T = InflatedTensorMapping(I1,I2,IdentityMapping{T}()) | 241 InflatedTensorMapping(I1::IdentityMapping{T}, I2::IdentityMapping{T}) where T = InflatedTensorMapping(I1,I2,IdentityMapping{T}()) |
230 | 242 |