view src/samer/maths/ClippedDivide.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
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(); 
	}
}