Skip to content

Commit fd778c6

Browse files
authored
Split chop! and resize! (#101)
1 parent cf82249 commit fd778c6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InfiniteLinearAlgebra"
22
uuid = "cde9dba0-b1de-11e9-2c62-0bab9446c55c"
3-
version = "0.6.6"
3+
version = "0.6.7"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/InfiniteLinearAlgebra.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ function choplength(c::AbstractVector, tol)
7474
return 0
7575
end
7676

77-
_chop!(_, c::AbstractVector, tol::Real) = resize!(c, choplength(c, tol))
78-
_chop!(ax::BlockedUnitRange, c::AbstractVector, tol::Real) = resize!(c, findblock(ax, choplength(c, tol)))
79-
80-
chop!(c::AbstractVector{T}, tol::Real=zero(real(T))) where T = _chop!(axes(c,1), c, tol)
77+
# resize! to nearest block
78+
compatible_resize!(_, c::AbstractVector, n) = resize!(c, n)
79+
compatible_resize!(ax::BlockedUnitRange, c::AbstractVector, n) = resize!(c, iszero(n) ? Block(0) : findblock(ax, n))
80+
compatible_resize!(c, n) = compatible_resize!(axes(c,1), c, n)
81+
chop!(c::AbstractVector{T}, tol::Real=zero(real(T))) where T = compatible_resize!(c, choplength(c, tol))
8182

8283
function chop(A::AbstractMatrix{T}, tol::Real=zero(real(T))) where T
8384
for k = size(A,1):-1:1

0 commit comments

Comments
 (0)