-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
56 lines (48 loc) · 1.18 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import math
import numpy as np
def cartesian_product(x):
result = set()
for first_value in x:
for second_value in x:
result.add((first_value, second_value))
return result
gauss_values = [
{
-1/math.sqrt(3): 1,
1/math.sqrt(3): 1
},
{
-math.sqrt(3/5): 5/9,
0: 8/9,
math.sqrt(3/5): 5/9
},
{
-0.861136: 0.347855,
-0.339981: 0.652145,
0.339981: 0.652145,
0.861136: 0.347855
}
]
gauss_points = [list(cartesian_product(gauss_values[i].keys()))
for i in range(len(gauss_values))]
i = 0
def sides_sort(x):
x.sort(key=lambda x: x[1])
length = len(gauss_values[i])
cnt = 0
b = True
while cnt < len(x):
if b:
slc = x[cnt:cnt+length]
slc.sort(key=lambda x: x[0])
x[cnt:cnt+length] = slc
else:
slc = x[cnt:cnt+length]
slc.sort(key=lambda x: -x[0])
x[cnt:cnt+length] = slc
cnt += length
b = not b
for v in x:
print(v)
l = list(gauss_points[i])
sides_sort(l)