package jsci.maths.wavelet;
import jsci.maths.*;
import jsci.maths.wavelet.*;
/**********************************************
* This class is used to be able to mix the wavelet
* and sine transforms. It is in fact a normalised
* sine.
* @author Daniel Lemire
*************************************************/
public final class Sine extends MultiscaleFunction implements NumericalConstants, Cloneable {
private int n0; private int freq;private double normalisation;
/*******************************
* Return a String representation
* of the object
********************************/
public String toString() {
String ans=new String("[n0=");
ans.concat(Integer.toString(n0));
ans.concat("][freq=");
ans.concat(Integer.toString(freq));
ans.concat("]");
return(ans);
}
public Sine (int N0,int FREQ) {
if(N0<0) {
throw new IllegalArgumentException("The length paramenter "+N0+" must be positive");
}
if((FREQ<0)||(FREQ>=N0)) {
throw new IllegalArgumentException("The frequency parameter "+FREQ+" must be between "+0+" and "+(N0-1));
}
n0=N0;freq=FREQ;
normalisation=Math.sqrt(n0/2d);
}
/*****************************************
* Check if another object is equal to this
* Sine object
******************************************/
public boolean equals(Object a) {
if((a!=null) && (a instanceof Sine)) {
Sine iv=(Sine)a;
return (this.dimension(0)==iv.dimension(0)) && (this.getFrequency()==iv.getFrequency());
}
return false;
}
public int getFrequency() {
return(freq);
}
/************************************************
* Return as an array the sampled values
* of the function
*************************************************/
public double[] evaluate() {
return(ArrayMath.scalarMultiply(1.0/normalisation,evaluate(n0,freq)));
}
private static double[] evaluate(int N0,int FREQ) {
double[] ans=new double[N0];
for(int k=0;k
Ads help maintain this website.