Index: trunk/SophyaLib/NTools/fftserver.cc
===================================================================
--- trunk/SophyaLib/NTools/fftserver.cc	(revision 459)
+++ trunk/SophyaLib/NTools/fftserver.cc	(revision 467)
@@ -23,4 +23,6 @@
 sz_cfft = 0;
 ws_cfft = NULL;
+sz_cdfft = 0;
+ws_cdfft = NULL;
 }
 
@@ -29,4 +31,5 @@
 if (ws_rfft) delete[] ws_rfft;
 if (ws_cfft) delete[] ws_cfft;
+if (ws_cdfft) delete[] ws_cdfft;
 }
 
@@ -75,4 +78,5 @@
   checkint_rfft(l);
   rfftf_(&l, inout, ws_rfft);
+  for (int k= 2;k<=(l+1)/2;k++) inout[2*k-2]=-inout[2*k-2];
 }
 
@@ -81,4 +85,5 @@
   checkint_dfft(l);
   dfftf_(&l, inout, ws_dfft);
+  for (int k= 2;k<=(l+1)/2;k++) inout[2*k-2]=-inout[2*k-2];
 }
 
@@ -92,5 +97,6 @@
   }
   cfftf_(&l, foo, ws_cfft);
-  for (int i=0;i<l;i++) inout[i]= complex<float> (foo[2*i], foo[2*i+1]);
+  inout[0]=complex<float> (foo[0],foo[1]);
+  for (int i=1;i<l;i++) inout[l-i]= complex<float> (foo[2*i], foo[2*i+1]);
   delete[] foo;
 }
@@ -99,5 +105,5 @@
 {
   checkint_cdfft(l);
-  double* foo = new double[2*l];
+  double* foo=new double[2*l];
   for (int i=0;i<l;i++){
     foo[2*i]=inout[i].real();
@@ -105,5 +111,8 @@
   }
   cdfftf_(&l, foo, ws_cdfft);
-  for (int i=0;i<l;i++) inout[i]= complex<double> (foo[2*i],foo[2*i+1]);
+  inout[0]=complex<double> (foo[0],foo[1]);
+  for (int i=1;i<l;i++) {
+    inout[l-i]= complex<double> (foo[2*i],foo[2*i+1]);
+  }
   delete[] foo;
 }
@@ -112,5 +121,5 @@
 {
   checkint_rfft(l);
-  rfftb_(&l, inout, ws_rfft);
+  rfftf_(&l, inout, ws_rfft);
 }
 
@@ -118,5 +127,5 @@
 {
   checkint_dfft(l);
-  dfftb_(&l, inout, ws_dfft);
+  dfftf_(&l, inout, ws_dfft);
 }
 
@@ -129,5 +138,5 @@
     foo[2*i+1]=inout[i].imag();
   }
-  cfftb_(&l, foo, ws_cfft);
+  cfftf_(&l, foo, ws_cfft);
   for (int i=0;i<l;i++) inout[i]=complex<float> (foo[2*i],foo[2*i+1]);
   delete[] foo;
@@ -142,5 +151,5 @@
     foo[2*i+1]=inout[i].imag();
   }
-  cdfftb_(&l, foo, ws_cdfft);
+  cdfftf_(&l, foo, ws_cdfft);
   for (int i=0;i<l;i++) inout[i]=complex<double> (foo[2*i],foo[2*i+1]);
   delete[] foo;
Index: trunk/SophyaLib/NTools/fftserver.h
===================================================================
--- trunk/SophyaLib/NTools/fftserver.h	(revision 459)
+++ trunk/SophyaLib/NTools/fftserver.h	(revision 467)
@@ -39,2 +39,65 @@
 };
 #endif
+
+/*! \class FFTServer
+ \brief An FFT server
+
+A class that calculates Fourier transforms forwards and backwards.
+
+The class calls the c library ``fftpack'', which is accessible and documented
+at http://www.netlib.org/fftpack/.  However, the class functions do not
+necessarily correspond with the equivalent fftpack function.  For example,
+fftpack "forward" transformations are in fact inverse fourier transformations.
+Otherwise, the output is in the fftpack format.
+
+Complex input must be entered using the <complex> template.  Otherwise,
+all input is assumed to be real.
+
+Due to the way that fftpack manages
+its work arrays, an object can run faster if the length of the input arrays
+does not change.  For example, if you need to do a series of FFT's
+of differing length, it may be more efficient to create an fftserver object
+for each length.
+*/
+
+/*! \fn virtual void FFTServer::fftf(int l, float* inout)
+  \param l length of array
+  \param inout input array /output forward FFT (original array destroyed)
+*/
+/*! \fn virtual void FFTServer::fftb(int l, float* inout)
+  \param l length of array
+  \param inout input array /output backward FFT (original array destroyed)
+*/
+/*! \fn virtual void FFTServer::fftf(int l, double* inout)
+  \param l length of array
+  \param inout input array /output forward FFT (original array destroyed)
+  \param inout input/output array (original array destroyed)
+*/
+/*! \fn virtual void FFTServer::fftb(int l, double* inout)
+  \param l length of array
+  \param inout input array /output backward FFT(original array destroyed)
+*/
+/*!\fn  virtual void FFTServer::fftf(int l, complex<float>* inout)
+  \param l length of array
+  \param inout input array /output forward FFT (original array destroyed)
+*/
+/*! \fn virtual void FFTServer::fftb(int l, complex<float>* inout)
+  \param l length of array
+  \param inout input array /output backward FFT (original array destroyed)
+*/
+/*! \fn virtual void FFTServer::fftf(int l, complex<double>* inout)
+  \param l length of array
+  \param inout input array /output forward FFT (original array destroyed)
+*/
+/*! \fn virtual void FFTServer::fftb(int l, complex<double>* inout)
+  \param l length of array
+  \param inout input array /output backward FFT(original array destroyed)
+*/
+/*!\fn  virtual void FFTServer::fftf(Vector& in, Vector& out)
+  \param in input array
+  \param out forward FFT
+*/
+/*! \fn virtual void FFTServer::fftb(Vector& in, Vector& out)
+  \param in input array
+  \param out backward FFT
+*/
