Mercurial > repos > public > sbplib_julia
comparison LazyTensors/src/lazy_operations.jl @ 198:b5c9be7f391c boundary_conditions
Fix up some formatting
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 20 Jun 2019 23:28:02 +0200 |
parents | a340fa91b1fc |
children | a22b419bbdf0 9d9f7b0e514b |
comparison
equal
deleted
inserted
replaced
197:a340fa91b1fc | 198:b5c9be7f391c |
---|---|
5 | 5 |
6 A subtype of `LazyArray` will use lazy version of `+`, `-`, `*`, `/`. | 6 A subtype of `LazyArray` will use lazy version of `+`, `-`, `*`, `/`. |
7 """ | 7 """ |
8 abstract type LazyArray{T,D} <: AbstractArray{T,D} end | 8 abstract type LazyArray{T,D} <: AbstractArray{T,D} end |
9 export LazyArray | 9 export LazyArray |
10 | |
11 | |
10 | 12 |
11 """ | 13 """ |
12 LazyTensorMappingApplication{T,R,D} <: LazyArray{T,R} | 14 LazyTensorMappingApplication{T,R,D} <: LazyArray{T,R} |
13 | 15 |
14 Struct for lazy application of a TensorMapping. Created using `*`. | 16 Struct for lazy application of a TensorMapping. Created using `*`. |
26 Base.:*(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o) | 28 Base.:*(tm::TensorMapping{T,R,D}, o::AbstractArray{T,D}) where {T,R,D} = LazyTensorMappingApplication(tm,o) |
27 | 29 |
28 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg) where {T,R,D} = apply(ta.t, ta.o, I...) | 30 Base.getindex(ta::LazyTensorMappingApplication{T,R,D}, I::Vararg) where {T,R,D} = apply(ta.t, ta.o, I...) |
29 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)) |
30 # TODO: What else is needed to implement the AbstractArray interface? | 32 # TODO: What else is needed to implement the AbstractArray interface? |
31 | |
32 | 33 |
33 # # 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 '→' |
34 Base.:*(args::Union{TensorMapping{T}, AbstractArray{T}}...) where T = foldr(*,args) | 35 Base.:*(args::Union{TensorMapping{T}, AbstractArray{T}}...) where T = foldr(*,args) |
35 # # Should we overload some other infix binary operator? | 36 # # Should we overload some other infix binary operator? |
36 # →(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) |