/usr/include/linbox/algorithms/cra-givrnsfixed.h is in liblinbox-dev 1.4.2-5build1.
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 | /* linbox/algorithms/cra-full-multip.h
* Copyright (C) 1999-2010 The LinBox group
*
* Time-stamp: <29 May 13 09:57:18 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========
*/
/*!@file algorithms/cra-givrnsfixed.h
* @ingroup algorithms
* @brief NO DOC
*/
#ifndef __LINBOX_cra_givrnsfix_H
#define __LINBOX_cra_givrnsfix_H
#include <stdlib.h>
#include "linbox/vector/blas-vector.h"
#include <givaro/givrnsfixed.h>
namespace LinBox
{
/*! NO DOC...
* @ingroup CRA
* @bib
*/
template<class Domain_Type>
struct GivaroRnsFixedCRA : public Givaro::RNSsystemFixed<integer> {
typedef Domain_Type Domain;
typedef typename Domain::Element DomainElement;
typedef Givaro::RNSsystemFixed<integer> Father_t;
typedef GivaroRnsFixedCRA<Domain> Self_t;
const size_t nbloops;
size_t iterationnumber;
std::vector< BlasVector< Givaro::ZRing<Integer> > > residues;
integer _product;
integer _midprod;
public:
GivaroRnsFixedCRA(const std::vector<integer>& primes)
: Father_t(primes),
nbloops(primes.size()),
iterationnumber(0)
, residues(0,BlasVector<Givaro::ZRing<Integer> >(Givaro::ZRing<Integer>()))
, _product(1)
{
for(size_t i=0; i<primes.size(); ++i)
_product *= primes[i];
Givaro::Integer::div(_midprod,_product,2);
}
GivaroRnsFixedCRA(const BlasVector<Givaro::ZRing<Integer> >& primes)
: Father_t(primes.getRep()), // refRep ?
nbloops(primes.size()),
iterationnumber(0)
, residues(0,BlasVector<Givaro::ZRing<Integer> >(Givaro::ZRing<Integer>()))
, _product(1)
{
for(size_t i=0; i<primes.size(); ++i)
_product *= primes[i];
Givaro::Integer::div(_midprod,_product,2);
}
Integer& getModulus(Integer& m)
{
return m=_product;
}
template<template<class> class Vect>
Vect<Integer>& getResidue(Vect<Integer>& r)
{
return result(r);
}
template< template<class, class> class Vect, template <class> class Alloc>
void initialize (const Domain& D, const Vect<DomainElement, Alloc<DomainElement> >& e)
{
residues.resize(e.size());
this->progress(D,e);
}
void initialize (const Domain& D, const BlasVector<Domain >& e)
{
Givaro::ZRing<Integer> ZZ;
BlasVector<Givaro::ZRing<Integer> > Z(ZZ);
residues.resize(e.size(),Z);
this->progress(D,e);
}
template< template<class, class> class Vect, template <class> class Alloc>
void progress (const Domain& D, const Vect<DomainElement, Alloc<DomainElement> >& e)
{
++iterationnumber;
typename Vect<DomainElement, Alloc<DomainElement> >::const_iterator eit=e.begin();
std::vector<std::vector< Integer > >::iterator rit = residues.begin();
for( ; eit != e.end(); ++eit, ++rit) {
Integer tmp;
D.convert(tmp, *eit);
rit->push_back(tmp);
}
}
void progress (const Domain& D, const BlasVector<Domain>& e)
{
++iterationnumber;
typename BlasVector<Domain >::const_iterator eit=e.begin();
std::vector<BlasVector< Givaro::ZRing<Integer> > >::iterator rit = residues.begin();
for( ; eit != e.end(); ++eit, ++rit) {
Integer tmp;
D.convert(tmp, *eit);
rit->push_back(tmp);
}
}
template<template<class, class> class Vect, template <class> class Alloc>
Vect<Integer, Alloc<Integer> >& result (Vect<Integer, Alloc<Integer> > &d)
{
d.resize(0);
for(typename Vect<Integer, Alloc<Integer> >::const_iterator rit = residues.begin(); rit != residues.end(); ++rit) {
Integer tmp;
RnsToRing(tmp, *rit);
linbox_check(tmp>=0);
linbox_check(tmp<_product);
if (tmp>_midprod)
tmp -= _product ;
linbox_check(tmp<=_midprod);
d.push_back(tmp);
}
return d;
}
BlasVector<Givaro::ZRing<Integer> >& result (BlasVector<Givaro::ZRing<Integer> > &d)
{
d.resize(0);
for(std::vector<BlasVector< Givaro::ZRing<Integer> > >::const_iterator rit = residues.begin(); rit != residues.end(); ++rit) {
Integer tmp;
RnsToRing(tmp, *rit);
linbox_check(tmp>=0);
linbox_check(tmp<_product);
if (tmp>_midprod)
tmp -= _product ;
linbox_check(tmp<=_midprod);
d.push_back(tmp);
}
return d;
}
bool terminated()
{
return iterationnumber >= nbloops;
}
bool noncoprime(const Integer& i) const
{
return false;
}
};
}
#endif //__LINBOX_cra_givrnsfix_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:
|