org.ode4j.cpp.internal
Class ApiCppMathMisc

java.lang.Object
  extended by org.ode4j.cpp.internal.ApiCppMathMisc
Direct Known Subclasses:
ApiCppMathRotation

public abstract class ApiCppMathMisc
extends java.lang.Object

miscellaneous math functions. these are mostly useful for testing


Constructor Summary
ApiCppMathMisc()
           
 
Method Summary
static void dClearUpperTriangle(double[] A, int n)
          clear the upper triangle of a square matrix
static void dMakeRandomMatrix(double[] A, int n, int m, double range)
          make a random matrix with entries between +/- range.
static void dMakeRandomVector(double[] A, int n, double range)
          make a random vector with entries between +/- range.
static double dMaxDifference(double[] A, double[] B, int n, int m)
          return the maximum element difference between the two n*m matrices
static double dMaxDifferenceLowerTriangle(double[] A, double[] B, int n)
          return the maximum element difference between the lower triangle of two n*n matrices
static long dRand()
          return next 32 bit random number.
static long dRandGetSeed()
          get and set the current random number seed.
static int dRandInt(int n)
          return a random integer between 0..n-1.
static double dRandReal()
          return a random real number between 0..1
static void dRandSetSeed(long s)
           
static boolean dTestRand()
          return 1 if the random number generator is working.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApiCppMathMisc

public ApiCppMathMisc()
Method Detail

dTestRand

public static boolean dTestRand()
return 1 if the random number generator is working.


dRand

public static long dRand()
return next 32 bit random number. this uses a not-very-random linear congruential method.


dRandGetSeed

public static long dRandGetSeed()
get and set the current random number seed.


dRandSetSeed

public static void dRandSetSeed(long s)

dRandInt

public static int dRandInt(int n)
return a random integer between 0..n-1. the distribution will get worse as n approaches 2^32.


dRandReal

public static double dRandReal()
return a random real number between 0..1


dMakeRandomVector

public static void dMakeRandomVector(double[] A,
                                     int n,
                                     double range)
make a random vector with entries between +/- range. A has n elements.


dMakeRandomMatrix

public static void dMakeRandomMatrix(double[] A,
                                     int n,
                                     int m,
                                     double range)
make a random matrix with entries between +/- range. A has size n*m.


dClearUpperTriangle

public static void dClearUpperTriangle(double[] A,
                                       int n)
clear the upper triangle of a square matrix


dMaxDifference

public static double dMaxDifference(double[] A,
                                    double[] B,
                                    int n,
                                    int m)
return the maximum element difference between the two n*m matrices


dMaxDifferenceLowerTriangle

public static double dMaxDifferenceLowerTriangle(double[] A,
                                                 double[] B,
                                                 int n)
return the maximum element difference between the lower triangle of two n*n matrices