Skip to content

Commit 504e134

Browse files
committed
Make jacobi prolongation more efficient
1 parent db32186 commit 504e134

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/smoother.jl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,26 @@ function weight(::DiagonalWeighting, S, ω)
124124
end
125125

126126
function weight(::LocalWeighting, S, ω)
127-
D = abs.(S) * ones(size(S, 1))
127+
#=D = abs.(S) * ones(eltype(S), size(S, 1))
128128
D_inv = 1 ./ D[find(D)]
129129
D_inv_S = scale_rows(S, D_inv)
130-
eltype(S)(ω) * D_inv_S
130+
eltype(S)(ω) * D_inv_S=#
131+
D = zeros(eltype(S), size(S,1))
132+
for i = 1:size(S, 1)
133+
for j in nzrange(S, i)
134+
row = S.rowval[j]
135+
val = S.nzval[j]
136+
D[row] += abs(val)
137+
end
138+
end
139+
for i = 1:size(D, 1)
140+
if D[i] != 0
141+
D[i] = 1/D[i]
142+
end
143+
end
144+
D_inv_S = scale_rows(S, D)
145+
# eltype(S)(ω) * D_inv_S
146+
scale!(D_inv_S, eltype(S)(ω))
131147
end
132148

133149
#approximate_spectral_radius(A) =

0 commit comments

Comments
 (0)