/usr/include/givaro/givintrns.h is in libgivaro-dev 4.0.2-5.
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 | // ==========================================================================
// Copyright(c)'1994-2009 by The Givaro group
// This file is part of Givaro.
// Givaro is governed by the CeCILL-B license under French law
// and abiding by the rules of distribution of free software.
// see the COPYRIGHT file for more details.
// Authors: T. Gautier
// Time-stamp: <08 Feb 02 16:33:39 Jean-Guillaume.Dumas@imag.fr>
// ==========================================================================
/** @file givintrns.h
* @ingroup CRA
* @brief arithmetic for RNS representations.
* Modular arithmetic for GIVARO. Here is defined arithmetic functions
* on rns representation with Givaro Integers.
*/
#ifndef __GIVARO__arithmodu_intrns_H
#define __GIVARO__arithmodu_intrns_H
#include "givaro/givconfig.h"
#include "givaro/givinteger.h"
// --------------------------------------------- class RNSsystem
// Structure which manages list of primes in order to do
namespace Givaro {
// #ifndef __ECC
//! RNS system class. No doc.
template< template<class, class> class Container, template <class> class Alloc>
class IntRNSsystem : public IntegerDom {
public:
// typedef Element Ring;
// typedef Element Modulo;
typedef Element external;
typedef Container< Element, Alloc<Element> > array;
// Default Cstor, Dstor/Cstor of recopy:
// -- free memory allocated in array !
IntRNSsystem() : _primes(0), _prod(one), _ck(0) {}
~IntRNSsystem(){}
IntRNSsystem(const IntRNSsystem& R) : _primes(R._primes), _prod(R._prod), _ck(R._primes) {}
// -- Cstor with given primes
IntRNSsystem( const array& primes );
template<class TT>
IntRNSsystem( const Container< TT, Alloc<TT> > & primes );
// -- Computation of a mixed-radix representation of the residus.
// void RnsToMixedRadix(array& mixrad, const array& residu) const;
template<class TT>
void RnsToMixedRadix(array& mixrad, const Container<TT, Alloc<TT> >& residu) ;
// -- Convert a mixed radix representation to an external
void MixedRadixToRing( external& res, const array& mixrad ) const;
// -- Convert an Ring Element to a its representation
// with the "this" rns system.
void RingToRns( array& residu, const external& a ) ;
// -- Fast conversion: requires pre-computation (first time it was called)
void fastRingToRns( array& residu, const external& a ) const;
// -- Convert a representation to an external Element
template<class TT>
void RnsToRing( external& a, const Container<TT, Alloc<TT> >& residu ) ;
// -- Fast conversion: requires pre-computation (first time it was called)
void fastRnsToRing( external& a, const array& residu ) const;
// ------------- Access methods
// -- Returns the number of primes of this ctxt
int NumOfPrimes() const { return _primes.size(); }
// -- Returns a array to the begin of the array of primes
const array& Primes() const;
// -- Returns the ith primes of the rns system
const Element ith(const size_t i) const;
// -- Returns a array of the reciprocal ck = (\prod_{j=0..k-1)p_j)^(-1) [pk]
const array& Reciprocals() const;
const Element reciprocal(const size_t i) const;
const Element product() const;
protected:
// -- Compute some fields of the structure :
void ComputeCk();
// -- Compute product of primes
void ComputeProd();
// -- Compute the Qk for Ring -> RNS, allocate U
void ComputeQk();
array _primes; // - array of the relatively primes numbers
Element _prod; // - product of primes
array _ck; // - reciprocals, _ck[0] = 1, same size as _primes
// -- for fast conversion
size_t _sizek;
size_t _log2k;
array _qk; // - cf algo Aho, Hopcroft & Ullman
array _u; // - cf algo Aho, Hopcroft & Ullman
};
// #endif
#if 0 // defined(__ECC)
//#else
/* template<class Container> */
/* class IntRNSsystem : public IntegerDom { */
/* public: */
/* // typedef Element Ring; */
/* // typedef Element Modulo; */
/* typedef Element external; */
/* typedef Container array; */
/* // Default Cstor, Dstor/Cstor of recopy: */
/* // -- free memory allocated in array ! */
/* IntRNSsystem() : _primes(0), _prod(one), _ck(0) {} */
/* ~IntRNSsystem(){} */
/* IntRNSsystem(const IntRNSsystem& R) : _primes(R._primes), _prod(R._prod), _ck(R._primes) {} */
/* // -- Cstor with given primes */
/* IntRNSsystem( const array& primes ); */
/* template<class ContTT> */
/* IntRNSsystem( const ContTT& primes ); */
/* // -- Computation of a mixed-radix representation of the residus. */
/* // void RnsToMixedRadix(array& mixrad, const array& residu) const; */
/* template<class ContTT> */
/* void RnsToMixedRadix(array& mixrad, const ContTT& residu) const; */
/* // -- Convert a mixed radix representation to an external */
/* void MixedRadixToRing( external& res, const array& mixrad ) const; */
/* // -- Convert an Ring Element to a its representation */
/* // with the "this" rns system. */
/* void RingToRns( array& residu, const external& a ) const; */
/* // -- Fast conversion: requires pre-computation (first time it was called) */
/* void fastRingToRns( array& residu, const external& a ) const; */
/* // -- Convert a representation to an external Element */
/* template<class ContTT> */
/* void RnsToRing( external& a, const ContTT& residu ) const; */
/* // -- Fast conversion: requires pre-computation (first time it was called) */
/* void fastRnsToRing( external& a, const array& residu ) const; */
/* // ------------- Access methods */
/* // -- Returns the number of primes of this ctxt */
/* int NumOfPrimes() const { return _primes.size(); } */
/* // -- Returns a array to the begin of the array of primes */
/* const array& Primes() const; */
/* // -- Returns the ith primes of the rns system */
/* const Element ith(const size_t i) const; */
/* // -- Returns a array of the reciprocal ck = (\prod_{j=0..k-1)p_j)^(-1) [pk] */
/* const array& Reciprocals() const; */
/* const Element reciprocal(const size_t i) const; */
/* const Element product() const; */
/* protected: */
/* // -- Compute some fields of the structure : */
/* void ComputeCk(); */
/* // -- Compute product of primes */
/* void ComputeProd(); */
/* // -- Compute the Qk for Ring -> RNS, allocate U */
/* void ComputeQk(); */
/* array _primes; // - array of the relatively primes numbers */
/* Element _prod; // - product of primes */
/* array _ck; // - reciprocals, _ck[0] = 1, same size as _primes */
/* // -- for fast conversion */
/* size_t _sizek; */
/* size_t _log2k; */
/* array _qk; // - cf algo Aho, Hopcroft & Ullman */
/* array _u; // - cf algo Aho, Hopcroft & Ullman */
/* }; */
/* #endif */
#endif
} // Givaro
#include "givaro/givintrns_cstor.inl"
#include "givaro/givintrns_convert.inl"
#endif // __GIVARO__arithmodu_intrns_H
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
|