atlas  0.6
filekl_in.h
Go to the documentation of this file.
1 
2 #ifndef FILEKL_IN_H
3 #define FILEKL_IN_H
4 
5 
6 
7 #include <iosfwd>
8 
9 #include "bitset.h"
10 #include "../Atlas.h"
11 
12 namespace atlas {
13  namespace filekl {
14 
15  typedef unsigned long long int ullong; // a 64-bit type even on 32-bit machines
16 
17  typedef ullong KLIndex;
18 
19 
20  typedef std::vector<RankFlags>
21  descent_set_vector; // indexed by block element
22 
23  typedef std::vector<BlockElt> ascent_vector; // indexed by simple root
24  typedef std::vector<ascent_vector> ascent_table; // indexed by block element
25 
26  typedef std::vector<BlockElt> prim_list; // list of weak primitives
27  typedef std::vector<prim_list> prim_table;
28 
29 
30  struct block_info
31  {
32  unsigned int rank;
34  unsigned int max_length; // maximal length of block elements
35  std::vector<BlockElt> start_length;
36  // array has size |max_length+2|; it defines intervals for each length
37 
38  descent_set_vector descent_set; // descent (bit)set listed per BlockElt
39 
40  private:
41  ascent_table ascents; // raised element per simple root, per BlockElt
42  prim_table primitives_list; // lists of weakly primitives, per descent set
43 
44  public:
45  block_info(std::ifstream& in); // constructor reads, and closes, file
46 
48  const prim_list& prims_for_descents_of(BlockElt y);
49  private:
50  bool is_primitive(BlockElt x, const RankFlags d) const;
51  };
52 
53  typedef prim_list strong_prim_list;
54 
56  {
57  std::ifstream& matrix_file; // non-owned reference to (open) file
58 
60 
61  std::vector<std::streampos> row_pos; // positions where each row starts
62 
63  // data for currently selected row~|y|
64  BlockElt cur_y; // row number
65  strong_prim_list cur_strong_prims; // strongly primitives for this row
66  std::streampos cur_row_entries; // indices of polynomials for row start here
67 
68  //private methods
69  matrix_info(const matrix_info&); // copying forbidden
70  void set_y(BlockElt y); // install |cur_y| and dependent data
71 
72  public:
73  BlockElt x_prim; // public variable that is set by |find_pol_nr|
74 
75  // constructor and destructor
76  matrix_info(std::ifstream& block_file,std::ifstream& m_file);
78 
79  // accessors
80  size_t rank() const { return block.rank; }
81  BlockElt block_size() const { return block.size; }
82  size_t length (BlockElt y) const; // length in block
83  BlockElt first_of_length (size_t l) const
84  { return block.start_length[l]; }
85  RankFlags descent_set (BlockElt y) const;
86  std::streamoff row_offset(BlockElt y) const { return row_pos[y]; }
88  { return block.primitivize(x,y); }
89 
90  // manipulators (they are so because they set |cur_y|)
91  KLIndex find_pol_nr(BlockElt x,BlockElt y);
92  BlockElt prim_nr(unsigned int i,BlockElt y);
93  // find primitive element
94  const strong_prim_list& strongly_primitives (BlockElt y)
95  { set_y(y); return cur_strong_prims; } // changing |y| invalidates this!
96  };
97 
99  {
100  std::ifstream& file; // non-owned reference to (open) file
101 
102  KLIndex n_pols; // number of polynomials in file
103  unsigned int coef_size; // number of bytes per coefficient
104  ullong n_coef; // number of coefficients
105  std::streamoff index_begin, coefficients_begin;
106 
107  public:
108  polynomial_info(std::ifstream& coefficient_file);
109  virtual ~polynomial_info();
110 
111  KLIndex n_polynomials() const { return n_pols; }
112  unsigned int coefficient_size() const { return coef_size; }
113  ullong n_coefficients() const { return n_coef; }
114 
115  virtual size_t degree(KLIndex i) const;
116  std::vector<size_t> coefficients(KLIndex i) const;
117  virtual size_t leading_coeff(KLIndex i) const;
118  ullong coeff_start(KLIndex i) const; // number of all preceding coefficients
119  };
120 
122  : public polynomial_info
123  {
124  static const size_t degree_mask = 0x1F; // degree must <32
125  mutable std::vector<unsigned char> cache;
126 
127  public:
128  cached_pol_info(std::ifstream& coefficient_file);
129 
130  virtual size_t degree(KLIndex i) const;
131  virtual size_t leading_coeff(KLIndex i) const;
132  };
133 
135  {
136  std::vector<KLIndex> first_pol; // count distinct polynomials in rows before
137  public:
138  progress_info(std::ifstream& progress_file);
139 
140  BlockElt block_size() const { return first_pol.size()-1; }
141  KLIndex first_new_in_row(BlockElt y) // |y==block_size()| is allowed
142  const
143  { return first_pol[y]; }
144  BlockElt first_row_for_pol(KLIndex i) const;
145  };
146 
147  }
148 }
149 #endif
150 
std::streampos cur_row_entries
Definition: filekl_in.h:66
ascent_table ascents
Definition: filekl_in.h:41
Definition: filekl_in.h:98
unsigned int coef_size
Definition: filekl_in.h:103
unsigned int max_length
Definition: filekl_in.h:34
BitSet< constants::RANK_MAX > RankFlags
Definition: Atlas.h:60
KLIndex first_new_in_row(BlockElt y) const
Definition: filekl_in.h:141
std::vector< BlockElt > prim_list
Definition: filekl_in.h:26
Definition: filekl_in.h:134
std::vector< KLIndex > first_pol
Definition: filekl_in.h:136
BlockElt primitivize(BlockElt x, BlockElt y) const
Definition: filekl_in.cpp:25
ullong n_coef
Definition: filekl_in.h:104
std::vector< BlockElt > ascent_vector
Definition: filekl_in.h:23
int length
Definition: common.c:103
KLIndex n_pols
Definition: filekl_in.h:102
KLIndex n_polynomials() const
Definition: filekl_in.h:111
BlockElt block_size() const
Definition: filekl_in.h:140
block_info block
Definition: filekl_in.h:59
strong_prim_list cur_strong_prims
Definition: filekl_in.h:65
std::vector< RankFlags > descent_set_vector
Definition: filekl_in.h:21
const strong_prim_list & strongly_primitives(BlockElt y)
Definition: filekl_in.h:94
const prim_list & prims_for_descents_of(BlockElt y)
Definition: filekl_in.cpp:48
ullong n_coefficients() const
Definition: filekl_in.h:113
ullong KLIndex
Definition: filekl_in.h:17
unsigned int rank
Definition: filekl_in.h:32
BlockElt cur_y
Definition: filekl_in.h:64
~matrix_info()
Definition: filekl_in.h:77
Definition: filekl_in.h:55
unsigned int coefficient_size() const
Definition: filekl_in.h:112
std::vector< prim_list > prim_table
Definition: filekl_in.h:27
Definition: filekl_in.h:30
prim_list strong_prim_list
Definition: filekl_in.h:53
std::ifstream & file
Definition: filekl_in.h:100
descent_set_vector descent_set
Definition: filekl_in.h:38
std::vector< std::streampos > row_pos
Definition: filekl_in.h:61
BlockElt x_prim
Definition: filekl_in.h:73
BlockElt primitivize(BlockElt x, BlockElt y) const
Definition: filekl_in.h:87
BlockElt block_size() const
Definition: filekl_in.h:81
std::streamoff index_begin
Definition: filekl_in.h:105
std::streamoff row_offset(BlockElt y) const
Definition: filekl_in.h:86
block_info(std::ifstream &in)
Definition: filekl_in.cpp:61
Definition: Atlas.h:38
bool is_primitive(BlockElt x, const RankFlags d) const
Definition: filekl_in.cpp:38
prim_table primitives_list
Definition: filekl_in.h:42
unsigned long long int ullong
Definition: filekl_in.h:15
Class definitions and function declarations for the BitSet class.
std::vector< BlockElt > start_length
Definition: filekl_in.h:35
unsigned int BlockElt
Definition: Atlas.h:367
std::ifstream & matrix_file
Definition: filekl_in.h:57
BlockElt size
Definition: filekl_in.h:33
std::vector< ascent_vector > ascent_table
Definition: filekl_in.h:24
BlockElt first_of_length(size_t l) const
Definition: filekl_in.h:83
size_t rank() const
Definition: filekl_in.h:80
std::vector< unsigned char > cache
Definition: filekl_in.h:125
Definition: filekl_in.h:121