SystemSolver constructor

SystemSolver({
  1. required RealMatrix matrix,
  2. required List<double> knownValues,
  3. 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. This class can only be built with square matrices. In particular:

  • matrix is the matrix with the equations;
  • knownValues is the vector with the known values.

An exception of type SystemSolverException is thrown if the matrix is not square.

Implementation

SystemSolver({
  required this.matrix,
  required this.knownValues,
  this.precision = 1.0e-10,
}) {
  // Only square matrices are allowed.
  if (!matrix.isSquareMatrix) {
    throw const SystemSolverException('The matrix must be square');
  }

  // The vector of known values must match the size of the matrix.
  if (matrix.rowCount != knownValues.length) {
    throw const SystemSolverException(
      'The known values vector must have the '
      'same size as the matrix.',
    );
  }
}