diff 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
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Sat Oct 24 20:40:28 2020 +0200
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Sun Oct 25 14:01:27 2020 +0100
@@ -317,17 +317,16 @@
 function LazyOuterProduct end
 export LazyOuterProduct
 
-function LazyOuterProduct(tm1::TensorMapping, tm2::TensorMapping)
-    itm1 = InflatedTensorMapping(tm1, IdentityMapping(range_size(tm2)))
-    itm2 = InflatedTensorMapping(IdentityMapping(domain_size(tm1)),tm2)
+function LazyOuterProduct(tm1::TensorMapping{T}, tm2::TensorMapping{T}) where T
+    itm1 = InflatedTensorMapping(tm1, IdentityMapping{T}(range_size(tm2)))
+    itm2 = InflatedTensorMapping(IdentityMapping{T}(domain_size(tm1)),tm2)
 
     return itm1∘itm2
 end
 
-# length(tms) is always >= 1 since the two argument method is more specific. Right??
-LazyOuterProduct(tm::TensorMapping, tms::Vararg{TensorMapping}) = tm∘LazyOuterProduct(tms...)
+LazyOuterProduct(tms::Vararg{TensorMapping}) = foldl(LazyOuterProduct, tms)
 
-⊗(a::TensorMapping,b::TensorMapping) = LazyOuterProduct(a,b)
-⊗(a,b,cs::Vararg{TensorMapping}) = ⊗(a⊗b, cs...)
+⊗(tms::Vararg{TensorMapping}) = LazyOuterProduct(tms...)
+export ⊗
 
 # TODO: Can we implement compositions and kroneckers of LazyIdentities to just return new LazyIdentities?