comparison LazyTensors/src/Lazy.jl @ 192:4799bc46eaa9 boundary_conditions

Remove assert in Lazy.jl. Add todo for fixing the bounds checking in getindex methods
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 20 Jun 2019 23:02:37 +0200
parents e8e21db70112
children 2d97c54fd1f1
comparison
equal deleted inserted replaced
191:25d2ef206fe9 192:4799bc46eaa9
7 struct LazyElementwiseOperation{T,D,Op, T1<:AbstractArray{T,D}, T2 <: AbstractArray{T,D}} <: AbstractArray{T,D} 7 struct LazyElementwiseOperation{T,D,Op, T1<:AbstractArray{T,D}, T2 <: AbstractArray{T,D}} <: AbstractArray{T,D}
8 a::T1 8 a::T1
9 b::T2 9 b::T2
10 10
11 function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op, T1<:AbstractArray{T,D}, T2<:AbstractArray{T,D}} 11 function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op, T1<:AbstractArray{T,D}, T2<:AbstractArray{T,D}}
12 #TODO: Remove assert? Asserts are not removed when compiling with
13 # optimization flags. If so, need to handle boundschecking proparly.
14 @assert size(a) == size(b)
15 return new{T,D,Op,T1,T2}(a,b) 12 return new{T,D,Op,T1,T2}(a,b)
16 end 13 end
17 end 14 end
18 15
19 Base.size(v::LazyElementwiseOperation) = size(v.a) 16 Base.size(v::LazyElementwiseOperation) = size(v.a)
20 17
18 # TODO: Make sure boundschecking is done properly and that the lenght of the vectors are equal
21 # NOTE: Boundschecking in getindex functions now assumes that the size of the 19 # NOTE: Boundschecking in getindex functions now assumes that the size of the
22 # vectors in the LazyElementwiseOperation are the same size. If we remove the 20 # vectors in the LazyElementwiseOperation are the same size. If we remove the
23 # size assertion in the constructor we might have to handle 21 # size assertion in the constructor we might have to handle
24 # boundschecking differently. 22 # boundschecking differently.
25 Base.@propagate_inbounds @inline function Base.getindex(leo::LazyElementwiseOperation{T,D,:+}, I...) where {T,D} 23 Base.@propagate_inbounds @inline function Base.getindex(leo::LazyElementwiseOperation{T,D,:+}, I...) where {T,D}