Compute integrated directional encoding (IDE). Args: xyz: [..., 3] array of Cartesian coordinates of directions to evaluate at. kappa_inv: [..., 1] reciprocal of the concentration parameter of the von Mises-Fisher distribution. Returns:
(self, xyz, roughness=0, **kwargs)
| 97 | self.n_output_dims = (2**deg_view - 1 + deg_view) * 2 |
| 98 | |
| 99 | def forward(self, xyz, roughness=0, **kwargs): |
| 100 | """Compute integrated directional encoding (IDE). |
| 101 | |
| 102 | Args: |
| 103 | xyz: [..., 3] array of Cartesian coordinates of directions to evaluate at. |
| 104 | kappa_inv: [..., 1] reciprocal of the concentration parameter of the von |
| 105 | Mises-Fisher distribution. |
| 106 | |
| 107 | Returns: |
| 108 | An array with the resulting IDE. |
| 109 | """ |
| 110 | kappa_inv = roughness |
| 111 | x = xyz[..., 0:1] |
| 112 | y = xyz[..., 1:2] |
| 113 | z = xyz[..., 2:3] |
| 114 | # avoid 0 + 0j exponentiation |
| 115 | zero_xy = torch.logical_and(x == 0, y == 0) |
| 116 | y = y + zero_xy |
| 117 | |
| 118 | vmz = z ** self.pow_level |
| 119 | vmxy = (x + 1j * y) ** self.ml_array[0, :] |
| 120 | |
| 121 | sph_harms = vmxy * torch.matmul(vmz, self.mat) |
| 122 | ide = sph_harms * torch.exp(-self.sigma * kappa_inv) |
| 123 | |
| 124 | # check whether Nan appears |
| 125 | if torch.isnan(ide).any(): |
| 126 | print('Nan appears in IDE') |
| 127 | import IPython; IPython.embed() |
| 128 | raise ValueError('Nan appears in IDE') |
| 129 | |
| 130 | return torch.cat([torch.real(ide), torch.imag(ide)], dim=-1) |
| 131 | |
| 132 | def forward_wo_j(self, xyz, roughness=0, **kwargs): # a non-complex version for web demo |
| 133 | """Compute integrated directional encoding (IDE). |
nothing calls this directly
no outgoing calls
no test coverage detected