annotate src/LazyTensors/lazy_array.jl @ 2015:5c2448d6a201 feature/grids/geometry_functions tip

Structure tests a bit more
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 09 May 2025 15:57:38 +0200
parents dfb43fdac9fc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
1 """
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
2 LazyArray{T,D} <: AbstractArray{T,D}
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
3
1513
d7bc11053951 Fix spelling mistakes
Jonatan Werpers <jonatan@werpers.com>
parents: 1293
diff changeset
4 Array which is calculated lazily when indexing.
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
5
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
6 A subtype of `LazyArray` will use lazy version of `+`, `-`, `*`, `/`.
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
7 """
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
8 abstract type LazyArray{T,D} <: AbstractArray{T,D} end
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
9
325
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
10 struct LazyConstantArray{T,D} <: LazyArray{T,D}
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
11 val::T
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
12 size::NTuple{D,Int}
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
13 end
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
14
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
15 Base.size(lca::LazyConstantArray) = lca.size
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
16 Base.getindex(lca::LazyConstantArray{T,D}, I::Vararg{Int,D}) where {T,D} = lca.val
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
17
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
18 """
371
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
19 LazyFunctionArray{F<:Function,T, D} <: LazyArray{T,D}
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
20
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
21 A lazy array where each element is defined by a function f(i,j,...)
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
22 """
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
23 struct LazyFunctionArray{F<:Function,T, D} <: LazyArray{T,D}
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
24 f::F
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
25 size::NTuple{D,Int}
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
26 end
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
27
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
28 function LazyFunctionArray(f::F, size::NTuple{D,Int}) where {F<:Function,D}
1142
6fd97b5ed3e5 Fix failing test
Jonatan Werpers <jonatan@werpers.com>
parents: 1121
diff changeset
29 T = typeof(f(ones(Int, D)...))
371
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
30 return LazyFunctionArray{F,T,D}(f,size)
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
31 end
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
32
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
33 Base.size(lfa::LazyFunctionArray) = lfa.size
372
33c360c3c6bc Improve formatting
Jonatan Werpers <jonatan@werpers.com>
parents: 371
diff changeset
34
371
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
35 function Base.getindex(lfa::LazyFunctionArray{F,T,D}, I::Vararg{Int,D}) where {F,T,D}
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
36 @boundscheck checkbounds(lfa, I...)
1293
c5cf32fab163 Add call site @inline in LazyFunctionArray to avoid allocations in eval_on on 3D grids
Jonatan Werpers <jonatan@werpers.com>
parents: 1142
diff changeset
37 return @inbounds @inline lfa.f(I...)
371
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
38 end
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
39
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
40
241bd2512c20 Add a LazyFunctionArray that evaluates a function for each index.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
41 """
325
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
42 LazyElementwiseOperation{T,D,Op} <: LazyArray{T,D}
1513
d7bc11053951 Fix spelling mistakes
Jonatan Werpers <jonatan@werpers.com>
parents: 1293
diff changeset
43 Struct allowing for lazy evaluation of element-wise operations on `AbstractArray`s.
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
44
838
76e5682d0e52 Fix a bunch of docstring mistakes
Jonatan Werpers <jonatan@werpers.com>
parents: 376
diff changeset
45 A `LazyElementwiseOperation` contains two arrays together with an operation.
76e5682d0e52 Fix a bunch of docstring mistakes
Jonatan Werpers <jonatan@werpers.com>
parents: 376
diff changeset
46 The operations are carried out when the `LazyElementwiseOperation` is indexed.
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
47 """
347
0a95a829176c lazy_array.jl: Bring back the concrete types in the LazyElementwiseOperation struct.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
48 struct LazyElementwiseOperation{T,D,Op,T1<:AbstractArray{T,D},T2<:AbstractArray{T,D}} <: LazyArray{T,D}
0a95a829176c lazy_array.jl: Bring back the concrete types in the LazyElementwiseOperation struct.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
49 a::T1
0a95a829176c lazy_array.jl: Bring back the concrete types in the LazyElementwiseOperation struct.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
50 b::T2
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
51
347
0a95a829176c lazy_array.jl: Bring back the concrete types in the LazyElementwiseOperation struct.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
52 function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op,T1<:AbstractArray{T,D},T2<:AbstractArray{T,D}}
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
53 @boundscheck if size(a) != size(b)
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
54 throw(DimensionMismatch("dimensions must match"))
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
55 end
347
0a95a829176c lazy_array.jl: Bring back the concrete types in the LazyElementwiseOperation struct.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
56 return new{T,D,Op,T1,T2}(a,b)
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
57 end
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
58
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
59 end
347
0a95a829176c lazy_array.jl: Bring back the concrete types in the LazyElementwiseOperation struct.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
60 LazyElementwiseOperation{T,D,Op}(a::AbstractArray{T,D},b::T) where {T,D,Op} = LazyElementwiseOperation{T,D,Op}(a, LazyConstantArray(b, size(a)))
0a95a829176c lazy_array.jl: Bring back the concrete types in the LazyElementwiseOperation struct.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
61 LazyElementwiseOperation{T,D,Op}(a::T,b::AbstractArray{T,D}) where {T,D,Op} = LazyElementwiseOperation{T,D,Op}(LazyConstantArray(a, size(b)), b)
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
62
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
63 Base.size(v::LazyElementwiseOperation) = size(v.a)
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
64
1015
4dd3c2312d9e Fix some @boundscheck @inboudns combos
Jonatan Werpers <jonatan@werpers.com>
parents: 1004
diff changeset
65 Base.@propagate_inbounds evaluate(leo::LazyElementwiseOperation{T,D,:+}, I::Vararg{Int,D}) where {T,D} = leo.a[I...] + leo.b[I...]
4dd3c2312d9e Fix some @boundscheck @inboudns combos
Jonatan Werpers <jonatan@werpers.com>
parents: 1004
diff changeset
66 Base.@propagate_inbounds evaluate(leo::LazyElementwiseOperation{T,D,:-}, I::Vararg{Int,D}) where {T,D} = leo.a[I...] - leo.b[I...]
4dd3c2312d9e Fix some @boundscheck @inboudns combos
Jonatan Werpers <jonatan@werpers.com>
parents: 1004
diff changeset
67 Base.@propagate_inbounds evaluate(leo::LazyElementwiseOperation{T,D,:*}, I::Vararg{Int,D}) where {T,D} = leo.a[I...] * leo.b[I...]
4dd3c2312d9e Fix some @boundscheck @inboudns combos
Jonatan Werpers <jonatan@werpers.com>
parents: 1004
diff changeset
68 Base.@propagate_inbounds evaluate(leo::LazyElementwiseOperation{T,D,:/}, I::Vararg{Int,D}) where {T,D} = leo.a[I...] / leo.b[I...]
325
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
69
1004
7fd37aab84fe Simplify bounds handling for LazyElementwiseOperation
Jonatan Werpers <jonatan@werpers.com>
parents: 1003
diff changeset
70 function Base.getindex(leo::LazyElementwiseOperation{T,D}, I::Vararg{Int,D}) where {T,D}
7fd37aab84fe Simplify bounds handling for LazyElementwiseOperation
Jonatan Werpers <jonatan@werpers.com>
parents: 1003
diff changeset
71 @boundscheck checkbounds(leo.a, I...)
1015
4dd3c2312d9e Fix some @boundscheck @inboudns combos
Jonatan Werpers <jonatan@werpers.com>
parents: 1004
diff changeset
72 return @inbounds evaluate(leo, I...)
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
73 end
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
74
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
75 # Define lazy operations for AbstractArrays. Operations constructs a LazyElementwiseOperation which
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
76 # can later be indexed into. Lazy operations are denoted by the usual operator followed by a tilde
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
77 Base.@propagate_inbounds +̃(a::AbstractArray{T,D}, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:+}(a,b)
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
78 Base.@propagate_inbounds -̃(a::AbstractArray{T,D}, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:-}(a,b)
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
79 Base.@propagate_inbounds *̃(a::AbstractArray{T,D}, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:*}(a,b)
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
80 Base.@propagate_inbounds /̃(a::AbstractArray{T,D}, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:/}(a,b)
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
81
325
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
82 Base.@propagate_inbounds +̃(a::AbstractArray{T,D}, b::T) where {T,D} = LazyElementwiseOperation{T,D,:+}(a,b)
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
83 Base.@propagate_inbounds -̃(a::AbstractArray{T,D}, b::T) where {T,D} = LazyElementwiseOperation{T,D,:-}(a,b)
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
84 Base.@propagate_inbounds *̃(a::AbstractArray{T,D}, b::T) where {T,D} = LazyElementwiseOperation{T,D,:*}(a,b)
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
85 Base.@propagate_inbounds /̃(a::AbstractArray{T,D}, b::T) where {T,D} = LazyElementwiseOperation{T,D,:/}(a,b)
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
86
325
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
87 Base.@propagate_inbounds +̃(a::T, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:+}(a,b)
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
88 Base.@propagate_inbounds -̃(a::T, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:-}(a,b)
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
89 Base.@propagate_inbounds *̃(a::T, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:*}(a,b)
41c3c25e4e3b LazyTensors: Simplify the LazyElementwiseOperation type by restricting it and introducing a LazyConstantArray to handle scalars.
Jonatan Werpers <jonatan@werpers.com>
parents: 267
diff changeset
90 Base.@propagate_inbounds /̃(a::T, b::AbstractArray{T,D}) where {T,D} = LazyElementwiseOperation{T,D,:/}(a,b)
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
91
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
92
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
93
1118
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
94 # Overload +,-,*,/ for LazyArrays
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
95 # Element wise operation for `*` and `/` are not overloaded for due to conflicts with the behavior
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
96 # of regular `*` and `/` for AbstractArrays. Use tilde versions instead.
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
97 Base.@propagate_inbounds Base.:+(a::LazyArray{T,D}, b::LazyArray{T,D}) where {T,D} = a +̃ b
1118
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
98 Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::LazyArray{T,D}) where {T,D} = a -̃ b
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
99
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
100 Base.@propagate_inbounds Base.:+(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a +̃ b
1118
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
101 Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::AbstractArray{T,D}) where {T,D} = a -̃ b
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
102
1118
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
103 Base.@propagate_inbounds Base.:+(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a +̃ b
267
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
104 Base.@propagate_inbounds Base.:-(a::AbstractArray{T,D}, b::LazyArray{T,D}) where {T,D} = a -̃ b
634453a4e1d8 Restructure code in LazyTensors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
105
1118
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
106 Base.@propagate_inbounds Base.:+(a::LazyArray{T,D}, b::T) where {T,D} = a +̃ b
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
107 Base.@propagate_inbounds Base.:-(a::LazyArray{T,D}, b::T) where {T,D} = a -̃ b
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
108
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
109 Base.@propagate_inbounds Base.:+(a::T, b::LazyArray{T,D}) where {T,D} = a +̃ b
6104db60b7a3 Export binary operations for LazyArrays and scalars
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1015
diff changeset
110 Base.@propagate_inbounds Base.:-(a::T, b::LazyArray{T,D}) where {T,D} = a -̃ b