public void GetAnswer_AnyMatrix_ReturnVector(Matrix matrix, Vector vector) { Vector result = GaussWithChoiceSolveSystem.FindAnswer(matrix, vector); Vector rightSide = CalculateRightSide(matrix, result); Assert.AreEqual(vector, rightSide); }
private static Vector ComputeNormal(Matrix leftSide) { Vector rightSide = new Vector(leftSide.Rows); try { return(GaussWithChoiceSolveSystem.FindAnswer(leftSide, rightSide)); } catch (InvalidOperationException) { throw new ArgumentException("Vectors are linearly dependent"); } }
public void GetAnswer_DeterminateMatrix_ReturnVector() { double[,] points = new double[3, 3] { { 1, 2, 3 }, { 3, 5, 7 }, { 1, 3, 4 } }; Matrix matrix = new Matrix(points); Vector vector = new Vector(new double[3] { 3, 0, 1 }); Vector expect = new Vector(new double[3] { -4, -13, 11 }); Vector result = GaussWithChoiceSolveSystem.FindAnswer(matrix, vector); Assert.AreEqual(expect, result); }