Sophie

Sophie

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

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>division_scs.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>division_scs.c</h1><a href="division__scs_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/** Functions for SCS inverse and division</font>
00002 <font class="comment"></font>
00003 <font class="comment">@file division_scs.c</font>
00004 <font class="comment"></font>
00005 <font class="comment">@author Defour David David.Defour@ens-lyon.fr</font>
00006 <font class="comment">@author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr </font>
00007 <font class="comment"> </font>
00008 <font class="comment">This file is part of the SCS library.</font>
00009 <font class="comment"></font>
00010 <font class="comment"></font>
00011 <font class="comment">*/</font>
00012 
00013 <font class="comment">/*</font>
00014 <font class="comment">Copyright (C) 2002  David Defour and Florent de Dinechin</font>
00015 <font class="comment"></font>
00016 <font class="comment">    This library is free software; you can redistribute it and/or</font>
00017 <font class="comment">    modify it under the terms of the GNU Lesser General Public</font>
00018 <font class="comment">    License as published by the Free Software Foundation; either</font>
00019 <font class="comment">    version 2.1 of the License, or (at your option) any later version.</font>
00020 <font class="comment"></font>
00021 <font class="comment">    This library is distributed in the hope that it will be useful,</font>
00022 <font class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00023 <font class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</font>
00024 <font class="comment">    Lesser General Public License for more details.</font>
00025 <font class="comment"></font>
00026 <font class="comment">    You should have received a copy of the GNU Lesser General Public</font>
00027 <font class="comment">    License along with this library; if not, write to the Free Software</font>
00028 <font class="comment">    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</font>
00029 <font class="comment"></font>
00030 <font class="comment"> */</font>
00031 <font class="preprocessor">#include "<a class="code" href="scs_8h.html">scs.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="scs__private_8h.html">scs_private.h</a>"</font>
00033 
00034 
00035 <font class="comment">/*</font>
00036 <font class="comment"> * Compute 1/x with a Newton scheme</font>
00037 <font class="comment"> */</font>
<a name="l00038"></a><a class="code" href="division__scs_8c.html#a0">00038</a> <font class="keywordtype">void</font> <a class="code" href="division__scs_8c.html#a0">scs_inv</a>(<a class="code" href="structscs.html">scs_ptr</a> result, <a class="code" href="structscs.html">scs_ptr</a> x){
00039   <a class="code" href="scs_8h.html#a3">scs_t</a> tmp, res, res1, scstwo;
00040   <font class="keywordtype">double</font> app_x, inv;
00041   
00042   <a class="code" href="addition__scs_8c.html#a0">scs_set</a>(tmp, x);  tmp-&gt;index = 0;  <a class="code" href="scs2double_8c.html#a0">scs_get_d</a>(&amp;app_x, tmp);
00043 
00044   <a class="code" href="double2scs_8c.html#a1">scs_set_si</a>(scstwo, 2);
00045   <font class="comment">/* inv is a 53-bit approximation of 1/x */</font>
00046   inv = 1/app_x;
00047   
00048   <a class="code" href="double2scs_8c.html#a0">scs_set_d</a>(res, inv);
00049   res-&gt;index -= x-&gt;<a class="code" href="structscs.html#m2">index</a>;
00050 
00051   <font class="comment">/* First Newton Iteration */</font>
00052   <a class="code" href="multiplication__scs_8c.html#a2">scs_mul</a>(res1, x, res);
00053   <a class="code" href="addition__scs_8c.html#a9">scs_sub</a>(res1, scstwo, res1);
00054   <a class="code" href="multiplication__scs_8c.html#a2">scs_mul</a>(res, res, res1);
00055 
00056   <font class="comment">/* Second Newton Iteration */</font>
00057   <a class="code" href="multiplication__scs_8c.html#a2">scs_mul</a>(res1, x, res);
00058   <a class="code" href="addition__scs_8c.html#a9">scs_sub</a>(res1, scstwo, res1);
00059   <a class="code" href="multiplication__scs_8c.html#a2">scs_mul</a>(result, res, res1); 
00060 
00061   <font class="keywordflow">return</font>;
00062 }
00063 
00064 <font class="comment">/*</font>
00065 <font class="comment"> * Compute result = x/y; </font>
00066 <font class="comment"> */</font>
<a name="l00067"></a><a class="code" href="division__scs_8c.html#a1">00067</a> <font class="keywordtype">void</font> <a class="code" href="division__scs_8c.html#a1">scs_div</a>(<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){ 
00068   <a class="code" href="scs_8h.html#a3">scs_t</a> res;
00069  
00070   <font class="keywordflow">if</font> (X_EXP != 1){
00071     R_EXP = X_EXP / Y_EXP;
00072     <font class="keywordflow">return</font>;
00073   }
00074 
00075   <a class="code" href="division__scs_8c.html#a0">scs_inv</a>(res, y);
00076   <a class="code" href="multiplication__scs_8c.html#a2">scs_mul</a>(result, res, x);
00077   <font class="keywordflow">return</font>;
00078 }
</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>