/** * Returns a uniformly distributed random number in the closed interval * <tt>[from,to]</tt> (including <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public static int staticNextIntFromTo(int from, int to) { synchronized (shared) { return shared.nextIntFromTo(from, to); } }
/** * Returns a uniformly distributed random number in the closed interval * <tt>[from,to]</tt> (including <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public static int staticNextIntFromTo(int from, int to) { synchronized (shared) { return shared.nextIntFromTo(from, to); } }
nextTriggerPos = 0; // tuned for speed else nextTriggerPos = generator.nextIntFromTo(0, weight - 1);
/** * Returns a uniformly distributed random number in the closed interval * <tt>[min,max]</tt> (including <tt>min</tt> and <tt>max</tt>). */ public int nextInt() { return nextIntFromTo((int) Math.round(min), (int) Math.round(max)); }
/** * Returns a uniformly distributed random number in the closed interval * <tt>[min,max]</tt> (including <tt>min</tt> and <tt>max</tt>). */ public int nextInt() { return nextIntFromTo((int) Math.round(min), (int) Math.round(max)); }
int random; for (int i = from; i < to; i++) { random = gen.nextIntFromTo(i, to);
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) boolean tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) char tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) int tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) byte tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) int tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) long tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) short tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) byte tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) long tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) boolean tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) char tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) short tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( AbstractDoubleDistribution.makeDefaultGenerator()); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) double tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( AbstractDoubleDistribution.makeDefaultGenerator()); for (int i = from; i < to; i++) { int random = gen.nextIntFromTo(i, to); // swap(i, random) double tmpElement = getQuick(random); setQuick(random, getQuick(i)); setQuick(i, tmpElement); } }