• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

algebra.hxx

00001 // q_number.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2011 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
00016 //
00017 
00018 #ifndef INCLUDE_VAUCANSON_MISC_ALGEBRA_HXX
00019 # define INCLUDE_VAUCANSON_MISC_ALGEBRA_HXX
00020 
00021 # include <vaucanson/misc/algebra.hh>
00022 
00023 namespace vcsn {
00024 
00025   namespace misc {
00026 
00027 
00028     inline
00029     unsigned long long
00030     gcd (unsigned long long a, unsigned long long b)
00031     {
00032       if (0 == a)
00033         return b;
00034       unsigned long long r;
00035       while (0 != b)
00036         {
00037           r = a % b;
00038           a = b;
00039           b = r;
00040         }
00041       return a;
00042     }
00043 
00044     inline
00045     unsigned long
00046     lcm (unsigned long long a, unsigned long b)
00047     {
00048       unsigned long long res = gcd (a, b);
00049       if (res)
00050         return a * b / res;
00051       return a * b;
00052     }
00053 
00054     inline
00055     bool
00056     is_coprime (unsigned long long a, unsigned long long b)
00057     {
00058       return 1 == gcd (a, b);
00059     }
00060 
00061     inline
00062     unsigned long long abs (long long a)
00063     {
00064       return a > 0 ? a : -a;
00065     }
00066   } // !misc
00067 
00068 } // !vcsn
00069 #endif // !INCLUDE_VAUCANSON_MISC_ALGEBRA_HXX

Generated on Fri Jul 8 2011 22:06:58 for Vaucanson by  doxygen 1.7.1