summaryrefslogtreecommitdiff
path: root/lib/dihedral.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-10 12:37:02 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-10 12:37:02 -0400
commite53a4c09eb78e4c5a8365f1328a69ba7f9ff8992 (patch)
tree3c252af9ffafacab8392bf864270dcd034ed07ed /lib/dihedral.c
parent609fb52b670d8ed74584a988b8c63da82d8d523b (diff)
parent1810103bc9ac4c9a8d432d113f5ca6eae6560fb4 (diff)
downloadc++-e53a4c09eb78e4c5a8365f1328a69ba7f9ff8992.tar.gz
c++-e53a4c09eb78e4c5a8365f1328a69ba7f9ff8992.tar.bz2
c++-e53a4c09eb78e4c5a8365f1328a69ba7f9ff8992.zip
Merge branch 'master' of m5:/srv/git/wolff
Diffstat (limited to 'lib/dihedral.c')
-rw-r--r--lib/dihedral.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/dihedral.c b/lib/dihedral.c
index ac74a23..8158b43 100644
--- a/lib/dihedral.c
+++ b/lib/dihedral.c
@@ -11,10 +11,14 @@ dihedral_t *dihedral_compose(q_t q, q_t g1i, const dihedral_t *g2) {
return g3;
}
-q_t dihedral_act(q_t q, q_t gi, q_t s) {
+q_t dihedral_act(q_t q, q_t gi, bool r, q_t s) {
// we only need to consider the action of reflections
- return (gi + q - s) % q;
+ if (r) {
+ return (gi + q - s) % q;
+ } else {
+ return (gi + s) % q;
+ }
}
q_t dihedral_inverse_act(q_t q, const dihedral_t *g, q_t s) {
@@ -26,15 +30,26 @@ q_t dihedral_inverse_act(q_t q, const dihedral_t *g, q_t s) {
}
q_t *dihedral_gen_transformations(q_t q) {
- q_t *transformations = (q_t *)malloc(q * q * sizeof(q_t));
+ q_t *transformations = (q_t *)malloc(2 * q * q * sizeof(q_t));
for (q_t i = 0; i < q; i++) {
for (q_t j = 0; j < q; j++) {
- transformations[q * i + j] = dihedral_act(q, i, j);
+ transformations[q * i + j] = dihedral_act(q, i, false, j);
+ transformations[q * q + q * i + j] = dihedral_act(q, i, true, j);
}
}
return transformations;
}
+R_t *dihedral_gen_involutions(q_t q) {
+ R_t *transformations = (R_t *)malloc(q * sizeof(R_t));
+
+ for (q_t i = 0; i < q; i++) {
+ transformations[i] = q + i;
+ }
+
+ return transformations;
+}
+