-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
129 deletions.
There are no files selected for viewing
69 changes: 0 additions & 69 deletions
69
mihxil-algebra/src/main/java/org/meeuw/math/abstractalgebra/dihedral/DiHedralGroup.java
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
mihxil-algebra/src/main/java/org/meeuw/math/abstractalgebra/dihedral/DihedralGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.meeuw.math.abstractalgebra.dihedral; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.stream.IntStream; | ||
import java.util.stream.Stream; | ||
|
||
import org.meeuw.math.abstractalgebra.*; | ||
import org.meeuw.math.text.TextUtils; | ||
|
||
/** | ||
* @since 0.14 | ||
* @see org.meeuw.math.abstractalgebra.dihedral | ||
*/ | ||
public class DihedralGroup implements Group<DihedralSymmetry>, Streamable<DihedralSymmetry> { | ||
|
||
public static Map<Integer, DihedralGroup> CACHE = new ConcurrentHashMap<>(); | ||
final int n; | ||
|
||
private DihedralGroup(int n) { | ||
this.n = n; | ||
} | ||
public static DihedralGroup of(int n) { | ||
return CACHE.computeIfAbsent(n, DihedralGroup::new); | ||
} | ||
|
||
|
||
public DihedralSymmetry r(int k) { | ||
return DihedralSymmetry.r(k, this); | ||
} | ||
|
||
public DihedralSymmetry s(int k) { | ||
return DihedralSymmetry.s(k, this); | ||
} | ||
|
||
@Override | ||
public DihedralSymmetry unity() { | ||
return DihedralSymmetry.r(0, this); | ||
} | ||
|
||
@Override | ||
public Cardinality getCardinality() { | ||
return Cardinality.of(2L * n); | ||
} | ||
|
||
@Override | ||
public Class<DihedralSymmetry> getElementClass() { | ||
return DihedralSymmetry.class; | ||
} | ||
|
||
@Override | ||
public Stream<DihedralSymmetry> stream() { | ||
return Stream.concat( | ||
IntStream.range(0, n) | ||
.mapToObj(i -> DihedralSymmetry.r(i, this)), | ||
IntStream.range(0, n) | ||
.mapToObj(i -> DihedralSymmetry.s(i, this)) | ||
); | ||
} | ||
|
||
@Override | ||
public boolean operationIsCommutative() { | ||
return n <= 2; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "D" + TextUtils.subscript(n); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
mihxil-algebra/src/main/java/org/meeuw/math/abstractalgebra/dihedral/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* The <a href="https://en.wikipedia.org/wiki/Dihedral_group"></a>dihedral symmetry groups</a> | ||
* @since 0.14 | ||
*/ | ||
package org.meeuw.math.abstractalgebra.dihedral; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters