Ejemplo n.º 1
0
        public void Expected_Multiply_Result()
        {
            const int size = 5;

            dynamic[,] realResult = new dynamic[size, size] {
                { 0, 10, 20, 30, 40 }, { 0, 10, 20, 30, 40 }, { 0, 10, 20, 30, 40 }, { 0, 10, 20, 30, 40 }, { 0, 10, 20, 30, 40 }
            };

            Matrix_DeT <double> matrix_one = new Matrix_DeT <double>(size, size);
            Matrix_DeT <double> matrix_two = new Matrix_DeT <double>(size, size);
            Matrix_DeT <double> resultmatrix_one;

            dynamic[,] resultmatrix_two = new dynamic[size, size];

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    matrix_one[j, i] = i;
                    matrix_two[j, i] = i;
                }
            }

            resultmatrix_one = matrix_one * matrix_two;

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    resultmatrix_two[j, i] = resultmatrix_one[j, i];
                }
            }

            CollectionAssert.AreEqual(realResult, resultmatrix_two);
        }
Ejemplo n.º 2
0
        /// расчёт
        private void Calculate()
        {
            if (priznak != 1)
            {
                throw new Exception("Необходимо создать матрицу!");
            }

            DateTime timeStart = DateTime.Now;

            this.Cursor = Cursors.Wait;

            switch (matrixMethod.SelectedIndex)
            {
            case 0:
                numbersResult = numbersMatrix_First + numbersMatrix_Second;
                break;

            case 1:
                numbersResult = numbersMatrix_First * numbersMatrix_Second;
                break;

            default:
                numbersResult = numbersMatrix_First + numbersMatrix_Second;
                break;
            }

            DateTime timeStop = DateTime.Now;

            tbResult.Text = Convert.ToString((timeStop - timeStart).TotalMilliseconds);
            DrawResult();
            numbersResult.WriteMatrix();

            this.Cursor = Cursors.Arrow;
        }
Ejemplo n.º 3
0
        public void Plus_exception_Matrix()
        {
            Matrix_DeT <double> resultmatrix_one;
            Matrix_DeT <double> matrix_one = new Matrix_DeT <double>(6, 6);
            Matrix_DeT <double> matrix_two = new Matrix_DeT <double>(8, 8);

            resultmatrix_one = matrix_one + matrix_two;
        }
Ejemplo n.º 4
0
        public void Multiply_exception_Matrix()
        {
            Matrix_DeT <double> resultmatrix_one;
            Matrix_DeT <double> matrix_one = new Matrix_DeT <double>(2, 8);
            Matrix_DeT <double> matrix_two = new Matrix_DeT <double>(2, 8);

            resultmatrix_one = matrix_one * matrix_two;
        }
Ejemplo n.º 5
0
        ///------------------------------------------------------------------------------------------------------------------------
        ///
        private void GetRandomMatrix(int x, int y)
        {
            numbersMatrix_First = Matrix_DeT <double> .GenerateMatrix(x, y, (x1, y1, rnd) => rnd.Next(-100, 100) + x1 - y1);

            Thread.Sleep(5);
            numbersMatrix_Second = Matrix_DeT <double> .GenerateMatrix(x, y, (x1, y1, rnd) => rnd.Next(-100, 100) + x1 - y1);

            numbersResult = new Matrix_DeT <double>(x, y);
        }
Ejemplo n.º 6
0
 public void Matrix_Error_0()
 {
     int x = 0;
     int y = 0;
     Matrix_DeT <double> matrix = new Matrix_DeT <double>(x, y);
 }