private double[] findGaussianBasis() { int n = InputPoints.Count; double[,] Ab = new double[n, n + 1]; // n + 1 because the result (Y) will be here // Create Basis matrix. Xl -> Xn, Xr -> X[1..n] in formula for (int i = 0; i < n; i++) { double xL = InputPoints[i].X; for (int j = 0; j < n; j++) { double xR = InputPoints[j].X; Ab[i, j] = Math.Exp(-Alpha * Math.Pow(xL - xR, 2)); } Ab[i, n] = InputPoints[i].Y; } try { return(GaussJordanElimination.SolveSystem(Ab, n)); } catch (NoSolutionException e) { throw new InterpolationException("Решения для базисов ф-и Гаусса НЕ найдено!", e); } catch (InfiniteSolutionException e) { throw new InterpolationException("Решения для базисов ф-и Гаусса содержит бесконечность!", e); } catch (Exception e) { throw new InterpolationException("GaussJordanElimination Error", e); } }
public static void UnableToSolveSingularMatrix() { // Arrange var solver = new GaussJordanElimination(); var input = new double[, ] { { 0, 0, 0 }, { 0, 0, 0 } }; // Act var result = solver.Solve(input); // Assert Assert.IsFalse(result); }
public static void NonSquaredMatrixThrowsException() { // Arrange var solver = new GaussJordanElimination(); var input = new double[, ] { { 2, -1, 5 }, { 0, 2, 1 }, { 3, 17, 7 } }; // Act void Act() => solver.Solve(input); // Assert _ = Assert.Throws <ArgumentException>(Act); }
/// <summary>Solves the linear equation system. If the system has no solution, the result is undefined.</summary> public void Solve() { GaussJordanElimination.Solve(Matrix, RightHandSide, Solution); }
public void Managed() { GaussJordanElimination.Solve_Managed_double(system.Matrix, system.RightHandSide, system.Solution); }
public void Native() { GaussJordanElimination.Solve_Native_double(system.Matrix, system.RightHandSide, system.Solution); }