edu.princeton.repeatedgames.rgsolve.utilities
Class MatrixTextUtilities

java.lang.Object
  extended by edu.princeton.repeatedgames.rgsolve.utilities.MatrixTextUtilities

public class MatrixTextUtilities
extends java.lang.Object

A utility class for translating arrays and BitSets to String, and the reverse.


Field Summary
static java.text.DecimalFormat fullPrec
          Decimal format for 16 digits of decimal precision
 
Constructor Summary
private MatrixTextUtilities()
           
 
Method Summary
static java.lang.String bitSetToZeroOne(java.util.BitSet bitset, int numcols)
          Converts the BitSet bitset into a text matrix of {0,1}, of dimensions (bitset.size() / numcols) x numcols
static java.lang.String booleanToZeroOne(boolean[][] bools)
          Converts boolean[][] into a String of a matrix of {0,1}
static double[][] getMatrixFromString(java.lang.String s, int M, int N)
          Converts the String s to a double[M][N], truncating and padding as necessary
static java.lang.String getMatrixString(double[][] array, int numDigits)
          Converts the double[][] array into a textual representation, entries delimited by spaces, rows by new lines, with numDigits of precision
static java.lang.String getMaxPrecisionMatrixString(double[][] array)
          Converts the double[][] array into a textual representation, entries delimited by spaces, rows by new lines, with full precision.
static BitSetFixed zeroOneToBitSet(java.lang.String s, int M, int N)
          Take a String s of an M x N matrix of {0,1} and converts it into a BitSet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fullPrec

public static final java.text.DecimalFormat fullPrec
Decimal format for 16 digits of decimal precision

Constructor Detail

MatrixTextUtilities

private MatrixTextUtilities()
Method Detail

getMatrixFromString

public static double[][] getMatrixFromString(java.lang.String s,
                                             int M,
                                             int N)
Converts the String s to a double[M][N], truncating and padding as necessary

Parameters:
s -
M -
N -
Returns:
A double[][] of the matrix in the String s

getMaxPrecisionMatrixString

public static java.lang.String getMaxPrecisionMatrixString(double[][] array)
Converts the double[][] array into a textual representation, entries delimited by spaces, rows by new lines, with full precision.

Parameters:
array -
Returns:
A string representation of double[][] array

getMatrixString

public static java.lang.String getMatrixString(double[][] array,
                                               int numDigits)
Converts the double[][] array into a textual representation, entries delimited by spaces, rows by new lines, with numDigits of precision

Parameters:
array -
numDigits -
Returns:
A string representation of double[][] array

bitSetToZeroOne

public static java.lang.String bitSetToZeroOne(java.util.BitSet bitset,
                                               int numcols)
Converts the BitSet bitset into a text matrix of {0,1}, of dimensions (bitset.size() / numcols) x numcols

Parameters:
bitset -
numcols -
Returns:
the text String matrix of {0,1} from bitset

booleanToZeroOne

public static java.lang.String booleanToZeroOne(boolean[][] bools)
Converts boolean[][] into a String of a matrix of {0,1}

Parameters:
bools - the boolean[][] to convert
Returns:
String representation of boolean[][] bools

zeroOneToBitSet

public static BitSetFixed zeroOneToBitSet(java.lang.String s,
                                          int M,
                                          int N)
Take a String s of an M x N matrix of {0,1} and converts it into a BitSet.

Parameters:
s -
M -
N -
Returns:
the BitSet represented by String s