Skip to content

Commit 79650d3

Browse files
authored
Revert "Use BLAS.trsm! instead of LAPACK.trtrs! in left-triangular solves" (#1239)
Reverts #1194 since it introduced a bug into BaseBenchmarks
2 parents b7bffc1 + 15bb46a commit 79650d3

File tree

4 files changed

+5
-25
lines changed

4 files changed

+5
-25
lines changed

Diff for: src/blas.jl

+1-12
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ export
8484
trsm!,
8585
trsm
8686

87-
using ..LinearAlgebra: libblastrampoline, BlasReal, BlasComplex, BlasFloat, BlasInt,
88-
DimensionMismatch, checksquare, chkstride1, SingularException
87+
using ..LinearAlgebra: libblastrampoline, BlasReal, BlasComplex, BlasFloat, BlasInt, DimensionMismatch, checksquare, chkstride1
8988

9089
include("lbt.jl")
9190

@@ -1378,11 +1377,6 @@ for (fname, elty) in ((:dtrsv_,:Float64),
13781377
throw(DimensionMismatch(lazy"size of A is $n != length(x) = $(length(x))"))
13791378
end
13801379
chkstride1(A)
1381-
if diag == 'N'
1382-
for i in 1:n
1383-
iszero(A[i,i]) && throw(SingularException(i))
1384-
end
1385-
end
13861380
px, stx = vec_pointer_stride(x, ArgumentError("input vector with 0 stride is not allowed"))
13871381
GC.@preserve x ccall((@blasfunc($fname), libblastrampoline), Cvoid,
13881382
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{BlasInt},
@@ -2231,11 +2225,6 @@ for (mmname, smname, elty) in
22312225
end
22322226
chkstride1(A)
22332227
chkstride1(B)
2234-
if diag == 'N'
2235-
for i in 1:k
2236-
iszero(A[i,i]) && throw(SingularException(i))
2237-
end
2238-
end
22392228
ccall((@blasfunc($smname), libblastrampoline), Cvoid,
22402229
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{UInt8},
22412230
Ref{BlasInt}, Ref{BlasInt}, Ref{$elty}, Ptr{$elty},

Diff for: src/triangular.jl

+3-5
Original file line numberDiff line numberDiff line change
@@ -1223,13 +1223,11 @@ function generic_mattrimul!(C::StridedMatrix{T}, uploc, isunitc, tfun::Function,
12231223
end
12241224
end
12251225
# division
1226-
generic_trimatdiv!(C::StridedVector{T}, uploc, isunitc, tfun::Function, A::StridedMatrix{T}, B::AbstractVector{T}) where {T<:BlasFloat} =
1227-
BLAS.trsv!(uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, A, C === B ? C : copyto!(C, B))
1228-
function generic_trimatdiv!(C::StridedMatrix{T}, uploc, isunitc, tfun::Function, A::StridedMatrix{T}, B::AbstractMatrix{T}) where {T<:BlasFloat}
1226+
function generic_trimatdiv!(C::StridedVecOrMat{T}, uploc, isunitc, tfun::Function, A::StridedMatrix{T}, B::AbstractVecOrMat{T}) where {T<:BlasFloat}
12291227
if stride(C,1) == stride(A,1) == 1
1230-
BLAS.trsm!('L', uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, one(T), A, C === B ? C : copyto!(C, B))
1228+
LAPACK.trtrs!(uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, A, C === B ? C : copyto!(C, B))
12311229
else # incompatible with LAPACK
1232-
@invoke generic_trimatdiv!(C::AbstractVecOrMat, uploc, isunitc, tfun::Function, A::AbstractMatrix, B::AbstractMatrix)
1230+
@invoke generic_trimatdiv!(C::AbstractVecOrMat, uploc, isunitc, tfun::Function, A::AbstractMatrix, B::AbstractVecOrMat)
12331231
end
12341232
end
12351233
function generic_mattridiv!(C::StridedMatrix{T}, uploc, isunitc, tfun::Function, A::AbstractMatrix{T}, B::StridedMatrix{T}) where {T<:BlasFloat}

Diff for: test/testtriag.jl

-2
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,6 @@ function test_triangular(elty1_types)
493493
@test_throws DimensionMismatch transpose(Ann) \ bm
494494
if t1 == UpperTriangular || t1 == LowerTriangular
495495
@test_throws SingularException ldiv!(t1(zeros(elty1, n, n)), fill(eltyB(1), n))
496-
@test_throws SingularException ldiv!(t1(zeros(elty1, n, n)), fill(eltyB(1), n, 2))
497-
@test_throws SingularException rdiv!(fill(eltyB(1), n, n), t1(zeros(elty1, n, n)))
498496
end
499497
@test B / A1 B / M1
500498
@test B / transpose(A1) B / transpose(M1)

Diff for: test/triangular.jl

+1-6
Original file line numberDiff line numberDiff line change
@@ -891,13 +891,8 @@ end
891891
end
892892
end
893893

894-
@testset "(l/r)mul! and (l/r)div! for non-contiguous arrays" begin
894+
@testset "(l/r)mul! and (l/r)div! for non-contiguous matrices" begin
895895
U = UpperTriangular(reshape(collect(3:27.0),5,5))
896-
b = float.(1:10)
897-
b2 = copy(b); b2v = view(b2, 1:2:9); b2vc = copy(b2v)
898-
@test lmul!(U, b2v) == lmul!(U, b2vc)
899-
b2 = copy(b); b2v = view(b2, 1:2:9); b2vc = copy(b2v)
900-
@test ldiv!(U, b2v) ldiv!(U, b2vc)
901896
B = float.(collect(reshape(1:100, 10,10)))
902897
B2 = copy(B); B2v = view(B2, 1:2:9, 1:5); B2vc = copy(B2v)
903898
@test lmul!(U, B2v) == lmul!(U, B2vc)

0 commit comments

Comments
 (0)