Skip to content

Commit 9b37d8c

Browse files
authored
Removed MulBandedLayout, removed print (#33)
* Removed MulBandedLayout, removed print * Update Project.toml * Cumsum for InfRanges * Update Project.toml
1 parent e381395 commit 9b37d8c

File tree

6 files changed

+35
-39
lines changed

6 files changed

+35
-39
lines changed

Project.toml

Lines changed: 9 additions & 9 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.3"
3+
version = "0.3.4"
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.3"
20-
BandedMatrices = "0.15.7"
21-
BlockArrays = "0.12.6"
22-
BlockBandedMatrices = "0.8.4"
23-
FillArrays = "0.8.8"
24-
InfiniteArrays = "0.7"
25-
LazyArrays = "0.16.8"
26-
LazyBandedMatrices = "0.2.8"
19+
ArrayLayouts = "0.3.4"
20+
BandedMatrices = "0.15.11"
21+
BlockArrays = "0.12.7"
22+
BlockBandedMatrices = "0.8.5"
23+
FillArrays = "0.8.10"
24+
InfiniteArrays = "0.7.2"
25+
LazyArrays = "0.16.12"
26+
LazyBandedMatrices = "0.2.11"
2727
MatrixFactorizations = "0.4.1"
2828
SemiseparableMatrices = "0.1"
2929
julia = "1.3"

src/InfiniteLinearAlgebra.jl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ module InfiniteLinearAlgebra
22
using BlockArrays, BlockBandedMatrices, BandedMatrices, LazyArrays, LazyBandedMatrices, SemiseparableMatrices,
33
FillArrays, InfiniteArrays, MatrixFactorizations, ArrayLayouts, LinearAlgebra
44

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

10-
import ArrayLayouts: colsupport, rowsupport, triangularlayout, MatLdivVec, triangulardata, TriangularLayout, sublayout, _qr,
10+
import ArrayLayouts: colsupport, rowsupport, triangularlayout, MatLdivVec, triangulardata, TriangularLayout, sublayout, _qr,
1111
MatLmulVec, MatLmulMat, AbstractQLayout, materialize!
1212
import BandedMatrices: BandedMatrix, _BandedMatrix, AbstractBandedMatrix, bandeddata, bandwidths, BandedColumns, bandedcolumns,
1313
_default_banded_broadcast
14-
import FillArrays: AbstractFill, getindex_value
15-
import InfiniteArrays: OneToInf, InfUnitRange, Infinity, InfStepRange, AbstractInfUnitRange, InfAxes
14+
import FillArrays: AbstractFill, getindex_value, axes_print_matrix_row
15+
import InfiniteArrays: OneToInf, InfUnitRange, Infinity, InfStepRange, AbstractInfUnitRange, InfAxes
1616
import LinearAlgebra: lmul!, ldiv!, matprod, qr, AbstractTriangular, AbstractQ, adjoint, transpose
1717
import LazyArrays: applybroadcaststyle, CachedArray, CachedMatrix, CachedVector, DenseColumnMajor, FillLayout, ApplyMatrix, check_mul_axes, ApplyStyle, LazyArrayApplyStyle, LazyArrayStyle,
1818
resizedata!, MemoryLayout, mulapplystyle, LmulStyle, RmulStyle,
@@ -26,7 +26,7 @@ import BlockArrays: AbstractBlockVecOrMat, sizes_from_blocks, _length, BlockedUn
2626

2727
import BandedMatrices: BandedMatrix, bandwidths, AbstractBandedLayout, _banded_qr!, _banded_qr, _BandedMatrix
2828

29-
import LazyBandedMatrices: MulBandedLayout, BroadcastBandedLayout, _krontrav_axes
29+
import LazyBandedMatrices: ApplyBandedLayout, BroadcastBandedLayout, _krontrav_axes
3030

3131
import BlockBandedMatrices: _BlockSkylineMatrix, _BandedMatrix, _BlockSkylineMatrix, blockstart, blockstride,
3232
BlockSkylineSizes, BlockSkylineMatrix, BlockBandedMatrix, _BlockBandedMatrix, BlockTridiagonal,
@@ -41,7 +41,7 @@ LazyArrays.@lazymul BandedMatrix{<:Any,<:Any,<:OneToInf}
4141
# BroadcastStyle(::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}) = LazyArrayStyle{2}()
4242

4343
function ^(A::BandedMatrix{T,<:Any,<:OneToInf}, p::Integer) where T
44-
if p < 0
44+
if p < 0
4545
inv(A)^(-p)
4646
elseif p == 0
4747
Eye{T}(∞)
@@ -66,18 +66,24 @@ include("infqr.jl")
6666
# block broadcasted
6767
######
6868

69-
const CumsumOneToInf2 = BroadcastArray{Int64,1,typeof(div),Tuple{BroadcastArray{Int64,1,typeof(*),Tuple{InfiniteArrays.OneToInf{Int64},InfiniteArrays.InfUnitRange{Int64}}},Int64}}
69+
const CumsumOneToInf2 = Cumsum{<:Any,1,<:OneToInf}
7070
BlockArrays.sortedunion(a::CumsumOneToInf2, ::CumsumOneToInf2) = a
7171

72+
function BlockArrays.sortedunion(a::Vcat{Int,1,<:Tuple{<:AbstractVector{Int},InfStepRange{Int,Int}}},
73+
b::Vcat{Int,1,<:Tuple{<:AbstractVector{Int},InfStepRange{Int,Int}}})
74+
@assert a == b
75+
a
76+
end
77+
7278

7379
map(::typeof(length), A::BroadcastArray{OneTo{Int},1,Type{OneTo}}) = A.args[1]
74-
map(::typeof(length), A::BroadcastArray{<:Fill,1,Type{Fill}}) = A.args[2]
75-
map(::typeof(length), A::BroadcastArray{<:Zeros,1,Type{Zeros}}) = A.args[1]
80+
map(::typeof(length), A::BroadcastArray{<:Fill,1,Type{Fill}}) = A.args[2]
81+
map(::typeof(length), A::BroadcastArray{<:Zeros,1,Type{Zeros}}) = A.args[1]
7682
map(::typeof(length), A::BroadcastArray{<:Vcat,1,Type{Vcat}}) = broadcast(+,map.(length,A.args)...)
7783
broadcasted(::LazyArrayStyle{1}, ::typeof(length), A::BroadcastArray{OneTo{Int},1,Type{OneTo}}) =
7884
A.args[1]
7985
broadcasted(::LazyArrayStyle{1}, ::typeof(length), A::BroadcastArray{<:Fill,1,Type{Fill}}) =
80-
A.args[2]
86+
A.args[2]
8187

8288
BlockArrays._length(::BlockedUnitRange, ::OneToInf) =
8389
BlockArrays._last(::BlockedUnitRange, ::OneToInf) =
@@ -86,8 +92,8 @@ BlockArrays._last(::BlockedUnitRange, ::OneToInf) = ∞
8692
# KronTrav
8793
###
8894

89-
_krontrav_axes(A::NTuple{N,OneToInf{Int}}, B::NTuple{N,OneToInf{Int}}) where N =
95+
_krontrav_axes(A::NTuple{N,OneToInf{Int}}, B::NTuple{N,OneToInf{Int}}) where N =
9096
@. blockedrange(OneTo(length(A)))
9197

92-
98+
9399
end # module

src/banded/infbanded.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ _BandedMatrix(::PertToeplitzLayout, A::AbstractMatrix) =
328328
# end
329329

330330

331-
@inline sub_materialize(::MulBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = V
331+
@inline sub_materialize(::ApplyBandedLayout{typeof(*)}, V, ::Tuple{InfAxes,InfAxes}) = V
332332
@inline sub_materialize(::BroadcastBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = V
333333
@inline sub_materialize(::AbstractBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = BandedMatrix(V)
334334
@inline sub_materialize(::BandedColumns, V, ::Tuple{InfAxes,InfAxes}) = BandedMatrix(V)

src/blockbanded/infblocktridiagonal.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,10 @@ sizes_from_blocks(A::Diagonal, ::NTuple{2,OneToInf{Int}}) = size.(A.diag, 1), si
3434

3535
sizes_from_blocks(A::Tridiagonal, ::NTuple{2,OneToInf{Int}}) = size.(A.d, 1), size.(A.d,2)
3636

37-
print_matrix_row(io::IO,
38-
X::AbstractBlockVecOrMat, A::Vector,
39-
i::Integer, cols::AbstractVector{<:Infinity}, sep::AbstractString) = nothing
37+
axes_print_matrix_row(_, io, X, A, i, ::AbstractVector{<:Infinity}, sep) = nothing
38+
axes_print_matrix_row(::NTuple{2,BlockedUnitRange}, io, X, A, i, ::AbstractVector{<:Infinity}, sep) = nothing
39+
4040

41-
print_matrix_row(io::IO,
42-
X::Union{AbstractTriangular{<:Any,<:AbstractBlockMatrix},
43-
Symmetric{<:Any,<:AbstractBlockMatrix},
44-
Hermitian{<:Any,<:AbstractBlockMatrix}}, A::Vector,
45-
i::Integer, cols::AbstractVector{<:Infinity}, sep::AbstractString) = nothing
46-
4741
function BlockSkylineSizes(A::BlockTriPertToeplitz, (l,u)::NTuple{2,Int})
4842
N = max(length(A.blocks.du.args[1])+1,length(A.blocks.d.args[1]),length(A.blocks.dl.args[1]))
4943
block_sizes = Vector{Int}(undef, N) # assume square

src/infqr.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ end
8787
partialqr!(F::AdaptiveQRData{<:Any,<:BlockSkylineMatrix}, n::Int) =
8888
partialqr!(F, findblock(axes(F.data,2), n))
8989

90-
struct AdaptiveQRFactors{T,DM<:AbstractMatrix{T},M<:AbstractMatrix{T}} <: AbstractMatrix{T}
90+
struct AdaptiveQRFactors{T,DM<:AbstractMatrix{T},M<:AbstractMatrix{T}} <: LayoutMatrix{T}
9191
data::AdaptiveQRData{T,DM,M}
9292
end
9393

@@ -128,12 +128,7 @@ rowsupport(F::QRPackedQ{<:Any,<:AdaptiveQRFactors}, j) = rowsupport(F.factors, j
128128
blockcolsupport(F::QRPackedQ{<:Any,<:AdaptiveQRFactors}, j) = blockcolsupport(F.factors, j)
129129

130130

131-
Base.replace_in_print_matrix(A::AdaptiveQRFactors, i::Integer, j::Integer, s::AbstractString) =
132-
i in colsupport(A,j) ? s : Base.replace_with_centered_mark(s)
133-
Base.replace_in_print_matrix(A::UpperTriangular{<:Any,<:AdaptiveQRFactors}, i::Integer, j::Integer, s::AbstractString) =
134-
i in colsupport(A,j) ? s : Base.replace_with_centered_mark(s)
135-
136-
struct AdaptiveQRTau{T,DM<:AbstractMatrix{T},M<:AbstractMatrix{T}} <: AbstractVector{T}
131+
struct AdaptiveQRTau{T,DM<:AbstractMatrix{T},M<:AbstractMatrix{T}} <: LayoutVector{T}
137132
data::AdaptiveQRData{T,DM,M}
138133
end
139134

test/test_infqr.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ import SemiseparableMatrices: AlmostBandedLayout, VcatAlmostBandedLayout
221221
@test (F.Q*[1;zeros(∞)])[1:6] [-0.9701425001453321,0,0.24253562503633297,0,0,0]
222222

223223
u = F \ [1; zeros(∞)]
224+
@test blockisequal(axes(A,2),axes(u,1))
224225
@test (A*u)[1:10] [1; zeros(9)]
225226

226227
x = 0.1
@@ -232,14 +233,14 @@ import SemiseparableMatrices: AlmostBandedLayout, VcatAlmostBandedLayout
232233

233234
@test dot(u[getindex.(Block.(1:50),1)], sin.((1:50) .* θ)/sin(θ)) 1/(x-2)
234235

235-
236236
L = A+B;
237237
@test MemoryLayout(L) isa BroadcastBandedBlockBandedLayout{typeof(+)}
238238
V = view(L,Block.(1:400),Block.(1:400))
239239
@time u = L \ [1;zeros(∞)]
240240

241241
x,y = 0.1,0.2
242242
θ,φ = acos(x),acos(y)
243+
@test u[Block.(1:50)] isa PseudoBlockArray
243244
@test (sin.((1:50) .* φ)/sin(φ))' * InvDiagTrav(u[Block.(1:50)]) * sin.((1:50) .* θ)/sin(θ) 1/(x+y-4)
244245
@test (L*u)[1:10] [1; zeros(9)]
245246

0 commit comments

Comments
 (0)