f | def det4(r0, r1, r2, r3): | f | def det4(r0, r1, r2, r3): |
| | | |
t | def det3(r1, r2, r3): | t | def determ3(r1, r2, r3): |
| lst = [(1, 2, 3), (0, 2, 3), (0, 1, 3), (0, 1, 2)] | | perm = [(1, 2, 3), (0, 2, 3), (0, 1, 3), (0, 1, 2)] |
| dets3 = [] | | count = [] |
| for l in lst: | | for k in perm: |
| dets3.append(r1[l[0]] * (r2[l[1]] * r3[l[2]] - r2[l[2]] * r3[l[1]]) - r1[l[1]] * (r2[l[0]] * r3[l[2]] - r2[l[2]] * r3[l[0]]) + r1[l[2]] * (r2[l[0]] * r3[l[1]] - r2[l[1]] * r3[l[0]])) | | count.append(r1[k[0]] * (r2[k[1]] * r3[k[2]] - r2[k[2]] * r3[k[1]]) - r1[k[1]] * (r2[k[0]] * r3[k[2]] - r2[k[2]] * r3[k[0]]) + r1[k[2]] * (r2[k[0]] * r3[k[1]] - r2[k[1]] * r3[k[0]])) |
| return dets3 | | return count |
| res = det3(r1, r2, r3) | | fun = determ3(r1, r2, r3) |
| determinant = r0[0] * res[0] - r0[1] * res[1] + r0[2] * res[2] - r0[3] * res[3] | | det = r0[0] * fun[0] - r0[1] * fun[1] + r0[2] * fun[2] - r0[3] * fun[3] |
| return determinant | | return det |