Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 247b28499c443e092731ffba814075f2 > files > 1066

mpqc-html-2.3.1-9mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>MPQC: function.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>function.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
<a name="l00002"></a>00002 <span class="comment">// function.h</span>
<a name="l00003"></a>00003 <span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 1996 Limit Point Systems, Inc.</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// Author: Curtis Janssen &lt;cljanss@limitpt.com&gt;</span>
<a name="l00007"></a>00007 <span class="comment">// Maintainer: LPS</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// This file is part of the SC Toolkit.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// The SC Toolkit is free software; you can redistribute it and/or modify</span>
<a name="l00012"></a>00012 <span class="comment">// it under the terms of the GNU Library General Public License as published by</span>
<a name="l00013"></a>00013 <span class="comment">// the Free Software Foundation; either version 2, or (at your option)</span>
<a name="l00014"></a>00014 <span class="comment">// any later version.</span>
<a name="l00015"></a>00015 <span class="comment">//</span>
<a name="l00016"></a>00016 <span class="comment">// The SC Toolkit is distributed in the hope that it will be useful,</span>
<a name="l00017"></a>00017 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00018"></a>00018 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00019"></a>00019 <span class="comment">// GNU Library General Public License for more details.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021 <span class="comment">// You should have received a copy of the GNU Library General Public License</span>
<a name="l00022"></a>00022 <span class="comment">// along with the SC Toolkit; see the file COPYING.LIB.  If not, write to</span>
<a name="l00023"></a>00023 <span class="comment">// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.</span>
<a name="l00024"></a>00024 <span class="comment">//</span>
<a name="l00025"></a>00025 <span class="comment">// The U.S. Government is granted a limited license as per AL 91-7.</span>
<a name="l00026"></a>00026 <span class="comment">//</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#ifdef __GNUC__</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#pragma interface</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef _math_optimize_function_h</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define _math_optimize_function_h</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;float.h&gt;</span>
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;util/state/state.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;math/optimize/transform.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;math/scmat/matrix.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;math/scmat/result.h&gt;</span>
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 <span class="keyword">namespace </span>sc {
<a name="l00044"></a>00044 
<a name="l00048"></a><a class="code" href="classsc_1_1Function.html">00048</a> <span class="keyword">class </span><a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a>: <span class="keyword">virtual</span> <span class="keyword">public</span> <a class="code" href="classsc_1_1SavableState.html" title="Base class for objects that can save/restore state.">SavableState</a>, <span class="keyword">public</span> <a class="code" href="classsc_1_1Compute.html" title="The Compute class provides a means of keeping results up to date.">Compute</a> {
<a name="l00049"></a>00049   <span class="keyword">protected</span>:
<a name="l00050"></a><a class="code" href="classsc_1_1Function.html#1833a04507ed111de5df37fe0cd71b1b">00050</a>     <a class="code" href="classsc_1_1Ref.html">Ref&lt;SCMatrixKit&gt;</a> <a class="code" href="classsc_1_1Function.html#1833a04507ed111de5df37fe0cd71b1b" title="Used to construct new matrices.">matrixkit_</a>;          
<a name="l00051"></a>00051 
<a name="l00052"></a><a class="code" href="classsc_1_1Function.html#2a615bead5bd425bd082708f4b2c58c2">00052</a>     <a class="code" href="classsc_1_1RefSCVector.html" title="The RefSCVector class is a smart pointer to an SCVector specialization.">RefSCVector</a> <a class="code" href="classsc_1_1Function.html#2a615bead5bd425bd082708f4b2c58c2" title="The variables.">x_</a>;                     
<a name="l00053"></a><a class="code" href="classsc_1_1Function.html#2f487293d319362639a912be9e9268ae">00053</a>     <a class="code" href="classsc_1_1RefSCDimension.html" title="The RefSCDimension class is a smart pointer to an SCDimension specialization.">RefSCDimension</a> <a class="code" href="classsc_1_1Function.html#2f487293d319362639a912be9e9268ae" title="The dimension of x_.">dim_</a>;                
<a name="l00054"></a><a class="code" href="classsc_1_1Function.html#a29fadf89f6ad8ab25e32d92dc9d87ee">00054</a>     <a class="code" href="classsc_1_1NCAccResult.html">AccResultdouble</a> <a class="code" href="classsc_1_1Function.html#a29fadf89f6ad8ab25e32d92dc9d87ee" title="The value of the function at x_.">value_</a>;             
<a name="l00055"></a><a class="code" href="classsc_1_1Function.html#ebedf1f0726ee6f6c782ebf81d7d85c1">00055</a>     <a class="code" href="classsc_1_1AccResult.html">AccResultRefSCVector</a> <a class="code" href="classsc_1_1Function.html#ebedf1f0726ee6f6c782ebf81d7d85c1" title="The gradient at x_.">gradient_</a>;     
<a name="l00056"></a><a class="code" href="classsc_1_1Function.html#1bf0316e343e945fce55fb7b25a27764">00056</a>     <a class="code" href="classsc_1_1AccResult.html">AccResultRefSymmSCMatrix</a> <a class="code" href="classsc_1_1Function.html#1bf0316e343e945fce55fb7b25a27764" title="The hessian at x_.">hessian_</a>;  
<a name="l00057"></a>00057 
<a name="l00062"></a>00062     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_value(<span class="keywordtype">double</span>);
<a name="l00063"></a>00063     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_gradient(<a class="code" href="classsc_1_1RefSCVector.html" title="The RefSCVector class is a smart pointer to an SCVector specialization.">RefSCVector</a>&amp;);
<a name="l00064"></a>00064     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_hessian(<a class="code" href="classsc_1_1RefSymmSCMatrix.html" title="The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization...">RefSymmSCMatrix</a>&amp;);
<a name="l00066"></a>00066 
<a name="l00069"></a>00069     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1Function.html#a76abecd574f7744cd6d93f1bd6b5506" title="Set the SCMatrixKit that should be used to construct the requisite vectors and matrices...">set_matrixkit</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref&lt;SCMatrixKit&gt;</a>&amp;);
<a name="l00070"></a>00070     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_dimension(<span class="keyword">const</span> <a class="code" href="classsc_1_1RefSCDimension.html" title="The RefSCDimension class is a smart pointer to an SCDimension specialization.">RefSCDimension</a>&amp;);
<a name="l00071"></a>00071 
<a name="l00076"></a>00076     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_actual_value_accuracy(<span class="keywordtype">double</span>);
<a name="l00077"></a>00077     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_actual_gradient_accuracy(<span class="keywordtype">double</span>);
<a name="l00078"></a>00078     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_actual_hessian_accuracy(<span class="keywordtype">double</span>);
<a name="l00080"></a>00080 
<a name="l00082"></a><a class="code" href="classsc_1_1Function.html#1287b3d19e716b17e229f731fa4dadc6">00082</a>     <a class="code" href="classsc_1_1RefSCVector.html" title="The RefSCVector class is a smart pointer to an SCVector specialization.">RefSCVector</a>&amp; <a class="code" href="classsc_1_1Function.html#1287b3d19e716b17e229f731fa4dadc6" title="Get read/write access to the coordinates for modification.">get_x_reference</a>() { <a class="code" href="classsc_1_1Compute.html#154962783ea8138940fd72a213d3d794" title="Marks all results as being out of date.">obsolete</a>(); <span class="keywordflow">return</span> <a class="code" href="classsc_1_1Function.html#2a615bead5bd425bd082708f4b2c58c2" title="The variables.">x_</a>; }
<a name="l00083"></a>00083 
<a name="l00086"></a>00086     <span class="keywordtype">void</span> <a class="code" href="classsc_1_1Function.html#aebdb9c0bf5645da91d00cb127afecc4" title="Change the coordinate system and apply the given transform to intermediates matrices...">do_change_coordinates</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html" title="A template class that maintains references counts.">Ref&lt;NonlinearTransform&gt;</a>&amp;);
<a name="l00087"></a>00087   <span class="keyword">public</span>:
<a name="l00088"></a>00088     <a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a>();
<a name="l00089"></a>00089     <a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a>(<a class="code" href="classsc_1_1StateIn.html" title="Restores objects that derive from SavableState.">StateIn</a>&amp;);
<a name="l00090"></a>00090     <a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a>&amp;);
<a name="l00091"></a>00091 
<a name="l00108"></a>00108     <a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref&lt;KeyVal&gt;</a>&amp;, <span class="keywordtype">double</span> funcacc = DBL_EPSILON,
<a name="l00109"></a>00109              <span class="keywordtype">double</span> gradacc = DBL_EPSILON, <span class="keywordtype">double</span> hessacc = DBL_EPSILON);
<a name="l00110"></a>00110     <span class="keyword">virtual</span> ~<a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a>();
<a name="l00111"></a>00111 
<a name="l00112"></a>00112     <a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a> &amp; operator=(<span class="keyword">const</span> <a class="code" href="classsc_1_1Function.html" title="The Function class is an abstract base class that, given a set of coordinates, will...">Function</a>&amp;);
<a name="l00113"></a>00113 
<a name="l00116"></a>00116     <a class="code" href="classsc_1_1Ref.html">Ref&lt;SCMatrixKit&gt;</a> <a class="code" href="classsc_1_1Function.html#86be61bf9d28596b283e65bf101b174b" title="Return the SCMatrixKit used to construct vectors and matrices.">matrixkit</a>() <span class="keyword">const</span>;
<a name="l00118"></a>00118     <a class="code" href="classsc_1_1RefSCDimension.html" title="The RefSCDimension class is a smart pointer to an SCDimension specialization.">RefSCDimension</a> <a class="code" href="classsc_1_1Function.html#a9d5688f8f8bb8796485e7c8a7a69545" title="Return the SCDimension of the problem.">dimension</a>() <span class="keyword">const</span>;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1Function.html#5b48312329bddf00e7a44adb6c577dff" title="Save the base classes (with save_data_state) and the members in the same order that...">save_data_state</a>(<a class="code" href="classsc_1_1StateOut.html" title="Serializes objects that derive from SavableState.">StateOut</a>&amp;);
<a name="l00121"></a>00121 
<a name="l00123"></a>00123     <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classsc_1_1Function.html#36e1b9c157780039752a3ea2e3736875" title="Return the value of the function.">value</a>();
<a name="l00125"></a>00125     <span class="keywordtype">int</span> <a class="code" href="classsc_1_1Function.html#fcaa99fe2ff2749d979d151b53ece66f" title="Returns nonzero if the current value is not up-to-date.">value_needed</a>() <span class="keyword">const</span>;
<a name="l00129"></a>00129     <span class="keywordtype">int</span> <a class="code" href="classsc_1_1Function.html#57ad99f54082575470644172a2022a5e" title="If passed a nonzero number, compute the value the next time compute() is called.">do_value</a>(<span class="keywordtype">int</span>);
<a name="l00130"></a>00130     <a class="code" href="classsc_1_1NCAccResult.html">AccResultdouble</a>&amp; value_result() { <span class="keywordflow">return</span> <a class="code" href="classsc_1_1Function.html#a29fadf89f6ad8ab25e32d92dc9d87ee" title="The value of the function at x_.">value_</a>; }
<a name="l00131"></a>00131 
<a name="l00133"></a>00133     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1Function.html#ddbc72f90b48f0423e855d3e9f3e36ed" title="Set the accuracy to which the value is to be computed.">set_desired_value_accuracy</a>(<span class="keywordtype">double</span>);
<a name="l00135"></a>00135     <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classsc_1_1Function.html#75ca40b52a69404c175758a25822ba3c" title="Return the accuracy with which the value has been computed.">actual_value_accuracy</a>() <span class="keyword">const</span>;
<a name="l00137"></a>00137     <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classsc_1_1Function.html#5a63f044fa1ea871cf9d14c723f03404" title="Return the accuracy with which the value is to be computed.">desired_value_accuracy</a>() <span class="keyword">const</span>;
<a name="l00138"></a>00138 
<a name="l00143"></a>00143     <span class="keyword">virtual</span> RefSCVector gradient();
<a name="l00144"></a>00144     <span class="keywordtype">int</span> gradient_needed() <span class="keyword">const</span>;
<a name="l00145"></a>00145     <span class="keywordtype">int</span> do_gradient(<span class="keywordtype">int</span>);
<a name="l00146"></a>00146     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_desired_gradient_accuracy(<span class="keywordtype">double</span>);
<a name="l00147"></a>00147     <span class="keyword">virtual</span> <span class="keywordtype">double</span> actual_gradient_accuracy() <span class="keyword">const</span>;
<a name="l00148"></a>00148     <span class="keyword">virtual</span> <span class="keywordtype">double</span> desired_gradient_accuracy() <span class="keyword">const</span>;
<a name="l00149"></a>00149     AccResultRefSCVector&amp; gradient_result() { <span class="keywordflow">return</span> <a class="code" href="classsc_1_1Function.html#ebedf1f0726ee6f6c782ebf81d7d85c1" title="The gradient at x_.">gradient_</a>; }
<a name="l00151"></a>00151 
<a name="l00156"></a>00156     <span class="keyword">virtual</span> RefSymmSCMatrix hessian();
<a name="l00157"></a>00157     <span class="keywordtype">int</span> hessian_needed() <span class="keyword">const</span>;
<a name="l00158"></a>00158     <span class="keywordtype">int</span> do_hessian(<span class="keywordtype">int</span>);
<a name="l00159"></a>00159     <span class="keyword">virtual</span> <span class="keywordtype">void</span> set_desired_hessian_accuracy(<span class="keywordtype">double</span>);
<a name="l00160"></a>00160     <span class="keyword">virtual</span> <span class="keywordtype">double</span> actual_hessian_accuracy() <span class="keyword">const</span>;
<a name="l00161"></a>00161     <span class="keyword">virtual</span> <span class="keywordtype">double</span> desired_hessian_accuracy() <span class="keyword">const</span>;
<a name="l00162"></a>00162     AccResultRefSymmSCMatrix&amp; hessian_result() { <span class="keywordflow">return</span> <a class="code" href="classsc_1_1Function.html#1bf0316e343e945fce55fb7b25a27764" title="The hessian at x_.">hessian_</a>; }
<a name="l00164"></a>00164 
<a name="l00165"></a>00165     <span class="comment">// hessian by gradients at finite displacements</span>
<a name="l00166"></a>00166     <span class="comment">// virtual RefSCMatrix fd1_hessian();</span>
<a name="l00167"></a>00167 
<a name="l00169"></a>00169     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1Function.html#9824774dc9c2539de5237dd43c208e1f" title="Compute a quick, approximate hessian.">guess_hessian</a>(RefSymmSCMatrix&amp;);
<a name="l00170"></a>00170     <span class="keyword">virtual</span> RefSymmSCMatrix inverse_hessian(RefSymmSCMatrix&amp;);
<a name="l00171"></a>00171 
<a name="l00174"></a>00174     <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classsc_1_1Function.html#54f1ed14490ca8bc4658989d6a78c1dc" title="Information about the availability of values, gradients, and hessians.">value_implemented</a>() <span class="keyword">const</span>;
<a name="l00175"></a>00175     <span class="keyword">virtual</span> <span class="keywordtype">int</span> gradient_implemented() <span class="keyword">const</span>;
<a name="l00176"></a>00176     <span class="keyword">virtual</span> <span class="keywordtype">int</span> hessian_implemented() <span class="keyword">const</span>;
<a name="l00177"></a>00177 
<a name="l00179"></a>00179     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1Function.html#aba15d584e7edd3c4ece549da5bd4778" title="Set and retrieve the coordinate values.">set_x</a>(<span class="keyword">const</span> RefSCVector&amp;);
<a name="l00180"></a>00180     RefSCVector get_x()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classsc_1_1Function.html#2a615bead5bd425bd082708f4b2c58c2" title="The variables.">x_</a>.copy(); }
<a name="l00181"></a>00181     <span class="keyword">const</span> RefSCVector&amp; get_x_no_copy()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classsc_1_1Function.html#2a615bead5bd425bd082708f4b2c58c2" title="The variables.">x_</a>; }
<a name="l00182"></a>00182 
<a name="l00189"></a>00189     <span class="keyword">virtual</span> Ref&lt;NonlinearTransform&gt; <a class="code" href="classsc_1_1Function.html#a97727905279ce992e25514f52766c37" title="An optimizer can call change coordinates periodically to give the function an opportunity...">change_coordinates</a>();
<a name="l00190"></a>00190 
<a name="l00192"></a>00192     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1Function.html#cdf2aa8181589c9ce7de5f63afe76402" title="Print information about the object.">print</a>(std::ostream&amp; = <a class="code" href="classsc_1_1ExEnv.html#360216acd1f990e999c0ed46cb350b1f" title="Return an ostream that writes from node 0.">ExEnv::out0</a>()) <span class="keyword">const</span>;
<a name="l00193"></a>00193 };
<a name="l00194"></a>00194 
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 <span class="preprocessor">#endif</span>
<a name="l00198"></a>00198 <span class="preprocessor"></span>
<a name="l00199"></a>00199 <span class="comment">// Local Variables:</span>
<a name="l00200"></a>00200 <span class="comment">// mode: c++</span>
<a name="l00201"></a>00201 <span class="comment">// c-file-style: "CLJ"</span>
<a name="l00202"></a>00202 <span class="comment">// End:</span>
</pre></div></div>
<hr>
<address>
<small>

Generated at Wed Oct 14 14:12:09 2009 for <a
href="http://www.mpqc.org">MPQC</a>
2.3.1 using the documentation package <a
href="http://www.doxygen.org">Doxygen</a>
1.5.9.

</small>
</address>
</body>
</html>