/** * Randomly permute the specified list using the specified source of randomness. * * @param a - the array to be shuffled. */ public static void shuffle(Object[] a) { shuffle(a, CC.getRandomGenerator()); }
/** * Returns uniformly distributed random permutation from this group. * * @return uniformly distributed random permutation from this group */ public Permutation randomElement() { return randomElement(CC.getRandomGenerator()); }
/** * Randomly permutes the specified array. * * @param a - the array to be shuffled. */ public static void shuffle(int[] a) { shuffle(a, CC.getRandomGenerator()); }
/** * Produces almost uniformly distributed elements of a group specified by specified generators (only if method * {@link #randomness(java.util.List, int, int, org.apache.commons.math3.random.RandomGenerator)} was invoked with specified generators); and brings additional * randomness in the specified list. See algorithm PRRANDOM in Sec. 3.2.2 in [Holt05]. * * @param generators generators (method {@link #randomness(java.util.List, int, int, org.apache.commons.math3.random.RandomGenerator)} should be invoked before) * @return random element of a group */ public static Permutation random(List<Permutation> generators) { return random(generators, CC.getRandomGenerator()); }
/** * Creates random permutation of specified dimension * * @param n dimension * @return random permutation of specified dimension */ public static int[] randomPermutation(final int n) { return randomPermutation(n, CC.getRandomGenerator()); }
/** * Brings randomness to a list of generators: the source list will be extended and filled by an equivalent set * of generators generated randomly; commonly it should be used in a combination with * {@link #random(java.util.List, org.apache.commons.math3.random.RandomGenerator)} to produce almost uniform distributed permutations in a group defined * by corresponding set of generators. This method is a variant of PREINITIALIZE described * in Sec. 3.2.2 in [Holt05]. * * @param generators a list of generators * @see #random(java.util.List, org.apache.commons.math3.random.RandomGenerator) */ public static void randomness(List<Permutation> generators) { randomness(generators, DEFAULT_RANDOMNESS_EXTEND_TO_SIZE, DEFAULT_NUMBER_OF_RANDOM_REFINEMENTS, CC.getRandomGenerator()); }
/** * Returns a random source of permutations in this group. * * @return a random source of permutations in this group * @see cc.redberry.core.groups.permutations.RandomPermutation#random(java.util.List, org.apache.commons.math3.random.RandomGenerator) */ public List<Permutation> randomSource() { if (randomSource == null) { ArrayList<Permutation> randomSource = new ArrayList<>(generators()); RandomPermutation.randomness(randomSource, 10, 20, CC.getRandomGenerator()); return this.randomSource = randomSource; } return randomSource; }
/** * Changes base of specified BSGS to specified new base by construction of a new BSGS with known base using * randomized Schreier-Sims algorithm {@link #RandomSchreierSimsAlgorithmForKnownOrder(java.util.ArrayList, java.math.BigInteger, org.apache.commons.math3.random.RandomGenerator)}. * The algorithm guaranties that if initial base is [b1, b2, b3, ..., bk] and specified base is [a1, a2, a3, ..., al], * then the resulting base will look like [a1, a2, a3, ...., al, x, y, ..., z] with no any redundant base * points at the end (redundant point is point which corresponding stabilizer generators are empty) but with some * additional points introduced if specified new base was not anought. * * @param BSGS BSGS * @param newBase new base */ public static void rebaseFromScratch(ArrayList<BSGSCandidateElement> BSGS, int[] newBase) { List<BSGSCandidateElement> newBSGS = createRawBSGSCandidate(newBase, BSGS.get(0).stabilizerGenerators, BSGS.get(0).internalDegree()); if (newBSGS.isEmpty())//todo add new base points here!!!! return; //new base is fixed by all group generators; nothing to do BigInteger order = calculateOrder(BSGS); RandomSchreierSimsAlgorithmForKnownOrder((ArrayList) newBSGS, order, CC.getRandomGenerator()); int i = 0; for (; i < newBSGS.size() && i < BSGS.size(); ++i) BSGS.set(i, newBSGS.get(i)); if (i < newBSGS.size()) for (; i < newBSGS.size(); ++i) BSGS.add(newBSGS.get(i)); if (i < BSGS.size()) for (int j = BSGS.size() - 1; j >= i; --j) BSGS.remove(j); }
RandomPermutation.randomness(closureSource, 10, 10, CC.getRandomGenerator()); AlgorithmsBase.RandomSchreierSimsAlgorithm(closure, NORMAL_CLOSURE_CONFIDENCE_LEVEL, CC.getRandomGenerator());