Sophie

Sophie

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

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>lbgbuild.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:37 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>lbgbuild.h</h1><div class="fragment"><pre>00001 <font class="comment">//</font>
00002 <font class="comment">// lbgbuild.h --- definitino of the load-balanced local G matrix builder</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: Edward Seidl &lt;seidl@janed.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_scf_lbgbuild_h</font>
00029 <font class="preprocessor"></font><font class="preprocessor">#define _chemistry_qc_scf_lbgbuild_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">#include &lt;chemistry/qc/scf/gbuild.h&gt;</font>
00036 
00037 <font class="keyword">namespace </font>sc {
00038 
00039 template&lt;class T&gt;
00040 <font class="keyword">class </font>LocalLBGBuild : <font class="keyword">public</font> GBuild&lt;T&gt; {
00041   <font class="keyword">protected</font>:
00042     Ref&lt;MessageGrp&gt; grp_;
00043     Ref&lt;TwoBodyInt&gt; tbi_;
00044     Ref&lt;Integral&gt; integral_;
00045     Ref&lt;GaussianBasisSet&gt; gbs_;
00046     <font class="keywordtype">signed</font> <font class="keywordtype">char</font> *pmax;
00047     
00048   <font class="keyword">public</font>:
00049     LocalLBGBuild(T&amp; t, <font class="keyword">const</font> Ref&lt;TwoBodyInt&gt;&amp; tbi, <font class="keyword">const</font> Ref&lt;Integral&gt;&amp; ints,
00050                 <font class="keyword">const</font> Ref&lt;GaussianBasisSet&gt;&amp; bs, <font class="keyword">const</font> Ref&lt;MessageGrp&gt;&amp; g,
00051                 <font class="keywordtype">signed</font> <font class="keywordtype">char</font> *pm) :
00052       GBuild&lt;T&gt;(t), grp_(g), tbi_(tbi), integral_(ints), gbs_(bs), pmax(pm) {}
00053     ~LocalLBGBuild()<font class="keyword"> </font>{}
00054 
00055     <font class="keywordtype">void</font> build_gmat(<font class="keywordtype">double</font> accuracy)<font class="keyword"> </font>{
00056       tim_enter(<font class="stringliteral">"ao_gmat"</font>);
00057       tim_set_default(<font class="stringliteral">"quartet"</font>);
00058 
00059       <font class="keywordtype">double</font> tnint=0;
00060       <font class="keywordtype">int</font> tol = (<font class="keywordtype">int</font>) (log(accuracy)/log(2.0));
00061       <font class="keywordtype">int</font> me=grp_-&gt;me();
00062       <font class="keywordtype">int</font> nproc = grp_-&gt;n();
00063   
00064       Ref&lt;PetiteList&gt; rpl = integral_-&gt;petite_list();
00065   
00066       <font class="comment">// grab references for speed</font>
00067       GaussianBasisSet&amp; gbs = *gbs_.pointer();
00068       PetiteList&amp; pl = *rpl.pointer();
00069       TwoBodyInt&amp; tbi = *tbi_.pointer();
00070 
00071       tbi.set_redundant(0);
00072       <font class="keyword">const</font> <font class="keywordtype">double</font> *intbuf = tbi.buffer();
00073 
00074       <font class="keywordtype">int</font> inds[4];
00075 
00076       <font class="comment">// node zero passes out indices</font>
00077       <font class="keywordflow">if</font> (me==0) {
00078         <font class="keywordtype">int</font> i;
00079         <font class="keywordflow">for</font> (i=0; i &lt; gbs.nshell(); i++) {
00080           <font class="keywordflow">if</font> (!pl.in_p1(i))
00081             <font class="keywordflow">continue</font>;
00082 
00083           inds[0]=i;
00084           
00085           <font class="keywordflow">for</font> (<font class="keywordtype">int</font> j=0; j &lt;= i; j++) {
00086             <font class="keywordtype">int</font> oij = i_offset(i)+j;
00087           
00088             <font class="keywordflow">if</font> (!pl.in_p2(oij))
00089               <font class="keywordflow">continue</font>;
00090             
00091             inds[1]=j;
00092 
00093             tim_enter_default();
00094             <font class="keywordtype">int</font> from;
00095             grp_-&gt;recvt(2323, &amp;from, 1);
00096             grp_-&gt;sendt(from, 3232, inds, 4);
00097             tim_exit_default();
00098           }
00099         }
00100 
00101         <font class="comment">// now clean up</font>
00102         inds[0] = inds[1] = inds[2] = inds[3] = -1;
00103         
00104         <font class="keywordflow">for</font> (i=1; i &lt; nproc; i++) {
00105           <font class="keywordtype">int</font> from;
00106           grp_-&gt;recvt(2323, &amp;from, 1);
00107           grp_-&gt;sendt(from, 3232, inds, 4);
00108         }
00109       }
00110       
00111       <font class="comment">// all other nodes do the work</font>
00112       <font class="keywordflow">else</font> {
00113         <font class="keywordflow">do</font> {
00114           grp_-&gt;sendt(0, 2323, &amp;me, 1);
00115           grp_-&gt;recvt(3232, inds, 4);
00116 
00117           <font class="keywordtype">int</font> i=inds[0];
00118           <font class="keywordtype">int</font> j=inds[1];
00119           
00120           <font class="keywordflow">if</font> (i &lt; 0)
00121             <font class="keywordflow">break</font>;
00122           
00123           <font class="keywordtype">int</font> fi=gbs.shell_to_function(i);
00124           <font class="keywordtype">int</font> ni=gbs(i).nfunction();
00125         
00126           <font class="keywordtype">int</font> oij = i_offset(i)+j;
00127           
00128           <font class="keywordtype">int</font> fj=gbs.shell_to_function(j);
00129           <font class="keywordtype">int</font> nj=gbs(j).nfunction();
00130           <font class="keywordtype">int</font> pmaxij = pmax[oij];
00131 
00132           <font class="keywordflow">for</font> (<font class="keywordtype">int</font> k=0; k &lt;= i; k++) {
00133           <font class="keywordtype">int</font> fk=gbs.shell_to_function(k);
00134           <font class="keywordtype">int</font> nk=gbs(k).nfunction();
00135 
00136           <font class="keywordtype">int</font> pmaxijk=pmaxij, ptmp;
00137           <font class="keywordflow">if</font> ((ptmp=pmax[i_offset(i)+k]-2) &gt; pmaxijk) pmaxijk=ptmp;
00138           <font class="keywordflow">if</font> ((ptmp=pmax[ij_offset(j,k)]-2) &gt; pmaxijk) pmaxijk=ptmp;
00139         
00140           <font class="keywordtype">int</font> okl = i_offset(k);
00141           <font class="keywordflow">for</font> (<font class="keywordtype">int</font> l=0; l &lt;= (k==i?j:k); l++,okl++) {
00142             
00143             <font class="keywordtype">int</font> pmaxijkl = pmaxijk;
00144             <font class="keywordflow">if</font> ((ptmp=pmax[okl]) &gt; pmaxijkl) pmaxijkl=ptmp;
00145             <font class="keywordflow">if</font> ((ptmp=pmax[i_offset(i)+l]-2) &gt; pmaxijkl) pmaxijkl=ptmp;
00146             <font class="keywordflow">if</font> ((ptmp=pmax[ij_offset(j,l)]-2) &gt; pmaxijkl) pmaxijkl=ptmp;
00147               
00148 
00149             <font class="keywordflow">if</font> (tbi.log2_shell_bound(i,j,k,l)+pmaxijkl &lt; tol)
00150               <font class="keywordflow">continue</font>;
00151 
00152             <font class="keywordtype">int</font> qijkl = pl.in_p4(oij,okl,i,j,k,l);
00153             <font class="keywordflow">if</font> (!qijkl)
00154               <font class="keywordflow">continue</font>;
00155 
00156             tim_enter_default();
00157             tbi.compute_shell(i,j,k,l);
00158             tim_exit_default();
00159 
00160             <font class="keywordtype">int</font> e12 = (i==j);
00161             <font class="keywordtype">int</font> e34 = (k==l);
00162             <font class="keywordtype">int</font> e13e24 = (i==k) &amp;&amp; (j==l);
00163             <font class="keywordtype">int</font> e_any = e12||e34||e13e24;
00164     
00165             <font class="keywordtype">int</font> fl=gbs.shell_to_function(l);
00166             <font class="keywordtype">int</font> nl=gbs(l).nfunction();
00167      
00168             <font class="keywordtype">int</font> ii,jj,kk,ll;
00169             <font class="keywordtype">int</font> I,J,K,L;
00170             <font class="keywordtype">int</font> index=0;
00171 
00172             <font class="keywordflow">for</font> (I=0, ii=fi; I &lt; ni; I++, ii++) {
00173               <font class="keywordflow">for</font> (J=0, jj=fj; J &lt;= (e12 ? I : nj-1); J++, jj++) {
00174                 <font class="keywordflow">for</font> (K=0, kk=fk; K &lt;= (e13e24 ? I : nk-1); K++, kk++) {
00175            
00176                   <font class="keywordtype">int</font> lend = (e34 ? ((e13e24)&amp;&amp;(K==I) ? J : K)
00177                               : ((e13e24)&amp;&amp;(K==I)) ? J : nl-1);
00178                   <font class="keywordflow">for</font> (L=0, ll=fl; L &lt;= lend; L++, ll++, index++) {
00179                     <font class="keywordtype">double</font> pki_int = intbuf[index];
00180 
00181                     <font class="keywordflow">if</font> ((pki_int&gt;0?pki_int:-pki_int) &lt; 1.0e-15)
00182                       <font class="keywordflow">continue</font>;
00183 
00184                     <font class="keywordflow">if</font> (qijkl &gt; 1)
00185                       pki_int *= qijkl;
00186 
00187       <font class="keywordflow">if</font> (e_any) {
00188         <font class="keywordtype">int</font> ij,kl;
00189         <font class="keywordtype">double</font> val;
00190 
00191         <font class="keywordflow">if</font> (jj == kk) {
00192           <font class="comment">/*</font>
00193 <font class="comment">           * if i=j=k or j=k=l, then this integral contributes</font>
00194 <font class="comment">           * to J, K1, and K2 of G(ij), so</font>
00195 <font class="comment">           * pkval = (ijkl) - 0.25 * ((ikjl)-(ilkj))</font>
00196 <font class="comment">           *       = 0.5 * (ijkl)</font>
00197 <font class="comment">           */</font>
00198           <font class="keywordflow">if</font> (ii == jj || kk == ll) {
00199             ij = i_offset(ii)+jj;
00200             kl = i_offset(kk)+ll;
00201             val = (ij==kl) ? 0.5*pki_int : pki_int;
00202 
00203             contribution.cont5(ij,kl,val);
00204 
00205           } <font class="keywordflow">else</font> {
00206             <font class="comment">/*</font>
00207 <font class="comment">             * if j=k, then this integral contributes</font>
00208 <font class="comment">             * to J and K1 of G(ij)</font>
00209 <font class="comment">             *</font>
00210 <font class="comment">             * pkval = (ijkl) - 0.25 * (ikjl)</font>
00211 <font class="comment">             *       = 0.75 * (ijkl)</font>
00212 <font class="comment">             */</font>
00213             ij = i_offset(ii)+jj;
00214             kl = i_offset(kk)+ll;
00215             val = (ij==kl) ? 0.5*pki_int : pki_int;
00216             
00217             contribution.cont4(ij,kl,val);
00218 
00219             <font class="comment">/*</font>
00220 <font class="comment">             * this integral also contributes to K1 and K2 of</font>
00221 <font class="comment">             * G(il)</font>
00222 <font class="comment">             *</font>
00223 <font class="comment">             * pkval = -0.25 * ((ijkl)+(ikjl))</font>
00224 <font class="comment">             *       = -0.5 * (ijkl)</font>
00225 <font class="comment">             */</font>
00226             ij = ij_offset(ii,ll);
00227             kl = ij_offset(kk,jj);
00228             val = (ij==kl) ? 0.5*pki_int : pki_int;
00229             
00230             contribution.cont3(ij,kl,val);
00231           }
00232         } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (ii == kk || jj == ll) {
00233           <font class="comment">/*</font>
00234 <font class="comment">           * if i=k or j=l, then this integral contributes</font>
00235 <font class="comment">           * to J and K2 of G(ij)</font>
00236 <font class="comment">           *</font>
00237 <font class="comment">           * pkval = (ijkl) - 0.25 * (ilkj)</font>
00238 <font class="comment">           *       = 0.75 * (ijkl)</font>
00239 <font class="comment">           */</font>
00240           ij = i_offset(ii)+jj;
00241           kl = i_offset(kk)+ll;
00242           val = (ij==kl) ? 0.5*pki_int : pki_int;
00243 
00244           contribution.cont4(ij,kl,val);
00245 
00246           <font class="comment">/*</font>
00247 <font class="comment">           * this integral also contributes to K1 and K2 of</font>
00248 <font class="comment">           * G(ik)</font>
00249 <font class="comment">           *</font>
00250 <font class="comment">           * pkval = -0.25 * ((ijkl)+(ilkj))</font>
00251 <font class="comment">           *       = -0.5 * (ijkl)</font>
00252 <font class="comment">           */</font>
00253           ij = ij_offset(ii,kk);
00254           kl = ij_offset(jj,ll);
00255           val = (ij==kl) ? 0.5*pki_int : pki_int;
00256 
00257           contribution.cont3(ij,kl,val);
00258 
00259         } <font class="keywordflow">else</font> {
00260           <font class="comment">/*</font>
00261 <font class="comment">           * This integral contributes to J of G(ij)</font>
00262 <font class="comment">           *</font>
00263 <font class="comment">           * pkval = (ijkl)</font>
00264 <font class="comment">           */</font>
00265           ij = i_offset(ii)+jj;
00266           kl = i_offset(kk)+ll;
00267           val = (ij==kl) ? 0.5*pki_int : pki_int;
00268 
00269           contribution.cont1(ij,kl,val);
00270 
00271           <font class="comment">/*</font>
00272 <font class="comment">           * and to K1 of G(ik)</font>
00273 <font class="comment">           *</font>
00274 <font class="comment">           * pkval = -0.25 * (ijkl)</font>
00275 <font class="comment">           */</font>
00276           ij = ij_offset(ii,kk);
00277           kl = ij_offset(jj,ll);
00278           val = (ij==kl) ? 0.5*pki_int : pki_int;
00279 
00280           contribution.cont2(ij,kl,val);
00281 
00282           <font class="keywordflow">if</font> ((ii != jj) &amp;&amp; (kk != ll)) {
00283             <font class="comment">/*</font>
00284 <font class="comment">             * if i!=j and k!=l, then this integral also</font>
00285 <font class="comment">             * contributes to K2 of G(il)</font>
00286 <font class="comment">             *</font>
00287 <font class="comment">             * pkval = -0.25 * (ijkl)</font>
00288 <font class="comment">             *</font>
00289 <font class="comment">             * note: if we get here, then ik can't equal jl,</font>
00290 <font class="comment">             * so pkval wasn't multiplied by 0.5 above.</font>
00291 <font class="comment">             */</font>
00292             ij = ij_offset(ii,ll);
00293             kl = ij_offset(kk,jj);
00294 
00295             contribution.cont2(ij,kl,val);
00296           }
00297         }
00298       } <font class="keywordflow">else</font> { <font class="comment">// !e_any</font>
00299         <font class="keywordflow">if</font> (jj == kk) {
00300           <font class="comment">/*</font>
00301 <font class="comment">           * if j=k, then this integral contributes</font>
00302 <font class="comment">           * to J and K1 of G(ij)</font>
00303 <font class="comment">           *</font>
00304 <font class="comment">           * pkval = (ijkl) - 0.25 * (ikjl)</font>
00305 <font class="comment">           *       = 0.75 * (ijkl)</font>
00306 <font class="comment">           */</font>
00307           contribution.cont4(i_offset(ii)+jj,i_offset(kk)+ll,pki_int);
00308 
00309           <font class="comment">/*</font>
00310 <font class="comment">           * this integral also contributes to K1 and K2 of</font>
00311 <font class="comment">           * G(il)</font>
00312 <font class="comment">           *</font>
00313 <font class="comment">           * pkval = -0.25 * ((ijkl)+(ikjl))</font>
00314 <font class="comment">           *       = -0.5 * (ijkl)</font>
00315 <font class="comment">           */</font>
00316           contribution.cont3(ij_offset(ii,ll),ij_offset(kk,jj),pki_int);
00317 
00318         } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (ii == kk || jj == ll) {
00319           <font class="comment">/*</font>
00320 <font class="comment">           * if i=k or j=l, then this integral contributes</font>
00321 <font class="comment">           * to J and K2 of G(ij)</font>
00322 <font class="comment">           *</font>
00323 <font class="comment">           * pkval = (ijkl) - 0.25 * (ilkj)</font>
00324 <font class="comment">           *       = 0.75 * (ijkl)</font>
00325 <font class="comment">           */</font>
00326           contribution.cont4(i_offset(ii)+jj,i_offset(kk)+ll,pki_int);
00327 
00328           <font class="comment">/*</font>
00329 <font class="comment">           * this integral also contributes to K1 and K2 of</font>
00330 <font class="comment">           * G(ik)</font>
00331 <font class="comment">           *</font>
00332 <font class="comment">           * pkval = -0.25 * ((ijkl)+(ilkj))</font>
00333 <font class="comment">           *       = -0.5 * (ijkl)</font>
00334 <font class="comment">           */</font>
00335           contribution.cont3(ij_offset(ii,kk),ij_offset(jj,ll),pki_int);
00336 
00337         } <font class="keywordflow">else</font> {
00338           <font class="comment">/*</font>
00339 <font class="comment">           * This integral contributes to J of G(ij)</font>
00340 <font class="comment">           *</font>
00341 <font class="comment">           * pkval = (ijkl)</font>
00342 <font class="comment">           */</font>
00343           contribution.cont1(i_offset(ii)+jj,i_offset(kk)+ll,pki_int);
00344 
00345           <font class="comment">/*</font>
00346 <font class="comment">           * and to K1 of G(ik)</font>
00347 <font class="comment">           *</font>
00348 <font class="comment">           * pkval = -0.25 * (ijkl)</font>
00349 <font class="comment">           */</font>
00350           contribution.cont2(ij_offset(ii,kk),ij_offset(jj,ll),pki_int);
00351 
00352           <font class="comment">/*</font>
00353 <font class="comment">           * and to K2 of G(il)</font>
00354 <font class="comment">           *</font>
00355 <font class="comment">           * pkval = -0.25 * (ijkl)</font>
00356 <font class="comment">           */</font>
00357           contribution.cont2(ij_offset(ii,ll),ij_offset(kk,jj),pki_int);
00358         }
00359       }
00360                   }
00361                 }
00362               }
00363             }
00364 
00365             tnint += (<font class="keywordtype">double</font>) ni*nj*nk*nl;
00366           }
00367           }
00368         } <font class="keywordflow">while</font> (inds[0] &gt; -1);
00369       }
00370 
00371       grp_-&gt;sum(&amp;tnint, 1, 0, 0);
00372       ExEnv::out0() &lt;&lt; indent &lt;&lt; scprintf(<font class="stringliteral">"%20.0f integrals\n"</font>, tnint);
00373 
00374       tim_exit(<font class="stringliteral">"ao_gmat"</font>);
00375     }
00376     
00377 };
00378 
00379 }
00380 
00381 <font class="preprocessor">#endif</font>
00382 <font class="preprocessor"></font>
00383 <font class="comment">// Local Variables:</font>
00384 <font class="comment">// mode: c++</font>
00385 <font class="comment">// c-file-style: "ETS"</font>
00386 <font class="comment">// End:</font>
</div></pre><hr>
<address>
<small>

Generated at Mon Oct 14 14:16:37 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>