Skip to content

Commit 62d1031

Browse files
committed
Add allocation tests
1 parent 64e5be1 commit 62d1031

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/adjtrans.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,16 @@ end
555555

556556
# Special adjoint/transpose methods for Adjoint/Transpose that have been reshaped as a vector
557557
# these are used in transposing banded matrices by forwarding the operation to the bands
558-
# compute vec(transpose(A)), but avoid an allocating reshape if possible
558+
"""
559+
_vectranspose(A::AbstractVector)::AbstractVector
560+
561+
Compute `vec(transpose(A))`, but avoid an allocating reshape if possible
562+
"""
559563
_vectranspose(A::AbstractVector) = vec(transpose(A))
560564
_vectranspose(A::Base.ReshapedArray{<:Any,1,<:TransposeAbsVec}) = transpose(parent(A))
561-
# compute vec(adjoint(A)), but avoid an allocating reshape if possible
565+
"""
566+
_vecadjoint(A::AbstractVector)::AbstractVector
567+
Compute `vec(adjoint(A))`, but avoid an allocating reshape if possible
568+
"""
562569
_vecadjoint(A::AbstractVector) = vec(adjoint(A))
563570
_vecadjoint(A::Base.ReshapedArray{<:Any,1,<:AdjointAbsVec}) = adjoint(parent(A))

test/bidiag.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,8 @@ end
12501250
@test B[1,1] == m
12511251
C[2,1] = el
12521252
@test B[1,2] == m
1253+
@test (@allocated op(B)) == 0
1254+
@test (@allocated op(op(B))) == 0
12531255
end
12541256
end
12551257

test/diagonal.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,8 @@ end
15231523
el = op(m)
15241524
C[1,1] = el
15251525
@test D[1,1] == m
1526+
@test (@allocated op(D)) == 0
1527+
@test (@allocated op(op(D))) == 0
15261528
end
15271529
end
15281530

0 commit comments

Comments
 (0)