Пример #1
0
        public Matrix MatrixOperation(Matrix matrix, int factor, IOperations.Operation operation)
        {
            Matrix copy = new Matrix(matrix);

            switch (operation)
            {
            case IOperations.Operation.MULTIPLY:
                for (int i = 0; i < copy.rows; i++)
                {
                    for (int j = 0; j < copy.columns; j++)
                    {
                        copy.SetElement(i, j, copy.GetElement(i, j) * factor);
                    }
                }
                break;

            case IOperations.Operation.SUM:
                for (int i = 0; i < copy.rows; i++)
                {
                    for (int j = 0; j < copy.columns; j++)
                    {
                        copy.SetElement(i, j, copy.GetElement(i, j) + factor);
                    }
                }
                break;
            }
            return(copy);
        }
Пример #2
0
        public Matrix MatrixesOperation(Matrix matrix, Matrix matrix1, IOperations.Operation operation)
        {
            Matrix result = new Matrix(matrix);

            switch (operation)
            {
            case IOperations.Operation.MATRIXSUM:
                for (int i = 0; i < matrix.rows; i++)
                {
                    for (int j = 0; j < matrix.columns; j++)
                    {
                        result.SetElement(i, j, matrix.GetElement(i, j) + matrix1.GetElement(i, j));
                    }
                }
                break;
            }
            return(result);
        }