From afa4be6301a1e6ca172cf9df524036b746cc7c29 Mon Sep 17 00:00:00 2001 From: Daniel Karrasch Date: Thu, 23 Nov 2023 12:22:17 +0100 Subject: [PATCH] Fix `getcolptr` for sparse matrix views --- test/linalg.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/linalg.jl b/test/linalg.jl index a9396ebf..7b79d9e2 100644 --- a/test/linalg.jl +++ b/test/linalg.jl @@ -158,8 +158,8 @@ begin MAW = tr(wr(MA)) @test AW * B ≈ MAW * B # and for SparseMatrixCSCView - a view of all rows and unit range of cols - vAW = tr(wr(view(A, :, 1:n))) - vMAW = tr(wr(view(MA, :, 1:n))) + vAW = tr(wr(view([A A], :, (n+1):2n))) + vMAW = tr(wr(view([MA MA], :, (n+1):2n))) @test vAW * B ≈ vMAW * B end a = sprand(rng, ComplexF64, n, n, 0.01) @@ -170,8 +170,8 @@ begin MAW = tr(wr(ma)) @test AW * B ≈ MAW * B # and for SparseMatrixCSCView - a view of all rows and unit range of cols - vAW = tr(wr(view(a, :, 1:n))) - vMAW = tr(wr(view(ma, :, 1:n))) + vAW = tr(wr(view([a a], :, (n+1):2n))) + vMAW = tr(wr(view([ma ma], :, (n+1):2n))) @test vAW * B ≈ vMAW * B end A = A - Diagonal(diag(A)) + 2I # avoid rounding errors by division @@ -181,6 +181,10 @@ begin AW = tr(wr(A)) MAW = tr(wr(MA)) @test AW \ B ≈ MAW \ B + # and for SparseMatrixCSCView - a view of all rows and unit range of cols + vAW = tr(wr(view([a a], :, (n+1):2n))) + vMAW = tr(wr(view([ma ma], :, (n+1):2n))) + @test vAW \ B ≈ vMAW \ B end @testset "triangular singular exceptions" begin A = LowerTriangular(sparse([0 2.0;0 1]))