<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="random-engine-pcgoneseq128xslrr64.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>Random\Engine\PcgOneseq128XslRr64::__construct</refname>
  <refpurpose>Constructs a new PCG Oneseq 128 XSL RR 64 engine</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <constructorsynopsis role="Random\\Engine\\PcgOneseq128XslRr64">
   <modifier>public</modifier> <methodname>Random\Engine\PcgOneseq128XslRr64::__construct</methodname>
   <methodparam choice="opt"><type class="union"><type>string</type><type>int</type><type>null</type></type><parameter>seed</parameter><initializer>&null;</initializer></methodparam>
  </constructorsynopsis>
  <para>

  </para>

  &warn.undocumented.func;

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>seed</parameter></term>
    <listitem>
     <para>
      How the internal 128 bit (16 byte) state consisting of one unsigned 128 bit integer is
      seeded depends on the type used as the <parameter>seed</parameter>.
      <informaltable>
       <tgroup cols="2">
        <thead>
         <row>
          <entry>Type</entry>
          <entry>&Description;</entry>
         </row>
        </thead>
        <tbody>
         <row>
          <entry><type>null</type></entry>
          <entry>
           Fills the state with 16 random bytes generated using the <acronym>CSPRNG</acronym>.
          </entry>
         </row>
         <row>
          <entry><type>int</type></entry>
          <entry>
           Fills the state by setting the state to <literal>0</literal>, advancing the engine one step,
           adding the value of <parameter>seed</parameter> interpreted as an unsigned 64 bit integer,
           and advancing the engine another step.
          </entry>
         </row>
         <row>
          <entry><type>string</type></entry>
          <entry>
           Fills the state by interpreting a 16 byte <type>string</type> as a little-endian unsigned
           128 bit integer.
          </entry>
         </row>
        </tbody>
       </tgroup>
      </informaltable>
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <!-- Return values commented out, as constructors generally don't return a
      value. Uncomment this if you do need a return values section (for
      example, because there's also a procedural version of the method).
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>

  </para>
 </refsect1>
 -->

 <refsect1 role="errors">
  &reftitle.errors;
  <itemizedlist>
   <listitem>
    <simpara>
     If the length of a <type>string</type> <parameter>seed</parameter> is
     not 16 bytes, a <classname>ValueError</classname> will be thrown.
    </simpara>
   </listitem>
  </itemizedlist>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>Random\Engine\PcgOneseq128XslRr64::__construct</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php
// Uses a random 128 Bit seed.
$e = new \Random\Engine\PcgOneseq128XslRr64();

$r = new \Random\Randomizer($e);
?>
]]>
   </programlisting>
  </example>
  <example>
   <title>Deriving a seed from a &string;</title>
   <programlisting role="php">
<![CDATA[
<?php
$string = "My string seed";

// Hash the string with truncated SHA-256 using binary output
// to turn the $string into a 128 Bit seed. Using the same
// string will result in the same sequence of randomness.
$e = new \Random\Engine\PcgOneseq128XslRr64(
    substr(hash('sha256', $string, binary: true), 0, 16)
);

echo bin2hex($e->generate()), "\n";
?>
]]>
   </programlisting>
   &example.outputs;
   <screen>
<![CDATA[
8333ef59315b16d8
]]>
   </screen>
  </example>
 </refsect1>


</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
