//public static double[][] MatrixExpViaEigenDecomp2(double[][] squareMatrix)
        //{
        //    DoubleArray matrix = new DoubleArray(squareMatrix);
        //    Eigen eigenSystem = new Eigen(matrix);

        //    ComplexArray exponentiatedDiagonal = ExpOfDiagComplex(eigenSystem.D);

        //    ComplexArray result = eigenSystem.V * exponentiatedDiagonal * eigenSystem.V.Inv();
        //    return ShoArrayToRaggedArray(result);
        //}



        private static ComplexArray ExpOfDiagComplex(ComplexArray complexArray)
        {
            double[,] real = new double[complexArray.Size()[0], complexArray.Size()[1]];
            double[,] img  = new double[complexArray.Size()[0], complexArray.Size()[1]];
            complexArray.ToArray(ref real, ref img);

            for (int i = 0; i < real.GetLength(0); i++)
            {
                real[i, i] = Math.Exp(real[i, i]);
                SpecialFunctions.SpecialFunctions.CheckCondition(img[i, i] == 0, "We can't deal with an imaginary number here.");
            }

            return(new ComplexArray(real, img));
        }
        internal static ComplexNumber[,] ShoArrayToArray(ComplexArray shoComplexArray)
        {
            double[,] real = new double[shoComplexArray.Size()[0], shoComplexArray.Size()[1]];
            double[,] img  = new double[shoComplexArray.Size()[0], shoComplexArray.Size()[1]];

            shoComplexArray.ToArray(ref real, ref img);

            ComplexNumber[,] result = new ComplexNumber[real.GetLength(0), real.GetLength(1)];
            for (int i = 0; i < result.GetLength(0); i++)
            {
                for (int j = 0; j < result.GetLength(1); j++)
                {
                    result[i, j] = new ComplexNumber(real[i, j], img[i, j]);
                }
            }

            return(result);
        }
        internal static ComplexNumber[] DiagonalShoArrayToArray(ComplexArray shoArray)
        {
            ComplexNumber[,] asMatrix = ShoArrayToArray(shoArray);
            ComplexNumber[] result = new ComplexNumber[shoArray.Size()[0]];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = asMatrix[i, i];
            }
            return(result);
        }