Exemplo n.º 1
0
        public double SlezTestBig(int size)
        {
            var mat1 = new MCJCMatrix(size, size);
            var mat2 = new MCJCMatrix(size, size);

            var random = new Random();

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    mat1.setAt(i, j, random.NextDouble(), 0);
                    mat2.setAt(i, j, random.NextDouble(), 0);
                }
            }

            var time = DateTime.Now;
            var lib  = new MLapackLib();

            var result = new MCJCMatrix(size, size);

            Console.WriteLine("multiplication started...");


            lib.solveSLE(mat1, mat2, result);


            Console.WriteLine("multiplication completed.");

            double ms = (DateTime.Now - time).TotalMilliseconds;

            Console.WriteLine("time = " + ms);
            return(ms);
        }
Exemplo n.º 2
0
        public void EigenValsTest()
        {
            var matrix1 = new NRealMatrix(2, 2);

            matrix1[0, 0] = 1;
            matrix1[0, 1] = 2;
            matrix1[1, 0] = 3;
            matrix1[1, 1] = 4;

            var w  = new MCJCMatrix(2, 2);
            var vl = new MCJCMatrix(2, 2);
            var vr = new MCJCMatrix(2, 2);

            var lib = new MLapackLib();

            lib.eigenVals(matrix1.ManagedMatrix, w, vl, vr);

            Console.WriteLine("w");
            PrintComplexMatrix(w);

            Console.WriteLine("vl");
            PrintComplexMatrix(vl);

            Console.WriteLine("vr");
            PrintComplexMatrix(vr);
        }
Exemplo n.º 3
0
        public void EigenValsTest()
        {
            var matrix1 = new NRealMatrix(2, 2);
            matrix1[0, 0] = 1;
            matrix1[0, 1] = 2;
            matrix1[1, 0] = 3;
            matrix1[1, 1] = 4;

            var w = new MCJCMatrix(2, 2);
            var vl = new MCJCMatrix(2, 2);
            var vr = new MCJCMatrix(2, 2);

            var lib = new MLapackLib();

            lib.eigenVals(matrix1.ManagedMatrix, w, vl, vr);

            Console.WriteLine("w");
            PrintComplexMatrix(w);

            Console.WriteLine("vl");
            PrintComplexMatrix(vl);

            Console.WriteLine("vr");
            PrintComplexMatrix(vr);
        }
Exemplo n.º 4
0
        public void TestMult()
        {
            var lib = new MLapackLib();

            var mat1 = new MCJRMatrix(2, 3);

            mat1.setAt(0, 0, 1);
            mat1.setAt(0, 1, 2);
            mat1.setAt(0, 2, 3);

            mat1.setAt(1, 0, 4);
            mat1.setAt(1, 1, 5);
            mat1.setAt(1, 2, 6);

            var mat2 = new MCJRMatrix(3, 2);

            mat2.setAt(0, 0, 1);
            mat2.setAt(0, 1, 2);

            mat2.setAt(1, 0, 3);
            mat2.setAt(1, 1, 4);

            mat2.setAt(2, 0, 5);
            mat2.setAt(2, 1, 6);

            var mat3 = new MCJRMatrix();

            lib.multiply(mat1, mat2, mat3);
            PrintMatrix(mat3);
        }
Exemplo n.º 5
0
        private static void CalcNorm(MCJRMatrix matrix, MatrixNormType normType)
        {
            var    lib  = new MLapackLib();
            double norm = lib.norm(Convert.ToSByte(normType), matrix);

            Console.WriteLine("norm = " + norm);
        }
Exemplo n.º 6
0
        public double SvdzTestBig(int size)
        {
            var mat1 = new MCJCMatrix(size, size);

            var random = new Random();

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    mat1.setAt(i, j, random.NextDouble(), 0);
                }
            }

            var lib = new MLapackLib();

            Console.WriteLine("multiplication started...");

            var s  = new MCJRMatrix();
            var u  = new MCJCMatrix();
            var vt = new MCJCMatrix();

            var time = DateTime.Now;

            lib.SVDDecomposition(mat1, s, u, vt);

            double ms = (DateTime.Now - time).TotalMilliseconds;

            Console.WriteLine("time = " + ms);
            return(ms);
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        public void TestMultBig()
        {
            for (int size = 100; size <= 4500; size += 100)
            {
                try
                {
                    Console.WriteLine(size);
                    var mat1 = new MCJRMatrix(size, size);

                    var random = new Random();

                    for (int i = 0; i < size; i++)
                    {
                        for (int j = 0; j < size; j++)
                        {
                            mat1.setAt(i, j, random.NextDouble());
                        }
                    }


                    var mat2 = new MCJRMatrix(size, size);

                    for (int i = 0; i < size; i++)
                    {
                        for (int j = 0; j < size; j++)
                        {
                            mat2.setAt(i, j, random.NextDouble());
                        }
                    }

                    var mat3 = new MCJRMatrix();

                    var time = DateTime.Now;
                    var lib  = new MLapackLib();

                    Console.WriteLine("multiplication started...");
                    lib.multiply(mat1, mat2, mat3);

                    Console.WriteLine("multiplication completed.");

                    Console.WriteLine("size = " + size + "time = " + (DateTime.Now - time).TotalMilliseconds);
                }
                catch (Exception)
                {
                    Console.WriteLine("exception");
                }
            }
        }
Exemplo n.º 8
0
        public void TestInv()
        {
            var mat1 = new MCJRMatrix(2, 2);

            mat1.setAt(0, 0, 1);
            mat1.setAt(0, 1, 2);

            mat1.setAt(1, 0, 3);
            mat1.setAt(1, 1, 4);

            var lib = new MLapackLib();

            var result = new MCJRMatrix();

            lib.inv(mat1, result);

            PrintMatrix(result);
        }
Exemplo n.º 9
0
        public double TestMultdBig(int size)
        {
            var mat1 = new MCJRMatrix(size, size);

            var random = new Random();

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    mat1.setAt(i, j, random.NextDouble());
                }
            }


            var mat2 = new MCJRMatrix(size, size);

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    mat2.setAt(i, j, random.NextDouble());
                }
            }

            var mat3 = new MCJRMatrix();

            var time = DateTime.Now;

            Console.WriteLine("multiplication started...");

            var lib = new MLapackLib();

            lib.multiply(mat1, mat2, mat3);

            double elapsedTime = (DateTime.Now - time).TotalMilliseconds;

            Console.WriteLine("multiplication completed.");

            Console.WriteLine("size = " + size + "time = " + (DateTime.Now - time).TotalMilliseconds);

            return(elapsedTime);
        }
Exemplo n.º 10
0
        public void ConditionNumerTest()
        {
            var matrix1 = new NRealMatrix(2, 2);
            matrix1[0, 0] = 1;
            matrix1[0, 1] = 2;
            matrix1[1, 0] = 3;
            matrix1[1, 1] = 4;

            var lib = new MLapackLib();

            var conditionNumber = lib.matrixRConditionNumber(Convert.ToSByte(MatrixNormType.OneNorm), matrix1.ManagedMatrix);

            Console.WriteLine("condNum = " + conditionNumber);
            /*var norm = (double)matrix1;
            var normInv = (double)(!matrix1);

            Console.WriteLine(norm + " " + normInv);
            Console.WriteLine(1/(norm * normInv));*/
        }
Exemplo n.º 11
0
        public void SlezTest()
        {
            const int size = 2;
            var       mat1 = new MCJCMatrix(2, 2);
            var       mat2 = new MCJCMatrix(2, 2);

            mat1.setAt(0, 0, 1, 1);
            mat1.setAt(0, 1, 2, 2);
            mat1.setAt(1, 0, 3, 3);
            mat1.setAt(1, 1, 4, 4);

            mat2.setAt(0, 0, 1, 0);
            mat2.setAt(0, 1, 2, 0);
            mat2.setAt(1, 0, 3, 0);
            mat2.setAt(1, 1, 4, 0);


            Console.WriteLine(new NComplexMatrix(mat1));

            /* mat1.setAt(0, 0, 1);
             * mat1.setAt(0, 1, 2);
             * mat1.setAt(1, 0, 3);
             * mat1.setAt(1, 1, 4);
             *
             * mat2.setAt(0, 0, 1);
             * mat2.setAt(0, 1, 2);
             * mat2.setAt(1, 0, 3);
             * mat2.setAt(1, 1, 4);*/

            var time = DateTime.Now;
            var lib  = new MLapackLib();

            var result = new MCJCMatrix(size, size);

            lib.solveSLE(mat1, mat2, result);

            Console.WriteLine(new NComplexMatrix(result));

            double ms = (DateTime.Now - time).TotalMilliseconds;

            Console.WriteLine("time = " + ms);
        }
Exemplo n.º 12
0
        public void ConditionNumerTest()
        {
            var matrix1 = new NRealMatrix(2, 2);

            matrix1[0, 0] = 1;
            matrix1[0, 1] = 2;
            matrix1[1, 0] = 3;
            matrix1[1, 1] = 4;

            var lib = new MLapackLib();

            var conditionNumber = lib.matrixRConditionNumber(Convert.ToSByte(MatrixNormType.OneNorm), matrix1.ManagedMatrix);

            Console.WriteLine("condNum = " + conditionNumber);

            /*var norm = (double)matrix1;
             * var normInv = (double)(!matrix1);
             *
             * Console.WriteLine(norm + " " + normInv);
             * Console.WriteLine(1/(norm * normInv));*/
        }
Exemplo n.º 13
0
        public void SvdDecompositionTest()
        {
            var matrix1 = new NRealMatrix(2, 2);

            matrix1[0, 0] = 1;
            matrix1[0, 1] = 2;
            matrix1[1, 0] = 3;
            matrix1[1, 1] = 4;

            var s  = new NRealMatrix();
            var u  = new NRealMatrix();
            var vt = new NRealMatrix();

            var lib = new MLapackLib();

            lib.SVDDecomposition(matrix1.ManagedMatrix, s.ManagedMatrix, u.ManagedMatrix, vt.ManagedMatrix);

            Console.WriteLine(matrix1);
            Console.WriteLine(s);
            Console.WriteLine(u);
            Console.WriteLine(vt);
        }
Exemplo n.º 14
0
        public void TestMultZ()
        {
            var lib = new MLapackLib();

            var mat1 = new MCJCMatrix(2, 2);

            mat1.setAt(0, 0, 1, 0);
            mat1.setAt(0, 1, 2, 0);
            mat1.setAt(1, 0, 3, 0);
            mat1.setAt(1, 1, 4, 0);

            var mat2 = new MCJCMatrix(2, 2);

            mat2.setAt(0, 0, 1, 0);
            mat2.setAt(0, 1, 2, 0);
            mat2.setAt(1, 0, 3, 0);
            mat2.setAt(1, 1, 4, 0);

            var mat3 = new MCJCMatrix();

            lib.multiply(mat1, mat2, mat3);
            Console.WriteLine(new NComplexMatrix(mat3));
        }
Exemplo n.º 15
0
        public void TestMultZ()
        {
            var lib = new MLapackLib();

            var mat1 = new MCJCMatrix(2, 2);
            mat1.setAt(0, 0, 1, 0);
            mat1.setAt(0, 1, 2 ,0);
            mat1.setAt(1, 0, 3, 0);
            mat1.setAt(1, 1, 4, 0);

            var mat2 = new MCJCMatrix(2, 2);
            mat2.setAt(0, 0, 1, 0);
            mat2.setAt(0, 1, 2, 0);
            mat2.setAt(1, 0, 3, 0);
            mat2.setAt(1, 1, 4, 0);

            var mat3 = new MCJCMatrix();
            lib.multiply(mat1, mat2, mat3);
            Console.WriteLine(new NComplexMatrix(mat3));
        }
Exemplo n.º 16
0
        /// <summary>
        /// 
        /// </summary>
        public void TestMultBig()
        {
            for (int size = 100; size <= 4500; size += 100)
            {
                try
                {
                    Console.WriteLine(size);
                    var mat1 = new MCJRMatrix(size, size);

                    var random = new Random();

                    for (int i = 0; i < size; i++)
                    {
                        for (int j = 0; j < size; j++)
                        {
                            mat1.setAt(i, j, random.NextDouble());
                        }
                    }

                    var mat2 = new MCJRMatrix(size, size);

                    for (int i = 0; i < size; i++)
                    {
                        for (int j = 0; j < size; j++)
                        {
                            mat2.setAt(i, j, random.NextDouble());
                        }
                    }

                    var mat3 = new MCJRMatrix();

                    var time = DateTime.Now;
                    var lib = new MLapackLib();

                    Console.WriteLine("multiplication started...");
                    lib.multiply(mat1, mat2, mat3);

                    Console.WriteLine("multiplication completed.");

                    Console.WriteLine("size = " + size + "time = " + (DateTime.Now - time).TotalMilliseconds);

                }
                catch (Exception)
                {

                    Console.WriteLine("exception");
                }
            }
        }
Exemplo n.º 17
0
        public void TestMult()
        {
            var lib = new MLapackLib();

            var mat1 = new MCJRMatrix(2, 3);
            mat1.setAt(0, 0, 1);
            mat1.setAt(0, 1, 2);
            mat1.setAt(0, 2, 3);

            mat1.setAt(1, 0, 4);
            mat1.setAt(1, 1, 5);
            mat1.setAt(1, 2, 6);

            var mat2 = new MCJRMatrix(3, 2);

            mat2.setAt(0, 0, 1);
            mat2.setAt(0, 1, 2);

            mat2.setAt(1, 0, 3);
            mat2.setAt(1, 1, 4);

            mat2.setAt(2, 0, 5);
            mat2.setAt(2, 1, 6);

            var mat3 = new MCJRMatrix();
            lib.multiply(mat1, mat2, mat3);
            PrintMatrix(mat3);
        }
Exemplo n.º 18
0
        public void TestInv()
        {
            var mat1 = new MCJRMatrix(2, 2);
            mat1.setAt(0, 0, 1);
            mat1.setAt(0, 1, 2);

            mat1.setAt(1, 0, 3);
            mat1.setAt(1, 1, 4);

            var lib = new MLapackLib();

            var result = new MCJRMatrix();
            lib.inv(mat1, result);

            PrintMatrix(result);
        }
Exemplo n.º 19
0
        public double SvdzTestBig(int size)
        {
            var mat1 = new MCJCMatrix(size, size);

            var random = new Random();

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    mat1.setAt(i, j, random.NextDouble(), 0);
                }
            }

            var lib = new MLapackLib();

            Console.WriteLine("multiplication started...");

            var s = new MCJRMatrix();
            var u = new MCJCMatrix();
            var vt = new MCJCMatrix();

            var time = DateTime.Now;
            lib.SVDDecomposition(mat1, s, u, vt);

            double ms = (DateTime.Now - time).TotalMilliseconds;
            Console.WriteLine("time = " + ms);
            return ms;
        }
Exemplo n.º 20
0
        public void SvdDecompositionTest()
        {
            var matrix1 = new NRealMatrix(2, 2);
            matrix1[0, 0] = 1;
            matrix1[0, 1] = 2;
            matrix1[1, 0] = 3;
            matrix1[1, 1] = 4;

            var s = new NRealMatrix();
            var u = new NRealMatrix();
            var vt = new NRealMatrix();

            var lib = new MLapackLib();

            lib.SVDDecomposition(matrix1.ManagedMatrix, s.ManagedMatrix, u.ManagedMatrix, vt.ManagedMatrix);

            Console.WriteLine(matrix1);
            Console.WriteLine(s);
            Console.WriteLine(u);
            Console.WriteLine(vt);
        }
Exemplo n.º 21
0
        public double SlezTestBig(int size)
        {
            var mat1 = new MCJCMatrix(size, size);
            var mat2 = new MCJCMatrix(size, size);

            var random = new Random();

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    mat1.setAt(i, j, random.NextDouble(), 0);
                    mat2.setAt(i, j, random.NextDouble(), 0);
                }
            }

            var time = DateTime.Now;
            var lib = new MLapackLib();

            var result = new MCJCMatrix(size, size);

            Console.WriteLine("multiplication started...");

            lib.solveSLE(mat1, mat2, result);

            Console.WriteLine("multiplication completed.");

            double ms = (DateTime.Now - time).TotalMilliseconds;
            Console.WriteLine("time = " + ms);
            return ms;
        }
Exemplo n.º 22
0
        public double TestMultZBig(int size)
        {
            var mat1 = new MCJCMatrix(size, size);
            var mat2 = new MCJCMatrix(size, size);

            var random = new Random();

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    mat1.setAt(i, j, random.NextDouble(), random.NextDouble());
                    mat2.setAt(i, j, random.NextDouble(), random.NextDouble());
                }
            }

            var mat3 = new MCJCMatrix();

            var time = DateTime.Now;
            Console.WriteLine("multiplication started...");

            var lib = new MLapackLib();

            lib.multiply(mat1, mat2, mat3);

            double elapsedTime = (DateTime.Now - time).TotalMilliseconds;

            Console.WriteLine("multiplication completed.");

            Console.WriteLine("size = " + size + "time = " + (DateTime.Now - time).TotalMilliseconds);

            return elapsedTime;
        }
Exemplo n.º 23
0
        private static void CalcNorm(MCJRMatrix matrix, MatrixNormType normType)
        {
            var lib = new MLapackLib();
            double norm = lib.norm(Convert.ToSByte(normType), matrix);

            Console.WriteLine("norm = " + norm);
        }
Exemplo n.º 24
0
        public void SlezTest()
        {
            const int size = 2;
            var mat1 = new MCJCMatrix(2, 2);
            var mat2 = new MCJCMatrix(2, 2);

            mat1.setAt(0, 0, 1, 1);
            mat1.setAt(0, 1, 2, 2);
            mat1.setAt(1, 0, 3, 3);
            mat1.setAt(1, 1, 4, 4);

            mat2.setAt(0, 0, 1, 0);
            mat2.setAt(0, 1, 2, 0);
            mat2.setAt(1, 0, 3, 0);
            mat2.setAt(1, 1, 4, 0);

            Console.WriteLine(new NComplexMatrix(mat1));

            /* mat1.setAt(0, 0, 1);
             mat1.setAt(0, 1, 2);
             mat1.setAt(1, 0, 3);
             mat1.setAt(1, 1, 4);

             mat2.setAt(0, 0, 1);
             mat2.setAt(0, 1, 2);
             mat2.setAt(1, 0, 3);
             mat2.setAt(1, 1, 4);*/

            var time = DateTime.Now;
            var lib = new MLapackLib();

            var result = new MCJCMatrix(size, size);

            lib.solveSLE(mat1, mat2, result);

            Console.WriteLine(new NComplexMatrix(result));

            double ms = (DateTime.Now - time).TotalMilliseconds;
            Console.WriteLine("time = " + ms);
        }