コード例 #1
0
        public MatrixValue Function(MatrixValue A, MatrixValue x, MatrixValue b)
        {
            var gmres = new GMRESkSolver(A);

            gmres.X0 = x;
            return(gmres.Solve(b));
        }
コード例 #2
0
        public static Double[,] Solve(Double[,] A, Double[,] b)
        {
            if (Helpers.IsSymmetric(A))
            {
                return(Cg(A, b));
            }
            else if (A.GetLength(0) == A.GetLength(1) && A.GetLength(0) > 64) // Is there a way to "guess" a good number for this?
            {
                var gmres = new GMRESkSolver(A);
                gmres.Restart = 30;
                return(gmres.Solve(b));
            }

            return(Helpers.Multiply(Inverse(A), b));
        }
コード例 #3
0
        public MatrixValue Function(MatrixValue M, MatrixValue phi)
        {
            if (M.IsSymmetric)
            {
                var cg = new CGSolver(M);
                return(cg.Solve(phi));
            }
            else if (M.DimensionX == M.DimensionY && M.DimensionY > 64)             // Is there a way to "guess" a good number for this?
            {
                var gmres = new GMRESkSolver(M);
                gmres.Restart = 30;
                return(gmres.Solve(phi));
            }

            return(M.Inverse() * phi);
        }
コード例 #4
0
        public static Double[,] Gmres(Double[,] A, Double[,] b)
        {
            var cg = new GMRESkSolver(A);

            return(cg.Solve(b));
        }