comparison src/LazyTensors/lazy_tensor_operations.jl @ 392:418cfd945715 feature/lazy_linear_map

Fix bug in range_size and domain_size for LazyLinearMap and expand the test
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 02 Oct 2020 13:43:36 +0200
parents 8414c2334393
children b14eacf823b6
comparison
equal deleted inserted replaced
377:8414c2334393 392:418cfd945715
111 range_indicies::NTuple{R,Int} 111 range_indicies::NTuple{R,Int}
112 domain_indicies::NTuple{D,Int} 112 domain_indicies::NTuple{D,Int}
113 end 113 end
114 export LazyLinearMap 114 export LazyLinearMap
115 115
116 range_size(llm::LazyLinearMap) = size(llm.A)[llm.range_indicies...] 116 range_size(llm::LazyLinearMap) = size(llm.A)[[llm.range_indicies...]]
117 domain_size(llm::LazyLinearMap) = size(llm.A)[llm.domain_indicies...] 117 domain_size(llm::LazyLinearMap) = size(llm.A)[[llm.domain_indicies...]]
118 118
119 function apply(llm::LazyLinearMap{T,R,D}, v::AbstractArray{T,D}, I::Vararg{Index,R}) where {T,R,D} 119 function apply(llm::LazyLinearMap{T,R,D}, v::AbstractArray{T,D}, I::Vararg{Index,R}) where {T,R,D}
120 view_index = ntuple(i->:,ndims(llm.A)) 120 view_index = ntuple(i->:,ndims(llm.A))
121 for i ∈ 1:R 121 for i ∈ 1:R
122 view_index = Base.setindex(view_index, Int(I[i]), llm.range_indicies[i]) 122 view_index = Base.setindex(view_index, Int(I[i]), llm.range_indicies[i])
124 124
125 A_view = @view llm.A[view_index...] 125 A_view = @view llm.A[view_index...]
126 126
127 return sum(A_view.*v) 127 return sum(A_view.*v)
128 end 128 end
129