/**
         * Creates a new iterator for traversing through a submatrix inside this matrix.  It can be traversed
         * by row or by column.  Range of elements is inclusive, e.g. minRow = 0 and maxRow = 1 will include rows
         * 0 and 1.  The iteration starts at (minRow,minCol) and ends at (maxRow,maxCol)
         *
         * @param a the matrix it is iterating through
         * @param rowMajor true means it will traverse through the submatrix by row first, false by columns.
         * @param minRow first row it will start at.
         * @param minCol first column it will start at.
         * @param maxRow last row it will stop at.
         * @param maxCol last column it will stop at.
         */
        public DMatrixIterator(DMatrixD1 a, bool rowMajor,
                               int minRow, int minCol, int maxRow, int maxCol
        )
        {
            if (maxCol < minCol)
                throw new ArgumentException("maxCol has to be more than or equal to minCol");
            if (maxRow < minRow)
                throw new ArgumentException("maxRow has to be more than or equal to minCol");
            if (maxCol >= a.numCols)
                throw new ArgumentException("maxCol must be < numCols");
            if (maxRow >= a.numRows)
                throw new ArgumentException("maxRow must be < numCRows");

            this.a = a;
            this.rowMajor = rowMajor;
            this.minCol = minCol;
            this.minRow = minRow;

            size = (maxCol - minCol + 1) * (maxRow - minRow + 1);

            if (rowMajor)
                submatrixStride = maxCol - minCol + 1;
            else
                submatrixStride = maxRow - minRow + 1;
        }
        /// <summary>
        /// Sets the value of this matrix to be the same as the value of the provided matrix.  Both
        /// matrices must have the same shape:<br>
        /// <br>
        /// a<sub>ij</sub> = b<sub>ij</sub><br>
        /// <br>
        /// </summary>
        /// <param name="b"> The matrix that this matrix is to be set equal to. </param>
        public virtual void setTo(DMatrixD1 b)
        {
            if (numRows != b.numRows || numCols != b.numCols)
            {
                throw new MatrixDimensionException("The two matrices do not have compatible shapes.");
            }

            int dataLength = b.DataLength;

            Array.Copy(b.data, 0, this.data, 0, dataLength);
        }