Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/LazyTensors.jl @ 1101:1e8270c18edb feature/lazy_tensors/pretty_printing
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 12 May 2022 21:52:47 +0200 |
parents | 93f87d5d9fbb |
children | f1c2a4fa0ee1 a922aa69eb83 |
comparison
equal
deleted
inserted
replaced
1014:67969bd7e642 | 1101:1e8270c18edb |
---|---|
1 module LazyTensors | 1 module LazyTensors |
2 | 2 |
3 export LazyTensorApplication | 3 export TensorApplication |
4 export LazyTensorTranspose | 4 export TensorTranspose |
5 export LazyTensorComposition | 5 export TensorComposition |
6 export LazyLinearMap | |
7 export IdentityTensor | 6 export IdentityTensor |
8 export ScalingTensor | 7 export ScalingTensor |
9 export InflatedLazyTensor | 8 export DiagonalTensor |
9 export DenseTensor | |
10 export InflatedTensor | |
10 export LazyOuterProduct | 11 export LazyOuterProduct |
11 export ⊗ | 12 export ⊗ |
12 export DomainSizeMismatch | 13 export DomainSizeMismatch |
13 export RangeSizeMismatch | 14 export RangeSizeMismatch |
14 | 15 |
17 include("lazy_array.jl") | 18 include("lazy_array.jl") |
18 include("lazy_tensor_operations.jl") | 19 include("lazy_tensor_operations.jl") |
19 include("tuple_manipulation.jl") | 20 include("tuple_manipulation.jl") |
20 | 21 |
21 # Applying lazy tensors to vectors | 22 # Applying lazy tensors to vectors |
22 Base.:*(a::LazyTensor, v::AbstractArray) = LazyTensorApplication(a,v) | 23 Base.:*(a::LazyTensor, v::AbstractArray) = TensorApplication(a,v) |
23 Base.:*(a::LazyTensor, b::LazyTensor) = throw(MethodError(Base.:*,(a,b))) | 24 Base.:*(a::LazyTensor, b::LazyTensor) = throw(MethodError(Base.:*,(a,b))) |
24 Base.:*(a::LazyTensor, args::Union{LazyTensor, AbstractArray}...) = foldr(*,(a,args...)) | 25 Base.:*(a::LazyTensor, args::Union{LazyTensor, AbstractArray}...) = foldr(*,(a,args...)) |
25 | 26 |
26 # Addition and subtraction of lazy tensors | 27 # Addition and subtraction of lazy tensors |
27 Base.:+(s::LazyTensor, t::LazyTensor) = LazyTensorBinaryOperation{:+}(s,t) | 28 Base.:+(s::LazyTensor, t::LazyTensor) = ElementwiseTensorOperation{:+}(s,t) |
28 Base.:-(s::LazyTensor, t::LazyTensor) = LazyTensorBinaryOperation{:-}(s,t) | 29 Base.:-(s::LazyTensor, t::LazyTensor) = ElementwiseTensorOperation{:-}(s,t) |
29 | 30 |
30 # Composing lazy tensors | 31 # Composing lazy tensors |
31 Base.:∘(s::LazyTensor, t::LazyTensor) = LazyTensorComposition(s,t) | 32 Base.:∘(s::LazyTensor, t::LazyTensor) = TensorComposition(s,t) |
32 | 33 |
33 # Outer products of tensors | 34 # Outer products of tensors |
34 ⊗(a::LazyTensor, b::LazyTensor) = LazyOuterProduct(a,b) | 35 ⊗(a::LazyTensor, b::LazyTensor) = LazyOuterProduct(a,b) |
35 | 36 |
36 end # module | 37 end # module |