pyamg.amg_core#
amg_core - a C++ implementation of AMG-related routines.
- pyamg.amg_core.apply_absolute_distance_filter()#
Return a filtered strength-of-connection matrix by applying a drop tolerance.
Strength values are assumed to be “distance”-like, i.e. the smaller the value the stronger the connection. Strength values are _Not_ evaluated relatively, i.e. an off-diagonal entry A[i,j] is a strong connection iff:
S[i,j] <= epsilon, where k != i
Also, set the diagonal to 1.0, as each node is perfectly close to itself.
- Parameters:
- Returns:
arrayModified in place such that the above dropping strategy has been applied. There will be explicit zero entries for each weak connection.
See also
distance_strength_of_connectionPrinciple calling routines are strength of connection routines.
Examples
>>> from scipy.sparse import csr_array >>> from pyamg.amg_core import apply_absolute_distance_filter >>> from scipy import array >>> # Graph in CSR where entries in row i represent distances from dof i >>> indptr = array([0,3,6,9]) >>> indices = array([0,1,2,0,1,2,0,1,2]) >>> data = array([1.,2.,3.,4.,1.,2.,3.,9.,1.]) >>> S = csr_array( (data,indices,indptr), shape=(3,3) ) >>> print "Matrix Before Applying Filter\n" + str(S.todense()) >>> apply_absolute_distance_filter(3, 1.9, S.indptr, S.indices, S.data) >>> print "Matrix After Applying Filter\n" + str(S.todense())
- pyamg.amg_core.apply_distance_filter()#
Return a filtered strength-of-connection matrix by applying a drop tolerance.
Strength values are assumed to be “distance”-like, i.e. the smaller the value the stronger the connection
An off-diagonal entry A[i,j] is a strong connection iff
S[i,j] <= epsilon * min( S[i,k] ) where k != i
Also, set the diagonal to 1.0, as each node is perfectly close to itself
- Parameters:
- Returns:
arrayModified in place such that the above dropping strategy has been applied. There will be explicit zero entries for each weak connection.
Notes
Principle calling routines are strength of connection routines, e.g. evolution_strength_of_connection(…) in strength.py. It is used to apply a drop tolerance.
Examples
>>> from scipy.sparse import csr_array >>> from pyamg.amg_core import apply_distance_filter >>> from scipy import array >>> # Graph in CSR where entries in row i represent distances from dof i >>> indptr = array([0,3,6,9]) >>> indices = array([0,1,2,0,1,2,0,1,2]) >>> data = array([1.,2.,3.,4.,1.,2.,3.,9.,1.]) >>> S = csr_array( (data,indices,indptr), shape=(3,3) ) >>> print "Matrix before Applying Filter\n" + str(S.todense()) >>> apply_distance_filter(3, 1.9, S.indptr, S.indices, S.data) >>> print "Matrix after Applying Filter\n" + str(S.todense())
- pyamg.amg_core.apply_givens()#
Apply the first nrot Givens rotations in B to x.
- Parameters:
- Returns:
Nonex is modified in place to reflect the application of the nrot rotations in B. It is assumed that the first rotation operates on degrees of freedom 0 and 1. The second rotation operates on dof’s 1 and 2, and so on.
Notes
Principle calling routines are gmres and fgmres.
- pyamg.amg_core.apply_householders()#
Apply Householder reflectors in B to z.
Implements the below python
for j in range(start,stop,step): z = z - 2.0*dot(conjugate(B[j,:]), v)*B[j,:]
- Parameters:
- Returns:
Nonez is modified in place to reflect the application of the Householder reflectors,
B[:,range(start,stop,step)].
Notes
Principle calling routines are gmres and fgmres.
- pyamg.amg_core.approx_ideal_restriction_pass1()#
Build row_pointer for approximate ideal restriction in CSR or BSR form.
- Parameters:
- Rp
array Empty row-pointer for R.
- Cp
array Row pointer for SOC matrix, C.
- Cj
array Column indices for SOC matrix, C.
- Cpts
array List of global C-point indices.
- splitting
array Boolean array with 1 denoting C-points and 0 F-points.
- distance
int,default2 Distance of F-point neighborhood to consider, options are 1 and 2.
- Rp
- Returns:
NoneNothing, Rp[] modified in place.
- pyamg.amg_core.approx_ideal_restriction_pass2()#
Build column indices and data array for approximate ideal restriction in CSR format.
- Parameters:
- Rp
array Pre-determined row-pointer for R in CSR format.
- Rj
array Empty array for column indices for R in CSR format.
- Rx
array Empty array for data for R in CSR format.
- Ap
array Row pointer for matrix A.
- Aj
array Column indices for matrix A.
- Ax
array Data array for matrix A.
- Cp
array Row pointer for SOC matrix, C.
- Cj
array Column indices for SOC matrix, C.
- Cx
array Data array for SOC matrix, C.
- Cpts
array List of global C-point indices.
- splitting
array Boolean array with 1 denoting C-points and 0 F-points.
- distance
int,default2 Distance of F-point neighborhood to consider, options are 1 and 2.
- use_gmresbool,
default0 Use GMRES for local dense solve.
- maxiter
int,default10 Maximum GMRES iterations.
- preconditionbool,
defaultTrue Diagonally precondition GMRES.
- Rp
- Returns:
NoneNothing, Rj[] and Rx[] modified in place.
Notes
Rx[] must be passed in initialized to zero.
- pyamg.amg_core.bellman_ford()#
Apply one iteration of Bellman-Ford iteration on a distance graph stored in CSR format.
- Parameters:
- num_nodes
int Number of nodes (number of rows in A).
- Ap
array CSR row pointer.
- Aj
array CSR index array.
- Ax
array CSR data array (edge lengths).
- c
array Cluster center.
- d
array,inplace Distance to nearest center.
- m
array,inplace Cluster index for each node.
- p
array,inplace Predecssor on the shortest path to center.
- num_nodes
See also
Notes
There are no checks within this kernel.
Ax is assumed to be positive
Initializations:
- d[i] = 0 if i is a center, else inf - m[i] = 0 .. num_clusters if in a cluster, else -1 - p[i] = -1
References
[1]Bellman-Ford Wikipedia: http://en.wikipedia.org/wiki/Bellman-Ford_algorithm
- pyamg.amg_core.bellman_ford_balanced()#
Bellman-Ford with a heuristic to balance cluster sizes
This version is modified to break distance ties by assigning nodes to the cluster with the fewest points, while preserving cluster connectivity. This results in more balanced cluster sizes.
- Parameters:
- num_nodes(
IN)numberofnodes(numberofrowsinA) - Ap[](
IN)CSRrowpointerforA(num_nodesx1) - Aj[](
IN)CSRcolumnindexforA(num_edgesx1) - Ax[](
IN)CSRdataarray(edgeweights) (num_edgesx1) c : (INOUT) cluster center (num_clusters x 1) d : (INOUT) distance to cluster center (num_nodes x 1) m : (INOUT) cluster index (num_nodes x 1) p : (INOUT) predecessor on shortest path to center (num_nodes x 1) pc : (INOUT) number of predecessors (num_nodes x 1) s : (INOUT) cluster size (num_clusters x 1)
- num_nodes(
See also
Notes
There are no checks within this kernel.
Ax > 0 is assumed
- pyamg.amg_core.block_approx_ideal_restriction_pass2()#
Build column indices and data array for approximate ideal restriction in BSR format.
- Parameters:
- Rp
array Pre-determined row-pointer for R in CSR format.
- Rj
array Empty array for column indices for R in CSR format.
- Rx
array Empty array for data for R in CSR format.
- Ap
array Row pointer for matrix A.
- Aj
array Column indices for matrix A.
- Ax
array Data array for matrix A.
- Cp
array Row pointer for SOC matrix, C.
- Cj
array Column indices for SOC matrix, C.
- Cx
array Data array for SOC matrix, C.
- Cpts
array List of global C-point indices.
- splitting
array Boolean array with 1 denoting C-points and 0 F-points.
- blocksize
int Blocksize of matrix (assume square blocks).
- distance
int,default2 Distance of F-point neighborhood to consider, options are 1 and 2.
- use_gmresbool,
default0 Use GMRES for local dense solve.
- maxiter
int,default10 Maximum GMRES iterations.
- preconditionbool,
defaultTrue Diagonally precondition GMRES.
- Rp
- Returns:
NoneNothing, Rj[] and Rx[] modified in place.
Notes
Rx[] must be passed in initialized to zero.
- pyamg.amg_core.block_gauss_seidel()#
Block Gauss-Seidel iteration.
Perform one iteration of block Gauss-Seidel relaxation on the linear system Ax = b, where A is stored in BSR format and x and b are column vectors.
Refer to gauss_seidel for additional information regarding row_start, row_stop, and row_step.
- Parameters:
- Ap
array BSR row pointer.
- Aj
array BSR index array.
- Ax
array BSR data array, blocks assumed square.
- x
array Approximate solution.
- b
array Right hand side.
- Tx
array Inverse of each diagonal block of A stored as a (n/blocksize, blocksize, blocksize) array.
- row_start
int Beginning of the sweep.
- row_stop
int End of the sweep (i.e. one past the last unknown).
- row_step
int Stride used during the sweep (may be negative).
- blocksize
int Dimension of square blocks in BSR matrix A.
- Ap
- Returns:
NoneResult in place.
- pyamg.amg_core.block_jacobi()#
Block Jacobi iteration.
Perform one iteration of block Jacobi relaxation on the linear system Ax = b, where A is stored in BSR format and x and b are column vectors. Damping is controlled by the omega parameter.
Refer to gauss_seidel for additional information regarding row_start, row_stop, and row_step.
- Parameters:
- Ap
array BSR row pointer.
- Aj
array BSR index array.
- Ax
array BSR data array, blocks assumed square.
- x
array Approximate solution.
- b
array Right hand side.
- Tx
array Inverse of each diagonal block of A stored as a (n/blocksize, blocksize, blocksize) array.
- temp
array Temporary vector the same size as x.
- row_start
int Beginning of the sweep.
- row_stop
int End of the sweep (i.e. one past the last unknown).
- row_step
int Stride used during the sweep (may be negative).
- omega
float Damping parameter.
- blocksize
int Dimension of square blocks in BSR matrix A.
- Ap
- Returns:
NoneResult in place.
- pyamg.amg_core.block_jacobi_indexed()#
Indexed Block Jacobi iteration.
Perform one iteration of block Jacobi relaxation on the linear system Ax = b for a given set of (block) row indices. A is stored in BSR format and x and b are column vectors. Damping is controlled by the parameter omega.
- Parameters:
- Ap
array BSR row pointer.
- Aj
array BSR index array.
- Ax
array BSR data array, blocks assumed square.
- x
array Approximate solution.
- b
array Right hand side.
- Tx
array Inverse of each diagonal block of A stored as a (n/blocksize, blocksize, blocksize) array.
- indices
array Indices.
- omega
float Damping parameter.
- blocksize
int Dimension of square blocks in BSR matrix A.
- Ap
- Returns:
NoneArray x will be modified in place.
- pyamg.amg_core.breadth_first_search()#
Breadth first search.
Compute a breadth first search of a graph in CSR format beginning at a given seed vertex.
- Parameters:
- Returns:
NoneIn place.
Notes
The values of the level must be initialized to -1.
- pyamg.amg_core.bsr_gauss_seidel()#
Gauss-Seidel iteration with BSR arrays.
Perform one iteration of Gauss-Seidel relaxation on the linear system Ax = b, where A is stored in Block CSR format and x and b are column vectors. This method applies point-wise relaxation to the BSR as opposed to "block relaxation".
Refer to gauss_seidel for additional information regarding row_start, row_stop, and row_step.
- Parameters:
- Ap
array BSR row pointer.
- Aj
array BSR index array.
- Ax
array BSR data array.
- x
array Approximate solution.
- b
array Right hand side.
- row_start
int Beginning of the sweep (block row index).
- row_stop
int End of the sweep (i.e. one past the last unknown).
- row_step
int Stride used during the sweep (may be negative).
- blocksize
int BSR blocksize (blocks must be square).
- Ap
- Returns:
NoneArray x will be modified inplace.
- pyamg.amg_core.bsr_jacobi()#
Weighted Jacobi iteration on BSR arrays.
Perform one iteration of Jacobi relaxation on the linear system Ax = b, where A is stored in Block CSR format and x and b are column vectors. This method applies point-wise relaxation to the BSR as opposed to "block relaxation".
Refer to jacobi for additional information regarding row_start, row_stop, and row_step.
- Parameters:
- Ap
array BSR row pointer.
- Aj
array BSR index array.
- Ax
array BSR data array.
- x
array Approximate solution.
- b
array Right hand side.
- temp
array Temporary vector the same size as x.
- row_start
int Beginning of the sweep (block row index).
- row_stop
int End of the sweep (i.e. one past the last unknown).
- row_step
int Stride used during the sweep (may be negative).
- blocksize
int BSR blocksize (blocks must be square).
- omega
float Damping parameter.
- Ap
- Returns:
NoneArray x will be modified inplace.
- pyamg.amg_core.bsr_jacobi_indexed()#
Indexed weighted Jacobi on BSR arrays.
Perform one iteration of Jacobi relaxation on the linear system Ax = b for a given set of row indices, where A is stored in Block CSR format and x and b are column vectors. This method applies point-wise relaxation to the BSR matrix for a given set of row block indices, as opposed to “block relaxation”.
- Parameters:
- Ap
array BSR row pointer.
- Aj
array BSR index array.
- Ax
array BSR data array.
- x
array Approximate solution.
- b
array Right hand side.
- indices
array List of row indices to perform Jacobi on, e.g., F-points. Note, it is assumed that indices correspond to blocks in A.
- blocksize
int BSR blocksize (blocks must be square).
- omega
float Damping parameter.
- Ap
- Returns:
NoneArray x will be modified in place.
- pyamg.amg_core.calc_BtB()#
Helper routine for energy_prolongation_smoother.
- Parameters:
- NullDim
int Number of near nullspace vectors.
- Nnodes
int Number of nodes, i.e. number of block rows in BSR matrix, S.
- cols_per_block
int Columns per block in S.
- b
array Nnodes x BsqCols array, in row-major form. This is B-squared, i.e. it is each column of B multiplied against each other column of B. For a Nx3 B,
b[:,0] = conjugate(B[:,0])*B[:,0] b[:,1] = conjugate(B[:,0])*B[:,1] b[:,2] = conjugate(B[:,0])*B[:,2] b[:,3] = conjugate(B[:,1])*B[:,1] b[:,4] = conjugate(B[:,1])*B[:,2] b[:,5] = conjugate(B[:,2])*B[:,2]
- BsqCols
int Sum(range(NullDim+1)), i.e. number of columns in b.
- x{float|complex
array} Modified inplace for output. Should be zeros upon entry.
- Sp,Sj
intarray BSR indptr and indices members for matrix, S.
- NullDim
- Returns:
Notes
Principle calling routine is energy_prolongation_smoother(…) in smooth.py.
Calculates the following python code:
rows_per_block = Sparsity_Pattern.blocksize[0] BtB = zeros((Nnodes,NullDim,NullDim), dtype=B.dtype) S2 = Sparsity_Pattern.tocsr() for i in range(Nnodes): Bi = mat( B[S2.indices[S2.indptr[i*rows_per_block]:S2.indptr[i*rows_per_block + 1]],:] ) BtB[i,:,:] = Bi.H*Bi
- pyamg.amg_core.center_nodes()#
Update center nodes for a cluster
- Parameters:
- num_nodes(
IN)numberofnodes(numberofrowsinA) Ap[] : (IN) CSR row pointer for A (num_nodes x 1) Aj[] : (IN) CSR column index for A (num_edges x 1) Ax[] : (IN) CSR data array (edge weights) (num_edges x 1)
- Cptr[](
INOUT)ptrtostartofindicesinCforeachcluster(num_clustersx1) D[] : (INOUT) FW distance array (max_size x max_size) P[] : (INOUT) FW predecessor array (max_size x max_size) C[] : (INOUT) FW global index for current cluster (num_nodes x 1) L[] : (INOUT) FW local index for current cluster (num_nodes x 1) q : (INOUT) FW work array for D**2 (max_size x max_size) c : (INOUT) cluster center (num_clusters x 1) d : (INOUT) distance to cluster center (num_nodes x 1) m : (INOUT) cluster index (num_nodes x 1) p : (INOUT) predecessor on shortest path to center (num_nodes x 1) pc : (INOUT) predecessor count (num_nodes x 1) s : (INOUT) cluster size (num_clusters x 1)
- num_nodes(
- Returns:
- changed
flagtoindicateachangeinarraysDorP
- changed
Notes
- sort into clusters first O(n)
s: [4 2 4 ….
pass pointer to start of each C[start,…., start+N]
N is the cluster size
- pyamg.amg_core.classical_strength_of_connection_abs()#
Classical strength of connection.
Compute a strength of connection matrix using the classical strength of connection measure by Ruge and Stuben. Both the input and output matrices are stored in CSR format. An off-diagonal nonzero entry A[i,j] is considered strong if:
|A[i,j]| >= theta * max( |A[i,k]| ) where k != i
Otherwise, the connection is weak.
- Parameters:
- Returns:
NoneArray S is be stored in Sp, Sj, Sx.
Notes
Storage for S must be preallocated. Since S will consist of a subset of A’s nonzero values, a conservative bound is to allocate the same storage for S as is used by A.
- pyamg.amg_core.classical_strength_of_connection_min()#
Classical strength of connection.
Compute a strength of connection matrix using the classical strength of connection measure by Ruge and Stuben. Both the input and output matrices are stored in CSR format. An off-diagonal nonzero entry A[i,j] is considered strong if:
A[i,j] >= theta * max( -A[i,k] ) where k != i
Otherwise, the connection is weak.
- Parameters:
- Returns:
NoneArray S is be stored in Sp, Sj, Sx.
Notes
Storage for S must be preallocated. Since S will consist of a subset of A’s nonzero values, a conservative bound is to allocate the same storage for S as is used by A.
- pyamg.amg_core.cljp_naive_splitting()#
Compute a CLJP splitting.
- Parameters:
- Returns:
NoneIn place.
Notes
The splitting array must be preallocated. CLJP naive since it requires the transpose.
- pyamg.amg_core.connected_components()#
Compute the connected components of a graph stored in CSR format.
- Parameters:
- Returns:
NoneIn place.
Notes
Vertices belonging to each component are marked with a unique integer in the range [0,K), where K is the number of components.
- pyamg.amg_core.cr_helper()#
Helper function for compatible relaxation.
Perform steps 3.1d - 3.1f in Falgout / Brannick (2010).
- Parameters:
- Ap
array Row pointer for sparse matrix in CSR format.
- Aj
array Column indices for sparse matrix in CSR format.
- B
array Target near null space vector for computing candidate set measure.
- e
array,inplace Relaxed vector for computing candidate set measure.
- indices
array,inplace Array of indices, where indices[0] = the number of F indices, nf, followed by F indices in elements 1:nf, and C indices in (nf+1):n.
- splitting
array,inplace Integer array with current C/F splitting of nodes, 0 = C-point, 1 = F-point.
- gamma
array,inplace Preallocated vector to store candidate set measure.
- thetacs
float Threshold for coarse grid candidates from set measure.
- Ap
- Returns:
NoneUpdated C/F-splitting and corresponding indices modified in place.
- pyamg.amg_core.csc_scale_columns()#
Scale the columns of a CSC matrix in place.
References
- pyamg.amg_core.csc_scale_rows()#
Scale the rows of a CSC matrix in place.
References
- pyamg.amg_core.evolution_strength_helper()#
Create strength-of-connection matrix based on constrained min problem.
Create strength-of-connection matrix based on constrained min problem of
- min( z - B*x ), such that
- (B*x)|_i = z|_i, i.e. they are equal at point i
z = (I - (t/k) Dinv A)^k delta_i
Strength is defined as the relative point-wise approximation error between B*x and z. B is the near-nullspace candidates. The constrained min problem is also restricted to consider B*x and z only at the nonzeros of column i of A.
Can use either the D_A inner product, or l2 inner-prod in the minimization problem. Using D_A gives scale invariance. This choice is reflected in whether the parameter DB = B or diag(A)*B.
This is a quadratic minimization problem with a linear constraint, so we can build a linear system and solve it to find the critical point, i.e. minimum..
- Parameters:
- Sp
array Row pointer array for CSR matrix S.
- Sj
array Col index array for CSR matrix S.
- Sx
array Value array for CSR matrix S. Upon entry to the routine,
S = (I - (t/k) Dinv A)^k.- nrows
int Dimension of S.
- B
array Array of size (nrows, NullDim) of near nullspace vectors in col major form, if calling from within Python, take a transpose.
- DB
array Array of size (nrows, NullDim) of possibly scaled near nullspace vectors in col major form. If calling from within Python, take a transpose. For a scale invariant measure, DB = diag(A)*conjugate(B)), corresponding to the D_A inner-product. Otherwise, DB = conjugate(B), corresponding to the l2-inner-product.
- b
array Array of size (nrows, BDBCols) in row-major form. This array is B-squared, i.e. it is each column of B multiplied against each other column of B. For a Nx3 B:
b[:,0] = conjugate(B[:,0])*B[:,0] b[:,1] = conjugate(B[:,0])*B[:,1] b[:,2] = conjugate(B[:,0])*B[:,2] b[:,3] = conjugate(B[:,1])*B[:,1] b[:,4] = conjugate(B[:,1])*B[:,2] b[:,5] = conjugate(B[:,2])*B[:,2]
- BDBCols
int Sum(range(NullDim+1)), i.e. number of columns in b.
- NullDim
int Number of nullspace vectors.
- tol
float Used to determine when values are numerically zero.
- Sp
- Returns:
arrayModified inplace and holds strength values for the above minimization problem.
See also
evolution_strength_of_connection
Notes
Upon entry to the routine,
S = (I - (t/k) Dinv A)^k. However, we only need the values of S at the sparsity pattern of A. Hence, there is no need to completely calculate all of S.Vector b is used to save on the computation of each local minimization problem.
Principle calling routine is evolution_strength_of_connection(…) in strength.py. In that routine, it is used to calculate strength-of-connection for the case of multiple near-nullspace modes.
- pyamg.amg_core.extract_subblocks()#
Extract diagonal blocks from A and insert into a linear array.
This is a helper function for overlapping_schwarz_csr.
- Parameters:
- Ap
array CSR row pointer.
- Aj
array CSR index array. Must be sorted for each row.
- Ax
array CSR data array, blocks assumed square.
- Tx
array Inverse of each diagonal block of A, stored in row major.
- Tp
array Pointer array into Tx indicating where the diagonal blocks start and stop.
- Sj
array Indices of each subdomain. Must be sorted over each subdomain.
- Sp
array Pointer array indicating where each subdomain starts and stops.
- nsdomains
int Number of subdomains.
- nrows
int Number of rows.
- Ap
- Returns:
NoneArray Tx will be modified inplace.
- pyamg.amg_core.filter_matrix_rows()#
Filter matrix rows by diagonal entry.
That is set A_ij = 0 if:
|A_ij| < theta * |A_ii|
- pyamg.amg_core.fit_candidates()#
- pyamg.amg_core.floyd_warshall()#
Floyd-Warshall on a subgraph or cluster of nodes in A.
- Parameters:
- num_nodes
int Number of nodes (number of rows in A).
- Ap
array CSR row pointer for A, (num_nodes, 1).
- Aj
array CSR column index for A, (num_edges, 1).
- Ax
array CSR data array (edge weights), (num_edges, 1).
- D
array FW distance array, (max_size, max_size).
- P
array FW predecessor array, (max_size, max_size).
- C
array FW global index for current cluster, (N, 1).
- L
array FW local index for current cluster, (num_nodes, 1).
- m
array Cluster index, (num_nodes, 1).
- a
array Center of current cluster.
- N
int Size of current cluster.
- num_nodes
Notes
There are no checks within this kernel
There is no initialization within this kernel
Ax > 0 is assumed
Only a slice of C is passed to Floyd–Warshall. See center_nodes.
C[i] is the global index of i for i=0, …, N in the current cluster
N = |C|
L = local indices, nx1 (-1 if not in the cluster)
assumes a fully connected (directed) graph
References
[1]Graph Center: https://en.wikipedia.org/wiki/Graph_center
[2]Floyd-Warshall: https://en.wikipedia.org/wiki/Floyd–Warshall_algorithm
[3]Graph Distance: https://en.wikipedia.org/wiki/Distance_(graph_theory)
- pyamg.amg_core.gauss_seidel()#
Gauss-Seidel iteration.
Perform one iteration of Gauss-Seidel relaxation on the linear system Ax = b, where A is stored in CSR format and x and b are column vectors.
- Parameters:
- Returns:
NoneArray x will be modified inplace.
Notes
The unknowns are swept through according to the slice defined by row_start, row_end, and row_step. These options are used to implement standard forward and backward sweeps, or sweeping only a subset of the unknowns. A forward sweep is implemented with
gauss_seidel(Ap, Aj, Ax, x, b, 0, N, 1)where N is the number of rows in matrix A. Similarly, a backward sweep is implemented withgauss_seidel(Ap, Aj, Ax, x, b, N, -1, -1).
- pyamg.amg_core.gauss_seidel_indexed()#
Indexed Gauss-Seidel iteration.
Perform one iteration of Gauss-Seidel relaxation on the linear system Ax = b, where A is stored in CSR format and x and b are column vectors.
- Parameters:
- Ap
array CSR row pointer.
- Aj
array CSR index array.
- Ax
array CSR data array.
- x
array Approximate solution.
- b
array Right hand side.
- Id
array Index array representing the.
- row_start
int Beginning of the sweep (in array Id).
- row_stop
int End of the sweep (in array Id).
- row_step
int Stride used during the sweep (may be negative).
- Ap
- Returns:
NoneArray x will be modified inplace.
Notes
Unlike gauss_seidel, which is restricted to updating a slice of the unknowns (defined by row_start, row_start, and row_step), this method updates unknowns according to the rows listed in an index array. This allows and arbitrary set of the unknowns to be updated in an arbitrary order, as is necessary for the relaxation steps in the Compatible Relaxation method.
In this method the slice arguments are used to define the subset of the index array Id which is to be considered.
- pyamg.amg_core.gauss_seidel_ne()#
Gauss-Seidel NE iteration.
Perform NE Gauss-Seidel on the linear system A x = b This effectively carries out Gauss-Seidel on A A.H y = b, where x = A.h y.
- Parameters:
- Ap
array Index pointer for CSR matrix A.
- Aj
array Column indices for CSR matrix A.
- Ax
array Value array for CSR matrix A.
- x
array Current guess to the linear system.
- b
array Right hand side.
- Tx
array Inverse(diag(A A.H)).
- omega
float Relaxation parameter (if not 1.0, then algorithm becomes SOR).
- row_start,stop,step
int Controls which rows to iterate over.
- Ap
- Returns:
NoneArray x is modified inplace in an additive, not overwriting fashion.
- pyamg.amg_core.gauss_seidel_nr()#
Gauss-Seidel NR iteration.
Perform NR Gauss-Seidel on the linear system A x = b This effectively carries out Gauss-Seidel on A.H A x = A.H b
- Parameters:
- Ap
array Index pointer for CSC matrix A.
- Aj
array Row indices for CSC matrix A.
- Ax
array Value array for CSC matrix A.
- x
array Current guess to the linear system.
- z
array Initial residual.
- Tx
array Inverse(diag(A.H A)).
- omega
float Relaxation parameter (if not 1.0, then algorithm becomes SOR).
- col_start,stop,step
int Controls which rows to iterate over.
- Ap
- Returns:
NoneArray x is modified inplace in an additive, not overwriting fashion.
- pyamg.amg_core.householder_hornerscheme()#
Householder Horner Scheme.
For use after gmres is finished iterating and the least squares solution has been found. This routine maps the solution back to the original space via the Householder reflectors.
Apply Householder reflectors in B to z while also adding in the appropriate value from y, so that we follow the Horner-like scheme to map our least squares solution in y back to the original space
Implements the below python
for j in range(inner,-1,-1): z[j] += y[j] # Apply j-th reflector, (I - 2.0*w_j*w_j.T)*update z = z - 2.0*dot(conjugate(B[j,:]), update)*B[j,:]
- Parameters:
- Returns:
Nonez is modified in place to reflect the application of the Householder reflectors, B[:,range(start,stop,step)], and the inclusion of values in y.
Notes
Principle calling routine are gmres and fgmres.
See pages 164-167 in Saad, “Iterative Methods for Sparse Linear Systems”.
- pyamg.amg_core.incomplete_mat_mult_bsr()#
Mat-mul over a sparsity pattern.
Calculate A*B = S, but only at the pre-existing sparsity pattern of S, i.e. do an exact, but incomplete mat-mat mult.
A, B and S must all be in BSR, may be rectangular, but the indices need not be sorted. Also, A.blocksize[0] must equal S.blocksize[0], A.blocksize[1] must equal B.blocksize[0], and B.blocksize[1] must equal S.blocksize[1]
- Parameters:
- Ap
array BSR row pointer array.
- Aj
array BSR col index array.
- Ax
array BSR value array.
- Bp
array BSR row pointer array.
- Bj
array BSR col index array.
- Bx
array BSR value array.
- Sp
array BSR row pointer array.
- Sj
array BSR col index array.
- Sx
array BSR value array.
- n_brow
int Number of block-rows in A.
- n_bcol
int Number of block-cols in S.
- brow_A
int Row blocksize for A.
- bcol_A
int Column blocksize for A.
- bcol_B
int Column blocksize for B.
- Ap
- Returns:
Sxismodifiedin-placetoreflectS(i,j) = <A_{i,:}, B_{:,j}>butonlyforthoseentriesalreadypresentinthesparsitypatternofS.
Notes
Algorithm is SMMP.
Principle calling routine is energy_prolongation_smoother(…) in smooth.py. Here it is used to calculate the descent direction A*P_tent, but only within an accepted sparsity pattern.
Is generally faster than the commented out incomplete_BSRmatmat(…) routine below, except when S has far few nonzeros than A or B.
- pyamg.amg_core.incomplete_mat_mult_csr()#
Calculate A*B = S, but only at a pre-existing sparsity.
Use the pattern of S, i.e. do an exact, but incomplete mat-mat multiply.
A must be in CSR, B must be in CSC and S must be in CSR. Indices for A, B and S must be sorted. A, B, and S must be square.
- Parameters:
- Ap
array Row pointer array for CSR matrix A.
- Aj
array Col index array for CSR matrix A.
- Ax
array Value array for CSR matrix A.
- Bp
array Row pointer array for CSC matrix B.
- Bj
array Col index array for CSC matrix B.
- Bx
array Value array for CSC matrix B.
- Sp
array Row pointer array for CSR matrix S.
- Sj
array Col index array for CSR matrix S.
- Sx
array Value array for CSR matrix S.
- dimen
int Dimensionality of A,B and S.
- Ap
- Returns:
arrayModified inplace to reflect S(i,j) = <A_{i,:}, B_{:,j}>
Notes
A must be in CSR, B must be in CSC and S must be in CSR. Indices for A, B and S must all be sorted. A, B and S must be square.
Algorithm is naive, S(i,j) = <A_{i,:}, B_{:,j}> But, the routine is written for the case when S’s sparsity pattern is a subset of A*B, so this algorithm should work well.
Principle calling routine is evolution_strength_of_connection in strength.py. Here it is used to calculate S*S only at the sparsity pattern of the original operator. This allows for BIG cost savings.
Examples
>>> from pyamg.amg_core import incomplete_mat_mult_csr >>> import numpy as np >>> from scipy.sparse import csr_array, csc_array >>> A = csr_array(np.arange(1,10,dtype=float).reshape(3,3)) >>> B = csc_array(np.ones((3,3),dtype=float)) >>> AB = csr_array(np.eye(3,3,dtype=float)) >>> A.sort_indices() >>> B.sort_indices() >>> AB.sort_indices() >>> incomplete_mat_mult_csr(A.indptr, A.indices, A.data, B.indptr, B.indices, B.data, AB.indptr, AB.indices, AB.data, 3) >>> print "Incomplete Matrix-Matrix Multiplication\n" + str(AB.todense()) >>> print "Complete Matrix-Matrix Multiplication\n" + str((A*B).todense())
- pyamg.amg_core.jacobi()#
Weighted Jacobi iteration.
Perform one iteration of Jacobi relaxation on the linear system Ax = b, where A is stored in CSR format and x and b are column vectors. Damping is controlled by the omega parameter.
Refer to gauss_seidel for additional information regarding row_start, row_stop, and row_step.
- Parameters:
- Ap
array CSR row pointer.
- Aj
array CSR index array.
- Ax
array CSR data array.
- x
array Approximate solution.
- b
array Right hand side.
- temp
array Temporary vector the same size as x.
- row_start
int Beginning of the sweep.
- row_stop
int End of the sweep (i.e. one past the last unknown).
- row_step
int Stride used during the sweep (may be negative).
- omega
float Damping parameter.
- Ap
- Returns:
NoneArray x will be modified inplace.
- pyamg.amg_core.jacobi_indexed()#
Indexed weighted Jacobi iteration.
Perform one iteration of Jacobi relaxation on the linear system Ax = b for a given set of row indices, where A is stored in CSR format and x and b are column vectors. Damping is controlled by the omega parameter.
- Parameters:
- Returns:
NoneArray x will be modified in place.
- pyamg.amg_core.jacobi_ne()#
Jacobi NE iteration.
Perform NE Jacobi on the linear system A x = b This effectively carries out weighted-Jacobi on A^TA x = A^T b (also known as Cimmino’s relaxation)
- Parameters:
- Ap
array Index pointer for CSR matrix A.
- Aj
array Column indices for CSR matrix A.
- Ax
array Value array for CSR matrix A.
- x
array Current guess to the linear system.
- b
array Right hand side.
- Tx
array Scaled residual D_A^{-1} (b - Ax).
- temp
array Work space.
- row_start
int Controls which rows to start on.
- row_stop
int Controls which rows to stop on.
- row_step
int Controls which rows to iterate over.
- omega
array Size one array that contains the weighted-jacobi parameter. An array must be used to pass in omega to account for the case where omega may be complex.
- Ap
- Returns:
Nonex is modified inplace in an additive, not overwriting fashion.
- pyamg.amg_core.maximal_independent_set_k_parallel()#
Compute MIS-k.
- Parameters:
- num_rows
int Number of rows in A (number of vertices).
- Ap
array CSR row pointer.
- Aj
array CSR index array.
- k
int Minimum separation between MIS vertices.
- x
array,inplace State of each vertex (1 if in the MIS, 0 otherwise).
- y
array Random values used during parallel MIS algorithm.
- max_iters
int Maximum number of iterations to use (default, no limit).
- num_rows
- Returns:
NoneIn place.
Notes
Compute a distance-k maximal independent set for a graph stored in CSR format using a parallel algorithm. An MIS-k is a set of vertices such that all vertices in the MIS-k are separated by a path of at least K+1 edges and no additional vertex can be added to the set without destroying this property. A standard MIS is therefore a MIS-1.
- pyamg.amg_core.maximal_independent_set_parallel()#
Parallel maximal independent set.
Compute a maximal independent set for a graph stored in CSR format using a variant of Luby’s parallel MIS algorithm.
- Parameters:
- num_rows
int Number of rows in A (number of vertices).
- Ap
array CSR row pointer.
- Aj
array CSR index array.
- active
float Value used for active vertices.
- C
float Value used to mark non-MIS vertices.
- F
float Value used to mark MIS vertices.
- x
array,output State of each vertex.
- y
array Random values for each vertex.
- max_iters
int Maximum number of iterations By default max_iters=-1 and no limit is imposed.
- num_rows
- Returns:
intThe number of nodes in the MIS.
Notes
Only the vertices with values with x[i] == active are considered when determining the MIS. Upon return, all active vertices will be assigned the value C or F depending on whether they are in the MIS or not.
- pyamg.amg_core.maximal_independent_set_serial()#
Serial maximal independent set.
Compute a maximal independent set for a graph stored in CSR format using a greedy serial algorithm
- Parameters:
- Returns:
intThe number of nodes in the MIS.
Notes
Only the vertices with values with x[i] == active are considered when determining the MIS. Upon return, all active vertices will be assigned the value C or F depending on whether they are in the MIS or not.
- pyamg.amg_core.maximum_row_value()#
Compute the maximum in magnitude row value for a CSR matrix.
- pyamg.amg_core.min_blocks()#
Find the size of the smallest entry in each block.
Given a BSR with num_blocks stored, return a linear array of length num_blocks, which holds each block’s smallest, nonzero, entry.
- Parameters:
- Returns:
arrayModified in place; Tx[i] holds the minimum nonzero value of block i of S.
Notes
Principle calling routine is evolution_strength_of_connection(…) in strength.py. In that routine, it is used to assign a strength of connection value between supernodes by setting the strength value to be the minimum nonzero in a block.
Examples
>>> from scipy.sparse import bsr_array, csr_array >>> from pyamg.amg_core import min_blocks >>> from numpy import zeros, array, ravel, round >>> from numpy import rand >>> row = array([0,2,4,6]) >>> col = array([0,2,2,0,1,2]) >>> data = round(10*rand(6,2,2), decimals=1) >>> S = bsr_array( (data,col,row), shape=(6,6) ) >>> T = zeros(data.shape[0]) >>> print "Matrix before\n" + str(S.todense()) >>> min_blocks(6, 4, ravel(S.data), T) >>> S2 = csr_array((T, S.indices, S.indptr), shape=(3,3)) >>> print("Matrix after\n" + str(S2.todense()))
- pyamg.amg_core.most_interior_nodes()#
Find the most interior nodes.
- Parameters:
- num_nodes
int Number of nodes (number of rows in A).
- Ap
array CSR row pointer for adjacency matrix A, (num_nodes, 1).
- Aj
array CSR index array, (num_edges, 1).
- Ax
array CSR data array (edge lengths), (num_edges, 1).
- c
array,num_cluster Cluster centers, (num_clusters, 1).
- d
array,num_nodes Distance to nearest seed, (num_nodes, 1).
- m
array,num_nodes Cluster index for each node, (num_nodes, 1).
- p
array Predecessor on shortest path to center, (num_nodes, 1).
- num_nodes
Notes
There are no checks within this kernel.
Ax is assumed to be positive
References
[Bell2008]Nathan Bell, Algebraic Multigrid for Discrete Differential Forms PhD thesis (UIUC), August 2008.
- pyamg.amg_core.naive_aggregation()#
Compute aggregates for a matrix A stored in CSR format.
- Parameters:
- Returns:
intThe number of aggregates (
== max(x[:]) + 1).
Notes
Differs from standard aggregation. Each dof is considered. If it has been aggregated, skip over. Otherwise, put dof and any unaggregated neighbors in an aggregate. Results in possibly much higher complexities.
- pyamg.amg_core.one_point_interpolation()#
Interpolate C-points and each F-point from its strongest connected C-neighbor.
- Parameters:
- Returns:
NoneNothing, Rj[] modified in place.
- pyamg.amg_core.overlapping_schwarz_csr()#
Overlapping Schwarz iteration.
Perform one iteration of an overlapping Schwarz relaxation on the linear system Ax = b, where A is stored in CSR format and x and b are column vectors.
Refer to gauss_seidel for additional information regarding row_start, row_stop, and row_step.
- Parameters:
- Ap
array CSR row pointer.
- Aj
array CSR index array.
- Ax
array CSR data array, blocks assumed square.
- x
array Approximate solution.
- b
array Right hand side.
- Tx
array Inverse of each diagonal block of A, stored in row major.
- Tp
array Pointer array into Tx indicating where the diagonal blocks start and stop.
- Sj
array Indices of each subdomain. Must be sorted over each subdomain.
- Sp
array Pointer array indicating where each subdomain starts and stops.
- nsdomains
int Number of subdomains.
- nrows
int Number of rows.
- row_start
int Subdomain processing start index.
- row_stop
int Subdomain processing stop index.
- row_step
int Subdomain processing step index.
- Ap
- Returns:
NoneArray x will be modified inplace.
- pyamg.amg_core.pairwise_aggregation()#
Compute aggregates for a matrix S stored in CSR format.
- Parameters:
- Returns:
intThe number of aggregates (
== max(x[:]) + 1).
Notes
S is the strength matrix. Assumes that the strength matrix is for classic strength with min norm.
- pyamg.amg_core.pinv_array()#
Replace each block of A with a Moore-Penrose pseudoinverse of that block.
Routine is designed to invert many small matrices at once.
- Parameters:
- Returns:
NoneAA is modified in place with the pseduoinverse replacing each block of AA. AA is returned in row-major form for Python
Notes
This routine is designed to be called once for a large m. Calling this routine repeatably would not be efficient.
This function offers substantial speedup over native Python code for many small matrices, e.g. 5x5 and 10x10. Tests have indicated that matrices larger than 27x27 are faster if done in native Python.
Examples
>>> from pyamg.amg_core import pinv_array >>> import numpy as np >>> A = np.array([np.arange(1,5, dtype=float).reshape(2,2), np.ones((2,2),dtype=float)]) >>> Ac = A.copy() >>> pinv_array(A, 2, 2, 'T') >>> print "Multiplication By Inverse\n" + str(np.dot(A[0], Ac[0])) >>> print "Multiplication by PseudoInverse\n" + str(np.dot(Ac[1], np.dot(A[1], Ac[1]))) >>> >>> A = Ac.copy() >>> pinv_array(A,2,2,'F') >>> print "Changing flag to \'F\' results in different Inverse\n" + str(np.dot(A[0], Ac[0])) >>> print "A holds the inverse of the transpose\n" + str(np.dot(A[0], Ac[0].T))
- pyamg.amg_core.remove_strong_FF_connections()#
Remove strong F-to-F connections.
Remove strong F-to-F connections that do NOT have a common C-point from the set of strong connections. Specifically, set the data value in CSR format to 0. Removing zero entries afterwards will adjust row pointer and column indices.
- pyamg.amg_core.rs_cf_splitting()#
Ruge-Stuben splitting.
Compute a C/F (coarse-fine( splitting using the classical coarse grid selection method of Ruge and Stuben. The strength of connection matrix S, and its transpose T, are stored in CSR format. Upon return, the splitting array will consist of zeros and ones, where C-nodes (coarse nodes) are marked with the value 1 and F-nodes (fine nodes) with the value 0.
- Parameters:
- n_nodes
int Number of rows in A.
- Sp
array CSR row pointer array for SOC matrix.
- Sj
array CSR column index array for SOC matrix.
- Tp
array CSR row pointer array for transpose of SOC matrix.
- Tj
array CSR column index array for transpose of SOC matrix.
- influence
array Array that influences splitting (values stored here are added to lambda for each point).
- splitting
array,inplace Array to store the C/F splitting.
- n_nodes
Notes
The splitting array must be preallocated.
- pyamg.amg_core.rs_cf_splitting_pass2()#
Ruge-Stuben splitting pass 2.
- Parameters:
Notes
The splitting array must be preallocated.
- pyamg.amg_core.rs_classical_interpolation_pass1()#
First pass of classical AMG interpolation.
Build row pointer for P based on SOC matrix and CF-splitting.
- pyamg.amg_core.rs_classical_interpolation_pass2()#
RS classical interpolation pass 2.
Produce a classical AMG interpolation operator for the case in which two strongly connected F -points do NOT have a common C-neighbor. Formula can be found in Sec. 3 Eq. (8) of [1] for modified=False and Eq. (9) for modified=True.
- Parameters:
- Ap
array Row pointer for matrix A.
- Aj
array Column indices for matrix A.
- Ax
array Data array for matrix A.
- Sp
array Row pointer for SOC matrix, C.
- Sj
array Column indices for SOC matrix, C.
- Sx
array Data array for SOC matrix, C – MUST HAVE VALUES OF A.
- splitting
array Boolean array with 1 denoting C-points and 0 F-points.
- Pp
array Row pointer for matrix P.
- Pj
array Column indices for matrix P.
- Px
array Data array for matrix P.
- modifiedbool
Use modified interpolation formula.
- Ap
- Returns:
NoneArrays Pj and Px modified in place.
Notes
For modified interpolation, it is assumed that SOC matrix C is passed in WITHOUT any F-to-F connections that do not share a common C-point neighbor. Any SOC matrix C can be set as such by calling
remove_strong_FF_connections().References
- ..[0] V. E. Henson and U. M. Yang, BoomerAMG: a parallel algebraic multigrid
solver and preconditioner, Applied Numerical Mathematics 41 (2002).
- ..[1] “Distance-Two Interpolation for Parallel Algebraic Multigrid,”
De Sterck, R. Falgout, J. Nolting, U. M. Yang, (2008).
- pyamg.amg_core.rs_direct_interpolation_pass1()#
Produce the Ruge-Stuben prolongator using “Direct Interpolation”.
The first pass uses the strength of connection matrix ‘S’ and C/F splitting to compute the row pointer for the prolongator.
The second pass fills in the nonzero entries of the prolongator.
- Parameters:
- Returns:
NoneIn place.
Notes
See page 479 of Multigrid.
- pyamg.amg_core.rs_direct_interpolation_pass2()#
RS direct interpolation pass 2.
- Parameters:
- Ap
array Row pointer for matrix A.
- Aj
array Column indices for matrix A.
- Ax
array Data array for matrix A.
- Sp
array Row pointer for SOC matrix, C.
- Sj
array Column indices for SOC matrix, C.
- Sx
array Data array for SOC matrix, C – MUST HAVE VALUES OF A.
- splitting
array Boolean array with 1 denoting C-points and 0 F-points.
- Pp
array Row pointer for matrix P.
- Pj
array Column indices for matrix P.
- Px
array Data array for matrix P.
- Ap
- Returns:
NoneArrays Pj and Px modified in place.
- pyamg.amg_core.satisfy_constraints_helper()#
Helper routine for satisfy_constraints routine.
- Parameters:
- rows_per_block
int Rows per block in the BSR matrix, S.
- cols_per_block
int Cols per block in the BSR matrix, S.
- num_block_rows
int Number of block rows,
S.shape[0]/rows_per_block.- NullDim
int Null-space dimension, i.e., the number of columns in B.
- x
array Conjugate of near-nullspace vectors, B, in row major.
- y
array S*B, in row major.
- z
array BtBinv, in row major, i.e.
z[i] = pinv(B_i.H Bi), where B_i is B restricted to the neighborhood of dof of i.- Sp
array Row pointer array for BSR matrix S.
- Sj
array Col index array for BSR matrix S.
- Sx
array Value array for BSR matrix S.
- rows_per_block
- Returns:
NoneSx is modified in place such that S*B = 0. S ends up being the update to the prolongator in the energy_minimization algorithm.
See also
energy_prolongation_smoother
Notes
Principle calling routine is energy_prolongation_smoother(…) in smooth.py.
This implements the python code:
# U is a BSR matrix, B is num_block_rows x cols_per_block x cols_per_block # UB is num_block_rows x rows_per_block x cols_per_block, BtBinv is num_block_rows x cols_per_block x cols_per_block B = asarray(B).reshape(-1,cols_per_block,B.shape[1]) UB = asarray(UB).reshape(-1,rows_per_block,UB.shape[1]) rows = csr_array((U.indices,U.indices,U.indptr), \ shape=(U.shape[0]/rows_per_block,U.shape[1]/cols_per_block)).tocoo(copy=False).row for n,j in enumerate(U.indices): i = rows[n] Bi = mat(B[j]) UBi = UB[i] U.data[n] -= dot(UBi,dot(BtBinv[i],Bi.H))
- pyamg.amg_core.sor_gauss_seidel()#
SOR iteration.
Perform one iteration of SOR relaxation on the linear system Ax = b, where A is stored in CSR format and x and b are column vectors.
- Parameters:
- Ap
array CSR row pointer.
- Aj
array CSR index array.
- Ax
array CSR data array.
- x
array Approximate solution.
- b
array Right hand side.
- row_start
int Beginning of the sweep.
- row_stop
int End of the sweep (i.e. one past the last unknown).
- row_step
int Stride used during the sweep (may be negative).
- omega
float Relaxation parameter for SOR.
- Ap
- Returns:
NoneArray x will be modified inplace.
Notes
Nearly identical to
gauss_seidelwith a relaxation parameteromega.
- pyamg.amg_core.standard_aggregation()#
Compute aggregates for a matrix A stored in CSR format.
- Parameters:
- Returns:
intThe number of aggregates (
== max(x[:]) + 1).
Notes
It is assumed that A is symmetric.
A may contain diagonal entries (self loops)
Unaggregated nodes are marked with a -1
- pyamg.amg_core.symmetric_strength_of_connection()#
Compute symmetric strength of connection.
Compute a strength of connection matrix using the standard symmetric Smoothed Aggregation heuristic. Both the input and output matrices are stored in CSR format. A nonzero connection A[i,j] is considered strong if:
abs(A[i,j]) >= theta * sqrt( abs(A[i,i]) * abs(A[j,j]) )
The strength of connection matrix S is simply the set of nonzero entries of A that qualify as strong connections.
- Parameters:
Notes
Storage for S must be preallocated. Since S will consist of a subset of A’s nonzero values, a conservative bound is to allocate the same storage for S as is used by A.
- pyamg.amg_core.truncate_rows_csr()#
Truncate the entries in A.
Only the largest (in magnitude) k entries per row are left. Smaller entries are zeroed out.
- pyamg.amg_core.vertex_coloring_LDF()#
Compute a vertex coloring of a graph using parallel Largest-Degree-First (LDF).
- Parameters:
References
[LDF]J. R. Allwright and R. Bordawekar and P. D. Coddington and K. Dincer and C. L. Martin A Comparison of Parallel Graph Coloring Algorithms DRAFT SCCS-666 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.45.4650
- pyamg.amg_core.vertex_coloring_jones_plassmann()#
Compute a vertex coloring of a graph using the Jones-Plassmann algorithm.
- Parameters:
Notes
Arrays x and z will be overwritten.
References
[Jones92]Mark T. Jones and Paul E. Plassmann A Parallel Graph Coloring Heuristic SIAM Journal on Scientific Computing 14:3 (1993) 654–669 http://citeseer.ist.psu.edu/jones92parallel.html
- pyamg.amg_core.vertex_coloring_mis()#
Compute a vertex coloring for a graph stored in CSR format.
The coloring is computed by removing maximal independent sets of vertices from the graph. Specifically, at iteration i an independent set of the remaining subgraph is constructed and assigned color i.
Returns the K, the number of colors used in the coloring. On return x[i] in [0,1, …, K - 1] will contain the color of the i-th vertex.