MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / solve

Function solve

code/mathematics/tridiagonal.cpp:3–10  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#define MAXN 5000
2long double A[MAXN], B[MAXN], C[MAXN], D[MAXN], X[MAXN];
3void solve(int n) {
4 C[0] /= B[0]; D[0] /= B[0];
5 rep(i,1,n-1) C[i] /= B[i] - A[i]*C[i-1];
6 rep(i,1,n)
7 D[i] = (D[i] - A[i] * D[i-1]) / (B[i] - A[i] * C[i-1]);
8 X[n-1] = D[n-1];
9 for (int i = n-2; i>=0; i--)
10 X[i] = D[i] - C[i] * X[i+1]; }
11// vim: cc=60 ts=2 sts=2 sw=2:

Callers 1

testFunction · 0.85

Calls

no outgoing calls

Tested by 1

testFunction · 0.68