diff --git a/src/banded/BandedLU.jl b/src/banded/BandedLU.jl index 07f9aeb7..6dfafa00 100644 --- a/src/banded/BandedLU.jl +++ b/src/banded/BandedLU.jl @@ -79,9 +79,11 @@ checksquare(A::BandedLU) = (A.m == size(A.data, 2) || # Returns the narrowest blas type given the eltypes of A and b in A*x=b function _promote_to_blas_type(::Type{T}, ::Type{S}) where {T<:Number, S<:Number} TS = Base.promote_op(/, T, S) - # promote to narrowest type - TS <: Complex && return Base.promote_op(/, TS, ComplexF32) - TS <: AbstractFloat && return Base.promote_op(/, TS, Float32) + if TS ≠ Union{} + # promote to narrowest type + TS <: Complex && return Base.promote_op(/, TS, ComplexF32) + TS <: AbstractFloat && return Base.promote_op(/, TS, Float32) + end error("Cannot convert objects of element type $(T), $(S) to a `BlasFloat` type") end diff --git a/test/test_bandedlu.jl b/test/test_bandedlu.jl index 34151a4e..5fe7e8ea 100644 --- a/test/test_bandedlu.jl +++ b/test/test_bandedlu.jl @@ -31,7 +31,6 @@ cldiv!(A, b) = ldiv!(adjoint(A), b) @test BandedMatrices._promote_to_blas_type(typ, Int16) == typ @test BandedMatrices._promote_to_blas_type(typ, Int8) == typ - @test_throws ErrorException BandedMatrices._promote_to_blas_type(_foo, Float64) end diff --git a/test/test_broadcasting.jl b/test/test_broadcasting.jl index 0b38ae0b..39ef6f15 100644 --- a/test/test_broadcasting.jl +++ b/test/test_broadcasting.jl @@ -141,11 +141,17 @@ using BandedMatrices, LinearAlgebra, LazyArrays, Test A = brand(5,5,1,1) A.data .= NaN lmul!(0.0,A) + @test isnan(norm(A)) == isnan(norm(lmul!(0.0,[NaN]))) + + lmul!(false,A) @test norm(A) == 0.0 A = brand(5,5,1,1) A.data .= NaN rmul!(A,0.0) + @test isnan(norm(A)) == isnan(norm(rmul!([NaN],0.0))) + + rmul!(A,false) @test norm(A) == 0.0 n = 100