You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decompress the thin matrix `C` into the symmetric matrix `A` which must have the same sparsity pattern as `S`.
165
+
166
+
Here, `colors` is a symmetric coloring of `S`, while `C` is a compressed representation of matrix `A` obtained by summing the columns that share the same color.
167
+
"""
168
+
function decompress_symmetric! end
169
+
170
+
functiondecompress_symmetric!(
171
+
A::AbstractMatrix{R},
172
+
S::AbstractMatrix{Bool},
173
+
C::AbstractMatrix{R},
174
+
colors::AbstractVector{<:Integer},
175
+
) where {R<:Real}
176
+
A .=zero(R)
177
+
groups =color_groups(colors)
178
+
checksquare(A)
179
+
for i inaxes(A, 1), j inaxes(A, 2)
180
+
iszero(S[i, j]) &&continue
181
+
ki, kj = colors[i], colors[j]
182
+
gi, gj = groups[ki], groups[kj]
183
+
ifsum(!iszero, view(S, i, gj)) ==1
184
+
A[i, j] = C[i, kj]
185
+
elseifsum(!iszero, view(S, j, gi)) ==1
186
+
A[i, j] = C[j, ki]
187
+
else
188
+
error("Symmetric coloring is not valid")
189
+
end
190
+
end
191
+
return A
192
+
end
193
+
194
+
functiondecompress_symmetric!(
195
+
A::Symmetric{R},
196
+
S::AbstractMatrix{Bool},
197
+
C::AbstractMatrix{R},
198
+
colors::AbstractVector{<:Integer},
199
+
) where {R<:Real}
200
+
# requires parent decompression to handle both upper and lower triangles
201
+
decompress_symmetric!(parent(A), S, C, colors)
202
+
return A
203
+
end
204
+
205
+
"""
206
+
decompress_symmetric(
207
+
S::AbstractMatrix{Bool},
208
+
C::AbstractMatrix{R},
209
+
colors::AbstractVector{<:Integer}
210
+
) where {R<:Real}
211
+
212
+
Decompress the thin matrix `C` into a new symmetric matrix `A` with the same sparsity pattern as `S`.
213
+
214
+
Here, `colors` is a symmetric coloring of `S`, while `C` is a compressed representation of matrix `A` obtained by summing the columns that share the same color.
0 commit comments