Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 470:0c3decc04649 feature/outer_product
Add some tests and fix some bugs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 25 Oct 2020 14:01:27 +0100 |
parents | 481e86e77c22 |
children | 3ad327378b2d |
comparison
equal
deleted
inserted
replaced
469:481e86e77c22 | 470:0c3decc04649 |
---|---|
315 (A⊗B⊗C)v = [(A⊗I_{|M|}⊗I_{|P|}) [(I_{|J|}⊗B⊗I_{|P|}) [(I_{|J|}⊗I_{|N|}⊗C)v]]] | 315 (A⊗B⊗C)v = [(A⊗I_{|M|}⊗I_{|P|}) [(I_{|J|}⊗B⊗I_{|P|}) [(I_{|J|}⊗I_{|N|}⊗C)v]]] |
316 """ | 316 """ |
317 function LazyOuterProduct end | 317 function LazyOuterProduct end |
318 export LazyOuterProduct | 318 export LazyOuterProduct |
319 | 319 |
320 function LazyOuterProduct(tm1::TensorMapping, tm2::TensorMapping) | 320 function LazyOuterProduct(tm1::TensorMapping{T}, tm2::TensorMapping{T}) where T |
321 itm1 = InflatedTensorMapping(tm1, IdentityMapping(range_size(tm2))) | 321 itm1 = InflatedTensorMapping(tm1, IdentityMapping{T}(range_size(tm2))) |
322 itm2 = InflatedTensorMapping(IdentityMapping(domain_size(tm1)),tm2) | 322 itm2 = InflatedTensorMapping(IdentityMapping{T}(domain_size(tm1)),tm2) |
323 | 323 |
324 return itm1∘itm2 | 324 return itm1∘itm2 |
325 end | 325 end |
326 | 326 |
327 # length(tms) is always >= 1 since the two argument method is more specific. Right?? | 327 LazyOuterProduct(tms::Vararg{TensorMapping}) = foldl(LazyOuterProduct, tms) |
328 LazyOuterProduct(tm::TensorMapping, tms::Vararg{TensorMapping}) = tm∘LazyOuterProduct(tms...) | 328 |
329 | 329 ⊗(tms::Vararg{TensorMapping}) = LazyOuterProduct(tms...) |
330 ⊗(a::TensorMapping,b::TensorMapping) = LazyOuterProduct(a,b) | 330 export ⊗ |
331 ⊗(a,b,cs::Vararg{TensorMapping}) = ⊗(a⊗b, cs...) | |
332 | 331 |
333 # TODO: Can we implement compositions and kroneckers of LazyIdentities to just return new LazyIdentities? | 332 # TODO: Can we implement compositions and kroneckers of LazyIdentities to just return new LazyIdentities? |