com.meapsoft
Class DSP

java.lang.Object
  extended bycom.meapsoft.DSP

public class DSP
extends java.lang.Object


Constructor Summary
DSP()
           
 
Method Summary
static double[] abs(double[] a)
          Returns the absolute value of each element of a.
static int argmax(double[] a)
          Returns the index of the max element of a.
static int argmin(double[] a)
          Returns the index of the min element of a.
static double[] conv(double[] a, double[] b)
          Convolves sequences a and b.
static double[] cos(double[] a)
          Cosine of each element of a.
static double[] cumsum(double[] a)
          Returns A such that A[x] = sum(a[0:x])
static double dot(double[] a, double[] b)
          Returns the inner product of a and b.
static double[] exp(double[] a)
          Take the natural exp of each element of a.
static double[] filter(double[] b, double[] a, double[] x)
          Filters x by the IIR filter defined by a and b.
static int[] find(byte[] a)
          Returns an array containing the indices into a that contain 1s.
static byte[] ge(double[] a, double b)
          Returns a binary array with 1s where a[idx] >= b and zeros elsewhere.
static byte[] ge(double[] a, double[] b)
          Returns a binary array with 1s where a[idx] >= b[idx] and zeros elsewhere.
static double[] getColumn(double[][] A, int n)
          Returns the n'th column of matrix A
static byte[] gt(double[] a, double b)
          Returns a binary array with 1s where a[idx] > b and zeros elsewhere.
static byte[] gt(double[] a, double[] b)
          Returns a binary array with 1s where a[idx] > b[idx] and zeros elsewhere.
static double[] hanning(int n)
          Returns an n point symmetric Hanning window.
static void imagesc(double[] a)
          Pop up a window containing an image representation of a.
static void imagesc(double[][] a)
          Pop up a window containing an image representation of a.
static void imagesc(double[][] a, java.lang.String s)
          Pop up a window containing an image representation of a.
static void imagesc(double[] a, java.lang.String s)
          Pop up a window containing an image representation of a.
static int[] irange(int start, int end)
          Returns an array of ints as follows: {start, start+1, ...
static int[] irange(int start, int end, int increment)
          Returns an array of ints as follows: {start, start+increment, ...
static byte[] le(double[] a, double b)
          Returns a binary array with 1s where a[idx] <= b and zeros elsewhere.
static byte[] le(double[] a, double[] b)
          Returns a binary array with 1s where a[idx] <= b[idx] and zeros elsewhere.
static double[] log(double[] a)
          Take the natural log of each element of a.
static double[] log10(double[] a)
          Take the log base 10 of each element of a.
static byte[] lt(double[] a, double b)
          Returns a binary array with 1s where a[idx] < b and zeros elsewhere.
static byte[] lt(double[] a, double[] b)
          Returns a binary array with 1s where a[idx] < b[idx] and zeros elsewhere.
static void main(java.lang.String[] args)
           
static double max(double[] a)
          Returns the max element of a.
static double[] max(double[][] a)
          Returns an array of the max elements of each column of a.
static double[][] max(double[][] a, double b)
          Returns a new array where each element is the maximum of a[i][j] and b.
static double[] max(double[] a, double b)
          Returns a new array where each element is the maximum of a[i] and b.
static double[] max(double[] a, double[] b)
          Returns a new array where each element is the maximum of a[i] and b[i].
static double mean(double[] a)
          Returns the mean of a.
static double[] mean(double[][] A)
          Returns the mean of each column of A.
static double median(double[] a)
          Returns the lower median value contained in a.
static double min(double[] a)
          Returns the min element of a.
static double[] min(double[][] a)
          Returns an array of the min elements of each column of a.
static double[][] min(double[][] a, double b)
          Returns a new array where each element is the minimum of a[i][j] and b.
static double[] min(double[] a, double b)
          Returns a new array where each element is the minimum of a[i] and b.
static double[] min(double[] a, double[] b)
          Returns a new array where each element is the minimum of a[i] and b[i].
static double[][] minus(double[][] A, double b)
          Subtracts b from each element of A (Y[x][y] = A[x][y]-b).
static double[] minus(double[] a, double b)
          Subtracts b from each element of a (y[x] = a[x]-b).
static double[] minus(double[] a, double[] b)
          Returns the elementwise difference of a and b.
static double[] minus(double a, double[] b)
          Subtracts each element of b from a (y[x] = a - b[x]).
static double[] plus(double[] a, double b)
          Adds b to each element of a.
static double[] plus(double[] a, double[] b)
          Returns the elementwise sum of a and b.
static double[] power(double[] a, double b)
          Raise each element of a to the b'th power.
static void printArray(double[] a)
           
static void printArray(double[] a, java.lang.String name)
           
static double[] range(int start, int end)
          Returns an array as follows: {start, start+1, ...
static double[] range(int start, int end, int increment)
          Returns an array as follows: {start, start+increment, ...
static double[] rdivide(double[] a, double b)
          Divides each element of a by b.
static double[] rdivide(double[] a, double[] b)
          Returns the elementwise quotient of a divided by b (a./b).
static double[] round(double[] a)
          Round each element of a.
static void setColumn(double[][] A, int n, double[] b)
          Set n'th column of matrix A to b
static double[] sin(double[] a)
          Sine of each element of a.
static double[] slice(double[] a, int start, int end)
          Returns the slice of array a between start and end inclusive.
static double[] subsref(double[] a, byte[] idx)
          Index into array a using the binary array idx.
static double[] subsref(double[] a, int[] idx)
          Index into array a using the indices listed in idx.
static double sum(double[] a)
          Returns the sum of the contents of a.
static double[] times(double[] a, double b)
          Multiplies each element of a by b.
static double[] times(double[] a, double[] b)
          Returns the elementwise product of a and b.
static double[] todouble(byte[] a)
           
static double[] todouble(int[] a)
           
static double[][] transpose(double[][] a)
          Returns the transpose of the matrix a.
static void wavwrite(double[] d, int sr, java.lang.String filename)
          Write the data in d to a mono wavefile.
static double[] xcorr(double[] a)
          Computes the auto correlation of a.
static double[] xcorr(double[] a, double[] b)
          Computes the cross correlation between sequences a and b.
static double[] xcorr(double[] a, double[] b, int maxlag)
          Computes the cross correlation between sequences a and b.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSP

public DSP()
Method Detail

conv

public static double[] conv(double[] a,
                            double[] b)
Convolves sequences a and b. The resulting convolution has length a.length+b.length-1.


xcorr

public static double[] xcorr(double[] a,
                             double[] b)
Computes the cross correlation between sequences a and b.


xcorr

public static double[] xcorr(double[] a)
Computes the auto correlation of a.


xcorr

public static double[] xcorr(double[] a,
                             double[] b,
                             int maxlag)
Computes the cross correlation between sequences a and b. maxlag is the maximum lag to


filter

public static double[] filter(double[] b,
                              double[] a,
                              double[] x)
Filters x by the IIR filter defined by a and b. Similar to Matlab's filter(). This is a direct implementation of the corresponding difference equation.


hanning

public static double[] hanning(int n)
Returns an n point symmetric Hanning window. Like the Matlab hanning() function (and unlike the version included in Octave), this drops the first and last zero samples. So hanning(10) in Octave is the same as hanning(8) in Matlab and DSP.hanning(8).


dot

public static double dot(double[] a,
                         double[] b)
Returns the inner product of a and b. a and b should be the same length or bad things will happen.


times

public static double[] times(double[] a,
                             double[] b)
Returns the elementwise product of a and b. a and b should be the same length or bad things will happen.


times

public static double[] times(double[] a,
                             double b)
Multiplies each element of a by b.


rdivide

public static double[] rdivide(double[] a,
                               double[] b)
Returns the elementwise quotient of a divided by b (a./b). a and b should be the same length or bad things will happen.


rdivide

public static double[] rdivide(double[] a,
                               double b)
Divides each element of a by b.


plus

public static double[] plus(double[] a,
                            double[] b)
Returns the elementwise sum of a and b. a and b should be the same length or bad things will happen.


plus

public static double[] plus(double[] a,
                            double b)
Adds b to each element of a.


minus

public static double[] minus(double[] a,
                             double[] b)
Returns the elementwise difference of a and b. a and b should be the same length or bad things will happen.


minus

public static double[] minus(double[] a,
                             double b)
Subtracts b from each element of a (y[x] = a[x]-b).


minus

public static double[][] minus(double[][] A,
                               double b)
Subtracts b from each element of A (Y[x][y] = A[x][y]-b).


minus

public static double[] minus(double a,
                             double[] b)
Subtracts each element of b from a (y[x] = a - b[x]).


sum

public static double sum(double[] a)
Returns the sum of the contents of a.


cumsum

public static double[] cumsum(double[] a)
Returns A such that A[x] = sum(a[0:x])


max

public static double max(double[] a)
Returns the max element of a.


max

public static double[] max(double[] a,
                           double[] b)
Returns a new array where each element is the maximum of a[i] and b[i]. a and b should be the same length.


max

public static double[] max(double[] a,
                           double b)
Returns a new array where each element is the maximum of a[i] and b.


max

public static double[][] max(double[][] a,
                             double b)
Returns a new array where each element is the maximum of a[i][j] and b.


max

public static double[] max(double[][] a)
Returns an array of the max elements of each column of a.


min

public static double min(double[] a)
Returns the min element of a.


min

public static double[] min(double[] a,
                           double[] b)
Returns a new array where each element is the minimum of a[i] and b[i]. a and b should be the same length.


min

public static double[] min(double[] a,
                           double b)
Returns a new array where each element is the minimum of a[i] and b.


min

public static double[][] min(double[][] a,
                             double b)
Returns a new array where each element is the minimum of a[i][j] and b.


min

public static double[] min(double[][] a)
Returns an array of the min elements of each column of a.


argmax

public static int argmax(double[] a)
Returns the index of the max element of a.


argmin

public static int argmin(double[] a)
Returns the index of the min element of a.


slice

public static double[] slice(double[] a,
                             int start,
                             int end)
Returns the slice of array a between start and end inclusive.


range

public static double[] range(int start,
                             int end)
Returns an array as follows: {start, start+1, ... , end-1, end}


range

public static double[] range(int start,
                             int end,
                             int increment)
Returns an array as follows: {start, start+increment, ... , end-increment, end}


irange

public static int[] irange(int start,
                           int end,
                           int increment)
Returns an array of ints as follows: {start, start+increment, ... , end-increment, end}


irange

public static int[] irange(int start,
                           int end)
Returns an array of ints as follows: {start, start+1, ... , end-1, end}


subsref

public static double[] subsref(double[] a,
                               int[] idx)
Index into array a using the indices listed in idx.


subsref

public static double[] subsref(double[] a,
                               byte[] idx)
Index into array a using the binary array idx.


find

public static int[] find(byte[] a)
Returns an array containing the indices into a that contain 1s.


lt

public static byte[] lt(double[] a,
                        double[] b)
Returns a binary array with 1s where a[idx] < b[idx] and zeros elsewhere. a and b should be the same length.


lt

public static byte[] lt(double[] a,
                        double b)
Returns a binary array with 1s where a[idx] < b and zeros elsewhere. a and b should be the same length.


le

public static byte[] le(double[] a,
                        double[] b)
Returns a binary array with 1s where a[idx] <= b[idx] and zeros elsewhere. a and b should be the same length.


le

public static byte[] le(double[] a,
                        double b)
Returns a binary array with 1s where a[idx] <= b and zeros elsewhere. a and b should be the same length.


gt

public static byte[] gt(double[] a,
                        double[] b)
Returns a binary array with 1s where a[idx] > b[idx] and zeros elsewhere. a and b should be the same length.


gt

public static byte[] gt(double[] a,
                        double b)
Returns a binary array with 1s where a[idx] > b and zeros elsewhere. a and b should be the same length.


ge

public static byte[] ge(double[] a,
                        double[] b)
Returns a binary array with 1s where a[idx] >= b[idx] and zeros elsewhere. a and b should be the same length.


ge

public static byte[] ge(double[] a,
                        double b)
Returns a binary array with 1s where a[idx] >= b and zeros elsewhere. a and b should be the same length.


median

public static double median(double[] a)
Returns the lower median value contained in a.


mean

public static double mean(double[] a)
Returns the mean of a.


mean

public static double[] mean(double[][] A)
Returns the mean of each column of A.


transpose

public static double[][] transpose(double[][] a)
Returns the transpose of the matrix a.


round

public static double[] round(double[] a)
Round each element of a.


abs

public static double[] abs(double[] a)
Returns the absolute value of each element of a.


cos

public static double[] cos(double[] a)
Cosine of each element of a.


sin

public static double[] sin(double[] a)
Sine of each element of a.


power

public static double[] power(double[] a,
                             double b)
Raise each element of a to the b'th power. Like MATLAB's .^ operator.


log

public static double[] log(double[] a)
Take the natural log of each element of a.


log10

public static double[] log10(double[] a)
Take the log base 10 of each element of a.


exp

public static double[] exp(double[] a)
Take the natural exp of each element of a.


todouble

public static double[] todouble(byte[] a)

todouble

public static double[] todouble(int[] a)

setColumn

public static void setColumn(double[][] A,
                             int n,
                             double[] b)
Set n'th column of matrix A to b


getColumn

public static double[] getColumn(double[][] A,
                                 int n)
Returns the n'th column of matrix A


imagesc

public static void imagesc(double[][] a)
Pop up a window containing an image representation of a.


imagesc

public static void imagesc(double[][] a,
                           java.lang.String s)
Pop up a window containing an image representation of a.


imagesc

public static void imagesc(double[] a)
Pop up a window containing an image representation of a.


imagesc

public static void imagesc(double[] a,
                           java.lang.String s)
Pop up a window containing an image representation of a.


wavwrite

public static void wavwrite(double[] d,
                            int sr,
                            java.lang.String filename)
Write the data in d to a mono wavefile.


printArray

public static void printArray(double[] a)

printArray

public static void printArray(double[] a,
                              java.lang.String name)

main

public static void main(java.lang.String[] args)