00001 /***************************************************************************
00002 normfunction.h - description
00003 -------------------
00004 begin : Tue May 2 2000
00005 copyright : (C) 2000 by Michael Peeters
00006 email : Michael.Peeters@vub.ac.be
00007 ***************************************************************************/
00008
00009 /***************************************************************************
00010 * *
00011 * This program is free software; you can redistribute it and/or modify *
00012 * it under the terms of the GNU General Public License as published by *
00013 * the Free Software Foundation; either version 2 of the License, or *
00014 * (at your option) any later version. *
00015 * *
00016 ***************************************************************************/
00017
00018 #ifndef NORMFUNCTION_H
00019 #define NORMFUNCTION_H
00020
00021 #include "scalarfunction.h"
00022
00023 namespace MODEL{
00024
00028 template <integer dims, class NT = NumericTraits<number,dims> >
00029 class NormFunction : public ScalarFunction<dims, NT>
00030 {
00031 public:
00032 typedef ScalarFunction<dims, NT> base;
00033 typedef typename NT::vf vf;
00034
00038 NormFunction(vf& vfu, bool own=false, numT scale=1.0)
00039 : owned(own), func((own)?(vfu.clone()):(&vfu)),values(0.),sc(scale) {}
00040
00044 NormFunction(const NormFunction& vfu)
00045 : base(vfu), owned(false),
00046 func(vfu.func), values(vfu.values), sc(vfu.sc) {}
00047
00050 const NormFunction& operator=(const NormFunction& vfu)
00051 { if(this!=&vfu)
00052 {
00053 if(owned) delete func;
00054 func=vfu.func;
00055 owned=false;
00056 values=vfu.values;
00057 sc=vfu.sc;
00058 }
00059 return *this;}
00060
00061 virtual ~NormFunction() { if(owned) delete func;}
00062
00064 virtual NormFunction* clone (void) const
00065 {return new NormFunction(*this);}
00066
00067
00072 virtual const numT& function(numT& fu,const vect& u)
00073 { values=(*func)(u); fu=sc*norm(values); return fu;}
00074
00075
00077 const vect& function_value(void){return values;}
00078
00079
00080 private:
00081 bool owned;
00082 vf* func;
00085 vect values;
00086 numT sc;
00087 };
00088
00089 } // end MODEL
00090 #endif
00091
00092 /*********************************************************************
00093 $Id: normfunction.h,v 1.1 2001/05/22 10:54:55 mpeeters Exp $
00094 **********************************************************************
00095
00096 $Log: normfunction.h,v $
00097 Revision 1.1 2001/05/22 10:54:55 mpeeters
00098 Moved sources and headers for libModel to model/ subdirectory, in an attempt to rationalize the source tree. This should make things "netter".
00099
00100 Revision 1.2 2000/09/15 10:26:31 mpeeters
00101 Cleaned out header and added CVS tails to files, removed superfuous
00102 @author comments, inserted dates
00103
00104 *********************************************************************/
More Info? Michael Peeters. Also, check our research website: www.alna.vub.ac.be
Last update: June 2002.