public void Test_GetMatricesDifference_()
        {
            var firstMatrix = MatrixFactoryObject.GetMatrixObject();

            firstMatrix.SetLineOfMatrix(3);
            firstMatrix.SetColumnOfMatrix(3);
            firstMatrix.SetMatrix(new [, ] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            });

            var secondMatrix = MatrixFactoryObject.GetMatrixObject();

            secondMatrix.SetLineOfMatrix(3);
            secondMatrix.SetColumnOfMatrix(3);
            secondMatrix.SetMatrix(new [, ] {
                { 7, 8, 9 }, { 4, 5, 6 }, { 1, 2, 3 }
            });

            var expected = new[, ] {
                { -6, -6, -6 }, { 0, 0, 0 }, { 6, 6, 6 }
            };

            Assert.AreEqual(_matricesWorkflow.GetMatricesDifference(firstMatrix, secondMatrix).GetMatrix(),
                            expected);
        }
        public void Test_GetMatricesProduct_()
        {
            var firstMatrix = MatrixFactoryObject.GetMatrixObject();

            firstMatrix.SetLineOfMatrix(3);
            firstMatrix.SetColumnOfMatrix(3);
            firstMatrix.SetMatrix(new [, ] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            });

            var secondMatrix = MatrixFactoryObject.GetMatrixObject();

            secondMatrix.SetLineOfMatrix(3);
            secondMatrix.SetColumnOfMatrix(3);
            secondMatrix.SetMatrix(new [, ] {
                { 7, 8, 9 }, { 4, 5, 6 }, { 1, 2, 3 }
            });

            var expected = new[, ] {
                { 7, 16, 27 }, { 16, 25, 36 }, { 7, 16, 27 }
            };

            Assert.AreEqual(_matricesWorkflow.GetMatricesProduct(firstMatrix, secondMatrix).GetMatrix(),
                            expected);
        }
Exemple #3
0
        public IAbstractMatrix ReadMatrix(int lines, int columns)
        {
            var matrix = MatrixFactoryObject.GetMatrixObject();

            matrix.SetLineOfMatrix(lines);
            matrix.SetColumnOfMatrix(columns);

            for (var it = 0; it < matrix.GetLineOfMatrix(); it++)
            {
                for (var jit = 0; jit < matrix.GetColumnOfMatrix(); jit++)
                {
                    matrix.GetMatrix()[it, jit] = Convert.ToInt32(Console.ReadLine());
                }
            }

            return(matrix);
        }
        public IAbstractMatrix GetMatricesProduct(IAbstractMatrix matrixOne, IAbstractMatrix matrixTwo)
        {
            var result = MatrixFactoryObject.GetMatrixObject();

            result.SetLineOfMatrix(matrixOne.GetLineOfMatrix());
            result.SetColumnOfMatrix(matrixOne.GetColumnOfMatrix());
            result.SetMatrix(matrixOne.GetMatrix());

            for (var it = 0; it < matrixOne.GetLineOfMatrix(); it++)
            {
                for (var jit = 0; jit < matrixOne.GetColumnOfMatrix(); jit++)
                {
                    result.GetMatrix()[it, jit] *= matrixTwo.GetMatrix()[it, jit];
                }
            }

            return(result);
        }
        public IAbstractMatrix BoostDownMatrix(IAbstractMatrix matrix, int booster)
        {
            var result = MatrixFactoryObject.GetMatrixObject();

            result.SetLineOfMatrix(matrix.GetLineOfMatrix());
            result.SetColumnOfMatrix(matrix.GetColumnOfMatrix());
            result.SetMatrix(matrix.GetMatrix());

            for (var it = 0; it < result.GetLineOfMatrix(); it++)
            {
                for (var jit = 0; jit < result.GetColumnOfMatrix(); jit++)
                {
                    result.GetMatrix()[it, jit] /= booster;
                }
            }

            return(result);
        }
 public void Setup()
 {
     _matricesWorkflow = MatricesWorkflowFactoryObject.GetMatricesWorkflowObject();
     _matrix           = MatrixFactoryObject.GetMatrixObject();
 }
Exemple #7
0
 public void Setup()
 {
     _oneDimensionalArray = OneDimensionalArrayFactoryObject.GetOneDimensionalArrayObject();
     _matrix = MatrixFactoryObject.GetMatrixObject();
 }