comparison LazyTensors/src/lazy_operations.jl @ 257:d4cd4882ee9f boundary_conditions

Improve error messages when multiblying with TensorMappings and add some tests for TensorOperators
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 28 Jun 2019 14:10:35 +0200
parents 1c6afdcfd657
children b577b5f64530
comparison
equal deleted inserted replaced
256:d8f42733f392 257:d4cd4882ee9f
30 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg{Int,R}) where {T,R,D} = apply(ta.t, ta.o, I) 30 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg{Int,R}) where {T,R,D} = apply(ta.t, ta.o, I)
31 Base.size(ta::LazyTensorMappingApplication{T,R,D}) where {T,R,D} = range_size(ta.t,size(ta.o)) 31 Base.size(ta::LazyTensorMappingApplication{T,R,D}) where {T,R,D} = range_size(ta.t,size(ta.o))
32 # TODO: What else is needed to implement the AbstractArray interface? 32 # TODO: What else is needed to implement the AbstractArray interface?
33 33
34 # # We need the associativity to be a→b→c = a→(b→c), which is the case for '→' 34 # # We need the associativity to be a→b→c = a→(b→c), which is the case for '→'
35 Base.:*(args::Union{TensorMapping{T}, AbstractArray{T}}...) where T = foldr(*,args) 35 Base.:*(a::TensorMapping{T,R,D}, b::TensorMapping{T,D,K}, args::Union{TensorMapping{T}, AbstractArray{T}}...) where {T,R,D,K} = foldr(*,(a,b,args...))
36 # # Should we overload some other infix binary operator? 36 # # Should we overload some other infix binary operator?
37 # →(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o) 37 # →(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o)
38 # TODO: We need to be really careful about good error messages. 38 # TODO: We need to be really careful about good error messages.
39 # For example what happens if you try to multiply LazyTensorMappingApplication with a TensorMapping(wrong order)? 39 # For example what happens if you try to multiply LazyTensorMappingApplication with a TensorMapping(wrong order)?
40 40