Skip to content

Commit 75ada18

Browse files
authored
Remove * overload hacks (#26)
1 parent 7bc6345 commit 75ada18

File tree

5 files changed

+25
-40
lines changed

5 files changed

+25
-40
lines changed

Project.toml

Lines changed: 5 additions & 5 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.3.0"
3+
version = "0.3.1"
44

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

1818
[compat]
19-
ArrayLayouts = "0.2.1"
20-
BandedMatrices = "0.15.1"
19+
ArrayLayouts = "0.2.4"
20+
BandedMatrices = "0.15.3"
2121
BlockArrays = "0.12"
2222
BlockBandedMatrices = "0.8"
2323
FillArrays = "0.8.6"
2424
InfiniteArrays = "0.7"
25-
LazyArrays = "0.16.4"
26-
LazyBandedMatrices = "0.2.5"
25+
LazyArrays = "0.16.5"
26+
LazyBandedMatrices = "0.2.6"
2727
MatrixFactorizations = "0.3.1"
2828
SemiseparableMatrices = "0.0.1"
2929
julia = "1.3"

src/InfiniteLinearAlgebra.jl

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using BlockArrays, BlockBandedMatrices, BandedMatrices, LazyArrays, LazyBandedMa
44

55
import Base: +, -, *, /, \, ^, OneTo, getindex, promote_op, _unsafe_getindex, print_matrix_row, size, axes,
66
AbstractMatrix, AbstractArray, Matrix, Array, Vector, AbstractVector, Slice,
7-
show, getproperty, copy, map
7+
show, getproperty, copy, map, require_one_based_indexing
88
import Base.Broadcast: BroadcastStyle, Broadcasted, broadcasted
99

1010
import ArrayLayouts: colsupport, rowsupport, triangularlayout, MatLdivVec, triangulardata, TriangularLayout, sublayout, _qr
@@ -49,13 +49,6 @@ function ^(A::BandedMatrix{T,<:Any,<:OneToInf}, p::Integer) where T
4949
end
5050
end
5151

52-
if VERSION < v"1.2-"
53-
import Base: has_offset_axes
54-
require_one_based_indexing(A...) = !has_offset_axes(A...) || throw(ArgumentError("offset arrays are not supported but got an array with index other than 1"))
55-
else
56-
import Base: require_one_based_indexing
57-
end
58-
5952
export Vcat, Fill, ql, ql!, ∞, ContinuousSpectrumError, BlockTridiagonal
6053

6154
include("banded/hessenbergq.jl")
@@ -66,29 +59,6 @@ include("banded/infqltoeplitz.jl")
6659
include("infql.jl")
6760
include("infqr.jl")
6861

69-
###
70-
# temporary work arounds
71-
###
72-
73-
# Fix ∞ BandedMatrix
74-
ApplyStyle(::typeof(*), ::Type{<:Diagonal}, ::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}) =
75-
LmulStyle()
76-
ApplyStyle(::typeof(*), ::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}, ::Type{<:Diagonal}) =
77-
RmulStyle()
78-
ApplyStyle(::typeof(*), ::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}, ::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}) =
79-
LazyArrayApplyStyle()
80-
ApplyStyle(::typeof(*), ::Type{<:AbstractArray}, ::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}) =
81-
LazyArrayApplyStyle()
82-
ApplyStyle(::typeof(*), ::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}, ::Type{<:AbstractArray}) =
83-
LazyArrayApplyStyle()
84-
ApplyStyle(::typeof(*), ::Type{<:Adjoint{<:Any,<:BandedMatrix{<:Any,<:Any,<:OneToInf}}}, ::Type{<:AbstractArray}) =
85-
LazyArrayApplyStyle()
86-
ApplyStyle(::typeof(*), ::Type{<:Transpose{<:Any,<:BandedMatrix{<:Any,<:Any,<:OneToInf}}}, ::Type{<:AbstractArray}) =
87-
LazyArrayApplyStyle()
88-
89-
ApplyStyle(::typeof(*), ::Type{<:BandedMatrix{<:Any,<:AbstractFill,<:OneToInf}}, ::Type{<:BandedMatrix{<:Any,<:AbstractFill,<:OneToInf}}) =
90-
MulAddStyle()
91-
9262
#######
9363
# block broadcasted
9464
######

src/banded/infbanded.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ _default_banded_broadcast(bc::Broadcasted, ::Tuple{<:OneToInf,<:Any}) = copy(Bro
354354
# BandedFill * BandedFill
355355
###
356356

357-
copy(M::MulAdd{BandedMatrices.BandedColumns{FillLayout},BandedMatrices.BandedColumns{FillLayout},ZerosLayout}) =
357+
copy(M::MulAdd{BandedColumns{FillLayout},BandedColumns{FillLayout},ZerosLayout}) =
358358
_bandedfill_mul(M, axes(M.A), axes(M.B))
359359

360360
_bandedfill_mul(M, _, _) = copyto!(similar(M), M)
@@ -368,4 +368,11 @@ function _bandedfill_mul(M::MulAdd, ::Tuple{InfAxes,InfAxes}, ::Tuple{InfAxes,In
368368
ret = _BandedMatrix(Hcat(Array{typeof(λ)}(undef, l+u+1,u), [1:m-1; Fill(m,l+u-2m+3); m-1:-1:1]*Fill(λ,1,∞)), ∞, l, u)
369369
mul!(view(ret, 1:l+u,1:u), view(A,1:l+u,1:u+Bl), view(B,1:u+Bl,1:u))
370370
ret
371-
end
371+
end
372+
373+
mulapplystyle(::BandedColumns{FillLayout}, ::PertToeplitzLayout) = LazyArrayApplyStyle()
374+
mulapplystyle(::PertToeplitzLayout, ::BandedColumns{FillLayout}) = LazyArrayApplyStyle()
375+
mulapplystyle(::BandedColumns{FillLayout}, ::BandedToeplitzLayout) = LazyArrayApplyStyle()
376+
mulapplystyle(::BandedToeplitzLayout, ::BandedColumns{FillLayout}) = LazyArrayApplyStyle()
377+
mulapplystyle(::QLayout, ::BandedToeplitzLayout) = LazyArrayApplyStyle()
378+
mulapplystyle(::QLayout, ::PertToeplitzLayout) = LazyArrayApplyStyle()

test/runtests.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import InfiniteLinearAlgebra: qltail, toeptail, tailiterate , tailiterate!, tail
33
InfToeplitz, PertToeplitz, TriToeplitz, InfBandedMatrix,
44
rightasymptotics, QLHessenberg, ConstRows, PertConstRows, BandedToeplitzLayout, PertToeplitzLayout
55
import Base: BroadcastStyle
6-
import BlockArrays: _BlockArray
6+
import BlockArrays: _BlockArray
77
import BlockBandedMatrices: isblockbanded, _BlockBandedMatrix
88
import MatrixFactorizations: QLPackedQ
99
import BandedMatrices: bandeddata, _BandedMatrix, BandedStyle
@@ -16,6 +16,12 @@ import InfiniteArrays: OneToInf
1616
@test B isa BandedMatrix
1717
@test B[1:10,1:10] == diagm(-1 => Fill(2,9))
1818
@test B[1:∞,2:∞] isa BandedMatrix
19+
20+
A = BandedMatrix(0 => 1:∞, 1=> Fill(2.0,∞), -1 => Fill(3.0,∞))
21+
x = [1; 2; zeros(∞)]
22+
@test ApplyStyle(*, typeof(A), typeof(x)) isa LazyArrays.MulAddStyle
23+
@test A*x isa Vcat
24+
@test (A*x)[1:10] == A[1:10,1:10]*x[1:10]
1925
end
2026

2127
@testset "∞-block arrays" begin
@@ -91,7 +97,7 @@ end
9197
A = _BandedMatrix(Fill(1,4,∞),∞,1,2)
9298
@test A*A isa BandedMatrix
9399
@test (A^2)[1:10,1:10] == (A*A)[1:10,1:10] == (A[1:100,1:100]^2)[1:10,1:10]
94-
@test (A^3)[1:10,1:10] == (A*A*A)[1:10,1:10] == (A[1:100,1:100]^3)[1:10,1:10]
100+
@test (A^3)[1:10,1:10] == (A*A*A)[1:10,1:10] == ((A*A)*A)[1:10,1:10] == (A*(A*A))[1:10,1:10] == (A[1:100,1:100]^3)[1:10,1:10]
95101
end
96102

97103
@testset "BlockTridiagonal" begin
@@ -152,6 +158,7 @@ end
152158
C = Diagonal( 2 ./ (1:2:∞))
153159
@test A*(B*C) isa MulMatrix
154160
@test bandwidths(A*(B*C)) == (-1,1)
161+
@test bandwidths((A*B)*C) == (-1,1)
155162
end
156163

157164
@testset "Triangle OP recurrences" begin

test/test_infql.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import BandedMatrices: _BandedMatrix
1313
L = _BandedMatrix(Hcat([e; X[2,2]; X[2,1]], X[2,end:-1:1] * Ones{Float64}(1,∞)), ∞, 2, 0)
1414
Qn,Ln = ql(A[1:1000,1:1000])
1515
@test Q[1:10,1:10] Qn[1:10,1:10]
16+
@test Q'A isa MulMatrix
1617
@test Array((Q'A)[1:10,1:10]) [(Q'A)[k,j] for k=1:10,j=1:10]
1718
@test (Q'A)[1:10,1:10] Ln[1:10,1:10] L[1:10,1:10]
1819

0 commit comments

Comments
 (0)