package jsci.maths.wavelet;

import jsci.maths.*;
import jsci.maths.wavelet.*;

/****************************************************
* This class allows to do some operations
* on wavelet coefficients
* @author Daniel Lemire
*****************************************/
public final class FWTCoefMath extends AbstractMath {
  private FWTCoefMath () {}

	public static boolean areCompatible(FWTCoef a,FWTCoef b) {
		if(a.getJ()!=b.getJ()) {
			return(false);
		}
		for(int i=0;i=getJ(a))) {
			throw new IllegalArgumentException("The integer parameter "+i+" should be between 0 and "+(getJ(a)-1));
		}
		double ans=0.0;
		for(int k=0;k=getJ(a))) {
			throw new IllegalArgumentException("The integer parameter "+i+" should be between 0 and "+(getJ(a)-1));
		}
		double ans=0.0;
		for(int k=0;k=getJ(a))) {
			throw new IllegalArgumentException("The integer parameter "+i+" should be between 0 and "+(getJ(a)-1));
		}
		double sumEnergies=sumSquares(a,i);
		int nombreDeCoefficients=a[0].coefs[i].length;
		double[] energyRatio=new double[nombreDeCoefficients];
		int pos=0;
		for(int l=0;l=getJ(a))) {
			throw new IllegalArgumentException("The integer parameter "+i+" should be between 0 and "+(getJ(a)-1));
		}
		if(sumEnergies(a)==0) {
			if(getJ(a)!=0) {
				return(1/getJ(a));
			} else {
				throw new IllegalArgumentException("No energy!");
			}
		}
		return(sumSquares(a,i)/sumEnergies(a));
	}

	public static double varianceRatio(FWTCoef[] a, int i) {
		if (areCompatible(a)==false) {
			throw new IllegalArgumentException("The Objects of type FWTCoef are not compatible.");
		}
		if(getJ(a)<=1) {
			throw new IllegalArgumentException("No wavelet coefficients!");
		}
		if((i<1)||(i>=getJ(a))) {
			throw new IllegalArgumentException("The integer parameter "+i+" should be between 0 and "+(getJ(a)-1));
		}
		if(sumVariance(a)==0) {
			if(getJ(a)!=0) {
				return(1/getJ(a));
			} else {
				throw new IllegalArgumentException("No energy!");
			}
		}
		return(variance(a,i)/sumVariance(a));
	}


        /**
        * Compute the Shannon entropy.
        */
	public static double icf(FWTCoef[] a) {
		if (areCompatible(a)==false) {
			throw new IllegalArgumentException("The Objects of type FWTCoef are not compatible.");
		}
		if(getJ(a)<=1) {
			throw new IllegalArgumentException("No wavelet coefficients!");
		}
		double[] pe=new double[getJ(a)-1];
		for(int j=1;j 

Ads help maintain this website.