/usr/include/singular/singular/coeffs/mpr_complex.h is in libsingular4-dev-common 1:4.1.0-p3+ds-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | #ifndef MPR_COMPLEX_H
#define MPR_COMPLEX_H
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/*
* ABSTRACT - multipolynomial resultants - real floating-point numbers using gmp
* and complex numbers based on pairs of real floating-point numbers
*
*/
//-> include & define stuff
// must have gmp version >= 2
#include <coeffs/si_gmp.h>
#include <coeffs/mpr_global.h>
#define ZTOF 1
#define QTOF 2
#define RTOF 3
#define CTOF 4
void setGMPFloatDigits( size_t digits, size_t rest );
//-> class gmp_float
/**
* @short wrapper class for GNU Multi Precision Floats
*/
class gmp_float;
char *floatToStr( const gmp_float & r, const unsigned int oprec );
class gmp_float
{
public:
gmp_float( const int v = 0 )
{
mpf_init_set_si( t, (long)v );
}
gmp_float( const long v )
{
mpf_init_set_si( t, v );
}
gmp_float( const mprfloat v ) // double
{
mpf_init_set_d( t, v );
}
gmp_float( const mpf_t v )
{
mpf_init_set( t, v );
}
gmp_float( const mpz_t v ) // gnu mp Z
{
mpf_init( t );
mpf_set_z( t, v );
}
gmp_float( const gmp_float & v ) // copy constructor
{
mpf_init_set( t, v.t );
}
~gmp_float()
{
mpf_clear( t );
}
inline gmp_float & operator = ( const gmp_float & a )
{
mpf_set( t, a.t );
return *this;
};
inline gmp_float & operator = ( const mpz_t & a )
{
mpf_set_z( t, a );
return *this;
};
inline gmp_float & operator = ( const mprfloat a )
{
mpf_set_d( t, (double) a );
return *this;
};
inline gmp_float & operator = ( const long a )
{
mpf_set_d( t, (double) a );
return *this;
};
gmp_float & operator += ( const gmp_float & a );
gmp_float & operator -= ( const gmp_float & a );
inline gmp_float & operator *= ( const gmp_float & a )
{
mpf_mul( t, t, a.t );
return *this;
};
inline gmp_float & operator /= ( const gmp_float & a )
{
mpf_div( t, t, a.t );
return *this;
};
inline gmp_float & neg ( ) { mpf_neg(t,t); return *this; };
friend gmp_float operator + ( const gmp_float & a, const gmp_float & b );
friend gmp_float operator - ( const gmp_float & a, const gmp_float & b );
friend gmp_float operator * ( const gmp_float & a, const gmp_float & b );
friend gmp_float operator / ( const gmp_float & a, const gmp_float & b );
inline gmp_float operator ^ ( const int exp ) const
{
mpf_t b;
mpf_init(b);
mpf_pow_ui( b, this->t, (unsigned long)exp );
return gmp_float(b);
};
friend bool operator == ( const gmp_float & a, const gmp_float & b );
friend bool operator > ( const gmp_float & a, const gmp_float & b );
friend bool operator < ( const gmp_float & a, const gmp_float & b );
friend bool operator >= ( const gmp_float & a, const gmp_float & b );
friend bool operator <= ( const gmp_float & a, const gmp_float & b );
friend gmp_float operator - ( const gmp_float & a );
inline int sign() // t>0:+1, t==0:0, t<0:-1
{ return mpf_sgn( t ); };
bool isZero() const; // t == 0 ?
bool isOne() const; // t == 1 ?
bool isMOne() const; // t == -1 ?
void setFromStr(const char * in );
// access
inline const mpf_t *mpfp() const { return &t; };
inline mpf_t *_mpfp() { return &t; };
inline operator double() { return mpf_get_d( t ); };
inline operator double() const { return mpf_get_d( t ); };
#if 0
inline operator int() { return (int)mpf_get_d( t ); };
inline operator int() const { return (int)mpf_get_d( t ); };
//#else
inline operator int() const
{ if (mpf_fits_sint_p(t))
{ return (int)mpf_get_si( t ); }
return 0;
};
#endif
private:
mpf_t t;
};
// built-in functions of GMP
gmp_float abs( const gmp_float & );
gmp_float sqrt( const gmp_float & );
gmp_float hypot( const gmp_float &, const gmp_float & );
//gmp_float pow( const gmp_float &, int & );
// simulated functions using double functions
gmp_float sin( const gmp_float & );
gmp_float cos( const gmp_float & );
gmp_float log( const gmp_float & );
gmp_float exp( const gmp_float & );
gmp_float max( const gmp_float &, const gmp_float & );
gmp_float numberToFloat( number num, const coeffs src );
gmp_float numberFieldToFloat( number num, int src );
//char *floatToStr( const gmp_float & r, const unsigned int oprec );
//<-
//-> class gmp_complex
/**
* @short gmp_complex numbers based on
*/
class gmp_complex
{
private:
gmp_float r, i;
public:
gmp_complex( const gmp_float re= 0.0, const gmp_float im= 0.0 )
{
r= re;
i= im;
}
gmp_complex( const mprfloat re, const mprfloat im = 0.0 )
{
r= re;
i= im;
}
gmp_complex( const long re, const long im )
{
r= re;
i= im;
}
gmp_complex( const gmp_complex & v )
{
r= v.r;
i= v.i;
}
~gmp_complex() {}
gmp_complex & neg ( );
friend gmp_complex operator + ( const gmp_complex & a, const gmp_complex & b );
friend gmp_complex operator - ( const gmp_complex & a, const gmp_complex & b );
friend gmp_complex operator * ( const gmp_complex & a, const gmp_complex & b );
friend gmp_complex operator / ( const gmp_complex & a, const gmp_complex & b );
// gmp_complex <operator> real
inline friend gmp_complex operator + ( const gmp_complex & a, const gmp_float b_d );
inline friend gmp_complex operator - ( const gmp_complex & a, const gmp_float b_d );
inline friend gmp_complex operator * ( const gmp_complex & a, const gmp_float b_d );
inline friend gmp_complex operator / ( const gmp_complex & a, const gmp_float b_d );
gmp_complex & operator += ( const gmp_complex & a );
gmp_complex & operator -= ( const gmp_complex & a );
gmp_complex & operator *= ( const gmp_complex & a );
gmp_complex & operator /= ( const gmp_complex & a );
inline friend bool operator == ( const gmp_complex & a, const gmp_complex & b );
inline friend bool operator > ( const gmp_complex & a, const gmp_complex & b );
inline friend bool operator < ( const gmp_complex & a, const gmp_complex & b );
inline friend bool operator >= ( const gmp_complex & a, const gmp_complex & b );
inline friend bool operator <= ( const gmp_complex & a, const gmp_complex & b );
inline gmp_complex & operator = ( const gmp_complex & a );
inline gmp_complex & operator = ( const gmp_float & f );
// access to real and imaginary part
inline gmp_float real() const { return r; }
inline gmp_float imag() const { return i; }
inline void real( gmp_float val ) { r = val; }
inline void imag( gmp_float val ) { i = val; }
inline bool isZero() { return (r.isZero() && i.isZero()); }
void SmallToZero();
};
// <gmp_complex> = <gmp_complex> operator <gmp_float>
//
inline gmp_complex operator + ( const gmp_complex & a, const gmp_float b_d )
{
return gmp_complex( a.r + b_d, a.i );
}
inline gmp_complex operator - ( const gmp_complex & a, const gmp_float b_d )
{
return gmp_complex( a.r - b_d, a.i );
}
inline gmp_complex operator * ( const gmp_complex & a, const gmp_float b_d )
{
return gmp_complex( a.r * b_d, a.i * b_d );
}
inline gmp_complex operator / ( const gmp_complex & a, const gmp_float b_d )
{
return gmp_complex( a.r / b_d, a.i / b_d );
}
// <gmp_complex> == <gmp_complex> ?
inline bool operator == ( const gmp_complex & a, const gmp_complex & b )
{
return ( b.real() == a.real() ) && ( b.imag() == a.imag() );
}
inline bool operator > ( const gmp_complex & a, const gmp_complex & b )
{
return ( a.real() > b.real() );
}
inline bool operator < ( const gmp_complex & a, const gmp_complex & b )
{
return ( a.real() < b.real() );
}
inline bool operator >= ( const gmp_complex & a, const gmp_complex & b )
{
return ( a.real() >= b.real() );
}
inline bool operator <= ( const gmp_complex & a, const gmp_complex & b )
{
return ( a.real() <= b.real() );
}
// <gmp_complex> = <gmp_complex>
inline gmp_complex & gmp_complex::operator = ( const gmp_complex & a )
{
r= a.r;
i= a.i;
return *this;
}
// <gmp_complex> = <gmp_complex>
inline gmp_complex & gmp_complex::operator = ( const gmp_float & f )
{
r= f;
i= (long int)0;
return *this;
}
// Returns absolute value of a gmp_complex number
//
inline gmp_float abs( const gmp_complex & c )
{
return hypot(c.real(),c.imag());
}
gmp_complex sqrt( const gmp_complex & x );
inline gmp_complex numberToComplex( number num, const coeffs r )
{
if (nCoeff_is_long_C(r))
{
return *(gmp_complex*)num;
}
else
{
return gmp_complex( numberToFloat(num, r) );
}
}
char *complexToStr( gmp_complex & c, const unsigned int oprec, const coeffs src );
//<-
bool complexNearZero( gmp_complex * c, int digits );
#endif /* MPR_COMPLEX_H */
// local Variables: ***
// folded-file: t ***
// compile-command-1: "make installg" ***
// compile-command-2: "make install" ***
// End: ***
|