umontreal.iro.lecuyer.util
Class TableFormat
- java.lang.Object
-
- umontreal.iro.lecuyer.util.TableFormat
-
public class TableFormat extends java.lang.ObjectThis class provides methods to format arrays and matrices intoStrings in different styles. This could be useful for printing arrays and subarrays, or for putting them in files for further treatment by other softwares such as Mathematica, Matlab, etc.
-
-
Field Summary
Fields Modifier and Type Field and Description static intMATHEMATICAMathematica matrix printing stylestatic intMATLABMatlab matrix printing stylestatic intPLAINPlain text matrix printing style
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.Stringformat(double[][] Mat, int i1, int i2, int j1, int j2, int w, int p, int style, java.lang.String Name)Formats the submatrix with lines i1 <= i <= i2 and columns j1 <= j <= j2 of the matrix Mat, using the formatting style style.static java.lang.Stringformat(double[] V, int n1, int n2, int k, int p1, int p2, int p3)Similar to the previous method, but for an array of double's.static java.lang.Stringformat(int[][] Mat, int i1, int i2, int j1, int j2, int w, int p, int style, java.lang.String Name)Formats a submatrix of integers.static java.lang.Stringformat(int[] V, int n1, int n2, int k, int p)Formats aStringcontaining the elements n1 to n2 (inclusive) of table V, k elements per line, p positions per element.
-
-
-
Field Detail
-
PLAIN
public static final int PLAIN
Plain text matrix printing style- See Also:
- Constant Field Values
-
MATHEMATICA
public static final int MATHEMATICA
Mathematica matrix printing style- See Also:
- Constant Field Values
-
MATLAB
public static final int MATLAB
Matlab matrix printing style- See Also:
- Constant Field Values
-
-
Method Detail
-
format
public static java.lang.String format(int[] V, int n1, int n2, int k, int p)Formats aStringcontaining the elements n1 to n2 (inclusive) of table V, k elements per line, p positions per element. If k = 1, the array index will also appear on the left of each element, i.e., each line i will have the form i V[i].- Parameters:
V- array to be formatedn1- index of the first element being formatedn2- index of the last element being formatedk- number of elements per linep- number of positions per element- Returns:
- formated string repreenting the elements
-
format
public static java.lang.String format(double[] V, int n1, int n2, int k, int p1, int p2, int p3)Similar to the previous method, but for an array of double's. Gives at least p1 positions per element, p2 digits after the decimal point, and at least p3 significant digits.- Parameters:
V- array to be formatedn1- index of the first element being formatedn2- index of the last element being formatedk- number of elements per linep1- number of positions per elementp2- number of digits after the decimal pointp3- number of significant digits- Returns:
- formated string repreenting the elements
-
format
public static java.lang.String format(int[][] Mat, int i1, int i2, int j1, int j2, int w, int p, int style, java.lang.String Name)Formats a submatrix of integers.- Parameters:
Mat- matrix to be formatedi1- index of the first row being formatedi2- index of the last row being formatedj1- index of the first column being formatedj2- index of the last column being formatedw- number of positions of the elementsp- number of digits after the decimal point of the elementsstyle- formating style of the submatrix, being one ofMATHEMATICA,MATLAB, orPLAINName- descriptive name of the submatrix- Returns:
- formated string repreenting the submatrix
-
format
public static java.lang.String format(double[][] Mat, int i1, int i2, int j1, int j2, int w, int p, int style, java.lang.String Name)Formats the submatrix with lines i1 <= i <= i2 and columns j1 <= j <= j2 of the matrix Mat, using the formatting style style. The elements are formated in w positions each, with a precision of p digits. The string Name provides an identifier for the submatrix.To be treated by Matlab, this string containing the matrix must be copied to a file with extension .m. If the file is named poil.m, for example, it can be accessed by calling poil in Matlab. For Mathematica, if the file is named poil, it will be read using « poil;.
- Parameters:
Mat- matrix to be formatedi1- index of the first row being formatedi2- index of the last row being formatedj1- index of the first column being formatedj2- index of the last column being formatedw- number of positions of the elementsp- number of digits after the decimal point of the elementsstyle- formating style of the submatrix, being one ofMATHEMATICA,MATLAB, orPLAINName- descriptive name of the submatrix- Returns:
- formated string repreenting the submatrix
-
-
DMelt 3.0 © DataMelt by jWork.ORG