Skip to content

Commit

Permalink
Update AbstractSimplicialComplexes.m2
Browse files Browse the repository at this point in the history
Edits to overload == and dim as requested.
  • Loading branch information
n-m-g authored Oct 31, 2024
1 parent 9be2c9d commit 7ab7cdf
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions M2/Macaulay2/packages/AbstractSimplicialComplexes.m2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ newPackage(

export {"AbstractSimplicialComplex", "abstractSimplicialComplex","simplicialChainComplex", "reducedSimplicialChainComplex", "ambientAbstractSimplicialComplexSize",
"ambientAbstractSimplicialComplex", "abstractSimplicialComplexFacets", "randomAbstractSimplicialComplex", "randomSubSimplicialComplex",
"inducedSimplicialChainComplexMap","inducedReducedSimplicialChainComplexMap","areEqual", "dimAbstractSimplicialComplex",
"inducedSimplicialChainComplexMap","inducedReducedSimplicialChainComplexMap"
}

-* Code section *-
Expand Down Expand Up @@ -113,19 +113,15 @@ abstractSimplicialComplexFacets(AbstractSimplicialComplex) := List => K ->(

--- decide if two simplicial complexes are equal

--- we could overload "==" here but it seems better not to overload too many things that are external to the package

areEqual = method()

areEqual(AbstractSimplicialComplex,AbstractSimplicialComplex) := Boolean => (K,L) ->(
AbstractSimplicialComplex == AbstractSimplicialComplex := Boolean => (K,L) ->(
return (abstractSimplicialComplexFacets K) == (abstractSimplicialComplexFacets L)
)


--- returns the dimension of a simplicial complex

dimAbstractSimplicialComplex = method()

dimAbstractSimplicialComplex(AbstractSimplicialComplex) := ZZ => (K) -> (
dim AbstractSimplicialComplex := ZZ => (K) -> (
return (max apply(abstractSimplicialComplexFacets(K), i -> #i) - 1)
)

Expand Down Expand Up @@ -400,7 +396,7 @@ inducedSimplicialChainComplexMap(AbstractSimplicialComplex,AbstractSimplicialCom
(
h := simplicialChainComplex H;
l := simplicialChainComplex L;
if areEqual(abstractSimplicialComplex {{}},H)==true then return map(l,h,zero)
if ((abstractSimplicialComplex {{}}) == H)==true then return map(l,h,zero)
else(
f := hashTable apply(spots h, i -> if i == -1 then i => map(l_(-1),h_(-1),zero) else i => inducedKFaceSimplicialChainComplexMap(i,L,H));
return map(l,h,f);
Expand All @@ -414,7 +410,7 @@ inducedReducedSimplicialChainComplexMap = method()
inducedReducedSimplicialChainComplexMap(AbstractSimplicialComplex,AbstractSimplicialComplex) := (L,H) -> (
h := reducedSimplicialChainComplex H;
l := reducedSimplicialChainComplex L;
if areEqual(abstractSimplicialComplex {{}},H)==true then return map(l,h, hashTable {-2 => map(l_(-2),h_(-2),zero), -1 => map(l_(-1),h_(-1),id_(h_(-1)))})
if ((abstractSimplicialComplex {{}}) == H) == true then return map(l,h, hashTable {-2 => map(l_(-2),h_(-2),zero), -1 => map(l_(-1),h_(-1),id_(h_(-1)))})
else(
f := hashTable apply(spots h, i -> if i == -1 then i => map(l_(-1),h_(-1),id_(h_(-1))) else i => inducedKFaceSimplicialChainComplexMap(i,L,H));
return map(l,h,f);
Expand Down Expand Up @@ -591,15 +587,14 @@ doc ///

doc ///
Key
areEqual
(areEqual,AbstractSimplicialComplex,AbstractSimplicialComplex)
(symbol ==,AbstractSimplicialComplex,AbstractSimplicialComplex)
Headline
Decide if two simplicial complexes are equal
Description
Text
Decides if two simplicial complexes are equal.
Example
areEqual(randomAbstractSimplicialComplex(4),randomAbstractSimplicialComplex(4))
randomAbstractSimplicialComplex(4) == randomAbstractSimplicialComplex(4)
///

doc ///
Expand All @@ -609,7 +604,7 @@ doc ///
(randomAbstractSimplicialComplex,ZZ,ZZ)
(randomAbstractSimplicialComplex,ZZ,ZZ,ZZ)
Headline
Create a random simplicial set
Create a random abstract simplicial complex
Description
Text
Create a random abstract simplicial complex with vertices supported on a subset of [n] = {1,...,n}.
Expand Down Expand Up @@ -829,16 +824,15 @@ doc ///

doc ///
Key
dimAbstractSimplicialComplex
(dimAbstractSimplicialComplex, AbstractSimplicialComplex)
(dim, AbstractSimplicialComplex)
Headline
The dimension of a simplicial complex
Description
Text
This method returns the dimension a given AbstractSimplicialComplex.
Example
K = abstractSimplicialComplex(3)
dimAbstractSimplicialComplex K
dim K
///


Expand Down

0 comments on commit 7ab7cdf

Please sign in to comment.