public class DigitalFunctionUtility
extends java.lang.Object
Utility class for performing common operations on and for digital functions.
Within this package digital functions are taken to be objects of type
double[]
). Because sub-typing from double[]
is illegal in Java, it is necessary to create a utility class to handle
the common operations on digital functions.
Constructor and Description |
---|
DigitalFunctionUtility() |
Modifier and Type | Method and Description |
---|---|
static double[] |
abs(double[] arrFunc)
Compute and return the (functional) absolute value of the given
function.
|
static double[] |
add(double[] arrFunc1,
double[] arrFunc2)
Compute and return the function sum of the given functions.
|
static int |
argGreaterThan(double dblVal,
double[] arrFunc)
Return the index where the function first exceeds the
given value.
|
static int |
argMaximum(double[] arrFunc)
Return the index at with the function maximum occurs.
|
static int |
argMinimum(double[] arrFunc)
Return the index at with the function minimum occurs.
|
static java.lang.String |
buildValueTable(double[]... argFuncs)
Build a table of function values for comparison.
|
static double |
compError(double[] arrFunc,
double[] arrTarg)
Computes and returns the l2 distance between the
given vector functions normalized by the norm ||arrTarg||2.
|
static double[] |
generateCosine(int szArray,
int intFreq,
double dblPhase)
Generate a discrete cosine function of the given size,
given discrete frequency, and given phase offset.
|
static double[] |
generateSine(int szArray,
int intFreq,
double dblPhase)
Generate a discrete sine function of the given size,
given discrete frequency, and given phase offset.
|
static double |
integral(double[] arrFunc)
Compute and return the integral (i.e., the summation of all
the elements) of the given function.
|
static double |
maximumValue(double[] arrFunc)
Return the maximum value of the function.
|
static double |
minimumValue(double[] arrFunc)
Return the minimum value of the function.
|
static void |
scaleFunction(double dblVal,
double[] arrFunc)
Scale the function by the given value.
|
static double[] |
square(double[] arrFunc)
Compute and return the (functional) square of the given function.
|
static double[] |
subtract(double[] arrFunc1,
double[] arrFunc2)
Compute and return the function difference of the given functions.
|
static void |
subtractFrom(double[] arrFunc,
double dblVal)
In place subtraction of the given value from the function.
|
static double[] |
totalVariation(double[] arrFunc)
Compute and return the total variation of the given
function.
|
public static double compError(double[] arrFunc, double[] arrTarg)
arrFunc
- vector functionarrTarg
- target vector functionpublic static java.lang.String buildValueTable(double[]... argFuncs) throws java.lang.ArrayIndexOutOfBoundsException
argFuncs
- discrete functions to be tabulatedjava.lang.ArrayIndexOutOfBoundsException
- arguments are not all the same sizepublic static double[] generateSine(int szArray, int intFreq, double dblPhase)
dblPhase
- phase offset (in radians)szArray
- array size of the returned functionintFreq
- frequency component of the returned functionpublic static double[] generateCosine(int szArray, int intFreq, double dblPhase)
dblPhase
- phase offset (in radians)szArray
- array size of the returned functionintFreq
- frequency component of the returned functionpublic static void scaleFunction(double dblVal, double[] arrFunc)
dblVal
- scale factorpublic static double[] add(double[] arrFunc1, double[] arrFunc2) throws java.lang.IllegalArgumentException
arrFunc1
- addendarrFunc2
- adderjava.lang.IllegalArgumentException
- arguments are of different sizespublic static double[] subtract(double[] arrFunc1, double[] arrFunc2) throws java.lang.IllegalArgumentException
arrFunc1
- subtractendarrFunc2
- subtractorjava.lang.IllegalArgumentException
- argument are of different sizespublic static void subtractFrom(double[] arrFunc, double dblVal)
arrFunc
- subtractenddblVal
- subtractorjava.lang.IllegalArgumentException
- argument are of different sizespublic static double maximumValue(double[] arrFunc)
arrFunc
- digital functionpublic static double minimumValue(double[] arrFunc)
arrFunc
- digital functionpublic static int argMaximum(double[] arrFunc)
arrFunc
- digital functionpublic static int argMinimum(double[] arrFunc)
arrFunc
- digital functionpublic static int argGreaterThan(double dblVal, double[] arrFunc)
dblVal
- inspection valuearrFunc
- digital functionarrFunc.length
if nonepublic static double[] abs(double[] arrFunc)
arrFunc
- function to processpublic static double[] square(double[] arrFunc)
arrFunc
- function to squarepublic static double[] totalVariation(double[] arrFunc)
arrFunc
- target functionpublic static double integral(double[] arrFunc)
arrFunc
- function to integrate