#include "sopnamsp.h" #include "fftmserver.h" #include #include "fftmayer.h" /* --Methode-- */ FFTMayerServer::FFTMayerServer() : FFTServerInterface("FFTMayerServer using extended FFTMayer package") , ckR4("FFTMayerServer: ", true, true) , ckR8("FFTMayerServer: ", true, true) { } /* --Methode-- */ FFTMayerServer::~FFTMayerServer() { } /* --Methode-- */ FFTServerInterface * FFTMayerServer::Clone() { return (new FFTMayerServer); } /* --Methode-- */ void FFTMayerServer::FFTForward(TArray< complex > const & ina, TArray< complex > & outa) { ckR8.CheckResize(ina, outa); TVector< complex > in(ina); TVector< complex > out(outa); r_8 a,b,c,d; r_8 q,r,s,t; int i,j,k; int n = in.NElts(); if (checkLength(n)) { char buff[256]; sprintf(buff, "FFTMayerServer::FFTForward/Error Size(%d) != 2^n ! (File=%s Line=%d)", n, __FILE__,__LINE__); throw ParmError(string(buff)); } TVector< r_8 > inoutre(n); TVector< r_8 > inoutim(n); inoutre(0) = in(0).real(); inoutim(0) = in(0).imag(); inoutre(n/2) = in(n/2).real(); inoutim(n/2) = in(n/2).imag(); if (n > 2) { inoutre(n/2+1) = in(n/2).real(); inoutim(n/2+1) = in(n/2).imag(); } for (i=1,j=n-1,k=n/2;i(inoutre(k)*fn, inoutim(k)*fn); else for(k=0; k(inoutre(k), inoutim(k)); } /* --Methode-- */ void FFTMayerServer::FFTBackward(TArray< complex > const & ina, TArray< complex > & outa) { ckR8.CheckResize(ina, outa); TVector< complex > in(ina); TVector< complex > out(outa); r_8 a,b,c,d; r_8 q,r,s,t; int i,j,k; int n = in.NElts(); if (checkLength(n)) { char buff[256]; sprintf(buff, "FFTMayerServer::FFTBackward/Error Size(%d) != 2^n ! (File=%s Line=%d)", n, __FILE__,__LINE__); throw ParmError(string(buff)); } TVector< r_8 > inoutre(n); TVector< r_8 > inoutim(n); for(k=0; k(inoutre(0), inoutim(0)); out(n/2) = complex(inoutre(n/2), inoutim(n/2)); if (n > 2) out(n/2+1) = complex(inoutre(n/2+1), inoutim(n/2+1)); for (i=1,j=n-1,k=n/2;i( (q-t)*0.5 , (s+r)*0.5 ); out(j) = complex( (q+t)*0.5 , (s-r)*0.5 ); } } /* --Methode-- */ void FFTMayerServer::FFTForward(TArray< complex > const & ina, TArray< complex > & outa) { ckR4.CheckResize(ina, outa); TVector< complex > in(ina); TVector< complex > out(outa); r_4 a,b,c,d; r_4 q,r,s,t; int i,j,k; int n = in.NElts(); if (checkLength(n)) { char buff[256]; sprintf(buff, "FFTMayerServer::FFTForward/Error Size(%d) != 2^n ! (File=%s Line=%d)", n, __FILE__,__LINE__); throw ParmError(string(buff)); } TVector< r_4 > inoutre(n); TVector< r_4 > inoutim(n); inoutre(0) = in(0).real(); inoutim(0) = in(0).imag(); inoutre(n/2) = in(n/2).real(); inoutim(n/2) = in(n/2).imag(); if (n > 2) { inoutre(n/2+1) = in(n/2).real(); inoutim(n/2+1) = in(n/2).imag(); } for (i=1,j=n-1,k=n/2;i(inoutre(k)*fn, inoutim(k)*fn); else for(k=0; k(inoutre(k), inoutim(k)); } /* --Methode-- */ void FFTMayerServer::FFTBackward(TArray< complex > const & ina, TArray< complex > & outa) { ckR4.CheckResize(ina, outa); TVector< complex > in(ina); TVector< complex > out(outa); r_4 a,b,c,d; r_4 q,r,s,t; int i,j,k; int n = in.NElts(); if (checkLength(n)) { char buff[256]; sprintf(buff, "FFTMayerServer::FFTBackward/Error Size(%d) != 2^n ! (File=%s Line=%d)", n, __FILE__,__LINE__); throw ParmError(string(buff)); } TVector< r_4 > inoutre(n); TVector< r_4 > inoutim(n); for(k=0; k(inoutre(0), inoutim(0)); out(n/2) = complex(inoutre(n/2), inoutim(n/2)); if (n > 2) out(n/2+1) = complex(inoutre(n/2+1), inoutim(n/2+1)); for (i=1,j=n-1,k=n/2;i( (q-t)*0.5 , (s+r)*0.5 ); out(j) = complex( (q+t)*0.5 , (s-r)*0.5 ); } } /* --Methode-- */ void FFTMayerServer::FFTForward(TArray< r_4 > const & ina, TArray< complex > & outa) { ckR4.CheckResize(ina, outa); TVector< r_4 > in(ina); TVector< complex > out(outa); r_4 a,b; int i,j,k; int n = in.NElts(); if (checkLength(n)) { char buff[256]; sprintf(buff, "FFTMayerServer::FFTForward/Error Size(%d) != 2^n ! (File=%s Line=%d)", n, __FILE__,__LINE__); throw ParmError(string(buff)); } TVector< r_4 > inout(in); fht_r4(inout.Data(),inout.NElts()); for (i=1,j=n-1,k=n/2;i( (a+b)*0.5 , (a-b)*0.5 ); } // out.ReSize(n/2+1); out(0) = complex(inout(0), 0.); if (n%2 == 0) { // n pair for (i=1,j=n/2+1; i(inout(i), inout(j)); out(n/2) = complex(inout(n/2), 0.); } else { // n impair for (i=1,j=n/2+2; i(inout(i), inout(j)); out(n/2) = complex(inout(n/2), inout(n/2+1)); } if (getNormalize()) out *= (1./(r_4)(in.NElts())); } /* --Methode-- */ void FFTMayerServer::FFTBackward(TArray< complex > const & ina, TArray< r_4 > & outa, bool usoutsz) { ckR4.CheckResize(ina, outa); TVector< complex > in(ina); TVector< r_4 > out(outa); r_4 a,b; int i,j,k; int n = in.NElts(); int nc = (fabs(in(n-1).imag()) < 1.e-9) ? nc = n*2-2 : nc = n*2-1; if (checkLength(nc)) { char buff[256]; sprintf(buff, "FFTMayerServer::FFTBackward/Error Size(%d) != 2^n ! (File=%s Line=%d)", nc, __FILE__,__LINE__); throw ParmError(string(buff)); } // out.ReSize(nc); out(0) = in(0).real(); if (nc%2 == 0) { // nc pair for (i=1,j=nc/2+1; i const & ina, TArray< complex > & outa) { ckR8.CheckResize(ina, outa); TVector< r_8 > in(ina); TVector< complex > out(outa); r_8 a,b; int i,j,k; int n = in.NElts(); if (checkLength(n)) { char buff[256]; sprintf(buff, "FFTMayerServer::FFTForward/Error Size(%d) != 2^n ! (File=%s Line=%d)", n, __FILE__,__LINE__); throw ParmError(string(buff)); } TVector< r_8 > inout(in); fht_r8(inout.Data(),inout.NElts()); for (i=1,j=n-1,k=n/2;i( (a+b)*0.5 , (a-b)*0.5 ); } // out.ReSize(n/2+1); out(0) = complex(inout(0), 0.); if (n%2 == 0) { // n pair for (i=1,j=n/2+1; i(inout(i), inout(j)); out(n/2) = complex(inout(n/2), 0.); } else { // n impair for (i=1,j=n/2+2; i(inout(i), inout(j)); out(n/2) = complex(inout(n/2), inout(n/2+1)); } if (getNormalize()) out *= (1./(r_4)(in.NElts())); } /* --Methode-- */ void FFTMayerServer::FFTBackward(TArray< complex > const & ina, TArray< r_8 > & outa, bool usoutsz) { ckR8.CheckResize(ina, outa); TVector< r_8 > out(outa); TVector< complex > in(ina); r_8 a,b; int i,j,k; int n = in.NElts(); int nc = (fabs(in(n-1).imag()) < 1.e-18) ? nc = n*2-2 : nc = n*2-1; if (checkLength(nc)) { char buff[256]; sprintf(buff, "FFTMayerServer::FFTBackward/Error Size(%d) != 2^n ! (File=%s Line=%d)", nc, __FILE__,__LINE__); throw ParmError(string(buff)); } // out.ReSize(nc); out(0) = in(0).real(); if (nc%2 == 0) { // nc pair for (i=1,j=nc/2+1; i 1) { if (nc%2 != 0) return(true); nc /= 2; } return(false); }