Ansicht
Dokumentation
CL_ABAP_RANDOM - Pseudozufallszahlengenerator
CPI1466 during Backup rdisp/max_wprun_time - Maximum work process run timeDiese Dokumentation steht unter dem Copyright der SAP AG.
Funktionalität
Diese Klasse implementiert die Grundversion eines Pseudozufallszahlengenerators. Als Grundlage dient der Algorithmus "Mersenne Twister". Dieser Algorithmus garantiert eine extrem hohe Periodenlänge der generierten Werte und liefert auch bei der Generierung von mehrdimensionlen Daten gleichverteilte Werte.
Die Klasse CL_ABAP_RANDOM kann Pseudozufallszahlen für ganze Zahlen, Gleitkommazahlen, und gepackte Zahlen für einfache Anwendungen liefern. Sie sollte nur verwendet werden, wenn unbedingt mehrdimensionale Daten mit unterschiedlich typisierten Komponenten erzeugt werden müssen. Für die Erzeugung eindimensionaler Werte mit bestimmter Typisierung steht ein Satz von weiteren Klassen zur Verfügung (s. unten), die in diesem Fall verwendet werden sollen.
Der Mersenne Twister wurde als OpenSource-Produkt in die ABAP- Laufzeitumgebung eingebaut. Aus diesem Grund müssen wir den folgenden Text in diese Dokumentation übernehmen:
/*
A C-program for MT19937, with initialization improved 2002/2/10.
Coded by Takuji Nishimura and Makoto Matsumoto.
This is a faster version by taking Shawn Cokus's optimization,
Matthe Bellew's simplification, Isaku Wada's real version.
Before using, initialize the state by using init_genrand(seed)
or init_by_array(init_key, key_length).
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
documentation and/or other materials provided with the distribution
3. The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE
IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Any feedback is very welcome.
http://www.math.keio.ac.jp/matumoto/emt.html
email: matumoto@math.keio.ac.jp
*/
Beziehungen
CL_ABAP_RANDOM ist eine finale Klasse.
Beispiel
REPORT random_numbers.
DATA prng TYPE REF TO CL_ABAP_RANDOM.
DATA num TYPE I.
START-OF-SELECTION.
prng = CL_ABAP_RANDOM=>create( ).
DO 10000 TIMES.
num = prng->Int( ).
WRITE / num.
ENDDO.
Hinweise
Dieser Pseudozufallszahlengenerator ist nicht geeignet für Anwendungen im Bereich Kryptographie.
Die Berechnung der Zahlenfolgen geschieht ausschließlich auf der Grundlage ganzzahliger Operationen. Die aus einer festen Startzahl berechnete Folge ist immer identisch (Reproduzierbarkeit). Dies gilt insbesondere plattformübergreifend. Wenn variable Folgen gewünscht sind, muss ein variabler Wert an den Parameter SEED der Methode CREATE übergeben werden, wozu das Ergebnis der Methode CL_ABAP_RANDOM=>SEED benutzt werden kann.
Weiterführende Informationen
Informationen zum Mersenne Twister:
http://www.math.keio.ac.jp/matumoto/emt.html
Weitere Klassen zur Erzeugung von Pseudozufallszahlen:
CL_ABAP_RANDOM_DECFLOAT16
CL_ABAP_RANDOM_DECFLOAT34
CL_ABAP_RANDOM_FLOAT
CL_ABAP_RANDOM_INT
CL_ABAP_RANDOM_PACKED
CL_ABAP_RANDOM_PACKED_DEC1
CL_ABAP_RANDOM_PACKED_DEC2
CL_ABAP_RANDOM_PACKED_DEC3
CL_ABAP_RANDOM_PACKED_DEC4
CL_ABAP_RANDOM_PACKED_DEC5
CL_ABAP_RANDOM_PACKED_DEC6
CL_ABAP_RANDOM_PACKED_DEC7
CL_ABAP_RANDOM_PACKED_DEC8
CL_ABAP_RANDOM_PACKED_DEC9
CL_ABAP_RANDOM_PACKED_DEC10
CL_ABAP_RANDOM_PACKED_DEC11
CL_ABAP_RANDOM_PACKED_DEC12
CL_ABAP_RANDOM_PACKED_DEC13
CL_ABAP_RANDOM_PACKED_DEC14
CPI1466 during Backup General Data in Customer Master
Diese Dokumentation steht unter dem Copyright der SAP AG.
Length: 5981 Date: 20240425 Time: 004736 sap01-206 ( 84 ms )