/usr/include/linbox/field/Givaro/givaro-montg.h is in liblinbox-dev 1.3.2-1.1build2.
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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | /* linbox/field/givaro-gfq.h
* Copyright (C) 2004 Jean-Guillaume Dumas
*
* Written by Jean-Guillaume Dumas <Jean-Guillaume.Dumas@imag.fr>
*
* ------------------------------------
*
*
* ========LICENCE========
* This file is part of the library LinBox.
*
* LinBox is free software: 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 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ========LICENCE========
*.
*/
/* WARNING this wrapper works only with an improved version of Givaro.
* This version of givaro won't be available for public yet.
* But it is available on my web page.
* You can send me a mail to get it or for others details.
*/
#ifndef __LINBOX_field_givaro_montgomery_H
#define __LINBOX_field_givaro_montgomery_H
#include "linbox/integer.h"
#include "linbox/field/field-interface.h"
#include "linbox/util/debug.h"
#include "linbox/linbox-config.h"
#include "linbox/field/field-traits.h"
//------------------------------------
// Files of Givaro library
#include <givaro/givmontg32.h>
#include <givaro/giv_randiter.h>
//------------------------------------
// Namespace in which all LinBox code resides
namespace LinBox
{
template <class Ring>
struct ClassifyRing;
class GivaroMontg;
template<>
struct ClassifyRing<GivaroMontg> {
typedef RingCategories::ModularTag categoryTag;
};
/**
\brief wrapper of Givaro's Givaro::Montgomery< Givaro::Std32>.
\ingroup field
* This class is a modular representation with a Givaro::Montgomery reduction
*/
class GivaroMontg : public Givaro::Montgomery< Givaro::Std32>, public FieldInterface {
public:
/** Element type.
* This type is inherited from the Givaro class Givaro::Montgomery< Givaro::Std32>
*/
typedef Givaro::Montgomery< Givaro::Std32> Father_t ;
typedef Father_t::Rep Element;
using Father_t::one;
using Father_t::mOne;
using Father_t::zero;
/** RandIter type
* This type is inherited from the Givaro class Givaro::Montgomery< Givaro::Std32>
*/
typedef Givaro::GIV_randIter< Givaro::Montgomery< Givaro::Std32>, LinBox::integer > RandIter;
/** Constructor from an integer
* this constructor use the ZpzDom<TAG> constructor
*/
GivaroMontg(const integer& p) :
Givaro::Montgomery< Givaro::Std32>(static_cast<uint32_t>(long(p)))
{ }
/** Constructor from an integer (takes degree of extension as 2nd parameter, must be 1)
* this constructor use the ZpzDom<TAG> constructor
*/
GivaroMontg(const integer& p, const integer& k) :
Givaro::Montgomery< Givaro::Std32>(static_cast<uint32_t>(long(p)))
{
if (k!=1)
throw PreconditionFailed(__func__,__FILE__,__LINE__,"exponent must be 1");
}
/** Characteristic.
* Return integer representing characteristic of the domain.
* Returns a positive integer to all domains with finite characteristic,
* and returns 0 to signify a domain of infinite characteristic.
* @return integer representing characteristic of the domain.
*/
integer& characteristic(integer& c) const
{
return c=integer(static_cast<long>( Givaro::Montgomery< Givaro::Std32>::characteristic()));
}
long characteristic() const
{
return static_cast<long>( Givaro::Montgomery< Givaro::Std32>::characteristic());
}
/** Cardinality.
* Return integer representing cardinality of the domain.
* Returns a non-negative integer for all domains with finite
* cardinality, and returns -1 to signify a domain of infinite
* cardinality.
* @return integer representing cardinality of the domain
*/
integer& cardinality(integer& c) const
{
return c=integer(static_cast<long>( Givaro::Montgomery< Givaro::Std32>::size()));
}
long cardinality() const
{
return static_cast<long>( Givaro::Montgomery< Givaro::Std32>::size());
}
/** Initialization of field base Element from an integer.
* Behaves like C++ allocator construct.
* This function assumes the output field base Element x has already been
* constructed, but that it is not already initialized.
* We assume that the type of Element is short int.
* this methos is just a simple cast.
* @return reference to field base Element.
* @param x field base Element to contain output (reference returned).
* @param y integer.
*/
Element& init(Element& x , const integer& y=0) const
{
return Givaro::Montgomery< Givaro::Std32>::init( x,long(y % (integer)_p));
}
Element& init(Element& x , const double y) const
{
return Givaro::Montgomery< Givaro::Std32>::init( x, y);
}
/** Conversion of field base element to an integer.
* This function assumes the output field base element x has already been
* constructed, but that it is not already initialized.
* @return reference to an integer.
* @param x integer to contain output (reference returned).
* @param y constant field base element.
*/
integer& convert(integer& x, const Element& y) const
{
long tmp;
// return x = *(new integer(Montgomery< Givaro::Std32>::convert(tmp,y)));
return x = integer( Givaro::Montgomery< Givaro::Std32>::convert(tmp,y));
}
double& convert(double& x, const Element& y) const
{
return Givaro::Montgomery< Givaro::Std32>::convert( x, y);
}
#if 0 /* isZero */
bool isZero(const Element& x) const
{
return Givaro::Montgomery< Givaro::Std32>::isZero(x);
}
#endif
static inline int getMaxModulus() { return 40504; }
}; // class GivaroMontg
} // namespace LinBox
#endif // __LINBOX_field_givaro_montgomery_H
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,:0,t0,+0,=s
// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End:
|