Skip to content

Commit

Permalink
triangular rot180 (#257)
Browse files Browse the repository at this point in the history
* copy for banded AdjOrTrans

* Update test_tribanded.jl
  • Loading branch information
dlfivefifty authored Oct 3, 2023
1 parent dcd4aa9 commit 59f4758
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tribanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ end
LUT = uplo == 'U' ? LowerTriangular : UpperTriangular
tbsv!(uploT, 'T', unit, size(A,1), bandwidth(A,bwdim), bandeddata(LUT(A')), x)
end


rot180(A::UpperTriangular{<:Any,<:AbstractBandedMatrix}) = LowerTriangular(rot180(parent(A)))
rot180(A::UnitUpperTriangular{<:Any,<:AbstractBandedMatrix}) = UnitLowerTriangular(rot180(parent(A)))
rot180(A::LowerTriangular{<:Any,<:AbstractBandedMatrix}) = UpperTriangular(rot180(parent(A)))
rot180(A::UnitLowerTriangular{<:Any,<:AbstractBandedMatrix}) = UnitUpperTriangular(rot180(parent(A)))
12 changes: 12 additions & 0 deletions test/test_tribanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,16 @@ import BandedMatrices: BandedColumns, BandedRows
@test\ B Matrix(L̃) \ B
@test B / B / Matrix(L̃)
end

@testset "rot180" begin
B = brand(5,5,2,1)
@test rot180(UpperTriangular(B)) isa LowerTriangular{<:Any,<:BandedMatrix}
@test rot180(UnitUpperTriangular(B)) isa UnitLowerTriangular{<:Any,<:BandedMatrix}
@test rot180(LowerTriangular(B)) isa UpperTriangular{<:Any,<:BandedMatrix}
@test rot180(UnitLowerTriangular(B)) isa UnitUpperTriangular{<:Any,<:BandedMatrix}
@test rot180(UpperTriangular(B)) == rot180(Matrix(UpperTriangular(B)))
@test rot180(UnitUpperTriangular(B)) == rot180(Matrix(UnitUpperTriangular(B)))
@test rot180(LowerTriangular(B)) == rot180(Matrix(LowerTriangular(B)))
@test rot180(UnitLowerTriangular(B)) == rot180(Matrix(UnitLowerTriangular(B)))
end
end

0 comments on commit 59f4758

Please sign in to comment.