SSJ  3.3.1
Stochastic Simulation in Java
List of all members
TableFormat Class Reference

This class provides methods to format arrays and matrices into String s in different styles. More...

Static Public Attributes

Formating styles
static final int PLAIN = 0
 Plain text matrix printing style.
 
static final int MATHEMATICA = 1
 Mathematica matrix printing style.
 
static final int MATLAB = 2
 Matlab matrix printing style.
 

Functions to convert arrays to `String`

static String format (int V[], int n1, int n2, int k, int p)
 Formats a String containing the elements n1 to n2 (inclusive) of table V, k elements per line, p positions per element. More...
 
static 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. More...
 
static String format (int[][] Mat, int i1, int i2, int j1, int j2, int w, int p, int style, String Name)
 
static String format (double[][] Mat, int i1, int i2, int j1, int j2, int w, int p, int style, String Name)
 Formats the submatrix with lines i1 \(\le i \le\) i2 and columns j1 \(\le j \le\) j2 of the matrix Mat, using the formatting style style. More...
 
static String format (int[][] Mat, int i1, int i2, int j1, int j2, int w, int style, String Name)
 Similar to the previous method, but for a matrix of int’s. More...
 

Detailed Description

This class provides methods to format arrays and matrices into String s 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.

Member Function Documentation

◆ format() [1/4]

static String format ( int  V[],
int  n1,
int  n2,
int  k,
int  p 
)
static

Formats a String containing 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
Varray to be formated
n1index of the first element being formated
n2index of the last element being formated
knumber of elements per line
pnumber of positions per element
Returns
formated string repreenting the elements

◆ format() [2/4]

static String format ( double  V[],
int  n1,
int  n2,
int  k,
int  p1,
int  p2,
int  p3 
)
static

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
Varray to be formated
n1index of the first element being formated
n2index of the last element being formated
knumber of elements per line
p1number of positions per element
p2number of digits after the decimal point
p3number of significant digits
Returns
formated string repreenting the elements

◆ format() [3/4]

static String format ( double  Mat[][],
int  i1,
int  i2,
int  j1,
int  j2,
int  w,
int  p,
int  style,
String  Name 
)
static

Formats the submatrix with lines i1 \(\le i \le\) i2 and columns j1 \(\le j \le\) j2 of the matrix Mat, using the formatting style style.

The elements are formated in w positions each, with a precision of p digits. Name provides an identifier for the submatrix. To be treated by Matlab, the returned string 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
Matmatrix to be formated
i1index of the first row being formated
i2index of the last row being formated
j1index of the first column being formated
j2index of the last column being formated
wnumber of positions for each element
pnumber of digits after the decimal point of the elements
styleformating style of the submatrix, being one of MATHEMATICA, MATLAB, or PLAIN
Namedescriptive name of the submatrix
Returns
formated string representing the submatrix

◆ format() [4/4]

static String format ( int  Mat[][],
int  i1,
int  i2,
int  j1,
int  j2,
int  w,
int  style,
String  Name 
)
static

Similar to the previous method, but for a matrix of int’s.

Parameters
Matmatrix to be formated
i1index of the first row being formated
i2index of the last row being formated
j1index of the first column being formated
j2index of the last column being formated
wnumber of positions for each element
styleformating style of the submatrix, being one of MATHEMATICA, MATLAB, or PLAIN
Namedescriptive name of the submatrix
Returns
formated string representing the submatrix

The documentation for this class was generated from the following file: