dust3d/thirdparty/cgal/CGAL-5.1/include/CGAL/Polynomial/Modular_traits.h

70 lines
2.2 KiB
C
Raw Normal View History

// Copyright (c) 2008 Max-Planck-Institute Saarbruecken (Germany)
//
2020-10-13 12:44:25 +00:00
// This file is part of CGAL (www.cgal.org)
//
2020-10-13 12:44:25 +00:00
// $URL: https://github.com/CGAL/cgal/blob/v5.1/Polynomial/include/CGAL/Polynomial/Modular_traits.h $
// $Id: Modular_traits.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Arno Eigenwillig <arno@mpi-inf.mpg.de>
2020-10-13 12:44:25 +00:00
// 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.
2020-10-13 12:44:25 +00:00
// NOT INTRODUCED YET
#ifndef CGAL_POLYNOMIAL_MODULAR_TRAITS_TRAITS_H
#define CGAL_POLYNOMIAL_MODULAR_TRAITS_TRAITS_H
#include <CGAL/basic.h>
#include <CGAL/Modular_traits.h>
namespace CGAL {
/*! \ingroup CGAL_Polynomial
* \ingroup CGAL_Modular_traits_spec
* \brief Specialization of Modular_traits for CGAL::Polynomial.
2020-10-13 12:44:25 +00:00
*
* CGAL::Modular_traits::Modular_image maps the coefficients of a polynomial
2020-10-13 12:44:25 +00:00
* to their Modular_image and returns the resulting polynomial.
*/
template< class COEFF >
class Modular_traits< Polynomial<COEFF> > {
2020-10-13 12:44:25 +00:00
private:
typedef Modular_traits<COEFF> Mtr;
public:
typedef Polynomial<COEFF> NT;
typedef Modular_traits<NT> Self;
typedef typename Mtr::Is_modularizable Is_modularizable;
typedef Polynomial<typename Mtr::Residue_type> Residue_type;
2020-10-13 12:44:25 +00:00
struct Modular_image{
2020-10-13 12:44:25 +00:00
Residue_type operator()(const NT& p){
std::vector<typename Mtr::Residue_type> V;
typename Mtr::Modular_image modular_image;
for(int i=0; i<=p.degree();i++)
V.push_back(modular_image(p[i]));
2020-10-13 12:44:25 +00:00
return Residue_type(V.begin(),V.end());
}
};
2020-10-13 12:44:25 +00:00
struct Modular_image_representative{
NT operator()(const Residue_type& p) const {
std::vector<COEFF> V;
typename Mtr::Modular_image_representative modular_image_representative;
for(int i=0; i<=p.degree();i++)
V.push_back(modular_image_representative(p[i]));
2020-10-13 12:44:25 +00:00
return NT(V.begin(),V.end());
}
};
};
} //namespace CGAL
#endif // CGAL_POLYNOMIAL_MODULAR_TRAITS_TRAITS_H