Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

complex_parameter.h

Go to the documentation of this file.
00001 // SuperMix version 1.0  C++ source file
00002 //
00003 // Copyright (c) 1999 California Institute of Technology.
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms for noncommercial
00007 // purposes are permitted provided that the above copyright notice and
00008 // this paragraph are duplicated in all such forms and that any
00009 // documentation and other materials related to such distribution and
00010 // use acknowledge that the software was developed by California
00011 // Institute of Technology. Redistribution and/or use in source or
00012 // binary forms is not permitted for any commercial purpose. Use of
00013 // this software does not include a permitted use of the Institute's
00014 // name or trademark for any purpose.
00015 //
00016 // DISCLAIMER:
00017 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT
00018 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR
00019 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET
00020 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
00021 // LICENSED PRODUCT, HOWEVER USED.  IN NO EVENT SHALL CALTECH/JPL BE
00022 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO
00023 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC
00024 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF
00025 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN
00026 // FACT SHALL KNOW OF THE POSSIBILITY.  THE USER BEARS ALL RISK
00027 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED
00028 // MATERIALS.
00029 //
00030 // **************************************************************************
00031  
00039 // **************************************************************************
00040 //
00041 // 5/13/01:  Converted comments to javadoc format
00042 // 5/8/01:   Fixed a sinister bug where double arguments are
00043 //           cast to ints vice converted to Complex
00044 // 11/23/98: Added operator= and constructor to shadow real
00045 //           parameters (JSW)
00046 // 8/19/98:  Fixed default operator =
00047 //
00048 // **************************************************************************
00049 
00050 #ifndef COMPLEX_PARAMETER_H
00051 #define COMPLEX_PARAMETER_H 1
00052 
00053 #include "abstract_complex_parameter.h"
00054 #include <iostream.h>
00055 #include "abstract_real_parameter.h"
00056 
00061 class complex_parameter : public abstract_complex_parameter
00062 {
00063 public:
00064 
00071   complex_parameter(Complex v = Complex(0.0));
00072 
00079   complex_parameter(int v);
00080 
00087   complex_parameter(double v);
00088 
00089 //    // Create a clone of the argument
00090 //    complex_parameter(const complex_parameter &) ;
00091 
00097   complex_parameter(const abstract_complex_parameter *p);
00098 
00104   complex_parameter(const abstract_real_parameter *p);
00105 
00106   enum {CARTESIAN = 1, POLAR = 2};
00107 
00115   complex_parameter(const abstract_real_parameter &p1,
00116                     const abstract_real_parameter &p2,
00117                     int imode = CARTESIAN) ;  
00118 
00125   inline bool is_shadow() const ;
00126 
00133   inline bool is_local() const ;
00134 
00140   bool is_cartesian() const { return mode == CARTESIAN; }
00141 
00147   bool is_polar() const { return mode == POLAR; }
00148 
00154   Complex get() const;
00155 
00162   inline complex_parameter& set(Complex v);
00163 
00169   complex_parameter& clone(const complex_parameter & p);
00170 
00176   complex_parameter & shadow(const abstract_complex_parameter & p);
00177 
00183   complex_parameter & shadow(const abstract_real_parameter & p);
00184 
00192   complex_parameter & shadow(const abstract_real_parameter &p1,
00193                              const abstract_real_parameter &p2,
00194                              int imode = CARTESIAN);
00195 
00201   complex_parameter& operator =(Complex v) { return set(v); }
00202 
00208   complex_parameter& operator =(double v) { return set(v); }
00209 
00215   complex_parameter& operator =(int v) { return set(Complex(v)); }
00216 
00222   complex_parameter& operator =(const complex_parameter & p)
00223   { return clone(p); }
00224 
00230   complex_parameter& operator =(const abstract_complex_parameter * p);
00231 
00237   complex_parameter& operator =(const abstract_real_parameter * p);
00238 
00239 private:
00241   Complex value;
00242 
00243   // used with CARTESIAN and POLAR
00244   enum {VALUE = 0, C_SHADOW = 3, R_SHADOW = 4};
00245 
00247   int mode ;
00248 
00249   union { 
00251     const abstract_complex_parameter *cp;
00253     const abstract_real_parameter *rp1;
00254   };
00255 
00257   const abstract_real_parameter *rp2;
00258 
00263   mutable bool get_flag ;
00264 };
00265 
00266 // inline member function definitions
00267 
00268 inline bool complex_parameter::is_shadow() const
00269 { return mode != VALUE; }
00270 
00271 inline bool complex_parameter::is_local() const
00272 { return mode == VALUE; }
00273 
00274 inline complex_parameter& complex_parameter::set(Complex v)
00275 { mode = VALUE; value = v; return *this; }
00276 
00278 inline complex_parameter & operator +=(complex_parameter & p, Complex d)
00279 { return p.set(p.get() + d); }
00280 
00282 inline complex_parameter & operator -=(complex_parameter & p, Complex d)
00283 { return p.set(p.get() - d); }
00284 
00286 inline complex_parameter & operator *=(complex_parameter & p, Complex d)
00287 { return p.set(p.get() * d); }
00288 
00290 inline complex_parameter & operator /=(complex_parameter & p, Complex d)
00291 { return p.set(p.get() / d); }
00292 
00294 istream &operator >>(istream&, complex_parameter&);
00295 
00296 #endif /* COMPLEX_PARAMETER_H */

Please direct comments and corrections to supermix@submm.caltech.edu
Go to the supermix home page
Generated by doxygen1.2.7