コード例 #1
0
ファイル: qMtrx.cs プロジェクト: wouldyougo/EMD
        /// <summary>
        /// вычисление R
        /// хз что это
        /// </summary>
        /// <param name="x"></param>
        /// <param name="Num_rs"></param>
        /// <returns></returns>
        public static TMatrix EvaluateR(TMatrix x, int Num_rs)
        {
            int i;
            double Val;
            double[] X_s;
            TMatrix Ret = new TMatrix(Num_rs, 1);

            if (x.GetRows() != 1)
                //throw E;
                throw new System.ApplicationException("неверные параметры вычислени¤ R");

            try
            {
                X_s = new double[x.GetCols()];
                for (i = 0; i < x.GetCols(); i++)
                    X_s[i] = x.GetElm(0, i);
                for (i = 0; i < Ret.GetRows(); i++)
                {
                    Val = GlobalMembersMtrx.eval_function(i, X_s, Num_rs, x.GetCols()); // ¬ычисл¤ем i-ю функцию
                    Ret.PutElm(i, 0, Val); // ‘ормируем Ret
                }
            }
            catch
            {
                //throw E;
                throw new System.ApplicationException();
            }
            X_s = null;
            return Ret;
        }
コード例 #2
0
ファイル: qMtrx.cs プロジェクト: wouldyougo/EMD
        //---------------------------------------------------------------------------
        /// <summary>
        /// вычисление матрицы якоби
        /// </summary>
        /// <param name="x">параметры вычислени¤ матрицы якоби</param>
        /// <param name="Num_rs">параметры вычислени¤ матрицы якоби</param>
        /// <param name="h">параметры вычислени¤ матрицы якоби</param>
        /// <returns></returns>
        public static TMatrix EvaluateJ(TMatrix x, int Num_rs, double h)
        {
            TMatrix Val_1 = new TMatrix();
            TMatrix Val_2 = new TMatrix();
            TMatrix Val = new TMatrix();

            if (x.GetRows() != 1)
                //throw E;
                throw new System.ApplicationException("неверные параметры вычислени¤ матрицы якоби");
            TMatrix Ret = new TMatrix(Num_rs, x.GetCols());
            TMatrix X_s = new TMatrix(1, x.GetCols());

            try
            {
                for (int i = 0; i < Ret.GetCols(); i++)
                {
                    for (int j = 0; j < X_s.GetCols(); j++)
                        X_s.PutElm(0, j, x.GetElm(0, j));
                    X_s.PutElm(0, i, x.GetElm(0, i) - h);
                    Val_1 = GlobalMembersMtrx.EvaluateR(X_s, Num_rs);
                    for (int j = 0; j < X_s.GetCols(); j++)
                        X_s.PutElm(0, j, x.GetElm(0, j));
                    X_s.PutElm(0, i, x.GetElm(0, i) + h);
                    Val_2 = GlobalMembersMtrx.EvaluateR(X_s, Num_rs);
                    Val = (1 / (2 * h)) * (Val_2 - Val_1);
                    for (int j = 0; j < Ret.GetRows(); j++)
                        Ret.PutElm(j, i, (double)Val.GetElm(j, 0));
                }
            }
            catch
            {
                //throw E;
                throw new System.ApplicationException();
            }
            return Ret;
        }
コード例 #3
0
ファイル: qMtrx.cs プロジェクト: wouldyougo/EMD
        //---------------------------------------------------------------------------
        //C++ TO C# CONVERTER NOTE: This 'CopyFrom' method was converted from the original C++ copy assignment operator:
        //ORIGINAL LINE: TMatrix& operator = (const TMatrix& M)
        public TMatrix CopyFrom(TMatrix M)
        {
            if (Data == null)
            {
                Rows = M.GetRows();
                Cols = M.GetCols();
                Data = new double[Rows][];
                for (int i = 0; i < Rows; i++)
                    Data[i] = new double[Cols];
            }
            else if (M.GetRows() != Rows || M.GetCols() != Cols)
            {
                for (int i = 0; i < Rows; i++)
                    Data[i] = null;
                Data = null;
                Rows = M.GetRows();
                Cols = M.GetCols();
                Data = new double[Rows][];
                for (int i = 0; i < Rows; i++)
                    Data[i] = new double[Cols];
            }

            for (int i = 0; i < Rows; i++)
                for (int j = 0; j < Cols; j++)
                    PutElm(i, j, M.GetElm(i, j));
            return this;
        }
コード例 #4
0
ファイル: qMtrx.cs プロジェクト: wouldyougo/EMD
 //---------------------------------------------------------------------------
 public TMatrix(ref TMatrix M)
 {
     Cols = M.GetCols();
     Rows = M.GetRows();
     Data = new double[Rows][];
     for (int i = 0; i < Rows; i++)
         Data[i] = new double[Cols];
     for (int i = 0; i < Rows; i++)
         for (int j = 0; j < Cols; j++)
             Data[i][j] = M.GetElm(i, j);
 }
コード例 #5
0
ファイル: qMatrix.cs プロジェクト: wouldyougo/EMD
        //---------------------------------------------------------------------------
        public List<List<double>> clcPIMatrix(List<List<double>> aMtrx)
        {
            int Row = 0;
            int Col = 0;
            Row = aMtrx.Count;
            if (Row != 0)
            {
                Col = aMtrx[0].Count;
            }
            TMatrix A = new TMatrix(Row, Col);
            for (int i = 0; i < Row; i++)
            {
                for (int j = 0; j < Col; j++)
                {
                    //         double tmp = 0;
                    //         tmp = aMtrx[i][j];
                    //         A.PutElm(i,j, tmp );
                    A.PutElm(i, j, aMtrx[i][j]);
                }
            }
            A = ~A;
            //List<List<double> > tVctr = new List<List<double> >(Col, new List<double>(Row));
            List<List<double>> tVctr = new List<List<double>>(Col);
            for (int i = 0; i < Col; i++)
                tVctr[i] = new List<double>(Row);

            for (int j = 0; j < Col; j++)
            {
                for (int i = 0; i < Row; i++)
                {
                    //         double tmp = 0;
                    //         tmp = A.GetElm(j,i);
                    //         tVctr[j][i] = tmp;
                    tVctr[j][i] = A.GetElm(j, i);
                }
            }
            return tVctr;
        }