/usr/include/givaro/givcra.h is in libgivaro-dev 3.2.13-1.2.
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 | #ifndef _CRA_H
#define _CRA_H
// ==========================================================================
// $Source: /var/lib/cvs/Givaro/src/kernel/zpz/givcra.h,v $
// Copyright(c)'94-97 by Givaro Team
// see the copyright file.
// Authors: T. Gautier
// $Id: givcra.h,v 1.10 2007-12-05 15:45:21 jgdumas Exp $
// ==========================================================================
// Description:
// Chinese Remainder Algorithm for 2 Elements.
// For any number of moduli see givrns.h
#include "givaro/givconfig.h"
#include "givaro/giverror.h"
template<class Ring, class Domain, bool REDUCE = true>
struct ChineseRemainder {
typedef typename Ring::Element RingElement;
typedef typename Domain::Element DomainElement;
// Computes u = M^-1 in the domain
// Then C_12 = (M^-1 mod D)M
ChineseRemainder(const Ring& R, const RingElement& M, const Domain& D)
: _domain(D) {
DomainElement u;
_domain.invin( _domain.init(u, M) );
_domain.convert(C_12, u);
C_12 *= M;
}
// Computes res = A + ((e-A) mod D)*(M^-1 mod D)M
// Then res mod M == A
// And res mod D == e
RingElement & operator()( RingElement& res, const RingElement& A, const DomainElement& e) const {
DomainElement smallA, smallM;
_domain.init(smallA, A);
_domain.init(smallM);
_domain.sub(smallM, e, smallA);
_domain.convert(res, smallM);
res *= C_12;
return res += A;
}
private:
Domain _domain;
RingElement C_12;
};
// JGD 05.12.2007: not required anymore ...
//template<>
template<class Ring, class Domain>
struct ChineseRemainder<Ring, Domain, false> {
typedef typename Ring::Element RingElement;
typedef typename Domain::Element DomainElement;
// Computes u = M^-1 in the domain
// Then C_12 = (M^-1 mod D)M
ChineseRemainder(const Ring& R, const RingElement& M, const Domain& D)
: _domain(D) {
DomainElement u;
_domain.invin( _domain.init(u, M) );
_domain.convert(C_12, u);
C_12 *= M;
}
// Computes res = A + (e-A)*(M^-1 mod D)M
// Then res mod M == A
// And res mod D == e
RingElement & operator()( RingElement& res, const RingElement& A, const DomainElement& e) const {
_domain.convert(res, e);
res -= A;
res *= C_12;
return res += A;
}
private:
Domain _domain;
RingElement C_12;
};
#endif
|