Mercurial > repos > public > sbplib_julia
comparison LazyTensors/src/lazy_operations.jl @ 197:a340fa91b1fc boundary_conditions
Move transpose def to the bottom of the file
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Thu, 20 Jun 2019 23:26:43 +0200 |
| parents | b3c252280a19 |
| children | b5c9be7f391c |
comparison
equal
deleted
inserted
replaced
| 196:b3c252280a19 | 197:a340fa91b1fc |
|---|---|
| 1 """ | |
| 2 LazyTensorMappingTranspose{T,R,D} <: TensorMapping{T,D,R} | |
| 3 | |
| 4 Struct for lazy transpose of a TensorMapping. | |
| 5 | |
| 6 If a mapping implements the the `apply_transpose` method this allows working with | |
| 7 the transpose of mapping `m` by using `m'`. `m'` will work as a regular TensorMapping lazily calling | |
| 8 the appropriate methods of `m`. | |
| 9 """ | |
| 10 struct LazyTensorMappingTranspose{T,R,D} <: TensorMapping{T,D,R} | |
| 11 tm::TensorMapping{T,R,D} | |
| 12 end | |
| 13 export LazyTensorMappingTranspose | |
| 14 | |
| 15 # # TBD: Should this be implemented on a type by type basis or through a trait to provide earlier errors? | |
| 16 Base.adjoint(t::TensorMapping) = LazyTensorMappingTranspose(t) | |
| 17 Base.adjoint(t::LazyTensorMappingTranspose) = t.tm | |
| 18 | |
| 19 apply(tm::LazyTensorMappingTranspose{T,R,D}, v::AbstractArray{T,R}, I::Vararg) where {T,R,D} = apply_transpose(tm.tm, v, I...) | |
| 20 apply_transpose(tm::LazyTensorMappingTranspose{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {T,R,D} = apply(tm.tm, v, I...) | |
| 21 | |
| 22 range_size(tmt::LazyTensorMappingTranspose{T,R,D}, d_size::NTuple{R,Integer}) where {T,R,D} = domain_size(tmt.tm, domain_size) | |
| 23 domain_size(tmt::LazyTensorMappingTranspose{T,R,D}, r_size::NTuple{D,Integer}) where {T,R,D} = range_size(tmt.tm, range_size) | |
| 24 | |
| 25 | |
| 26 | |
| 27 """ | 1 """ |
| 28 LazyArray{T,D} <: AbstractArray{T,D} | 2 LazyArray{T,D} <: AbstractArray{T,D} |
| 29 | 3 |
| 30 Array which is calcualted lazily when indexing. | 4 Array which is calcualted lazily when indexing. |
| 31 | 5 |
| 135 | 109 |
| 136 export +̃, -̃, *̃, /̃ | 110 export +̃, -̃, *̃, /̃ |
| 137 | 111 |
| 138 | 112 |
| 139 | 113 |
| 114 """ | |
| 115 LazyTensorMappingTranspose{T,R,D} <: TensorMapping{T,D,R} | |
| 116 | |
| 117 Struct for lazy transpose of a TensorMapping. | |
| 118 | |
| 119 If a mapping implements the the `apply_transpose` method this allows working with | |
| 120 the transpose of mapping `m` by using `m'`. `m'` will work as a regular TensorMapping lazily calling | |
| 121 the appropriate methods of `m`. | |
| 122 """ | |
| 123 struct LazyTensorMappingTranspose{T,R,D} <: TensorMapping{T,D,R} | |
| 124 tm::TensorMapping{T,R,D} | |
| 125 end | |
| 126 export LazyTensorMappingTranspose | |
| 127 | |
| 128 # # TBD: Should this be implemented on a type by type basis or through a trait to provide earlier errors? | |
| 129 Base.adjoint(t::TensorMapping) = LazyTensorMappingTranspose(t) | |
| 130 Base.adjoint(t::LazyTensorMappingTranspose) = t.tm | |
| 131 | |
| 132 apply(tm::LazyTensorMappingTranspose{T,R,D}, v::AbstractArray{T,R}, I::Vararg) where {T,R,D} = apply_transpose(tm.tm, v, I...) | |
| 133 apply_transpose(tm::LazyTensorMappingTranspose{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {T,R,D} = apply(tm.tm, v, I...) | |
| 134 | |
| 135 range_size(tmt::LazyTensorMappingTranspose{T,R,D}, d_size::NTuple{R,Integer}) where {T,R,D} = domain_size(tmt.tm, domain_size) | |
| 136 domain_size(tmt::LazyTensorMappingTranspose{T,R,D}, r_size::NTuple{D,Integer}) where {T,R,D} = range_size(tmt.tm, range_size) | |
| 137 | |
| 138 | |
| 139 | |
| 140 # TODO: Write tests and documentation for LazyTensorMappingComposition | 140 # TODO: Write tests and documentation for LazyTensorMappingComposition |
| 141 # struct LazyTensorMappingComposition{T,R,K,D} <: TensorMapping{T,R,D} | 141 # struct LazyTensorMappingComposition{T,R,K,D} <: TensorMapping{T,R,D} |
| 142 # t1::TensorMapping{T,R,K} | 142 # t1::TensorMapping{T,R,K} |
| 143 # t2::TensorMapping{T,K,D} | 143 # t2::TensorMapping{T,K,D} |
| 144 # end | 144 # end |
