Mercurial > repos > public > sbplib_julia
changeset 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 |
files | LazyTensors/src/lazy_operations.jl |
diffstat | 1 files changed, 26 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyTensors/src/lazy_operations.jl Thu Jun 20 23:25:38 2019 +0200 +++ b/LazyTensors/src/lazy_operations.jl Thu Jun 20 23:26:43 2019 +0200 @@ -1,29 +1,3 @@ -""" - LazyTensorMappingTranspose{T,R,D} <: TensorMapping{T,D,R} - -Struct for lazy transpose of a TensorMapping. - -If a mapping implements the the `apply_transpose` method this allows working with -the transpose of mapping `m` by using `m'`. `m'` will work as a regular TensorMapping lazily calling -the appropriate methods of `m`. -""" -struct LazyTensorMappingTranspose{T,R,D} <: TensorMapping{T,D,R} - tm::TensorMapping{T,R,D} -end -export LazyTensorMappingTranspose - -# # TBD: Should this be implemented on a type by type basis or through a trait to provide earlier errors? -Base.adjoint(t::TensorMapping) = LazyTensorMappingTranspose(t) -Base.adjoint(t::LazyTensorMappingTranspose) = t.tm - -apply(tm::LazyTensorMappingTranspose{T,R,D}, v::AbstractArray{T,R}, I::Vararg) where {T,R,D} = apply_transpose(tm.tm, v, I...) -apply_transpose(tm::LazyTensorMappingTranspose{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {T,R,D} = apply(tm.tm, v, I...) - -range_size(tmt::LazyTensorMappingTranspose{T,R,D}, d_size::NTuple{R,Integer}) where {T,R,D} = domain_size(tmt.tm, domain_size) -domain_size(tmt::LazyTensorMappingTranspose{T,R,D}, r_size::NTuple{D,Integer}) where {T,R,D} = range_size(tmt.tm, range_size) - - - """ LazyArray{T,D} <: AbstractArray{T,D} @@ -137,6 +111,32 @@ +""" + LazyTensorMappingTranspose{T,R,D} <: TensorMapping{T,D,R} + +Struct for lazy transpose of a TensorMapping. + +If a mapping implements the the `apply_transpose` method this allows working with +the transpose of mapping `m` by using `m'`. `m'` will work as a regular TensorMapping lazily calling +the appropriate methods of `m`. +""" +struct LazyTensorMappingTranspose{T,R,D} <: TensorMapping{T,D,R} + tm::TensorMapping{T,R,D} +end +export LazyTensorMappingTranspose + +# # TBD: Should this be implemented on a type by type basis or through a trait to provide earlier errors? +Base.adjoint(t::TensorMapping) = LazyTensorMappingTranspose(t) +Base.adjoint(t::LazyTensorMappingTranspose) = t.tm + +apply(tm::LazyTensorMappingTranspose{T,R,D}, v::AbstractArray{T,R}, I::Vararg) where {T,R,D} = apply_transpose(tm.tm, v, I...) +apply_transpose(tm::LazyTensorMappingTranspose{T,R,D}, v::AbstractArray{T,D}, I::Vararg) where {T,R,D} = apply(tm.tm, v, I...) + +range_size(tmt::LazyTensorMappingTranspose{T,R,D}, d_size::NTuple{R,Integer}) where {T,R,D} = domain_size(tmt.tm, domain_size) +domain_size(tmt::LazyTensorMappingTranspose{T,R,D}, r_size::NTuple{D,Integer}) where {T,R,D} = range_size(tmt.tm, range_size) + + + # TODO: Write tests and documentation for LazyTensorMappingComposition # struct LazyTensorMappingComposition{T,R,K,D} <: TensorMapping{T,R,D} # t1::TensorMapping{T,R,K}