samer@0: /* samer@0: * Copyright (c) 2000, Samer Abdallah, King's College London. samer@0: * All rights reserved. samer@0: * samer@0: * This software is provided AS iS and WITHOUT ANY WARRANTY; samer@0: * without even the implied warranty of MERCHANTABILITY or samer@0: * FITNESS FOR A PARTICULAR PURPOSE. samer@0: */ samer@0: samer@0: package samer.units; samer@0: samer@0: import samer.core.*; samer@0: import samer.maths.*; samer@0: import samer.tools.*; samer@0: import samer.functions.*; samer@0: samer@0: /** samer@0: Inverts a given FFT using an alternative magnitude spectrum samer@0: */ samer@0: samer@0: public class RescaledIFT extends FFT implements Task samer@0: { samer@0: Vec mag; samer@0: FFT ft; samer@0: double k[]; samer@0: VVector out; samer@0: samer@0: public RescaledIFT(FFT ft, Vec mag) throws Exception samer@0: { samer@0: super(ft.size()); samer@0: this.ft=ft; samer@0: this.mag=mag; samer@0: k=new double[N]; samer@0: invert(); samer@0: out=new VVector("ift.output", real); samer@0: } samer@0: samer@0: public VVector output() { return out; } samer@0: samer@0: public void dispose() {} samer@0: public void starting() {} samer@0: public void stopping() {} samer@0: public void run() { samer@0: Vec.Iterator mit=mag.iterator(); samer@0: int i, j; samer@0: samer@0: for (i=0, j=N-1; mit.more(); i++, j--) samer@0: k[j]=k[i]=mit.next()/abs(ft.real[i],ft.imag[i]); samer@0: for (; i<=N/2; i++, j--) k[i]=k[j]=0; samer@0: samer@0: for (i=0; i