(t, m, s)-nets generator
3.0.1
|
In this tutorial you will get acquainted with the most basic functionality of the library. The goal of this exercise is to generate a ready-to-use \((t, m, s)\)-net.
We assume that before reading this tutorial you already downloaded the library and unpacked its files. If you didn't, visit the Download page. We also assume your decent knowledge of C++.
Let us now create a sample project for the purposes of this tutorial. You may do this however you prefer: manually or with the help of your most favourive IDE. Hereafter we assume that our sample project has the following file structure.
File main.cpp
was created manually and it is currently empty.
Let us now open and edit main.cpp
file of our sample program. There, in order to use our library, we first need to include the file with needed functionality. Say, we want to generate a \((t, m, s)\)-net using Niederreiter's algorithm. Hence, we need to include the following file:
The functionality of our library is completely stored within a sole namespace called tms. In particular, the Niederreiter's \((t, m, s)\)-nets in base \(2\) will be represented as the objects of class tms::Niederreiter. Each digital net has the parameters \(t\), \(m\) and \(s\) as its invariants meaning that if at some moment of time you need to change their values, you'll have to create a new net. These parameters have the following meaning:
If you want to find out mathematically rigorous description of parameter \(t\), check out the sources from Recommended literature. However, if you don't want to go deep into the theory, you shall not despair, since our generator is capable of automatic selection of the best (i.e., the lowest) possible \(t\) for each particular case. Having this, you may just forget about its existence (as long as your value of \(m\) is sufficiently large to satisfy \(m \ge t\); don't worry: if your value of \(m\) is too small for a particular \(s\), our library will inform you about that with the help of a runtime exception).
Let us now write a program that saturates a two-dimesional unit cube (i.e., a square with the length of each edge being equal to \(1\)) with a \((t, m, s)\)-net containing \(16\) quasirandom points. Here, \(s = 2\) (since the unit cube is two-dimensional) and \(m = \log_2 M = \log_2 16 = \log_2 2^4 = 4\). Knowing this, we may finally create a new net with the help of the following constructor.
Here nbits
shall be replaced with \(m\) and dim
shall be replaced with \(s\). Having this said, we may write the following piece of code.
Thus, my_first_net
is the \((t, 4, 2)\)-net (value of \(t\) is still unknown) which was constructed with Niederreiter's algorithm and consists of \(16\) distinct quasirandom points within two-dimensional unit cube.
Let us now quickly verify the parameters \(t\), \(m\) and \(s\) of our net. Since \(m\) and \(s\) are defined by user, their values can be retrieved from the net by the calls of respective member functions m
and s
. As for the parameter \(t\), its value requires some additional analytical calculations which is why it can be retrieved with the special function t
contained within tms::analysis namespace:
Here, net
should be replaced with our digital net. The complete code may look as follows:
The expected output is:
As we see, we were able to reach the value \(t = 0\) which is the lowest possible ever. You may spend a couple of minutes of your pastime on checking how the automatically chosen value of \(t\) changes with the growth of \(s\).
Let us finally see the points! In order to optimise the consumption of resources our my_first_net
doesn't actually store all its points in the memory. Instead, it calculates their coordinates on the fly right at the moment when we request them. To do this we are going to use the
method. Its only argument pos
specifies the ordinal index of the point we wish to get. Since we want to take a look at not a single point of our new but all \(16\) points at once, we should wrap the call of this method in a loop.
If you compile this code, you will see that it is still quite useless. Let us add the output of our points to finally see their coordinates!
The expected output is:
Let us visualise our net with the help of a thirdparty plotter (feature is not included into the library).