Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > ff8e7344076b5fbaa54d805766a057bd > files > 23

libscs-devel-1.4.1-4.fc15.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>poly_fct.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; </center>
<hr><h1>poly_fct.c</h1><div class="fragment"><pre>00001 <font class="comment">/*</font>
00002 <font class="comment"> * Author  : Defour David</font>
00003 <font class="comment"> * Contact : David.Defour@ens-lyon.fr</font>
00004 <font class="comment"> *</font>
00005 <font class="comment"> * This program is free software; you can redistribute it and/or modify</font>
00006 <font class="comment"> * it under the terms of the GNU Lesser General Public License as published by</font>
00007 <font class="comment"> * the Free Software Foundation; either version 2 of the License, or </font>
00008 <font class="comment"> * (at your option) any later version.</font>
00009 <font class="comment"> * </font>
00010 <font class="comment"> * This program is distributed in the hope that it will be useful,</font>
00011 <font class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00012 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</font>
00013 <font class="comment"> * GNU General Public License for more details.</font>
00014 <font class="comment"> *</font>
00015 <font class="comment"> * You should have received a copy of the GNU Lesser General Public License</font>
00016 <font class="comment"> * along with this program; if not, write to the Free Software</font>
00017 <font class="comment"> * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  </font>
00018 <font class="comment"> */</font>
00019 <font class="preprocessor">#include "<a class="code" href="scs_8h.html">scs.h</a>"</font>
00020 <font class="preprocessor">#include "<a class="code" href="scs__private_8h.html">scs_private.h</a>"</font>
00021 
00022 
00023 <font class="comment">/*</font>
00024 <font class="comment"> * result = z + (x * y)</font>
00025 <font class="comment"> */</font>
00026 <font class="comment">/* z-&gt;sign = X_SGN . Y_SGN */</font>
00027 <font class="keywordtype">void</font> scs_fma(<a class="code" href="structscs.html">scs_ptr</a> result,  <a class="code" href="structscs.html">scs_ptr</a> x,  <a class="code" href="structscs.html">scs_ptr</a> y,  <a class="code" href="structscs.html">scs_ptr</a> z){
00028   <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <font class="keywordtype">long</font> <font class="keywordtype">int</font> RES[2*SCS_NB_WORDS];
00029   <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <font class="keywordtype">long</font> <font class="keywordtype">int</font> val, tmp;
00030   <font class="keywordtype">int</font> i, j, ind, Diff;    
00031 
00032   ind = X_IND + Y_IND; 
00033 
00034   <font class="keywordflow">for</font>(i=0; i&lt;=SCS_NB_WORDS+1; i++)
00035     RES[i]=0;
00036   
00037   <font class="keywordflow">for</font>(i=0 ; i&lt;SCS_NB_WORDS; i++){
00038     <font class="keywordflow">for</font>(j=0; j&lt;(SCS_NB_WORDS-i); j++){
00039       RES[i+j] += (<font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <font class="keywordtype">long</font> <font class="keywordtype">int</font>)X_HW[i] * Y_HW[j];
00040     }}
00041 
00042   <font class="comment">/* if we can perform an add */</font>
00043   <font class="keywordflow">if</font> (z-&gt;<a class="code" href="structscs.html#m3">sign</a> == (X_SGN * Y_SGN)){
00044     Diff = z-&gt;<a class="code" href="structscs.html#m2">index</a> - ind;
00045     <font class="keywordflow">if</font> (Diff &gt;= 0){
00046       <font class="keywordflow">for</font>(i=(SCS_NB_WORDS-1), j=(SCS_NB_WORDS-Diff); j&gt;=0; i--, j--)
00047         RES[i] = z-&gt;<a class="code" href="structscs.html#m0">h_word</a>[i] + RES[j];     
00048       <font class="keywordflow">for</font>(  ; i&gt;=0; i--)
00049         RES[i] = z-&gt;<a class="code" href="structscs.html#m0">h_word</a>[i]; 
00050     }<font class="keywordflow">else</font> {    
00051       <font class="keywordflow">for</font>(i=(SCS_NB_WORDS+Diff), j=(SCS_NB_WORDS-1); i&gt;=0; i--, j--)
00052         RES[j] = z-&gt;<a class="code" href="structscs.html#m0">h_word</a>[i] + RES[j];     
00053     }
00054 
00055     <font class="comment">/* Carry propagate */</font>
00056     RES[SCS_NB_WORDS-1] += (RES[SCS_NB_WORDS]&gt;&gt;SCS_NB_BITS);
00057     <font class="keywordflow">for</font>(i=(SCS_NB_WORDS-1); i&gt;0; i--)
00058       {tmp = RES[i]&gt;&gt;SCS_NB_BITS;  RES[i-1] += tmp;  RES[i] -= (tmp&lt;&lt;SCS_NB_BITS);}
00059     
00060     val = RES[0] &gt;&gt; SCS_NB_BITS;
00061     R_IND = X_IND + Y_IND;
00062     
00063     <font class="comment">/* Store the result */</font>
00064     <font class="keywordflow">if</font>(val != 0){
00065       <font class="comment">/* shift all the digits ! */</font>     
00066       R_HW[0] = val;
00067       R_HW[1] = RES[0] - (val&lt;&lt;SCS_NB_BITS);
00068       <font class="keywordflow">for</font>(i=2; i&lt;SCS_NB_WORDS; i++)
00069         R_HW[i] = RES[i-1];
00070       
00071       R_IND += 1;
00072     }
00073     <font class="keywordflow">else</font> {
00074       <font class="keywordflow">for</font>(i=0; i&lt;SCS_NB_WORDS; i++)
00075         R_HW[i] = RES[i];
00076     }
00077     
00078     R_EXP = (z-&gt;<a class="code" href="structscs.html#m1">exception</a>.d + (X_EXP * Y_EXP)) - 1;
00079     R_SGN = X_SGN * Y_SGN;
00080   
00081   }<font class="keywordflow">else</font> {
00082     <font class="comment">/* we have to do a sub */</font>
00083 
00084     <font class="comment">/* Carry propagate */</font>
00085     RES[SCS_NB_WORDS-1] += (RES[SCS_NB_WORDS]&gt;&gt;SCS_NB_BITS);
00086     <font class="keywordflow">for</font>(i=(SCS_NB_WORDS-1); i&gt;0; i--)
00087       {tmp = RES[i]&gt;&gt;SCS_NB_BITS;  RES[i-1] += tmp;  RES[i] -= (tmp&lt;&lt;SCS_NB_BITS);}
00088     
00089     val = RES[0] &gt;&gt; SCS_NB_BITS;
00090     R_IND = X_IND + Y_IND;
00091     
00092     <font class="comment">/* Store the result */</font>
00093     <font class="keywordflow">if</font>(val != 0){
00094       <font class="comment">/* shift all the digits ! */</font>     
00095       R_HW[0] = val;
00096       R_HW[1] = RES[0] - (val&lt;&lt;SCS_NB_BITS);
00097       <font class="keywordflow">for</font>(i=2; i&lt;SCS_NB_WORDS; i++)
00098         R_HW[i] = RES[i-1];
00099       
00100       R_IND += 1;
00101     }
00102     <font class="keywordflow">else</font> {
00103       <font class="keywordflow">for</font>(i=0; i&lt;SCS_NB_WORDS; i++)
00104         R_HW[i] = RES[i];
00105     }
00106     
00107     R_EXP = (X_EXP * Y_EXP);
00108     R_SGN = X_SGN * Y_SGN;
00109 
00110     <a class="code" href="addition__scs_8c.html#a8">scs_add</a>(result, result, z);
00111   }
00112 }
</pre></div><hr><address align="right"><small>Generated on Tue Jun 17 10:15:51 2003 for SCSLib by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>