00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _ComplexToPolarCnv_
00025 #define _ComplexToPolarCnv_
00026
00027 #include "Complex.hxx"
00028 #include "Polar.hxx"
00029 #include "Array.hxx"
00030 #include "Err.hxx"
00031 #include "DataTypes.hxx"
00032
00033 namespace CLAM {
00034
00035 template <class T> class ComplexToPolarCnv
00036 {
00037 public:
00038
00039
00040 ComplexToPolarCnv(){};
00041 ~ComplexToPolarCnv(){};
00042
00043
00044
00045
00046 void ToPolar(const Array<ComplexTmpl<T> > &inputArray,
00047 Array<PolarTmpl<T> > &outputArray) const
00048 {
00049 CLAM_ASSERT(outputArray.Size() == inputArray.Size(),
00050 "ComplexToPolarCnv::Convert: unable to convert buffers with different sizes");
00051
00052 for (int i=0; i<inputArray.Size(); i++) {
00053 outputArray[i].SetMag(inputArray[i].Mag());
00054 outputArray[i].SetAng(inputArray[i].Ang());
00055 }
00056 }
00057
00058
00059 void ToComplex(const Array<PolarTmpl<T> > &inputArray,
00060 Array<ComplexTmpl<T> > &outputArray) const
00061 {
00062 CLAM_ASSERT(outputArray.Size() == inputArray.Size(),
00063 "ComplexToPolarCnv::Convert: unable to convert buffers with different sizes");
00064
00065 for (int i=0; i<inputArray.Size(); i++) {
00066 outputArray[i].SetReal(inputArray[i].Real());
00067 outputArray[i].SetImag(inputArray[i].Imag());
00068 }
00069 }
00070 };
00071
00072 typedef ComplexToPolarCnv<TData> ComplexToPolarCnv_;
00073
00074 }
00075
00076 #endif
00077