Skip to content

Commit 66954a0

Browse files
authored
Merge branch 'master' into versioninfo_type_stability
2 parents 3bee465 + 84fd21b commit 66954a0

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
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)

src/bidiag.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,19 +1250,19 @@ end
12501250
ldiv!(A::Bidiagonal, b::AbstractVecOrMat) = @inline ldiv!(b, A, b)
12511251
function ldiv!(c::AbstractVecOrMat, A::Bidiagonal, b::AbstractVecOrMat)
12521252
require_one_based_indexing(c, A, b)
1253-
N = size(A, 2)
1253+
N = size(A, 1)
12541254
mb, nb = size(b, 1), size(b, 2)
12551255
if N != mb
1256-
throw(DimensionMismatch(lazy"second dimension of A, $N, does not match first dimension of b, $mb"))
1256+
dimstr = b isa AbstractVector ? "length" : "first dimension"
1257+
throw(DimensionMismatch(LazyString(lazy"the first dimension of the Bidiagonal matrix, $N, ",
1258+
lazy"does not match the $dimstr of the right-hand-side, $mb")))
12571259
end
12581260
mc, nc = size(c, 1), size(c, 2)
12591261
if mc != mb || nc != nb
1260-
throw(DimensionMismatch(lazy"size of result, ($mc, $nc), does not match the size of b, ($mb, $nb)"))
1262+
throw(DimensionMismatch(lazy"size of result, $(size(c)), does not match the size of b, $(size(b))"))
12611263
end
12621264

1263-
if N == 0
1264-
return copyto!(c, b)
1265-
end
1265+
N == 0 && return c # in this case c and b are also empty
12661266

12671267
zi = findfirst(iszero, A.dv)
12681268
isnothing(zi) || throw(SingularException(zi))

test/bidiag.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,9 @@ Random.seed!(1)
362362
@test (x\T)::typediv x\TM
363363
@test (T/x)::typediv TM/x
364364
if !isa(x, Number)
365-
@test Array((T\x)::typediv2) Array(TM\x)
366-
@test Array((x/T)::typediv2) Array(x/TM)
365+
U = T.uplo == 'U' ? UpperTriangular : LowerTriangular
366+
@test Array((T\x)::typediv2) Array(U(TM)\x)
367+
@test Array((x/T)::typediv2) Array(x/U(TM))
367368
end
368369
return nothing
369370
end
@@ -1180,4 +1181,15 @@ end
11801181
@test !isreal(im*M)
11811182
end
11821183

1184+
@testset "ldiv! error message" begin
1185+
C = zeros(2)
1186+
B = Bidiagonal(1:0, 1:0, :U)
1187+
msg = "size of result, (2,), does not match the size of b, (0, 1)"
1188+
@test_throws msg ldiv!(C, B, zeros(0,1))
1189+
msg = "the first dimension of the Bidiagonal matrix, 0, does not match the length of the right-hand-side, 2"
1190+
@test_throws msg ldiv!(C, B, zeros(2))
1191+
msg = "the first dimension of the Bidiagonal matrix, 0, does not match the first dimension of the right-hand-side, 2"
1192+
@test_throws msg ldiv!(C, B, zeros(2,1))
1193+
end
1194+
11831195
end # module TestBidiagonal

test/runtests.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,18 @@ end
99
@testset "Docstrings" begin
1010
@test isempty(Docs.undocumented_names(LinearAlgebra))
1111
end
12+
13+
@testset "versioninfo" begin
14+
vinfo = sprint(LinearAlgebra.versioninfo)
15+
@test occursin("Threading:", vinfo)
16+
@test occursin(r"Threads.threadpoolsize\(\) = [0-9]+", vinfo)
17+
@test occursin(r"Threads.maxthreadid\(\) = [0-9]+", vinfo)
18+
@test occursin(r"LinearAlgebra.BLAS.get_num_threads\(\) = [0-9]+", vinfo)
19+
@test occursin("Relevant environment variables:", vinfo)
20+
vars = strip(split(vinfo, "Relevant environment variables:")[end])
21+
@test any(occursin(vars), [r"JULIA_NUM_THREADS = [0-9]+", r"MKL_DYNAMIC = [0-9]+",
22+
r"MKL_NUM_THREADS = [0-9]+",
23+
r"OPENBLAS_NUM_THREADS = [0-9]+",
24+
r"GOTO_NUM_THREADS = [0-9]+",
25+
r"OMP_NUM_THREADS = [0-9]+", r"\[none\]"])
26+
end

0 commit comments

Comments
 (0)