9
L = spmatrix.ll_mat(n*n, n*n)
25
L = spmatrix.ll_mat_sym(n*n)
36
def poisson2d_sym_blk(n):
37
L = spmatrix.ll_mat_sym(n*n)
38
I = spmatrix.ll_mat_sym(n)
39
P = spmatrix.ll_mat_sym(n)
44
if i > 0: P[i,i-1] = -1
45
for i in range(0, n*n, n):
47
if i > 0: L[i:i+n,i-n:i] = I
54
print 'Time for constructing the matrix: %8.2f sec' % (time.clock() - t1, )
55
#L.export_mtx('poi2d_100.mtx')
64
b = numpy.ones(n*n, 'd')
65
e = numpy.ones(n*n, 'd')
66
c = numpy.ones(n*n, 'd')
67
for loop in xrange(n*n):
70
y = numpy.ones(n*n, 'd')
76
# ---------------------------------------------------------------------------------------
80
x = numpy.zeros(n*n, 'd')
81
info, iter, relres = itsolvers.gmres(S, b, x, 1e-12, 200, None, 100)
82
print 'info=%d, iter=%d, relres=%e' % (info, iter, relres)
84
print 'Time for solving the system using SSS matrix: %8.2f sec' % (time.clock() - t1, )
86
print 'norm(x) = %g' % math.sqrt(numpy.dot(x, x))
88
r = numpy.zeros(n*n, 'd')
91
print 'norm(b - A*x) = %g' % math.sqrt(numpy.dot(r, r))
93
# ---------------------------------------------------------------------------------------
97
x = numpy.zeros(n*n, 'd')
98
info, iter, relres = itsolvers.gmres(A, b, x, 1e-12, 200)
99
print 'info=%d, iter=%d, relres=%e' % (info, iter, relres)
101
print 'Time for solving the system using CSR matrix: %8.2f sec' % (time.clock() - t1, )
103
print 'norm(x) = %g' % math.sqrt(numpy.dot(x, x))
105
r = numpy.zeros(n*n, 'd')
108
print 'norm(b - A*x) = %g' % math.sqrt(numpy.dot(r, r))
110
# ---------------------------------------------------------------------------------------
114
x = numpy.zeros(n*n, 'd')
115
info, iter, relres = itsolvers.gmres(L, b, x, 1e-12, 200)
116
print 'info=%d, iter=%d, relres=%e' % (info, iter, relres)
118
print 'Time for solving the system using LL matrix: %8.2f sec' % (time.clock() - t1, )
120
print 'norm(x) = %g' % math.sqrt(numpy.dot(x, x))
122
r = numpy.zeros(n*n, 'd')
125
print 'norm(b - A*x) = %g' % math.sqrt(numpy.dot(r, r))
126
# ---------------------------------------------------------------------------------------
128
K_ssor = precon.ssor(S, 1.0)
131
x = numpy.zeros(n*n, 'd')
132
info, iter, relres = itsolvers.gmres(S, b, x, 1e-12, 500, K_ssor, 20)
133
print 'info=%d, iter=%d, relres=%e' % (info, iter, relres)
135
print 'Time for solving the system using SSS matrix and SSOR preconditioner: %8.2f sec' % (time.clock() - t1, )
137
print 'norm(x) = %g' % math.sqrt(numpy.dot(x, x))
139
r = numpy.zeros(n*n, 'd')
142
print 'norm(b - A*x) = %g' % math.sqrt(numpy.dot(r, r))
144
# ---------------------------------------------------------------------------------------
147
#jdsym.jdsym(S, None, None, 5, 0.0, 1e-8, 20, itsolvers.qmrs, clvl=1)
149
x = numpy.zeros(n*n, 'd')
150
info, iter, relres = itsolvers.gmres(S, b, x, 1e-15, 500, K_ssor, 50)
151
print 'info=%d, iter=%d, relres=%e' % (info, iter, relres)
153
print 'Time for solving the system using SSS matrix and SSOR preconditioner: %8.2f sec' % (time.clock() - t1, )
155
print 'norm(x) = %g' % math.sqrt(numpy.dot(x, x))
157
r = numpy.zeros(n*n, 'd')
160
print 'norm(b - A*x) = %g' % math.sqrt(numpy.dot(r, r))