Simulation Core Library

org.simulator.math
Class Mathematics

java.lang.Object
  extended by org.simulator.math.Mathematics

public class Mathematics
extends Object

This class contains a collection of mathematical functions like the faculty, logarithms and several trigonometric functions.

Since:
0.9
Version:
$Rev: 454 $
Author:
Marcel Kronfeld, Andreas Dräger, Diedonné Motsuo Wouamba

Constructor Summary
Mathematics()
           
 
Method Summary
static double factorial(double n)
          This method computes the factorial!
static int min(int x, int y, int z)
          This just computes the minimum of three integer values.
static void scale(double scale, double[] vec)
          Scales a vector with the given scalar.
static void svMult(double s, double[] v, double[] res)
          Multiplies (scales) every element of the array v with s in place.
static void svvAddAndScale(double s, double[] v, double[] w, double[] res)
          Add vectors scaled: res[i] = s*(v[i] + w[i])
static void svvAddScaled(double s, double[] v, double[] w, double[] res)
          Add vectors scaled: res[i] = s*v[i] + w[i]
static void swap(double a, double b)
          Swaps a and b if a is greater then b.
static void vvAdd(double[] v1, double[] v2, double[] res)
          Add vectors in place setting res = v1 + v2.
static void vvAddOffs(double[] v1, int v1Offs, double[] v2, int v2Offs, double[] res, int resOffs, int len)
          Add vectors in place setting with an offset within the target vector, meaning that res[resOffs+i]=v1[v1Offs+i]+v2[v2Offs+i] for i in length.
static double[] vvSub(double[] a, double[] b)
          Subtract vectors returning a new vector c = a - b.
static void vvSub(double[] a, double[] b, double[] res)
          Subtract vectors returning a new vector c = a - b.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mathematics

public Mathematics()
Method Detail

factorial

public static final double factorial(double n)
This method computes the factorial! function.

Parameters:
n -
Returns:
result

swap

public static final void swap(double a,
                              double b)
Swaps a and b if a is greater then b.

Parameters:
a -
b -

min

public static int min(int x,
                      int y,
                      int z)
This just computes the minimum of three integer values.

Parameters:
x -
y -
z -
Returns:
Gives the minimum of three integers

scale

public static void scale(double scale,
                         double[] vec)
Scales a vector with the given scalar.

Parameters:
scale -
vec -

svMult

public static void svMult(double s,
                          double[] v,
                          double[] res)
Multiplies (scales) every element of the array v with s in place.

Parameters:
s - a scalar
v - an array to be multiplied with s.

svvAddAndScale

public static void svvAddAndScale(double s,
                                  double[] v,
                                  double[] w,
                                  double[] res)
Add vectors scaled: res[i] = s*(v[i] + w[i])

Parameters:
s -
v -
w -

svvAddScaled

public static void svvAddScaled(double s,
                                double[] v,
                                double[] w,
                                double[] res)
Add vectors scaled: res[i] = s*v[i] + w[i]

Parameters:
s -
v -
w -

vvAdd

public static void vvAdd(double[] v1,
                         double[] v2,
                         double[] res)
Add vectors in place setting res = v1 + v2.

Parameters:
v1 -
v2 -

vvAddOffs

public static void vvAddOffs(double[] v1,
                             int v1Offs,
                             double[] v2,
                             int v2Offs,
                             double[] res,
                             int resOffs,
                             int len)
Add vectors in place setting with an offset within the target vector, meaning that res[resOffs+i]=v1[v1Offs+i]+v2[v2Offs+i] for i in length.

Parameters:
v1 -
v2 -

vvSub

public static double[] vvSub(double[] a,
                             double[] b)
Subtract vectors returning a new vector c = a - b.

Parameters:
a -
b -
Returns:
a new vector c = a - b

vvSub

public static void vvSub(double[] a,
                         double[] b,
                         double[] res)
Subtract vectors returning a new vector c = a - b.

Parameters:
a -
b -

Generated at March 17 2014
Version 1.4 Revision 453