public void Dominant_ShouldCalculateDominantEigenvalueAndEigenvector( double eigenvalue, double[] eigenvector, double[,] source) { // Act var(actualEigVal, actualEigVec) = PowerIteration.Dominant(source, StartVector(source.GetLength(0)), epsilon); // Assert actualEigVal.Should().BeApproximately(eigenvalue, epsilon); actualEigVec.Magnitude().Should().BeApproximately(eigenvector.Magnitude(), epsilon); }
public void Dominant_ShouldThrowArgumentException_WhenSourceMatrixIsNotSquareShaped() { // Arrange var source = new double[, ] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 0, 0 } }; // Act Action action = () => PowerIteration.Dominant(source, StartVector(source.GetLength(0)), epsilon); // Assert action.Should().Throw <ArgumentException>().WithMessage("The source matrix is not square-shaped."); }
public void Dominant_ShouldThrowArgumentException_WhenStartVectorIsNotSameSizeAsMatrix() { // Arrange var source = new double[, ] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; var startVector = new double[] { 1, 0, 0, 0 }; // Act Action action = () => PowerIteration.Dominant(source, startVector, epsilon); // Assert action.Should().Throw <ArgumentException>() .WithMessage("The length of the start vector doesn't equal the size of the source matrix."); }