Skip to content

Commit ca3a660

Browse files
authored
Merge pull request #28 from jointpoints/development
Update to v.3.0.1
2 parents 0658b7f + 7266a9b commit ca3a660

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+22049
-5176
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
This repository contains a C++ generator of digital (t, m, s)-nets in base 2 as well as a number of tools to measure their figures of merit.
55

6+
Available nets:
7+
8+
* Sobol,
9+
* Niederreiter,
10+
* Any digital net with manually set generating matrices.
11+
612
Broadly speaking, (t, m, s)-nets are low-discrepancy finite sets of points in _s_-dimensional unit cube. They have been proven to be efficient in a number of Numerical Analysis tasks.
713

814
![Example of a net](tools/custom_dox_content/tutorial1_Step4_1.jpg)

include/tms-nets.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// Include generators
1717
#include "tms-nets/digital_net.hpp"
1818
#include "tms-nets/niederreiter.hpp"
19-
#include "tms-nets/modified_niederreiter.hpp"
19+
#include "tms-nets/sobol.hpp"
2020
// Include details
2121
#include "tms-nets/details/genmat.hpp"
2222
// Include analysis

include/tms-nets/analysis/analysis.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ namespace tms::analysis
4646
* @param net A digital net.
4747
*
4848
* @returns Precise value of parameter \f$t\f$ for the given digital net.
49+
*
50+
* @throws invalid_argument If at least one generating matrix of the given net is degenerate
51+
* (determinant equals zero over \f$\mathbb{F}_2\f$).
52+
*
53+
* @note Exceptions will never be encountered in this function if it used with \c Niederreiter
54+
* and \c Sobol nets provided in this library. Their generating matrices are \b guaranteed to
55+
* always be non-degenerate. If you discover a case when this function fails to perform on these
56+
* nets, [<b>report a bug</b>](https://github.com/jointpoints/tms-nets/issues/new).
4957
*/
5058
BasicInt t (DigitalNet const &net);
5159

include/tms-nets/details/common.hpp

Lines changed: 95 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,65 +7,109 @@
77
#include <stdexcept>
88

99

10+
/** @namespace tms
11+
* @brief All the entities in the library are defined in this namespace. */
1012
namespace tms
1113
{
12-
using DirNumInt = uintmax_t;
13-
14-
using IntPoint = std::vector<DirNumInt>;
15-
/// Type used for storing integer values that are less than word size.
14+
/// A type for integer values that are less than word size (e.g. m, s parameters of the net)
1615
using BasicInt = unsigned int;
17-
/// Type used for storing quantity-values and indexation-values, i.e. the total amount of points to generate.
16+
/// A type for integer counting values, (e.g. number of net's point)
1817
using CountInt = uintmax_t;
19-
/// Type used for storing coordinates of points of (t,m,s)-net.
18+
/// A type of coordinates of points of (t, m, s)-net
2019
using Real = long double;
21-
/// Type used for storing points of (t,m,s)-net.
20+
/// Represents a generating number of a digital (t, m, s)-net
21+
using GenNumInt = uintmax_t;
22+
/// Represents a point of a scaled (t, m, s)-net
23+
using IntPoint = std::vector<uintmax_t>;
24+
/// Represents a point of a (t, m, s)-net
2225
using Point = std::vector<Real>;
23-
/// Type used for storing polynomials.
26+
/// Represents a polynomial over GF[2]
2427
using Polynomial = irrpoly::gfpoly;
2528

26-
class DirNum;
29+
30+
/// Highest allowed m parameter value of created nets, i.e. highest bit depth value
31+
BasicInt const max_nbits = sizeof(uintmax_t)*8;
32+
33+
34+
class GenNum;
2735

2836
class GenMatRow;
2937

3038
class GenMat;
3139

32-
BasicInt const max_nbits = sizeof(DirNumInt)*8;
33-
3440

35-
class DirNum
41+
/** @class GenNum
42+
* @brief Represents container of generating numbers of a digital net.
43+
* Can be used as a shortened version of generating matrix */
44+
class GenNum
3645
{
3746
public:
3847

39-
DirNum(void);
40-
DirNum(DirNum const&);
41-
DirNum(DirNum &&);
48+
/// Creates empty container with no generating numbers
49+
GenNum(void);
50+
GenNum(GenNum const&);
51+
GenNum(GenNum &&);
52+
53+
~GenNum(void);
4254

43-
~DirNum(void);
55+
GenNum& operator =(GenNum const &);
56+
GenNum& operator =(GenNum &&);
4457

45-
DirNum& operator =(DirNum const &);
46-
DirNum& operator =(DirNum &&);
58+
/** Creates generating numbers with given values
59+
* @param values – vector of generating numbers values */
60+
GenNum(std::vector<GenNumInt> const &values);
4761

48-
DirNum(std::vector<DirNumInt> const &values);
49-
DirNum(BasicInt size);
50-
//DirNum(GenMat const &gen_mat);
62+
/** Creates certain amount of zero defined generating numbers
63+
* @param amount – amount of generating numbers */
64+
GenNum(BasicInt amount);
5165

66+
/// Casts generating numbers to the corresponding generating matrix
5267
explicit operator GenMat(void) const;
5368

69+
/// Checks whether generating numbers container is empty
70+
bool empty(void) const;
71+
72+
/// Checks whether the corresponding generating matrix is toeplitz
73+
bool is_toeplitz(void) const;
74+
75+
/// Returns amount of generating numbers in the containter
5476
BasicInt size(void) const;
77+
78+
/** Returns certain bit of a generating number addressed as an element of generating matrix
79+
* @param i – row number
80+
* @param j – column number */
5581
bool get_bit(BasicInt i, BasicInt j) const;
56-
DirNumInt operator[](BasicInt n) const;
5782

83+
/** Returns certain generating number
84+
* @param n – index of a number */
85+
uintmax_t operator[](BasicInt n) const;
86+
87+
/** Sets new bit value of a certain generating number addressed as an element of generating matrix
88+
* @param i – row number
89+
* @param j – column number
90+
* @param value – new bit value */
5891
void set_bit(BasicInt i, BasicInt j, bool value);
59-
DirNumInt& operator[](BasicInt n);
92+
93+
/** Returns reference to a certain generating number
94+
* @param n – index of a number */
95+
uintmax_t& operator[](BasicInt n);
96+
97+
GenNum& operator *=(GenNum const& l);
98+
99+
friend bool operator ==(GenNum const &r, GenNum const &l);
60100

61101

62102
private:
63103

64104
BasicInt m_nbits;
65-
std::vector<DirNumInt> m_numbers;
105+
std::vector<GenNumInt> m_numbers;
66106
};
67107

108+
GenNum operator * (GenNum r, GenNum const &l);
109+
bool operator !=(GenNum const &l, GenNum const &r);
110+
68111

112+
/** Represents a row of a generating matrix */
69113
class GenMatRow
70114
{
71115
public:
@@ -83,6 +127,8 @@ namespace tms
83127
GenMatRow(std::vector<uint8_t> const &values_vector); //?
84128
GenMatRow(std::initializer_list<uint8_t> const &values_list);
85129

130+
bool empty(void) const;
131+
86132
BasicInt size(void) const;
87133
uint8_t operator [](BasicInt n) const;
88134
uint8_t& operator [](BasicInt n);
@@ -127,13 +173,15 @@ namespace tms
127173
GenMat(std::vector<GenMatRow> const &matrix);
128174
GenMat(std::initializer_list<GenMatRow> const &lines_list);
129175

130-
explicit operator DirNum(void) const;
176+
explicit operator GenNum(void) const;
131177

132-
BasicInt size(void) const;
178+
bool empty(void) const;
179+
180+
BasicInt size(void) const;
133181
GenMatRow operator [](BasicInt n) const;
134182
GenMatRow& operator [](BasicInt n);
135183

136-
bool is_shifted(void) const;
184+
bool is_toeplitz(void) const;
137185
GenMat inverse(void) const;
138186

139187
GenMat& operator *=(GenMat const &r);
@@ -159,30 +207,38 @@ namespace tms
159207

160208

161209

210+
inline bool
211+
GenNum::empty() const
212+
{ return m_numbers.empty(); }
213+
162214
inline BasicInt
163-
DirNum::size(void) const
215+
GenNum::size(void) const
164216
{ return m_nbits; }
165217

166218
inline bool
167-
DirNum::get_bit(BasicInt i, BasicInt j) const
219+
GenNum::get_bit(BasicInt i, BasicInt j) const
168220
{ return (m_numbers[j] >> (m_nbits - 1 - i)) & 1; }
169221

170-
inline DirNumInt
171-
DirNum::operator[](BasicInt n) const
222+
inline uintmax_t
223+
GenNum::operator[](BasicInt n) const
172224
{ return m_numbers[n]; }
173225

174226

175227
inline void
176-
DirNum::set_bit(BasicInt i, BasicInt j, bool value)
177-
{ m_numbers[j] |= static_cast<DirNumInt>(value) << (m_nbits - 1 - i); }
228+
GenNum::set_bit(BasicInt i, BasicInt j, bool value)
229+
{ m_numbers[j] |= static_cast<uintmax_t>(value) << (m_nbits - 1 - i); }
178230

179-
inline DirNumInt&
180-
DirNum::operator[](BasicInt n)
231+
inline uintmax_t&
232+
GenNum::operator[](BasicInt n)
181233
{ return m_numbers[n]; }
182234

183235

184236

185237

238+
inline bool
239+
GenMatRow::empty(void) const
240+
{ return m_values.empty(); }
241+
186242
inline BasicInt
187243
GenMatRow::size(void) const
188244
{ return static_cast<BasicInt>(m_values.size()); }
@@ -198,6 +254,10 @@ namespace tms
198254

199255

200256

257+
inline bool
258+
GenMat::empty() const
259+
{ return m_rows.empty(); }
260+
201261
inline BasicInt
202262
GenMat::size(void) const
203263
{ return m_nbits; }

0 commit comments

Comments
 (0)