public double[,] GetCoefficientsMatrix()
 {
     double[,] matrix = new double[Correlations.GetLength(0), Correlations.GetLength(1)];
     for (int i = 0; i < Correlations.GetLength(0); i++)
     {
         for (int j = 0; j < Correlations.GetLength(1); j++)
         {
             matrix[i, j] = Correlations[i, j].Coefficient;
         }
     }
     return(matrix);
 }
        public void AdjustToPositiveSemiDefinite()
        {
            int    iNum     = Correlations.GetLength(0);
            double minEigen = eigenvalues.Min();

            if (minEigen < 0)
            {
                for (int i = 0; i < iNum; i++)
                {
                    Correlations[i, i].Coefficient = Correlations[i, i].Coefficient - minEigen * 1.000000001;
                }
                for (int i = 0; i < iNum; i++)
                {
                    for (int j = 0; j < iNum; j++)
                    {
                        Correlations[i, j].Coefficient = Correlations[i, j].Coefficient / (1 - minEigen * 1.000000001);
                    }
                }
            }
        }