View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.rng.core.source64;
19  
20  /**
21   * A large-state all-purpose 64-bit generator.
22   *
23   * <p>This is a member of the Xor-Shift-Rotate family of generators. Memory footprint is 1024 bits
24   * and the period is 2<sup>1024</sup>-1.</p>
25   *
26   * <p>Note: This can be used as a replacement for {@link XorShift1024Star}.</p>
27   *
28   * @see <a href="http://xorshift.di.unimi.it/xoroshiro1024starstar.c">Original source code</a>
29   * @see <a href="http://xoshiro.di.unimi.it/">xorshiro / xoroshiro generators</a>
30   * @since 1.3
31   */
32  public class XoRoShiRo1024StarStar extends AbstractXoRoShiRo1024 {
33      /**
34       * Creates a new instance.
35       *
36       * @param seed Initial seed.
37       * If the length is larger than 16, only the first 16 elements will
38       * be used; if smaller, the remaining elements will be automatically
39       * set. A seed containing all zeros will create a non-functional generator.
40       */
41      public XoRoShiRo1024StarStar(long[] seed) {
42          super(seed);
43      }
44  
45      /**
46       * Creates a copy instance.
47       *
48       * @param source Source to copy.
49       */
50      protected XoRoShiRo1024StarStar(XoRoShiRo1024StarStar source) {
51          super(source);
52      }
53  
54      /** {@inheritDoc} */
55      @Override
56      protected long transform(long s0, long s15) {
57          return Long.rotateLeft(s0 * 5, 7) * 9;
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      protected XoRoShiRo1024StarStar copy() {
63          // This exists to ensure the jump function returns
64          // the correct class type. It should not be public.
65          return new XoRoShiRo1024StarStar(this);
66      }
67  }