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 large-state all-purpose 64-bit generator.
022 *
023 * <p>This is a member of the Xor-Shift-Rotate family of generators. Memory footprint is 1024 bits
024 * and the period is 2<sup>1024</sup>-1.</p>
025 *
026 * <p>Note: This can be used as a replacement for {@link XorShift1024Star}.</p>
027 *
028 * @see <a href="http://xorshift.di.unimi.it/xoroshiro1024plusplus.c">Original source code</a>
029 * @see <a href="http://xoshiro.di.unimi.it/">xorshiro / xoroshiro generators</a>
030 * @since 1.3
031 */
032public class XoRoShiRo1024PlusPlus extends AbstractXoRoShiRo1024 {
033    /**
034     * Creates a new instance.
035     *
036     * @param seed Initial seed.
037     * If the length is larger than 16, only the first 16 elements will
038     * be used; if smaller, the remaining elements will be automatically
039     * set. A seed containing all zeros will create a non-functional generator.
040     */
041    public XoRoShiRo1024PlusPlus(long[] seed) {
042        super(seed);
043    }
044
045    /**
046     * Creates a copy instance.
047     *
048     * @param source Source to copy.
049     */
050    protected XoRoShiRo1024PlusPlus(XoRoShiRo1024PlusPlus source) {
051        super(source);
052    }
053
054    /** {@inheritDoc} */
055    @Override
056    protected long transform(long s0, long s15) {
057        return Long.rotateLeft(s0 + s15, 23) + s15;
058    }
059
060    /** {@inheritDoc} */
061    @Override
062    protected XoRoShiRo1024PlusPlus copy() {
063        // This exists to ensure the jump function returns
064        // the correct class type. It should not be public.
065        return new XoRoShiRo1024PlusPlus(this);
066    }
067}