---
name: "Math::GSL::QRNG"
section: "3pm"
platform: "linux"
package: "libmath-gsl-perl"
version: "0.45-2+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Math::GSL::QRNG"
---

# Math::GSL::QRNG(3pm)

Quasi-random number generators

## NAME

Math::GSL::QRNG - Quasi-random number generators

## SYNOPSIS

```
    # use OO approach
    use Math::GSL::QRNG;
    my $QRNG = Math::GSL::QRNG::Sobol->new(2);
    my @samples = $QRNG->get();
    # use GSL interface
    use Math::GSL::QRNG qw/:all/;
```

## DESCRIPTION

This module interfaces with GNU Scientific Library quasi-random number generators (QRNG).

## OO Interface

The OO Interface described in this documentation is available to all different subclasses, namely:

- Math::GSL::QRNG::Sobol

  - Math::GSL::QRNG::Niederreiter2

  - Math::GSL::QRNG::Halton

  - Math::GSL::QRNG::ReverseHalton

  ### reinit

Reinitializes the generator to its starting point. Note that quasi-random sequences do not use a seed and always produce the same set of values.

```
        $qrng->reinit();
```

### get

Retrieves the next point from the sequence generator. Returns `"undef"` on error.

```
        my @points = $qrng->get();
```

### name

Retrieves the QRNG name.

```
    my $name = $qrng->name();
```

### state\_size

Returns the size of the QRNG state.

### clone

Returns an exact copy of the current QRNG.

## GSL API

Here is a list of all the functions included in this module :

- "gsl\_qrng\_alloc($T, $n)" - This function returns a pointer to a newly-created instance of a quasi-random sequence generator of type $T and dimension $d. The type $T must be one of the constants included in this module.

  - gsl\_qrng\_clone($q) - This function returns a pointer to a newly created generator which is an exact copy of the generator $q.

  - "gsl\_qrng\_memcpy($dest, $src)" - This function copies the quasi-random sequence generator $src into the pre-existing generator $dest, making $dest into an exact copy of $src. The two generators must be of the same type.

  - gsl\_qrng\_free($q) - This function frees all the memory associated with the generator $q. Don't call this function explicitly. It will be called automatically in DESTROY.

  - gsl\_qrng\_init($q) - This function reinitializes the generator $q to its starting point. Note that quasi-random sequences do not use a seed and always produce the same set of values.

  - gsl\_qrng\_name($q) - This function returns a pointer to the name of the generator $q.

  - gsl\_qrng\_size($q) - This function returns the size of the state of generator r from the generator $q. You can use this information to access the state directly.

  - gsl\_qrng\_state($q) - This function returns a pointer to the state of generator r from the generator $q. You can use this information to access the state directly.

  - "gsl\_qrng\_get"

  This module also contains the following constants :

- $gsl\_qrng\_niederreiter\_2

  - $gsl\_qrng\_sobol

  - $gsl\_qrng\_halton

  - $gsl\_qrng\_reversehalton

  For more information on the functions, we refer you to the GSL official documentation: \<http://www.gnu.org/software/gsl/manual/html\_node/\>

## EXAMPLES

## AUTHORS

Jonathan "Duke" Leto \<jonathan@leto.net\> Thierry Moisan \<thierry.moisan@gmail.com\> Alberto Simões \<ambs@cpan.org\>

## COPYRIGHT AND LICENSE

Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
