This file is indexed.

/usr/include/CGAL/RS/polynomial_converter.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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Copyright (c) 2009 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_POLYNOMIAL_CONVERTER
#define CGAL_RS_POLYNOMIAL_CONVERTER

#include <CGAL/Polynomial.h>
#include <CGAL/RS/polynomial_1.h>

namespace CGAL{

template<class P>
struct to_rs_poly:
public std::unary_function<P,RS_polynomial_1>{
        RS_polynomial_1 operator()(const P &p)const{
                std::cerr<<"can't convert to integer polynomial"<<std::endl;
                exit(-1);
        }
};

template<>
struct to_rs_poly<RS_polynomial_1>:
public std::unary_function<RS_polynomial_1,RS_polynomial_1>{
        const RS_polynomial_1& operator()(const RS_polynomial_1 &p)const{
                return p;
        }
};

// The conversions using this macro are efficient, since this construct an
// RS polynomial only by copying pointers. The only implementation detail
// is that it should not free the occuped by the pointed coefficients.
#define CGALRS_POLYNOMIAL_CONVERTER_REF(_T,_CONVERT) \
        template<> \
        struct to_rs_poly<Polynomial<_T> >: \
        public std::unary_function<Polynomial<_T>,RS_polynomial_1>{ \
                RS_polynomial_1& operator()(const Polynomial<_T> &p)const{ \
                        void *(*af)(size_t); \
                        void *(*rf)(void*,size_t,size_t); \
                        void (*ff)(void*,size_t); \
                        int d=p.degree(); \
                        mpz_t* c=(mpz_t*)malloc((d+1)*sizeof(mpz_t)); \
                        for(int i=0;i<=d;++i) \
                                _CONVERT; \
                        mp_get_memory_functions(&af,&rf,&ff); \
                        mp_set_memory_functions(af,rf,__cgalrs_dummy_free); \
                        RS_polynomial_1 *r=new RS_polynomial_1(&c,d); \
                        mp_set_memory_functions(af,rf,ff); \
                        return *r; \
                } \
        }

// The conversions using this macro are not intended to be efficient, since
// there is no direct way to convert from these types to mpz_t and we need
// thus to create new mpz_t's.
#define CGALRS_POLYNOMIAL_CONVERTER_COPY(_T,_CONVERT) \
        template<> \
        struct to_rs_poly<Polynomial<_T> >: \
        public std::unary_function<Polynomial<_T>,RS_polynomial_1>{ \
                RS_polynomial_1& operator()(const Polynomial<_T> &p)const{ \
                        int d=p.degree(); \
                        mpz_t* c=(mpz_t*)malloc((d+1)*sizeof(mpz_t)); \
                        for(int i=0;i<=d;++i){ \
                                mpz_init(c[i]); \
                                _CONVERT; \
                        } \
                        return *(new RS_polynomial_1(&c,d)); \
                } \
        }

//CGALRS_POLYNOMIAL_CONVERTER_REF(Gmpz,c[i][0]=*(p[i].mpz()));
CGALRS_POLYNOMIAL_CONVERTER_COPY(Gmpz,mpz_set(c[i],p[i].mpz()));
CGALRS_POLYNOMIAL_CONVERTER_COPY(int,mpz_set_si(c[i],(long)p[i]));
CGALRS_POLYNOMIAL_CONVERTER_COPY(long,mpz_set_si(c[i],p[i]));
CGALRS_POLYNOMIAL_CONVERTER_COPY(unsigned,mpz_set_ui(c[i],(unsigned long)p[i]));
CGALRS_POLYNOMIAL_CONVERTER_COPY(unsigned long,mpz_set_ui(c[i],p[i]));

#undef CGALRS_POLYNOMIAL_CONVERTER_REF
#undef CGALRS_POLYNOMIAL_CONVERTER_COPY

// convert a Gmpz rational polynomial to an integer one
template<>
struct to_rs_poly<Polynomial<Gmpq> >:
public std::unary_function<Polynomial<Gmpq>,RS_polynomial_1>{
        RS_polynomial_1& operator()(const Polynomial<Gmpq> &p)const{
                int d=p.degree();
                mpz_t denominator;
                mpz_init(denominator);
                mpz_lcm(denominator,
                        mpq_denref(p[0].mpq()),
                        mpq_denref(p[d].mpq()));
                for(int j=1;j<d;++j)
                        mpz_lcm(denominator,
                                denominator,
                                mpq_denref(p[j].mpq()));
                mpz_t* c=(mpz_t*)malloc((d+1)*sizeof(mpz_t));
                for(int i=0;i<=d;++i){
                        mpz_init(c[i]);
                        mpz_div(c[i],denominator,mpq_denref(p[i].mpq()));
                        mpz_mul(c[i],c[i],mpq_numref(p[i].mpq()));
                }
                mpz_clear(denominator);
                return *(new RS_polynomial_1(&c,d));
        }
};

template<class P>
struct from_rs_poly:
public std::unary_function<RS_polynomial_1,P>{
        P operator()(const RS_polynomial_1 &p)const{
                std::cerr<<"can't convert to integer polynomial"<<std::endl;
                exit(-1);
        }
};

template<>
struct from_rs_poly<RS_polynomial_1>:
public std::unary_function<RS_polynomial_1,RS_polynomial_1>{
        const RS_polynomial_1& operator()(const RS_polynomial_1 &p)const{
                return p;
        }
};

template<>
struct from_rs_poly<Polynomial<Gmpz> >:
public std::unary_function<RS_polynomial_1,Polynomial<Gmpz> >{
        Polynomial<Gmpz> operator()(const RS_polynomial_1 &p)const{
                typedef Polynomial_traits_d<Polynomial<Gmpz> >  PT;
                mpz_t* pcoef=p.get_coefs();
                std::vector<Gmpz> coeffs;
                int d=p.get_degree();
                for(int i=0;i<=d;++i){
                        // Gmpz c(1);
                        // *c.mpz()=*pcoef[i];
			Gmpz c(pcoef[i]);
                        coeffs.push_back(c);
                }
                return PT::Construct_polynomial()(coeffs.begin(),coeffs.end());
        }
};

template<>
struct from_rs_poly<Polynomial<Gmpq> >:
public std::unary_function<RS_polynomial_1,Polynomial<Gmpq> >{
        Polynomial<Gmpq> operator()(const RS_polynomial_1 &p)const{
                typedef Polynomial_traits_d<Polynomial<Gmpq> >  PT;
                mpz_t* pcoef=p.get_coefs();
                std::vector<Gmpq> coeffs;
                int d=p.get_degree();
                for(int i=0;i<=d;++i){
                        // Gmpq c(1);
                        // *mpq_numref(c.mpq())=*pcoef[i];
                        Gmpq c(pcoef[i]);
                        coeffs.push_back(c);
                }
                return PT::Construct_polynomial()(coeffs.begin(),coeffs.end());
        }
};

} // namespace CGAL

#endif  // CGAL_RS_POLYNOMIAL_CONVERTER