org.optimizationservices.oscommon.util
Class MathUtil

java.lang.Object
  extended by org.optimizationservices.oscommon.util.MathUtil

public class MathUtil
extends java.lang.Object

The MathUtil class contains methods for performing mathematics related operations used by many classes in the Optimization Services (OS) framework.

Since:
OS1.0
Version:
1.0, 03/14/2004
Author:
Robert Fourer, Jun Ma, Kipp Martin, Huanyuan Sheng

Constructor Summary
MathUtil()
          Constructor.
 
Method Summary
static SparseMatrix convertLinearConstraintCoefficientMatrixToTheOtherMajor(boolean isColumnMajor, int[] start, int[] index, double[] value, int dimension)
          convert linear constraint coefficient matrix (row or column major) to the other major (column or row)
static void main(java.lang.String[] argv)
          main for test purposes.
static double mod(double x, double y)
          Calculation of x mod y.
static double round(double x, int precision)
          Round a double number to the precision specified.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtil

public MathUtil()
Constructor.

Method Detail

round

public static double round(double x,
                           int precision)
Round a double number to the precision specified.

Parameters:
x - holds the number to be rounded.
precision - holds the number of digit after (or before if negative) the decimal point.
Returns:
the rounded number.

mod

public static double mod(double x,
                         double y)
Calculation of x mod y.

Parameters:
x - holds the number before the mod operator.
y - holds the number after the mod operator.
Returns:
the result of x mod y.

convertLinearConstraintCoefficientMatrixToTheOtherMajor

public static SparseMatrix convertLinearConstraintCoefficientMatrixToTheOtherMajor(boolean isColumnMajor,
                                                                                   int[] start,
                                                                                   int[] index,
                                                                                   double[] value,
                                                                                   int dimension)
convert linear constraint coefficient matrix (row or column major) to the other major (column or row)

Parameters:
isColumnMajor - holds whether the coefMatrix (AMatrix) holding linear program data is stored by column. If false, the matrix is stored by row.
start - holds an integer array of start elements in coefMatrix (AMatrix), which points to the start of a column (row) of nonzero elements in coefMatrix (AMatrix).
index - holds an integer array of rowIdx (or colIdx) elements in coefMatrix (AMatrix). If the matrix is stored by column (row), rowIdx (colIdx) is the array of row (column) indices.
value - holds a double array of value elements in coefMatrix (AMatrix), which contains nonzero elements.
dimension - holds the column count if the input matrix is row major (row count = start.length-1) or the row number if the input matrix is column major (columnh count = start.length -1)
Returns:
Linear constraint coefficient matrix in the other major of the input matrix. Return null if input matrix not valid.

main

public static void main(java.lang.String[] argv)
main for test purposes.

Parameters:
argv - command line arguments.