Skip to content

Commit

Permalink
Merge pull request #27 from louisponet/resize_fixes
Browse files Browse the repository at this point in the history
Resize fixes
  • Loading branch information
MichelJuillard authored Aug 22, 2022
2 parents 9da48bd + dab8957 commit 9e4d442
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 272 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

2 comments on commit 9e4d442

@MichelJuillard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/66744

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.5 -m "<description of version>" 9e4d4421423970f3220d03fc83854cf25c6c1eff
git push origin v1.2.5

Please sign in to comment.