001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.rng.core.source64; 019 020/** 021 * A fast RNG implementing the {@code XorShift1024*} algorithm. 022 * 023 * <p>Note: This supersedes {@link XorShift1024Star}. The sequences emitted by both 024 * generators are correlated.</p> 025 * 026 * <p>This generator differs only in the final multiplier (a fixed-point representation 027 * of the golden ratio), which eliminates linear dependencies from one of the lowest 028 * bits.</p> 029 * 030 * @see <a href="http://xorshift.di.unimi.it/xorshift1024star.c">Original source code</a> 031 * @see <a href="https://en.wikipedia.org/wiki/Xorshift">Xorshift (Wikipedia)</a> 032 * @since 1.3 033 */ 034public class XorShift1024StarPhi extends XorShift1024Star { 035 /** 036 * Creates a new instance. 037 * 038 * @param seed Initial seed. 039 * If the length is larger than 16, only the first 16 elements will 040 * be used; if smaller, the remaining elements will be automatically 041 * set. A seed containing all zeros will create a non-functional generator. 042 */ 043 public XorShift1024StarPhi(long[] seed) { 044 super(seed, 0x9e3779b97f4a7c13L); 045 } 046 047 /** 048 * Creates a copy instance. 049 * 050 * @param source Source to copy. 051 */ 052 protected XorShift1024StarPhi(XorShift1024StarPhi source) { 053 super(source); 054 } 055 056 /** {@inheritDoc} */ 057 @Override 058 protected XorShift1024StarPhi copy() { 059 // This exists to ensure the jump function performed in the super class returns 060 // the correct class type. It should not be public. 061 return new XorShift1024StarPhi(this); 062 } 063}