---
name: "randommt"
section: "3bobcat"
platform: "linux"
package: "libbobcat-dev"
version: "6.07.01-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/randommt"
---

# randommt(3bobcat)

Class template generating random numbers

## NAME

FBB::RandomMT - Class template generating random numbers

## SYNOPSIS

**#include \<bobcat/randommt\>**\
 Linking option: *-lbobcat*

## DESCRIPTION

The class template *RandomMT* uses the *std::mt19937* Mercenne Twister to produce random numbers. The class template has one template type parameter, which can be any integral or floating point type. By default *size\_t*-valued random numbers are generated.

## NAMESPACE

**FBB**\
 All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace **FBB**.

## INHERITS FROM

\-

## CONSTRUCTORS

- o

  **RandomMT\<typename Type = size\_t\>::RandomMT(Type minimum,** **Type maximum, size\_t mtSeed)**:\
   The *Type* template type parameter can be any integral or floating point type. If not specified *size\_t* is used. The parameters *minimum* and *maximum* define the range of the generated random values. *minimum* must be less or equal to *maximum*, or an exception is thrown. The *mtSeed* parameter is used to initialize (seed) the *mt19937* Mercenne Twister.

The default copy and move constructors and assignment operators are available.

## OVERLOADED OPERATORS

- o

  **Type operator()()**:\
   The function call operator returns the next random value.

## EXAMPLE

```
#include <iostream>
#include <bobcat/randommt>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
try
{
    if (argc == 1)
    {
        cout << "arg[1]: minimum value, arg[2]: maximum value,\n"
                "arg[3]: (optional) seed (or time(0))\n";
        return 0;
    }
    // specify, e.g., RandomMt<double> to generate random double values
    RandomMT<> rmt( stoull(argv[1]), stoull(argv[2]),
                  argc >= 4 ? stoull(argv[3]) : time(0) );
    while (true)
    {
        cout << rmt() << "\n"
                "Enter: next";
        cin.ignore(1000, ’\n’);
    }
}
catch (exception const &exc)
{
    cerr << exc.what() << ’\n’;
}
```

## FILES

*bobcat/randommt* - defines the class interface

## SEE ALSO

[**bobcat**(7)](/bobcat/7.md), [**irandstream**(3bobcat)](/irandstream/3bobcat.md), [**rand**(3)](/rand/3.md), [**randbuf**(3bobcat)](/randbuf/3bobcat.md), [**srand**(3)](/srand/3.md)

## BUGS

None Reported.

## BOBCAT PROJECT FILES

- o

  *https://fbb-git.gitlab.io/bobcat/*: gitlab project page;

Debian Bobcat project files:

- o

  *libbobcat6*: debian package containing the shared library, changelog and copyright note;

- o

  *libbobcat-dev*: debian package containing the static library, headers, manual pages, and developer info;

## BOBCAT

Bobcat is an acronym of \`Brokken’s Own Base Classes And Templates’.

## COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

## AUTHOR

Frank B. Brokken (**f.b.brokken@rug.nl**).
