public static void CorrectEigenvectorsTest(double[] a) { var matrix = SquareMatrixHelper.SquareMatrix(a); var eigenvalues = matrix.Eigenvalues(); var eigenvectors = matrix.GetEigenvectors(); Assert.AreEqual(matrix * eigenvectors.Column(0), eigenvalues[0].Re * eigenvectors.Column(0)); if ((eigenvalues[0].Re - eigenvalues[1].Re).IsZero() && matrix.GetGeometricMultiplicity(eigenvalues[0].Re) == 1) { Assert.AreNotEqual(matrix * eigenvectors.Column(1), eigenvalues[1].Re * eigenvectors.Column(1)); } else { Assert.AreEqual(matrix * eigenvectors.Column(1), eigenvalues[1].Re * eigenvectors.Column(1)); } }
public static void CorrectMatrixExponentialCalculations(double[] actualEntries, double[] expectedExpMEntries) { var expectedExpM = SquareMatrixHelper.ExpM(SquareMatrixHelper.SquareMatrix(actualEntries))(1.0); Assert.AreEqual(expectedExpMEntries, GetOriginEntries(expectedExpM)); }
public static double[] CorrectEigenvaluesTest(double[] a) { return(GetEigenvaluesArray(SquareMatrixHelper.SquareMatrix(a).Eigenvalues())); }