def test_superlu_2_dense(small_superlu): """ Tests the superlu wrapper to dense matrix function. """ superlu_mat = small_superlu dense_mat = LinearAlgebraTools.superlu_sparse_2_dense(superlu_mat) comparison_mat = numpy.loadtxt( os.path.join(os.path.dirname(__file__), 'sparse_mat_1.txt')) assert numpy.allclose(dense_mat, comparison_mat)
def test_superlu_2_dense(small_superlu): """ Tests the superlu wrapper to dense matrix function. """ superlu_mat = small_superlu dense_mat = LinearAlgebraTools.superlu_sparse_2_dense(superlu_mat) comparison_mat = numpy.loadtxt(os.path.join(os.path.dirname(__file__), 'sparse_mat_1.txt')) assert numpy.allclose(dense_mat,comparison_mat)
def test_1(self): """ Initial test to check whether this is working """ self.laplace_object.modelList[0].levelModelList[0].calculateCoefficients() rowptr, colind, nzval = self.laplace_object.modelList[0].levelModelList[0].jacobian.getCSRrepresentation() self.laplace_object.modelList[0].levelModelList[0].scale_dt = False self.Asys_rowptr = rowptr.copy() self.Asys_colptr = colind.copy() self.Asys_nzval = nzval.copy() nn = len(self.Asys_rowptr)-1 self.Asys = LinearAlgebraTools.SparseMatrix(nn,nn, self.Asys_nzval.shape[0], self.Asys_nzval, self.Asys_colptr, self.Asys_rowptr) self.petsc4py_A = self.laplace_object.modelList[0].levelModelList[0].getSpatialJacobian(self.Asys) laplace_mat = LinearAlgebraTools.superlu_sparse_2_dense(self.petsc4py_A) expected_output = os.path.dirname(os.path.abspath(__file__)) + '/comparison_files/laplace_reference_c0p1_2D.txt' comparison_mat = numpy.loadtxt(expected_output) assert numpy.allclose(laplace_mat,comparison_mat)
def test_superlu_2_dense(): """ Tests the superlu wrapper to dense matrix function. """ vals = numpy.array([ 10., -2., 3., 9., 3., 7., 8., 7., 3., 8., 7., 5., 8., 9., 9., 13., 4., 2., -1. ]) col_idx = numpy.array( [0, 4, 0, 1, 5, 1, 2, 3, 0, 2, 3, 4, 1, 3, 4, 5, 1, 4, 5], dtype='int32') row_idx = numpy.array([0, 2, 5, 8, 12, 16, 19], dtype='int32') size_n = len(row_idx) - 1 superlu_mat = LinearAlgebraTools.SparseMat(size_n, size_n, len(vals), vals, col_idx, row_idx) dense_mat = LinearAlgebraTools.superlu_sparse_2_dense(superlu_mat) comparison_mat = numpy.loadtxt( os.path.join(os.path.dirname(__file__), 'sparse_mat_1.txt')) assert numpy.allclose(dense_mat, comparison_mat)
def test_superlu_2_dense(): """ Tests the superlu wrapper to dense matrix function. """ vals = numpy.array([10.,-2.,3.,9.,3.,7.,8.,7.,3., 8.,7.,5.,8.,9.,9.,13.,4.,2.,-1.]) col_idx = numpy.array([0, 4 ,0 ,1 ,5 ,1 ,2 ,3 ,0 ,2 , 3 ,4 ,1 ,3 ,4 ,5 ,1 ,4 , 5 ], dtype='int32') row_idx = numpy.array([0, 2, 5, 8, 12, 16, 19], dtype='int32') size_n = len(row_idx)-1 superlu_mat = LinearAlgebraTools.SparseMat(size_n, size_n, len(vals), vals, col_idx, row_idx) dense_mat = LinearAlgebraTools.superlu_sparse_2_dense(superlu_mat) comparison_mat = numpy.loadtxt(os.path.join(os.path.dirname(__file__), 'sparse_mat_1.txt')) assert numpy.allclose(dense_mat,comparison_mat)
def test_1(self): """ Initial test to check whether this is working """ self.laplace_object.modelList[0].levelModelList[ 0].calculateCoefficients() rowptr, colind, nzval = self.laplace_object.modelList[ 0].levelModelList[0].jacobian.getCSRrepresentation() self.laplace_object.modelList[0].levelModelList[0].scale_dt = False self.Asys_rowptr = rowptr.copy() self.Asys_colptr = colind.copy() self.Asys_nzval = nzval.copy() nn = len(self.Asys_rowptr) - 1 self.Asys = LinearAlgebraTools.SparseMatrix(nn, nn, self.Asys_nzval.shape[0], self.Asys_nzval, self.Asys_colptr, self.Asys_rowptr) self.petsc4py_A = self.laplace_object.modelList[0].levelModelList[ 0].getSpatialJacobian(self.Asys) laplace_mat = LinearAlgebraTools.superlu_sparse_2_dense( self.petsc4py_A) expected_output = os.path.dirname(os.path.abspath( __file__)) + '/comparison_files/laplace_reference_c0p1_3D.txt' comparison_mat = numpy.loadtxt(expected_output) assert numpy.allclose(laplace_mat, comparison_mat)