CadsImpl.mesa
DIRECTORY
Rope,
Atom,
IO,
Convert,
MathExpr,
MathConstructors,
AlgebraClasses,
Ints,
Reals,
BigRats,
RatIntervals,
Variables,
Polynomials,
Formulas,
FormulaOperators,
AlgebraicNumbers,
ExtensionFields,
SamplePoints,
Points,
Sequences,
Graphs,
GraphOps,
CoveringSets,
Colors,
Cells,
Cads;
CadsImpl: CEDAR PROGRAM
IMPORTS Rope, Atom, IO, Convert, AlgebraClasses, MathConstructors, Cells, Sequences, Variables, Points, Ints, FormulaOperators, Polynomials, BigRats, CoveringSets, Colors
EXPORTS Cads =
BEGIN OPEN AC: AlgebraClasses, BR: BigRats, RI: RatIntervals, VARS: Variables, AN: AlgebraicNumbers, PTS: Points, POL: Polynomials, AN: AlgebraicNumbers, EF: ExtensionFields, SEQ: Sequences, QFF: Formulas, SP: SamplePoints, CS: CoveringSets, Cells, Cads;
Errors
SyntaxError: PUBLIC ERROR [reason: ATOM] = CODE;
BadElementStructure: PUBLIC ERROR [elementStructure: AC.Structure] = CODE;
TypeError: PUBLIC ERROR [message: ATOM ← $Unspecified] = CODE;
Class for Cell Structures
ClassPrintName: AC.PrintNameProc = {
data: CadStructureData ← NARROW[structure.instanceData];
RETURN[Rope.Cat[
"Cads in ",
data.inputPolynomialRing.class.printName[data.inputPolynomialRing],
" and ",
data.minPolyRing.class.printName[data.minPolyRing]
] ];
};
ClassPrintName: AC.PrintNameProc = {
RETURN["Cads"];
};
ClassShortPrintName: AC.PrintNameProc = {
data: CadStructureData ← NARROW[structure.instanceData];
RETURN[Rope.Cat[
"Cads(",
data.inputPolynomialRing.class.shortPrintName[data.inputPolynomialRing],
data.minPolyRing.class.shortPrintName[data.minPolyRing],
")"
] ];
};
ClassShortPrintName: AC.PrintNameProc = {
RETURN["Cads"];
};
ClassReportOps: AC.ReportOpsProc = {
opNames ← CONS["CoveringSetsFromLinearRope", opNames];
refOps ← CONS[NEW[AC.BinaryInPlaceOp ← CSetsFromLinRope ], refOps];
opNames ← CONS["ParentCad", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← ParCad ], refOps];
opNames ← CONS["InducedCad", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← IndCad ], refOps];
opNames ← CONS["OthClusters", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← OthClusters ], refOps];
opNames ← CONS["BasisClusters", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← BasClusters ], refOps];
opNames ← CONS["CadCells", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← Cels ], refOps];
opNames ← CONS["CellsWithSignature", opNames];
refOps ← CONS[NEW[AC.BinaryOp ← CellsWithSig ], refOps];
opNames ← CONS["BasisProjection", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← BasisProj ], refOps];
opNames ← CONS["Contents", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← Conts ], refOps];
opNames ← CONS["Basis", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← Base ], refOps];
opNames ← CONS["InputPolynomials", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← InputPolys ], refOps];
opNames ← CONS["LocalizationFormula", opNames];
refOps ← CONS[NEW[AC.UnaryOp ← LocalizFormula ], refOps];
opNames ← CONS["FromLinearRope", opNames];
refOps ← CONS[NEW[AC.FromRopeOp ← FromRope], refOps];
};
ClassIsElementOf: AC.ElementOfProc = {
Assumes that if item is a cad, then it really belongs to the domain pointed to by its structure field.
IF NOT structure.class.structureEqual[structure, item.structure] THEN RETURN[FALSE];
RETURN[ TRUE ]
};
ClassLegalFirstChar: AC.LegalFirstCharOp = {
SELECT char FROM
'[ , '(=> RETURN[TRUE];
ENDCASE;
RETURN[FALSE];
};
ClassToExpr: AC.ToExprOp = {
inData: CadData;
outColumn, tail: LIST OF MathExpr.EXPRNIL;
colLength: CARDINAL;
IF in=NIL THEN {
out ← MathConstructors.MakeVector[1, LIST[MathConstructors.MakeVariable["NILCAD"]], FALSE];
RETURN;
};
inData ← NARROW[in.data];
IF inData=NIL THEN {
out ← MathConstructors.MakeVector[1, LIST[MathConstructors.MakeVariable["NILCAD"]], FALSE];
RETURN;
};
outColumn ← tail ← LIST[MathConstructors.MakeVariable[
Rope.Concat[Convert.RopeFromCard[inData.dimension], "-Space Cad"] ] ];
tail ← tail.rest ← LIST[inData.inputPolynomials.structure.class.toExpr[inData.inputPolynomials] ];
colLength ← 2;
out ← MathConstructors.MakeVector[colLength, outColumn, FALSE];
};
cadOps: CadOps ← NEW[CadOpsRec ← [
localizationFormula: LocalizFormula,
inputPolynomials: InputPolys,
basis: Base,
contents: Conts,
basisProjection: BasisProj,
cells: Cels,
cellsWithSignature: CellsWithSig,
basisClusters: BasClusters,
otherClusters: OthClusters,
makeBasisClusters: MakeBasClusters,
makeOtherClusters: MakeOthClusters, -- cluster(cad, edgePredicateFormula) -> clusters
inducedCad: IndCad,
parentCad: ParCad,
coveringSetsFromLinearRope: CSetsFromLinRope
] ];
cadProp: Atom.DottedPair ← NEW[Atom.DottedPairNode← [$CadStructure, cadOps]];
cadStructureClass: PUBLIC AC.StructureClass ← NEW[AC.StructureClassRec ← [
category: set,
printName: ClassPrintName,
shortPrintName: ClassShortPrintName,
structureEqual: AC.defaultStructureEqualityTest,
reportOps: ClassReportOps,
isElementOf: ClassIsElementOf,
legalFirstChar: ClassLegalFirstChar,
read: Read,
fromRope: FromRope,
toRope: ToRope,
toIndexRope: ToIndexRope,
write: Write,
toExpr: ClassToExpr,
integralDomain: FALSE,
gcdDomain: FALSE,
euclideanDomain: FALSE,
propList: LIST[cadProp]
] ];
Cad Structure Constructor
MakeCadStructure: PUBLIC PROC [inputPolynomialRing, minPolyRing: AC.Structure] RETURNS [cellStructure: AC.Structure] ~ {
cadStructureData: CadStructureData ← NEW[CadStructureDataRec ← [
inputPolynomialRing: inputPolynomialRing,
minPolyRing: minPolyRing
] ];
RETURN[ NEW[AC.StructureRec ← [
class: cadStructureClass,
instanceData: cadStructureData
] ] ];
};
MakeCadStructure: PUBLIC PROC [] RETURNS [cellStructure: AC.Structure] ~ {
RETURN[ NEW[AC.StructureRec ← [
class: cadStructureClass,
instanceData: NIL
] ] ];
};
Extract Cell Operations from Class Record Property Lists
IsCadStructure: PUBLIC PROC [structure: AC.Structure] RETURNS [BOOL] ~ {
IF Atom.GetPropFromList[structure.class.propList, $CadStructure] # NIL THEN RETURN[TRUE] ELSE RETURN[FALSE];
};
LocalizationFormula: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.localizationFormula];
}
ELSE ERROR;
};
InputPolynomials: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.inputPolynomials];
}
ELSE ERROR;
};
Basis: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.basis];
}
ELSE ERROR;
};
Contents: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.contents];
}
ELSE ERROR;
};
BasisProjection: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.basisProjection];
}
ELSE ERROR;
};
CadCells: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.cells];
}
ELSE ERROR;
};
CellsWithSignature: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.BinaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.cellsWithSignature];
}
ELSE ERROR;
};
BasisClusters: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.basisClusters];
}
ELSE ERROR;
};
InducedCad: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.inducedCad];
}
ELSE ERROR;
};
ParentCad: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.UnaryOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.parentCad];
}
ELSE ERROR;
};
CoveringSetsFromLinearRope: PUBLIC PROC [structure: AC.Structure] RETURNS [AC.BinaryInPlaceOp] ~ {
IF IsCadStructure[structure] THEN {
cadOps: CadOps ← NARROW[ Atom.GetPropFromList[structure.class.propList, $CadStructure] ];
RETURN[cadOps.coveringSetsFromLinearRope];
}
ELSE ERROR;
};
Conversion and IO
cadGraphClass: PUBLIC Graphs.GraphClass ← Graphs.NewGraphClass[[
EnumerateVertices: CadEnumerateVertices,
Destroy: NIL
]];
CadEnumerateVertices: PUBLIC Graphs.EnumerateVerticesProc ~ {
cad: Cad ← NARROW[graph.rep];
cadData: CadData ← NARROW[cad.data];
cells: SEQ.Sequence ← cadData.cells;
cellsData: SEQ.SequenceData ← NARROW[cells.data];
FOR i:NAT IN [1..cellsData.lengthPlus1 - 1] DO
cellData: Cells.CellData ← NARROW[cellsData[i].data];
consume.proc[cellData.abstractVertex, consume.data];
ENDLOOP;
};
Read: PUBLIC AC.ReadOp ~ {
cadStructureData: CadStructureData ← NARROW[structure.instanceData];
inputPolynomialRing: AC.Structure ← cadStructureData.inputPolynomialRing;
minPolyRing: AC.Structure ← cadStructureData.minPolyRing;
minPolyRing, inputPolynomialRing, inputPolyRingSeqStructure: AC.Structure;
token: Rope.ROPE;
dimension: CARDINAL;
name: Rope.ROPENIL;
inputVariables, projVariables, minPolyVariable, fieldElementVariable: VARS.VariableSeq;
projPolynomialRing: AC.Structure;
projPolyRingSeqStructure: AC.Structure;
inputPolynomials, basis: SEQ.Sequence ← NIL;
numBasisElements: CARDINAL ← 0;
contents, basisProjection: SEQ.Sequence ← NIL;
basisClusters: SEQ.Sequence ← NIL;
cells: SEQ.Sequence ← NIL;
cellsData: SEQ.SequenceData;
cellIndexStructure: AC.Structure;
basisSignatureStructure: AC.Structure;
inducedCad: Cad ← NIL;
inducedCadData: CadData;
outData: CadData;
token ← in.GetID[];
IF NOT Rope.Equal[token, "BEGINCAD"] THEN ERROR;
token ← in.GetID[];
IF Rope.Equal[token, "NAME"] THEN {
name ← in.GetID[];
token ← in.GetID[];
};
IF NOT Rope.Equal[token, "DIMENSION"] THEN ERROR;
dimension ← in.GetCard[];
cellIndexStructure ← PTS.MakePointStructure[Ints.Ints, dimension];
token ← in.GetID[];
IF NOT Rope.Equal[token, "INPUTVARIABLES"] THEN ERROR;
inputVariables ← VARS.ReadVariableSeq[in];
inputPolynomialRing ← POL.MakePolynomialStructure[BR.BigRats, inputVariables];
inputPolyRingSeqStructure ← SEQ.MakeSequenceStructure[inputPolynomialRing];
token ← in.GetID[];
IF NOT Rope.Equal[token, "MINPOLYVARIABLE"] THEN ERROR;
minPolyVariable ← VARS.ReadVariableSeq[in];
minPolyRing ← POL.MakePolynomialStructure[BR.BigRats, minPolyVariable];
Should check that minPolyVariable read = minPolyRing.allVariables
token ← in.GetID[];
IF NOT Rope.Equal[token, "FIELDELEMENTVARIABLE"] THEN ERROR;
fieldElementVariable ← VARS.ReadVariableSeq[in];
IF NOT Rope.Equal[fieldElementVariable[1], minPolyVariable[1] ] THEN ERROR; -- quick fix; the entire use of fieldElementVariable should be removed
token ← in.GetID[];
IF NOT Rope.Equal[token, "INPUTPOLYNOMIALS"] THEN ERROR;
inputPolynomials ← inputPolyRingSeqStructure.class.read[in, inputPolyRingSeqStructure];
token ← in.GetID[];
IF Rope.Equal[token, "BASIS"] THEN {
basisData: SEQ.SequenceData;
basis ← inputPolyRingSeqStructure.class.read[in, inputPolyRingSeqStructure];
basisData ← NARROW[basis.data];
numBasisElements ← basisData.lengthPlus1 - 1;
basisSignatureStructure ← PTS.MakePointStructure[FormulaOperators.Operators, numBasisElements];
token ← in.GetID[];
};
projVariables ← VARS.RemoveMainVariable[inputVariables];
projPolynomialRing ← POL.MakePolynomialStructure[BR.BigRats, projVariables];
projPolyRingSeqStructure ← SEQ.MakeSequenceStructure[projPolynomialRing];
IF Rope.Equal[token, "CONTENTS"] THEN {
contents ← projPolyRingSeqStructure.class.read[in, projPolyRingSeqStructure];
token ← in.GetID[];
};
IF Rope.Equal[token, "PROJECTION"] THEN {
basisProjection ← projPolyRingSeqStructure.class.read[in, projPolyRingSeqStructure];
token ← in.GetID[];
};
IF Rope.Equal[token, "CELLS"] THEN {
cellStructure: AC.Structure ← Cells.MakeCellStructure[inputPolynomialRing, minPolyRing, numBasisElements];
cellSeqStructure: AC.Structure ← SEQ.MakeSequenceStructure[cellStructure];
cells ← cellSeqStructure.class.read[in, cellSeqStructure];
token ← in.GetID[];
};
IF Rope.Equal[token, "CLUSTERS"] THEN
[basisClusters, token] ← ReadSignedRegionSeq[in, cellIndexStructure, inputPolynomialRing, minPolyRing, basisSignatureStructure];
IF Rope.Equal[token, "INDUCEDCAD"] THEN {
inducedCadStructure: AC.Structure ← MakeCadStructure[projPolynomialRing, minPolyRing];
inducedCad ← Read[in, structure];
token ← in.GetID[];
};
IF NOT Rope.Equal[token, "ENDCAD"] THEN ERROR;
outData ← NEW[CadDataRec ← [
dimension: dimension,
inputPolynomials: inputPolynomials,
basis: basis,
contents: contents,
basisProjection: basisProjection,
cells: cells,
basisClusters: basisClusters,
inducedCad: inducedCad
] ];
out ← NEW[AC.ObjectRec ← [name: name, structure: structure, data: outData] ];
IF inducedCad#NIL THEN {
inducedCadData ← NARROW[inducedCad.data];
inducedCadData.parentCad ← out;
};
cellsData ← NARROW[cells.data];
FOR i:NAT IN [1..cellsData.lengthPlus1 - 1] DO
cellData: Cells.CellData ← NARROW[cellsData[i].data];
cellData.cad ← out;
ENDLOOP;
outData.abstractGraph ← NEW [Graphs.GraphPrivate ← [
class: cadGraphClass,
rep: out
]];
RETURN[out];
};
FromRope: PUBLIC AC.FromRopeOp ~ {
out ← Read[IO.RIS[in], structure];
};
ToIndexRope: AC.ToRopeOp ~ {
out ← Rope.Cat["Cad(", in.name, ")"];
};
ToRope: PUBLIC AC.ToRopeOp ~ {
inData: CadData ← NARROW[in.data];
inStructureData: CadStructureData ← NARROW[in.structure.instanceData];
inputPolyRingSeqStructure: AC.Structure ← inData.inputPolynomials.structure;
sequenceStructureData: SEQ.SequenceStructureData ← NARROW[inputPolyRingSeqStructure.instanceData];
inputPolynomialRing: AC.Structure ← sequenceStructureData.elementStructure;
inputVariables: VARS.VariableSeq ← NARROW[inputPolynomialRing.instanceData, POL.PolynomialRingData].allVariables;
minPolyVariable: VARS.VariableSeq ← NARROW[inStructureData.minPolyRing.instanceData, POL.PolynomialRingData].allVariables;
out ← "BEGINCAD\n";
IF in.name#NIL THEN out ← Rope.Cat[out, "NAME\n", in.name, "\n"];
out ← Rope.Concat[out, "DIMENSION\n"];
out ← Rope.Cat[out, Convert.RopeFromCard[inData.dimension], "\n"];
out ← Rope.Concat[out, "INPUTVARIABLES\n"];
out ← Rope.Cat[out, VARS.VariableSeqToRope[inputVariables], "\n"];
out ← Rope.Concat[out, "MINPOLYVARIABLE\n"];
out ← Rope.Cat[out, VARS.VariableSeqToRope[inData.minPolyVariable], "\n"];
out ← Rope.Concat[out, "FIELDELEMENTVARIABLE\n"];
out ← Rope.Cat[out, VARS.VariableSeqToRope[inData.minPolyVariable], "\n"];
IF inData.inputPolynomials#NIL THEN {
out ← Rope.Concat[out, "INPUTPOLYNOMIALS\n"];
out ← Rope.Cat[out, inData.inputPolynomials.structure.class.toRope[inData.inputPolynomials], "\n"];
};
IF inData.basis#NIL THEN {
out ← Rope.Concat[out, "BASIS\n"];
out ← Rope.Cat[out, inData.basis.structure.class.toRope[inData.basis], "\n"];
};
IF inData.contents#NIL THEN {
out ← Rope.Concat[out, "CONTENTS\n"];
out ← Rope.Cat[out, inData.contents.structure.class.toRope[inData.contents], "\n"];
};
IF inData.basisProjection#NIL THEN {
out ← Rope.Concat[out, "PROJECTION\n"];
out ← Rope.Cat[out, inData.basisProjection.structure.class.toRope[inData.basisProjection], "\n"];
};
IF inData.cells#NIL THEN {
out ← Rope.Concat[out, "CELLS\n"];
out ← Rope.Cat[out, inData.cells.structure.class.toRope[inData.cells], "\n"];
};
IF inData.basisClusters#NIL THEN {
out ← Rope.Concat[out, "CLUSTERS\n"];
out ← Rope.Cat[out, SignedRegionSeqToRope[inData.basisClusters], "\n"];
};
IF inData.inducedCad#NIL THEN {
out ← Rope.Concat[out, "INDUCEDCAD\n"];
out ← Rope.Cat[out, ToRope[inData.inducedCad], "\n"];
};
out ← Rope.Concat[out, "ENDCAD\n"];
};
Write: PUBLIC AC.WriteOp ~ {
stream.PutRope[ToRope[in] ]
};
Operations
LocalizFormula: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.localizationFormula];
};
InputPolys: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.inputPolynomials];
};
Base: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.basis];
};
Conts: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.contents];
};
BasisProj: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.basisProjection];
};
Cels: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.cells];
};
CellsWithSig: PUBLIC AC.BinaryOp ~ {
cadData: CadData ← NARROW[firstArg.data]; -- firstArg is cad
basisSig: Cells.Signature ← NARROW[secondArg];
inCells: SEQ.Sequence ← cadData.cells;
inCellsData: SEQ.SequenceData ← NARROW[inCells.data];
outCellsList, tail: LIST OF Cells.Cell ← NIL;
FOR i:NAT IN [1..inCellsData.lengthPlus1 - 1] DO
inCellData: Cells.CellData ← NARROW[inCellsData[i].data];
IF inCellData.basisSignature.structure.class.equal[inCellData.basisSignature, basisSig] THEN
{ IF outCellsList = NIL THEN outCellsList ← tail ← LIST[inCellsData[i] ] ELSE
tail ← tail.rest ← LIST[inCellsData[i] ] };
ENDLOOP;
RETURN[ SEQ.MakeSeq[outCellsList, inCells.structure] ];
};
BasClusters: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.basisClusters];
};
OthClusters: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.otherClusters];
};
MakeBasClusters: PUBLIC AC.UnaryOp ~ {
User specifies polynomials with respect to which to cluster by (*,*,@,*,*,@) tuples (@ is new FormulaOperators.Op).
data: CadData ← NARROW[arg.data];
edgePredicate: GraphOps.EdgePredicate ~ {
cell1: Cells.Cell ← NARROW[v.rep];
cell2: Cells.Cell ← NARROW[w.rep];
cell1Data: Cells.CellData ← NARROW[cell1.data];
cell2Data: Cells.CellData ← NARROW[cell2.data];
RETURN[cell1Data.basisSignature.structure.class.equal[cell1Data.basisSignature, cell2Data.basisSignature] ];
};
numComponents: CARDINAL ← GraphOps.DetermineComponents[data.abstractGraph, Undirected, edgePredicate];
numComponents: CARDINAL ← 0;
data.basisClusters ← ExtractClusters[arg, numComponents];
};
MakeOthClusters: PUBLIC AC.BinaryOp ~ {
User specifies basis polynomials with respect to which to cluster by (*,*,@,*,*,@) tuples (@ is new FormulaOperators.Op). Should be expanded to tuple of such tuples, one for each dimension, then we can specify clustering with respect to selected basis polys in all dimensions.
data: CadData ← NARROW[arg.data];
edgePredicate: GraphOps.EdgePredicate ~ {
cell1: Cells.Cell ← NARROW[v.rep];
cell2: Cells.Cell ← NARROW[w.rep];
-- For each elt of Op sequence, if * then ignore this basis poly, else if @, then check for equal signs with respect to this basis poly
RETURN[ ];
};
numComponents: CARDINAL ← GraphOps.DetermineComponents[data.abstractGraph, Undirected, edgePredicate];
data.basisClusters ← ExtractClusters[arg, numComponents];
};
IndCad: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.inducedCad];
};
ParCad: PUBLIC AC.UnaryOp ~ {
data: CadData ← NARROW[arg.data];
RETURN[data.parentCad];
};
LookupCell: PUBLIC AC.BinaryOp ~ {
cellsData: SEQ.SequenceData ← NARROW[firstArg.data];
cellIndexStructure: AC.Structure ← secondArg.structure;
FOR i:NAT IN [1..cellsData.lengthPlus1 - 1] DO
cellData: Cells.CellData ← NARROW[cellsData[i].data];
IF cellIndexStructure.class.equal[cellData.index, secondArg] THEN RETURN[cellsData[i] ];
ENDLOOP;
RETURN[NIL];
};
ReadCSets: PUBLIC PROC [in: IO.STREAM, cad: Cads.Cad] ~ {
cadData: CadData ← NARROW[cad.data];
token: Rope.ROPE ← in.GetID[];
index: PTS.Point;
dimension: CARDINAL;
cellIndexStructure: AC.Structure;
coveringSetStructure: AC.Structure;
cells: SEQ.Sequence;
cell: Cells.Cell;
cellData: Cells.CellData;
IF Rope.Equal[token, "BEGINCOVERINGSETS"] THEN token ← in.GetID[]; -- flush if present
IF NOT Rope.Equal[token, "DIMENSION"] THEN ERROR;
dimension ← in.GetCard[];
IF dimension # cadData.dimension THEN ERROR;
cellIndexStructure ← PTS.MakePointStructure[Ints.Ints, dimension];
coveringSetStructure ← CS.MakeCoveringSetStructure[dimension];
cells ← cadData.cells;
token ← in.GetID[];
WHILE Rope.Equal[token, "CELLINDEX"] DO
index ← cellIndexStructure.class.read[in, cellIndexStructure];
cell ← LookupCell[cells, index];
cellData ← NARROW[cell.data];
token ← in.GetID[];
IF NOT Rope.Equal[token, "BEGINCOVERINGSET"] THEN ERROR;
cellData.coveringSet ← coveringSetStructure.class.read[in, coveringSetStructure];
cellData.color ← Colors.FromRope["Black", Colors.Colors];
token ← in.GetID[];
ENDLOOP;
IF NOT Rope.Equal[token, "ENDCOVERINGSETS"] THEN ERROR;
};
CSetsFromLinRope: PUBLIC AC.BinaryInPlaceOp ~ {
inRope: Rope.ROPENARROW[secondArg];
stream: IO.STREAMIO.RIS[inRope];
ReadCSets[stream, firstArg];
};
Adjacencies and Clusters
ExtractClusters: PUBLIC PROC [cad: Cad, numComponents: CARDINAL] RETURNS [basisClusters: SEQ.Sequence] ~ {};
END.