PageRenderTime 56ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/cln-1.3.2/src/rational/elem/cl_RA_plus1.cc

#
C++ | 33 lines | 18 code | 8 blank | 7 comment | 2 complexity | 69afa23d0cab61fd65fb4fe607d6538c MD5 | raw file
Possible License(s): GPL-2.0
  1. // plus1().
  2. // General includes.
  3. #include "base/cl_sysdep.h"
  4. // Specification.
  5. #include "cln/rational.h"
  6. // Implementation.
  7. #include "rational/cl_RA.h"
  8. #include "cln/integer.h"
  9. namespace cln {
  10. const cl_RA plus1 (const cl_RA& r)
  11. {
  12. // Methode:
  13. // Falls r ein Integer ist: I_1_plus_I anwenden
  14. // Falls r = a/b: (a+b)/b, wobei b>1 und ggT(a+b,b)=ggT(a,b)=1 ist.
  15. if (integerp(r)) {
  16. DeclareType(cl_I,r);
  17. return plus1(r);
  18. } else {
  19. DeclareType(cl_RT,r);
  20. var const cl_I& a = numerator(r);
  21. var const cl_I& b = denominator(r);
  22. return I_I_to_RT(a+b,b);
  23. }
  24. }
  25. } // namespace cln