Sandia Home Sandia Home
Main Page | Publications | Downloads | Configuration | Running the Code | Solver Parameters | FAQ | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

APPSPACK_Cache_Point.cpp

Go to the documentation of this file.
00001 // $Id: APPSPACK_Cache_Point.cpp,v 1.9 2006/06/30 01:42:08 tgkolda Exp $ 
00002 // $Source: /space/CVS-Acro/acro/packages/appspack/appspack/src/APPSPACK_Cache_Point.cpp,v $ 
00003 
00004 //@HEADER
00005 // ************************************************************************
00006 // 
00007 //          APPSPACK: Asynchronous Parallel Pattern Search
00008 //                 Copyright (2003) Sandia Corporation
00009 // 
00010 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00011 // license for use of this work by or on behalf of the U.S. Government.
00012 // 
00013 // This library is free software; you can redistribute it and/or modify
00014 // it under the terms of the GNU Lesser General Public License as
00015 // published by the Free Software Foundation; either version 2.1 of the
00016 // License, or (at your option) any later version.
00017 //  
00018 // This library is distributed in the hope that it will be useful, but
00019 // WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 // Lesser General Public License for more details.
00022 //                                                                                 
00023 // You should have received a copy of the GNU Lesser General Public
00024 // License along with this library; if not, write to the Free Software
00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00026 // USA.                                                                           .
00027 // 
00028 // Questions? Contact Tammy Kolda (tgkolda@sandia.gov) 
00029 // 
00030 // ************************************************************************
00031 //@HEADER
00032 
00038 #include "APPSPACK_Cache_Point.hpp" 
00039 
00040 APPSPACK::Vector APPSPACK::Cache::Point::scaling(0);
00041 double APPSPACK::Cache::Point::tolerance = 0;
00042 
00043 APPSPACK::Cache::Point::Point() :
00044   xPtr(NULL),
00045   x(*xPtr),
00046   f()
00047 {
00048 }
00049 
00050 APPSPACK::Cache::Point::Point(const Vector& x_in) :
00051   xPtr(NULL),
00052   x(x_in),
00053   f()
00054 {
00055   checkSize();
00056 }
00057 
00058 APPSPACK::Cache::Point::Point(const Vector& x_in, const Vector& f_in) :
00059   xPtr(NULL),
00060   x(x_in),
00061   f(f_in)
00062 {
00063   checkSize();
00064 }
00065 
00066 APPSPACK::Cache::Point::Point(const Point& source) :
00067   xPtr(new Vector(source.x)),
00068   x(*xPtr),
00069   f(source.f)
00070 {
00071   checkSize();
00072 }
00073 
00074 APPSPACK::Cache::Point::~Point()
00075 {
00076   delete xPtr;
00077 }
00078 
00079 void APPSPACK::Cache::Point::copyData(const Point& source)
00080 {
00081   f = source.f;
00082 }
00083 
00084 const APPSPACK::Vector& APPSPACK::Cache::Point::getF()
00085 {
00086   return f;
00087 }
00088 
00089 bool APPSPACK::Cache::Point::operator>(const Point& pt) const
00090 {
00091   checkSize(pt);
00092 
00093   int n = x.size();
00094 
00095   for(int i = 0; i < n; i++) 
00096   {
00097     if ( fabs(x[i] - pt.x[i]) > (scaling[i] * tolerance) ) 
00098     {
00099       // unequal with respect to tolerance
00100 
00101       if ( (x[i] - pt.x[i]) > (scaling[i] * tolerance) ) 
00102       {
00103         // this > other
00104         return true;
00105       }
00106       else
00107       {
00108         // this < other
00109         return false;
00110       }
00111 
00112     }
00113   }
00114 
00115   // this == other
00116   return false;
00117 }
00118 
00119 bool APPSPACK::Cache::Point::operator<(const Point& pt) const
00120 {
00121   checkSize(pt);
00122 
00123   int n = x.size();
00124 
00125   for(int i = 0; i < n; i++) 
00126   {
00127     if ( fabs(x[i] - pt.x[i]) > (scaling[i] * tolerance) ) // unequal 
00128     {
00129       if ( (pt.x[i] - x[i]) > (scaling[i] * tolerance) ) // x > pt.x
00130       {
00131         // this < other
00132         return true;
00133       }
00134       else
00135       {
00136         // this > other
00137         return false;
00138       }
00139     }
00140   }
00141 
00142   // this == other
00143   return false;
00144 }
00145 
00146 bool APPSPACK::Cache::Point::operator!=(const Point& pt) const
00147 {
00148   checkSize(pt);
00149 
00150   int n = x.size();
00151 
00152   for(int i = 0; i < n; i++) 
00153   {
00154     if ( fabs(pt.x[i] - x[i]) > (scaling[i] * tolerance))
00155     {
00156       // this != other
00157       return true;
00158     }
00159   }
00160 
00161   // this == other
00162   return false;
00163 }
00164 
00165 void APPSPACK::Cache::Point::setStaticScaling(const Vector& scaling_in)
00166 {
00167   scaling = scaling_in;
00168 }
00169 
00170 void APPSPACK::Cache::Point::setStaticTolerance(double tolerance_in)
00171 {
00172   tolerance = tolerance_in;
00173 }
00174 
00175 
00176 // PRIVATE
00177 void APPSPACK::Cache::Point::checkSize() const
00178 {
00179   if (x.size() != scaling.size())
00180   {
00181     cout << "APPSPACK::Cache::Point::checksize - scaling size mismatch" << endl;
00182     throw "APPSPACK Error";
00183   }
00184 }
00185 
00186 // PRIVATE
00187 void APPSPACK::Cache::Point::checkSize(const Point& pt) const
00188 {
00189   if (x.size() != pt.x.size())
00190   {
00191     cout << "APPSPACK::Cache::Point::checksize - point size mismatch" << endl;
00192     throw "APPSPACK Error";
00193   }
00194 }
00195 

 

© Sandia Corporation | Site Contact | Privacy and Security

Generated on Fri Feb 16 10:33:34 2007 for APPSPACK 5.0.1 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2002