asu.seismo.signals.oned
Class doubleSignal1d

java.lang.Object
  extended by asu.seismo.signals.oned.doubleSignal1d
Direct Known Subclasses:
doubleSignal1dpadp2, psf1d

public class doubleSignal1d
extends java.lang.Object

Basic implementation of a real valued signal


Field Summary
protected  double[] data
           
protected  int length
           
 
Constructor Summary
doubleSignal1d()
           
doubleSignal1d(double[] d)
          Construct signal from array d with length l
doubleSignal1d(double[] d, arraySelector1d s)
          Take only a part of the given array
doubleSignal1d(double[] d, int l)
          Construct signal from array d with length l
doubleSignal1d(doubleSignal1d sig)
          Construct signal from other signal sig
doubleSignal1d(int l)
          Construct signal with length l
 
Method Summary
 void add(double c)
          Add a constant point wise
 void add(double factor, doubleSignal1d sig)
          Add a weighted signal to this signal (this=this+factor*sig)
 void add(doubleSignal1d sig)
          Add a signal to this signal (this=this+sig)
protected  void allocateMemory(int l)
          Allocate the memory for the signal
 void assign(arraySelector1d s, double c)
          Replace part of the signal by the value of c
 void assign(arraySelector1d st, doubleSignal1d sig)
          Replace part of this signal by sig
 void assign(arraySelector1d st, doubleSignal1d sig, arraySelector1d s)
          Replace part of this signal by a part of the signal sig
 void assign(double c)
          Replace this signal by the constant signal with value c
 void assign(doubleSignal1d sig)
          Assign another signal to this one
 void assign(doubleSignal1d sig, arraySelector1d s)
          Replace this signal by a part of the signal sig
 void changePhys()
          Has to be called if the data was changed this becomes impotent in the derived classed that have other then the physical data in it eg fft data
 void clear()
          clear signal ie fill signal with zeros
 void cutNeg()
          Cut off negative values
static doubleSignal1d diff(doubleSignal1d s1, doubleSignal1d s2)
          Subtract one signal form another one and return a new signal (return=s2-s1)
 void diffHere(doubleSignal1d s1, doubleSignal1d s2)
          Subtract s2 from s1 and assign it to this signal
static double dp(doubleSignal1d s1, doubleSignal1d s2)
          The dot product (s1'*s2 in matlab notation) is computed
 double getAbsMax()
          Return maximum value of the absolute values of the signal
 java.lang.String getAsString()
          Get Signal as single string
 double[] getDataArray()
          Get data Array
 int getLength()
          Get length of signal
 double getMaxValue()
          Return max value of signal
 double getMinValue()
          Return max value of signal
static doubleSignal1d loadASCII(java.lang.String filename)
          return a new signal loaded as column vector from the ASCII file filename.
 void mult(double c)
          Multiply point wise with a constant c
 void mult(doubleSignal1d sig)
          Multiply point wise another signal
 double norm2()
          Return 2-norm of signal
 void normalize2()
          Normalize signal wrt the 2-norm
 void normalizeMax()
          Normalize signal wrt the max value
 void normalizeS()
          Normalize signal wrt the sum of all elements
 double normTK2()
          Returns the Tikhonov semi-norm without the gradient
 double normTK2(doubleSignal1d grad)
          Returns the Tikhonov Norm (H^2 norm) squared and the gradient of the function f: x-> ||x||_{TK}^2 at the point x="this signal"
 double normTV(double beta)
          Compute TV semi-norm (total variation norm of this signal the TV norm is defines as the integral over the derivative of the signal in case of a discrete signal like this, the integral becomes a sum and the derivative is approximated by a forward difference of order 1.
 double normTV(doubleSignal1d grad, double beta)
          Computes the TV semi-norm of the signal and returns the gradient of the function f: x-> ||x||_TV at the point x="this signal"
static doubleSignal1d ones(int l)
          Return a new signal with l ones in it
 void printAsColumn()
          Print signal as column vector
 void printAsLine()
          Print signal in one line
static doubleSignal1d rand(int l)
          Return a new signal with random values (0,1) uniformly distributed
 void removeDC()
          Remove DC offset
static doubleSignal1d reverse(doubleSignal1d sig)
          New signal in reverse order
 void reverseThis()
          Reverse the order of the data in this signal
 void saveASCII(java.lang.String filename)
          save signal as column vector in the ASCII file filename
 void setLength(int l)
          Set the lengt of the signal
 doubleSignal1d subSignal(arraySelector1d s)
          Return a sub signal determined by s
 double sum()
          Sum over all elements
static doubleSignal1d sum(doubleSignal1d s1, doubleSignal1d s2)
          Compute the sum of two signals and return a new signal
 void validatePhys()
          This validates the data of the signal a invalid_data_exception will be thrown by almost all functions if the data is invalid.
 double[] vec()
          return new array with the signal values
 void zeros()
          Replace this signal by the zero signal
 void zeros(arraySelector1d s)
          Replace a part of this signal by zeros
static doubleSignal1d zeros(int l)
          Return a new signal with l zeros in it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected double[] data

length

protected int length
Constructor Detail

doubleSignal1d

public doubleSignal1d()

doubleSignal1d

public doubleSignal1d(int l)
Construct signal with length l


doubleSignal1d

public doubleSignal1d(double[] d)
Construct signal from array d with length l


doubleSignal1d

public doubleSignal1d(double[] d,
                      int l)
Construct signal from array d with length l


doubleSignal1d

public doubleSignal1d(doubleSignal1d sig)
               throws invalid_data_exception
Construct signal from other signal sig

Throws:
invalid_data_exception

doubleSignal1d

public doubleSignal1d(double[] d,
                      arraySelector1d s)
Take only a part of the given array

Method Detail

vec

public double[] vec()
             throws invalid_data_exception
return new array with the signal values

Throws:
invalid_data_exception

getDataArray

public double[] getDataArray()
                      throws invalid_data_exception
Get data Array

Throws:
invalid_data_exception

getLength

public int getLength()
Get length of signal


setLength

public void setLength(int l)
Set the lengt of the signal


reverse

public static doubleSignal1d reverse(doubleSignal1d sig)
                              throws invalid_data_exception
New signal in reverse order

Throws:
invalid_data_exception

reverseThis

public void reverseThis()
Reverse the order of the data in this signal


printAsLine

public void printAsLine()
                 throws invalid_data_exception
Print signal in one line

Throws:
invalid_data_exception

printAsColumn

public void printAsColumn()
                   throws invalid_data_exception
Print signal as column vector

Throws:
invalid_data_exception

saveASCII

public void saveASCII(java.lang.String filename)
               throws invalid_data_exception,
                      java.io.IOException
save signal as column vector in the ASCII file filename

Throws:
invalid_data_exception
java.io.IOException

loadASCII

public static doubleSignal1d loadASCII(java.lang.String filename)
                                throws invalid_data_exception,
                                       java.io.IOException
return a new signal loaded as column vector from the ASCII file filename.

Throws:
invalid_data_exception
java.io.IOException

getMaxValue

public double getMaxValue()
                   throws invalid_data_exception
Return max value of signal

Throws:
invalid_data_exception

getMinValue

public double getMinValue()
                   throws invalid_data_exception
Return max value of signal

Throws:
invalid_data_exception

getAbsMax

public double getAbsMax()
                 throws invalid_data_exception
Return maximum value of the absolute values of the signal

Throws:
invalid_data_exception

getAsString

public java.lang.String getAsString()
                             throws invalid_data_exception
Get Signal as single string

Throws:
invalid_data_exception

mult

public void mult(double c)
          throws invalid_data_exception
Multiply point wise with a constant c

Throws:
invalid_data_exception

mult

public void mult(doubleSignal1d sig)
          throws invalid_data_exception,
                 size_mismatch_exception
Multiply point wise another signal

Throws:
invalid_data_exception
size_mismatch_exception

add

public void add(double c)
         throws invalid_data_exception
Add a constant point wise

Throws:
invalid_data_exception

add

public void add(double factor,
                doubleSignal1d sig)
         throws invalid_data_exception,
                size_mismatch_exception
Add a weighted signal to this signal (this=this+factor*sig)

Throws:
invalid_data_exception
size_mismatch_exception

add

public void add(doubleSignal1d sig)
         throws invalid_data_exception,
                size_mismatch_exception
Add a signal to this signal (this=this+sig)

Throws:
invalid_data_exception
size_mismatch_exception

sum

public double sum()
           throws invalid_data_exception
Sum over all elements

Throws:
invalid_data_exception

normalize2

public void normalize2()
                throws invalid_data_exception
Normalize signal wrt the 2-norm

Throws:
invalid_data_exception

normalizeS

public void normalizeS()
                throws invalid_data_exception
Normalize signal wrt the sum of all elements

Throws:
invalid_data_exception

normalizeMax

public void normalizeMax()
                  throws invalid_data_exception
Normalize signal wrt the max value

Throws:
invalid_data_exception

diff

public static doubleSignal1d diff(doubleSignal1d s1,
                                  doubleSignal1d s2)
                           throws invalid_data_exception,
                                  size_mismatch_exception
Subtract one signal form another one and return a new signal (return=s2-s1)

Throws:
invalid_data_exception
size_mismatch_exception

diffHere

public void diffHere(doubleSignal1d s1,
                     doubleSignal1d s2)
              throws invalid_data_exception,
                     size_mismatch_exception
Subtract s2 from s1 and assign it to this signal

Throws:
invalid_data_exception
size_mismatch_exception

dp

public static double dp(doubleSignal1d s1,
                        doubleSignal1d s2)
                 throws invalid_data_exception,
                        size_mismatch_exception
The dot product (s1'*s2 in matlab notation) is computed

Throws:
invalid_data_exception
size_mismatch_exception

sum

public static doubleSignal1d sum(doubleSignal1d s1,
                                 doubleSignal1d s2)
                          throws invalid_data_exception,
                                 size_mismatch_exception
Compute the sum of two signals and return a new signal

Throws:
invalid_data_exception
size_mismatch_exception

subSignal

public doubleSignal1d subSignal(arraySelector1d s)
                         throws invalid_data_exception
Return a sub signal determined by s

Throws:
invalid_data_exception

allocateMemory

protected void allocateMemory(int l)
Allocate the memory for the signal


rand

public static doubleSignal1d rand(int l)
                           throws invalid_data_exception
Return a new signal with random values (0,1) uniformly distributed

Throws:
invalid_data_exception

assign

public void assign(double c)
Replace this signal by the constant signal with value c


assign

public void assign(arraySelector1d s,
                   double c)
            throws invalid_data_exception
Replace part of the signal by the value of c

Throws:
invalid_data_exception

assign

public void assign(doubleSignal1d sig)
            throws invalid_data_exception
Assign another signal to this one

Throws:
invalid_data_exception

assign

public void assign(arraySelector1d st,
                   doubleSignal1d sig)
            throws invalid_data_exception
Replace part of this signal by sig

Throws:
invalid_data_exception

assign

public void assign(arraySelector1d st,
                   doubleSignal1d sig,
                   arraySelector1d s)
            throws invalid_data_exception,
                   size_mismatch_exception
Replace part of this signal by a part of the signal sig

Throws:
invalid_data_exception
size_mismatch_exception

assign

public void assign(doubleSignal1d sig,
                   arraySelector1d s)
            throws invalid_data_exception,
                   size_mismatch_exception
Replace this signal by a part of the signal sig

Throws:
invalid_data_exception
size_mismatch_exception

clear

public void clear()
clear signal ie fill signal with zeros


zeros

public void zeros()
           throws invalid_data_exception
Replace this signal by the zero signal

Throws:
invalid_data_exception

zeros

public void zeros(arraySelector1d s)
           throws invalid_data_exception,
                  size_mismatch_exception
Replace a part of this signal by zeros

Throws:
invalid_data_exception
size_mismatch_exception

zeros

public static doubleSignal1d zeros(int l)
                            throws invalid_data_exception
Return a new signal with l zeros in it

Throws:
invalid_data_exception

ones

public static doubleSignal1d ones(int l)
                           throws invalid_data_exception
Return a new signal with l ones in it

Throws:
invalid_data_exception

normTV

public double normTV(double beta)
              throws invalid_data_exception
Compute TV semi-norm (total variation norm of this signal the TV norm is defines as the integral over the derivative of the signal in case of a discrete signal like this, the integral becomes a sum and the derivative is approximated by a forward difference of order 1.

Throws:
invalid_data_exception

normTV

public double normTV(doubleSignal1d grad,
                     double beta)
              throws invalid_data_exception,
                     size_mismatch_exception
Computes the TV semi-norm of the signal and returns the gradient of the function f: x-> ||x||_TV at the point x="this signal"

Throws:
invalid_data_exception
size_mismatch_exception

normTK2

public double normTK2(doubleSignal1d grad)
               throws invalid_data_exception,
                      size_mismatch_exception
Returns the Tikhonov Norm (H^2 norm) squared and the gradient of the function f: x-> ||x||_{TK}^2 at the point x="this signal"

Throws:
invalid_data_exception
size_mismatch_exception

normTK2

public double normTK2()
               throws invalid_data_exception
Returns the Tikhonov semi-norm without the gradient

Throws:
invalid_data_exception

norm2

public double norm2()
             throws invalid_data_exception
Return 2-norm of signal

Throws:
invalid_data_exception

changePhys

public void changePhys()
Has to be called if the data was changed this becomes impotent in the derived classed that have other then the physical data in it eg fft data


validatePhys

public void validatePhys()
This validates the data of the signal a invalid_data_exception will be thrown by almost all functions if the data is invalid. This becomes impotent in the derived class with other then physical data.


cutNeg

public void cutNeg()
            throws invalid_data_exception
Cut off negative values

Throws:
invalid_data_exception

removeDC

public void removeDC()
              throws invalid_data_exception
Remove DC offset

Throws:
invalid_data_exception