Esempio n. 1
0
        public static bool IsNearlyEigenpair(AnySquareMatrix A, ColumnVector v, double a)
        {
            // compute products
            ColumnVector Av = A * v;
            ColumnVector av = a * v;

            // compute tolerance
            int    d  = v.Dimension;
            double N  = A.MaxNorm();
            double n  = v.MaxNorm();
            double ep = TargetPrecision * (Math.Abs(N * n) / d + Math.Abs(a * n));

            // compare elements within tolerance
            for (int i = 0; i < d; i++)
            {
                if (Math.Abs(Av[i] - av[i]) > ep)
                {
                    return(false);
                }
            }
            return(true);
        }