Changeset 586 for inundation/ga/storm_surge/pyvolution/test_cg_solve.py
- Timestamp:
- Nov 17, 2004, 5:48:23 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/test_cg_solve.py
r475 r586 6 6 from Numeric import dot, allclose, array, transpose, arange, ones, Float 7 7 from cg_solve import * 8 from sparse import Sparse 8 from sparse import Sparse, Sparse_CSR 9 9 10 10 … … 78 78 assert allclose(x,xe) 79 79 80 def test_solve_large_2d_csr_matrix(self): 81 """Standard 2d laplacian""" 82 83 n = 50 84 m = 50 85 86 A = Sparse(m*n, m*n) 87 88 for i in arange(0,n): 89 for j in arange(0,m): 90 I = j+m*i 91 A[I,I] = 4.0 92 if i > 0 : 93 A[I,I-m] = -1.0 94 if i < n-1 : 95 A[I,I+m] = -1.0 96 if j > 0 : 97 A[I,I-1] = -1.0 98 if j < m-1 : 99 A[I,I+1] = -1.0 100 101 xe = ones( (n*m,), Float) 102 103 # Convert to csr format 104 #print 'start covert' 105 A = Sparse_CSR(A) 106 #print 'finish covert' 107 b = A*xe 108 x = conjugate_gradient(A,b,b,iprint=10) 109 110 assert allclose(x,xe) 111 80 112 81 113 def test_solve_large_2d_with_default_guess(self):
Note: See TracChangeset
for help on using the changeset viewer.