Skip to content

Commit 243efdb

Browse files
authored
AbstractQ bugfix: define Base.IteratorSize (#1277)
This used to incorrectly fall back to `HasLength`. The correct type is `HasShape{2}`, as `AbstractQ` is two-dimensional. Makes the `collect` method unnecessary.
1 parent 6073f28 commit 243efdb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/abstractq.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ end
99
parent(adjQ::AdjointQ) = adjQ.Q
1010
eltype(::Type{<:AbstractQ{T}}) where {T} = T
1111
Base.eltypeof(Q::AbstractQ) = eltype(Q)
12+
Base.IteratorSize(::Type{<:AbstractQ}) = Base.HasShape{2}()
1213
ndims(::AbstractQ) = 2
1314

1415
# inversion/adjoint/transpose
@@ -40,7 +41,6 @@ convert(::Type{AbstractQ{T}}, adjQ::AdjointQ{T}) where {T} = adjQ
4041
convert(::Type{AbstractQ{T}}, adjQ::AdjointQ) where {T} = convert(AbstractQ{T}, adjQ.Q)'
4142

4243
# ... to matrix
43-
collect(Q::AbstractQ) = copyto!(Matrix{eltype(Q)}(undef, size(Q)), Q)
4444
Matrix{T}(Q::AbstractQ) where {T} = convert(Matrix{T}, Q*I) # generic fallback, yields square matrix
4545
Matrix{T}(adjQ::AdjointQ{S}) where {T,S} = convert(Matrix{T}, lmul!(adjQ, Matrix{S}(I, size(adjQ))))
4646
Matrix(Q::AbstractQ{T}) where {T} = Matrix{T}(Q)

0 commit comments

Comments
 (0)