Mercurial > repos > public > sbplib_julia
comparison LazyTensors/src/lazy_operations.jl @ 264:8ffd9c2e2119 boundary_conditions
Update documentation and formating
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 04 Dec 2019 19:13:55 +0100 |
parents | b577b5f64530 |
children |
comparison
equal
deleted
inserted
replaced
263:b577b5f64530 | 264:8ffd9c2e2119 |
---|---|
40 | 40 |
41 """ | 41 """ |
42 LazyElementwiseOperation{T,D,Op,T1,T2} <: LazyArray{T,D} | 42 LazyElementwiseOperation{T,D,Op,T1,T2} <: LazyArray{T,D} |
43 Struct allowing for lazy evaluation of elementwise operations on AbstractArrays. | 43 Struct allowing for lazy evaluation of elementwise operations on AbstractArrays. |
44 | 44 |
45 A LazyElementwiseOperation contains two AbstractArrays of equal size, | 45 A LazyElementwiseOperation contains two datatypes T1, and T2, together with an operation, |
46 together with an operation. The operations are carried out when the | 46 where at least one of T1 and T2 is an AbstractArray, and one may be a Real. |
47 LazyElementwiseOperation is indexed. | 47 The operations are carried out when the LazyElementwiseOperation is indexed. |
48 """ | 48 """ |
49 struct LazyElementwiseOperation{T,D,Op, T1, T2} <: LazyArray{T,D} | 49 struct LazyElementwiseOperation{T,D,Op,T1,T2} <: LazyArray{T,D} |
50 a::T1 | 50 a::T1 |
51 b::T2 | 51 b::T2 |
52 | 52 |
53 @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op, T1<:AbstractArray{T,D}, T2<:AbstractArray{T,D}} | 53 @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op,T1<:AbstractArray{T,D},T2<:AbstractArray{T,D}} |
54 @boundscheck if size(a) != size(b) | 54 @boundscheck if size(a) != size(b) |
55 throw(DimensionMismatch("dimensions must match")) | 55 throw(DimensionMismatch("dimensions must match")) |
56 end | 56 end |
57 return new{T,D,Op,T1,T2}(a,b) | 57 return new{T,D,Op,T1,T2}(a,b) |
58 end | 58 end |
59 | 59 |
60 @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op, T1<:AbstractArray{T,D}, T2<:Real} | 60 @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op,T1<:AbstractArray{T,D},T2<:Real} |
61 return new{T,D,Op,T1,T2}(a,b) | 61 return new{T,D,Op,T1,T2}(a,b) |
62 end | 62 end |
63 | 63 |
64 @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op, T1<:Real, T2<:AbstractArray{T,D}} | 64 @inline function LazyElementwiseOperation{T,D,Op}(a::T1,b::T2) where {T,D,Op,T1<:Real,T2<:AbstractArray{T,D}} |
65 return new{T,D,Op,T1,T2}(a,b) | 65 return new{T,D,Op,T1,T2}(a,b) |
66 end | 66 end |
67 end | 67 end |
68 # TODO: Move Op to be the first parameter? Compare to Binary operations | 68 # TODO: Move Op to be the first parameter? Compare to Binary operations |
69 | 69 |