/// <summary>
        /// Multiplication of two rows from two matrices respectively.
        /// </summary>
        /// <param name="matrix"></param>
        /// <param name="row"></param>
        /// <param name="other"></param>
        /// <param name="otherRow"></param>
        /// <returns></returns>
        public static double RowMultiplication(this DenseMatrix <double> matrix, int row, DenseMatrix <double> other, int otherRow)
        {
            double sum = 0.0;

            for (int i = 0; i < matrix.NumberOfColumns; i++)
            {
                sum += matrix[row, i] * other[otherRow, i];
            }
            return(sum);
        }
        /// <summary>
        /// Inverse of a matrix.
        /// </summary>
        /// <param name="matrix">The inversed matrix</param>
        /// <returns></returns>
        public static DenseMatrix <double> Inverse(this DenseMatrix <double> matrix)
        {
            int m = matrix.NumberOfRows;
            int n = matrix.NumberOfColumns;

            double[,] array = new double[2 * m + 1, 2 * n + 1];
            for (int k = 0; k < 2 * m + 1; k++)  // Initialize
            {
                for (int t = 0; t < 2 * n + 1; t++)
                {
                    array[k, t] = 0.00000000;
                }
            }
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    array[i, j] = matrix[i, j];
                }
            }

            for (int k = 0; k < m; k++)
            {
                for (int t = n; t <= 2 * n; t++)
                {
                    if ((t - k) == m)
                    {
                        array[k, t] = 1.0;
                    }
                    else
                    {
                        array[k, t] = 0;
                    }
                }
            }
            //得到逆矩阵
            for (int k = 0; k < m; k++)
            {
                if (array[k, k] != 1)
                {
                    double bs = array[k, k];
                    array[k, k] = 1;
                    for (int p = k + 1; p < 2 * n; p++)
                    {
                        array[k, p] /= bs;
                    }
                }
                for (int q = 0; q < m; q++)
                {
                    if (q != k)
                    {
                        double bs = array[q, k];
                        for (int p = 0; p < 2 * n; p++)
                        {
                            array[q, p] -= bs * array[k, p];
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            DenseMatrix <double> NI = new DenseMatrix <double>(m, n);

            for (int x = 0; x < m; x++)
            {
                for (int y = n; y < 2 * n; y++)
                {
                    NI[x, y - n] = array[x, y];
                }
            }
            return(NI);
        }