-
Notifications
You must be signed in to change notification settings - Fork 210
/
dense_generic.jl
37 lines (34 loc) · 1.07 KB
/
dense_generic.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using CUDA.CUSOLVER
using LinearAlgebra
n = 10
p = 5
@testset "elty = $elty" for elty in [Float32, Float64, ComplexF32, ComplexF64]
@testset "sytrs!" begin
for uplo in ('L', 'U')
A = rand(elty,n,n)
B = rand(elty,n,p)
A = A + A'
d_A = CuMatrix(A)
d_B = CuMatrix(B)
d_A, d_ipiv, _ = CUSOLVER.sytrf!(uplo, d_A)
d_ipiv = CuVector{Int64}(d_ipiv)
A, ipiv, _ = LinearAlgebra.sytrf!(uplo, A)
CUSOLVER.sytrs!(uplo, d_A, d_ipiv, d_B)
LinearAlgebra.sytrs!(uplo, A, ipiv, B)
@test B ≈ collect(d_B)
end
end
@testset "trtri!" begin
for uplo in ('L', 'U')
for diag in ('N', 'U')
A = rand(elty,n,n)
A = uplo == 'L' ? tril(A) : triu(A)
A = diag == 'N' ? A : A - Diagonal(A) + I
d_A = CuMatrix(A)
d_B = copy(d_A)
CUSOLVER.trtri!(uplo, diag, d_B)
@test collect(d_A * d_B) ≈ I
end
end
end
end