Sophie

Sophie

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

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>mops.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>mops.h</h1><div class="fragment"><pre>00001 <font class="comment">//</font>
00002 <font class="comment">// mops.h --- block matrix operations</font>
00003 <font class="comment">//</font>
00004 <font class="comment">// Copyright (C) 1997 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 _math_scmat_mops_h</font>
00029 <font class="preprocessor"></font><font class="preprocessor">#define _math_scmat_mops_h</font>
00030 <font class="preprocessor"></font>
00031 <font class="preprocessor">#define D1 32</font>
00032 <font class="preprocessor"></font>
00033 <font class="comment">// copy a chunk of rectangular matrix source into dest.  dest is D1xD1, and is</font>
00034 <font class="comment">// padded with zeros</font>
00035 
00036 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font>
00037 copy_block(<font class="keywordtype">double</font> **dest, <font class="keywordtype">double</font> **source,
00038            <font class="keywordtype">int</font> istart, <font class="keywordtype">int</font> ni, <font class="keywordtype">int</font> jstart, <font class="keywordtype">int</font> nj)<font class="keyword"></font>
00039 <font class="keyword"></font>{
00040   <font class="keywordtype">int</font> ii,jj;
00041   
00042   <font class="keywordflow">for</font> (ii=0; ii &lt; ni; ii++) {
00043     <font class="keywordtype">double</font> *di = dest[ii];
00044     <font class="keywordtype">double</font> *si = &amp;source[istart+ii][jstart];
00045     <font class="keywordflow">for</font> (jj=0; jj &lt; nj; jj++)
00046       di[jj] = si[jj];
00047     <font class="keywordflow">for</font> (; jj &lt; D1; jj++)
00048       di[jj] = 0;
00049   }
00050 
00051   <font class="keywordtype">int</font> left=D1-ii;
00052   <font class="keywordflow">if</font> (left)
00053     memset(dest[ii], 0, <font class="keyword">sizeof</font>(<font class="keywordtype">double</font>)*left*D1);
00054 }
00055 
00056 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font>
00057 copy_trans_block(<font class="keywordtype">double</font> **dest, <font class="keywordtype">double</font> **source,
00058                  <font class="keywordtype">int</font> istart, <font class="keywordtype">int</font> ni, <font class="keywordtype">int</font> jstart, <font class="keywordtype">int</font> nj)<font class="keyword"></font>
00059 <font class="keyword"></font>{
00060   <font class="keywordtype">int</font> ii,jj;
00061   
00062   memset(dest[0], 0, <font class="keyword">sizeof</font>(<font class="keywordtype">double</font>)*D1*D1);
00063 
00064   <font class="keywordflow">for</font> (jj=0; jj &lt; nj; jj++) {
00065     <font class="keywordtype">double</font> *sj = &amp;source[jstart+jj][istart];
00066     <font class="keywordflow">for</font> (ii=0; ii &lt; ni; ii++)
00067       dest[ii][jj] = sj[ii];
00068   }
00069 }
00070 
00071 <font class="comment">// copy a chunk of symmetric matrix source into dest.  dest is D1xD1, and is</font>
00072 <font class="comment">// padded with zeros</font>
00073 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font>
00074 copy_sym_block(<font class="keywordtype">double</font> **dest, <font class="keywordtype">double</font> **source,
00075                <font class="keywordtype">int</font> istart, <font class="keywordtype">int</font> ni, <font class="keywordtype">int</font> jstart, <font class="keywordtype">int</font> nj)<font class="keyword"></font>
00076 <font class="keyword"></font>{
00077   <font class="keywordtype">int</font> ii,jj;
00078 
00079   <font class="keywordflow">for</font> (ii=0; ii &lt; ni; ii++) {
00080     <font class="keywordtype">double</font> *di = dest[ii];
00081     <font class="keywordtype">double</font> *si = &amp;source[istart+ii][jstart];
00082     
00083     <font class="keywordflow">if</font> (jstart &lt; istart)
00084       <font class="keywordflow">for</font> (jj=0; jj &lt; nj; jj++)
00085         di[jj] = si[jj];
00086     <font class="keywordflow">else</font> <font class="keywordflow">if</font> (jstart==istart)
00087       <font class="keywordflow">for</font> (jj=0; jj &lt;= ii; jj++)
00088         di[jj] = dest[jj][ii] = si[jj];
00089     <font class="keywordflow">else</font>
00090       <font class="keywordflow">for</font> (jj=0; jj &lt; nj; jj++)
00091         di[jj] = source[jstart+jj][istart+ii];
00092 
00093     <font class="keywordflow">for</font> (jj=nj; jj &lt; D1; jj++)
00094       di[jj] = 0;
00095   }
00096 
00097   <font class="keywordtype">int</font> left=D1-ii;
00098   <font class="keywordflow">if</font> (left)
00099     memset(dest[ii], 0, <font class="keyword">sizeof</font>(<font class="keywordtype">double</font>)*left*D1);
00100 }
00101 
00102 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font>
00103 return_block(<font class="keywordtype">double</font> **dest, <font class="keywordtype">double</font> **source,
00104              <font class="keywordtype">int</font> istart, <font class="keywordtype">int</font> ni, <font class="keywordtype">int</font> jstart, <font class="keywordtype">int</font> nj)<font class="keyword"></font>
00105 <font class="keyword"></font>{
00106   <font class="keywordtype">int</font> ii,jj;
00107 
00108   <font class="keywordflow">for</font> (ii=0; ii &lt; ni; ii++)
00109     <font class="keywordflow">for</font> (jj=0; jj &lt; nj; jj++)
00110       dest[istart+ii][jstart+jj] = source[ii][jj];
00111 }
00112 
00113 <font class="comment">// a, b, and c are all D1xD1 blocks</font>
00114 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font>
00115 mult_block(<font class="keywordtype">double</font> **a, <font class="keywordtype">double</font> **b, <font class="keywordtype">double</font> **c, <font class="keywordtype">int</font> ni, <font class="keywordtype">int</font> nj, <font class="keywordtype">int</font> nk)<font class="keyword"></font>
00116 <font class="keyword"></font>{
00117   <font class="keywordtype">int</font> ii,jj,kk;
00118   <font class="keywordtype">double</font> t00,t10,t20,t30;
00119   <font class="keywordtype">double</font> *a0, *a1, *a2, *a3;
00120   <font class="keywordtype">double</font> *c0, *c1, *c2, *c3;
00121 
00122   <font class="keywordflow">for</font> (ii=0; ii &lt; ni; ii += 4) {
00123     a0=a[ii]; a1=a[ii+1]; a2=a[ii+2]; a3=a[ii+3];
00124     c0=c[ii]; c1=c[ii+1]; c2=c[ii+2]; c3=c[ii+3];
00125 
00126     <font class="keywordflow">for</font> (jj=0; jj &lt; nj; jj++) {
00127       <font class="keywordtype">double</font> *bt = b[jj];
00128       t00=c0[jj]; t10=c1[jj]; t20=c2[jj]; t30=c3[jj];
00129 
00130       <font class="keywordflow">for</font> (kk=0; kk &lt; nk; kk += 2) {
00131         <font class="keyword">register</font> <font class="keywordtype">double</font> b0=bt[kk], b1=bt[kk+1];
00132         t00 += a0[kk]*b0 + a0[kk+1]*b1;
00133         t10 += a1[kk]*b0 + a1[kk+1]*b1;
00134         t20 += a2[kk]*b0 + a2[kk+1]*b1;
00135         t30 += a3[kk]*b0 + a3[kk+1]*b1;
00136       }
00137 
00138       c0[jj]=t00;
00139       c1[jj]=t10;
00140       c2[jj]=t20;
00141       c3[jj]=t30;
00142     }
00143   }
00144 }
00145 
00146 <font class="preprocessor">#endif</font>
00147 <font class="preprocessor"></font>
00148 <font class="comment">// Local Variables:</font>
00149 <font class="comment">// mode: c++</font>
00150 <font class="comment">// c-file-style: "ETS"</font>
00151 <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>