Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

complex_u.h

Go to the documentation of this file.
00001 // 
00002 // Copyright(c) 1993-1996 Tony Kirke
00003 // author="Tony Kirke" *
00004 /*
00005  * SPUC - Signal processing using C++ - A DSP library
00006  * 
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2, or (at your option)
00010  * any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 #ifndef UINTC
00022 #define UINTC
00023 #include <complex_iu.h>
00024 namespace SPUC {
00027 template <long Bits=32> class complex_u : public complexiu
00028 {
00029         public:
00030           complex_u() { 
00031                   bits=Bits;
00032                   mask = -1 << Bits;
00033           }
00034           complex_u(long r, long i=0) {
00035                   q = complex<long>(r,i); 
00036                   bits=Bits;
00037                   mask = -1 << Bits;
00038           }
00039           complex_u(complex<long>& y) {
00040                   q = y; 
00041                   bits=Bits;
00042                   mask = -1 << Bits;
00043           }
00044           complex_u(complex_iu& y) {
00045                   q = y.q; 
00046                   bits=Bits;
00047                   mask = -1 << Bits;
00048                   long r,i;
00049                   if (  ((mask&q.real())!=mask) || ((mask&q.real())!=0) ) {
00050                            r = q.real() & ~mask;}
00051                   if (  ((mask&q.imag())!=mask) || ((mask&q.imag())!=0) ) {
00052                            i = q.imag() & ~mask;}
00053                   q = complex<long>(r,i);
00054           }
00055 //        complex_u(long y) { 
00056 //                q = y;
00057 //                bits=Bits;
00058 //                mask = -1 << Bits;
00059 //        }
00060           inline complex_u operator =(const complex_iu& y) {   
00061            q = y.q;
00062            long r,i;
00063            if (  ((mask&q.real())!=mask) || ((mask&q.real())!=0) ) {
00064                    r = q.real() & ~mask;}
00065            if (  ((mask&q.imag())!=mask) || ((mask&q.imag())!=0) ) {
00066                    i = q.imag() & ~mask;}
00067            q = complex<long>(r,i);
00068        return *this; 
00069           } 
00070           inline complex_u operator =(const long& y) {   
00071                 q = y;
00072                 if ( ((mask&y)!=mask) || ((mask&y)!=0) ) q = (y& ~mask);
00073                 return *this; 
00074           } 
00075 
00076  
00077 };
00078 } // namespace SPUC 
00079 #endif

Generated on Fri Sep 16 11:02:26 2005 for spuc by  doxygen 1.4.4