-
Notifications
You must be signed in to change notification settings - Fork 4
/
rpca_admm_kernel.cu
55 lines (43 loc) · 1.11 KB
/
rpca_admm_kernel.cu
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "rpca_admm_kernel.cuh"
__global__ void nodiag_normalize(float *A, float *I, int n, int i){
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if (x < n && y < n)
if (x == i && x!=y){
I[x*n + y] /= A[i*n + i];
A[x*n + y] /= A[i*n + i];
}
}
__global__ void diag_normalize(float *A, float *I, int n, int i){
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if (x < n && y < n)
if (x == y && x == i){
I[x*n + y] /= A[i*n + i];
A[x*n + y] /= A[i*n + i];
}
}
__global__ void gaussjordan(float *A, float *I, int n, int i)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if (x < n && y < n){
if (x != i){
I[x*n + y] -= I[i*n + y] * A[x*n + i];
if (y != i){
A[x*n + y] -= A[i*n + y] * A[x*n + i];
}
}
}
}
__global__ void set_zero(float *A, float *I, int n, int i){
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if (x < n && y < n){
if (x != i){
if (y == i){
A[x*n + y] = 0;
}
}
}
}