Changeset 5ce0793 in git for Singular/mpr_complex.cc
- Timestamp:
- Jun 5, 2000, 2:53:24 PM (24 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- 191c94de014986ddfda1bf819a80b8ca4be61eec
- Parents:
- 4a0a5d596d166bd7225fe54833032e8b60423bba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/mpr_complex.cc
r4a0a5d5 r5ce0793 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mpr_complex.cc,v 1. 19 2000-04-27 10:07:09 obachmanExp $ */4 /* $Id: mpr_complex.cc,v 1.20 2000-06-05 12:53:24 pohl Exp $ */ 5 5 6 6 /* … … 40 40 41 41 int dummy=mmInit(); 42 const gmp_float gmpOne= 1; 43 const gmp_float gmpMOne= -1; 44 const gmp_float gmpZero= 0; 42 static const gmp_float gmpOne= 1; 43 static const gmp_float gmpMOne= -1; 44 static gmp_float gmpRel=0; 45 static gmp_float diff=0; 45 46 46 47 … … 76 77 size_t bits= 1 + (size_t) (digits / (log(2)/log(10))); 77 78 bits= bits>64?bits:64; 78 //gmp_float::setPrecision( bits+EXTRABYTES*8 ); 79 gmp_float::setPrecision( bits+(bits/5) ); 79 gmp_float::setPrecision( bits+bits ); 80 80 gmp_float::setEqualBits( bits ); 81 81 gmp_output_digits= digits; 82 mpf_set_default_prec( bits+bits ); 83 mpf_set_ui(*gmpRel.mpfp(),1); 84 mpf_div_2exp(*gmpRel.mpfp(),*gmpRel.mpfp(),bits); 82 85 } 83 86 … … 142 145 } 143 146 144 // <gmp_float> == <gmp_float> ?? up to the first gmp_float::gmp_needequal_bits bits 147 // <gmp_float> operator <gmp_float> 148 gmp_float & gmp_float::operator += ( const gmp_float & a ) 149 { 150 gmp_float r = -a; 151 if (!(*this == r)) 152 mpf_sub( t, t, r.t ); 153 else 154 mpf_set_d( t, 0.0); 155 return *this; 156 } 157 gmp_float & gmp_float::operator -= ( const gmp_float & a ) 158 { 159 gmp_float r = a; 160 if (!(*this == r)) 161 mpf_sub( t, t, r.t ); 162 else 163 mpf_set_d( t, 0.0); 164 return *this; 165 } 166 167 // <gmp_float> == <gmp_float> ?? 145 168 bool operator == ( const gmp_float & a, const gmp_float & b ) 146 169 { 147 //return mpf_cmp( a.t, b.t ) == 0; 148 return mpf_eq( a.t , b.t , gmp_float::gmp_needequal_bits ); 170 if(mpf_sgn(a.t) != mpf_sgn(b.t)) 171 return false; 172 mpf_reldiff(diff.t, a.t, b.t); 173 mpf_abs(diff.t, diff.t); 174 if(diff < gmpRel) 175 return true; 176 else 177 return false; 178 } 179 // t == 0 ? 180 bool gmp_float::isZero() 181 { 182 return (mpf_sgn( t ) == 0); 183 } 184 // t == 1 ? 185 bool gmp_float::isOne() 186 { 187 #ifdef VARIANTE_1 188 return (mpf_cmp_ui( t , 1 ) == 0); 189 #else 190 if (mpf_sgn(t) <= 0) 191 return false; 192 mpf_reldiff(diff.t, t, gmpOne.t); 193 mpf_abs(diff.t, diff.t); 194 if(diff < gmpRel) 195 return true; 196 else 197 return false; 198 #endif 199 } 200 // t == -1 ? 201 bool gmp_float::isMOne() 202 { 203 #ifdef VARIANTE_1 204 return (mpf_cmp_si( t , -1 ) == 0); 205 #else 206 if (mpf_sgn(t) >= 0) 207 return false; 208 mpf_reldiff(diff.t, t, gmpMOne.t); 209 mpf_abs(diff.t, diff.t); 210 if(diff < gmpRel) 211 return true; 212 else 213 return false; 214 #endif 149 215 } 150 216 bool operator > ( const gmp_float & a, const gmp_float & b )
Note: See TracChangeset
for help on using the changeset viewer.