private void button_solve_Click(object sender, EventArgs e) { int serverCount = DEFAULT_SERVER_COUNT; try { serverCount = int.Parse(server_count.Text); } catch (Exception exc) { } try { GaussStatisticsMaker gaussStatisticsMaker = new GaussStatisticsMaker(matrix, 1, 2, 3, 4); gaussStatisticsMaker.MakeStatistic(); gaussStatistics = gaussStatisticsMaker.GetWorkStatistic(); DrawChart(); GaussMethod gaussMethod = new GaussMethod(matrix); gaussMethod.Solve(); VectorInterface <double> result = gaussMethod.GetSolution(); FileHandler.WriteMatrix(matrix); FileHandler.WriteSolution(result); } catch (Exception exc) { } }
public void Variables_3_matrix_solve() { VectorInterface <Double> expected = new DoubleVector(-2f / 11.0, 1f / 11.0, 5f / 11.0); GaussMethod gaussMethod = new GaussMethod(new Double[][] { new double[] { 3.0, 2.0, 3.0, 1.0 }, new double[] { 4.0, 4.0, 3.0, 1.0 }, new double[] { 1.0, 4.0, 4.0, 2.0 } }); gaussMethod.Solve(); VectorInterface <Double> actual = gaussMethod.GetSolution(); Assert.AreEqual(expected, actual); }
public static void WriteSolution(VectorInterface <double> solution) { StringBuilder data = new StringBuilder(); for (int j = 0; j < solution.Count; j++) { data.Append(solution[j]); if (j != solution.Count - 1) { data.Append('\n'); } } Write("solution.txt", data.ToString()); }
private void TestFile(string testName) { VectorInterface <Double> expected = new DoubleVector( Parser.parseVector(FileHandler.Read("tests/" + testName + "/" + testName + ".des"))); DoubleMatrix doubleMatrix = new DoubleMatrix( Parser.parseMatrix(FileHandler.Read("tests/" + testName + "/" + testName + ".A"))); doubleMatrix.UpendColumn(new DoubleVector( Parser.parseVector(FileHandler.Read("tests/" + testName + "/" + testName + ".B")))); GaussMethod gaussMethod = new GaussMethod(doubleMatrix); gaussMethod.Solve(); VectorInterface <Double> actual = gaussMethod.GetSolution(); Assert.AreEqual(expected, actual); }