Exemplo n.º 1
0
		// DecimalFormat is a little disappointing coming from Fortran or C's printf.
		// Since it doesn't pad on the left, the elements will come out different
		// widths.  Consequently, we'll pass the desired column width in as an
		// argument and do the extra padding ourselves.
		
		/// <summary> Print the matrix to the output stream.  Line the elements up in columns.
		/// Use the format object, and right justify within columns of width
		/// characters.
		/// Note that is the matrix is to be read back in, you probably will want
		/// to use a NumberFormat that is set to US Locale.
		/// </summary>
		/// <param name="output">the output stream.
		/// </param>
		/// <param name="format">A formatting object to format the matrix elements 
		/// </param>
		/// <param name="width"> Column width.
		/// </param>
		/// <seealso cref="java.text.DecimalFormat.setDecimalFormatSymbols">
		/// </seealso>
		public virtual void  print(System.IO.StreamWriter output, TextNumberFormat format, int width)
		{
			//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln'"
			output.WriteLine(); // start on new line.
			for (int i = 0; i < m; i++)
			{
				for (int j = 0; j < n; j++)
				{
					System.String s = format.FormatDouble(A[i][j]); // format the number
					int padding = System.Math.Max(1, width - s.Length); // At _least_ 1 space
					for (int k = 0; k < padding; k++)
						output.Write(' ');
					output.Write(s);
				}
				//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln'"
				output.WriteLine();
			}
			//UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln'"
			output.WriteLine(); // end with blank line.
		}