ru.sscc.util.data
Class RealMath

java.lang.Object
  |
  +--ru.sscc.util.data.RealMath

public class RealMath
extends java.lang.Object

A collection of basic algebraic operations with real vectors.


Field Summary
static double DBL_EPSILON
          Smallest double value such that 1+DBL_EPSILON isn't equal to 1.
static float FLT_EPSILON
          Smallest float value such that 1+FLT_EPSILON isn't equal to 1.
 
Method Summary
static void addVector(double[] vector1, int index1, int step1, double[] vector2, int index2, int step2, double factor, int count)
          Operation vector1 = vector1 + factor * vector2.
static void addVector(float[] vector1, int index1, int step1, float[] vector2, int index2, int step2, double factor, int count)
          Operation vector1 = vector1 + factor * vector2.
static void addVector(RealPointer p1, RealPointer p2, double factor, int count)
          Operation p1 = p1 + factor * p2.
static void assign(double[] vector1, int index1, int step1, double[] vector2, int index2, int step2, int count)
          Assignment vector1 = vector2.
static void assign(double[] vector, int index, int step, double value, int count)
          Assignment vector = value.
static void assign(float[] vector, int index, int step, double value, int count)
          Assignment vector = value.
static void assign(float[] vector1, int index1, int step1, float[] vector2, int index2, int step2, int count)
          Assignment vector1 = vector2.
static void assign(RealPointer p1, double[] vector2, int index2, int step2, int count)
          Assignment p1 = vector2.
static void assign(RealPointer p, double value, int count)
          Assignment p = value.
static void assign(RealPointer p1, float[] vector2, int index2, int step2, int count)
          Assignment p1 = vector2.
static void assign(RealPointer p1, RealPointer p2, double factor, int count)
          Assignement p1 = factor*p2.
static void assign(RealPointer p1, RealPointer p2, int count)
          Assignment p1 = p2.
static double factorial(int n)
          Calculates n! -- the factorial of n.
static int indexOfNormMax(double[] vector, int index, int step, int count)
          Calculates the index of the first entry having the maximum module for the vector stored in the double[] type array.
static int indexOfNormMax(float[] vector, int index, int step, int count)
          Calculates the index of the first entry having the maximum module for the vector stored in the float[] type array.
static int indexOfNormMax(RealPointer p, int count)
          Calculates the index of the first entry having the maximum module for the vector presented by RealPointer.
static double innerProduct(double[] vector1, int index1, int step1, double[] vector2, int index2, int step2, int count)
          Calculates an inner product of two vectors stored in double[] type arrays.
static double innerProduct(float[] vector1, int index1, int step1, float[] vector2, int index2, int step2, int count)
          Calculates an inner product of two vectors stored in float[] type arrays.
static double innerProduct(RealPointer p1, RealPointer p2, int count)
          Calculates an inner product of two vectors presented by RealPointer pointers.
static void multiply(double[] vector, int index, int step, double value, int count)
          Multiplication of a vector by a value.
static void multiply(float[] vector, int index, int step, double value, int count)
          Multiplication of a vector by a value.
static void multiply(RealPointer p, double value, int count)
          Multiplication of a vector by a value.
static double norm(RealPointer p, int count)
          Calculates the euqlidian norm of a vector presented by RealPointer.
static double normMax(double[] vector, int index, int step, int count)
          Calculates the maximum modules norm of the vector stored in the double[] type array.
static double normMax(float[] vector, int index, int step, int count)
          Calculates the maximum modules norm of the vector stored in the float[] type array.
static double normMax(RealPointer p, int count)
          Calculates the maximum modules norm of a vector presented by RealPointer.
static double normSum(double[] vector, int index, int step, int count)
          Calculates the sum of modules norm of the vector stored in the double[] type array.
static double normSum(float[] vector, int index, int step, int count)
          Calculates the sum of modules norm of the vector stored in the float[] type array.
static double normSum(RealPointer p, int count)
          Calculates the sum of modules norm of a vector presented by RealPointer.
static double polynomial(double[] vector, int index, int step, double x, int degree)
          Calculates a polynomial of required degree at the point x.
static double polynomial(float[] vector, int index, int step, double x, int degree)
          Calculates a polynomial of required degree at the point x.
static double polynomial(RealPointer vector, double x, int degree)
          Calculates a polynomial of required degree at the point x.
static double power(double x, int n)
          Calculate xn -- x powered to the integer power n.
static void recalculatePolynomial(double[] source, int index1, int step1, double[] target, int index2, int step2, double x, int degree)
          Recalculates polynomial representation with respect to a point x using its representation at zero (source and target coefficient vectors may coinside).
static void recalculatePolynomial(float[] source, int index1, int step1, float[] target, int index2, int step2, double x, int degree)
          Recalculates polynomial representation with respect to a point x using its representation at zero (source and target coefficient vectors may coinside).
static void recalculatePolynomial(RealPointer source, RealPointer target, double x, int degree)
          Recalculates polynomial representation with respect to a point x using its representation at zero (source and target coefficient vectors may coinside).
static double squaredDistance(double[] vector1, int index1, double[] vector2, int index2, int count)
          Calculates the squared euqlidian distance between two vectors stored in double[] type arrays.
static double squaredDistance(double[] vector1, int index1, float[] vector2, int index2, int count)
          Calculates the squared euqlidian distance between two vectors stored in double[] and float[] type arrays respectively.
static double squaredDistance(float[] vector1, int index1, float[] vector2, int index2, int count)
          Calculates the squared euqlidian distance between two vectors stored in float[] type arrays.
static double squaredDistance(RealPointer p1, double[] vector2, int index2, int count)
          Calculates the squared euqlidian distance between a vector presented by real pointer and a vector stored in double[] type array.
static double squaredDistance(RealPointer p1, float[] vector2, int index2, int count)
          Calculates the squared euqlidian distance between a vector presented by real pointer and a vector stored in float[] type array.
static double squaredDistance(RealPointer p1, RealPointer p2, int count)
          Calculates a squared euqlidian distance between two vectors.
static void swap(double[] vector1, int index1, int step1, double[] vector2, int index2, int step2, int count)
          Swaps entries of vector1 with corresponding entries of vector2 for the double[] type storage.
static void swap(float[] vector1, int index1, int step1, float[] vector2, int index2, int step2, int count)
          Swaps entries of vector1 with corresponding entries of vector2 for the float[] type storage.
static double weightedNorm(RealPointer p, RealPointer weight, int count)
          Calculates the weighted euqlidian norm of a vector presented by RealPointer.
static double weightedNormMax(double[] vector, int index, int step, RealPointer weight, int count)
          Calculates the weighted maximum modules norm of the vector stored in the double[] type array.
static double weightedNormMax(float[] vector, int index, int step, RealPointer weight, int count)
          Calculates the weighted maximum modules norm of the vector stored in the float[] type array.
static double weightedNormMax(RealPointer p, RealPointer weight, int count)
          Calculates the weighted maximum modules norm of a vector presented by RealPointer.
static double weightedNormSum(double[] vector, int index, int step, RealPointer weight, int count)
          Calculates the weighted sum of modules norm of the vector stored in the double[] type array.
static double weightedNormSum(float[] vector, int index, int step, RealPointer weight, int count)
          Calculates the weighted sum of modules norm of the vector stored in the float[] type array.
static double weightedNormSum(RealPointer p, RealPointer weight, int count)
          Calculates the weighted sum of modules norm of a vector presented by RealPointer.
static double weightedProduct(double[] vector1, int index1, int step1, double[] vector2, int index2, int step2, RealPointer weight, int count)
          Calculates the weighted inner product of two vectors stored in double[] type arrays.
static double weightedProduct(float[] vector1, int index1, int step1, float[] vector2, int index2, int step2, RealPointer weight, int count)
          Calculates the weighted inner product of two vectors stored in float[] type arrays.
static double weightedProduct(RealPointer p1, RealPointer p2, RealPointer weight, int count)
          Calculates the weighted inner product of two vectors presented by RealPointer pointers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBL_EPSILON

public static final double DBL_EPSILON
Smallest double value such that 1+DBL_EPSILON isn't equal to 1.

FLT_EPSILON

public static final float FLT_EPSILON
Smallest float value such that 1+FLT_EPSILON isn't equal to 1.
Method Detail

assign

public static void assign(double[] vector,
                          int index,
                          int step,
                          double value,
                          int count)
Assignment vector = value. Assigns a value to the vector stored in double[] type array.
Parameters:
vector - a container for the vector
index - a starting index
step - an increment step
value - a value to assign
count - a vector size

assign

public static void assign(float[] vector,
                          int index,
                          int step,
                          double value,
                          int count)
Assignment vector = value. Assigns a value to the vector stored in float[] type array.
Parameters:
vector - a container for the vector
index - a starting index
step - an increment step
value - a value to assign
count - a vector size

assign

public static void assign(RealPointer p,
                          double value,
                          int count)
Assignment p = value. Vector is described by RealPointer pointer.
Parameters:
p - a pointer to the vector
value - a value to assign
count - a vector size

assign

public static void assign(double[] vector1,
                          int index1,
                          int step1,
                          double[] vector2,
                          int index2,
                          int step2,
                          int count)
Assignment vector1 = vector2. Assigns the first vector stored in double[] type array by the second vector of the same type.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vector size

assign

public static void assign(float[] vector1,
                          int index1,
                          int step1,
                          float[] vector2,
                          int index2,
                          int step2,
                          int count)
Assignment vector1 = vector2. Assigns the first vector stored in float[] type array by the second vector of the same type.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vector size

assign

public static void assign(RealPointer p1,
                          double[] vector2,
                          int index2,
                          int step2,
                          int count)
Assignment p1 = vector2. Assigns the first vector pointed by RealPointer by the second vector of the double[] type.
Parameters:
p1 - a pointer to the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vector size

assign

public static void assign(RealPointer p1,
                          float[] vector2,
                          int index2,
                          int step2,
                          int count)
Assignment p1 = vector2. Assigns the first vector pointed by RealPointer by the second vector of the float[] type.
Parameters:
p1 - a pointer to the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vector size

assign

public static void assign(RealPointer p1,
                          RealPointer p2,
                          int count)
Assignment p1 = p2. Vectors are presented by RealPointer pointers.
Parameters:
p1 - a pointer to the first (target) vector
p2 - a pointer to the second (source) vector
count - a vector size

assign

public static void assign(RealPointer p1,
                          RealPointer p2,
                          double factor,
                          int count)
Assignement p1 = factor*p2. Vectors are presented by RealPointer pointers.
Parameters:
p1 - a pointer to the first (target) vector
p2 - a pointer to the second (source) vector
factor - a multiple
count - a vector size

addVector

public static void addVector(double[] vector1,
                             int index1,
                             int step1,
                             double[] vector2,
                             int index2,
                             int step2,
                             double factor,
                             int count)
Operation vector1 = vector1 + factor * vector2. Adds to the first vector stored in double[] type array the second vector of the same type multiplied by a factor.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
factor - a multiplier
count - a vector size

addVector

public static void addVector(float[] vector1,
                             int index1,
                             int step1,
                             float[] vector2,
                             int index2,
                             int step2,
                             double factor,
                             int count)
Operation vector1 = vector1 + factor * vector2. Adds to the first vector stored in float[] type array the second vector of the same type multiplied by a factor.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
factor - a multiplier
count - a vector size

addVector

public static void addVector(RealPointer p1,
                             RealPointer p2,
                             double factor,
                             int count)
Operation p1 = p1 + factor * p2. Adds to the first vector the second vector multiplied by a factor. Vectors are presented by RealPointer pointers.
Parameters:
p1 - a pointer to the first vector
p2 - a pointer to the second vector
factor - a multiplier
count - a vector length

multiply

public static void multiply(double[] vector,
                            int index,
                            int step,
                            double value,
                            int count)
Multiplication of a vector by a value. Multiplues a vector stored in double[] type array by a value.
Parameters:
vector - a container for the vector
index - a starting index
step - an increment step
value - a value to multiply
count - a vector size

multiply

public static void multiply(float[] vector,
                            int index,
                            int step,
                            double value,
                            int count)
Multiplication of a vector by a value. Multiplues a vector stored in float[] type array by a value.
Parameters:
vector - a container for the vector
index - a starting index
step - an increment step
value - a value to multiply
count - a vector size

multiply

public static void multiply(RealPointer p,
                            double value,
                            int count)
Multiplication of a vector by a value. Vector is described by RealPointer pointer.
Parameters:
p - a pointer to the vector
value - a value to multiply
count - a vector size

innerProduct

public static double innerProduct(double[] vector1,
                                  int index1,
                                  int step1,
                                  double[] vector2,
                                  int index2,
                                  int step2,
                                  int count)
Calculates an inner product of two vectors stored in double[] type arrays.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vector size
Returns:
the inner product of the vectors

innerProduct

public static double innerProduct(float[] vector1,
                                  int index1,
                                  int step1,
                                  float[] vector2,
                                  int index2,
                                  int step2,
                                  int count)
Calculates an inner product of two vectors stored in float[] type arrays.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vector size
Returns:
the inner product of the vectors

innerProduct

public static double innerProduct(RealPointer p1,
                                  RealPointer p2,
                                  int count)
Calculates an inner product of two vectors presented by RealPointer pointers.
Parameters:
p1 - a pointer to the first vector
p2 - a pointer to the second vector
count - a vector size
Returns:
the inner product of the vectors

weightedProduct

public static double weightedProduct(double[] vector1,
                                     int index1,
                                     int step1,
                                     double[] vector2,
                                     int index2,
                                     int step2,
                                     RealPointer weight,
                                     int count)
Calculates the weighted inner product of two vectors stored in double[] type arrays.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
weight - a pointer to the weight vector (may be equal to null)
count - a vector size
Returns:
the inner product of the vectors

weightedProduct

public static double weightedProduct(float[] vector1,
                                     int index1,
                                     int step1,
                                     float[] vector2,
                                     int index2,
                                     int step2,
                                     RealPointer weight,
                                     int count)
Calculates the weighted inner product of two vectors stored in float[] type arrays.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
weight - a pointer to the weight vector (may be equal to null)
count - a vector size
Returns:
the inner product of the vectors

weightedProduct

public static double weightedProduct(RealPointer p1,
                                     RealPointer p2,
                                     RealPointer weight,
                                     int count)
Calculates the weighted inner product of two vectors presented by RealPointer pointers.
Parameters:
p1 - a pointer to the first vector
p2 - a pointer to the second vector
weight - a pointer to the weight vector (may be equal to null)
count - a vector size
Returns:
the weighted inner product of the vectors

norm

public static double norm(RealPointer p,
                          int count)
Calculates the euqlidian norm of a vector presented by RealPointer.
Parameters:
p - a pointer to the vector
count - a vector size
Returns:
the euqlidian norm

normMax

public static double normMax(double[] vector,
                             int index,
                             int step,
                             int count)
Calculates the maximum modules norm of the vector stored in the double[] type array.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
count - the vector size
Returns:
the max-norm

normMax

public static double normMax(float[] vector,
                             int index,
                             int step,
                             int count)
Calculates the maximum modules norm of the vector stored in the float[] type array.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
count - the vector size
Returns:
the max-norm

normMax

public static double normMax(RealPointer p,
                             int count)
Calculates the maximum modules norm of a vector presented by RealPointer.
Parameters:
p - a pointer to the vector
count - a vector size
Returns:
the max-norm

normSum

public static double normSum(double[] vector,
                             int index,
                             int step,
                             int count)
Calculates the sum of modules norm of the vector stored in the double[] type array.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
count - the vector size
Returns:
the sum-norm

normSum

public static double normSum(float[] vector,
                             int index,
                             int step,
                             int count)
Calculates the sum of modules norm of the vector stored in the float[] type array.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
count - the vector size
Returns:
the sum-norm

normSum

public static double normSum(RealPointer p,
                             int count)
Calculates the sum of modules norm of a vector presented by RealPointer.
Parameters:
p - a pointer to the vector
count - a vector size
Returns:
the sum-norm

indexOfNormMax

public static int indexOfNormMax(double[] vector,
                                 int index,
                                 int step,
                                 int count)
Calculates the index of the first entry having the maximum module for the vector stored in the double[] type array. If vector length is nonpositive, (-1) is returned.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
count - the vector size
Returns:
the index of entry having the maximum module

indexOfNormMax

public static int indexOfNormMax(float[] vector,
                                 int index,
                                 int step,
                                 int count)
Calculates the index of the first entry having the maximum module for the vector stored in the float[] type array. If vector length is nonpositive, (-1) is returned.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
count - the vector size
Returns:
the index of entry having the maximum module

indexOfNormMax

public static int indexOfNormMax(RealPointer p,
                                 int count)
Calculates the index of the first entry having the maximum module for the vector presented by RealPointer. If vector length is nonpositive, (-1) is returned.
Parameters:
p - a pointer to the vector
count - the vector size
Returns:
the index of entry having the maximum module

weightedNorm

public static double weightedNorm(RealPointer p,
                                  RealPointer weight,
                                  int count)
Calculates the weighted euqlidian norm of a vector presented by RealPointer.
Parameters:
p - a pointer to the vector
weight - a pointer to the weight vector (may be equal to null)
count - a vector size
Returns:
the weighted euqlidian norm

weightedNormMax

public static double weightedNormMax(double[] vector,
                                     int index,
                                     int step,
                                     RealPointer weight,
                                     int count)
Calculates the weighted maximum modules norm of the vector stored in the double[] type array.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
weight - a pointer to the weight vector (may be equal to null)
count - the vector size
Returns:
the weighted max-norm

weightedNormMax

public static double weightedNormMax(float[] vector,
                                     int index,
                                     int step,
                                     RealPointer weight,
                                     int count)
Calculates the weighted maximum modules norm of the vector stored in the float[] type array.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
weight - a pointer to the weight vector (may be equal to null)
count - the vector size
Returns:
the weighted max-norm

weightedNormMax

public static double weightedNormMax(RealPointer p,
                                     RealPointer weight,
                                     int count)
Calculates the weighted maximum modules norm of a vector presented by RealPointer.
Parameters:
p - a pointer to the vector
weight - a pointer to the weight vector (may be equal to null)
count - a vector size
Returns:
the weighted max-norm

weightedNormSum

public static double weightedNormSum(double[] vector,
                                     int index,
                                     int step,
                                     RealPointer weight,
                                     int count)
Calculates the weighted sum of modules norm of the vector stored in the double[] type array.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
weight - the pointer to the weight vector (may be equal to null)
count - the vector size
Returns:
the weighted sum-norm

weightedNormSum

public static double weightedNormSum(float[] vector,
                                     int index,
                                     int step,
                                     RealPointer weight,
                                     int count)
Calculates the weighted sum of modules norm of the vector stored in the float[] type array.
Parameters:
vector - the container for the vector
index - the starting index
step - the increment step
weight - the pointer to the weight vector (may be equal to null)
count - the vector size
Returns:
the weighted sum-norm

weightedNormSum

public static double weightedNormSum(RealPointer p,
                                     RealPointer weight,
                                     int count)
Calculates the weighted sum of modules norm of a vector presented by RealPointer.
Parameters:
p - a pointer to the vector
weight - a pointer to the weight vector (may be equal to null)
count - a vector size
Returns:
the weighted sum-norm

swap

public static void swap(double[] vector1,
                        int index1,
                        int step1,
                        double[] vector2,
                        int index2,
                        int step2,
                        int count)
Swaps entries of vector1 with corresponding entries of vector2 for the double[] type storage.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vector size

swap

public static void swap(float[] vector1,
                        int index1,
                        int step1,
                        float[] vector2,
                        int index2,
                        int step2,
                        int count)
Swaps entries of vector1 with corresponding entries of vector2 for the float[] type storage.
Parameters:
vector1 - a container for the first vector
index1 - a starting index for the first vector
step1 - an increment step for the first vector
vector2 - a container for the second vector
index2 - a starting index for the second vector
step2 - an increment step for the second vector
count - a vector size

squaredDistance

public static double squaredDistance(double[] vector1,
                                     int index1,
                                     double[] vector2,
                                     int index2,
                                     int count)
Calculates the squared euqlidian distance between two vectors stored in double[] type arrays. The vectors are stored with unit increment between their entries.
Parameters:
vector1 - a container for the first vector
index1 - a starting index in the first vector
vector2 - a container for the second vector
index2 - a starting index in the second vector
count - a vector size

squaredDistance

public static double squaredDistance(double[] vector1,
                                     int index1,
                                     float[] vector2,
                                     int index2,
                                     int count)
Calculates the squared euqlidian distance between two vectors stored in double[] and float[] type arrays respectively. The vectors are stored with unit increment between their entries.
Parameters:
vector1 - a container for the first vector
index1 - a starting index in the first vector
vector2 - a container for the second vector
index2 - a starting index in the second vector
count - a vector size

squaredDistance

public static double squaredDistance(float[] vector1,
                                     int index1,
                                     float[] vector2,
                                     int index2,
                                     int count)
Calculates the squared euqlidian distance between two vectors stored in float[] type arrays. The vectors are stored with unit increment between their entries.
Parameters:
vector1 - a container for the first vector
index1 - a starting index in the first vector
vector2 - a container for the second vector
index2 - a starting index in the second vector
count - a vector size

squaredDistance

public static double squaredDistance(RealPointer p1,
                                     double[] vector2,
                                     int index2,
                                     int count)
Calculates the squared euqlidian distance between a vector presented by real pointer and a vector stored in double[] type array. The second vector is stored with unit increment between entries.
Parameters:
p1 - a pointer to the first vector
vector2 - a container for the second vector
index2 - a starting index in the second vector
count - a vector size

squaredDistance

public static double squaredDistance(RealPointer p1,
                                     float[] vector2,
                                     int index2,
                                     int count)
Calculates the squared euqlidian distance between a vector presented by real pointer and a vector stored in float[] type array. The second vector is stored with unit increment between entries.
Parameters:
p1 - a pointer to the first vector
vector2 - a container for the second vector
index2 - a starting index in the second vector
count - a vector size

squaredDistance

public static double squaredDistance(RealPointer p1,
                                     RealPointer p2,
                                     int count)
Calculates a squared euqlidian distance between two vectors.
Parameters:
p1 - a pointer to the first vector
p2 - a pointer to the second vector
count - a vector size
Returns:
the squared euqlidian distance

polynomial

public static double polynomial(double[] vector,
                                int index,
                                int step,
                                double x,
                                int degree)
Calculates a polynomial of required degree at the point x. The polynomial coefficients are stored in double[] type vector from the index position with the step increment in growing order: for x0, x1, ..., xdegree.
Parameters:
vector - contains polynomial coefficients
index - a starting position in the vector
step - a distance between neighboring coefficients
x - a point to calculate
degree - a degree of polynomial
Returns:
the polynomial value (if degree<0, returns 0)

polynomial

public static double polynomial(float[] vector,
                                int index,
                                int step,
                                double x,
                                int degree)
Calculates a polynomial of required degree at the point x. The polynomial coefficients are stored in float[] type vector from the index position with the step increment in growing order: for x0, x1, ..., xdegree.
Parameters:
vector - contains polynomial coefficients
index - a starting position in the vector
step - a distance between neighboring coefficients
x - a point to calculate
degree - a degree of polynomial
Returns:
the polynomial value (if degree<0, returns 0)

polynomial

public static double polynomial(RealPointer vector,
                                double x,
                                int degree)
Calculates a polynomial of required degree at the point x. The polynomial coefficients are stored in growing order of monomial powers in the vector pointed by RealPointer.
Parameters:
vector - a pointer to polynomial coefficients
x - a point to calculate
degree - a degree of polynomial
Returns:
the polynomial value (if degree<0, returns 0)

recalculatePolynomial

public static void recalculatePolynomial(double[] source,
                                         int index1,
                                         int step1,
                                         double[] target,
                                         int index2,
                                         int step2,
                                         double x,
                                         int degree)
Recalculates polynomial representation with respect to a point x using its representation at zero (source and target coefficient vectors may coinside). The polynomial coefficients are stored in growing order of monomial powers in the vectors inside double[] arrays.
Parameters:
source - contains source polynomial representation at zero
target - a pointer to the target polynomial representation at x
x - a point to recalculate the polynomial
degree - a polynomial degree (if degree<0, nothing happens)

recalculatePolynomial

public static void recalculatePolynomial(float[] source,
                                         int index1,
                                         int step1,
                                         float[] target,
                                         int index2,
                                         int step2,
                                         double x,
                                         int degree)
Recalculates polynomial representation with respect to a point x using its representation at zero (source and target coefficient vectors may coinside). The polynomial coefficients are stored in growing order of monomial powers in the vectors inside float[] arrays.
Parameters:
source - contains source polynomial representation at zero
target - a pointer to the target polynomial representation at x
x - a point to recalculate the polynomial
degree - a polynomial degree (if degree<0, nothing happens)

recalculatePolynomial

public static void recalculatePolynomial(RealPointer source,
                                         RealPointer target,
                                         double x,
                                         int degree)
Recalculates polynomial representation with respect to a point x using its representation at zero (source and target coefficient vectors may coinside). The polynomial coefficients are stored in growing order of monomial powers in the vectors pointed by RealPointer's instances.
Parameters:
source - a pointer to the source polynomial representation at zero
target - a pointer to the target polynomial representation at x
x - a point to recalculate the polynomial
degree - a polynomial degree (if degree<0, nothing happens)

factorial

public static double factorial(int n)
Calculates n! -- the factorial of n.

power

public static double power(double x,
                           int n)
Calculate xn -- x powered to the integer power n.