Пример #1
0
        public static IMatrix <T> PerformNonMutableOperation(IMatrix <T> matrix, SingleElementOperation <T> Operation)
        {
            // duplicate the matrix to verify that we are not mutating the original matrix
            IMatrix <T> Dupe = matrix.Duplicate();

            // perform the possible mytating operation on all items int he matrix
            PerformMutableOperation(Dupe, Operation);

            // return the duplicated matrix and not the original
            return(Dupe);
        }
Пример #2
0
        public static IMatrix <T> PerformMutableOperation(IMatrix <T> matrix, SingleElementOperation <T> Operation)
        {
            for (int row = 0; row < matrix.Rows; row++)
            {
                Span <T> Row = new(matrix._Matrix[row]);
                for (int column = 0; column < matrix.Columns; column++)
                {
                    Operation(ref Row[column]);
                }
            }

            return(matrix);
        }