File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
tests/LinearAlgebra/Eigen Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ class EigenAxiomsTest extends \PHPUnit\Framework\TestCase
2424 * - tr(A) = Σλᵢ (trace equals sum of eigenvalues)
2525 * - det(A) = Πλᵢ (determinant equals product of eigenvalues)
2626 * - Aⁿv = λⁿv (matrix power property)
27+ * - Eigenvalues of a triangular matrix are its diagonal entries
2728 */
2829
2930 /**************************************************************************
@@ -170,6 +171,32 @@ public function testMatrixPowerProperty(array $A, int $n)
170171 }
171172 }
172173
174+ /**
175+ * @test Axiom: Eigenvalues of a triangular matrix are its diagonal entries
176+ * For a triangular matrix (upper or lower), its eigenvalues are simply the entries on its main diagonal.
177+ *
178+ * @dataProvider dataProviderForUpperTriangularMatrix
179+ * @dataProvider dataProviderForLowerTriangularMatrix
180+ * @param array $A
181+ * @throws \Exception
182+ */
183+ public function testEigenvaluesOfTriangularMatrixAreDiagonalEntries (array $ A )
184+ {
185+ // Given
186+ $ A = MatrixFactory::create ($ A );
187+
188+ // When
189+ $ eigenvalues = $ A ->eigenvalues ();
190+ $ diagonal = $ A ->getDiagonalElements ();
191+
192+ // And
193+ sort ($ eigenvalues );
194+ sort ($ diagonal );
195+
196+ // Then
197+ $ this ->assertEqualsWithDelta ($ diagonal , $ eigenvalues , 1e-6 );
198+ }
199+
173200 /**************************************************************************
174201 * DATA PROVIDERS FOR EIGENVALUE TESTS
175202 **************************************************************************/
You can’t perform that action at this time.
0 commit comments