Skip to content

Commit 1acc2dd

Browse files
authored
Remove uniformscaling special cases (#98)
* Remove uniformscaling special cases * add choplength * test Eye * PaddedMatrix * Update Project.toml * increase cov
1 parent 808d4a8 commit 1acc2dd

File tree

6 files changed

+30
-27
lines changed

6 files changed

+30
-27
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
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.4"
3+
version = "0.6.5"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -17,15 +17,15 @@ MatrixFactorizations = "a3b82374-2e81-5b9e-98ce-41277c0e4c87"
1717
SemiseparableMatrices = "f8ebbe35-cbfb-4060-bf7f-b10e4670cf57"
1818

1919
[compat]
20-
ArrayLayouts = "0.7.5"
20+
ArrayLayouts = "0.7.7"
2121
BandedMatrices = "0.16.9"
2222
BlockArrays = "0.16"
2323
BlockBandedMatrices = "0.11"
2424
DSP = "0.7"
2525
FillArrays = "0.12"
2626
InfiniteArrays = "0.12"
2727
LazyArrays = "0.22"
28-
LazyBandedMatrices = "0.7.2"
28+
LazyBandedMatrices = "0.7.4"
2929
MatrixFactorizations = "0.8"
3030
SemiseparableMatrices = "0.3"
3131
julia = "1.6"

src/InfiniteLinearAlgebra.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,22 @@ function ArrayLayouts._power_by_squaring(_, ::NTuple{2,InfiniteCardinal{0}}, A::
6464
end
6565
end
6666

67-
68-
function chop!(c::AbstractVector, tol::Real)
69-
@assert tol >= 0
70-
71-
@inbounds for k=length(c):-1:1
67+
function choplength(c::AbstractVector, tol)
68+
@inbounds for k = length(c):-1:1
7269
if abs(c[k]) > tol
73-
resize!(c,k)
74-
return c
70+
return k
71+
break
7572
end
7673
end
77-
resize!(c,0)
78-
c
74+
return 0
7975
end
8076

81-
function chop(A::AbstractMatrix, tol)
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)
81+
82+
function chop(A::AbstractMatrix{T}, tol::Real=zero(real(T))) where T
8283
for k = size(A,1):-1:1
8384
if norm(view(A,k,:))>tol
8485
A=A[1:k,:]

src/banded/infbanded.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,6 @@ end
386386
# end
387387

388388

389-
390-
ArrayLayouts._apply(_, ::NTuple{2,InfiniteCardinal{0}}, op, Λ::UniformScaling, A::AbstractMatrix) = op(Diagonal(Fill.λ,∞)), A)
391-
ArrayLayouts._apply(_, ::NTuple{2,InfiniteCardinal{0}}, op, A::AbstractMatrix, Λ::UniformScaling) = op(A, Diagonal(Fill.λ,∞)))
392-
393389
_default_banded_broadcast(bc::Broadcasted, ::Tuple{<:OneToInf,<:Any}) = copy(Broadcasted{LazyArrayStyle{2}}(bc.f, bc.args))
394390

395391
###

src/infqr.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,7 @@ end
192192
function resizedata_chop!(v::PseudoBlockVector, tol)
193193
c = paddeddata(v.blocks)
194194
n = length(c)
195-
k_tol = n
196-
for k = n:-1:1
197-
if abs(c[k]) > tol
198-
k_tol = k
199-
break
200-
end
201-
end
195+
k_tol = choplength(c, tol)
202196
ax = axes(v,1)
203197
K = findblock(ax,k_tol)
204198
n2 = last(ax[K])

test/runtests.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using InfiniteLinearAlgebra, BlockBandedMatrices, BlockArrays, BandedMatrices, I
22
MatrixFactorizations, ArrayLayouts, LinearAlgebra, Random, LazyBandedMatrices, StaticArrays
33
import InfiniteLinearAlgebra: qltail, toeptail, tailiterate , tailiterate!, tail_de, ql_X!,
44
InfToeplitz, PertToeplitz, TriToeplitz, InfBandedMatrix, InfBandCartesianIndices,
5-
rightasymptotics, QLHessenberg, ConstRows, PertConstRows,
5+
rightasymptotics, QLHessenberg, ConstRows, PertConstRows, chop, chop!,
66
BandedToeplitzLayout, PertToeplitzLayout, TridiagonalToeplitzLayout, BidiagonalToeplitzLayout
77
import Base: BroadcastStyle
88
import BlockArrays: _BlockArray
@@ -16,11 +16,17 @@ import LazyBandedMatrices: BroadcastBandedBlockBandedLayout, BroadcastBandedLayo
1616
@testset "chop" begin
1717
a = randn(5)
1818
b = [a; zeros(5)]
19-
InfiniteLinearAlgebra.chop!(b, eps())
19+
chop!(b, eps())
2020
@test b == a
2121

22+
@test isempty(chop!([0]))
23+
2224
A = randn(5,5)
23-
@test InfiniteLinearAlgebra.chop([A zeros(5,2); zeros(2,5) zeros(2,2)],eps()) == A
25+
@test chop([A zeros(5,2); zeros(2,5) zeros(2,2)],eps()) == A
26+
27+
c = PseudoBlockArray([randn(5); zeros(10)], (blockedrange(1:5),))
28+
d = chop!(c, 0);
29+
@test length(d) == 6
2430
end
2531

2632
include("test_infconv.jl")

test/test_infbanded.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,10 @@ import BandedMatrices: _BandedMatrix
158158
H = ApplyArray(hvcat, (2,2), 1, [1 Zeros(1,∞)], [1; Zeros(∞)], Diagonal(1:∞))
159159
@test_broken bandwidths(H) == (1,1)
160160
end
161+
162+
@testset "Banded * PaddedMatrix" begin
163+
A = Eye(∞)[2:∞,:]
164+
B = PaddedArray(randn(3,3),ℵ₀,ℵ₀)
165+
@test (A*B)[1:10,1:10] A[1:10,1:10] * B[1:10,1:10]
166+
end
161167
end

0 commit comments

Comments
 (0)