<!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>scs2mpfr.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> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center> <hr><h1>scs2mpfr.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 00020 00021 00022 <font class="preprocessor">#include "<a class="code" href="scs_8h.html">scs.h</a>"</font> 00023 <font class="preprocessor">#include "<a class="code" href="scs__private_8h.html">scs_private.h</a>"</font> 00024 00025 <font class="comment">/* Compile only if mpfr is present */</font> 00026 00027 <font class="preprocessor">#ifdef HAVE_MPFR_H</font> 00028 <font class="preprocessor"></font> 00029 00030 <font class="comment">/*</font> 00031 <font class="comment"> * Convert a scs number into a MPFR number rounded to nearest</font> 00032 <font class="comment"> */</font> 00033 <font class="keywordtype">void</font> scs_get_mpfr(<a class="code" href="structscs.html">scs_ptr</a> x, mpfr_t rop){ 00034 mpfr_t mp1; 00035 <font class="keywordtype">long</font> <font class="keywordtype">int</font> expo; 00036 <font class="keywordtype">int</font> i; 00037 00038 mpfr_set_ui(rop, 0, GMP_RNDN); 00039 00040 <font class="comment">/* mantissa */</font> 00041 <font class="keywordflow">for</font> (i=0; i<SCS_NB_WORDS; i++){ 00042 mpfr_mul_2exp(rop, rop, SCS_NB_BITS, GMP_RNDN); 00043 mpfr_add_ui(rop, rop, X_HW[i], GMP_RNDN); 00044 } 00045 00046 <font class="comment">/* sign */</font> 00047 <font class="keywordflow">if</font> (X_SGN == -1) mpfr_neg(rop, rop, GMP_RNDN); 00048 00049 <font class="comment">/* exception */</font> 00050 mpfr_init_set_d(mp1, X_EXP, GMP_RNDN); 00051 mpfr_mul(rop, rop, mp1, GMP_RNDN); 00052 00053 <font class="comment">/* exponent */</font> 00054 expo = (X_IND - SCS_NB_WORDS + 1) * SCS_NB_BITS; 00055 00056 <font class="keywordflow">if</font> (expo < 0) mpfr_div_2exp(rop, rop, (<font class="keywordtype">unsigned</font> <font class="keywordtype">int</font>) -expo, GMP_RNDN); 00057 <font class="keywordflow">else</font> mpfr_mul_2exp(rop, rop, (<font class="keywordtype">unsigned</font> <font class="keywordtype">int</font>) expo, GMP_RNDN); 00058 00059 mpfr_clear(mp1); 00060 } 00061 <font class="preprocessor">#endif </font><font class="comment">/* HAVE_MPFR_H */</font> </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>