Exemple #1
0
        public void Eigenvectors_and_eigenvalues_of_satisfy_defining_equations
            ([Values(0.577, 0.577, 0.577, 0.577)] double xx,
            [Values(2.718, 0.577, 0.577, 0.577)] double yy,
            [Values(3.141, 0, 1e-40, 1e-60)] double xy)
        {
            var mat = new SymmetricMatrix2(xx, yy, xy);

            var loVal = mat.LowEigenvalue();
            var loVec = mat.LowEigenvector();

            Expect((mat - SymmetricMatrix2.Scalar(loVal)).Det(), Is.EqualTo(0).Within(_tolerance));
            Expect(Vector2.Distance(mat * loVec, loVal * loVec), Is.LessThan(_tolerance));

            var hiVal = mat.HighEigenvalue();
            var hiVec = mat.HighEigenvector();

            Expect((mat - SymmetricMatrix2.Scalar(hiVal)).Det(), Is.EqualTo(0).Within(_tolerance));
            Expect(Vector2.Distance(mat * hiVec, hiVal * hiVec), Is.LessThan(_tolerance));

            Expect(loVal, Is.LessThan(hiVal + _tolerance));
            Expect(loVal + hiVal, Is.EqualTo(mat.Trace()).Within(_tolerance));
        }
Exemple #2
0
 public static void ComputeLowEigendata(this SymmetricMatrix2 @this, out double eigenvalue, out Vector2 eigenvector)
 {
     eigenvalue  = @this.LowEigenvalue();
     eigenvector = @this.Eigenvector(eigenvalue);
 }
Exemple #3
0
 public static Vector2 LowEigenvector(this SymmetricMatrix2 @this)
 {
     return(@this.Eigenvector(@this.LowEigenvalue()));
 }