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

num_utility.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 // num_utility.h
00032 //
00033 // Utility declarations and definitions used by various numerical routines
00034 //
00035 // F. Rice 7/8/99
00036 //
00037 // ********************************************************************
00038 #ifndef NUM_UTILITY_H
00039 #define NUM_UTILITY_H
00040 
00041 #include <functional>
00042 
00043 // ********************************************************************
00044 // A default norm for doubles, consistent with those for other data types.
00045 // Returns the magnitude squared of the argument
00046 
00047 inline double norm(double x) { return x*x; }
00048 
00049 
00050 // ********************************************************************
00051 // the following functional provides access to the overloaded global norm()
00052 // functions, with overload resolution as a template. Useful as an argument
00053 // to something which needs a norm function.
00054 // Usage: default_norm<double> dnorm;  then say:  dnorm(x);
00055 
00056 template <class X>
00057 struct default_norm : public unary_function<X,double>
00058 {
00059   double operator() (const X & x) const { return ::norm(x); }
00060 };
00061 
00062 
00063 // ********************************************************************
00064 // Here are functions to convert a member function obj.f(x), where "obj"
00065 // is of type "Class", to a form suitable for passing as an argument
00066 // to something which requires a functional or a regular function. The
00067 // resulting argument for use in such a a call would be:
00068 //    member_function(&Class::f, obj)
00069 // Note that the member function f() should take exactly one argument.
00070 
00071 template <class S, class T, class A>
00072 inline binder1st< mem_fun1_ref_t<S,T,A> > member_function(S (T::*f)(A), T obj)
00073 { return bind1st(mem_fun1_ref(f),obj); }
00074 
00075 template <class S, class T, class A>
00076 inline binder1st< const_mem_fun1_ref_t<S,T,A> > 
00077 member_function(S (T::*f)(A) const, T obj)
00078 { return bind1st(mem_fun1_ref(f), obj); }
00079 
00080 
00081 #endif /* NUM_UTILITY_H */
00082 

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