def schur(self, A, schur_list, full_matrix=True): """ Setup the solver object to work in Schur complement mode full_matrix: boolean, default True. If full_matrix is False and a symmetric factorization is used, only the lower part of the Schur matrix is stored in self.S """ self.A = A self.spmA = spm.spmatrix(A) if self.verbose: self.spmA.printInfo() self.schur_list = schur_list + self.spmA.findBase() setSchurUnknownList(self.pastix_data, self.schur_list) task_analyze(self.pastix_data, self.spmA) task_numfact(self.pastix_data, self.spmA) nschur = len(schur_list) self.S = np.zeros((nschur, nschur), order='F', dtype=A.dtype) getSchur(self.pastix_data, self.S) if full_matrix and (self.factotype != factotype.LU): self.S += la.tril(self.S, -1).T
def setup(self, A): """ Setup the solver object for the classic case w/o Schur complement """ self.A = A self.spmA = spm.spmatrix(A) if self.verbose: self.spmA.printInfo() task_analyze(self.pastix_data, self.spmA) task_numfact(self.pastix_data, self.spmA)
Univ. Bordeaux. All rights reserved. @version 6.0.0 @author Pierre Ramet @author Mathieu Faverge @author Louis Poirel @date 2017-05-04 """ import spm import scipy.sparse as sps import numpy as np # Hack to make sure that the mkl is loaded tmp = np.eye(2).dot(np.ones(2)) # Set the problem n = 9 A = sps.spdiags([np.ones(n) * i for i in [4, -1, -1, -1, -1]], [0, 1, 3, -1, -3], n, n) x0 = np.arange(n) b = np.zeros(n) spmA = spm.spmatrix(A) # Multiply A by x spmA.mult(x0, b, trans=spm.trans.NoTrans, alpha=1., beta=0.) # Check that A * x = b spmA.checkAxb(None, b, x0)
@version 6.0.0 @author Pierre Ramet @author Mathieu Faverge @author Louis Poirel @date 2017-05-04 """ import spm import numpy as np # Hack to make sure that the mkl is loaded tmp = np.eye(2).dot(np.ones(2)) # Load a sparse matrix from the Laplacian driver A = spm.spmatrix(None, driver=spm.driver.Laplacian, filename="10:10:10:2.:1.") # Example from a HB file #A = spm( None, driver=driver.HB, filename="$PASTIX_DIR/test/matrix/orsirr.rua" ) A.printInfo() # Scale A for low-rank: A / ||A||_f norm = A.norm() A.scale(1. / norm) # Generate b and x0 vectors such that A * x0 = b nrhs = 10 x0, b = A.genRHS(spm.rhstype.RndX, nrhs) # Check that A * x = b
# Hack to make sure that the mkl is loaded tmp = np.eye(2).dot(np.ones(2)) # Initialize parameters to default values iparm, dparm = pastix.initParam() # Startup PaStiX pastix_data = pastix.init(iparm, dparm) # Change some parameters iparm[pastix.iparm.factorization] = pastix.factotype.LU for nspb in range(1, 3): # Load a sparse matrix from HB driver spmA = spm.spmatrix(None, driver=spm.driver.Laplacian, filename=("%d:%d:%d:4.:1." % (nspb * 5, nspb * 5, nspb * 5))) #spmA = spm.spmatrix( None, driver=driver.HB, filename="$PASTIX_DIR/test/matrix/orsirr.rua" ) spmA.printInfo() # Scale A for low-rank: A / ||A||_f norm = spmA.norm() spmA.scale(1. / norm) # Perform analyze pastix.task_analyze(pastix_data, spmA) for nfact in range(1, 3): # Perform numerical factorization pastix.task_numfact(pastix_data, spmA)