changeset 157:63b495d5dbc7 boundary_conditions

Add *-operator for tensor application
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 29 Apr 2019 11:47:26 +0200
parents ef3e6c70b6f9
children a3fac8298e3c
files TensorMappings.jl
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/TensorMappings.jl	Mon Apr 29 11:40:22 2019 +0200
+++ b/TensorMappings.jl	Mon Apr 29 11:47:26 2019 +0200
@@ -36,6 +36,8 @@
 
 # range_size(::TensorMappingTranspose{T,R,D}, domain_size::NTuple{}) = range_size_of_transpose???
 
+
+
 struct TensorApplication{T,R,D} <: AbstractArray{T,R}
 	t::TensorMapping{R,D}
 	o::AbstractArray{T,D}
@@ -53,6 +55,15 @@
 # The associativity of the operators might be fixed somehow... (rfold/lfold?)
 # ∘ also is an option but that has the same problem as * (but is not n-ary) (or is this best used for composition of Mappings?)
 
+# If we want to use * it would be something like this:
+import Base.*
+*(args::Union{TensorMapping{T}, AbstractArray{T}}...) where T = foldr(*,args)
+*(t::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = TensorApplication(t,o)
+# We need to be really careful about good error messages.
+# For example what happens if you try to multiply TensorApplication with a TensorMapping(wrong order)?
+
+
+
 struct TensorMappingComposition{T,R,K,D} <: TensorMapping{T,R,D}
 	t1::TensorMapping{T,R,K}
 	t2::TensorMapping{T,K,D}