math
Class Mat1

java.lang.Object
  extended by math.Mat1

public abstract class Mat1
extends java.lang.Object

Mat1 is a class that uses 1-D arrays and contains static methods.

Author:
Douglas Lyon

Constructor Summary
Mat1()
           
 
Method Summary
static double[] accumulate(double[] a)
           
static double add(byte[] a)
           
static double add(double[] a)
          Sum all the numbers and return the result.
static void add(double[] a, double k)
           
static void add(double[] a, double[] b)
          Add two vectors.
static void add(double[] a, double[] b, double c)
          Add a vector times a scalar to a vector.
static void add(double[] a, double[] b, double[] c)
          Add three vectors.
static double add(float[] a)
           
static void add(float[] a, float[] b)
          Add two vectors.
static void add(float[] a, float[] b, float[] c)
           
static double add(int[] a)
           
static double add(short[] a)
           
static double add16(float[] a)
           
static float add4(float[] a)
           
static float add8(float[] a)
           
static void add8(float[] a, float[] b, float[] c)
           
static double add8Depend(float[] a)
           
static double add8NoDepend(float[] a)
           
static double addUnsigned(byte[] a)
           
static double[] arrayCopy(double[] in)
           
static double[] arrayCopy(double[] source, int sourceStartPoint, int length)
           
static float[] arrayCopy(float[] in)
           
static double[] backwardDerivativeMag(double[] a)
           
static void centering(double[] r)
           
static int[] clamp(int[] ia)
           
static double coefficientOfVariation(float[] a)
           
static double coefficientOfVariation(int[] a)
          Standard deviation divided by the mean is the coefficientOfVariation
static double[] concatenate(double[] a, double[] b)
           
static double[] concatenate(double[] a, double[] b, double[] c)
           
static double[] concatenate(double[] a, double[] b, double[] c, double[] d)
           
static int[] concatenate(int[] a, int[] b)
           
static double[] concatenate(java.util.Vector v)
           
static double[] copyArray(double[] a)
           
static float[] copyArray(float[] a)
           
static short[] copyArray(short[] a)
           
static double[] cross2D(double[] a, double b)
          Calculate the cross product of a vector within a plane and a vector perpendicular to a plane.
static double cross2D(double[] a, double[] b)
          Calculate the cross product of two vectors that lie within a plane.
static double[] divide(double[] a, double b)
          Divide creates a new array.
static double[] divide(double[] a, double[] b)
           
static void divideEquals(double[] a, double b)
          Replace the a array with a = a / b
static double dot(double[] a)
          Calculate the dot product of a vector with itself.
static double dot(double[] a, double[] b)
          Calculate the dot product of two vectors.
static short dot(short[] a, short[] b)
          Calculate the dot product of two vectors.
static boolean equals(boolean[] a1, boolean[] a2)
           
static boolean equals(byte[] a1, byte[] a2)
           
static boolean equals(char[] a1, char[] a2)
           
static boolean equals(double[] a1, double[] a2)
           
static boolean equals(float[] a1, float[] a2)
           
static boolean equals(int[] a1, int[] a2)
           
static boolean equals(long[] a1, long[] a2)
           
static boolean equals(short[] a1, short[] a2)
           
static double[] fastCorrelation(double[] x, double[] y, boolean nomalize)
           
static void forwardDerivativeMag(double[] a)
           
static float[] getBiasedRampDataFloat(int n)
           
static double[] getDouble(float[] d)
           
static double[] getDoubleArray(int[] ints)
           
static float[] getFloat(double[] d)
           
static double getGeometricMean(double[] a)
           
static double getGeometricMean(short[] a)
           
static double[] getHalfArray(double[] a)
          Get 1/2 of the array
static int[] getIntArray(double[] d)
          input an array of double and return an array of int, via truncation
static double[] getInterpolation(double[] d, int ws)
           
static double[] getInterpolationMinMax(double[] d, int ws)
           
static int getLocation(double[] a, double value)
           
static int[] getMat1(int i)
           
static int[] getMat1(long i)
           
static double getMax(double[] a)
           
static float getMax(float[] a)
           
static int getMax(int[] a)
           
static short getMax(short[] a)
           
static int getMaxLocation(double[] psd)
           
static int getMaxLocation(int offsetFromEdge, double[] psd)
           
static double getMaxValue(double[] in)
           
static double getMean(double[] values)
          Computes the mean value for the argument array.
static double[] getMean(double[] a, double[] b, double[] c)
           
static double getMean(double[] values, int offset, int number)
          Computes the mean value for some elements of the argument array.
static double getMean(float[] a)
          Compute the average.
static double getMean(int[] a)
           
static double[] getMean(int[] a, int[] b, int[] c)
           
static double getMean(int[] values, int offset, int number)
           
static double getMean(short[] a)
          Compute the average.
static double getMeanPower(double[] data)
          Take the sum of the abs value of the data, then divide by the number of sample points
static double getMeanPower(int windowStartPoint, int proposedWindowSize, double[] data)
          Compute the mean power in a window.
static int getMedian(int[] a)
           
static int getMiddle(int[] a)
           
static double getMin(double[] a)
           
static float getMin(float[] a)
           
static short getMin(short[] a)
           
static int getMinLocation(double[] psd)
           
static double[] getNormalized(double[] in)
           
static void getNormalizedMinus1ToPlus1(double[] d)
          Normalized data from -1 to +1
static java.util.Vector getOverlappedWindows(double[] data, int ws)
          return a vector of arrays, each array is only 256 elements long, each array overlaps by 50% with each other array.
static double getPower(double[] d)
           
static double[] getRampData(int n)
          Generate an array of doubles that is n elements long and has numbers that range from 0 to n-1.
static float[] getRampDataFloat(int n)
           
static double[] getRandomDoubleData(int n)
           
static float[] getRandomFloatData(int n)
           
static double getSnrdB(double[] signal, double[] reconstructedSignal)
           
static double getSnrdB(float[] signal, float[] reconstructedSignal)
           
static double getStandardDeviation(double[] values)
          Computes the standard deviation for the argument array of values.
static double getStandardDeviation(double[] values, double mean)
          Computes the standard deviation for the argument array of values.
static double getStandardDeviation(double[] values, int offset, int number)
          Computes the standard deviation for some of the argument array's values.
static double getStandardDeviation(double[] values, int offset, int number, double mean)
          Computes the standard deviation for some of the argument array's values.
static double getStandardDeviation(int[] values)
           
static double getStandardDeviation(int[] values, int offset, int number)
           
static double getStandardDeviation(int[] values, int offset, int number, double mean)
           
static double[] getSubArray(double[] d, int startPoint, int n)
          Get a sub-array that starts at the startPoint and takesn the next n data points and returns it in a smaller array
static double getVariance(double[] values)
          Computes the variance for the argument array.
static double getVariance(double[] values, double mean)
          Computes the variance for some of the argument array's values.
static double getVariance(double[] values, int offset, int number)
          Computes the variance for some of the argument array's values.
static double getVariance(double[] values, int offset, int number, double mean)
          Computes the variance for some of the argument array's values.
static double getVariance(int[] a)
           
static double getVariance(int[] values, int offset, int number, double mean)
           
static java.util.Vector getWindows(double[] data, int ws)
           
static double[] histToProbability(int[] dayCounter)
          Takes a series of discrete events and computes the probability
static double[] interpolate(double[] c)
           
static void interpolate(java.util.Vector v)
           
static void intQuickSort(int[] a)
           
static void intQuickSort(int[] a, int lo0, int hi0)
           
static int locateMax(double[] inputData)
          Search through the given array and locate the maximum quantity.
static int locateMin(double[] inputData)
          Search through the given array and locate the minimum quantity.
static void logArray(double[] a)
           
static void lpf(double[] a)
           
static double magnitude(double[] a)
          Calculate the magnitude a vector.
static void main(java.lang.String[] args)
           
static void makeBartlett()
           
static double[] makeBartlett(int n)
           
static void makeHanning()
           
static double[] makeHanning(int n)
           
static void makeLyon()
           
static double[] makeLyon(int n)
           
static double mean(double[] a)
           
static double mean(float[] a)
           
static double mean(int[] a)
           
static void medianFilter(int[] a, double percentageAboveMedianForClip)
          Change the input array so that any value larger than twice as big at the median is replaced with the median.
static void mult(double[] sma, double v)
          Multiply every element in sma by v and replace with new result
static void mult(float[] sma, float v)
           
static double[] multiply(double[] a, double b)
           
static double[] multiply(double[] a, double[] b)
           
static void normalize(double[] a)
          Sum all the elements in an array, then divide by the total.
static void normalize(float[] a)
           
static float[] normalize(short[] a)
           
static void normalizeToMagnitudeOne(double[] a)
           
static int numberOfNonZeros(short[][] k)
           
static boolean outlierHere(int[] a)
           
static boolean outlierHere(int[] a, double sensitivity)
           
static double[] padToIntegralPowerOfTwo(double[] data)
           
static void plus(double[] a, double[] b)
          Add two vectors.
static void plus(double[] a, double[] b, double c)
          Add a vector times a scalar to a vector.
static void print(double[] a)
           
static void print(double[] v, java.lang.String title)
           
static void print(float[] a)
           
static void print(int[] a)
           
static void print(java.lang.Object[] o)
           
static void printStats(float[] a)
           
static void printStats(java.lang.String title, float[] a)
           
static void quickSort(int[] a)
           
static void quickSort(int[] a, int lo0, int hi0)
           
static float[] ramp(float start, float end, int n)
           
static int[] removeDuplicates(int[] locations)
           
static void removeTheDcComponent(float[] m)
           
static double[] resampleAdaptive(double[] d)
           
static void reverse(double[] doubles)
          Alter the input array so that it is reversed in place
static void scale(double[] a, double k)
           
static void scale(float[] a, double k)
           
static void scale(float[] a, float k)
           
static float[] scale(short[] a, float k)
           
static void scaleIntoRange(float[] im, float min, float max, int maxValueOutput)
           
static double[] shift(double[] d, int s)
           
static float[] shortToFloat(short[] a)
           
static double[] slowCorrelationNormalized(double[] x, double[] y)
           
static double[] slowCorrelationNotNormalized(double[] x, double[] y)
           
static double[] sort(double[] a)
           
static int[] sort(int[] a)
          Ascending sort of int array
static double[] sortDescending(double[] a)
           
static double[] subtract(double[] a, double b)
           
static double[] subtract(double[] a, double[] b)
           
static double sumOfSquares(double[] d)
           
static double sumOfTheSquares(double[] x)
           
static float sumV(float[] a)
           
static void swap(int[] x, int a, int b)
           
static void synthesizeRamp(float[] realPart, float[] imaginaryPart)
          Destroy the input data with a linear ramp.
static void testAdd1()
           
static void testAdd1(float[] a)
          Show how loop unwinding can improve speed for a vector sum, but only to a point.
static void testAdd2()
           
static void testAddFloat()
           
static void testCoefficientOfVariation()
           
static void testConcatenate()
           
static void testCorrelate()
           
static void testGeometricMean()
           
static void testGetMedian()
           
static void testGetOverlappedWindows()
           
static void testGetRandomFloatData()
           
static void testGetWindows()
           
static void testHanningOverlappedWindows()
           
static void testHanningOverlappedWindowsSpectrogram()
           
static void testInterpolation()
           
static void testOutlier()
           
static void testPadOutWithZeros()
           
static void testPadToIntegralPowerOfTwo()
           
static void testQuickSort()
           
static void testShift()
           
static void testtruncateToIntegralPowerOfTwo()
           
static void testVariance()
           
static void threshold(short[] a)
           
static void threshold(short[] a, short thresh)
          For each element in a below the thresh, make the element 0, otherwise make the element 255.
static double[] truncateToIntegralPowerOfTwo(double[] data)
           
static java.lang.String[] truncateToIntegralPowerOfTwo(java.lang.String[] data)
           
static double variance(float[] a)
           
static double variance(int[] a)
           
static void window(double[] inputData, double[] window)
          Replaces the inputData with amplitude modulated data that takes its multiplying factors from the window.
static void windowArray(double[] window, double[] r_d)
           
static void windowArrays(double[] window, double[] r_d, double[] i_d)
          This will apply the windows to each of the arrays.
static double y5(double y0, double y1, double u)
          This is a quintic with zero curvature and slope at the end points.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mat1

public Mat1()
Method Detail

testInterpolation

public static void testInterpolation()

testGetWindows

public static void testGetWindows()

getInterpolationMinMax

public static double[] getInterpolationMinMax(double[] d,
                                              int ws)

getInterpolation

public static double[] getInterpolation(double[] d,
                                        int ws)

concatenate

public static double[] concatenate(java.util.Vector v)

interpolate

public static void interpolate(java.util.Vector v)

interpolate

public static double[] interpolate(double[] c)

getWindows

public static java.util.Vector getWindows(double[] data,
                                          int ws)

concatenate

public static double[] concatenate(double[] a,
                                   double[] b,
                                   double[] c)

concatenate

public static double[] concatenate(double[] a,
                                   double[] b,
                                   double[] c,
                                   double[] d)

concatenate

public static double[] concatenate(double[] a,
                                   double[] b)

concatenate

public static int[] concatenate(int[] a,
                                int[] b)

testConcatenate

public static void testConcatenate()

resampleAdaptive

public static double[] resampleAdaptive(double[] d)

medianFilter

public static void medianFilter(int[] a,
                                double percentageAboveMedianForClip)
Change the input array so that any value larger than twice as big at the median is replaced with the median.

Parameters:
a -

testCorrelate

public static void testCorrelate()

add

public static void add(double[] a,
                       double[] b,
                       double c)
Add a vector times a scalar to a vector. The first vector contains the sum.

Parameters:
a - the first vector
b - the second vector
c - the scalar multiplier

add

public static void add(double[] a,
                       double[] b)
Add two vectors. The first vector contains the sum. This is not optimized for altivec

Parameters:
a - the first vector a = a + b;
b - the second vector

add

public static void add(double[] a,
                       double[] b,
                       double[] c)
Add three vectors. The first vector contains the sum. This is not optimized for altivec

Parameters:
a - the first vector a = a + b;
b - the second vector
c - the second vector

add

public static void add(float[] a,
                       float[] b)
Add two vectors. The first vector contains the sum.

Parameters:
a - the first vector a = a + b;
b - the second vector

testAddFloat

public static void testAddFloat()

testAdd2

public static void testAdd2()

dot

public static double dot(double[] a,
                         double[] b)
Calculate the dot product of two vectors.

Parameters:
a - the first vector
b - the second vector
Returns:
the dot product

dot

public static short dot(short[] a,
                        short[] b)
Calculate the dot product of two vectors.

Parameters:
a - the first vector
b - the second vector
Returns:
the dot product

dot

public static double dot(double[] a)
Calculate the dot product of a vector with itself.

Parameters:
a - the vector
Returns:
the dot product

magnitude

public static double magnitude(double[] a)
Calculate the magnitude a vector.

Parameters:
a - the vector
Returns:
the magnitude

print

public static void print(int[] a)

print

public static void print(double[] a)

printStats

public static void printStats(java.lang.String title,
                              float[] a)

printStats

public static void printStats(float[] a)

print

public static void print(float[] a)

add

public static double add(double[] a)
Sum all the numbers and return the result.

Parameters:
a - the numbers to be added
Returns:
a double computed via double operations (internally).

lpf

public static void lpf(double[] a)

backwardDerivativeMag

public static double[] backwardDerivativeMag(double[] a)

forwardDerivativeMag

public static void forwardDerivativeMag(double[] a)

ramp

public static float[] ramp(float start,
                           float end,
                           int n)

testAdd1

public static void testAdd1()

testAdd1

public static void testAdd1(float[] a)
Show how loop unwinding can improve speed for a vector sum, but only to a point.


add

public static void add(float[] a,
                       float[] b,
                       float[] c)

add8

public static void add8(float[] a,
                        float[] b,
                        float[] c)

add4

public static float add4(float[] a)

add8

public static float add8(float[] a)

add8Depend

public static double add8Depend(float[] a)

add8NoDepend

public static double add8NoDepend(float[] a)

reverse

public static void reverse(double[] doubles)
Alter the input array so that it is reversed in place

Parameters:
doubles - both the input and output

add16

public static double add16(float[] a)

add

public static double add(float[] a)

add

public static double add(short[] a)

add

public static double add(int[] a)

add

public static double add(byte[] a)

addUnsigned

public static double addUnsigned(byte[] a)

sumV

public static float sumV(float[] a)

normalize

public static void normalize(double[] a)
Sum all the elements in an array, then divide by the total. for example a[]={1,0,10}, sum is 11, now divide by the total and the array is 1/11,0,10/11 and the array sums to one.

Parameters:
a -

normalizeToMagnitudeOne

public static void normalizeToMagnitudeOne(double[] a)

normalize

public static float[] normalize(short[] a)

normalize

public static void normalize(float[] a)

getMean

public static double getMean(float[] a)
Compute the average.

Parameters:
a - array of numbers to be averaged
Returns:
the sum divided by the number of elements

getMean

public static double getMean(short[] a)
Compute the average.

Parameters:
a - array of shorts
Returns:
the sum divided by the number of elements

threshold

public static void threshold(short[] a,
                             short thresh)
For each element in a below the thresh, make the element 0, otherwise make the element 255.

Parameters:
a - an array whose values are altered.
thresh - a point that is used to floor or ceiling a

threshold

public static void threshold(short[] a)

scale

public static float[] scale(short[] a,
                            float k)

scale

public static void scale(double[] a,
                         double k)

add

public static void add(double[] a,
                       double k)

scale

public static void scale(float[] a,
                         float k)

scale

public static void scale(float[] a,
                         double k)

shortToFloat

public static float[] shortToFloat(short[] a)

copyArray

public static short[] copyArray(short[] a)

copyArray

public static double[] copyArray(double[] a)

copyArray

public static float[] copyArray(float[] a)

variance

public static double variance(int[] a)

variance

public static double variance(float[] a)

mean

public static double mean(int[] a)

mean

public static double mean(double[] a)

mean

public static double mean(float[] a)

coefficientOfVariation

public static double coefficientOfVariation(int[] a)
Standard deviation divided by the mean is the coefficientOfVariation

Parameters:
a - list of numbers
Returns:
will be subjected to a detection algorithm of unknown complexity.

coefficientOfVariation

public static double coefficientOfVariation(float[] a)

testVariance

public static void testVariance()

testCoefficientOfVariation

public static void testCoefficientOfVariation()

outlierHere

public static boolean outlierHere(int[] a)

outlierHere

public static boolean outlierHere(int[] a,
                                  double sensitivity)

testOutlier

public static void testOutlier()

quickSort

public static void quickSort(int[] a,
                             int lo0,
                             int hi0)

swap

public static void swap(int[] x,
                        int a,
                        int b)

quickSort

public static void quickSort(int[] a)

getMean

public static double[] getMean(double[] a,
                               double[] b,
                               double[] c)

getMean

public static double[] getMean(int[] a,
                               int[] b,
                               int[] c)

getMin

public static double getMin(double[] a)

getMin

public static float getMin(float[] a)

getMin

public static short getMin(short[] a)

getMax

public static int getMax(int[] a)

getMax

public static short getMax(short[] a)

getMax

public static double getMax(double[] a)

getMax

public static float getMax(float[] a)

testQuickSort

public static void testQuickSort()

numberOfNonZeros

public static int numberOfNonZeros(short[][] k)

arrayCopy

public static float[] arrayCopy(float[] in)

arrayCopy

public static double[] arrayCopy(double[] in)

getRampData

public static double[] getRampData(int n)
Generate an array of doubles that is n elements long and has numbers that range from 0 to n-1.

For example:
double x1[] = getRampData(N);>

Parameters:
n - a positive integer
Returns:
the ramp data.

getRampDataFloat

public static float[] getRampDataFloat(int n)

testGetRandomFloatData

public static void testGetRandomFloatData()

getRandomFloatData

public static float[] getRandomFloatData(int n)

getRandomDoubleData

public static double[] getRandomDoubleData(int n)

getBiasedRampDataFloat

public static float[] getBiasedRampDataFloat(int n)

getMaxValue

public static double getMaxValue(double[] in)

print

public static void print(double[] v,
                         java.lang.String title)

window

public static void window(double[] inputData,
                          double[] window)
Replaces the inputData with amplitude modulated data that takes its multiplying factors from the window. Overwrites the inputData.

Parameters:
inputData - the data to be windows
window - the window

getSubArray

public static double[] getSubArray(double[] d,
                                   int startPoint,
                                   int n)
Get a sub-array that starts at the startPoint and takesn the next n data points and returns it in a smaller array

Parameters:
d - input data
startPoint -
n -
Returns:
a generally smaller array

print

public static void print(java.lang.Object[] o)

synthesizeRamp

public static void synthesizeRamp(float[] realPart,
                                  float[] imaginaryPart)
Destroy the input data with a linear ramp.

Parameters:
realPart - input datas real component
imaginaryPart - input datas' imaginary component.

getMean

public static double getMean(double[] values)
Computes the mean value for the argument array. Adds all values and divides them by the number of array elements.

Parameters:
values - double array on which the mean is to be determined
Returns:
computed mean value
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least one element

getMean

public static double getMean(double[] values,
                             int offset,
                             int number)
Computes the mean value for some elements of the argument array. Adds all values and divides them by the number of array elements.

Parameters:
values - array from which elements are read
offset - index of the first element to be used
number - number of elements to be used
Returns:
computed mean value
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least one element

getMean

public static double getMean(int[] values,
                             int offset,
                             int number)

getStandardDeviation

public static double getStandardDeviation(double[] values)
Computes the standard deviation for the argument array of values.

Parameters:
values - array from which elements are read
Returns:
computed standard deviation
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least two elements

getStandardDeviation

public static double getStandardDeviation(int[] values)

getStandardDeviation

public static double getStandardDeviation(double[] values,
                                          double mean)
Computes the standard deviation for the argument array of values. Reuses the mean value for that argument which must have been computed before.

Parameters:
values - array from which elements are read
mean - the mean value for the array, possibly computed with a call to getMean(double[]).
Returns:
computed standard deviation
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least two elements

getStandardDeviation

public static double getStandardDeviation(double[] values,
                                          int offset,
                                          int number)
Computes the standard deviation for some of the argument array's values. If you already have computed a mean value using getMean(double[],int,int), better call getStandardDeviation(double[],int,int,double). Otherwise, this method has to compute mean again.

Parameters:
values - array from which elements are read
offset - first element to be used
number - number of elements used starting affineTransform values[offset]
Returns:
computed standard deviation
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least two elements

getStandardDeviation

public static double getStandardDeviation(int[] values,
                                          int offset,
                                          int number)

getStandardDeviation

public static double getStandardDeviation(double[] values,
                                          int offset,
                                          int number,
                                          double mean)
Computes the standard deviation for some of the argument array's values. Use this version of the method if you already have a mean value, otherwise this method must be computed again.

Parameters:
values - array from which elements are read
offset - first element to be used
number - number of elements used starting affineTransform values[offset]
mean - value of the elements
Returns:
computed standard deviation
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least two elements

getStandardDeviation

public static double getStandardDeviation(int[] values,
                                          int offset,
                                          int number,
                                          double mean)

getVariance

public static double getVariance(double[] values)
Computes the variance for the argument array.

Parameters:
values - array from which elements are read
Returns:
variance for the array elements
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least two elements

getVariance

public static double getVariance(double[] values,
                                 double mean)
Computes the variance for some of the argument array's values.

Parameters:
values - array from which elements are read
mean - the mean for the array elements
Returns:
variance for the array elements
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least two elements

getVariance

public static double getVariance(double[] values,
                                 int offset,
                                 int number)
Computes the variance for some of the argument array's values. If you already have computed a mean value using getMean(double[],int,int), better call getVariance(double[],int,int,double). Otherwise, this method has to compute mean again.

Parameters:
values - array from which elements are read
offset - first element to be used
number - number of elements used starting affineTransform values[offset]
Returns:
computed variance
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least two elements

getVariance

public static double getVariance(double[] values,
                                 int offset,
                                 int number,
                                 double mean)
Computes the variance for some of the argument array's values. Use this version of the method in case mean has already been computed.

Parameters:
values - array from which elements are read
offset - first element to be used
number - number of elements used starting affineTransform values[offset]
mean - the mean for the array elements
Returns:
computed variance
Throws:
java.lang.IllegalArgumentException - if the array has not affineTransform least two elements

getVariance

public static double getVariance(int[] values,
                                 int offset,
                                 int number,
                                 double mean)

removeTheDcComponent

public static void removeTheDcComponent(float[] m)

scaleIntoRange

public static void scaleIntoRange(float[] im,
                                  float min,
                                  float max,
                                  int maxValueOutput)

getMean

public static double getMean(int[] a)

testGeometricMean

public static void testGeometricMean()

getGeometricMean

public static double getGeometricMean(short[] a)

getGeometricMean

public static double getGeometricMean(double[] a)

getVariance

public static double getVariance(int[] a)

intQuickSort

public static void intQuickSort(int[] a)

testGetMedian

public static void testGetMedian()

getMedian

public static int getMedian(int[] a)

getMiddle

public static int getMiddle(int[] a)

testPadOutWithZeros

public static void testPadOutWithZeros()

makeHanning

public static double[] makeHanning(int n)

makeLyon

public static double[] makeLyon(int n)

logArray

public static void logArray(double[] a)

testHanningOverlappedWindowsSpectrogram

public static void testHanningOverlappedWindowsSpectrogram()

testHanningOverlappedWindows

public static void testHanningOverlappedWindows()

testGetOverlappedWindows

public static void testGetOverlappedWindows()

makeBartlett

public static void makeBartlett()

makeHanning

public static void makeHanning()

getOverlappedWindows

public static java.util.Vector getOverlappedWindows(double[] data,
                                                    int ws)
return a vector of arrays, each array is only 256 elements long, each array overlaps by 50% with each other array. This is done before windowing is performed

Parameters:
data -
Returns:
The Vector of double arrays of data

windowArray

public static void windowArray(double[] window,
                               double[] r_d)

y5

public static double y5(double y0,
                        double y1,
                        double u)
This is a quintic with zero curvature and slope at the end points.

Parameters:
y0 - start value
y1 - end value
u - dilation parameter that ranges from 0 to 1.
Returns:
Fifth order polynomial suitable for smooth travel

See Parallel Parking with Nonholonomic constraints.


windowArrays

public static void windowArrays(double[] window,
                                double[] r_d,
                                double[] i_d)
This will apply the windows to each of the arrays. The length of all the arrays must be the same.

Parameters:
window -
r_d -
i_d -

makeLyon

public static void makeLyon()

makeBartlett

public static double[] makeBartlett(int n)

getMinLocation

public static int getMinLocation(double[] psd)

getLocation

public static int getLocation(double[] a,
                              double value)
Parameters:
a -
value -
Returns:
return the location of value in the array of a, by search from location 0. If value is not found, return location -1;

getMaxLocation

public static int getMaxLocation(int offsetFromEdge,
                                 double[] psd)

getMaxLocation

public static int getMaxLocation(double[] psd)

getMeanPower

public static double getMeanPower(double[] data)
Take the sum of the abs value of the data, then divide by the number of sample points

Parameters:
data -
Returns:
average (or mean) power.

getMeanPower

public static double getMeanPower(int windowStartPoint,
                                  int proposedWindowSize,
                                  double[] data)
Compute the mean power in a window.

Parameters:
windowStartPoint -
proposedWindowSize -
data -
Returns:
average power

arrayCopy

public static double[] arrayCopy(double[] source,
                                 int sourceStartPoint,
                                 int length)

centering

public static void centering(double[] r)

sort

public static int[] sort(int[] a)
Ascending sort of int array

Parameters:
a -
Returns:
new instance of a sorted array

sort

public static double[] sort(double[] a)

sortDescending

public static double[] sortDescending(double[] a)

getHalfArray

public static double[] getHalfArray(double[] a)
Get 1/2 of the array

Parameters:
a -
Returns:
the first half of the array.

equals

public static boolean equals(float[] a1,
                             float[] a2)

equals

public static boolean equals(double[] a1,
                             double[] a2)

equals

public static boolean equals(short[] a1,
                             short[] a2)

equals

public static boolean equals(long[] a1,
                             long[] a2)

equals

public static boolean equals(byte[] a1,
                             byte[] a2)

equals

public static boolean equals(boolean[] a1,
                             boolean[] a2)

equals

public static boolean equals(char[] a1,
                             char[] a2)

equals

public static boolean equals(int[] a1,
                             int[] a2)

clamp

public static int[] clamp(int[] ia)

mult

public static void mult(double[] sma,
                        double v)
Multiply every element in sma by v and replace with new result

Parameters:
sma -
v -

mult

public static void mult(float[] sma,
                        float v)

getIntArray

public static int[] getIntArray(double[] d)
input an array of double and return an array of int, via truncation

Returns:

getDoubleArray

public static double[] getDoubleArray(int[] ints)

subtract

public static double[] subtract(double[] a,
                                double[] b)

subtract

public static double[] subtract(double[] a,
                                double b)

divide

public static double[] divide(double[] a,
                              double[] b)

divide

public static double[] divide(double[] a,
                              double b)
Divide creates a new array. It divides a by b and returns c

Parameters:
a - an input array that is not changed.
b - a scalar that is not changed.
Returns:
c a new array of double

divideEquals

public static void divideEquals(double[] a,
                                double b)
Replace the a array with a = a / b

Parameters:
a - the arg is changed
b - a scalar for division, not zero

multiply

public static double[] multiply(double[] a,
                                double[] b)

multiply

public static double[] multiply(double[] a,
                                double b)

accumulate

public static double[] accumulate(double[] a)

getNormalized

public static double[] getNormalized(double[] in)

locateMin

public static int locateMin(double[] inputData)
Search through the given array and locate the minimum quantity.

Parameters:
inputData -
Returns:
the position of the minimum quantity.

locateMax

public static int locateMax(double[] inputData)
Search through the given array and locate the maximum quantity.

Parameters:
inputData -
Returns:
the position of the maximum quantity.

histToProbability

public static double[] histToProbability(int[] dayCounter)
Takes a series of discrete events and computes the probability

Parameters:
dayCounter -
Returns:

sumOfTheSquares

public static double sumOfTheSquares(double[] x)

plus

public static void plus(double[] a,
                        double[] b,
                        double c)
Add a vector times a scalar to a vector. The first vector contains the sum.

Parameters:
a - the first vector
b - the second vector
c - the scalar multiplier

plus

public static void plus(double[] a,
                        double[] b)
Add two vectors. The first vector contains the sum.

Parameters:
a - the first vector
b - the second vector

cross2D

public static double cross2D(double[] a,
                             double[] b)
Calculate the cross product of two vectors that lie within a plane. The result is the component perpendicular to the plane.

Parameters:
a - the first vector
b - the second vector
Returns:
the cross product.

cross2D

public static double[] cross2D(double[] a,
                               double b)
Calculate the cross product of a vector within a plane and a vector perpendicular to a plane. The operation transforms the vector in the plane into the new vector.

Parameters:
a - the vector in the plane
b - the vector perpendicular to the plane

intQuickSort

public static void intQuickSort(int[] a,
                                int lo0,
                                int hi0)

getFloat

public static float[] getFloat(double[] d)

getDouble

public static double[] getDouble(float[] d)

testPadToIntegralPowerOfTwo

public static void testPadToIntegralPowerOfTwo()

padToIntegralPowerOfTwo

public static double[] padToIntegralPowerOfTwo(double[] data)

truncateToIntegralPowerOfTwo

public static double[] truncateToIntegralPowerOfTwo(double[] data)

truncateToIntegralPowerOfTwo

public static java.lang.String[] truncateToIntegralPowerOfTwo(java.lang.String[] data)

testtruncateToIntegralPowerOfTwo

public static void testtruncateToIntegralPowerOfTwo()

removeDuplicates

public static int[] removeDuplicates(int[] locations)

getPower

public static double getPower(double[] d)

shift

public static double[] shift(double[] d,
                             int s)
Parameters:
d - array to be shifted
s - amount of shift, with zero padding
Returns:
new array of size d.length

fastCorrelation

public static double[] fastCorrelation(double[] x,
                                       double[] y,
                                       boolean nomalize)

sumOfSquares

public static double sumOfSquares(double[] d)

slowCorrelationNormalized

public static double[] slowCorrelationNormalized(double[] x,
                                                 double[] y)

slowCorrelationNotNormalized

public static double[] slowCorrelationNotNormalized(double[] x,
                                                    double[] y)

getMat1

public static int[] getMat1(long i)
Parameters:
i - convert i into an array of int values 0, 1
Returns:
msb in the lowest array element.

getMat1

public static int[] getMat1(int i)
Parameters:
i - convert i into an array of int values 0, 1
Returns:
msb in the lowest array element.

getSnrdB

public static double getSnrdB(double[] signal,
                              double[] reconstructedSignal)

getSnrdB

public static double getSnrdB(float[] signal,
                              float[] reconstructedSignal)

testShift

public static void testShift()

getNormalizedMinus1ToPlus1

public static void getNormalizedMinus1ToPlus1(double[] d)
Normalized data from -1 to +1

Parameters:
d - is altered as a side-effect.

main

public static void main(java.lang.String[] args)
                 throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException