comparison src/LazyTensors/LazyTensors.jl @ 999:20cb83efb3f1 refactor/lazy_tensors

More operator definitions to top file
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 18 Mar 2022 21:43:38 +0100
parents 20c376dffe84
children 1091ac8c69ad
comparison
equal deleted inserted replaced
998:390dfc3db4b1 999:20cb83efb3f1
14 include("lazy_tensor.jl") 14 include("lazy_tensor.jl")
15 include("lazy_array.jl") 15 include("lazy_array.jl")
16 include("lazy_tensor_operations.jl") 16 include("lazy_tensor_operations.jl")
17 include("tuple_manipulation.jl") 17 include("tuple_manipulation.jl")
18 18
19 # Applying lazy tensors to vectors
20 Base.:*(a::LazyTensor, v::AbstractArray) = LazyTensorApplication(a,v)
21 Base.:*(a::LazyTensor, b::LazyTensor) = throw(MethodError(Base.:*,(a,b)))
22 Base.:*(a::LazyTensor, args::Union{LazyTensor, AbstractArray}...) = foldr(*,(a,args...))
23
24 # Addition and subtraction of lazy tensors
25 Base.:+(tm1::LazyTensor{T,R,D}, tm2::LazyTensor{T,R,D}) where {T,R,D} = LazyLazyTensorBinaryOperation{:+,T,R,D}(tm1,tm2)
26 Base.:-(tm1::LazyTensor{T,R,D}, tm2::LazyTensor{T,R,D}) where {T,R,D} = LazyLazyTensorBinaryOperation{:-,T,R,D}(tm1,tm2)
27
28 # Composing lazy tensors
29 Base.:∘(s::LazyTensor, t::LazyTensor) = LazyTensorComposition(s,t)
30
31 # Outer products of tensors
32 ⊗(a::LazyTensor, b::LazyTensor) = LazyOuterProduct(a,b)
33
19 end # module 34 end # module