view src/samer/maths/ClippedDivide.java @ 0:bf79fb79ee13

Initial Mercurial check in.
author samer
date Tue, 17 Jan 2012 17:50:20 +0000
parents
children
line wrap: on
line source
/*
 *	Copyright (c) 2000, Samer Abdallah, King's College London.
 *	All rights reserved.
 *
 *	This software is provided AS iS and WITHOUT ANY WARRANTY; 
 *	without even the implied warranty of MERCHANTABILITY or 
 *	FITNESS FOR A PARTICULAR PURPOSE.
 */

package samer.maths;
import  samer.core.*;
import  samer.tools.*;

public class ClippedDivide extends AnonymousTask
{
	VVector		out;
	double []	_top, _bot, _F;
	int			l;

	public ClippedDivide(VVector num, VVector denom) throws Exception 
	{ 
		l = num.size(); // length of input
		out = new VVector("F",l); // output

		// add task to compute the desired frequency response
		_top = num.array();
		_bot = denom.array();
		_F   = out.array();
	}

	public VVector output() { return out; }

	public void run() {
		for (int i=0; i<l; i++) {
			_F[i] = (_top[i]<_bot[i]) ? _top[i]/_bot[i] : 1;
			// Weiner filter version would be
			// t1=z[i]*z[i]; t2=x[i]-z[i];
			// _F[i]=t1/(t1 + t2*t2); ??
		}
		out.changed(); 
	}
}