################################################################################ ## ## simpcomp / complex.gi ## ## GAP object type for simplicial complex ## ## $Id$ ## ################################################################################
################################################################################ ##<#GAPDoc Label="SCIsSimplicialComplex"> ## <ManSection> ## <Filt Name="SCIsSimplicialComplex" Arg="object"/> ## <Returns><K>true</K> or <K>false</K> upon success, <K>fail</K> ## otherwise.</Returns> ## <Description> ## Checks if <Arg>object</Arg> is of type <C>SCSimplicialComplex</C>. The ## object type <C>SCSimplicialComplex</C> is derived from the object type ## <C>SCPropertyObject</C>. ## <Example><![CDATA[ ## gap> c:=SCEmpty();; ## gap> SCIsSimplicialComplex(c); ## true ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
SCSimplicialComplexFamily:=NewFamily("SCSimplicialComplexFamily",
SCIsSimplicialComplex and IsMutable and IsCopyable);
SCSimplicialComplexType:=NewType(SCSimplicialComplexFamily,
SCIsSimplicialComplex and IsAttributeStoringRep and IsListOrCollection);
#properties of which the values are displayed by ViewObj of SCSimplicialComplex
SCIntFunc.SCViewProperties:=[ "Name", "Dim", "AltshulerSteinberg", "AutomorphismGroupSize", "AutomorphismGroupStructure", "AutomorphismGroupTransitivity", "EulerCharacteristic", "Cohomology", "FVector", "GVector", "HVector", "HasBoundary", "HasInterior", "Homology", "IsCentrallySymmetric", "IsConnected", "IsEulerianManifold", "IsOrientable", "IsPseudoManifold", "IsPure", "IsShellable", "IsStronglyConnected", "Neighborliness", "TopologicalType" ];
#print simplicial complex info (in compact format) #compact format: dim, chi, fvec, hom
InstallMethod(ViewObj,"for SCSimplicialComplex",
[SCIsSimplicialComplex], function(sc)
Print(SCIntFunc.StringEx(sc)); end);
SCIntFunc.StringEx:= function(sc)
local type,buf,props,name,dim,n;
if(SCIsSimplicialComplex(sc)) then
type:="SimplicialComplex"; elif(SCIsNormalSurface(sc)) then
type:="NormalSurface"; else
type:="OtherComplex"; fi;
buf:=Concatenation("<",type,": ");
name := SCName(sc); if name = fail then
Append(buf,"unnamed complex"); else
Append(buf,name); fi;
Append(buf," | dim = ");
if type = "NormalSurface" or type = "SimplicialComplex"then
dim := SCDim(sc); if dim = fail then
Info(InfoSimpcomp,1,"SCIntFunc.StringEx: could not compute dimension of complex.");
Append(buf,"unknown"); else
Append(buf,String(dim)); fi; else
Append(buf,"unknown"); fi; if type = "SimplicialComplex"then
n := SCNumFaces(sc,0); if n = fail then
Info(InfoSimpcomp,1,"SCIntFunc.StringEx: could not compute number of vertices of complex."); else
Append(buf," | n = ");
Append(buf,String(n)); fi; fi;
Append(buf,">");
return buf; end;
################################################################################ ##<#GAPDoc Label="SCDetails"> ## <ManSection> ## <Func Name="SCDetails" Arg="complex"/> ## <Returns>a string of type <C>IsString</C> upon success, ## <K>fail</K> otherwise.</Returns> ## <Description> ## The function returns a list of known properties of <Arg>complex</Arg> ## an lists some of these properties explicitly. ## <Example><![CDATA[ ## gap> c:=SC([[1,2,3],[1,2,4],[1,3,4],[2,3,4]]); ## gap> Print(SCDetails(c)); ## gap> c.F; ## gap> c.Homology; ## gap> Print(SCDetails(c)); ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallGlobalFunction(SCDetails, function(arg)
local buf,props,pprops,prop,p,pp,size,pos,sort,type,sc,view,vprops;
if Length(arg) < 1 or Length(arg) > 3then
Info(InfoSimpcomp,1,"SCDetails: function takes between one and three arguments.");
return fail; fi;
if Length(arg) >= 1then
sc := arg[1]; fi;
if Length(arg) >= 2then
view := arg[2]; if not IsBool(view) then
Info(InfoSimpcomp,1,"SCDetails: second argument must be of type IsBoolean.");
return fail; fi; fi;
if Length(arg) >= 3then
vprops := arg[3]; if not IsList(vprops) then
Info(InfoSimpcomp,1,"SCDetails: third argument must be a list of strings.");
return fail; fi; fi;
if(SCIsSimplicialComplex(sc)) then
type:="SimplicialComplex"; elif(SCIsNormalSurface(sc)) then
type:="NormalSurface"; else
type:="OtherComplex"; fi;
if Length(arg) = 1then if type = "SimplicialComplex"then
vprops := SCIntFunc.SCViewProperties; elif type = "NormalSurface"then
vprops := SCIntFunc.SCNSViewProperties; else
vprops := []; fi;
view := true; fi;
if Length(arg) = 2then if type = "SimplicialComplex"then
vprops := SCIntFunc.SCViewProperties; elif type = "NormalSurface"then
vprops := SCIntFunc.SCNSViewProperties; else
vprops := []; fi; fi;
# get known attributes
props:=KnownAttributesOfObject(sc);
# make short names of attributes (without prefix SC...)
pprops:=[]; for p in [1..Length(props)] do
pp:=props[p]; if(Length(pp)>2 and pp{[1,2]}="SC") then
pp:=pp{[3..Length(pp)]}; elif(Length(pp)>10 and pp{[1..10]}="ComputedSC") then if(pp{[Length(pp)-1,Length(pp)]}="ss") then
pp:=pp{[1..Length(pp)-1]}; fi;
pp:=Concatenation(pp{[11..Length(pp)]},"[]"); fi;
Add(pprops,pp);
od;
# respect screen size if view then
size:=SizeScreen()[1]-8; if(size<0) then
size:=0; fi; else
size:=0; fi;
# display list of all known attributes for p in [1..Length(pprops)] do if(size>0 and pos>0 and pos+Length(pprops[p])+2>=size) then
Append(buf,"\n ");
pos:=19; fi;
# display view properties with values for p in vprops do
pos:=Position(pprops,p); if(pos<>fail) then
prop:=EvalString(props[pos])(sc); #sc.(pprops[pos]); if(IsStringRep(prop)) then
Append(buf,Concatenation([" ",p,"=\"",prop,"\"\n"])); else
Append(buf,Concatenation([" ",p,"=",String(prop),"\n"])); fi; fi;
od;
#perform an opertation op on the vertex labels
SCIntFunc.OperationLabels:= function(sc,op)
local labels,c;
labels:=SCVertices(sc);
c:=SCCopy(sc); if(labels=fail) then
return fail; fi;
if ForAll(labels,x->IsAdditiveElement(x)) then
c!.SCVertices:=List(labels,op);
return c; else
Info(InfoSimpcomp,1,"SCIntFunc.OperationsLabels: vertex labels of ", "complex can not be changed by +, -, * or mod.");
return fail; fi; end;
################################################################################ ##<#GAPDoc Label="SCOpPlusSCInt"> ## <ManSection> ## <Meth Name="Operation + (SCSimplicialComplex, Integer)" Arg="complex, value"/> ## <Returns>the simplicial complex passed as argument upon success, ## <K>fail</K> otherwise.</Returns> ## <Description> ## Positively shifts the vertex labels of <Arg>complex</Arg> (provided that ## all labels satisfy the property <C>IsAdditiveElement</C>) by the amount ## specified in <Arg>value</Arg>. ## <Example><![CDATA[ ## gap> c:=SCBdSimplex(3)+10;; ## gap> c.Facets; ## [[11, 12, 13], [11, 12, 14], [11, 13, 14], [12, 13, 14]] ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(
\+,"for SCSimplicialComplex, Integer",
[SCIsSimplicialComplex,IsInt], function(complex, value)
return SCIntFunc.OperationLabels(complex,function(x) return x+value; end); end);
################################################################################ ##<#GAPDoc Label="SCOpMinusSCInt"> ## <ManSection> ## <Meth Name="Operation - (SCSimplicialComplex, Integer)" Arg="complex, value"/> ## <Returns>the simplicial complex passed as argument upon success, <K>fail</K> otherwise.</Returns> ## <Description> ## Negatively shifts the vertex labels of <Arg>complex</Arg> (provided that ## all labels satisfy the property <C>IsAdditiveElement</C>) by the amount ## specified in <Arg>value</Arg>. ## <Example><![CDATA[ ## gap> c:=SCBdSimplex(3)-1;; ## gap> c.Facets; ## [[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]] ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(
\-,"for SCSimplicialComplex, Integer",
[SCIsSimplicialComplex,IsInt], function(complex, value)
return complex+(-value); end);
################################################################################ ##<#GAPDoc Label="Operation * (SCSimplicialComplex, Integer)"> ## <ManSection> ## <Meth Name="Operation * (SCSimplicialComplex, Integer" Arg="complex, value"/> ## <Returns>the simplicial complex passed as argument upon success, ## <K>fail</K> otherwise.</Returns> ## <Description> ## Multiplies the vertex labels of <Arg>complex</Arg> (provided that all ## labels satisfy the property <C>IsAdditiveElement</C>) with the integer ## specified in <Arg>value</Arg>. ## <Example><![CDATA[ ## gap> c:=SCBdSimplex(3)*10;; ## gap> c.Facets; ## [[10, 20, 30], [10, 20, 40], [10, 30, 40], [20, 30, 40]] ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(
\*,"for SCSimplicialComplex, Integer",
[SCIsSimplicialComplex,IsInt], function(complex, value)
return SCIntFunc.OperationLabels(complex,function(x) return x*value; end); end);
################################################################################ ##<#GAPDoc Label="SCOpModSCInt"> ## <ManSection> ## <Meth Name="Operation mod (SCSimplicialComplex, Integer)" Arg="complex, value"/> ## <Returns>the simplicial complex passed as argument upon success, ## <K>fail</K> otherwise.</Returns> ## <Description> ## Takes all vertex labels of <Arg>complex</Arg> modulo the value specified ## in <Arg>value</Arg> (provided that all labels satisfy the property ## <C>IsAdditiveElement</C>). Warning: this might result in different vertices ## being assigned the same label or even in invalid facet lists, so be careful. ## <Example><![CDATA[ ## gap> c:=(SCBdSimplex(3)*10) mod 7;; ## gap> c.Facets; ## [[3, 6, 2], [3, 6, 5], [3, 2, 5], [6, 2, 5]] ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(
\mod,"for SCSimplicialComplex, Integer",
[SCIsSimplicialComplex,IsInt], function(complex, value)
return SCIntFunc.OperationLabels(complex,function(x) return x mod value; end); end);
################################################################################ ##<#GAPDoc Label="SCOpPowSCInt"> ## <ManSection> ## <Meth Name="Operation ^ (SCSimplicialComplex, Integer)" Arg="complex, value"/> ## <Returns>simplicial complex of type <C>SCSimplicialComplex</C> upon ## success, <K>fail</K> otherwise.</Returns> ## <Description> ## Forms the <Arg>value</Arg>-th simplicial cartesian power of ## <Arg>complex</Arg>, i.e. the <Arg>value</Arg>-fold cartesian product of ## copies of <Arg>complex</Arg>. The complex passed as argument is not altered. ## Internally calls <Ref Func="SCCartesianPower"/>. ## <Example><![CDATA[ ## gap> c:=SCBdSimplex(2)^2; #a torus ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(
\^,"for SCSimplicialComplex, Integer",
[SCIsSimplicialComplex,IsPosInt], function(sc, val)
return SCCartesianPower(sc,val); end);
################################################################################ ##<#GAPDoc Label="SCOpPlusSCSC"> ## <ManSection> ## <Meth Name="Operation + (SCSimplicialComplex, SCSimplicialComplex)" Arg="complex1, complex2"/> ## <Returns>simplicial complex of type <C>SCSimplicialComplex</C> upon ## success, <K>fail</K> otherwise.</Returns> ## <Description> ## Forms the connected sum of <Arg>complex1</Arg> and <Arg>complex2</Arg>. ## Uses the lexicographically first facets of both complexes to do the gluing. ## The complexes passed as arguments are not altered. Internally calls ## <Ref Func="SCConnectedSum"/>. ## <Example><![CDATA[ ## gap> SCLib.SearchByName("RP^3");; ## gap> c:=SCLib.Load(last[1][1]);; ## gap> SCLib.SearchByName("S^2~S^1"){[1..3]}; ## [ [ 12, "S^2~S^1 (VT)" ], [ 26, "S^2~S^1 (VT)" ], ## [ 27, "S^2~S^1 (VT)" ] ] ## gap> d:=SCLib.Load(last[1][1]);; ## gap> c:=c+d; #form RP^3#(S^2~S^1) ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(
\+,"for SCSimplicialComplex, SCSimplicialComplex",
[SCIsSimplicialComplex,SCIsSimplicialComplex], function(complex1, complex2)
return SCConnectedSum(complex1,complex2); end);
################################################################################ ##<#GAPDoc Label="SCShallowCopy"> ## <ManSection> ## <Meth Name="ShallowCopy (SCSimplicialComplex)" Arg="complex"/> ## <Returns>a copy of <Arg>complex</Arg> upon success, <K>fail</K> ## otherwise.</Returns> ## <Description> ## Makes a copy of <Arg>complex</Arg>. This is actually a ``deep copy'' ## such that all properties of the copy can be altered without changing ## the original complex. Internally calls <Ref Func="SCCopy"/>. ## <Example><![CDATA[ ## gap> c:=SCBdCrossPolytope(7);; ## gap> d:=ShallowCopy(c)+10;; ## gap> c.Facets=d.Facets; ## false ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(ShallowCopy, "for SCSimplicialComplex",
[SCIsSimplicialComplex], function(complex)
return SCCopy(complex); end);
################################################################################ ##<#GAPDoc Label="SCCopy"> ## <ManSection> ## <Meth Name="SCCopy" Arg="complex"/> ## <Returns>a copy of <Arg>complex</Arg> upon success, <K>fail</K> otherwise.</Returns> ## <Description> ## Makes a ``deep copy'' of <Arg>complex</Arg> -- this is a copy such that ## all properties of the copy can be altered without changing the original ## complex. ## <Example><![CDATA[ ## gap> c:=SCBdSimplex(4);; ## gap> d:=SCCopy(c)-1;; ## gap> c.Facets=d.Facets; ## false ## ]]></Example> ## <Example><![CDATA[ ## gap> c:=SCBdSimplex(4);; ## gap> d:=SCCopy(c);; ## gap> IsIdenticalObj(c,d); ## false ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(SCCopy, "for SCSimplicialComplex",
[SCIsSimplicialComplex], function(complex)
local a,c,attr;
attr:=KnownAttributesOfObject(complex);
c:=SCIntFunc.SCNew(); if c = fail then
return fail; fi;
for a in attr do
Setter(EvalString(a))(c,complex!.(a));
od;
return c; end);
################################################################################ ##<#GAPDoc Label="SCSize"> ## <ManSection> ## <Meth Name="Size (SCSimplicialComplex)" Arg="complex"/> ## <Returns>an integer upon success, <K>fail</K> otherwise.</Returns> ## <Description> ## Returns the ``size'' of a simplicial complex. This is <M>d+1</M>, where ## <M>d</M> is the dimension of the complex. <M>d+1</M> is returned instead ## of <M>d</M>, as all lists in &GAP; are indexed beginning with 1 -- thus ## this also holds for all the face lattice related properties of the complex. ## <Example><![CDATA[ ## gap> SCLib.SearchByAttribute("F=[12,66,108,54]");; ## gap> c:=SCLib.Load(last[1][1]);; ## gap> for i in [1..Size(c)] do Print(c.F[i],"\n"); od; ## 12 ## 66 ## 108 ## 54 ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(Size, "for SCSimplicialComplex",
[SCIsSimplicialComplex], function(complex)
local dim;
dim:=SCDim(complex);
if(dim=fail) then
return fail; else
return dim+1; fi; end);
################################################################################ ##<#GAPDoc Label="SCLength"> ## <ManSection> ## <Meth Name="Length (SCSimplicialComplex)" Arg="complex"/> ## <Returns>an integer upon success, <K>fail</K> otherwise.</Returns> ## <Description> ## Returns the ``size'' of a simplicial complex by calling ## <C>Size(</C><Arg>complex</Arg><C>)</C>. ## <Example><![CDATA[ ## gap> SCLib.SearchByAttribute("F=[12,66,108,54]");; ## gap> c:=SCLib.Load(last[1][1]);; ## gap> for i in [1..Length(c)] do Print(c.F[i],"\n"); od; ## 12 ## 66 ## 108 ## 54 ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(Length, "for SCSimplicialComplex",
[SCIsSimplicialComplex], function(complex)
return Size(complex); end);
InstallMethod(
IsBound\[\],"for SCSimplicialComplex",
[SCIsSimplicialComplex,IsPosInt], function(complex, pos)
local dim;
dim:=SCDim(complex);
if(dim=fail) then
return fail; else
return pos>=1 and pos<=dim+1; fi; end);
################################################################################ ##<#GAPDoc Label="SCIterator"> ## <ManSection> ## <Meth Name="Iterator (SCSimplicialComplex)" Arg="complex"/> ## <Returns>an iterator on the face lattice of <Arg>complex</Arg> upon ## success, <K>fail</K> otherwise.</Returns> ## <Description> ## Provides an iterator object for the face lattice of a simplicial complex. ## <Example><![CDATA[ ## gap> c:=SCBdCrossPolytope(4);; ## gap> for faces in c do Print(Length(faces),"\n"); od; ## 8 ## 24 ## 32 ## 16 ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallMethod(
Iterator,"for SCSimplicialComplex",
[SCIsSimplicialComplex], function(complex)
local faces;
faces:=SCFaceLattice(complex);
################################################################################ ##<#GAPDoc Label="SCPropertiesDropped"> ## <ManSection> ## <Func Name="SCPropertiesDropped" Arg="complex"/> ## <Returns>a object of type <C>SCSimplicialComplex</C> upon success, ## <K>fail</K> otherwise.</Returns> ## <Description> ## An object of the type <C>SCSimplicialComplex</C> caches its previously ## calculated properties such that each property only has to be calculated ## once. This function returns a copy of <Arg>complex</Arg> with all ## properties (apart from Facets, Dim and Name) dropped, clearing all ## previously computed properties. See also <Ref Meth="SCPropertyDrop" /> ## and <Ref Meth="SCPropertyTmpDrop" />. ## <Example><![CDATA[ ## gap> c:=SC(SCFacets(SCBdCyclicPolytope(10,12))); ## gap> c.F; time; ## gap> c.F; time; ## gap> c:=SCPropertiesDropped(c); ## gap> c.F; time; ## ]]></Example> ## </Description> ## </ManSection> ##<#/GAPDoc> ################################################################################
InstallGlobalFunction(SCPropertiesDropped, function(complex)
local sc;
if(not SCIsSimplicialComplex(complex)) then
Info(InfoSimpcomp,1,"SCPropertiesDropped: argument must be of type ", "SCSimplicialComplex.");
return fail; fi;
sc:=SCFromFacets(SCFacetsEx(complex));
if(sc=fail) then
return fail; fi;
if(SCName(complex)<>fail) then
SCRename(sc,SCName(complex)); fi;
return sc; end);
# create new complex as SCSimplicialComplex and empty attributes
SCIntFunc.SCNew:= function()
local sc;
sc:=Objectify(SCSimplicialComplexType,rec(Properties:=rec(),
PropertiesTmp:=rec(forceCalc:=false),
PropertyHandlers:=SCIntFunc.SCPropertyHandlers));
if(sc=fail) then
Info(InfoSimpcomp,1,"SCIntFunc.SCNew: Error creating new instance of ", "SCSimplicialComplex!"); fi;
return sc; end;
# create new complex as SCSimplicialComplex with predefined attributes
SCIntFunc.SCNewWithProperties:= function(props)
return Objectify(SCSimplicialComplexType,rec(Properties:=ShallowCopy(props),
PropertiesTmp:=rec(forceCalc:=false),
PropertyHandlers:=SCIntFunc.SCPropertyHandlers)); end;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.30 Sekunden
(vorverarbeitet am 2026-10-12)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.