save_state#

Writes state of the random number engine to the file or memory buffer.

Description#

The save_state function allows you to store the state of the random number engine in the binary format in a file or memory buffer.

API#

Syntax#

Save to Memory Interface

namespace oneapi::mkl::rng {
  template<typename Engine>
  void save_state (Engine& engine,
                   std::uint8_t* mem);
}

Save to File Interface

namespace oneapi::mkl::rng {
  template<typename Engine>
  void save_state (Engine& engine,
                   const std::string& filename); // deprecated since 2024.1 release
}

> Note: The Save to File function is deprecated. Use the Save to Memory function instead.

Include Files#

  • oneapi/mkl/rng.hpp

Input Parameters#

Save to Memory Interface

Name

Type

Description

engine

Engine&

Object of engine class, which state would be saved.

mem

std::uint8_t*

Memory, which you allocate to store the engine’s state. To check the size of memory in bytes needed for the particular engine, use the get_state_size function.

Save to File Interface

Name

Type

Description

engine

Engine&

Object of engine class, which state would be saved.

filename

const std::string&

Name of the file where the engine’s state would be written.