summaryrefslogtreecommitdiff
path: root/lib/dihedral.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-02-28 20:33:41 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-02-28 20:33:41 -0500
commit1fbcb4dd4e52daeb53becba33827f8e48c5606b2 (patch)
tree6b8088fef6ca3e5f11551073b7793f6e9e767670 /lib/dihedral.c
parente0d4943090c285a44dad501cf9dc24714f9b3530 (diff)
downloadc++-1fbcb4dd4e52daeb53becba33827f8e48c5606b2.tar.gz
c++-1fbcb4dd4e52daeb53becba33827f8e48c5606b2.tar.bz2
c++-1fbcb4dd4e52daeb53becba33827f8e48c5606b2.zip
fixed major mistake in process, also got n-component version fully working
Diffstat (limited to 'lib/dihedral.c')
-rw-r--r--lib/dihedral.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/dihedral.c b/lib/dihedral.c
new file mode 100644
index 0000000..623041a
--- /dev/null
+++ b/lib/dihedral.c
@@ -0,0 +1,28 @@
+
+#include "dihedral.h"
+
+dihedral_t *dihedral_compose(q_t q, q_t g1i, const dihedral_t *g2) {
+ // we only need to consider the action of reflections
+ dihedral_t *g3 = (dihedral_t *)malloc(1 * sizeof(dihedral_t));
+
+ g3->r = !g2->r;
+ g3->i = (g1i + q - g2->i) % q;
+
+ return g3;
+}
+
+q_t dihedral_act(q_t q, q_t gi, q_t s) {
+ // we only need to consider the action of reflections
+
+ return (gi + q - s) % q;
+}
+
+q_t dihedral_inverse_act(q_t q, const dihedral_t *g, q_t s) {
+ if (g->r) {
+ return (q - ((q + s - g->i) % q)) % q;
+ } else {
+ return (q + s - g->i) % q;
+ }
+}
+
+