Exemple #1
0
        public void LinearAlgebraComplexMatrix()
        {
            //using DotNumerics.LinearAlgebra;
            //using DotNumerics;

            ComplexMatrix A = new ComplexMatrix(3, 3);

            A[0, 0] = new Complex(3, 9); A[0, 1] = new Complex(4, 6); A[0, 2] = new Complex(1, 8);
            A[1, 0] = new Complex(8, 3); A[1, 1] = new Complex(2, 4); A[1, 2] = new Complex(5, 5);
            A[2, 0] = new Complex(2, 5); A[2, 1] = new Complex(7, 2); A[2, 2] = new Complex(5, 5);

            EigenSystem   es = new EigenSystem();
            ComplexMatrix eigenvectors;
            ComplexMatrix eigenvalues = es.GetEigenvalues(A, out eigenvectors);

            //Ax-lX=0
            Complex       lambda     = eigenvalues[0, 0];
            ComplexVector X          = eigenvectors.GetColumnVectors()[0];
            ComplexMatrix AXmlambdaX = A * X - lambda * X;

            ObjectDumper.Write("A=");
            ObjectDumper.Write(A.MatrixToString("0.000"));

            ObjectDumper.Write("Eigenvalues:");
            ObjectDumper.Write(eigenvalues.MatrixToString("0.000"));

            ObjectDumper.Write("Eigenvectors:");
            ObjectDumper.Write(eigenvectors.MatrixToString("0.000"));

            ObjectDumper.Write("A * X - lambda * X = ");
            ObjectDumper.Write(AXmlambdaX.MatrixToString("0.000"));
        }
Exemple #2
0
        public void LinearAlgebraEigenvaluesAndEigenvectors()
        {
            //using DotNumerics.LinearAlgebra;
            //using DotNumerics;

            Matrix A = new Matrix(3, 3);

            A[0, 0] = 2; A[0, 1] = 5; A[0, 2] = 3;
            A[1, 0] = 1; A[1, 1] = 5; A[1, 2] = 7;
            A[2, 0] = 8; A[2, 1] = 2; A[2, 2] = 3;

            EigenSystem   es = new EigenSystem();
            ComplexMatrix eigenvectors;
            ComplexMatrix eigenvalues = es.GetEigenvalues(A, out eigenvectors);

            //Ax-lX=0
            Complex       lambda     = eigenvalues[0, 0];
            ComplexVector X          = eigenvectors.GetColumnVectors()[0];
            ComplexMatrix AXmlambdaX = A.CopyToComplex() * X - lambda * X;

            ObjectDumper.Write("A=");
            ObjectDumper.Write(A.MatrixToString("0.000"));

            ObjectDumper.Write("Eigenvalues:");
            ObjectDumper.Write(eigenvalues.MatrixToString("0.000"));

            ObjectDumper.Write("Eigenvectors:");
            ObjectDumper.Write(eigenvectors.MatrixToString("0.000"));

            ObjectDumper.Write("A * X - lambda * X = ");
            ObjectDumper.Write(AXmlambdaX.MatrixToString("0.000"));
        }
Exemple #3
0
        static void Main(string[] args)
        {
            GraphLoader loader = new GraphLoader("completPartite.xml");
            loader.Init();
            Graph graph = loader.GetGraph();

            //graph.PrintVertex();
            //graph.PrintEdge();

            Matrix A = graph.GetAdjacentMatrix();
            Matrix D = graph.GetDegreeMatrix();

            Console.WriteLine("ADJACENT MATRIX:");
            Console.WriteLine(A.MatrixToString());

            Console.WriteLine("DEGREE MATRIX:");
            Console.WriteLine(D.MatrixToString());

            Matrix L = D.Subtract(A);

            Console.WriteLine("LAPLACIAN MATRIX:");
            Console.WriteLine(L.MatrixToString());

            EigenSystem eigSys = new EigenSystem();

            ComplexMatrix eigenVals = eigSys.GetEigenvalues(L);

            Console.WriteLine("EIGENVALUES:");
            Console.WriteLine(eigenVals.MatrixToString());

            GraphPlotter plotter = new GraphPlotter(graph);
            plotter.Draw();

            return;
        }
Exemple #4
0
        public void Schrodinger(double step, double range)
        {
            int size = (int)(range / step);

            EkMatrix = new SymmetricBandMatrix(size, 1);
            VMatrix  = new SymmetricBandMatrix(size, 1);
            HMatrix  = new SymmetricBandMatrix(size, 1);

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    // EkMatrix

                    if (i == j)
                    {
                        EkMatrix[i, j] = -2 * C / (step * step * 1e-18);
                    }
                    else if (Math.Abs(i - j) == 1)
                    {
                        EkMatrix[i, j] = 1 * C / (step * step * 1e-18);
                    }
                    else
                    {
                        EkMatrix[i, j] = 0;
                    }

                    //VMatrix

                    if (i == j && (j < (size - Width / step) / 2 || j > (size + Width / step) / 2))
                    {
                        VMatrix[i, j] = BarrierHeight * e;
                    }
                    else
                    {
                        VMatrix[i, j] = 0;
                    }
                }
            }

            HMatrix = EkMatrix + VMatrix;

            EigenSystem eigenSystem = new EigenSystem();


            eigenVals = eigenSystem.GetEigenvalues(HMatrix, out eigenVects);

            eigenVals.MultiplyInplace(1 / e);
            VMatrix.MultiplyInplace(1 / e);
            EkMatrix.MultiplyInplace(1 / e);
            HMatrix.MultiplyInplace(1 / e);
        }
Exemple #5
0
        public void LinearAlgebraEigenvalues()
        {
            //using DotNumerics.LinearAlgebra;
            //using DotNumerics;

            Matrix A = new Matrix(3, 3);

            A[0, 0] = 2; A[0, 1] = 5; A[0, 2] = 3;
            A[1, 0] = 1; A[1, 1] = 5; A[1, 2] = 7;
            A[2, 0] = 8; A[2, 1] = 2; A[2, 2] = 3;

            EigenSystem   es          = new EigenSystem();
            ComplexMatrix eigenvalues = es.GetEigenvalues(A);

            ObjectDumper.Write("A=");
            ObjectDumper.Write(A.MatrixToString("0.000"));

            ObjectDumper.Write("Eigenvalues:");
            ObjectDumper.Write(eigenvalues.MatrixToString("0.000"));
        }