00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "scs.h"
00023 #include "scs_private.h"
00024
00025
00026
00027 #ifdef HAVE_MPFR_H
00028
00029
00030
00031
00032
00033 void scs_get_mpfr(scs_ptr x, mpfr_t rop){
00034 mpfr_t mp1;
00035 long int expo;
00036 int i;
00037
00038 mpfr_set_ui(rop, 0, GMP_RNDN);
00039
00040
00041 for (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
00047 if (X_SGN == -1) mpfr_neg(rop, rop, GMP_RNDN);
00048
00049
00050 mpfr_init_set_d(mp1, X_EXP, GMP_RNDN);
00051 mpfr_mul(rop, rop, mp1, GMP_RNDN);
00052
00053
00054 expo = (X_IND - SCS_NB_WORDS + 1) * SCS_NB_BITS;
00055
00056 if (expo < 0) mpfr_div_2exp(rop, rop, (unsigned int) -expo, GMP_RNDN);
00057 else mpfr_mul_2exp(rop, rop, (unsigned int) expo, GMP_RNDN);
00058
00059 mpfr_clear(mp1);
00060 }
00061 #endif