-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
023c792
commit 1a81699
Showing
5 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
function LinearAlgebra.lu(A::CuSparseMatrixCSR{T}) where T <: BlasFloat | ||
n = LinearAlgebra.checksquare(A) | ||
solver = CudssSolver(A, "G", 'F') | ||
x = CudssMatrix(T, n) | ||
b = CudssMatrix(T, n) | ||
cudss("analysis", solver, x, b) | ||
cudss("factorization", solver, x, b) | ||
return solver | ||
end | ||
|
||
function LinearAlgebra.ldlt(A::CuSparseMatrixCSR{T}) where T <: BlasFloat | ||
n = LinearAlgebra.checksquare(A) | ||
structure = T <: Real ? "S" : "H" | ||
solver = CudssSolver(A, structure, 'F') | ||
(T <: Complex) && cudss_set(solver, "pivot_type", 'N') | ||
x = CudssMatrix(T, n) | ||
b = CudssMatrix(T, n) | ||
cudss("analysis", solver, x, b) | ||
cudss("factorization", solver, x, b) | ||
return solver | ||
end | ||
|
||
function LinearAlgebra.cholesky(A::CuSparseMatrixCSR{T}) where T <: BlasFloat | ||
n = LinearAlgebra.checksquare(A) | ||
structure = T <: Real ? "SPD" : "HPD" | ||
solver = CudssSolver(A, structure, 'F') | ||
x = CudssMatrix(T, n) | ||
b = CudssMatrix(T, n) | ||
cudss("analysis", solver, x, b) | ||
cudss("factorization", solver, x, b) | ||
return solver | ||
end | ||
|
||
for fun in (:lu!, :ldlt!, :cholesky!) | ||
@eval begin | ||
function LinearAlgebra.$fun(solver::CudssSolver{T}, A::CuSparseMatrixCSR{T}) where T <: BlasFloat | ||
n = LinearAlgebra.checksquare(A) | ||
cudss_set(solver.matrix, A) | ||
x = CudssMatrix(T, n) | ||
b = CudssMatrix(T, n) | ||
cudss("factorization", solver, x, b) | ||
return solver | ||
end | ||
end | ||
end | ||
|
||
for type in (:CuVector, :CuMatrix) | ||
@eval begin | ||
function LinearAlgebra.ldiv!(solver::CudssSolver{T}, b::$type{T}) where T <: BlasFloat | ||
cudss("solve", solver, b, b) | ||
end | ||
|
||
function LinearAlgebra.ldiv!(x::$type{T}, solver::CudssSolver{T}, b::$type{T}) where T <: BlasFloat | ||
cudss("solve", solver, x, b) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters