public void Algorithm() { _matrix = new double[3, 3] { { 3, 1, 1 }, { 0, 5, 1 }, { 2, 0, 3 } }; IVector resultActual = new Vector(new double[] { 1, 1, 1 }); DenseMatrix denseMatrix = new DenseMatrix(_matrix); Vector x0 = new Vector(new double[] { 0, 0, 0 }); IVector b = denseMatrix.Multiply(resultActual); var result = loggingSolver.Solve(denseMatrix, x0, b); foreach (var elem in result) { _testOutputHelper.WriteLine(elem.ToString()); } for (int i = 0; i < resultActual.Size; i++) { Assert.Equal(result[i], resultActual[i], 8); } }
private Task <IVector> RunAsync(LoggingSolver loggingSolver, IMatrix matrix, IVector x0, IVector b) { return(Task.Run(() => { return loggingSolver.Solve((ILinearOperator)matrix, x0, b); })); }
public void TestAlgorithmCountMult() { var proxyMethod = new ProxyMethod(new JacobiMethod()); loggingSolver = new LoggingSolver(proxyMethod, Logger); double[,] _matrix = new double[3, 3] { { 3, 1, 1 }, { 0, 5, 1 }, { 2, 0, 3 } }; IVector resultActual = new Vector(new double[] { 1, 1, 1 }); DenseMatrix denseMatrix = new DenseMatrix(_matrix); ProxyMatrix proxyMatrix = new ProxyMatrix(denseMatrix); Vector x0 = new Vector(new double[] { 0, 0, 0 }); IVector b = denseMatrix.Multiply(resultActual); var result = loggingSolver.Solve(proxyMatrix, x0, b); var MultCount = proxyMethod.MultCount; _testOutputHelper.WriteLine(MultCount[0].ToString()); _testOutputHelper.WriteLine(MultCount[1].ToString()); for (int i = 0; i < resultActual.Size; i++) { Assert.Equal(result[i], resultActual[i], 8); } }
public void TestAlgorithm() { _matrix = new double[3, 3] { { 3, 1, 1 }, { 0, 5, 1 }, { 2, 0, 3 } }; IVector resultActual = new Vector(new double[] { 1, 1, 1 }); DenseMatrix denseMatrix = new DenseMatrix(_matrix); Vector x0 = new Vector(new double[] { 0, 0, 0 }); IVector b = denseMatrix.Multiply(resultActual); var result = loggingSolver.Solve(denseMatrix, x0, b); Assert.NotEmpty(result); }
public void TestAlgorithm() { _matrix = new double[3, 3] { { 3, 1, 1 }, { 0, 5, 1 }, { 2, 0, 3 } }; IVector resultActual = new Vector(new double[] { 1, 1, 1 }); DenseMatrix denseMatrix = new DenseMatrix(_matrix); Vector x0 = new Vector(new double[] { 0, 0, 0 }); IVector b = denseMatrix.Multiply(resultActual); var result = loggingSolver.Solve(denseMatrix, x0, b); for (int i = 0; i < resultActual.Size; i++) { Assert.Equal(result[i], resultActual[i], 8); } }