/** * Calculates minimal capacity needed to store Schreier vector * * @param stabilizerGenerators stabilizers * @return minimal capacity needed to store Schreier vector */ private static int calculateSVCapacity(List<Permutation> stabilizerGenerators) { int capacity = -1; for (Permutation p : stabilizerGenerators) capacity = Math.max(capacity, p.degree()); return capacity; }
/** * Calculates common <i>degree</i> of specified permutations, i.e.larges point moved by specified permutations plus * one. * * @param permutations permutations * @return larges point moved by specified permutations plus one */ public static int internalDegree(final List<? extends Permutation> permutations) { int r = 0; for (Permutation p : permutations) r = Math.max(r, p.degree()); return r; }
public void addStabilizer(Permutation stabilizer) { internalDegree = Math.max(internalDegree, stabilizer.degree()); stabilizerGenerators.add(stabilizer); recalculateOrbitAndSchreierVector(); }
/** * This method checks whether specified permutation is consistent with * specified indices. Permutation considered to be consistent if it has * similar length and does not permutes indices with different types. * * @param indices indices array to be checked * @param permutation permutation in one-line notation * @return {@code false} if permutation permutes indices with different * types or have different length and true in other case */ public static boolean isPermutationConsistentWithIndices(final int[] indices, Permutation permutation) { if (indices.length < permutation.degree()) return false; for (int i = 0, s = permutation.degree(); i < s; ++i) if (getRawTypeInt(indices[i]) != getRawTypeInt(indices[permutation.newIndexOf(i)])) return false; return true; }
/** * Creates symmetries of indices with specified structure and with specified generating set. * * @param structureOfIndices structure of indices for which this symmetries can be assigned * @param generators generating set * @return symmetries with specified generating set for indices with specified structure * @throws java.lang.IllegalArgumentException if some generator in {@code generators} have degree different from * size of {@code structureOfIndices} */ public static IndicesSymmetries create(StructureOfIndices structureOfIndices, List<Permutation> generators) { for (Permutation p : generators) if (p.degree() > structureOfIndices.size()) throw new IllegalArgumentException("Permutation degree not equal to indices size."); if (structureOfIndices.size() == 0) return getEmpty(); return new IndicesSymmetries(structureOfIndices, new ArrayList<>(generators), null); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof Permutation)) return false; Permutation that = (Permutation) o; if (antisymmetry != that.antisymmetry()) return false; if (internalDegree != that.degree()) return false; for (int i = 0; i < internalDegree; ++i) if (newIndexOf(i) != that.newIndexOf(i)) return false; return true; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof Permutation)) return false; Permutation that = (Permutation) o; if (antisymmetry != that.antisymmetry()) return false; if (internalDegree != that.degree()) return false; for (int i = 0; i < internalDegree; ++i) if (newIndexOf(i) != that.newIndexOf(i)) return false; return true; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof Permutation)) return false; Permutation that = (Permutation) o; if (antisymmetry != that.antisymmetry()) return false; if (internalDegree != that.degree()) return false; for (int i = 0; i < internalDegree; ++i) if (newIndexOf(i) != that.newIndexOf(i)) return false; return true; }
@Override public int compareTo(Permutation t) { final int max = Math.max(degree(), t.degree()); if (antisymmetry != t.antisymmetry()) return antisymmetry ? -1 : 1; for (int i = 0; i < max; ++i) if (newIndexOf(i) < t.newIndexOf(i)) return -1; else if (newIndexOf(i) > t.newIndexOf(i)) return 1; return 0; } }
@Override public int compareTo(Permutation t) { final int max = Math.max(degree(), t.degree()); if (antisymmetry != t.antisymmetry()) return antisymmetry ? -1 : 1; for (int i = 0; i < max; ++i) if (newIndexOf(i) < t.newIndexOf(i)) return -1; else if (newIndexOf(i) > t.newIndexOf(i)) return 1; return 0; } }
@Override public int compareTo(Permutation t) { final int max = Math.max(degree(), t.degree()); if (antisymmetry != t.antisymmetry()) return antisymmetry ? -1 : 1; for (int i = 0; i < max; ++i) if (newIndexOf(i) < t.newIndexOf(i)) return -1; else if (newIndexOf(i) > t.newIndexOf(i)) return 1; return 0; } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof Permutation)) return false; Permutation that = (Permutation) o; if (antisymmetry != that.antisymmetry()) return false; if (degree() != that.degree()) return false; for (int i = 0; i < degree(); ++i) if (newIndexOf(i) != that.newIndexOf(i)) return false; return true; }
@Override public int compareTo(Permutation t) { int c = Integer.compare(degree(), t.degree()); if (c != 0) return c; if (antisymmetry != t.antisymmetry()) return antisymmetry ? -1 : 1; for (int i = 0; i < degree(); ++i) if (newIndexOf(i) < t.newIndexOf(i)) return -1; else if (newIndexOf(i) > t.newIndexOf(i)) return 1; return 0; } }
@Override public Permutation composition(Permutation a, Permutation b, Permutation c) { if (this.isIdentity) return a.composition(b, c); if (a.isIdentity()) return composition(b, c); if (b.isIdentity()) return composition(a, c); if (c.isIdentity()) return composition(b, c); final int newLength = Math.max(c.degree(), Math.max( Math.max(degree(), a.degree()), b.degree())); final int[] result = new int[newLength]; int newInternalDegree = -1; boolean resultIsIdentity = true; for (int i = 0; i < newLength; ++i) { result[i] = c.newIndexOf(b.newIndexOf(a.newIndexOf(newIndexOf(i)))); resultIsIdentity &= result[i] == i; newInternalDegree = result[i] == i ? newInternalDegree : i; } try { return new PermutationOneLineInt(resultIsIdentity, antisymmetry ^ a.antisymmetry() ^ b.antisymmetry() ^ c.antisymmetry(), newInternalDegree + 1, result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + a + " and " + b + " and " + c); } }
@Override public Permutation composition(Permutation a, Permutation b) { if (this.isIdentity) return a.composition(b); if (a.isIdentity()) return composition(b); if (b.isIdentity()) return composition(a); final int newLength = Math.max(Math.max(degree(), a.degree()), b.degree()); int newInternalDegree = -1; final int[] result = new int[newLength]; boolean resultIsIdentity = true; for (int i = 0; i < newLength; ++i) { result[i] = b.newIndexOf(a.newIndexOf(newIndexOf(i))); resultIsIdentity &= result[i] == i; newInternalDegree = result[i] == i ? newInternalDegree : i; } try { return new PermutationOneLineInt(resultIsIdentity, antisymmetry ^ a.antisymmetry() ^ b.antisymmetry(), newInternalDegree + 1, result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + a + " and " + b); } }
@Override public Permutation composition(Permutation a, Permutation b, Permutation c) { if (this.isIdentity) return a.composition(b, c); if (a.isIdentity()) return composition(b, c); if (b.isIdentity()) return composition(a, c); if (c.isIdentity()) return composition(b, c); final int newLength = Math.max(c.degree(), Math.max( Math.max(degree(), a.degree()), b.degree())); if (newLength > Short.MAX_VALUE) return toIntRepresentation().composition(a, b, c); final short[] result = new short[newLength]; short newInternalDegree = -1; boolean resultIsIdentity = true; for (short i = 0; i < newLength; ++i) { result[i] = (short) c.newIndexOf(b.newIndexOf(a.newIndexOf(newIndexOf(i)))); resultIsIdentity &= result[i] == i; newInternalDegree = result[i] == i ? newInternalDegree : i; } try { return new PermutationOneLineShort(resultIsIdentity, antisymmetry ^ a.antisymmetry() ^ b.antisymmetry() ^ c.antisymmetry(), (short) (newInternalDegree + 1), result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + a + " and " + b + " and " + c); } }
@Override public Permutation composition(final Permutation other) { if (this.isIdentity) return other; if (other.isIdentity()) return this; final int newLength = Math.max(degree(), other.degree()); int newInternalDegree = -1; final int[] result = new int[newLength]; boolean resultIsIdentity = true; for (int i = 0; i < newLength; ++i) { result[i] = other.newIndexOf(newIndexOf(i)); resultIsIdentity &= result[i] == i; newInternalDegree = result[i] == i ? newInternalDegree : i; } try { return new PermutationOneLineInt(resultIsIdentity, antisymmetry ^ other.antisymmetry(), newInternalDegree + 1, result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + other); } }
@Override public Permutation composition(Permutation a, Permutation b, Permutation c) { if (this.isIdentity) return a.composition(b, c); if (a.isIdentity()) return composition(b, c); if (b.isIdentity()) return composition(a, c); if (c.isIdentity()) return composition(b, c); final int newLength = Math.max(c.degree(), Math.max( Math.max(degree(), a.degree()), b.degree())); if (newLength > Byte.MAX_VALUE) return toLargerRepresentation(newLength).composition(a, b, c); final byte[] result = new byte[newLength]; byte newInternalDegree = -1; boolean resultIsIdentity = true; for (byte i = 0; i < newLength; ++i) { result[i] = (byte) c.newIndexOf(b.newIndexOf(a.newIndexOf(newIndexOf(i)))); resultIsIdentity &= result[i] == i; newInternalDegree = result[i] == i ? newInternalDegree : i; } try { return new PermutationOneLineByte(resultIsIdentity, antisymmetry ^ a.antisymmetry() ^ b.antisymmetry() ^ c.antisymmetry(), (byte) (newInternalDegree + 1), result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + a + " and " + b + " and " + c); } }
@Override public Permutation composition(final Permutation other) { if (this.isIdentity) return other; if (other.isIdentity()) return this; final int newLength = Math.max(degree(), other.degree()); if (newLength > Short.MAX_VALUE) return toIntRepresentation().composition(other); short newInternalDegree = -1; final short[] result = new short[newLength]; boolean resultIsIdentity = true; for (short i = 0; i < newLength; ++i) { result[i] = (short) other.newIndexOf(newIndexOf(i)); resultIsIdentity &= result[i] == i; newInternalDegree = result[i] == i ? newInternalDegree : i; } try { return new PermutationOneLineShort(resultIsIdentity, antisymmetry ^ other.antisymmetry(), (short) (newInternalDegree + 1), result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + other); } }
@Override public Permutation composition(final Permutation other) { if (this.isIdentity) return other; if (other.isIdentity()) return this; final int newLength = Math.max(degree(), other.degree()); if (newLength > Byte.MAX_VALUE) return toLargerRepresentation(newLength).composition(other); byte newInternalDegree = -1; final byte[] result = new byte[newLength]; boolean resultIsIdentity = true; for (byte i = 0; i < newLength; ++i) { result[i] = (byte) other.newIndexOf(newIndexOf(i)); resultIsIdentity &= result[i] == i; newInternalDegree = result[i] == i ? newInternalDegree : i; } try { return new PermutationOneLineByte(resultIsIdentity, antisymmetry ^ other.antisymmetry(), (byte) (newInternalDegree + 1), result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + other); } }