Mercurial > repos > public > sbplib_julia
changeset 414:f4c51b0350ba
Merge feature/LazyLinearMap/transpose. Add apply_transpose method to LazyLinearMapping
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 16 Oct 2020 09:34:06 +0200 |
parents | 26e186b565b3 (current diff) f7a4bac0d599 (diff) |
children | 814865d40f48 3796e296fe64 10a67ac48d6e |
files | |
diffstat | 2 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl Thu Oct 15 21:06:28 2020 +0200 +++ b/src/LazyTensors/lazy_tensor_operations.jl Fri Oct 16 09:34:06 2020 +0200 @@ -137,3 +137,7 @@ A_view = @view llm.A[view_index...] return sum(A_view.*v) end + +function apply_transpose(llm::LazyLinearMap{T,R,D}, v::AbstractArray{T,R}, I::Vararg{Index,D}) where {T,R,D} + apply(LazyLinearMap(llm.A, llm.domain_indicies, llm.range_indicies), v, I...) +end
--- a/test/testLazyTensors.jl Thu Oct 15 21:06:28 2020 +0200 +++ b/test/testLazyTensors.jl Fri Oct 16 09:34:06 2020 +0200 @@ -219,6 +219,7 @@ A = rand(3,4) à = LazyLinearMap(A, (1,), (2,)) v = rand(4) + w = rand(3) @test à isa LazyLinearMap{T,1,1} where T @test à isa TensorMapping{T,1,1} where T @@ -227,6 +228,7 @@ @test Ã*ones(4) ≈ A*ones(4) atol=5e-13 @test Ã*v ≈ A*v atol=5e-13 + @test Ã'*w ≈ A'*w A = rand(2,3,4) @test_throws DomainError LazyLinearMap(A, (3,1), (2,))