bigvec.h 2.74 KB
Newer Older
Antoine Lucas's avatar
import  
Antoine Lucas committed
1
2
3
4
5
6
7
8
9
/*! \file bigvec.h
 *  \brief bigvec class definition
 *
 *  \version 1
 *
 *  \date Created: 2005
 *  \date Last modified: Time-stamp: <2013-06-08 22:27:37 antoine>
 *
 *
10
 *  \note Licence: GPL (>= 2)
Antoine Lucas's avatar
import  
Antoine Lucas committed
11
12
13
14
15
16
 */


#ifndef BIGVEC_HEADER_
#define BIGVEC_HEADER_ 1

17
18
#include <memory>

Antoine Lucas's avatar
import  
Antoine Lucas committed
19
#include "bigmod.h"
antoine lucas's avatar
antoine lucas committed
20
#include "templateMatrix.h"
Antoine Lucas's avatar
import  
Antoine Lucas committed
21
22
23
24
25
26
27

/** \brief class bigvec
 *
 * It a class composed of 2 vectors, (value & modulus) that
 * can be of different size and a nrow
 * parameter (for matrix support)
 */
28
class bigvec : public math::Matrix<bigmod> {
Antoine Lucas's avatar
import  
Antoine Lucas committed
29
30
31
32
33
 public:
  /** \brief value */
  std::vector<biginteger> value;
  /** \brief modulus */
  std::vector<biginteger> modulus;
antoine lucas's avatar
antoine lucas committed
34
35
36
37
  
  /** array with all bigmod, that are references to values in vector. */
  std::vector<bigmod *> valuesMod;
  
Antoine Lucas's avatar
import  
Antoine Lucas committed
38
39
40
41
42
43
44
45
46
47
48
49
  /** \brief optional parameter used with matrix -- set to -1 for non-matrix */
  int nrow ;

  /** \brief initialize value to size i
   */
  bigvec(unsigned int i = 0);

  /**
   * \brief copy constructor
   */
  bigvec(const bigvec & vecteur);

antoine lucas's avatar
antoine lucas committed
50
51
  virtual ~bigvec();

52
53
54
  inline bool isVector() const{
    return nrow < 0 ;
  }
Antoine Lucas's avatar
Antoine Lucas committed
55

Antoine Lucas's avatar
import  
Antoine Lucas committed
56
57
58
59
60
61
62
  /**
   * \brief construct a bigmod at indice i
   *
   * It gets values from value[i] & modulus[i % modulus.size()]
   *
   * \note should  not used for assignement
   */
antoine lucas's avatar
antoine lucas committed
63
  const bigmod & operator[] (unsigned int i) const;
Antoine Lucas's avatar
import  
Antoine Lucas committed
64

antoine lucas's avatar
antoine lucas committed
65
  bigmod & operator[] (unsigned int i) ;
Antoine Lucas's avatar
import  
Antoine Lucas committed
66
67
68
69
70
71

  /**
   * \brief assign a value at indice i
   */
  void set(unsigned int i,const bigmod & val);

antoine lucas's avatar
antoine lucas committed
72
73
74
75
  void set(unsigned int row, unsigned int col, const bigmod & val) ;

  bigmod & get(unsigned int row, unsigned int col) ;

Antoine Lucas's avatar
import  
Antoine Lucas committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  /**
   * \brief extend our vectors.
   *
   * This function will check if modulus should be added.
   * Modulus can be set "globaly" i.e. one modulus for the
   * whole vector/matrix.
   * Or set by row (a constant modulus for each row)
   * Or set by cell (as many modulus as value)
   */
  void push_back(const bigmod &i);

  /** 
   * insert int value
   */
  void push_back(int value_p);

  /**
   * Insert Big Integer value
   */
antoine lucas's avatar
antoine lucas committed
95
  void push_back(biginteger & value_p);
Antoine Lucas's avatar
import  
Antoine Lucas committed
96
97
98
99
100
101
102
  void push_back(const __mpz_struct* value_p);

  /**
   * \brief return size of vector value
   */
  unsigned int size() const ;

antoine lucas's avatar
antoine lucas committed
103
104
  unsigned int nRows() const;

Antoine Lucas's avatar
import  
Antoine Lucas committed
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
  /**
   * \brief extend vector value.
   */
  void resize(unsigned int i);

  /**
   * \brief clear all
   */
  void clear();

  /**
   * \brief Return as a human readible string
   */
  std::string str(int i, int b) const;

  /**
   * \brief assignement operator
   */
  bigvec & operator= (const bigvec & rhs);

  /** \brief print matrix to stdout
   *
   * use for debug purpose
   */
  void print();



antoine lucas's avatar
antoine lucas committed
133
134
135
136
137
 private:
  void checkValuesMod() ;
  void clearValuesMod() ;


Antoine Lucas's avatar
import  
Antoine Lucas committed
138
139
140
141
142
143
144
145
146
147
148
};
//


/** \brief comparison operator
 */
bool operator!= (const bigvec& rhs, const bigvec& lhs);



#endif