Example #1
0
        /// <summary>
        /// Divides all of the matrix elements by a double value.
        /// </summary>
        /// <param name="value">The double value.</param>
        /// <returns>The result matrix.</returns>
        protected virtual Matrix <T, C> divideByValue(Numeric <T, C> value)
        {
            Matrix <T, C> temp = this.Clone() as Matrix <T, C>;

            MatrixNumericHelper <T, C> .divValue(temp, value, temp);

            return(temp);
        }
Example #2
0
        /// <summary>
        /// Multiplies all of the matrix elements by a double value.
        /// </summary>
        /// <param name="value">The double value.</param>
        /// <returns>The result matrix.</returns>
        protected virtual Matrix <T, C> multiplyByValue(Numeric <T, C> value)
        {
            Matrix <T, C> temp = this.Clone() as Matrix <T, C>;

            MatrixNumericHelper <T, C> .mulValue(temp, value, temp);

            return(temp);
        }
Example #3
0
        // ---------------------
        // ------- ctors -------
        // ---------------------

        internal MinorMatrix(Matrix <T, C> parent, int removedRow, int removedColumn)
        {
            this.Matrix_Type = MatrixNumericHelper <T, C> .getMatrixType(parent);

            this.RemovedRow    = removedRow;
            this.RemovedColumn = removedColumn;

            this.rows    = parent.RowCount - 1;
            this.columns = parent.ColumnCount - 1;

            this.Parent = parent;
        }
Example #4
0
        protected override Matrix <T, C> multiply(Matrix <T, C> another)
        {
            if (this.ColumnCount != another.RowCount)
            {
                throw new ArgumentException("The column count of the first matrix and the row count of the second matrix must match.");
            }

            Matrix <T, C> temp = MatrixNumericHelper <T, C> .getMatrixOfSize(Parent.Matrix_Type, this.rows, another.ColumnCount);

            MatrixNumericHelper <T, C> .multiplySimple(this, another, temp);

            return(temp);
        }
Example #5
0
        protected override Matrix <T, C> substract(Matrix <T, C> another)
        {
            if (this.rows != another.RowCount || this.columns != another.ColumnCount)
            {
                throw new ArgumentException("Matrices must be of the same size in order to substract.");
            }

            Matrix <T, C> temp = MatrixNumericHelper <T, C> .getMatrixOfSize(Parent.Matrix_Type, rows, columns);

            MatrixNumericHelper <T, C> .dif(this, another, temp);

            return(temp);
        }
Example #6
0
        protected override Matrix <T, C> negate()
        {
            Matrix <T, C> temp = MatrixNumericHelper <T, C> .getMatrixOfSize(Parent.Matrix_Type, rows, columns);

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    temp[i, j] = -this.getItemAt(i, j);
                }
            }

            return(temp);
        }
Example #7
0
        /// <summary>
        /// Returns the matrix that will be equal to the current matrix after the transposition.
        /// Performs memory allocation for the new matrix, so any changes made to it will not be reflected on the current matrix.
        /// </summary>
        /// <returns>Returns the matrix that will be equal to the current matrix after the transposition.</returns>
        public Matrix <T, C> transposedMatrixCopy()
        {
            Matrix <T, C> transposedMatrix = MatrixNumericHelper <T, C> .getMatrixOfSize(this.Matrix_Type, this.columns, this.rows);

            for (int i = 0; i < this.rows; i++)
            {
                for (int j = 0; j < this.columns; j++)
                {
                    transposedMatrix.setItemAt(j, i, this.getItemAt(i, j));
                }
            }

            return(transposedMatrix);
        }
Example #8
0
        /// <summary>
        /// Returns the minor matrix copy (independent from the current),
        /// which is made by removing the row with index <paramref name="rowToRemove"/>
        /// and the column with index <paramref name="columnToRemove"/>.
        /// </summary>
        /// <param name="rowToRemove">The index of the row to remove.</param>
        /// <param name="columnToRemove">The index of the column to remove.</param>
        /// <returns>The minor matrix copy (independent from the current).</returns>
        public Matrix <T, C> getMinorMatrixCopy(int rowToRemove, int columnToRemove)
        {
            checkPositive(rowToRemove, columnToRemove);
            checkBounds(rowToRemove + 1, columnToRemove + 1);

            Matrix <T, C> tmp = MatrixNumericHelper <T, C> .getMatrixOfSize(this.Matrix_Type, this.rows - 1, this.columns - 1);

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    int positionIndexRow    = (i < rowToRemove ? i : (i > rowToRemove ? i - 1 : -1));
                    int positionIndexColumn = (j < columnToRemove ? j : (j > columnToRemove ? j - 1 : -1));

                    if (positionIndexColumn >= 0 && positionIndexRow >= 0)
                    {
                        tmp.setItemAt(positionIndexRow, positionIndexColumn, this.getItemAt(i, j));
                    }
                }
            }

            return(tmp);
        }