Skip to content

Commit

Permalink
Bumped version, fixed resizes, added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Aug 21, 2022
1 parent 9da48bd commit cdd20bd
Show file tree
Hide file tree
Showing 15 changed files with 283 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
version:
- '1.6'
- '1.8.0-rc1'
- '1.8.0'
- 'nightly'
os:
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FastLapackInterface"
uuid = "29a986be-02c6-4525-aec4-84b980013641"
authors = ["Louis Ponet, Michel Juillard"]
version = "1.2.4"
version = "1.2.5"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion src/FastLapackInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ else
end

abstract type Workspace end

include("exceptions.jl")
include("lu.jl")
export LUWs
include("qr.jl")
Expand Down
25 changes: 14 additions & 11 deletions src/bunch_kaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,22 @@ for (sytrfs, elty) in
((:csytrf_,:csytrf_rook_, :chetrf_,:chetrf_rook_),:ComplexF32))

@eval begin
function Base.resize!(ws::BunchKaufmanWs, A::AbstractMatrix{$elty})
function Base.resize!(ws::BunchKaufmanWs, A::AbstractMatrix{$elty}; work = true)
chkstride1(A)
n = checksquare(A)
if n == 0
return ws
end
resize!(ws.ipiv, n)
info = Ref{BlasInt}()
ccall((@blasfunc($(sytrfs[1])), liblapack), Cvoid,
(Ref{UInt8}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
Ptr{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ptr{BlasInt}, Clong),
'U', n, A, stride(A,2), ws.ipiv, ws.work, -1, info, 1)
chkargsok(info[])
resize!(ws.work, BlasInt(real(ws.work[1])))
if work
info = Ref{BlasInt}()
ccall((@blasfunc($(sytrfs[1])), liblapack), Cvoid,
(Ref{UInt8}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
Ptr{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ptr{BlasInt}, Clong),
'U', n, A, stride(A,2), ws.ipiv, ws.work, -1, info, 1)
chkargsok(info[])
resize!(ws.work, BlasInt(real(ws.work[1])))
end
return ws
end
function BunchKaufmanWs(A::AbstractMatrix{$elty})
Expand All @@ -110,11 +112,12 @@ for (sytrfs, elty) in
return A, ws.ipiv, zero(BlasInt)
end
chkuplo(uplo)
if n > length(ws.ipiv)
nws = length(ws.ipiv)
if n != nws
if resize
resize!(ws, A)
resize!(ws, A, work=nws<n)
else
throw(ArgumentError("Workspace is too small, use resize!(ws, A)."))
throw(WorkspaceSizeError(nws, n))
end
end
info = Ref{BlasInt}()
Expand Down
13 changes: 8 additions & 5 deletions src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ for (pstrf, elty, rtyp) in
(:zpstrf_,:ComplexF64,:Float64),
(:cpstrf_,:ComplexF32,:Float32))
@eval begin
function Base.resize!(ws::CholeskyPivotedWs, A::AbstractMatrix{$elty})
function Base.resize!(ws::CholeskyPivotedWs, A::AbstractMatrix{$elty}; work = true)
n = checksquare(A)
resize!(ws.work, 2n)
resize!(ws.piv, n)
if work
resize!(ws.work, 2n)
end
return ws
end
function CholeskyPivotedWs(A::AbstractMatrix{$elty})
Expand All @@ -61,11 +63,12 @@ for (pstrf, elty, rtyp) in
chkuplo(uplo)
rank = Ref{BlasInt}()
info = Ref{BlasInt}()
if length(ws.piv) < n
nws = length(ws.piv)
if nws != n
if resize
resize!(ws, A)
resize!(ws, A; work = nws < n)
else
throw(ArgumentError("Workspace is too small, use resize!(ws, A)."))
throw(WorkspaceSizeError(nws, n))
end
end

Expand Down
Loading

0 comments on commit cdd20bd

Please sign in to comment.