Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > contrib > by-pkgid > 263386785cefb9ae5d63b926d214d809 > files > 1364

mpqc-2.1.2-4mdk.ppc.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta name="robots" content="noindex">
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>storage.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.5 on Mon Oct 14 14:16:38 2002 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>storage.h</h1><div class="fragment"><pre>00001 <font class="comment">//</font>
00002 <font class="comment">// storage.h</font>
00003 <font class="comment">//</font>
00004 <font class="comment">// Copyright (C) 1996 Limit Point Systems, Inc.</font>
00005 <font class="comment">//</font>
00006 <font class="comment">// Author: Curtis Janssen &lt;cljanss@limitpt.com&gt;</font>
00007 <font class="comment">// Maintainer: LPS</font>
00008 <font class="comment">//</font>
00009 <font class="comment">// This file is part of the SC Toolkit.</font>
00010 <font class="comment">//</font>
00011 <font class="comment">// The SC Toolkit is free software; you can redistribute it and/or modify</font>
00012 <font class="comment">// it under the terms of the GNU Library General Public License as published by</font>
00013 <font class="comment">// the Free Software Foundation; either version 2, or (at your option)</font>
00014 <font class="comment">// any later version.</font>
00015 <font class="comment">//</font>
00016 <font class="comment">// The SC Toolkit is distributed in the hope that it will be useful,</font>
00017 <font class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00018 <font class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</font>
00019 <font class="comment">// GNU Library General Public License for more details.</font>
00020 <font class="comment">//</font>
00021 <font class="comment">// You should have received a copy of the GNU Library General Public License</font>
00022 <font class="comment">// along with the SC Toolkit; see the file COPYING.LIB.  If not, write to</font>
00023 <font class="comment">// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.</font>
00024 <font class="comment">//</font>
00025 <font class="comment">// The U.S. Government is granted a limited license as per AL 91-7.</font>
00026 <font class="comment">//</font>
00027 
00028 <font class="preprocessor">#ifndef _chemistry_qc_intv3_storage_h</font>
00029 <font class="preprocessor"></font><font class="preprocessor">#define _chemistry_qc_intv3_storage_h</font>
00030 <font class="preprocessor"></font>
00031 <font class="preprocessor">#ifdef __GNUC__</font>
00032 <font class="preprocessor"></font><font class="preprocessor">#pragma interface</font>
00033 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00034 <font class="preprocessor"></font>
00035 <font class="preprocessor">#ifdef __cplusplus</font>
00036 <font class="preprocessor"></font>
00037 <font class="preprocessor">#include &lt;stddef.h&gt;</font>
00038 <font class="preprocessor">#include &lt;util/class/class.h&gt;</font>
00039 <font class="preprocessor">#include &lt;util/keyval/keyval.h&gt;</font>
00040 <font class="preprocessor">#include &lt;util/container/eavlmmap.h&gt;</font>
00041 
00042 <font class="keyword">namespace </font>sc {
00043 
00044 <font class="comment">// the max shell number is 2^15 (sizeof(int) must be &gt;= 4)</font>
00045 <font class="preprocessor">#define SH_BITS 15 // the number of bits holding a shell index</font>
00046 <font class="preprocessor"></font><font class="preprocessor">#define PE_BITS 1  // the number of bits holding a permutation</font>
00047 <font class="preprocessor"></font>
00048 <font class="preprocessor">#define SH_MASK ((1&lt;&lt;SH_BITS)-1)</font>
00049 <font class="preprocessor"></font><font class="preprocessor">#define PE_MASK ((1&lt;&lt;PE_BITS)-1)</font>
00050 <font class="preprocessor"></font>
00051 <font class="preprocessor">#define SH0_SHIFT 0</font>
00052 <font class="preprocessor"></font><font class="preprocessor">#define SH1_SHIFT (SH_BITS + SH0_SHIFT)</font>
00053 <font class="preprocessor"></font><font class="preprocessor">#define P12_SHIFT (SH_BITS + SH1_SHIFT)</font>
00054 <font class="preprocessor"></font><font class="preprocessor">#define P34_SHIFT (PE_BITS + P12_SHIFT)</font>
00055 <font class="preprocessor"></font><font class="preprocessor">#define SH2_SHIFT 0</font>
00056 <font class="preprocessor"></font><font class="preprocessor">#define SH3_SHIFT (SH_BITS + SH2_SHIFT)</font>
00057 <font class="preprocessor"></font><font class="preprocessor">#define P13P24_SHIFT (SH_BITS + SH3_SHIFT)</font>
00058 <font class="preprocessor"></font><font class="keyword">class </font>IntegralKey {
00059   <font class="keyword">public</font>:
00060     <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> sh0_sh1_p12_p34;
00061     <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> sh2_sh3_p13p24;
00062   <font class="keyword">public</font>:
00063     IntegralKey(<font class="keywordtype">int</font>,<font class="keywordtype">int</font>,<font class="keywordtype">int</font>,<font class="keywordtype">int</font>,<font class="keywordtype">int</font>,<font class="keywordtype">int</font>,<font class="keywordtype">int</font>);
00064     IntegralKey(<font class="keyword">const</font> IntegralKey&amp;);
00065     <font class="keywordtype">int</font> sh0()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> (sh0_sh1_p12_p34&gt;&gt;SH0_SHIFT) &amp; SH_MASK; }
00066     <font class="keywordtype">int</font> sh1()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> (sh0_sh1_p12_p34&gt;&gt;SH1_SHIFT) &amp; SH_MASK; }
00067     <font class="keywordtype">int</font> p12()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> (sh0_sh1_p12_p34&gt;&gt;P12_SHIFT) &amp; PE_MASK; }
00068     <font class="keywordtype">int</font> p34()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> (sh0_sh1_p12_p34&gt;&gt;P34_SHIFT) &amp; PE_MASK; }
00069     <font class="keywordtype">int</font> sh2()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> (sh2_sh3_p13p24&gt;&gt;SH2_SHIFT) &amp; SH_MASK; }
00070     <font class="keywordtype">int</font> sh3()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> (sh2_sh3_p13p24&gt;&gt;SH3_SHIFT) &amp; SH_MASK; }
00071     <font class="keywordtype">int</font> p13p24()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> (sh2_sh3_p13p24&gt;&gt;P13P24_SHIFT) &amp; PE_MASK; }
00072 };
00073 
00074 <font class="keyword">inline</font>
00075 IntegralKey::IntegralKey(<font class="keywordtype">int</font> sh1_, <font class="keywordtype">int</font> sh2_, <font class="keywordtype">int</font> sh3_, <font class="keywordtype">int</font> sh4_,
00076                          <font class="keywordtype">int</font> p12_, <font class="keywordtype">int</font> p34_, <font class="keywordtype">int</font> p13p24_)<font class="keyword"></font>
00077 <font class="keyword"></font>{
00078   sh0_sh1_p12_p34 = (sh1_&lt;&lt;SH0_SHIFT)
00079                     |(sh2_&lt;&lt;SH1_SHIFT)
00080                     |(p12_&lt;&lt;P12_SHIFT)
00081                     |(p34_&lt;&lt;P34_SHIFT);
00082   sh2_sh3_p13p24 = (sh3_&lt;&lt;SH2_SHIFT)
00083                    |(sh4_&lt;&lt;SH3_SHIFT)
00084                    |(p13p24_&lt;&lt;P13P24_SHIFT);
00085 }
00086 
00087 <font class="keyword">inline</font>
00088 IntegralKey::IntegralKey(<font class="keyword">const</font> IntegralKey&amp; ik)<font class="keyword"></font>
00089 <font class="keyword"></font>{
00090   sh0_sh1_p12_p34 = ik.sh0_sh1_p12_p34;
00091   sh2_sh3_p13p24 = ik.sh2_sh3_p13p24;
00092 }
00093 
00094 <font class="keyword">inline</font> <font class="keywordtype">int</font>
00095 compare(<font class="keyword">const</font> IntegralKey&amp;k1, <font class="keyword">const</font> IntegralKey&amp;k2)<font class="keyword"></font>
00096 <font class="keyword"></font>{
00097   <font class="keywordflow">if</font> (k1.sh0_sh1_p12_p34 &lt; k2.sh0_sh1_p12_p34) <font class="keywordflow">return</font> -1;
00098   <font class="keywordflow">else</font> <font class="keywordflow">if</font> (k1.sh0_sh1_p12_p34 &gt; k2.sh0_sh1_p12_p34) <font class="keywordflow">return</font> 1;
00099 
00100   <font class="keywordflow">if</font> (k1.sh2_sh3_p13p24 &lt; k2.sh2_sh3_p13p24) <font class="keywordflow">return</font> -1;
00101   <font class="keywordflow">else</font> <font class="keywordflow">if</font> (k1.sh2_sh3_p13p24 &gt; k2.sh2_sh3_p13p24) <font class="keywordflow">return</font> 1;
00102   <font class="keywordflow">else</font> <font class="keywordflow">return</font> 0;
00103 }
00104 
00105 <font class="keyword">class </font>IntegralLink {
00106   <font class="keyword">public</font>:
00107     EAVLMMapNode&lt;IntegralKey, IntegralLink&gt; intlist;
00108     EAVLMMapNode&lt;int, IntegralLink&gt; costlist;
00109     <font class="keywordtype">int</font> size;
00110   <font class="keyword">public</font>:
00111     IntegralLink(IntegralKey&amp; key, <font class="keywordtype">int</font> cost, <font class="keywordtype">int</font> size);
00112     <font class="keyword">static</font> <font class="keywordtype">int</font> size_to_actualsize(<font class="keywordtype">int</font> size);
00113     ~IntegralLink();
00114     <font class="keywordtype">int</font> actualsize() <font class="keyword">const</font>;
00115     <font class="keywordtype">int</font> hash() <font class="keyword">const</font>;
00116     <font class="keyword">static</font> <font class="keywordtype">int</font> shells_to_hash(<font class="keywordtype">int</font>,<font class="keywordtype">int</font>,<font class="keywordtype">int</font>,<font class="keywordtype">int</font>);
00117     <font class="keywordtype">int</font> cost()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> costlist.key; }
00118     <font class="keywordtype">void</font> print();
00119 
00120     <font class="comment">// the integrals are squirreled away after this</font>
00121     <font class="keywordtype">double</font>* buffer()<font class="keyword"> </font>{ <font class="keywordflow">return</font> (<font class="keywordtype">double</font>*)&amp;<font class="keyword">this</font>[1]; }
00122     <font class="keywordtype">void</font>* operator new(size_t, <font class="keywordtype">int</font>);
00123     <font class="keywordtype">void</font> operator delete(<font class="keywordtype">void</font>*, <font class="keywordtype">int</font>);
00124     <font class="keywordtype">void</font> operator delete(<font class="keywordtype">void</font>*);
00125 };
00126 
00127 <font class="keyword">inline</font> <font class="keywordtype">int</font>
00128 IntegralLink::shells_to_hash(<font class="keywordtype">int</font> sh1,<font class="keywordtype">int</font> sh2,<font class="keywordtype">int</font> sh3,<font class="keywordtype">int</font> sh4)<font class="keyword"></font>
00129 <font class="keyword"></font>{
00130   <font class="keywordflow">return</font> sh1 ^ (sh4&lt;&lt;4) ^ (sh2&lt;&lt;8) ^ (sh3&lt;&lt;12);
00131 }
00132 
00133 <font class="keyword">inline</font> <font class="keywordtype">int</font>
00134 IntegralLink::hash()<font class="keyword"> const</font>
00135 <font class="keyword"></font>{
00136   <font class="keywordflow">return</font> shells_to_hash(intlist.key.sh0(),
00137                         intlist.key.sh1(),
00138                         intlist.key.sh2(),
00139                         intlist.key.sh3());
00140 }
00141 
00142 <font class="keyword">inline</font> <font class="keywordtype">int</font>
00143 IntegralLink::size_to_actualsize(<font class="keywordtype">int</font> size)<font class="keyword"></font>
00144 <font class="keyword"></font>{
00145   <font class="keywordflow">return</font> size*<font class="keyword">sizeof</font>(<font class="keywordtype">double</font>) + <font class="keyword">sizeof</font>(IntegralLink) + <font class="keyword">sizeof</font>(<font class="keywordtype">void</font>*)*2;
00146 }
00147 
00148 <font class="keyword">inline</font> <font class="keywordtype">int</font>
00149 IntegralLink::actualsize()<font class="keyword"> const</font>
00150 <font class="keyword"></font>{
00151   <font class="keywordflow">return</font> size_to_actualsize(size);
00152 }
00153 
00154 <font class="keyword">class </font>IntegralStorer: <font class="keyword">public</font> DescribedClass {
00155   <font class="keyword">private</font>:
00156     <font class="keywordtype">int</font> table_size_;
00157     EAVLMMap&lt;int,IntegralLink&gt; costlist;
00158     EAVLMMap&lt;IntegralKey,IntegralLink&gt;* table_;
00159     <font class="keywordtype">int</font> maxsize_;
00160     <font class="keywordtype">int</font> currentsize_;
00161     <font class="keywordtype">int</font> n_integrals_;
00162     <font class="keywordtype">int</font> n_shellquart_;
00163   <font class="keyword">public</font>:
00164     IntegralStorer();
00165     IntegralStorer(<font class="keyword">const</font> Ref&lt;KeyVal&gt;&amp;);
00166     ~IntegralStorer();
00167     <font class="keywordtype">void</font> init(<font class="keywordtype">int</font> nbytes);
00168     <font class="keywordtype">void</font> done();
00169     IntegralLink *find(IntegralKey&amp;);
00170     <font class="keywordtype">int</font> should_store(<font class="keywordtype">int</font> cost, <font class="keywordtype">int</font> actualsize);
00171     <font class="keywordtype">void</font> store(IntegralKey&amp; key, <font class="keyword">const</font> <font class="keywordtype">double</font> *buf,
00172                <font class="keywordtype">int</font> size, <font class="keywordtype">int</font> cost, <font class="keywordtype">int</font> actualsize);
00173     <font class="keywordtype">void</font> print_stats();
00174     <font class="keywordtype">int</font> table_size()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> table_size_; }
00175 };
00176 
00177 }
00178 
00179 <font class="preprocessor">#endif</font>
00180 <font class="preprocessor"></font>
00181 <font class="preprocessor">#endif</font>
00182 <font class="preprocessor"></font>
00183 <font class="comment">// Local Variables:</font>
00184 <font class="comment">// mode: c++</font>
00185 <font class="comment">// c-file-style: "CLJ"</font>
00186 <font class="comment">// End:</font>
</div></pre><hr>
<address>
<small>

Generated at Mon Oct 14 14:16:38 2002 for <a
href="http://aros.ca.sandia.gov/~cljanss/mpqc">MPQC</a>
2.1.2 using the documentation package <a
href="http://www.stack.nl/~dimitri/doxygen/index.html">Doxygen</a>
1.2.5.

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