Beispiel #1
0
        public static Polynomial Parse(string ip)
        {
            MATHEMATICS math = new MATHEMATICS(12);

            string[]   co  = ip.Split(',');
            Polynomial res = new Polynomial(co.Length);

            for (int i = 0; i < co.Length; i++)
            {
                res[i] = math.EvaluateReal(co[i]);
            }
            return(res);
        }
Beispiel #2
0
        public static Matrix MatAcosh(Matrix A)
        {
            MATHEMATICS math = new MATHEMATICS(12);

            if (!A.IsSquare())
            {
                throw new Exception("Required Square Matrix");
            }
            Matrix s = new Matrix(A.rows, A.cols);

            for (int i = 1; i <= 12; i++)
            {
                s += (math.fact(2 * i) * Matrix.Power(A, -2 * i)) / (Math.Pow(4, i) * math.fact(i) * math.fact(i) * (2 * i));
            }
            return(MatLog(2 * A) - s);
        }
Beispiel #3
0
        public static Matrix MatAtanh(Matrix A)
        {
            MATHEMATICS math = new MATHEMATICS(12);

            if (!A.IsSquare())
            {
                throw new Exception("Required Square Matrix");
            }
            Matrix I = IdentityMatrix(A.rows, A.cols);
            Matrix s = new Matrix(A.rows, A.cols);

            for (int i = 0; i <= 12; i++)
            {
                s += (Matrix.Power(A, 2 * i + 1)) / ((2 * i + 1));
            }
            return(s);
        }
Beispiel #4
0
        public static Matrix MatLog(Matrix A)
        {
            MATHEMATICS math = new MATHEMATICS(12);

            if (!A.IsSquare())
            {
                throw new Exception("Required Square Matrix");
            }
            Matrix I = IdentityMatrix(A.rows, A.cols);
            Matrix s = new Matrix(A.rows, A.cols);

            for (int i = 1; i <= 12; i++)
            {
                s += Math.Pow(-1, i + 1) * ((Matrix.Power(A - I, i)) / i);
            }
            return(s);
        }
Beispiel #5
0
        public static Matrix  MatExp(Matrix A)
        {
            MATHEMATICS math = new MATHEMATICS(12);

            if (!A.IsSquare())
            {
                throw new Exception("Required Square Matrix");
            }
            Matrix I = IdentityMatrix(A.rows, A.cols);
            Matrix s = new Matrix(A.rows, A.cols);

            for (int i = 1; i <= 12; i++)
            {
                s += (Matrix.Power(A, i)) / math.fact(i);
            }
            return(I + s);
        }
Beispiel #6
0
        public static Matrix Parse2(string ps)
        // Function parses the matrix from string
        {
            MATHEMATICS math = new MATHEMATICS(10);
            string      s    = NormalizeMatrixString(ps);

            string[] rows   = ps.Split('\n');
            string[] nums   = rows[0].Split('\t');
            Matrix   matrix = new Matrix(rows.Length, nums.Length);

            try
            {
                for (int i = 0; i < rows.Length; i++)
                {
                    nums = rows[i].Split('\t');
                    for (int j = 0; j < nums.Length; j++)
                    {
                        matrix[i, j] = math.EvaluateReal(nums[j]);
                    }
                }
            }
            catch (FormatException) { throw new MException("Wrong input format!"); }
            return(matrix);
        }