5 from scipy
.weave
import blitz
, inline
, converters
8 def sweep(_a
, _b
, _c
, _d
):
20 for i
in xrange(1, n
):
21 denom
= 1 / (b
[i
] - c
[i
-1] * a
[i
])
23 x
[i
] = (x
[i
] - x
[i
-1] * a
[i
]) * denom
26 for i
in xrange(n
- 2, -1, -1):
31 def native_sweep(_a
, _b
, _c
, _d
):
43 for (int i=1; i < n; i++) {
44 double denom = 1 / (b(i) - c(i - 1) * a(i));
46 x(i) = (x(i) - x(i - 1) * a(i)) * denom;
48 for (int i=n-2; i >= 0; i--) {
49 x(i) -= c(i) * x(i+1);
53 ['n', 'a', 'b', 'c', 'x'],
54 type_converters
=converters
.blitz
,
62 if __name__
== '__main__':