This file is indexed.

/usr/include/CGAL/Polynomial/Fraction_traits.h is in libcgal-dev 4.11-2build1.

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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright (c) 2008 Max-Planck-Institute Saarbruecken (Germany)
//
// 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)     : Arno Eigenwillig <arno@mpi-inf.mpg.de>
//                 Michael Hemmer <hemmer@informatik.uni-mainz.de> 
//
// ============================================================================

// TODO: The comments are all original EXACUS comments and aren't adapted. So
//         they may be wrong now.


#ifndef CGAL_POLYNOMIAL_FRACTION_TRAITS_H
#define CGAL_POLYNOMIAL_FRACTION_TRAITS_H

#include <CGAL/basic.h>

namespace CGAL {

// We need to play a similar game to provide Fraction_traits

template <class POLY, class TAG>
class Poly_Ftr_base;

// Use this if the coefficients cannot be decomposed
// into numerator and denominator
template <class NT_>
class Poly_Ftr_base< Polynomial<NT_>, CGAL::Tag_false > {
public:
    typedef Polynomial<NT_> Type;
    typedef CGAL::Tag_false Is_fraction;
    typedef CGAL::Null_tag Numerator;
    typedef CGAL::Null_tag Denominator_type;
    typedef CGAL::Null_functor Common_factor;
    typedef CGAL::Null_functor Decompose;
    typedef CGAL::Null_functor Compose;
};

// If they can, use this
template <class NT_>
class Poly_Ftr_base< Polynomial<NT_>, CGAL::Tag_true > {
    typedef Polynomial<NT_> Poly;
    typedef NT_ Coefficient_type;
public:
    typedef Polynomial<NT_> Type;
    typedef CGAL::Tag_true Is_fraction;
    typedef Polynomial<typename Fraction_traits<NT_>::Numerator_type>
        Numerator_type;
    typedef typename Fraction_traits<NT_>::Denominator_type Denominator_type;
    typedef typename Fraction_traits<NT_>::Common_factor Common_factor;
    class Decompose {
    public:
        typedef Type first_argument_type;
        typedef Numerator_type& second_argument_type;
        typedef Denominator_type& third_argument_type;
        inline void operator () (
                const Type& p,
                Numerator_type& num,
                Denominator_type& den){
            
            typedef Numerator_type INTPOLY;
            typedef Denominator_type DENOM;
            
            typedef Fraction_traits<Coefficient_type> CFTRAITS;
            typedef typename CFTRAITS::Numerator_type INTCOEFF;

            const int d = p.degree();
            std::vector<INTCOEFF> integ(d+1);
            std::vector<DENOM> denom(d+1);
  
            int i;

            // decompose each coefficient into integral part and denominator
            typename CFTRAITS::Decompose decomp_coeff;
            for (i = 0; i <= d; i++) {
                decomp_coeff(p[i], integ[i], denom[i]);
            }

            // c = lcm(denom[0], ..., denom[d])
            typename Algebraic_structure_traits<DENOM>::Integral_division idiv;
            typename CFTRAITS::Common_factor  gcd;  // not really `greatest'

            den = denom[0];
            for (i = 1; i <= d; i++) {
                den *= idiv(denom[i], gcd(den, denom[i]));
            }
            
            // expand each (integ, denom) pair to common denominator
            for (i = 0; i <= d; i++) {
                integ[i] *= INTCOEFF(idiv(den, denom[i]));
            }
            num =  INTPOLY(integ.begin(), integ.end());    
        }
    };

    class Compose {
    public:
        typedef Numerator_type first_argument_type;
        typedef Denominator_type second_argument_type;
        typedef Type result_type;
        inline Type operator () (const Numerator_type& n,
                                 const Denominator_type& d){
            typename Fraction_traits<NT_>::Compose comp_coeff; 
            (void)comp_coeff;
            
            std::vector< NT_> coeffs(n.degree()+1);
            
            for (int i = 0; i <= n.degree(); i++) {
                coeffs[i] = comp_coeff(n[i], d);
            }
            
            return Type(coeffs.begin(), coeffs.end());
        };
    };
};


// Select the right alternative as Fraction_traits
/*! \ingroup CGAL_Polynomial
    \brief \c CGAL::Fraction_traits < \c CGAL::Polynomial<NT> >
 *
 *  Polynomials provide suitable specializations of \c CGAL::Fraction_traits.
 *  They are decomposable iff their coefficient type is.
 *  The denominator \e d of a polynomial \e p is a low common multiple
 *  (see \c CGAL::Fraction_traits::Common_factor for details) of the
 *  denominators of its coefficients.  The numerator is the polynomial
 *  \e d*p with a fraction-free coefficient type.
 *
 *  This works for nested polynomials, too.
 */
template <class NT_>
class Fraction_traits< Polynomial<NT_> >
    : public Poly_Ftr_base< Polynomial<NT_>,
                 typename Fraction_traits<NT_>::Is_fraction >
{
    // nothing new
};

} //namespace CGAL
#endif // CGAL_POLYNOMIAL_FRACTION_TRAITS_H