/usr/include/CGAL/RS/ugcd/inverse.h is in libcgal-dev 4.2-5ubuntu1.
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 | // Copyright (c) 2007-2008 Inria Lorraine (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author: Luis PeƱaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS__INVERSE_H
#define CGAL_RS__INVERSE_H
#ifdef _MSC_VER
# define CGALRS_S64 __int64
# define CGALRS_U64 unsigned __int64
# define CGALRS_U32 unsigned __int32
#else
# include <stdint.h>
# define CGALRS_S64 int64_t
# define CGALRS_U64 uint64_t
# define CGALRS_U32 uint32_t
#endif
namespace CGAL{
namespace RS_MGCD{
#define CGALRS_N(A) (A<0?-A:A)
//#define CGALRS_U(A) (A<0?-1:1)
#define CGALRS_U(A,C) (A<0?(C<0?1:-1):(C<0?-1:1))
class Inverse{
protected:
// given a and b, returns s such that gcd(a,b)=s*a+t*b (GCL, page 36)
// s*a+t*q=1 => s is the inverse of a, mod q (pafe 173)
static CGALRS_S64 eea_s(CGALRS_U32 a,CGALRS_U32 b){
CGALRS_S64 c1,d1,r1;//,c2,d2,r2,t,s;
CGALRS_U32 r,c,d;//,q;
// a and b are positive, so a=CGALRS_N(a) and b=CGALRS_N(b)
//c=CGALRS_N(a); d=CGALRS_N(b);
c=a; d=b;
c1=1; d1=0;
//c2=0; d2=1;
while(d){
//q=c/d;
r=c%d;
r1=c1-d1*(c/d); //r2=c2-d2*q;
c=d; c1=d1; //c2=d2;
d=r; d1=r1; //d2=r2;
}
// gcd(a,b) is CGALRS_N(c)
//t=c2/(CGALRS_U(b)*CGALRS_U(c));
// a and c are always positive, so s=c1/CGALRS_U(a,c) equals c1
//s=c1/CGALRS_U(a,c);
//return s;
return c1;
};
}; // class Inverse
#undef CGALRS_N
#undef CGALRS_U
} // namespace RS_MGCD
} // namespace CGAL
#endif // CGAL_RS__INVERSE_H
|