changeset 442:e70e47fbfa7c feature/lazy_identity

Add another convenience constructor
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 19 Oct 2020 21:41:34 +0200
parents 552189707fbe
children e95343a486f3 ac6d22570a08
files src/LazyTensors/lazy_tensor_operations.jl test/testLazyTensors.jl
diffstat 2 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Mon Oct 19 21:23:12 2020 +0200
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Mon Oct 19 21:41:34 2020 +0200
@@ -162,6 +162,7 @@
 
 IdentityMapping{T}(size::NTuple{D,Int}) where {T,D} = IdentityMapping{T,D}(size)
 IdentityMapping{T}(size::Vararg{Int,D}) where {T,D} = IdentityMapping{T,D}(size)
+IdentityMapping(size::Vararg{Int,D}) where D = IdentityMapping{Float64,D}(size)
 
 range_size(tmi::IdentityMapping) = tmi.size
 domain_size(tmi::IdentityMapping) = tmi.size
--- a/test/testLazyTensors.jl	Mon Oct 19 21:23:12 2020 +0200
+++ b/test/testLazyTensors.jl	Mon Oct 19 21:41:34 2020 +0200
@@ -287,6 +287,8 @@
     @test IdentityMapping{Float64}((4,5)) isa TensorMapping{T,2,2} where T
     @test IdentityMapping{Float64}((4,5)) == IdentityMapping{Float64}(4,5)
 
+    @test IdentityMapping(3,2) isa IdentityMapping{Float64,2}
+
     for sz ∈ [(4,5),(3,),(5,6,4)]
         I = IdentityMapping{Float64}(sz)
         v = rand(sz...)