comparison src/LazyTensors/lazy_tensor_operations.jl @ 429:46acb2560451 feature/lazy_identity

Start implementing LazyIdentity
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 18 Oct 2020 22:30:17 +0200
parents 4aa59af074ef
children 541c16a8c791 904aae1899df
comparison
equal deleted inserted replaced
423:10a67ac48d6e 429:46acb2560451
139 end 139 end
140 140
141 function apply_transpose(llm::LazyLinearMap{T,R,D}, v::AbstractArray{T,R}, I::Vararg{Index,D}) where {T,R,D} 141 function apply_transpose(llm::LazyLinearMap{T,R,D}, v::AbstractArray{T,R}, I::Vararg{Index,D}) where {T,R,D}
142 apply(LazyLinearMap(llm.A, llm.domain_indicies, llm.range_indicies), v, I...) 142 apply(LazyLinearMap(llm.A, llm.domain_indicies, llm.range_indicies), v, I...)
143 end 143 end
144
145
146 """
147 LazyIdentity{T,D} <: TensorMapping{T,D,D}
148
149 The lazy identity TensorMapping for a given size. Usefull for building up higher dimensional tensor mappings from lower
150 dimensional ones through outer products. Also used in the Implementation for InflatedTensorMapping.
151 """
152 struct LazyIdentity{T,D} <: TensorMapping{T,D,D}
153 size::NTuple{D,Int}
154 end
155 export LazyIdentity
156
157 LazyIdentity{T}(size::NTuple{D,Int}) where {T,D} = LazyIdentity{T,D}(size)
158
159 range_size(tmi::LazyIdentity) = tmi.size
160 domain_size(tmi::LazyIdentity) = tmi.size
161
162 apply(tmi::LazyIdentity{T,D}, v::AbstractArray{T,D}, I::Vararg{Index,D}) where {T,D} = v[Int.(I)...]
163 apply_transpose(tmi::LazyIdentity{T,D}, v::AbstractArray{T,D}, I::Vararg{Index,D}) where {T,D} = v[Int.(I)...]
164