Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lloyd Aggregation and Dirichlet Nodes #274

Open
Alexey-Voronin opened this issue Jun 6, 2021 · 0 comments
Open

Lloyd Aggregation and Dirichlet Nodes #274

Alexey-Voronin opened this issue Jun 6, 2021 · 0 comments

Comments

@Alexey-Voronin
Copy link

Alexey-Voronin commented Jun 6, 2021

Some of the matrices that I deal with contain rows with only 1's not diagonal, corresponding to Dirichlet boundary conditions. I found that Lloyd aggregation randomly picks some of them to be the seeds for the aggregates, which is not desirable behavior.

pyamg/pyamg/graph.py

Lines 191 to 201 in 83b4851

G = asgraph(G)
N = G.shape[0]
if G.dtype.kind == 'c':
# complex dtype
G = np.abs(G)
# interpret seeds argument
if np.isscalar(seeds):
seeds = np.random.permutation(N)[:seeds]
seeds = seeds.astype('intc')

I included a couple of lines of code on line 199 to help avoid this behavior.

     if np.isscalar(seeds):
         indptr = G.indptr
         nodes = np.where(indptr[1:]-indptr[:-1] > 1)[0]
         seeds = np.random.permutation(nodes)[:seeds]
         seeds = seeds.astype('intc')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant