in models/utils.py [0:0]
def forward(self, rvec):
theta = torch.sqrt(1e-5 + torch.sum(rvec ** 2, dim=1))
rvec = rvec / theta[:, None]
costh = torch.cos(theta)
sinth = torch.sin(theta)
return torch.stack((
rvec[:, 0] ** 2 + (1. - rvec[:, 0] ** 2) * costh,
rvec[:, 0] * rvec[:, 1] * (1. - costh) - rvec[:, 2] * sinth,
rvec[:, 0] * rvec[:, 2] * (1. - costh) + rvec[:, 1] * sinth,
rvec[:, 0] * rvec[:, 1] * (1. - costh) + rvec[:, 2] * sinth,
rvec[:, 1] ** 2 + (1. - rvec[:, 1] ** 2) * costh,
rvec[:, 1] * rvec[:, 2] * (1. - costh) - rvec[:, 0] * sinth,
rvec[:, 0] * rvec[:, 2] * (1. - costh) - rvec[:, 1] * sinth,
rvec[:, 1] * rvec[:, 2] * (1. - costh) + rvec[:, 0] * sinth,
rvec[:, 2] ** 2 + (1. - rvec[:, 2] ** 2) * costh), dim=1).view(-1, 3, 3)