@@ -3896,6 +3896,68 @@ def link(self, simplex: Iterable[int]) -> "SimplicialComplex":
38963896 # if we include all faces. from_simplices will organize them.
38973897 return SimplicialComplex .from_simplices (link_simplices , coefficient_ring = self .coefficient_ring , close_under_faces = True )
38983898
3899+ def get_subfaces (self , simplex : Iterable [int ], dimension : Optional [int ] = None ) -> Set [Tuple [int , ...]]:
3900+ """Return all subfaces of a simplex present in the complex, optionally filtered by dimension.
3901+
3902+ A subface of sigma is any simplex tau in the complex that is a subset of sigma.
3903+
3904+ Args:
3905+ simplex: The simplex to find subfaces of.
3906+ dimension: Optional dimension to filter by.
3907+
3908+ Returns:
3909+ A set of tuples representing the subfaces.
3910+ """
3911+ sigma = _normalize_simplex (simplex )
3912+ subfaces = set ()
3913+
3914+ for r in range (1 , len (sigma ) + 1 ):
3915+ d = r - 1
3916+ if dimension is not None and d != dimension :
3917+ continue
3918+ if d not in self ._simplices_table :
3919+ continue
3920+ for combo in itertools .combinations (sigma , r ):
3921+ f = tuple (sorted (combo ))
3922+ if f in self ._simplices_table [d ]:
3923+ subfaces .add (f )
3924+ return subfaces
3925+
3926+ def get_cofaces (self , simplex : Iterable [int ], dimension : Optional [int ] = None ) -> Set [Tuple [int , ...]]:
3927+ """Return all cofaces of a simplex in the complex, optionally filtered by dimension.
3928+
3929+ A coface of sigma is any simplex tau in the complex that contains sigma.
3930+
3931+ Args:
3932+ simplex: The simplex to find cofaces of.
3933+ dimension: Optional dimension to filter by.
3934+
3935+ Returns:
3936+ A set of tuples representing the cofaces.
3937+ """
3938+ cofaces = self .star (simplex )
3939+ if dimension is not None :
3940+ cofaces = {c for c in cofaces if len (c ) - 1 == dimension }
3941+ return cofaces
3942+
3943+ def to_dynamic_complex (self ) -> "DynamicComplex" :
3944+ """Convert this static SimplicialComplex into a DynamicComplex.
3945+
3946+ Preserves the simplices, coefficient ring, filtration, and coordinates.
3947+
3948+ Returns:
3949+ DynamicComplex: The dynamic complex representation.
3950+ """
3951+ dc = DynamicComplex (
3952+ simplices = self .simplices_field ,
3953+ coefficient_ring = self .coefficient_ring ,
3954+ filtration = self .filtration ,
3955+ )
3956+ if hasattr (self , "_coordinates" ) and self ._coordinates is not None :
3957+ dc ._coordinates = self ._coordinates .copy ()
3958+ dc ._generate_point_cloud_mappings (dc ._coordinates )
3959+ return dc
3960+
38993961 def simplex_to_index (self , d : int ) -> Dict [Tuple [int , ...], int ]:
39003962 """Map each d-simplex to its index in the ordered simplex list.
39013963
0 commit comments