|
| 1 | +.. SPDX-FileCopyrightText: 2025 Intel Corporation |
| 2 | +.. |
| 3 | +.. SPDX-License-Identifier: CC-BY-4.0 |
| 4 | +
|
| 5 | +.. _onemath_device_rng_pcg64_dxsm: |
| 6 | + |
| 7 | +pcg64_dxsm |
| 8 | +========== |
| 9 | + |
| 10 | +A permuted congruential pseudorandom number generator PCG64 DXSM with a period of :math:`2^{128}` :ref:`[pcg2014] <onemath_rng_bibliography>`. |
| 11 | + |
| 12 | +.. rubric:: Description |
| 13 | + |
| 14 | +The PCG is a family of random number generators based on linear congruential generator (LCG). The algorithm applies permutation function to improve statistical properties of LCG. |
| 15 | +PCG64 DXSM uses `double xorshift multiply` output function and has a period of :math:`2^{128}`. |
| 16 | + |
| 17 | +.. container:: section |
| 18 | + |
| 19 | + .. rubric:: Generation algorithm |
| 20 | + |
| 21 | + :math:`x_n = x_{n-1} \cdot a + b` |
| 22 | + |
| 23 | + :math:`hi_n = x_n \gg 64` |
| 24 | + |
| 25 | + :math:`lo_n = x_n \land \left(2^{64} - 1\right) \lor 1` |
| 26 | + |
| 27 | + :math:`hi_n = hi_n \oplus (hi_n \gg 32)` |
| 28 | + |
| 29 | + :math:`hi_n = hi_n \cdot a` |
| 30 | + |
| 31 | + :math:`hi_n = hi_n \oplus (hi_n \gg 48)` |
| 32 | + |
| 33 | + :math:`u_n = hi_n \cdot lo_n` |
| 34 | + |
| 35 | + :math:`a = \text{0xDA942042E4DD58B5}, b = \text{0x5851F42D4C957F2D14057B7EF767814F}` |
| 36 | + |
| 37 | +class pcg64_dxsm |
| 38 | +---------------- |
| 39 | + |
| 40 | +.. rubric:: Syntax |
| 41 | + |
| 42 | +.. code-block:: cpp |
| 43 | +
|
| 44 | + namespace oneapi::math::rng::device { |
| 45 | + template<std::int32_t VecSize = 1> |
| 46 | + class pcg64_dxsm { |
| 47 | + public: |
| 48 | + static constexpr std::uint64_t default_seed = 1; |
| 49 | + static constexpr std::int32_t vec_size = VecSize; |
| 50 | +
|
| 51 | + pcg64_dxsm(); |
| 52 | + pcg64_dxsm(std::uint64_t seed, std::uint64_t offset = 0); |
| 53 | + pcg64_dxsm(std::initializer_list<std::uint64_t> seed, std::uint64_t offset = 0); |
| 54 | + pcg64_dxsm(std::uint64_t seed, std::initializer_list<std::uint64_t> offset); |
| 55 | + pcg64_dxsm(std::initializer_list<std::uint64_t> seed, std::initializer_list<std::uint64_t> offset); |
| 56 | + }; |
| 57 | + } |
| 58 | +
|
| 59 | +.. container:: section |
| 60 | + |
| 61 | + .. rubric:: Class Template Parameters |
| 62 | + |
| 63 | + VecSize |
| 64 | + Describes the size of vector which will be produced by generate function by this engine. VecSize values |
| 65 | + may be 1, 2, 3, 4, 8, 16 as ``sycl::vec`` class size. By default VecSize = 1, for this case, a single |
| 66 | + random number is returned by the ``generate`` function. |
| 67 | + |
| 68 | +.. container:: section |
| 69 | + |
| 70 | + .. rubric:: Class Members |
| 71 | + |
| 72 | + .. list-table:: |
| 73 | + :header-rows: 1 |
| 74 | + |
| 75 | + * - Routine |
| 76 | + - Description |
| 77 | + * - `pcg64_dxsm()`_ |
| 78 | + - Default constructor |
| 79 | + * - `pcg64_dxsm(std::uint64_t seed, std::uint64_t offset = 0)`_ |
| 80 | + - Constructor for common seed initialization of the engine and common number of skipped elements |
| 81 | + * - `pcg64_dxsm(std::initializer_list<std::uint64_t> seed, std::uint64_t offset = 0)`_ |
| 82 | + - Constructor for extended seed initialization of the engine and common number of skipped elements |
| 83 | + * - `pcg64_dxsm(std::uint64_t seed, std::initializer_list<std::uint64_t> offset)`_ |
| 84 | + - Constructor for common seed initialization of the engine and extended number of skipped elements |
| 85 | + * - `pcg64_dxsm(std::initializer_list<std::uint64_t> seed, std::initializer_list<std::uint64_t> offset)`_ |
| 86 | + - Constructor for extended seed initialization of the engine and extended number of skipped elements |
| 87 | + |
| 88 | +.. container:: section |
| 89 | + |
| 90 | + .. rubric:: Constructors |
| 91 | + |
| 92 | + .. _`pcg64_dxsm()`: |
| 93 | + |
| 94 | + .. code-block:: cpp |
| 95 | + |
| 96 | + pcg64_dxsm::pcg64_dxsm() |
| 97 | +
|
| 98 | + .. _`pcg64_dxsm(std::uint64_t seed, std::uint64_t offset = 0)`: |
| 99 | + |
| 100 | + .. code-block:: cpp |
| 101 | + |
| 102 | + pcg64_dxsm::pcg64_dxsm(std::uint64_t seed, std::uint64_t offset = 0) |
| 103 | +
|
| 104 | + .. container:: section |
| 105 | + |
| 106 | + .. rubric:: Input Parameters |
| 107 | + |
| 108 | + seed |
| 109 | + The initial conditions of the generator state. |
| 110 | + |
| 111 | + offset |
| 112 | + Number of skipped elements. |
| 113 | + |
| 114 | + .. _`pcg64_dxsm(std::initializer_list<std::uint64_t> seed, std::uint64_t offset = 0)`: |
| 115 | + |
| 116 | + .. code-block:: cpp |
| 117 | + |
| 118 | + pcg64_dxsm::pcg64_dxsm(std::initializer_list<std::uint64_t> seed, std::uint64_t offset = 0) |
| 119 | +
|
| 120 | + .. container:: section |
| 121 | + |
| 122 | + .. rubric:: Input Parameters |
| 123 | + |
| 124 | + seed |
| 125 | + The initial conditions of the generator state. |
| 126 | + |
| 127 | + offset |
| 128 | + Number of skipped elements. |
| 129 | + |
| 130 | + .. _`pcg64_dxsm(std::uint64_t seed, std::initializer_list<std::uint64_t> offset)`: |
| 131 | + |
| 132 | + .. code-block:: cpp |
| 133 | + |
| 134 | + pcg64_dxsm::pcg64_dxsm(std::uint64_t seed, std::initializer_list<std::uint64_t> offset) |
| 135 | +
|
| 136 | + .. container:: section |
| 137 | + |
| 138 | + .. rubric:: Input Parameters |
| 139 | + |
| 140 | + seed |
| 141 | + The initial conditions of the generator state. |
| 142 | + |
| 143 | + offset |
| 144 | + Number of skipped elements. Offset is calculated as: ``num_to_skip`` [0]+ ``num_to_skip`` [1]*2\ :sup:`64`. |
| 145 | + |
| 146 | + .. _`pcg64_dxsm(std::initializer_list<std::uint64_t> seed, std::initializer_list<std::uint64_t> offset)`: |
| 147 | + |
| 148 | + .. code-block:: cpp |
| 149 | + |
| 150 | + pcg64_dxsm::pcg64_dxsm(std::initializer_list<std::uint64_t> seed, std::initializer_list<std::uint64_t> offset) |
| 151 | +
|
| 152 | + .. container:: section |
| 153 | + |
| 154 | + .. rubric:: Input Parameters |
| 155 | + |
| 156 | + seed |
| 157 | + The initial conditions of the generator state. |
| 158 | + |
| 159 | + offset |
| 160 | + Number of skipped elements. Offset is calculated as: ``num_to_skip`` [0]+ ``num_to_skip`` [1]*2\ :sup:`64`. |
| 161 | + |
| 162 | +**Parent topic:** :ref:`onemath_device_rng_engines` |
0 commit comments