Пример #1
0
        public MutableMatrix <U> CastValues <U>(Func <T, U> castingFunction)
        {
            if (castingFunction == null)
            {
                throw new ArgumentNullException(nameof(castingFunction));
            }

            var casted       = new MutableMatrix <U>(rowCount: RowCount, columnCount: ColumnCount);
            var castedValues = casted.FlattenedValues;

            for (int i = 0; i < FlattenedValues.Length; i++)
            {
                castedValues[i] = castingFunction(FlattenedValues[i]);
            }

            return(casted);
        }
Пример #2
0
        public MutableMatrix <T> Transpose()
        {
            var translated = new MutableMatrix <T>(
                rowCount: ColumnCount,
                columnCount: RowCount);

            for (int y = 0; y < RowCount; y++)
            {
                for (int x = 0; x < ColumnCount; x++)
                {
                    translated.Set(
                        rowIndex: x,
                        columnIndex: y,
                        value: Get(rowIndex: y, columnIndex: x));
                }
            }

            return(translated);
        }