Changeset 1018 for inundation/ga/storm_surge/pyvolution/test_cg_solve.py
- Timestamp:
- Mar 7, 2005, 9:32:07 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/test_cg_solve.py
r599 r1018 9 9 10 10 11 class Test Case(unittest.TestCase):11 class Test_CG_Solve(unittest.TestCase): 12 12 13 13 def test_sparse_solve(self): 14 14 """Small Sparse Matrix""" 15 15 16 16 A = [[2.0, -1.0, 0.0, 0.0 ], 17 17 [-1.0, 2.0, -1.0, 0.0], 18 18 [0.0, -1.0, 2.0, -1.0], 19 19 [0.0,0.0, -1.0, 2.0]] 20 20 21 21 A = Sparse(A) 22 22 … … 35 35 n = 50 36 36 A = Sparse(n,n) 37 37 38 38 for i in arange(0,n): 39 39 A[i,i] = 1.0 … … 42 42 if i < n-1 : 43 43 A[i,i+1] = -0.5 44 44 45 45 xe = ones( (n,), Float) 46 46 … … 52 52 def test_solve_large_2d(self): 53 53 """Standard 2d laplacian""" 54 54 55 55 n = 20 56 56 m = 10 … … 70 70 if j < m-1 : 71 71 A[I,I+1] = -1.0 72 72 73 73 xe = ones( (n*m,), Float) 74 74 … … 81 81 """Standard 2d laplacian with csr format 82 82 """ 83 83 84 84 n = 100 85 85 m = 100 … … 99 99 if j < m-1 : 100 100 A[I,I+1] = -1.0 101 101 102 102 xe = ones( (n*m,), Float) 103 103 … … 114 114 def test_solve_large_2d_with_default_guess(self): 115 115 """Standard 2d laplacian using default first guess""" 116 116 117 117 n = 20 118 118 m = 10 … … 132 132 if j < m-1 : 133 133 A[I,I+1] = -1.0 134 134 135 135 xe = ones( (n*m,), Float) 136 136 … … 143 143 def test_vector_shape_error(self): 144 144 """Raise VectorShapeError""" 145 145 146 146 A = [[2.0, -1.0, 0.0, 0.0 ], 147 147 [-1.0, 2.0, -1.0, 0.0], 148 148 [0.0, -1.0, 2.0, -1.0], 149 149 [0.0,0.0, -1.0, 2.0]] 150 150 151 151 A = Sparse(A) 152 152 … … 161 161 raise msg 162 162 163 163 164 164 #------------------------------------------------------------- 165 165 if __name__ == "__main__": 166 suite = unittest.makeSuite(Test Case,'test')166 suite = unittest.makeSuite(Test_CG_Solve,'test') 167 167 runner = unittest.TextTestRunner() #(verbosity=2) 168 168 runner.run(suite) 169 169 170 171 172 170 173 171
Note: See TracChangeset
for help on using the changeset viewer.