5050Base. size (A:: BlockMap ) = (last (A. rowranges[end ]), last (A. colranges[end ]))
5151
5252# ###########
53- # hcat
53+ # concatenation
5454# ###########
5555
5656for k in 1 : 8 # is 8 sufficient?
@@ -63,6 +63,32 @@ for k in 1:8 # is 8 sufficient?
6363 @eval Base. hvcat (rows:: Tuple{Vararg{Int}} , $ (Is... ), $ L, As:: Union{LinearMap,UniformScaling} ...) = _hvcat (rows, $ (args... ), As... )
6464end
6565
66+ # ###########
67+ # hcat
68+ # ###########
69+ """
70+ hcat(As::Union{LinearMap,UniformScaling}...)
71+
72+ Construct a `BlockMap <: LinearMap` object, a (lazy) representation of the
73+ horizontal concatenation of the arguments. `UniformScaling` objects are promoted
74+ to `LinearMap` automatically. To avoid fallback to the generic [`Base.hcat`](@ref),
75+ there must be a `LinearMap` object among the first 8 arguments.
76+
77+ # Examples
78+ ```jldoctest; setup=(using LinearMaps)
79+ julia> CS = LinearMap{Int}(cumsum, 3)::LinearMaps.FunctionMap;
80+
81+ julia> L = [CS LinearMap(ones(Int, 3, 3))]::LinearMaps.BlockMap;
82+
83+ julia> L * ones(Int, 6)
84+ 3-element Array{Int64,1}:
85+ 4
86+ 5
87+ 6
88+ ```
89+ """
90+ Base. hcat
91+
6692function _hcat (As:: Union{LinearMap,UniformScaling} ...)
6793 T = promote_type (map (eltype, As)... )
6894 nbc = length (As)
82108# ###########
83109# vcat
84110# ###########
111+ """
112+ vcat(As::Union{LinearMap,UniformScaling}...)
113+
114+ Construct a `BlockMap <: LinearMap` object, a (lazy) representation of the
115+ vertical concatenation of the arguments. `UniformScaling` objects are promoted
116+ to `LinearMap` automatically. To avoid fallback to the generic [`Base.vcat`](@ref),
117+ there must be a `LinearMap` object among the first 8 arguments.
118+
119+ # Examples
120+ ```jldoctest; setup=(using LinearMaps)
121+ julia> CS = LinearMap{Int}(cumsum, 3)::LinearMaps.FunctionMap;
122+
123+ julia> L = [CS; LinearMap(ones(Int, 3, 3))]::LinearMaps.BlockMap;
124+
125+ julia> L * ones(Int, 3)
126+ 6-element Array{Int64,1}:
127+ 1
128+ 2
129+ 3
130+ 3
131+ 3
132+ 3
133+ ```
134+ """
135+ Base. vcat
85136
86137function _vcat (As:: Union{LinearMap,UniformScaling} ...)
87138 T = promote_type (map (eltype, As)... )
103154# ###########
104155# hvcat
105156# ###########
157+ """
158+ hvcat(rows::Tuple{Vararg{Int}}, As::Union{LinearMap,UniformScaling}...)
159+
160+ Construct a `BlockMap <: LinearMap` object, a (lazy) representation of the
161+ horizontal-vertical concatenation of the arguments. The first argument specifies
162+ the number of arguments to concatenate in each block row. `UniformScaling` objects
163+ are promoted to `LinearMap` automatically. To avoid fallback to the generic
164+ [`Base.hvcat`](@ref), there must be a `LinearMap` object among the first 8 arguments.
165+
166+ # Examples
167+ ```jldoctest; setup=(using LinearMaps)
168+ julia> CS = LinearMap{Int}(cumsum, 3)::LinearMaps.FunctionMap;
169+
170+ julia> L = [CS CS; CS CS]::LinearMaps.BlockMap;
171+
172+ julia> L.rows
173+ (2, 2)
174+
175+ julia> L * ones(Int, 6)
176+ 6-element Array{Int64,1}:
177+ 2
178+ 4
179+ 6
180+ 2
181+ 4
182+ 6
183+ ```
184+ """
185+ Base. hvcat
106186
107187function _hvcat (rows:: Tuple{Vararg{Int}} , As:: Union{LinearMap,UniformScaling} ...)
108188 nr = length (rows)
@@ -221,6 +301,7 @@ LinearAlgebra.adjoint(A::BlockMap) = AdjointMap(A)
221301# ###########
222302
223303function A_mul_B! (y:: AbstractVector , A:: BlockMap , x:: AbstractVector )
304+ require_one_based_indexing (y, x)
224305 m, n = size (A)
225306 @boundscheck (m == length (y) && n == length (x)) || throw (DimensionMismatch (" A_mul_B!" ))
226307 maps, rows, yinds, xinds = A. maps, A. rows, A. rowranges, A. colranges
@@ -238,6 +319,7 @@ function A_mul_B!(y::AbstractVector, A::BlockMap, x::AbstractVector)
238319end
239320
240321function At_mul_B! (y:: AbstractVector , A:: BlockMap , x:: AbstractVector )
322+ require_one_based_indexing (y, x)
241323 m, n = size (A)
242324 @boundscheck (n == length (y) && m == length (x)) || throw (DimensionMismatch (" At_mul_B!" ))
243325 maps, rows, xinds, yinds = A. maps, A. rows, A. rowranges, A. colranges
@@ -262,6 +344,7 @@ function At_mul_B!(y::AbstractVector, A::BlockMap, x::AbstractVector)
262344end
263345
264346function Ac_mul_B! (y:: AbstractVector , A:: BlockMap , x:: AbstractVector )
347+ require_one_based_indexing (y, x)
265348 m, n = size (A)
266349 @boundscheck (n == length (y) && m == length (x)) || throw (DimensionMismatch (" At_mul_B!" ))
267350 maps, rows, xinds, yinds = A. maps, A. rows, A. rowranges, A. colranges
0 commit comments