From 372a9503b64e8dce8ec15816b949f3e08aab4996 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 15 Mar 2019 12:47:08 +0100 Subject: [PATCH] 3d:: fieldpattern now works in 3D --- fieldpattern.cpp | 77 +++++++++++++++++++++++++++++++++--------------- hyper.h | 5 ++++ 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/fieldpattern.cpp b/fieldpattern.cpp index 6cd415d1..88f58a09 100644 --- a/fieldpattern.cpp +++ b/fieldpattern.cpp @@ -15,25 +15,25 @@ bool isprime(int n) { } struct matrix { - int a[3][3]; + int a[MAXMDIM][MAXMDIM]; int* operator [] (int k) { return a[k]; } const int* operator [] (int k) const { return a[k]; } }; bool operator == (const matrix& A, const matrix& B) { - for(int i=0; i<3; i++) for(int j=0; j<3; j++) + for(int i=0; i qcoords; - matrix Id, R, P; + // S7 in 2D, but e.g. 4 for a 3D cube + int rotations; + + // S7 in 2D, but e.g. 24 for a 3D cube + int local_group; + + // Id: Identity + // R : rotate by 1/rotations of the full circle + // P : make a step and turn backwards + // X : in 3-dim, turn by 90 degrees + + matrix Id, R, P, X; matrix strtomatrix(string s) { matrix res = Id; @@ -149,6 +160,7 @@ struct fpattern { matcode[M] = i, matrices.push_back(M); for(int j=0; j connections; - vector inverses; - vector rrf; // rrf[i] equals gmul(i, S7-1) - vector rpf; // rpf[i] equals gmul(i, S7) + vector inverses; // NYI in 3D + + // 2D only + vector rrf; // rrf[i] equals gmul(i, rotations-1) + vector rpf; // rpf[i] equals gmul(i, rotations) matrix mpow(matrix M, int N) { while((N&1) == 0) N >>= 1, M = mmul(M, M); @@ -201,11 +215,14 @@ struct fpattern { int solve() { - for(int a=0; a<3; a++) for(int b=0; b<3; b++) Id[a][b] = a==b?1:0; + for(int a=0; a3) break; @@ -234,8 +251,9 @@ struct fpattern { printf("\n"); } - for(int i=0; i<3; i++) for(int j=0; j<3; j++) - R[i][j] = P[i][j] = i==j ? 1 : 0; + R = P = X = Id; + X[1][1] = 0; X[2][2] = 0; + X[1][2] = 1; X[2][1] = Prime-1; for(cs=0; cs g(geometry, gSpace435); + static fpattern fp(5); + return fp; + } if(S7 == 8 && S3 == 3) { static fpattern fp(17); return fp; @@ -790,6 +817,10 @@ void enableFieldChange() { int currfp_gmul(int a, int b) { return currfp.gmul(a,b); } int currfp_inverses(int i) { return currfp.inverses[i]; } int currfp_distwall(int i) { return currfp.distwall[i]; } +int currfp_n() { return isize(currfp.matrices); } +int currfp_get_R() { return currfp.matcode[currfp.R]; } +int currfp_get_P() { return currfp.matcode[currfp.P]; } +int currfp_get_X() { return currfp.matcode[currfp.X]; } } #endif diff --git a/hyper.h b/hyper.h index 910d408c..a96ee1df 100644 --- a/hyper.h +++ b/hyper.h @@ -3190,6 +3190,11 @@ namespace fieldpattern { int currfp_gmul(int a, int b); int currfp_inverses(int i); int currfp_distwall(int i); + +int currfp_n(); +int currfp_get_P(); +int currfp_get_R(); +int currfp_get_X(); #endif const char *dnameof(eMonster m);