Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 421:2808c41f5efa bugfix/tensor_application_multiplication
Change defs of * for TensorApplication to fix bug
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 18 Oct 2020 22:09:17 +0200 |
parents | 4aa59af074ef |
children | cffdac9c612d |
comparison
equal
deleted
inserted
replaced
420:3796e296fe64 | 421:2808c41f5efa |
---|---|
14 # TODO: Do boundschecking on creation! | 14 # TODO: Do boundschecking on creation! |
15 export LazyTensorMappingApplication | 15 export LazyTensorMappingApplication |
16 | 16 |
17 # TODO: Go through and remove unneccerary type parameters on functions | 17 # TODO: Go through and remove unneccerary type parameters on functions |
18 | 18 |
19 Base.:*(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o) | |
20 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg{Index,R}) where {T,R,D} = apply(ta.t, ta.o, I...) | 19 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg{Index,R}) where {T,R,D} = apply(ta.t, ta.o, I...) |
21 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg{Int,R}) where {T,R,D} = apply(ta.t, ta.o, Index{Unknown}.(I)...) | 20 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg{Int,R}) where {T,R,D} = apply(ta.t, ta.o, Index{Unknown}.(I)...) |
22 Base.size(ta::LazyTensorMappingApplication) = range_size(ta.t) | 21 Base.size(ta::LazyTensorMappingApplication) = range_size(ta.t) |
23 # TODO: What else is needed to implement the AbstractArray interface? | 22 # TODO: What else is needed to implement the AbstractArray interface? |
24 | 23 |
24 Base.:*(a::TensorMapping, v::AbstractArray) = LazyTensorMappingApplication(a,v) | |
25 Base.:*(a::TensorMapping, b::TensorMapping) = throw(MethodError(Base.:*,(a,b))) | |
26 Base.:*(a::TensorMapping, args::Union{TensorMapping, AbstractArray}...) = foldr(*,(a,args...)) | |
27 | |
25 # # We need the associativity to be a→b→c = a→(b→c), which is the case for '→' | 28 # # We need the associativity to be a→b→c = a→(b→c), which is the case for '→' |
26 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...)) | |
27 # # Should we overload some other infix binary opesrator? | 29 # # Should we overload some other infix binary opesrator? |
28 # →(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o) | 30 # →(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o) |
29 # TODO: We need to be really careful about good error messages. | 31 # TODO: We need to be really careful about good error messages. |
30 # For example what happens if you try to multiply LazyTensorMappingApplication with a TensorMapping(wrong order)? | 32 # For example what happens if you try to multiply LazyTensorMappingApplication with a TensorMapping(wrong order)? |
31 | 33 |