|
| 1 | +using Test, LinearMaps, LinearAlgebra, BlockArrays |
| 2 | + |
| 3 | +@testset "Non-traditional axes" begin |
| 4 | + |
| 5 | + A = rand(ComplexF64,2,4) |
| 6 | + B = PseudoBlockMatrix{ComplexF64}(undef, [2,3], [3,4]) |
| 7 | + |
| 8 | + ax1 = axes(B)[1] |
| 9 | + ax2 = axes(B)[2] |
| 10 | + fill!(B,0) |
| 11 | + B[Block(1),Block(2)] .= A |
| 12 | + |
| 13 | + N = @inferred LinearMap(B) |
| 14 | + @test axes(N) == (ax1,ax2) |
| 15 | + |
| 16 | + @test eltype(N) == eltype(B) |
| 17 | + |
| 18 | + u = similar(Array{ComplexF64}, ax2) |
| 19 | + v = PseudoBlockVector{ComplexF64}(undef, [3,5]) |
| 20 | + w = PseudoBlockVector{ComplexF64}(undef, [4,3]) |
| 21 | + # v = similar(Array{ComplexF64}, blockedrange([3,5])) |
| 22 | + # w = similar(Array{ComplexF64}, blockedrange([4,3])) |
| 23 | + |
| 24 | + for i in eachindex(u) u[i] = rand(ComplexF64) end |
| 25 | + for i in eachindex(v) v[i] = rand(ComplexF64) end |
| 26 | + for i in eachindex(w) w[i] = rand(ComplexF64) end |
| 27 | + |
| 28 | + @test B*u == N*u |
| 29 | + @test_throws DimensionMismatch N*v |
| 30 | + |
| 31 | + # Lu = L*u |
| 32 | + Nu = N*u |
| 33 | + |
| 34 | + @test axes(Nu)[1] == axes(N)[1] == axes(B)[1] |
| 35 | + @test blocklengths(axes(Nu)[1]) == blocklengths(axes(N)[1]) == blocklengths(axes(B)[1]) == [2,3] |
| 36 | + |
| 37 | + C = B + 2N |
| 38 | + @test axes(C) === axes(B) === axes(N) |
| 39 | + @test C*u ≈ 3*Nu |
| 40 | + |
| 41 | + Cu = C*u |
| 42 | + @test axes(C)[1] == ax1 |
| 43 | + @test blocklengths(axes(C)[1]) == blocklengths(ax1) |
| 44 | +end |
0 commit comments