/usr/include/linbox/algorithms/rational-cra-full-multip.h is in liblinbox-dev 1.4.2-3.
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 207 208 209 210 211 212 213 214 215 216 217 218 | /* Copyright (C) 2007 LinBox
* Written by JG Dumas
*
*
*
* ========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========
*/
#ifndef __LINBOX_rational_full_multip_cra_H
#define __LINBOX_rational_full_multip_cra_H
#include "givaro/zring.h"
#include "linbox/algorithms/cra-full-multip.h"
namespace LinBox
{
#if 0
template<class T, template <class T> class Container>
std::ostream& operator<< (std::ostream& o, const Container<T>& C) {
for(typename Container<T>::const_iterator refs = C.begin();
refs != C.end() ;
++refs )
o << (*refs) << " " ;
return o << std::endl;
}
#endif
template<class Domain_Type>
struct FullMultipRatCRA : public virtual FullMultipCRA<Domain_Type> {
typedef Domain_Type Domain;
typedef FullMultipCRA<Domain> Father_t;
typedef typename Father_t::DomainElement DomainElement;
typedef FullMultipRatCRA<Domain> Self_t;
Givaro::ZRing<Integer> _ZZ;
public:
using Father_t::RadixSizes_;
using Father_t::RadixResidues_;
using Father_t::RadixPrimeProd_;
using Father_t::RadixOccupancy_;
FullMultipRatCRA(const double BOUND = 0.0) :
Father_t(BOUND)
{}
template<template<class, class> class Vect, template <class> class Alloc>
Vect<Integer, Alloc<Integer> >& result (Vect<Integer, Alloc<Integer> > &num, Integer& den)
{
num.resize( (Father_t::RadixResidues_.front()).size() );
std::vector< LazyProduct >::iterator _mod_it = Father_t::RadixPrimeProd_.begin();
std::vector< std::vector< Integer > >::iterator _tab_it = Father_t::RadixResidues_.begin();
std::vector< bool >::iterator _occ_it = Father_t::RadixOccupancy_.begin();
LazyProduct Product;
for( ; _occ_it != Father_t::RadixOccupancy_.end() ; ++_mod_it, ++_tab_it, ++_occ_it) {
if (*_occ_it) {
Product = *_mod_it;
std::vector<Integer>::iterator t0_it = num.begin();
std::vector<Integer>::iterator t_it = _tab_it->begin();
if (++_occ_it == Father_t::RadixOccupancy_.end()) {
den = 1;
Integer s, nd; _ZZ.sqrt(s, _mod_it->operator()());
for( ; t0_it != num.end(); ++t0_it, ++t_it) {
iterativeratrecon(*t0_it = *t_it, nd, den, _mod_it->operator()(), s);
if (nd > 1) {
std::vector<Integer>::iterator t02 = num.begin();
for( ; t02 != t0_it ; ++t02)
*t02 *= nd;
den *= nd;
}
}
return num;
}
else {
for( ; t0_it != num.end(); ++t0_it, ++t_it)
*t0_it = *t_it;
++_mod_it; ++_tab_it;
break;
}
}
}
for( ; _occ_it != Father_t::RadixOccupancy_.end() ; ++_mod_it, ++_tab_it, ++_occ_it) {
if (*_occ_it) {
std::vector<Integer>::iterator t0_it = num.begin();
std::vector<Integer>::const_iterator t_it = _tab_it->begin();
Integer invprod;
this->precomputeInvProd(invprod, Product(), _mod_it->operator()() );
for( ; t0_it != num.end(); ++t0_it, ++t_it)
this->smallbigreconstruct(*t0_it, *t_it, invprod );
Product.mulin(*_mod_it);
// Moding out and normalization
for(t0_it = num.begin();t0_it != num.end(); ++t0_it) {
*t0_it %= Product();
Integer tmp(*t0_it);
this->normalize(*t0_it, tmp, Product());
}
}
}
den = 1;
Integer s, nd; _ZZ.sqrt(s, Product.operator()());
std::vector<Integer>::iterator t0_it = num.begin();
for( ; t0_it != num.end(); ++t0_it) {
iterativeratrecon(*t0_it, nd, den, Product.operator()(), s);
if (nd > 1) {
std::vector<Integer>::iterator t02 = num.begin();
for( ; t02 != t0_it ; ++t02)
*t02 *= nd;
den *= nd;
}
}
return num;
}
BlasVector<Givaro::ZRing<Integer> >& result (BlasVector<Givaro::ZRing<Integer>> &num, Integer& den)
{
num.resize( (Father_t::RadixResidues_.front()).size() );
std::vector< LazyProduct >::iterator _mod_it = Father_t::RadixPrimeProd_.begin();
std::vector< BlasVector<Givaro::ZRing<Integer>> >::iterator _tab_it = Father_t::RadixResidues_.begin();
std::vector< bool >::iterator _occ_it = Father_t::RadixOccupancy_.begin();
LazyProduct Product;
for( ; _occ_it != Father_t::RadixOccupancy_.end() ; ++_mod_it, ++_tab_it, ++_occ_it) {
if (*_occ_it) {
Product = *_mod_it;
BlasVector<Givaro::ZRing<Integer>>::iterator t0_it = num.begin();
BlasVector<Givaro::ZRing<Integer>>::iterator t_it = _tab_it->begin();
if (++_occ_it == Father_t::RadixOccupancy_.end()) {
den = 1;
Integer s, nd; _ZZ.sqrt(s, _mod_it->operator()());
for( ; t0_it != num.end(); ++t0_it, ++t_it) {
iterativeratrecon(*t0_it = *t_it, nd, den, _mod_it->operator()(), s);
if (nd > 1) {
BlasVector<Givaro::ZRing<Integer>>::iterator t02 = num.begin();
for( ; t02 != t0_it ; ++t02)
*t02 *= nd;
den *= nd;
}
}
return num;
}
else {
for( ; t0_it != num.end(); ++t0_it, ++t_it)
*t0_it = *t_it;
++_mod_it; ++_tab_it;
break;
}
}
}
for( ; _occ_it != Father_t::RadixOccupancy_.end() ; ++_mod_it, ++_tab_it, ++_occ_it) {
if (*_occ_it) {
BlasVector<Givaro::ZRing<Integer> >::iterator t0_it = num.begin();
BlasVector<Givaro::ZRing<Integer> >::const_iterator t_it = _tab_it->begin();
Integer invprod;
this->precomputeInvProd(invprod, Product(), _mod_it->operator()() );
for( ; t0_it != num.end(); ++t0_it, ++t_it)
this->smallbigreconstruct(*t0_it, *t_it, invprod );
Product.mulin(*_mod_it);
// Moding out and normalization
for(t0_it = num.begin();t0_it != num.end(); ++t0_it) {
*t0_it %= Product();
Integer tmp(*t0_it);
this->normalize(*t0_it, tmp, Product());
}
}
}
den = 1;
Integer s, nd; _ZZ.sqrt(s, Product.operator()());
BlasVector<Givaro::ZRing<Integer> >::iterator t0_it = num.begin();
for( ; t0_it != num.end(); ++t0_it) {
iterativeratrecon(*t0_it, nd, den, Product.operator()(), s);
if (nd > 1) {
BlasVector<Givaro::ZRing<Integer> >::iterator t02 = num.begin();
for( ; t02 != t0_it ; ++t02)
*t02 *= nd;
den *= nd;
}
}
return num;
}
protected:
Integer& iterativeratrecon(Integer& u1, Integer& new_den, const Integer& old_den, const Integer& m1, const Integer& s)
{
Integer a;
_ZZ.reconstructRational(a, new_den, u1*=old_den, m1, s);
return u1=a;
}
};
}
#endif //__LINBOX_rational_full_multip_cra_H
// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End:
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
|