org.simbrain.util
Class SimbrainMath

java.lang.Object
  extended by org.simbrain.util.SimbrainMath

public class SimbrainMath
extends Object

SimbrainMath is the math functions used in simbrain.


Constructor Summary
SimbrainMath()
           
 
Method Summary
static void addNoise(double[] vector, double noiselevel)
          Add noise to an vector.
static double[] addVector(double[] base, double[] add)
          Add these vectors.
static int distance(Point src, Point tar)
          Calculates the Euclidean distance between two points.
static double getAverage(double[] vals)
          Helper function for computing mean values of an array of doubles.
static double getMaximum(double[] theVec)
          Finds the largest value in a vector array.
static double inverf(double p)
          Calculates the inverse of the error function.
static double[] max(double[] one, double[] two)
          Finds the larger of two numbers.
static int max(int one, int two)
          Return the greater of two integers.
static double[] multVector(double[] theVec, double mult)
          Finds the vector multiple.
static void printVector(double[] da)
          Prints out the vector list.
static double[] zeroVector(int size)
          Set an array of doubles to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimbrainMath

public SimbrainMath()
Method Detail

distance

public static int distance(Point src,
                           Point tar)
Calculates the Euclidean distance between two points. Used in World.

Parameters:
src - source point
tar - target point
Returns:
distance between source and target

zeroVector

public static double[] zeroVector(int size)
Set an array of doubles to zero. TODO: Replace usage in World with library call

Parameters:
size - size of array
Returns:
new array of zero'd values

multVector

public static double[] multVector(double[] theVec,
                                  double mult)
Finds the vector multiple.

Parameters:
theVec - Vecotr
mult - Multiple
Returns:
Multiple of the vector and the multiple TODO: Replace occurence in world with library call

max

public static int max(int one,
                      int two)
Return the greater of two integers.

Parameters:
one - first int
two - second int
Returns:
greater of one and two

max

public static double[] max(double[] one,
                           double[] two)
Finds the larger of two numbers.

Parameters:
one - First number
two - Second number
Returns:
the larger number

addVector

public static double[] addVector(double[] base,
                                 double[] add)
Add these vectors. If one is larger than the other return a vector with zeros in the difference.

Parameters:
base - Base number
add - Number to be added to base number
Returns:
added vectors

getAverage

public static double getAverage(double[] vals)
Helper function for computing mean values of an array of doubles.

Parameters:
vals - an array of values
Returns:
the mean values of the array

printVector

public static void printVector(double[] da)
Prints out the vector list.

Parameters:
da - Vector list

inverf

public static double inverf(double p)
Calculates the inverse of the error function. Originally written by S.C. Pohlig, adapted by J.N. Sanders

Parameters:
p - Parameter to find inverse of the error
Returns:
inverse of the error

getMaximum

public static double getMaximum(double[] theVec)
Finds the largest value in a vector array.

Parameters:
theVec - Vector array
Returns:
largest value in array

addNoise

public static void addNoise(double[] vector,
                            double noiselevel)
Add noise to an vector.

Parameters:
vector - vector to which noise should be added
noiselevel - Noise level