JacobiSolver constructor

JacobiSolver({
  1. required List<List<double>> equations,
  2. required List<double> constants,
  3. required List<double> x0,
  4. int maxSteps = 30,
  5. double precision = 1.0e-10,
})

Given an equation in the form Ax = b, A is a square matrix containing n equations in n unknowns and b is the vector of the known values.

  • equations is the matrix containing the equations
  • constants is the vector with the known values
  • x0 is the initial guess (which is a vector)
  • precision tells how accurate the algorithm has to be
  • maxSteps the maximum number of iterations the algorithm

A must be strictly diagonally dominant.

Implementation

factory JacobiSolver({
  required List<List<double>> equations,
  required List<double> constants,
  required List<double> x0,
  int maxSteps = 30,
  double precision = 1.0e-10,
}) {
  // The initial vector with the guesses MUST have the same size as the matrix
  // of course
  if (x0.length != constants.length) {
    throw const SystemSolverException('The length of the guesses vector '
        'must match the size of the square matrix.');
  }

  return JacobiSolver._(
    equations: equations,
    constants: constants,
    x0: x0,
    maxSteps: maxSteps,
    precision: precision,
  );
}