Borderbasix

Scl.hpp
Go to the documentation of this file.
1 /*********************************************************************
2 * This file is part of the source code of BORDERBASIX software. *
3 * (C) B. Mourrain, GALAAD, INRIA *
4 **********************************************************************
5 History: Initialized from the Posso file.
6  Modified in order to handel different internal representation.
7 $Id: Scl.hpp,v 1.1.1.1 2006/10/06 08:01:40 trebuche Exp $
8 **********************************************************************/
9 #ifndef NDEBUG
10 #include <assert.h>
11 #endif //
12 #ifndef Scl_H
13 #define Scl_H
14 
15 //----------------------------------------------------------------------
16 #include <stdio.h>
17 //extern "C"
18 //{
19 #include "gmp.h"
20 //}
21 //----------------------------------------------------------------------
22 
26 template<class T> struct Scl
27 {
28 public:
29  //data
30  //shared_object<T> data;
31  //T & rep() {return (*data);}
32  //const T & rep() const {return (*data);}
33 
34  T data;
35  inline T & rep() {return (data);}
36  inline const T & rep() const {return (data);}
37 
38  Scl (){this->init();};
39  Scl (const Scl<T>& b); //{ data=b.data;}
40  Scl (double d){this->init();data=T(d);};
41  Scl (signed long sl);
42  Scl (unsigned long ul);
43  Scl (int si);
44  Scl (const char* str, unsigned int b=10);
45 
46  //template<class S>
47  //Scl(const VAL<S> & P) {this->init();assign(*this,P.rep());}
48 
49  ~Scl () {}
50 
51  operator int () const;
52  //operator double () const;
53 
54  static double castDouble(Scl<T> &ref);
55 
56  bool operator == (const Scl<T>& rhs) const;
57  bool operator != (const Scl<T>& rhs) const;
58  bool operator > (const Scl<T>& rhs) const;
59  bool operator >= (const Scl<T>& rhs) const;
60  bool operator < (const Scl<T>& rhs) const;
61  bool operator <= (const Scl<T>& rhs) const;
62 
63  bool operator == (long sl) const;
64  bool operator != (long sl) const;
65  bool operator > (long sl) const;
66  bool operator >= (long sl) const;
67  bool operator < (long sl) const;
68  bool operator <= (long sl) const;
69 
70  bool operator == (int si) const;
71  bool operator != (int si) const;
72  bool operator > (int si) const;
73  bool operator >= (int si) const;
74  bool operator < (int si) const;
75  bool operator <= (int si) const;
76 
77  bool operator == (unsigned long ul) const;
78  bool operator != (unsigned long ul) const;
79  bool operator > (unsigned long ul) const;
80  bool operator >= (unsigned long ul) const;
81  bool operator < (unsigned long ul) const;
82  bool operator <= (unsigned long ul) const;
83 
84  bool operator != (double ul) const;
85  bool operator == (double ul) const;
86  bool operator > (double ul) const;
87  bool operator < (double sl) const;
88  bool operator >= (double ul) const;
89  bool operator <= (double ul) const;
90  // functions that modify at least one argument or `*this'
91  Scl<T> operator - () { return -1* *this;}
92  Scl<T> operator = (const Scl<T>& rhs);// {data=rhs.data; return *this;}
93  Scl<T> operator += (const Scl<T>& rhs);
94  Scl<T> operator -= (const Scl<T>& rhs);
95  Scl<T> operator *= (const Scl<T>& rhs);
96  Scl<T> operator /= (const Scl<T>& rhs);
97  Scl<T> operator %= (const Scl<T>& rhs);
98 
99  Scl<T> operator = (int rhs);
100  Scl<T> operator += (int rhs);
101  Scl<T> operator -= (int rhs);
102  Scl<T> operator *= (int rhs);
103  Scl<T> operator /= (int rhs);
104  Scl<T> operator %= (int rhs);
105 
106  Scl<T> operator = (unsigned long rhs);
107  Scl<T> operator += (unsigned long rhs);
108  Scl<T> operator -= (unsigned long rhs);
109  Scl<T> operator *= (unsigned long rhs);
110  Scl<T> operator /= (unsigned long rhs);
111  Scl<T> operator %= (unsigned long rhs);
112 
113  Scl<T> operator *= (double rhs);
114  Scl<T> operator += (double rhs);
115  Scl<T> operator = (double rhs);
116  Scl<T> operator -= (double rhs);
117 
118  Scl<T> operator = (long rhs);
119  Scl<T> operator += (long rhs);
120  Scl<T> operator -= (long rhs);
121  Scl<T> operator *= (long rhs);
122  Scl<T> operator /= (long rhs);
123 // Scl<T>& operator %= (long rhs);
124  // template<class S>
125 // Scl<T>& operator = (const VAL<S> & x) {assign(*this,x.rep());return *this;}
126 // template<class S>
127 // Scl<T>& operator += (const VAL<S> & x)
128 // {Scl<T> tmp(x);*this+=tmp;return *this;}
129 // template<class S>
130 // Scl<T>& operator -= (const VAL<S> & x)
131 // {Scl<T> tmp(x); *this-=tmp;return *this;}
132 // template<class S> Scl<T>& operator *= (const VAL<S> & x)
133 // {Scl<T> tmp(x); *this*=tmp;return *this;}
134 // template<class S> Scl<T>& operator /= (const VAL<S> & x)
135 // {Scl<T> tmp(x); *this/=tmp;return *this;}
136 // template<class S> Scl<T>& operator %= (const VAL<S> & x)
137 // {Scl<T> tmp(x); *this%=tmp;return *this;}
138 
139  //-----------------------------------------------------------------
140  void operator ++ ( );
141  void operator -- ( );
142  //-----------------------------------------------------------------
143  void Div2Exp (unsigned long exponent_of_2);
144  void GCD (const Scl<T>& b2);
145  void Mod2Exp (unsigned long exponent_of_2);
146  void Mul2Exp (unsigned long exponent_of_2);
147  void PowMod (const Scl<T>& exp, const Scl<T>& m);
148  void PowMod (unsigned long exp, const Scl<T>& m);
149  void abs ( );
150  void factorial (unsigned long n);
151  Scl<T>& negate ( );
152  Scl<T>& pow (int exp);
153  Scl<T>& pow (unsigned long base, unsigned long exp);
154  void quo (const Scl<T>& divisor);
155  void quo (unsigned long divisor);
156  void rem (const Scl<T>& divisor);
157  unsigned long rem (unsigned long divisor);
158  void sqrt ( );
159 
160 private:
161  void init();
162 };
163 
164 //======================================================================
165 // THE ARITHMETIC OPERATORS
166 //======================================================================
167 // template<class T> Scl<T>& operator - (const Scl<T>& b);
168 // template<class T> Scl<T>& operator + (const Scl<T>& b1, const Scl<T>& b2);
169 // template<class T> Scl<T>& operator - (const Scl<T>& b1, const Scl<T>& b2);
170 // template<class T> Scl<T>& operator * (const Scl<T>& b1, const Scl<T>& b2);
171 // template<class T> Scl<T>& operator / (const Scl<T>& b1, const Scl<T>& b2);
172 // template<class T> Scl<T>& operator % (const Scl<T>& b1, const Scl<T>& b2);
173 //----------------------------------------------------------------------}
174 // template <class R> inline
175 // VAL<OP<'+',Scl<R>,Scl<R> > > operator+(const Scl<R> & a, const Scl<R> & b)
176 // {
177 // return VAL<OP<'+',Scl<R>,Scl<R> > >(OP<'+',Scl<R>,Scl<R> >(a,b));
178 // }
179 // //----------------------------------------------------------------------
180 // template <class R> inline
181 // VAL<OP<'-',Scl<R>,Scl<R> > > operator-(const Scl<R> & a, const Scl<R> & b)
182 // {
183 // return VAL<OP<'-',Scl<R>,Scl<R> > >(OP<'-',Scl<R>,Scl<R> >(a,b));
184 // }
185 // //----------------------------------------------------------------------}
186 // template<class T> inline
187 // Scl<T>& operator - (const Scl<T>& b)
188 // {
189 // Scl<T> r(b); return (r.negate());
190 // }
191 // //----------------------------------------------------------------------
192 // // Product of polynomials
193 // template <class R> inline
194 // VAL<OP<'*',Scl<R>,Scl<R> > > operator*(const Scl<R> & a, const Scl<R> & b)
195 // {
196 // return VAL<OP<'*',Scl<R>,Scl<R> > >(OP<'*',Scl<R>,Scl<R> >(a,b));
197 // }
198 // //----------------------------------------------------------------------
199 // // Division of polynomials
200 // template <class R> inline
201 // VAL<OP<'/',Scl<R>,Scl<R> > > operator/(const Scl<R> & a, const Scl<R> & b)
202 // {
203 // return VAL<OP<'/',Scl<R>,Scl<R> > >(OP<'/',Scl<R>,Scl<R> >(a,b));
204 // }
205 // //----------------------------------------------------------------------
206 // // Division of polynomials
207 // template <class R> inline
208 // VAL<OP<'%',Scl<R>,Scl<R> > > operator%(const Scl<R> & a, const Scl<R> & b)
209 // {
210 // return VAL<OP<'%',Scl<R>,Scl<R> > >(OP<'%',Scl<R>,Scl<R> >(a,b));
211 // }
212 //----------------------------------------------------------------------
213 template<class T> Scl<T> operator + (const Scl<T>& b, unsigned long ul);
214 template<class T> Scl<T> operator - (const Scl<T>& b, unsigned long ul);
215 template<class T> Scl<T> operator * (const Scl<T>& b, int ul);
216 template<class T> Scl<T> operator * (const Scl<T>& b, unsigned long ul);
217 template<class T> Scl<T> operator / (const Scl<T>& b, unsigned long ul);
218 template<class T> Scl<T> operator % (const Scl<T>& b, unsigned long ul);
219 
220 template<class T> Scl<T> operator + (unsigned long ul, const Scl<T>& b);
221 template<class T> Scl<T> operator * (unsigned long ul, const Scl<T>& b);
222 template<class T> Scl<T> operator * (int ul, const Scl<T>& b);
223 
224 template<class T> Scl<T> operator + (const Scl<T>& b, long sl);
225 template<class T> Scl<T> operator - (const Scl<T>& b, long sl);
226 template<class T> Scl<T> operator * (const Scl<T>& b, long sl);
227 template<class T> Scl<T> operator / (const Scl<T>& b, long sl);
228 template<class T> Scl<T> operator % (const Scl<T>& b, long sl);
229 
230 template<class T> Scl<T> operator + (long sl, const Scl<T>& b);
231 template<class T> Scl<T> operator * (long sl, const Scl<T>& b);
232 template<class T> Scl<T> operator * ( const Scl<T>& b, double d);
233 template<class T> Scl<T> operator + (const Scl<T>& b, double sl);
234 template<class T> Scl<T> operator + (double s, const Scl<T>& b );
235 template<class T> Scl<T> operator * (double d, const Scl<T>& b);
236 template<class T> Scl<T> operator / (double ul,const Scl<T>& b);
237 template<class T> Scl<T> operator / (const Scl<T>& b, double ul);
238 template<class T> Scl<T> operator / (int ul, const Scl<T>& b);
239 template<class T> Scl<T> operator / (const Scl<T>& b, int ul);
240 template<class T> Scl<T> operator - (double d, const Scl<T>& b);
241 template<class T> Scl<T> operator - (const Scl<T>& b, double sl);
242 //----------------------------------------------------------------------
243 template<class T> Scl<T> Div2Exp (const Scl<T>& b,
244  unsigned long exponent_of_2);
245 template<class T> Scl<T> GCD (const Scl<T>& b1, const Scl<T>& b2);
246 template<class T> Scl<T> gcd (const Scl<T>& b1, const Scl<T>& b2);
247 template<class T> Scl<T> Mod2Exp (const Scl<T>& b,
248  unsigned long exponent_of_2);
249 template<class T> Scl<T> Mul2Exp (const Scl<T>& b, unsigned long exponent_of_2);
250 template<class T> Scl<T> PowMod (const Scl<T>& b, const Scl<T>& exp, const Scl<T>& m);
251 template<class T> Scl<T> PowMod (const Scl<T>& b, unsigned long exp,
252  const Scl<T>& m);
253 template<class T> Scl<T> abs (const Scl<T>& b);
254 // template<class T> Scl<T>& negate (const Scl<T>& b);
255 template<class T> Scl<T> pow (const Scl<T>& base, int exp);
256 template<class T> Scl<T> quo (const Scl<T>& dividend,
257  const Scl<T>& divisor);
258 template<class T> Scl<T> quo (const Scl<T>& dividend,
259  unsigned long divisor);
260 template<class T> Scl<T> rem (const Scl<T>& dividend,
261  const Scl<T>& divisor);
262 template<class T> Scl<T> sqrt (const Scl<T>& b);
263 template<class T> unsigned long rem (const Scl<T>& b, unsigned long divisor);
264 
265 template<class T> Scl<T> BigIntFactorial (unsigned long n);
266 
267 //
268 // -------- the corresponding `const' functions -----------------------------
269 //
270 
271 #define NO_NRV 1
272 #if defined(__GNUG__) && !defined(NO_NRV)
273 #define NRVAL(name) return name
274 #define NRCODE(code) code
275 #define NONRCODE(code)
276 #else
277 #define NRVAL(name)
278 #define NRCODE(code)
279 #define NONRCODE(code) code
280 #endif //
281 
282 #define OPCODE(a, b, op) Scl<T> r(a); return (r op b);
283 
284 
285 // template<class T> inline
286 // Scl<T>& operator + (const Scl<T>& b1, const Scl<T>& b2)
287 // {
288 // OPCODE(b1,b2,+=)
289 // }
290 
291 // template<class T> inline
292 // Scl<T>& operator - (const Scl<T>& b1, const Scl<T>& b2)
293 // {
294 // OPCODE(b1,b2,-=)
295 // }
296 
297 // template<class T> inline
298 // Scl<T>& operator * (const Scl<T>& b1, const Scl<T>& b2)
299 // {
300 // OPCODE(b1,b2,*=)
301 // }
302 
303 // template<class T> inline
304 // Scl<T>& operator / (const Scl<T>& b1, const Scl<T>& b2)
305 // {
306 // OPCODE(b1,b2,/=)
307 // }
308 
309 // template<class T> inline
310 // Scl<T>& operator % (const Scl<T>& b1, const Scl<T>& b2)
311 // {
312 // OPCODE(b1,b2,%=)
313 // }
314 
315 //--------------------------
316 template<class T> inline
317 Scl<T> operator + (int ul, const Scl<T> &b)
318 {
319  OPCODE(b,ul,+=)
320 }
321 
322 template<class T> inline
323 Scl<T> operator + (const Scl<T>& b, int ul)
324 {
325  OPCODE(b,ul,+=)
326 }
327 template<class T> inline
328 Scl<T> operator + (const Scl<T>& b, unsigned long ul)
329 {
330  OPCODE(b,ul,+=)
331 }
332 
333 template<class T> inline
334 Scl<T> operator + (double ul, const Scl<T>& b)
335 {
336  OPCODE(b,ul,+=)
337 }
338 template<class T> inline
339 Scl<T> operator + (const Scl<T>& b, double ul)
340 {
341  OPCODE(b,ul,+=)
342 }
343 template<class T> inline
344 Scl<T> operator - (double ul, const Scl<T>& b)
345 {
346  OPCODE(ul,b,-=)
347 }
348 template<class T> inline
349 Scl<T> operator - (const Scl<T>& b, double ul)
350 {
351  OPCODE(b,ul,-=)
352 }
353 template<class T> inline
354 Scl<T> operator - (const Scl<T>& b, unsigned long ul)
355 {
356  OPCODE(b,ul,-=)
357 }
358 
359 template<class T> inline Scl<T>
360 operator * (const Scl<T>& b, double ul)
361 {
362  OPCODE(b,ul,*=)
363 }
364 template<class T> inline Scl<T>
365 operator * (double ul, const Scl<T>& b)
366 {
367  OPCODE(b,ul,*=)
368 }
369 
370 template<class T> inline Scl<T>
371 operator * (int ul, const Scl<T>& b)
372 {
373  OPCODE(b,ul,*=)
374 }
375 
376 template<class T> inline Scl<T>
377 operator * (const Scl<T>& b, unsigned long ul)
378 {
379  OPCODE(b,ul,*=)
380 }
381 
382 template<class T> inline Scl<T>
383 operator / (const Scl<T>& b, unsigned long ul)
384 {
385  OPCODE(b,ul,/=)
386 }
387 
388 template<class T> inline Scl<T>
389 operator / (const Scl<T>& b, int ul)
390 {
391  OPCODE(b,ul,/=)
392 }
393 
394 template<class T> inline Scl<T>
395 operator / (int ul, const Scl<T>& b)
396 {
397  OPCODE(ul,b,/=)
398 }
399 
400 template<class T> inline
401 Scl<T> operator % (const Scl<T>& b, unsigned long ul)
402 {
403  OPCODE(b,ul,%=)
404 }
405 
406 //----------------------------------------------------------------------
407 template<class T> inline
408 Scl<T> operator + (unsigned long ul, const Scl<T>& b)
409 {
410  return b + ul;
411 }
412 //----------------------------------------------------------------------
413 template<class T> inline
414 Scl<T> operator * (unsigned long ul, const Scl<T>& b)
415 {
416  return b * ul;
417 }
418 //----------------------------------------------------------------------
419 template<class T> inline
420 Scl<T> operator + (const Scl<T>& b, long sl)
421 {
422  OPCODE(b,sl,+=)
423 }
424 
425 
426 template<class T> inline
427 Scl<T> operator - (const Scl<T>& b, long sl) NRVAL(r(b))
428 {
429  OPCODE(b,sl,-=)
430 }
431 
432 template<class T> inline
433 Scl<T> operator * (const Scl<T>& b, int sl) NRVAL(r(b))
434 {
435  OPCODE(b,sl,*=)
436 }
437 
438 template<class T> inline
439 Scl<T> operator * (const Scl<T>& b, long sl) NRVAL(r(b))
440 {
441  OPCODE(b,sl,*=)
442 }
443 
444 template<class T> inline
445 Scl<T> operator / (const Scl<T>& b, long sl) NRVAL(r(b))
446 {
447  OPCODE(b,sl,/=)
448 }
449 
450 template<class T> inline Scl<T>&
451 operator % (const Scl<T>& b, long sl) NRVAL(r(b))
452 {
453  OPCODE(b,sl,%=)
454 }
455 
456 //--------------------------
457 
458 template<class T> inline
459 Scl<T> operator + (long sl, const Scl<T>& b)
460 {
461  return b + sl;
462 }
463 
464 template<class T> inline
465 Scl<T> operator * (long sl, const Scl<T>& b)
466 {
467  return b * sl;
468 }
469 //--------------------------
470 
471 template<class T> inline
472 Scl<T>& Div2Exp (const Scl<T>& b, unsigned long exponent_of_2) NRVAL(r(b))
473 {
474  NRCODE(r.Div2Exp(exponent_of_2);)
475  NONRCODE(Scl<T> r(b); r.Div2Exp(exponent_of_2); return r;)
476 }
477 
478 template<class T> inline
479 Scl<T>& GCD (const Scl<T>& b1, const Scl<T>& b2) NRVAL(r(b1))
480 {
481  NRCODE(r.GCD(b2);)
482  NONRCODE(Scl<T> r(b1); r.GCD(b2); return r;)
483 }
484 
485 template<class T> inline
486 Scl<T>& gcd (const Scl<T>& b1, const Scl<T>& b2) NRVAL(r(b1))
487 {
488  NRCODE(r.GCD(b2);)
489  NONRCODE(Scl<T> r(b1); r.GCD(b2); return r;)
490 }
491 
492 template<class T> inline
493 Scl<T>& Mod2Exp (const Scl<T>& b, unsigned long exponent_of_2) NRVAL(r(b))
494 {
495  NRCODE(r.Mod2Exp(exponent_of_2);)
496  NONRCODE(Scl<T> r(b); r.Mod2Exp(exponent_of_2); return r;)
497 }
498 
499 template<class T> inline
500 Scl<T>& Mul2Exp (const Scl<T>& b, unsigned long exponent_of_2) NRVAL(r(b))
501 {
502  NRCODE(r.Mul2Exp(exponent_of_2);)
503  NONRCODE(Scl<T> r(b); r.Mul2Exp(exponent_of_2); return r;)
504 }
505 
506 template<class T> inline
507 Scl<T>& PowMod (const Scl<T>& b, const Scl<T>& exp, const Scl<T>& m) NRVAL(r(b))
508 {
509  NRCODE(r.PowMod(exp, m);)
510  NONRCODE(Scl<T> r(b); r.PowMod(exp,m); return r;)
511 }
512 
513 template<class T> inline
514 Scl<T>& PowMod (const Scl<T>& b, unsigned long exp, const Scl<T>& m) NRVAL(r(b))
515 {
516  NRCODE(r.PowMod(exp, m);)
517  NONRCODE(Scl<T> r(b); r.PowMod(exp,m); return r;)
518 }
519 
520 //template<class T> inline Scl<T>
521 template <class T> inline
522 Scl<T> abs (const Scl<T>& b) NRVAL(r(b))
523 {
524  NRCODE(r.abs();)
525  NONRCODE(Scl<T> r(b); r.abs(); return r;)
526 }
527 
528 // template<class T> inline Scl<T>&
529 // negate (const Scl<T>& b) NRVAL(r(b))
530 // {
531 // NRCODE(r.negate();)
532 // NONRCODE(Scl<T> r(b); r.negate(); return r;)
533 // }
534 
535 template<class T> inline
536 Scl<T> pow (const Scl<T>& base, const Scl<T>& exp);
537 
538 template<class T> inline
539 Scl<T> pow (const Scl<T>& base, int exp) NRVAL(r(base))
540 {
541  NRCODE(r.pow(exp);)
542  NONRCODE(Scl<T> r(base); r.pow(exp); return r;)
543 }
544 
545 template<class T> inline
546 Scl<T>& quo (const Scl<T>& dividend, const Scl<T>& divisor) NRVAL(r(dividend))
547 {
548  NRCODE(r.quo(divisor);)
549  NONRCODE(Scl<T> r(dividend); r.quo(divisor); return r;)
550 }
551 
552 template<class T> inline
553 Scl<T>& quo (const Scl<T>& dividend, unsigned long divisor) NRVAL(r(dividend))
554 {
555  NRCODE(r.quo(divisor);)
556  NONRCODE(Scl<T> r(dividend); r.quo(divisor); return r;)
557 }
558 
559 template<class T> inline
560 Scl<T>& rem (const Scl<T>& dividend, const Scl<T>& divisor) NRVAL(r(dividend))
561 {
562  NRCODE(r.rem(divisor);)
563  NONRCODE(Scl<T> r(dividend); r.rem(divisor); return r;)
564 }
565 
566 template<class T> inline
567 Scl<T> sqrt (const Scl<T>& b) NRVAL(r(b))
568 {
569  NRCODE(r.sqrt();)
570  NONRCODE(Scl<T> r(b); r.sqrt(); return r;)
571 }
572 
573 template<class T> inline
574 unsigned long rem (const Scl<T>& b, unsigned long divisor)
575 {
576  Scl<T> r(b);
577  return r.rem(divisor);
578 }
579 
580 template<class T> inline
581 Scl<T>& BigIntFactorial (unsigned long n) NRVAL(r)
582 {
583  NRCODE(r.factorial(n);)
584  NONRCODE(Scl<T> r; r.factorial(n); return r;)
585 }
586 
587 template<class T> inline
588 Scl<T>& BigIntPow (unsigned long base, unsigned long exp) NRVAL(r)
589 {
590  NRCODE(r.pow(base, exp);)
591  NONRCODE(Scl<T> r; r.pow(base, exp); return r;)
592 }
593 
594 template<class T>
595  Scl<T> Size(const Scl<T> & r)
596 {
597  return abs(r);
598 }
599 
600  template<class T> inline
601  Scl<T> hypot (const Scl<T>& a, const Scl<T>& b)
602  {
603  return sqrt(a*a+b*b);
604  }
605  //--------------------------------------------------------------------------
606  /*
607  namespace std {
608  namespace __1 {
609  template<typename _Tp> struct complex;
610  }
611  }
612  #define COMPLEX std::__1::complex< Scl<_Tp> >
613 
614  template<typename _Tp>
615  inline COMPLEX
616  operator*(const COMPLEX& x, const COMPLEX& y)
617  {
618  COMPLEX __r(x.real()*y.real()-x.imag()*y.imag(),
619  x.imag()*y.real()+x.real()*y.imag());
620  return __r;
621  }
622 
623  template<typename _Tp>
624  inline COMPLEX
625  operator/(const COMPLEX& x, const COMPLEX& y)
626  {
627  Scl<_Tp> a (x.real()*y.real()+x.imag()*y.imag());
628  Scl<_Tp> b (x.imag()*y.real()-x.real()*y.imag());
629  Scl<_Tp> n2 (y.real()*y.real() + y.imag()*y.imag());
630  a /= n2;
631  b /= n2;
632  return COMPLEX(a,b);
633  }
634  #undef COMPLEX
635  */
636 //--------------------------------------------------------------------------
637 #undef NRVAL
638 #undef NRCODE
639 #undef NONRCODE
640 #endif // //Scl_H
641 
642 
643 
644 
Scl< T > Mul2Exp(const Scl< T > &b, unsigned long exponent_of_2)
Definition: BC.hpp:1040
Scl< T > operator*(const Scl< T > &b, int ul)
Definition: Scl.hpp:433
Scl< T > quo(const Scl< T > &dividend, const Scl< T > &divisor)
Definition: BC.hpp:1082
Scl< T > BigIntFactorial(unsigned long n)
Definition: BC.hpp:1117
void PowMod(const Scl< T > &exp, const Scl< T > &m)
#define OPCODE(a, b, op)
Definition: Scl.hpp:282
Scl< T > operator+(const Scl< T > &b, unsigned long ul)
Definition: Scl.hpp:328
#define NRVAL(name)
Definition: Scl.hpp:277
Scl< T > & negate()
Scl< T > operator-(const Scl< T > &b, unsigned long ul)
Definition: Scl.hpp:354
void pow(unsigned long exp)
Definition: BC.hpp:761
void sqrt()
void Div2Exp(unsigned long exponent_of_2)
Scl< T > operator-()
Definition: Scl.hpp:91
Scl< T > operator%(const Scl< T > &b, unsigned long ul)
Definition: Scl.hpp:401
T data
Definition: Scl.hpp:34
Scl< T > operator-=(const Scl< T > &rhs)
MSKaccmodee MSKint32t MSKsoltypee MSKstakeye MSKrealt MSKrealt * sl
Definition: mosek.h:3209
Scl< T > Mod2Exp(const Scl< T > &b, unsigned long exponent_of_2)
Definition: BC.hpp:1033
Scl< T > operator+=(const Scl< T > &rhs)
Scl< T > hypot(const Scl< T > &a, const Scl< T > &b)
Definition: Scl.hpp:601
static double castDouble(Scl< T > &ref)
bool operator>=(const Scl< T > &rhs) const
void operator--()
Scl< T > & BigIntPow(unsigned long base, unsigned long exp) NRVAL(r)
Definition: Scl.hpp:588
void Mod2Exp(unsigned long exponent_of_2)
void quo(const Scl< T > &divisor)
Scl< T > Div2Exp(const Scl< T > &b, unsigned long exponent_of_2)
Definition: BC.hpp:1012
Scl< T > Size(const Scl< T > &r)
Definition: Scl.hpp:595
Scl< T > operator*=(const Scl< T > &rhs)
Scl< T > abs(const Scl< T > &b)
Definition: Scl.hpp:522
void operator++()
bool operator==(const Scl< T > &rhs) const
void rem(const Scl< T > &divisor)
Scl< T > rem(const Scl< T > &dividend, const Scl< T > &divisor)
Definition: BC.hpp:1096
MSKCONST char * str
Definition: mosek.h:2317
const T & rep() const
Definition: Scl.hpp:36
Scl()
Definition: Scl.hpp:38
Definition: BC.hpp:23
bool operator<=(const Scl< T > &rhs) const
Scl< T > & pow(int exp)
Scl< T > operator/=(const Scl< T > &rhs)
Definition: Scl.hpp:26
Scl< T > pow(const Scl< T > &base, int exp)
Definition: Scl.hpp:539
void Mul2Exp(unsigned long exponent_of_2)
Scl< T > gcd(const Scl< T > &b1, const Scl< T > &b2)
Definition: BC.hpp:1026
Scl< T > GCD(const Scl< T > &b1, const Scl< T > &b2)
Definition: BC.hpp:1019
void rem(const Scl< T > &divisor)
Definition: BC.hpp:785
Scl< T > operator=(const Scl< T > &rhs)
MSKrescodee r
Definition: mosek.h:2321
Scl< T > operator%=(const Scl< T > &rhs)
bool operator>(const Scl< T > &rhs) const
MSKstreamtypee MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t a
Definition: mosek.h:3833
Scl(double d)
Definition: Scl.hpp:40
#define NONRCODE(code)
Definition: Scl.hpp:279
void abs()
#define NRCODE(code)
Definition: Scl.hpp:278
T & rep()
Definition: Scl.hpp:35
Scl< T > sqrt(const Scl< T > &b)
Definition: Scl.hpp:567
Scl< T > operator/(const Scl< T > &b, unsigned long ul)
Definition: Scl.hpp:383
~Scl()
Definition: Scl.hpp:49
void GCD(const Scl< T > &b2)
void factorial(unsigned long n)
bool operator!=(const Scl< T > &rhs) const
Scl< T > PowMod(const Scl< T > &b, const Scl< T > &exp, const Scl< T > &m)
Definition: BC.hpp:1047
bool operator<(const Scl< T > &rhs) const
void factorial(unsigned long n)
Definition: BC.hpp:749
Home  |  Download & InstallContributions