private double pivot(MatrixR A, VectorR b, int q)
        {
            int    n = b.GetSize();
            int    i = q;
            double d = 0.0;

            for (int j = q; j < n; j++)
            {
                double dd = Math.Abs(A[j, q]);
                if (dd > d)
                {
                    d = dd;
                    i = j;
                }
            }
            if (i > q)
            {
                A.GetRowSwap(q, i);
                b.GetSwap(q, i);
            }
            return(A[q, q]);
        }