main
Class MoreMath

java.lang.Object
  extended bymain.MoreMath

public class MoreMath
extends java.lang.Object

This class includes a bunch of extra mathematical functions and other math tidbits that are useful to have around. All the functions are static and all the important ones are public, so you never actually need to instantiate this class.


Nested Class Summary
static interface MoreMath.Comparer
           
 class MoreMath.PartialDerivRec
          A record class that's handy when assembling a Jacobian matrix from the Affectors' formulas rather than numerically.
 
Field Summary
static int BROWN_NOISE
           
static int GAUSSIAN
           
static int UNIFORM
           
 
Constructor Summary
MoreMath()
           
 
Method Summary
static void calcJacobian(float[] matrix, Cell cell, int num_nodes, float epsilon)
          Calculates the jacobian matrix for the equations in a network around the Node values of the input cell.
static void eigenvalues(float[] a, int n, float[] wr, float[] wi)
          Numerical recipes in C code for finding eigenvalues of a general, real, non-symmetric matrix.
static double getStdDev(double sum, double sum_sqr, int num)
          Returns the standard deviation.
static float getStdDev(float sum, float sum_sqr, int num)
           
static float pickRandomLinear(float min, float max)
           
static float pickRandomLogarithmic(float min, float max)
           
static float randNeg(int mode)
           
static float random()
           
static float random(int mode)
           
static int randomInt(int min, int max)
          Returns an integer between min and max - 1.
static void randomize(int[] array)
          Randomizes the elements in the array.
static void setRandomSeed(int seed)
           
static void sort(java.lang.Object[] a, MoreMath.Comparer comparer)
           
static void sort(java.lang.Object[] a, java.lang.Object[] b, int from, int to, boolean ascending, MoreMath.Comparer comparer)
          Sort a and b, using a as the reference - stolen from somewhere on internet
static double sqr(double num)
          Returns num * num
static float sqr(float num)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNIFORM

public static final int UNIFORM
See Also:
Constant Field Values

GAUSSIAN

public static final int GAUSSIAN
See Also:
Constant Field Values

BROWN_NOISE

public static final int BROWN_NOISE
See Also:
Constant Field Values
Constructor Detail

MoreMath

public MoreMath()
Method Detail

sqr

public static double sqr(double num)
Returns num * num


sqr

public static float sqr(float num)

getStdDev

public static double getStdDev(double sum,
                               double sum_sqr,
                               int num)
Returns the standard deviation. Sum is the sum of the values, sum_sqr is the sum of the squares of the values, and num is the number of values.


getStdDev

public static float getStdDev(float sum,
                              float sum_sqr,
                              int num)

setRandomSeed

public static void setRandomSeed(int seed)

random

public static float random()

random

public static float random(int mode)

randNeg

public static float randNeg(int mode)

randomInt

public static int randomInt(int min,
                            int max)
Returns an integer between min and max - 1.


pickRandomLinear

public static float pickRandomLinear(float min,
                                     float max)

pickRandomLogarithmic

public static float pickRandomLogarithmic(float min,
                                          float max)

randomize

public static void randomize(int[] array)
Randomizes the elements in the array.


calcJacobian

public static void calcJacobian(float[] matrix,
                                Cell cell,
                                int num_nodes,
                                float epsilon)
Calculates the jacobian matrix for the equations in a network around the Node values of the input cell. epsilon determines the amount to change each Node when finding the derivative.


eigenvalues

public static void eigenvalues(float[] a,
                               int n,
                               float[] wr,
                               float[] wi)
                        throws java.lang.Exception
Numerical recipes in C code for finding eigenvalues of a general, real, non-symmetric matrix. Note - this function destroys the matrix a. a is the square input matrix, n is the length of a, wr are the real parts of the eigenvalues, wi are the imaginary parts.

Throws:
java.lang.Exception

sort

public static void sort(java.lang.Object[] a,
                        MoreMath.Comparer comparer)

sort

public static void sort(java.lang.Object[] a,
                        java.lang.Object[] b,
                        int from,
                        int to,
                        boolean ascending,
                        MoreMath.Comparer comparer)
Sort a and b, using a as the reference - stolen from somewhere on internet