Example #1
0
        //Matrix multiplication speed test functions
        static void TestCppCLIMultiplySpeed(EigenWrapper_CppCLI.MatrixXd A, EigenWrapper_CppCLI.MatrixXd B)
        {
            EigenWrapper_CppCLI.MatrixXd C;
            Stopwatch watch = Stopwatch.StartNew();

            for (int i = 0; i < testIterations; i++)
            {
                C = A * B;
            }
            watch.Stop();
            Console.WriteLine("C++/CLI Eigen matrix multiply test took: " + watch.ElapsedMilliseconds + " ms.");
        }
Example #2
0
        static void Main(string[] args)
        {
            //Create the test matrices
            double[,] A = MatrixMathCS.RandomMatrix(matrixSize, matrixSize, 100, -100);
            double[,] B = MatrixMathCS.RandomMatrix(matrixSize, matrixSize, 100, -100);
            EigenWrapper.Matrix          AMatrix = EigenWrapper.Matrix.RandomMatrix(matrixSize, matrixSize, -100, 100);
            EigenWrapper.Matrix          BMatrix = EigenWrapper.Matrix.RandomMatrix(matrixSize, matrixSize, -100, 100);
            EigenWrapper_CppCLI.MatrixXd matrixA = new EigenWrapper_CppCLI.MatrixXd(matrixSize, matrixSize);
            EigenWrapper_CppCLI.MatrixXd matrixB = new EigenWrapper_CppCLI.MatrixXd(matrixSize, matrixSize);

            //Run the multiplication speed tests, if requested
            if (runMultSpeed)
            {
                TestCSMultiplySpeed(A, B);
                TestCppCLIMultiplySpeed(matrixA, matrixB);
                TestEigenMultiplySpeed(A, B);
                TestMatrixMultiplySpeed(AMatrix, BMatrix);
            }
            else
            {
                Console.WriteLine("Skipping multiplication speed tests...");
            }
            ConditionalPause();
            Console.WriteLine();

            //Run the matrix inversion speed tests, if requested
            if (runInvSpeed)
            {
                TestCSInvertSpeed(A);
                //CppCLI inverse hasn't been implemented
                TestEigenInvertSpeed(A);
                TestMatrixInvertSpeed(AMatrix);
            }
            else
            {
                Console.WriteLine("Skipping matrix inversion speed tests...");
            }
            ConditionalPause();
            Console.WriteLine();

            //Run the method correctness tests, if requested
            if (runCorrectness)
            {
                //Test the correctness of the matrix multiplication
                TestMultiplyCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the matrix inverse calculations
                TestInverseCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the matrix addition calculations
                TestAdditionCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the matrix subtraction calculations
                TestSubtractionCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the transpose
                TestTransposeCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the matrix * scalar calculation
                TestMatrixScalarMultiplyCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the matrix / scalar calculation
                TestMatrixScalarDivideCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the matrix * vector calculation
                TestMatrixVectorMultiplyCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the determinant calculation
                TestMatrixDeterminantCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the has inverse calculation
                TestIsInvertableCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the matrix norm calculation
                TestMatrixNormCorrectness();
                ConditionalPause();
                Console.WriteLine();

                //Test the correctness of the vector cross product calculation
                TestVectorCrossProduct();
                ConditionalPause();
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("Skipping correctness tests...");
            }

            Console.WriteLine();
            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }