/// <summary>
 /// Sanity check for operations requiring matrices with the same number of columns and rows.
 /// </summary>
 /// <param name="b">
 /// The second matrix.
 /// </param>
 /// <param name="c">
 /// The third matrix.
 /// </param>
 /// <exception cref="ArgumentOutOfRangeException">
 /// If <tt>columns() != B.columns() || rows() != B.rows() || columns() != C.columns() || rows() != C.rows()</tt>.
 /// </exception>
 public void CheckShape(AbstractMatrix2D b, AbstractMatrix2D c)
 {
     if (Columns != b.Columns || Rows != b.Rows || Columns != c.Columns || Rows != c.Rows)
     {
         throw new ArgumentOutOfRangeException(String.Format(Cern.LocalizedResources.Instance().Exception_IncompatibleDimensionsAandBandC, this, b, c));
     }
 }
 /// <summary>
 /// Sanity check for operations requiring matrices with the same number of columns and rows.
 /// </summary>
 /// <param name="b">
 /// The second matrix.
 /// </param>
 /// <param name="c">
 /// The third matrix.
 /// </param>
 /// <exception cref="ArgumentOutOfRangeException">
 /// If <tt>columns() != B.columns() || rows() != B.rows() || columns() != C.columns() || rows() != C.rows()</tt>.
 /// </exception>
 public void CheckShape(AbstractMatrix2D b, AbstractMatrix2D c)
 {
     if (Columns != b.Columns || Rows != b.Rows || Columns != c.Columns || Rows != c.Rows)
     {
         throw new ArgumentOutOfRangeException("Incompatible dimensions: " + this + ", " + b + ", " + c);
     }
 }
        /// <summary>
        /// Returns a string representation of the given matrix.
        /// </summary>
        /// <param name="matrix">
        /// The matrix to convert.
        /// </param>
        /// <returns>
        /// A string representation of the given matrix.
        /// </returns>
        protected virtual string ToString(AbstractMatrix2D matrix)
        {
            var strings = this.Format(matrix);

            Align(strings);
            var total = new StringBuilder(ToString(strings));

            if (printShape)
            {
                total.Insert(0, Shape(matrix) + "\n");
            }
            return(total.ToString());
        }
 /// <summary>
 /// Returns a string representations of all cells; no alignment considered.
 /// </summary>
 /// <param name="matrix">
 /// The matrix.
 /// </param>
 /// <returns>
 /// A string representations of all cells.
 /// </returns>
 protected abstract string[][] Format(AbstractMatrix2D matrix);
 /// <summary>
 /// Returns a short string representation describing the shape of the matrix.
 /// </summary>
 /// <param name="matrix">
 /// The matrix.
 /// </param>
 /// <returns>
 /// A short string representation describing the shape of the matrix.
 /// </returns>
 public static string Shape(AbstractMatrix2D matrix)
 {
     return(matrix.Rows + " x " + matrix.Columns + " matrix ");
 }