예제 #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));
        }
예제 #2
0
 public static void ComputeEigenvectors(this SymmetricMatrix2 @this, out Vector2 low, out Vector2 high)
 {
     low  = @this.LowEigenvector();
     high = low.Rotate90();
 }