// 3/1/2007 DCC sedhepts.c reads in a file: 1st line is signmask, subsequent lines have 1 triad per line;
// output is html
format of sedenion multiplication table, followed by ordered list of triads, then list of heptads (if any) by triad index
#include
int triads[35][3], hept[7];
int main() {
int i, j, k, l;
long long signmask;
FILE *fp;
int M0[16][16];
char S[16][16], odd, even;
char filnam[50], line[20];
printf("\n");
printf("Read signmask, triads from:
\n");
scanf("%s", filnam);
fp = fopen(filnam, "r");
fgets(line, 20, fp);
sscanf(line,"%llx", &signmask);
printf("");
for(i=0; i<35; i++)
{
fgets(line, 20, fp);
sscanf(line, "%d,%d,%d", &triads[i][0], &triads[i][1], &triads[i][2]);
printf("%d: e%d,e%d,e%d | ",i,triads[i][0],triads[i][1],triads[i][2]);
if(i%5==4) printf("
\n");
}
printf("
");
M0[0][0] = 0;
for(i=0; i<16; i++) for(j=0; j<16; j++) S[i][j] = ' ';
for(i=1; i<16; i++)
{
M0[0][i] = M0[i][0] = i;
M0[i][i] = 0;
S[i][i] = '-';
}
for(i=0; i<35; i++)
{
odd = '-';
even = ' ';
if(signmask & (1LL<\n");
printf(" | ");
for(j=0; j<16; j++)
printf(" e%d | ", M0[0][j]);
printf("
\n");
for(i=0; i<16; i++)
{
printf(" e%d | ", M0[i][0]);
for(j=0; j<16; j++)
printf(" %ce%d | ", S[i][j], M0[i][j]);
printf("
\n");
}
printf("
\n");
for(i=0; i<35; i++)
for(j=i+1; j<35; j++) // for each pair of triplets, see if they make a heptad
{
if((l=intersect(i,j)) == 3) continue;
// if here, intersecting triads
hept[0] = triads[i][l];
hept[1] = triads[i][(l+1)%3];
hept[2] = triads[i][(l+2)%3];
for(k=0;k<3 && triads[j][k] != triads[i][l]; k++);
hept[3] = triads[j][(k+1)%3];
hept[4] = triads[j][(k+2)%3];
hept[5] = M0[hept[1]][hept[3]];
hept[6] = M0[hept[1]][hept[4]];
printf("%d#%d: ",i,j);
for(k=0; k<7; k++) printf("%d ", hept[k]);
if(M0[hept[2]][hept[4]] != hept[5]) printf("... %d*%d = %d ",hept[2],hept[4],M0[hept[2]][hept[4]]);
if(M0[hept[2]][hept[3]] != hept[6]) printf("... %d*%d = %d ",hept[2],hept[3],M0[hept[2]][hept[3]]);
if(M0[hept[5]][hept[6]] != hept[0]) printf("... %d*%d = %d ",hept[5],hept[6],M0[hept[5]][hept[6]]);
printf("\n
");
}
printf("