/usr/include/CGAL/Chinese_remainder_traits.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 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 | // Copyright (c) 2006-2007 Max-Planck-Institute Saarbruecken (Germany).
// 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(s) : Michael Hemmer <hemmer@mpi-inf.mpg.de>
//
// =============================================================================
#ifndef CGAL_CHINESE_REMAINDER_TRAITS_H
#define CGAL_CHINESE_REMAINDER_TRAITS_H 1
#include <CGAL/basic.h>
#include <vector>
#include <CGAL/extended_euclidean_algorithm.h>
namespace CGAL{
namespace internal{
template <class T_, class TAG>
class Chinese_remainder_traits_base{
public:
typedef T_ Type;
typedef ::CGAL::Null_tag Scalar_type;
typedef ::CGAL::Null_functor Chinese_remainder;
};
}
template <class T> class Chinese_remainder_traits
:public internal::Chinese_remainder_traits_base<T,
typename Algebraic_structure_traits<T>::Algebraic_category>{};
namespace internal {
template <class NT>
class Chinese_remainder_traits_base<NT,Euclidean_ring_tag>{
public:
typedef NT Type;
typedef NT Scalar_type;
struct Chinese_remainder{
void operator() (
const Scalar_type& m1, const Scalar_type& m2, const Scalar_type& m,
const Scalar_type& s, const Scalar_type& CGAL_precondition_code(t),
NT u1, NT u2,
NT& u) const {
#ifndef CGAL_NDEBUG
NT tmp,s_,t_;
tmp = CGAL::extended_euclidean_algorithm(m1,m2,s_,t_);
CGAL_precondition(tmp == NT(1));
CGAL_precondition(s_ == s);
CGAL_precondition(t_ == t);
#endif
typedef Algebraic_structure_traits<NT> AST;
typename AST::Mod mod;
//typename AST::Unit_part unit_part;
typename AST::Integral_division idiv;
if(u1 < NT(0) ) u1 += m1;
if(u2 < NT(0) ) u2 += m2;
CGAL_precondition(0 < m1);
CGAL_precondition(u1 < m1);
CGAL_precondition(u1 >= NT(0));
CGAL_precondition(0 < m2);
CGAL_precondition(u2 < m2);
CGAL_precondition(u2 >= NT(0));
NT v = mod(s*(u2-u1),m2);
u = m1*v + u1;
// u is not unique yet!
NT m_half = idiv(m-mod(m,NT(2)),NT(2));
if (u > m_half) u -= m ;
if (u <= -m_half) u += m ;
}
void operator() (
const Scalar_type& m1, const Type& u1,
const Scalar_type& m2, const Type& u2,
Scalar_type& m, Type& u) const {
Scalar_type s,t;
CGAL::extended_euclidean_algorithm(m1,m2,s,t);
m = m1 * m2;
this->operator()(m1,m2,m,s,t,u1,u2,u);
}
};
};
} // namespace internal
} // namespace CGAL
#endif // CGAL_CHINESE_REMAINDER_TRAITS_H //
|