solve method
Solves the Ax = b
equation and returns the x
vector containing the
solutions of the system.
Implementation
@override
List<double> solve() {
// Exit conditions for the method
var k = 0;
var diff = precision + 1;
// Support lists
final size = knownValues.length;
final phi = List<double>.generate(size, (_) => 0);
// Jacobi
while ((diff >= precision) && (k < maxSteps)) {
for (var i = 0; i < size; ++i) {
var sigma = 0.0;
for (var j = 0; j < size; ++j) {
if (j != i) {
sigma += equations(i, j) * phi[j];
}
}
phi[i] =
(1 - w) * phi[i] + (w / equations(i, i)) * (knownValues[i] - sigma);
}
++k;
diff = _euclideanNorm(phi);
}
return phi;
}