Read:
PUBLIC
AC.ReadOp ~ {
samplePointStructureData: SamplePointStructureData ← NARROW[structure.instanceData];
polyRingData: POL.PolynomialRingData ← NARROW[samplePointStructureData.inputPolynomialRing.instanceData];
V: VARS.VariableSeq ← polyRingData.allVariables;
dimension: NAT ← V.lengthPlus1 - 1;
token: Rope.ROPE;
RealAlgebraicNumbers: AC.Structure ← AN.MakeFieldOfAlgebraicNumbers[samplePointStructureData.minPolyRing, TRUE];
primitiveElement: AN.AlgebraicNumber;
basePoint: PTS.Point;
definingPolynomial: POL.Polynomial;
isolatingInterval: RI.RatInterval;
point: PTS.Point;
numberField, algebraicPolynomialsRing: AC.Structure;
outData: SamplePointData;
token ← in.GetID[];
IF Rope.Equal[token, "NILSAMPLEPOINT"]
THEN
RETURN[NEW[AC.ObjectRec ← [structure: structure, data: NIL] ] ]
ELSE
IF Rope.Equal[token, "EXTENDEDSAMPLEPOINT"]
THEN {
basePointStructure: AC.Structure;
token ← in.GetID[];
IF NOT Rope.Equal[token, "PRIMITIVEELEMENT"] THEN ERROR;
primitiveElement ← RealAlgebraicNumbers.class.read[in, RealAlgebraicNumbers];
numberField ← EF.MakeExtensionField[primitiveElement];
token ← in.GetID[];
IF NOT Rope.Equal[token, "BASEPOINT"] THEN ERROR;
basePointStructure ← PTS.MakePointStructure[numberField, dimension - 1];
basePoint ← PTS.Read[in, basePointStructure];
token ← in.GetID[];
algebraicPolynomialsRing ← POL.MakePolynomialStructure[numberField, VARS.MainVariable[V] ];
IF NOT Rope.Equal[token, "DEFININGPOLYNOMIAL"] THEN ERROR;
definingPolynomial ← NARROW[algebraicPolynomialsRing.class.read[in, algebraicPolynomialsRing] ];
token ← in.GetID[];
IF NOT Rope.Equal[token, "ISOLATINGINTERVAL"] THEN ERROR;
isolatingInterval ← RI.RatIntervals.class.read[in, RI.RatIntervals];
outData ←
NEW[SamplePointDataRec ← [
basePoint: basePoint,
definingPolynomial: definingPolynomial,
isolatingInterval: isolatingInterval
] ];
}
ELSE
IF Rope.Equal[token, "PRIMITIVESAMPLEPOINT"]
THEN {
pointStructure: AC.Structure;
token ← in.GetID[];
IF NOT Rope.Equal[token, "PRIMITIVEELEMENT"] THEN ERROR;
primitiveElement ← RealAlgebraicNumbers.class.read[in, RealAlgebraicNumbers];
numberField ← EF.MakeExtensionField[primitiveElement];
token ← in.GetID[];
IF NOT Rope.Equal[token, "POINT"] THEN ERROR;
pointStructure ← PTS.MakePointStructure[numberField, dimension];
point ← PTS.Read[in, pointStructure];
outData ←
NEW[SamplePointDataRec ← [
point: point
] ];
}
ELSE ERROR;
RETURN[NEW[AC.ObjectRec ← [structure: structure, data: outData] ] ];
};
ToRope:
PUBLIC
AC.ToRopeOp ~ {
samplePointStructureData: SamplePointStructureData ← NARROW[in.structure.instanceData];
minPolyRing: AC.Structure ← samplePointStructureData.minPolyRing;
RealAlgebraicNumbers: AC.Structure ← AN.MakeFieldOfAlgebraicNumbers[samplePointStructureData.minPolyRing, TRUE];
inData: SamplePointData ← NARROW[in.data];
out ← "";
IF inData=
NIL
THEN {
out ← Rope.Concat[out, "NILSAMPLEPOINT\n"];
RETURN;
};
IF inData.basePoint #
NIL
THEN {
pointStructureData: PTS.PointStructureData ← NARROW[inData.basePoint.structure.instanceData];
extensionFieldData: EF.ExtensionFieldData ← NARROW[pointStructureData.coordinateStructure.instanceData];
out ← Rope.Concat[out, "EXTENDEDSAMPLEPOINT\n"];
out ← Rope.Concat[out, "PRIMITIVEELEMENT\n"];
out ← Rope.Cat[out, RealAlgebraicNumbers.class.toRope[extensionFieldData.primitiveElement], "\n"];
out ← Rope.Concat[out, "BASEPOINT\n"];
out ← Rope.Cat[out, PTS.ToRope[inData.basePoint], "\n"];
out ← Rope.Concat[out, "DEFININGPOLYNOMIAL\n"];
out ← Rope.Cat[out, POL.PolyToRope[inData.definingPolynomial], "\n"];
out ← Rope.Concat[out, "ISOLATINGINTERVAL\n"];
out ← Rope.Cat[out, RI.RatIntervals.class.toRope[inData.isolatingInterval], "\n"];
}
ELSE {
pointStructureData: PTS.PointStructureData ← NARROW[inData.point.structure.instanceData];
extensionFieldData: EF.ExtensionFieldData ← NARROW[pointStructureData.coordinateStructure.instanceData];
out ← Rope.Concat[out, "PRIMITIVESAMPLEPOINT\n"];
out ← Rope.Concat[out, "PRIMITIVEELEMENT\n"];
out ← Rope.Cat[out, RealAlgebraicNumbers.class.toRope[extensionFieldData.primitiveElement], "\n"];
out ← Rope.Concat[out, "POINT\n"];
out ← Rope.Cat[out, PTS.ToRope[inData.point], "\n"];
};
};