/** * Returns {@code true} if all generators are identity (and, consequently, the underlying permutation group is trivial) * and false otherwise. * * @return {@code true} if all generators are identity */ public final boolean isTrivial() { for (Permutation p : generators) if (!p.isIdentity()) return false; return true; }
/** * Returns true if this group is trivial and false otherwise. * * @return true if this group is trivial and false otherwise */ public boolean isTrivial() { if (isTrivial != null) return isTrivial.booleanValue(); isTrivial = true; for (Permutation p : generators) if (!p.isIdentity()) { isTrivial = false; break; } return isTrivial; }
@Override public boolean is(Permutation permutation) { if (permutation.isIdentity()) return false; for (Permutation p : subgroup.generators()) if (!p.commutator(permutation).isIdentity()) return false; return true; }
/** * Returns whether specified permutation belongs to permutation group defined by specified base and strong * generating set. * * @param BSGS base and strong generating set * @param permutation permutation * @return true if specified permutation belongs to permutation group defined by specified base and strong * generating set and false otherwise */ public static boolean membershipTest(final List<? extends BSGSElement> BSGS, Permutation permutation) { StripContainer sc = strip(BSGS, permutation); return sc.terminationLevel == BSGS.size() && sc.remainder.isIdentity(); }
/** * Returns true if this group is abelian and false otherwise. * * @return true if this group is abelian and false otherwise. */ public boolean isAbelian() { if (isTrivial()) return true; if (isAbelian != null) return isAbelian.booleanValue(); isAbelian = true; List<Permutation> generators = generators(); final int size = generators.size(); out: for (int i = 0; i < size; ++i) for (int j = i + 1; j < size; ++j) if (!generators.get(i).commutator(generators.get(j)).isIdentity()) return isAbelian = false; return isAbelian.booleanValue(); }
private void calculateSortedOrbit(int level) { if (word[level - 1].isIdentity()) sortedOrbits[level] = cachedSortedOrbits[level]; else { sortedOrbits[level] = word[level - 1].imageOf(bsgs.get(level).orbitList.toArray()); ArraysUtils.quickSort(sortedOrbits[level], ordering); } } }
/** * Returns a commutator of this group with specified group. * * @param group permutation group * @return commutator of this and specified group */ public PermutationGroup commutator(PermutationGroup group) { //commutator is normal closure of set [generators, group.generators] in <generators,group.generators>. ArrayList<Permutation> commutator = new ArrayList<>(); Permutation c; for (Permutation a : generators) for (Permutation b : group.generators) { c = a.commutator(b); if (!c.isIdentity()) commutator.add(c); } if (commutator.isEmpty()) return TRIVIAL_GROUP; return union(group).normalClosureOf(createPermutationGroup(commutator)); }
/** * Returns true if specified permutation is member of this group and false otherwise. * * @param permutation permutation * @return true if specified permutation is member of this group and false otherwise */ public boolean membershipTest(Permutation permutation) { if (isTrivial()) return permutation.isIdentity(); return AlgorithmsBase.membershipTest(getBSGS(), permutation); }
@Override public Permutation compositionWithInverse(final Permutation other) { if (this.isIdentity) return other.inverse(); if (other.isIdentity()) return this; return composition(other.inverse()); }
@Override public Permutation compositionWithInverse(final Permutation other) { if (this.isIdentity) return other.inverse(); if (other.isIdentity()) return this; return composition(other.inverse()); }
@Override public Permutation compositionWithInverse(final Permutation other) { if (this.isIdentity) return other.inverse(); if (other.isIdentity()) return this; return composition(other.inverse()); }
@Override public Permutation compositionWithInverse(final Permutation other) { if (this.isIdentity) return other.inverse(); if (other.isIdentity()) return this; return composition(other.inverse()); }
@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(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 > 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(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()); if (newLength > Short.MAX_VALUE) return toIntRepresentation().composition(a, b); short newInternalDegree = -1; final short[] result = new short[newLength]; boolean resultIsIdentity = true; for (short i = 0; i < newLength; ++i) { result[i] = (short) 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(), (short) (newInternalDegree + 1), result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + a + " and " + b); } }
@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()); if (newLength > Byte.MAX_VALUE) return toLargerRepresentation(newLength).composition(a, b); byte newInternalDegree = -1; final byte[] result = new byte[newLength]; boolean resultIsIdentity = true; for (byte i = 0; i < newLength; ++i) { result[i] = (byte) 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(), (byte) (newInternalDegree + 1), result); } catch (InconsistentGeneratorsException ex) { throw new InconsistentGeneratorsException(this + " and " + a + " and " + b); } }
@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); } }