changeset 469:481e86e77c22 feature/outer_product

Merge in feature/infated_tensormapping
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 24 Oct 2020 20:40:28 +0200
parents a52f38e72258 (current diff) 6458c929de4a (diff)
children 0c3decc04649
files src/LazyTensors/lazy_tensor_operations.jl test/testLazyTensors.jl
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Thu Oct 22 10:18:57 2020 +0200
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Sat Oct 24 20:40:28 2020 +0200
@@ -195,14 +195,20 @@
     end
 end
 export InflatedTensorMapping
-
 """
     InflatedTensorMapping(before, tm, after)
+    InflatedTensorMapping(before,tm)
+    InflatedTensorMapping(tm,after)
 
 The outer product of `before`, `tm` and `after`, where `before` and `after` are `IdentityMapping`s.
+
+If one of `before` or `after` is left out, a 0-dimensional `IdentityMapping` is used as the default value.
 """
 InflatedTensorMapping(::IdentityMapping, ::TensorMapping, ::IdentityMapping)
-# TODO: Implement constructors where one of `before` or `after` is missing
+InflatedTensorMapping(before::IdentityMapping, tm::TensorMapping{T}) where T = InflatedTensorMapping(before,tm,IdentityMapping{T}())
+InflatedTensorMapping(tm::TensorMapping{T}, after::IdentityMapping) where T = InflatedTensorMapping(IdentityMapping{T}(),tm,after)
+# Resolve ambiguity between the two previous methods
+InflatedTensorMapping(I1::IdentityMapping{T}, I2::IdentityMapping{T}) where T = InflatedTensorMapping(I1,I2,IdentityMapping{T}())
 
 # TODO: Implement syntax and constructors for products of different combinations of InflatedTensorMapping and IdentityMapping
 
--- a/test/testLazyTensors.jl	Thu Oct 22 10:18:57 2020 +0200
+++ b/test/testLazyTensors.jl	Sat Oct 24 20:40:28 2020 +0200
@@ -328,6 +328,9 @@
     @test InflatedTensorMapping(I(3,2), A, I(4)) isa TensorMapping{Float64, 4, 4}
     @test InflatedTensorMapping(I(3,2), B, I(4)) isa TensorMapping{Float64, 5, 4}
     @test InflatedTensorMapping(I(3), C, I(2,3)) isa TensorMapping{Float64, 4, 5}
+    @test InflatedTensorMapping(C, I(2,3)) isa TensorMapping{Float64, 3, 4}
+    @test InflatedTensorMapping(I(3), C) isa TensorMapping{Float64, 2, 3}
+    @test InflatedTensorMapping(I(3), I(2,3)) isa TensorMapping{Float64, 3, 3}
 
     @test range_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,4,4)
     @test domain_size(InflatedTensorMapping(I(3,2), A, I(4))) == (3,2,2,4)