Exemplo n.º 1
0
        private static void performSecondOperationOnMyFraction(MyMatrix <Fraction> matrixA, MyMatrix <Fraction> matrixB, MyMatrix <Fraction> matrixC, TextWriter timeWriter)
        {
            matrixA.printMatrix();
            Console.WriteLine("+++++++++++++");
            matrixB.printMatrix();
            Console.WriteLine("+++++++++++++");
            matrixC.printMatrix();
            Console.WriteLine("************");
            matrixA.printVectorB();
            Console.WriteLine("==============");
            var watch = System.Diagnostics.Stopwatch.StartNew();
            MyMatrix <Fraction> matrixTemp = matrixA + matrixB;

            matrixTemp = matrixTemp + matrixC;
            Fraction[] vector = matrixTemp * matrixA.VectorB;
            watch.Stop();
            double elapsedMs = watch.Elapsed.TotalMilliseconds;

            foreach (Fraction element in vector)
            {
                Console.WriteLine(element);
            }
            Console.WriteLine(elapsedMs);
            timeWriter.Write(elapsedMs);
            timeWriter.Write(";");
        }
Exemplo n.º 2
0
        private static void performFirstOperationOnDouble(MyMatrix <double> matrix, TextWriter timeWriter)
        {
            matrix.printMatrix();
            Console.WriteLine("***************");
            matrix.printVectorB();
            Console.WriteLine("==============");
            double[] vector;
            var      watch = System.Diagnostics.Stopwatch.StartNew();

            vector = matrix * matrix.VectorB;
            watch.Stop();
            double elapsedMs = watch.Elapsed.TotalMilliseconds;

            foreach (double element in vector)
            {
                Console.WriteLine(element);
            }
            Console.WriteLine(elapsedMs);
            timeWriter.Write(elapsedMs);
            timeWriter.Write(";");
        }