/usr/include/polybori/groebner/cache_manager.h is in libbrial-groebner-dev 0.8.5-4.
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 | /* Copyright (c) 2005-2007 by The PolyBoRi Team */
#include <polybori.h>
#include <algorithm>
#include <utility>
#include <iostream>
#include <boost/shared_ptr.hpp>
#include "groebner_defs.h"
#ifndef PBORI_GB_CACHE_H
#define PBORI_GB_CACHE_H
BEGIN_NAMESPACE_PBORIGB
template<class idx_type1, class idx_type2> void set_up_translation_vectors(std::vector<idx_type1>& ring_2_0123, std::vector<idx_type2>& back_2_ring, const Exponent& used_variables){
BooleExponent::const_iterator it=used_variables.begin();
BooleExponent::const_iterator end=used_variables.end();
idx_type1 idx_0123=0;
while(it!=end){
ring_2_0123[*it]=idx_0123;
back_2_ring[idx_0123]=*it;
idx_0123++;
it++;
}
}
//template<class idx_type1, class idx_type2> void set_up_translation_vectors(std::vector<idx_type1>& ring_2_0123, std::vector<idx_type>& back_2_ring, const Exponent& used_variables);
Polynomial translate_indices(const Polynomial& p, const std::vector<idx_type>& table);
class CacheManager{
public:
typedef Polynomial::poly_vec_map_type impl_type;
typedef std::vector<Polynomial> poly_vec_type;
typedef boost::shared_ptr<poly_vec_type> res_type;
typedef Polynomial::poly_vec_map_type::const_iterator impl_iterator_type;
protected:
impl_type impl;
public:
CacheManager(){
}
res_type lookup(const Polynomial& p, bool& succ){
int nv=p.ring().nVariables();
BooleExponent used_exp=p.usedVariablesExp();
std::vector<idx_type> back_2_ring(used_exp.size());
std::vector<idx_type> ring_2_0123(nv);
//PBORI_ASSERT(nv<255);
set_up_translation_vectors(ring_2_0123,back_2_ring, used_exp);
Polynomial p_t=translate_indices(p,ring_2_0123);
impl_iterator_type it=impl.find(p_t);
//cache_res_type res;
if (it!=impl.end()){
succ=true;
res_type res(new poly_vec_type(it->second));
for(poly_vec_type::size_type i=0;i<res->size();i++){
(*res)[i]=translate_indices((*res)[i],back_2_ring);
}
return res;
}
else{
succ=false;
return res_type();
}
}
void insert(const Polynomial& key, const poly_vec_type& value){
int nv=key.ring().nVariables();
BooleExponent used_exp=key.usedVariablesExp();
std::vector<idx_type> back_2_ring(used_exp.size());
std::vector<idx_type> ring_2_0123(nv);
set_up_translation_vectors(ring_2_0123,back_2_ring, used_exp);
Polynomial key_t=translate_indices(key,ring_2_0123);
poly_vec_type value_t(value);
for(poly_vec_type::size_type i=0;i<value_t.size();i++){
value_t[i]=translate_indices(value_t[i], ring_2_0123);
}
impl[key_t]=value_t;
}
};
END_NAMESPACE_PBORIGB
#endif
|