r"""Return the hyperedge degree matrix :math:`\mathbf{D}_e` of the specified hyperedge group with ``torch.sparse_coo_tensor`` format. Args: ``group_name`` (``str``): The name of the specified hyperedge group.
(self, group_name: str)
| 943 | return self.cache["D_e"] |
| 944 | |
| 945 | def D_e_of_group(self, group_name: str) -> torch.Tensor: |
| 946 | r"""Return the hyperedge degree matrix :math:`\mathbf{D}_e` of the specified hyperedge group with ``torch.sparse_coo_tensor`` format. |
| 947 | |
| 948 | Args: |
| 949 | ``group_name`` (``str``): The name of the specified hyperedge group. |
| 950 | """ |
| 951 | assert ( |
| 952 | group_name in self.group_names |
| 953 | ), f"The specified {group_name} is not in existing hyperedge groups." |
| 954 | if self.group_cache[group_name].get("D_e") is None: |
| 955 | _tmp = ( |
| 956 | torch.sparse.sum(self.H_T_of_group(group_name), dim=1) |
| 957 | .to_dense() |
| 958 | .clone() |
| 959 | .view(-1) |
| 960 | ) |
| 961 | _num_e = _tmp.size(0) |
| 962 | self.group_cache[group_name]["D_e"] = torch.sparse_coo_tensor( |
| 963 | torch.arange(0, _num_e).view(1, -1).repeat(2, 1), |
| 964 | _tmp, |
| 965 | torch.Size([_num_e, _num_e]), |
| 966 | device=self.device, |
| 967 | ).coalesce() |
| 968 | return self.group_cache[group_name]["D_e"] |
| 969 | |
| 970 | @property |
| 971 | def D_e_neg_1(self) -> torch.Tensor: |