Beispiel #1
0
        /// <summary>
        /// Replaces all cell values of the receiver with the values of another matrix.
        /// Both matrices must have the same number of Rows and Columns.
        /// If both matrices share the same cells (as is the case if they are views derived from the same matrix) and intersect in an ambiguous way, then replaces <i>as if</i> using an intermediate auxiliary deep copy of <i>other</i>.
        /// </summary>
        /// <param name="other">the source matrix to copy from (may be identical to the receiver).</param>
        /// <returns><i>this</i> (for convenience only).</returns>
        /// <exception cref="ArgumentException">if <i>Columns != other.Columns || Rows != other.Rows</i></exception>
        public virtual ObjectMatrix2D Assign(ObjectMatrix2D other)
        {
            if (other == this)
            {
                return(this);
            }
            CheckShape(other);
            if (HaveSharedCells(other))
            {
                other = other.Copy();
            }

            for (int row = Rows; --row >= 0;)
            {
                for (int column = Columns; --column >= 0;)
                {
                    this[row, column] = other[row, column];
                }
            }
            return(this);
        }