Iterator<Permutation> cosetRepresentatives;
BigInteger factor;
//for a simple tensors we can compute coset representatives directly:
if (t instanceof SimpleTensor) {
PermutationGroup t_group =
conjugatedSymmetriesOfSubIndices(((SimpleTensor) t).getIndices());
PermutationGroup union = t_group.union(indicesGroup);
Permutation[] reps = union.leftCosetRepresentatives(t_group);
cosetRepresentatives = new ArrayIterator<>(reps);
factor = BigInteger.valueOf(reps.length);
} else {
//in case of multitensor, we do not know its group of symmetries
//if the resulting symmetries are small, then we'll just apply all of them
if (indicesGroup.order().compareTo(SMALL_ORDER_MAX_VALUE) < 0) {
cosetRepresentatives = indicesGroup.iterator();
factor = indicesGroup.order();
} else {
//otherwise we might will be more lucky if compute it group of symmetries and then compute coset reps.
PermutationGroup t_group = PermutationGroup.createPermutationGroup(
TensorUtils.findIndicesSymmetries(indices, t));
PermutationGroup union = t_group.union(indicesGroup);
Permutation[] reps = union.leftCosetRepresentatives(t_group);
cosetRepresentatives = new ArrayIterator<>(reps);
factor = BigInteger.valueOf(reps.length);
}
}