Compare commits

..

3 Commits

Author SHA1 Message Date
Florian Stecker
f89545e995 simplify image generation 2022-06-18 14:54:50 +02:00
Florian Stecker
920a530385 remove unnecessary function qext_newtype() 2022-06-16 15:43:19 +02:00
Florian Stecker
cfc13d2ba7 add useful help text 2022-06-15 18:47:55 +02:00
4 changed files with 27 additions and 53 deletions

View File

@@ -161,10 +161,17 @@ int main(int argc, char *argv[])
if(mode == MODE_HELP) {
fprintf(stderr, "Usage: %s <help|evs|summary|trace_ids> [arguments]\n", argv[0]);
fprintf(stderr, "%s help display this page\n", argv[0]);
fprintf(stderr, "%s evs <n> <q1> <q2> <q3> <treal> <timag> enumerate group and output unique (log) eigenvalue triples\n", argv[0]);
fprintf(stderr, "%s summary <n> <q1> <q2> <q3> <treal> <timag> only output max slope etc.\n", argv[0]);
fprintf(stderr, "%s help display this page\n", argv[0]);
fprintf(stderr, "%s evs <n> <q1> <q2> <q3> <treal> <timag> enumerate group and output unique (log) eigenvalue triples\n", argv[0]);
fprintf(stderr, "%s summary <n> <q1> <q2> <q3> <treal> <timag> only output max slope etc.\n", argv[0]);
fprintf(stderr, "%s trace_ids <n> <q1> <q2> <q3> <treal> <timag> list of ids of unique traces\n", argv[0]);
fprintf(stderr, "\n");
fprintf(stderr, "This program computes the traces and inverse traces of the first n elements of a SL(3,C) representation of the\n");
fprintf(stderr, "triangle reflection group with corner orders (5,5,5). The representation is given by the parameters q1,q2,q3,\n");
fprintf(stderr, "treal, and timag. q1,q2,q3 can each be 1 or 2 and determine the connected component. (1,1,1) is Hitchin and\n");
fprintf(stderr, "(2,2,2) is Barbot. treal and timag are the components of the complex parameter and have to be given as rational\n");
fprintf(stderr, "numbers. If the environment variable IDLIST is set to a filename, a list of elements can be read from this file.\n");
fprintf(stderr, "Such a list can be precomputed with the \"trace_ids\" subcommand and speeds up the computation considerably.\n");
return 0;
}

View File

@@ -3,65 +3,43 @@
import sys
import math
def sharpen(x):
alpha = 1
y = abs(2*x-1)**alpha # between 0 and 1
if x > 0.499 and x < 0.501:
return 0.5
elif x > 0.5:
return (y+1)/2
else:
return (1-y)/2
f = open(sys.argv[1])
lines = [x.split() for x in f]
f.close()
res1 = int(sys.argv[2]) # 400 pixel per unit
res2 = int(sys.argv[3]) # 50 pixel in picture (acutally one quadrant)
res = int(sys.argv[2]) # pixel per unit
data = {(round(float(l[0])*res1), round(float(l[1])*res1)) : float(l[5]) for l in lines}
data = {(round(float(l[0])*res), round(float(l[1])*res)) : float(l[5]) for l in lines}
data[(0,0)] = 2.0
xmin = min([p[0] for p in data.keys()])
xmax = max([p[0] for p in data.keys()])
ymin = min([p[1] for p in data.keys()])
ymax = max([p[1] for p in data.keys()])
yrange=max([-ymin,ymax])
print("P3")
print("1000 1000")
print("{dx:d} {dy:d}".format(dx=xmax-xmin+1, dy=2*yrange+1))
print("255")
for i in range (-500,500):
for j in range(-500,500):
x = j/500*res2
y = i/500*res2
for i in range(-yrange,yrange+1):
for j in range(xmin,xmax+1):
x = j
y = i if i >= ymin and i <= ymax else -i
if y < 0:
y = -y
x0 = math.floor(x)
y0 = math.floor(y)
x1 = math.ceil(x)
y1 = math.ceil(y)
tx = sharpen(x-x0)
ty = sharpen(y-y0)
if not (x0,y0) in data or not (x0,y1) in data or not (x1,y0) in data or not (x1,y1) in data:
if not (x,y) in data:
value = 0
else:
value = 0.0
value += data[(x0,y0)]*(1-tx)*(1-ty)
value += data[(x0,y1)]*(1-tx)*ty
value += data[(x1,y0)]*tx*(1-ty)
value += data[(x1,y1)]*tx*ty
value -= 1
value = data[(x,y)]-1
value = 0 if value < 0 else 1 if value > 1 else value
r = round(255*math.sqrt(value))
r = round(255*value**0.5)
g = round(255*(value)**3)
b = round(255*math.sin(2*math.pi*(value)))
b = round(255*(math.sin(2*math.pi*value)))
r = 0 if r < 0 else 255 if r > 255 else r
g = 0 if g < 0 else 255 if g > 255 else g
b = 0 if b < 0 else 255 if b > 255 else b
print("%d %d %d" % (r,g,b))
#print(data)

10
qext.c
View File

@@ -37,16 +37,6 @@ static void qext_init_type(struct qext_type *type)
}
}
struct qext_type *qext_newtype(int rank, const int *coeffs)
{
struct qext_type *type = malloc(sizeof(struct qext_type));
type->rank = rank;
type->integer_coeffs = coeffs;
qext_init_type(type);
return type;
}
void qext_init(qext_number x, struct qext_type *type)
{
if(type->coeffs == NULL) // uninitialized default type

1
qext.h
View File

@@ -20,7 +20,6 @@ extern struct qext_type *QT_TRIVIAL;
extern struct qext_type *QT_SQRT5;
extern struct qext_type *QT_GAUSS_SQRT5;
struct qext_type *qext_newtype(int rank, const int *coeffs);
void qext_init(qext_number x, struct qext_type *type);
void qext_clear(qext_number x);
void qext_set(qext_number x, qext_number y);