(l, r)
| 111 | return L |
| 112 | |
| 113 | def build_rotation_4d(l, r): |
| 114 | l_norm = torch.norm(l, dim=-1, keepdim=True) |
| 115 | r_norm = torch.norm(r, dim=-1, keepdim=True) |
| 116 | |
| 117 | q_l = l / l_norm |
| 118 | q_r = r / r_norm |
| 119 | |
| 120 | a, b, c, d = q_l.unbind(-1) |
| 121 | p, q, r, s = q_r.unbind(-1) |
| 122 | |
| 123 | M_l = torch.stack([a,-b,-c,-d, |
| 124 | b, a,-d, c, |
| 125 | c, d, a,-b, |
| 126 | d,-c, b, a]).view(4,4,-1).permute(2,0,1) |
| 127 | M_r = torch.stack([ p, q, r, s, |
| 128 | -q, p,-s, r, |
| 129 | -r, s, p,-q, |
| 130 | -s,-r, q, p]).view(4,4,-1).permute(2,0,1) |
| 131 | A = M_l @ M_r |
| 132 | A = A.flip(1,2) |
| 133 | return A |
| 134 | |
| 135 | def build_scaling_rotation_4d(s, l, r): |
| 136 | L = torch.zeros((s.shape[0], 4, 4), dtype=torch.float, device="cuda") |
no outgoing calls
no test coverage detected