Esempio n. 1
0
        public override Matrix <double> Inverse()
        {
            Matrix <double> X = new MatrixDouble(Col, Row);

            X.Arr = Accord.Math.Matrix.Inverse(Arr);
            return(X);
        }
Esempio n. 2
0
        public Matrix <double> Calculate(Matrix <double> a, Matrix <double> n)
        {
            int             order = 28;
            Matrix <double> U     = new MatrixDouble(a.Col, a.Row);
            Matrix <double> S     = new MatrixDouble(a.Col, a.Row);

            U = U.Unity();
            S = S.Unity();
            U = U * 20.98637;
            var Inv = (a - U).Inverse();
            var At  = (a + U) * Inv;
            var N   = n * Globals.MMPA_a28[0];
            var dx  = 100.0 / (order + 1.0);

            ExpStatusChangedEvent?.Invoke((int)(dx));
            for (int i = 1; i <= order; i++)
            {
                S = At * S;
                N = N + S * n * Globals.MMPA_a28[i];
                ExpStatusChangedEvent?.Invoke((int)((i + 1) * dx));
            }
            N.RemoveMinuses();

            return(N);
        }
Esempio n. 3
0
        private Matrix <double> exp(Matrix <double> a)
        {
            int             p    = 6;
            int             q    = 6;
            int             col  = a.Col;
            int             row  = a.Row;
            Matrix <double> N_pq = new MatrixDouble(col, row);
            Matrix <double> D_pq = new MatrixDouble(col, row);
            Matrix <double> temp;
            double          ff;

            for (int k = 0; k <= p; k++)
            {
                ff   = Globals.Factorial(p + q - k) * Globals.Factorial(p) / (Globals.Factorial(p + q) * Globals.Factorial(k) * Globals.Factorial(p - k));
                temp = a.Pow(k);
                N_pq = N_pq + (temp * ff);
            }

            for (int k = 0; k <= q; k++)
            {
                ff   = Globals.Factorial(p + q - k) * Globals.Factorial(q) / (Globals.Factorial(p + q) * Globals.Factorial(k) * Globals.Factorial(q - k));
                temp = a * (-1.0);
                temp = temp.Pow(k);
                D_pq = D_pq + (temp * ff);
            }
            temp = N_pq / D_pq;
            return(temp);
        }
Esempio n. 4
0
 private void initilaize(int count)
 {
     Matrix = new MatrixDouble(count, count);
     //DecayProbability = new MatrixDouble(count, count);
     //CaptureProbability = new MatrixDouble(count, count);
     //setDecayProbabilityMatrix();
     //setCaptureProbabilityMatrix();
     SetBurnMatrix();
 }
Esempio n. 5
0
        public override Matrix <double> Unity()
        {
            var unity = new MatrixDouble(this.Col, this.Row);

            for (int i = 0; i < Col; i++)
            {
                unity.Arr[i, i] = 1.0;
            }
            return(unity);
        }
Esempio n. 6
0
        protected override Matrix <double> Multiply(double k)
        {
            MatrixDouble result = new MatrixDouble(Col, Row);

            for (int i = 0; i < Col; i++)
            {
                for (int j = 0; j < Row; j++)
                {
                    result.Arr[i, j] = Arr[i, j] * k;
                }
            }
            return(result);
        }
Esempio n. 7
0
        protected override Matrix <double> Devide(double k)
        {
            MatrixDouble result = new MatrixDouble(this.Col, this.Row);

            for (int i = 0; i < Col; i++)
            {
                for (int j = 0; j < Row; j++)
                {
                    result.Arr[i, j] = Arr[i, j] / k;
                }
            }
            return(result);
        }
Esempio n. 8
0
        public override Matrix <double> Clone()
        {
            Matrix <double> result = new MatrixDouble(Col, Row);

            for (int i = 0; i < Col; i++)
            {
                for (int j = 0; j < Row; j++)
                {
                    result.Arr[i, j] = Arr[i, j];
                }
            }
            return(result);
        }
Esempio n. 9
0
        public Matrix <double> InverseOld()
        {
            Matrix <double> X = new MatrixDouble(Col, Row);
            Matrix <double> E = new MatrixDouble(Col, Row);

            E = E.Unity();
            double kf;
            int    RANG = Row;
            var    Temp = Clone();

            for (int p = 0; p < RANG; p++)
            {
                for (int i = p + 1; i < RANG; i++)
                {
                    if (Temp.Arr[p, p] == 0.0)
                    {
                        kf = 0;
                    }
                    else
                    {
                        kf = -Temp.Arr[i, p] / Temp.Arr[p, p];
                    }

                    for (int j = 0; j < RANG; j++)
                    {
                        E.Arr[i, j] = E.Arr[i, j] + kf * E.Arr[p, j];
                        if (j >= p)
                        {
                            Temp.Arr[i, j] = Temp.Arr[i, j] + kf * Temp.Arr[p, j];
                        }
                    }
                }
            }

            for (int k = 0; k < RANG; k++)
            {
                X.Arr[RANG - 1, k] = E.Arr[RANG - 1, k] / Temp.Arr[RANG - 1, RANG - 1];

                for (int i = RANG - 2; i >= 0; i--)
                {
                    double sum = 0.0;
                    for (int j = i + 1; j < RANG; j++)
                    {
                        sum = sum + X.Arr[j, k] * Temp.Arr[i, j];
                    }

                    X.Arr[i, k] = (E.Arr[i, k] - sum) / Temp.Arr[i, i];
                }
            }
            return(X);
        }
Esempio n. 10
0
        protected override Matrix <double> Multiply(Matrix <double> B)
        {
            MatrixDouble result = new MatrixDouble(this.Col, B.Row);

            if (this.Row == B.Col)
            {
                result.Arr = Accord.Math.Matrix.Dot(Arr, B.Arr);
                return(result);
            }
            else
            {
                throw new Exception("These matrices cannot be multiplied");
            }
        }
Esempio n. 11
0
        protected override Matrix <double> Substract(Matrix <double> B)
        {
            MatrixDouble result = new MatrixDouble(B.Col, B.Row);

            if (B.Col != this.Col || B.Row != this.Row)
            {
                throw new Exception("These matrices is not equal");
            }
            else
            {
                for (int i = 0; i < B.Col; i++)
                {
                    for (int j = 0; j < B.Row; j++)
                    {
                        result.Arr[i, j] = this.Arr[i, j] - B.Arr[i, j];
                    }
                }
                return(result);
            }
        }
Esempio n. 12
0
        protected override Matrix <double> Add(Matrix <double> A)
        {
            MatrixDouble result = new MatrixDouble(A.Col, A.Row);

            if (A.Col != this.Col || A.Row != this.Row)
            {
                throw new Exception("These matrices is not equal");
            }
            else
            {
                for (int i = 0; i < A.Col; i++)
                {
                    for (int j = 0; j < A.Row; j++)
                    {
                        result.Arr[i, j] = this.Arr[i, j] + A.Arr[i, j];
                    }
                }
                return(result);
            }
        }
Esempio n. 13
0
        public override Matrix <double> Pow(int p)
        {
            Matrix <double> result = new MatrixDouble(Col, Row);

            result = result.Unity();

            if (p == 0)
            {
            }
            else if (p == 1)
            {
                result = Clone();
            }
            else
            {
                result = Clone();
                for (int i = 1; i < p; i++)
                {
                    result = result * this;
                }
            }
            return(result);
        }