Example #1
0
        static void Main(string[] args)
        {
            Function      f      = new Function((x, y) => Math.Sin(x) - Math.Cos(y));
            EulerModified eulerM = new EulerModified(f, 0, 1, 1, 5);
            EulerSimple   eulerS = new EulerSimple(f, 0, 1, 1, 5);
            RungeKutta4   rk4    = new RungeKutta4(f, 0, 1, 1, 5);

            double[,] MAT = new double[, ] {
                { 1, 23, 32, 1 }, { 1, 5, 1, 1 }, { 32, 1, 1, 1 }, { 1, 10, 1, 1 }
            };

            // double[,] MAT = new double[,] { { 3 ,0 ,2 }, { 2,0,-2 }, { 0,1,1 } };

            MatrixInverse MATINV = new MatrixInverse();

            MAT = MATINV.InvMatrix(MAT, 4);



            double[,] EQU = new double[, ] {
                { 1, 2, -1 }, { 3, 5, -1 }, { -2, -1, -2 }
            };
            double[]     ANS    = new double[] { 6, 2, 4 };
            MatInvMethod SOLVER = new MatInvMethod();

            SOLVER.MatrixInverseMethod(EQU, ANS, 3);
            double[] result = SOLVER.GetSolution();
        }
Example #2
0
        /// <summary>
        /// Solve N Linear Equations [A][x]=[B] using Matrix Inverse Method
        /// http://www.intmath.com/matrices-determinants/6-matrices-linear-equations.php
        /// </summary>
        /// Coded by : ahmed osama  ([email protected])
        /// <summary>
        ///  Parameters of entries:
        /// </summary>
        /// <param name="A">Coeff. Array N x N , </param>
        /// <param name="B">Ans. array N item </param>
        /// <param name="N">No. of Linear Equations </param>
        ///

        public void MatrixInverseMethod(double [,] A, double [] B, int N)
        {
            double [,] tmp;
            result = new double[N];

            MatrixInverse MATINV = new MatrixInverse();

            tmp = MATINV.InvMatrix(A, N);

            for (int R = 0; R < N; R++)
            {
                for (int C = 0; C < N; C++)
                {
                    result[R] = result[R] + tmp[R, C] * B[C];
                }
            }
        }