1 // Copyright (c) 2019 Anna Bigatti 2 3 // This file is part of the source of CoCoALib, the CoCoA Library. 4 5 // CoCoALib is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 10 // CoCoALib is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 15 // You should have received a copy of the GNU General Public License 16 // along with CoCoALib. If not, see <http://www.gnu.org/licenses/>. 17 18 #include "CoCoA5io.H" 19 20 #include "CoCoA/BigIntOps.H" 21 #include "CoCoA/BuildInfo.H" 22 #include "CoCoA/CanonicalHom.H" 23 #include "CoCoA/DenseMatrix.H" 24 #include "CoCoA/FractionField.H" 25 #include "CoCoA/FreeModule.H" 26 #include "CoCoA/ModuleOrdering.H" 27 #include "CoCoA/QuotientRing.H" 28 #include "CoCoA/RingDistrMPolyInlFpPP.H" 29 #include "CoCoA/RingDistrMPolyInlPP.H" 30 #include "CoCoA/RingFp.H" 31 #include "CoCoA/RingQQ.H" 32 #include "CoCoA/RingTwinFloat.H" 33 #include "CoCoA/RingZZ.H" 34 #include "CoCoA/SparsePolyIter.H" 35 #include "CoCoA/SparsePolyOps-RingElem.H" 36 //#include "CoCoA/SparsePolyRing.H" 37 #include "CoCoA/TmpGReductor.H" 38 #include "CoCoA/degree.H" 39 #include "CoCoA/ideal.H" 40 #include "CoCoA/matrix.H" 41 #include "CoCoA/module.H" 42 #include "CoCoA/ring.H" 43 #include "CoCoA/symbol.H" 44 #include "GlobalIO.H" 45 46 // #include<algorithm> 47 // #include<cstdlib> 48 // #include<fstream> 49 // #include<functional> 50 // #include<typeinfo> 51 52 //#include <vector> 53 using std::vector; 54 #include <iostream> 55 using std::endl; 56 using std::flush; 57 //#include <string> 58 using std::string; 59 #include<sstream> 60 using std::ostringstream; 61 62 namespace CoCoA 63 { ReadOperationString(std::istream & in)64 string ReadOperationString(std::istream& in) 65 { 66 string s; 67 SkipTag(in, "<operation>"); 68 in >> s; 69 InputFailCheck(in, "ReadOperationString"); 70 SkipTag(in, "</operation>"); 71 return s; 72 } 73 74 ReadPoly(std::istream & in,const SparsePolyRing & P)75 RingElem ReadPoly(std::istream& in, const SparsePolyRing& P) 76 { 77 ring R = CoeffRing(P); 78 long NumParams=0; 79 const long NumInds = NumIndets(P); 80 if (IsFractionField(R) && IsPolyRing(BaseRing(R))) 81 { 82 NumParams = NumIndets(BaseRing(R)); 83 } 84 vector<long> v(NumInds); 85 vector<long> ParV(NumParams); 86 87 long NumSummands; 88 in >> NumSummands; 89 InputFailCheck(in, "ReadPoly -- NumSummands"); 90 BigInt IntCoeff; // to avoid ctor-dtor inside loop 91 RingElem c(R), ans(P), mon(P); 92 for (long NS=0; NS<NumSummands; ++NS) 93 { 94 in >> IntCoeff; 95 for (long i=0 ; i<NumParams ; ++i) in >> ParV[i]; 96 for (long i=0 ; i<NumInds ; ++i) in >> v[i]; 97 InputFailCheck(in, "ReadPoly -- summand"); 98 if (NumParams==0) 99 c = IntCoeff; 100 else 101 { 102 const SparsePolyRing BR = BaseRing(R); 103 c = CanonicalHom(BR,R)(monomial(BR, IntCoeff, ParV)); 104 } 105 mon = monomial(P, c, v); 106 P->myAddClear(raw(ans), raw(mon)); // ANNA: use geobucket 107 } 108 return ans; 109 } 110 111 ReadPP(std::istream & in,const PPMonoid & PPM)112 PPMonoidElem ReadPP(std::istream& in, const PPMonoid& PPM) 113 { 114 long NumInds = NumIndets(PPM); 115 vector<long> v(NumInds); 116 for (long i=0; i<NumInds; ++i) in >> v[i]; 117 InputFailCheck(in, "ReadPP"); 118 return PPMonoidElem(PPM, v); 119 } 120 121 ReadVerbosityLevel(std::istream & in,SkipTagType ST)122 int ReadVerbosityLevel(std::istream& in, SkipTagType ST) 123 { 124 if (ST == GetTag) SkipTag(in, "<verbosity_level>"); 125 int vl; 126 in >> vl; 127 InputFailCheck(in, "ReadVerbosityLevel"); 128 SkipTag(in, "</verbosity_level>"); 129 return vl; 130 } 131 132 ReadRationalMatrix(std::istream & in,SkipTagType ST)133 matrix ReadRationalMatrix(std::istream& in, SkipTagType ST) 134 { 135 if (ST == GetTag) SkipTag(in, "<rational_matrix>"); 136 ring QQ = RingQQ(); 137 long rows, cols; 138 in >> rows; 139 in >> cols; 140 InputFailCheck(in, "ReadRationalMatrix -- rows/cols"); 141 matrix M(NewDenseMat(QQ, rows, cols)); 142 BigInt N, D; 143 for (long i = 0; i < rows; ++i) 144 for (long j = 0; j < cols; ++j) 145 { 146 in >> N; 147 in >> D; 148 InputFailCheck(in, "ReadRationalMatrix -- entry"); 149 SetEntry(M, i, j, RingElem(QQ, N)/D); 150 } 151 SkipTag(in, "</rational_matrix>"); 152 return M; 153 } 154 155 ReadIntegerMatrix(std::istream & in,SkipTagType ST)156 matrix ReadIntegerMatrix(std::istream& in, SkipTagType ST) 157 { 158 if (ST == GetTag) SkipTag(in, "<integer_matrix>"); 159 ring ZZ = RingZZ(); 160 long rows, cols; 161 in >> rows; 162 in >> cols; 163 InputFailCheck(in, "ReadIntegerMatrix -- rows/cols"); 164 matrix M(NewDenseMat(ZZ, rows, cols)); 165 BigInt N; 166 for (long i = 0; i < rows; ++i) 167 for (long j = 0; j < cols; ++j) 168 { 169 in >> N; 170 InputFailCheck(in, "ReadIntegerMatrix -- entry"); 171 SetEntry(M, i, j, N); 172 } 173 SkipTag(in, "</integer_matrix>"); 174 return M; 175 } 176 177 178 // Expects in to be positioned on the number of polys in the PolyList ReadPolyList(std::istream & in,PolyList & PL,const SparsePolyRing & P,SkipTagType ST)179 void ReadPolyList(std::istream& in, PolyList& PL, const SparsePolyRing& P, SkipTagType ST) 180 { 181 if (ST == GetTag) SkipTag(in, "<polynomial_list>"); 182 long NumPolys; 183 PL.clear(); 184 in >> NumPolys; 185 InputFailCheck(in, "ReadPolyList -- NumPolys"); 186 PL.reserve(NumPolys); 187 for (long i=0 ; i<NumPolys ; ++i) PL.push_back(ReadPoly(in, P)); 188 SkipTag(in, "</polynomial_list>"); 189 } 190 191 192 // Expects in to be positioned on the number of PPs ReadPPs(std::istream & in,std::vector<PPMonoidElem> & PPs,const PPMonoid & PPM,SkipTagType ST)193 void ReadPPs(std::istream& in, std::vector<PPMonoidElem>& PPs, const PPMonoid& PPM, SkipTagType ST) 194 { 195 if (ST == GetTag) SkipTag(in, "<powerproduct_list>"); 196 long NumPP; 197 PPs.clear(); 198 in >> NumPP; 199 InputFailCheck(in, "ReadPPs -- NumPP"); 200 PPs.reserve(NumPP); 201 for (long i=0 ; i<NumPP ; ++i) PPs.push_back(ReadPP(in, PPM)); 202 SkipTag(in, "</powerproduct_list>"); 203 } 204 205 ReadVectorList(std::istream & in,VectorList & VL,const FreeModule & FM,SkipTagType ST)206 void ReadVectorList(std::istream& in, VectorList& VL, const FreeModule& FM, SkipTagType ST) 207 { 208 if (ST == GetTag) SkipTag(in, "<vector_list>"); 209 const SparsePolyRing P = RingOf(FM); 210 ModuleElem TmpVector(FM); 211 const vector<ModuleElem>& e = gens(FM); 212 const long NumComponents = NumCompts(FM); 213 214 VL.erase(VL.begin(), VL.end()); 215 //PL.reserve(NumPolys); 216 long NumVectors; 217 in >> NumVectors; 218 InputFailCheck(in, "ReadVectorList -- NumVectors"); 219 for (long i=0 ; i<NumVectors ; ++i) 220 { 221 TmpVector = zero(FM); 222 for (long j=0 ; j<NumComponents ; ++j) 223 { 224 long ComponentIndex; 225 in >> ComponentIndex; // ANNA: does this really make sense?? 226 if (ComponentIndex != j+1) 227 CoCoA_ERROR("wrong component index","ReadVectorList"); 228 TmpVector += e[j]*ReadPoly(in, P); 229 } 230 VL.push_back(TmpVector); 231 } 232 SkipTag(in, "</vector_list>"); 233 } 234 235 ReadDegree(std::istream & in,long GradingDim)236 degree ReadDegree(std::istream& in, long GradingDim) 237 { 238 degree ans(GradingDim); 239 BigInt tmp; 240 for (long i=0; i<GradingDim; ++i) 241 { 242 in >> tmp; 243 InputFailCheck(in, "ReadDegree"); 244 ans.mySetComponent(i, tmp); // ans[i] is read only. 245 } 246 return ans; 247 } 248 249 ReadFreeModule(std::istream & in,SkipTagType ST)250 FreeModule ReadFreeModule(std::istream& in, SkipTagType ST) 251 { 252 if (ST == GetTag) SkipTag(in, "<graded_free_module>"); 253 bool IsPosTO=false; 254 vector<degree> InputShifts; 255 vector<size_t> ComponentOrdering; 256 257 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 258 259 SkipTag(in, "number_module_components"); 260 long NumComponents; 261 in >> NumComponents; 262 InputFailCheck(in, "ReadFreeModule -- NumComponents"); 263 264 SkipTag(in, "<ordering_grading>"); 265 string tag; 266 in >> tag; 267 InputFailCheck(in, "ReadFreeModule -- tag"); 268 while (tag!="</ordering_grading>") 269 { 270 switch (tag[1]) 271 { 272 case 'm': 273 AssertTag(tag, "<module_shifts>"); 274 for (long i=0 ; i<NumComponents ; ++i) 275 InputShifts.push_back(ReadDegree(in, GradingDim(P))); 276 SkipTag(in, "</module_shifts>"); 277 break; 278 case 'o': 279 AssertTag(tag, "<ordering_type>"); 280 in >> tag; 281 InputFailCheck(in, "ReadFreeModule -- tag2"); 282 while (tag!="</ordering_type>") 283 { 284 if (tag=="wdeg_pos_to" || tag=="pos_to") IsPosTO = true; 285 else if (tag=="wdeg_to_pos" || tag=="to_pos") IsPosTO = false; 286 else if (tag=="<module_components_ordering>") 287 { 288 for (long i=0 ; i<NumComponents ; ++i) 289 { 290 long c; 291 in >> c; 292 ComponentOrdering.push_back(c); 293 } 294 InputFailCheck(in, "ReadFreeModule -- ComponentOrdering"); 295 SkipTag(in, "</module_components_ordering>"); 296 } 297 else ThrowInputError(tag); 298 in >> tag; 299 InputFailCheck(in, "ReadFreeModule -- tag3"); 300 } 301 break; 302 } 303 in >> tag; 304 InputFailCheck(in, "ReadFreeModule -- tag4"); 305 } 306 SkipTag(in, "</graded_free_module>"); 307 308 if (InputShifts.empty()) // GradimDim is 0 309 { 310 CoCoA_ASSERT(GradingDim(P)==0); 311 for (long i=0; i != NumComponents; ++i) InputShifts.push_back(degree(0)); 312 } 313 314 if (IsPosTO) 315 return NewFreeModule(P, InputShifts, WDegPosnOrd); 316 else 317 return NewFreeModule(P, InputShifts, OrdPosn); 318 } 319 320 ReadPolyRing(std::istream & in,SkipTagType ST)321 SparsePolyRing ReadPolyRing(std::istream& in, SkipTagType ST) 322 { 323 if (ST == GetTag) SkipTag(in, "<polynomial_ring>"); 324 long NumInds = 0; 325 long NumPars = 0; 326 BigInt charact(32003); 327 long PrecBits = 0; 328 329 string PolyRingName; 330 string tag; 331 in >> tag; 332 InputFailCheck(in, "ReadPolyRing -- tag"); 333 if (tag=="name") 334 { 335 in >> PolyRingName; 336 in >> tag; 337 InputFailCheck(in, "ReadPolyRing -- PolyRingName"); 338 } 339 AssertTag(tag, "<coefficient_ring>"); 340 in >> tag; 341 InputFailCheck(in, "ReadPolyRing -- tag2"); 342 while (tag!="</coefficient_ring>") 343 { 344 switch (tag[0]) 345 { 346 case 'f': AssertTag(tag,"float_precision"); in >> PrecBits;break; 347 case 'c': AssertTag(tag, "characteristic"); in >> charact; break; 348 default: ThrowInputError(tag); 349 } 350 in >> tag; 351 InputFailCheck(in, "ReadPolyRing -- tag3"); 352 } 353 // Read Indets 354 SkipTag(in, "<indeterminates>"); 355 in >> tag; 356 InputFailCheck(in, "ReadPolyRing -- tag4"); 357 while (tag!="</indeterminates>") 358 { 359 switch (tag[7]) 360 { 361 case 'i': AssertTag(tag, "number_indets"); in >> NumInds; break; 362 case 'p': AssertTag(tag, "number_params"); in >> NumPars; break; 363 default: ThrowInputError(tag); 364 } 365 in >> tag; 366 InputFailCheck(in, "ReadPolyRing -- tag5"); 367 } 368 const PPOrdering O(ReadPolyRingOrdering(in, NumInds, GetTag)); 369 SkipTag(in, "</polynomial_ring>"); 370 371 SparsePolyRing P = NewPolyRingServer(charact, PrecBits, NumPars, O); 372 WritePolyRing(GlobalLogput(), P); 373 return P; 374 } 375 376 WriteMatrix(std::ostream & out,const matrix & M)377 void WriteMatrix(std::ostream& out, const matrix &M) 378 { 379 if (NumCols(M)==0) { out << "Mat([[]])" << endl; return; } 380 ostringstream buf; 381 buf << "Mat(["; 382 for (long i=0 ; i < NumRows(M); ++i) 383 { 384 if (i > 0) buf << ","; 385 buf << "\n [" << M(i,0); 386 for (long j=1 ; j < NumCols(M); ++j) buf << ", " << M(i,j); 387 buf << "]"; 388 } 389 buf << "\n])" << flush; 390 out << buf.str(); 391 } 392 393 394 // void WriteMatrixInVar(std::ostream& out, const std::string& VarName, const matrix &M) 395 // { 396 // out << VarName << " := "; 397 // WriteMatrix(out, M); 398 // out << ";" << endl; 399 // } 400 401 WritePolyRing(std::ostream & out,const SparsePolyRing & P)402 void WritePolyRing(std::ostream& out, const SparsePolyRing& P) 403 { 404 const BigInt charact = characteristic(P); 405 long NumPars = 0; 406 long prec = 0; 407 PPOrdering PPO = ordering(PPM(P)); 408 409 if (IsRingTwinFloat(CoeffRing(P))) 410 prec = PrecisionBits(CoeffRing(P)); 411 if (IsQuotientRing(CoeffRing(P)) && 412 IsSparsePolyRing(BaseRing(CoeffRing(P)))) 413 { // this is just enough for the rings CoCoA-4 can send 414 const SparsePolyRing R = BaseRing(CoeffRing(P)); 415 if (IsRingTwinFloat(CoeffRing(R))) 416 prec = PrecisionBits(CoeffRing(R)); 417 NumPars = NumIndets(R); 418 } 419 out << "Use P::="; 420 if (charact > 0) out << "ZZ/(" << charact << ")"; 421 else if (prec == 0) out << "QQ"; 422 else out << "RR(" << prec << ")"; 423 if (NumPars > 0) 424 out << "(a[0.." << NumPars-1 << "])"; 425 out << "[x[0.." << NumIndets(P)-1 << "]]"; 426 if (IsLex(PPO)) out << ",Lex;\n"; 427 else if (IsStdDegLex(PPO)) out << ",DegLex;\n"; 428 else if (IsStdDegRevLex(PPO)) out << ";\n"; 429 else 430 { 431 out << ",Mat([..]);\n"; 432 out << "-- GrDim = " << GradingDim(PPO) << endl; 433 } 434 out << flush; 435 } 436 437 438 // void WriteMonomials(std::ostream& out, ConstRefRingElem f) 439 // { 440 // // prints the polynomial writing [term,..,term] (called by WritePolyList) 441 // if (IsZero(f)) // trivial special case 442 // { out << "[0]" << endl; return; } 443 444 // ostringstream buf; 445 // SparsePolyIter i=BeginIter(f); 446 // buf << "[ (" << coeff(i) << ")*" << PP(i); 447 // for (++i; !IsEnded(i); ++i) 448 // buf << ", (" << coeff(i) << ")*" << PP(i); 449 // buf << " ]" << flush; 450 // out << buf.str() << flush; 451 // } 452 453 WritePoly(std::ostream & out,ConstRefRingElem f)454 void WritePoly(std::ostream& out, ConstRefRingElem f) 455 { out << f; } 456 457 WritePolyList(std::ostream & out,const PolyList & PL)458 void WritePolyList(std::ostream& out, const PolyList& PL) 459 { 460 out << "<poly_list>" << endl; 461 for (PolyList::const_iterator it=PL.begin(); it!=PL.end(); ++it) 462 { 463 WritePoly(out, *it); 464 out << ";\n"; 465 } 466 out << "</poly_list>" << endl; 467 } 468 469 WriteIdeal(std::ostream & out,const ideal & I)470 void WriteIdeal(std::ostream& out, const ideal& I) 471 { 472 out << "<ideal>" << endl; 473 WritePolyList(out, gens(I)); 474 out << "</ideal>" << endl; 475 } 476 477 WritePolyListInVar(std::ostream & out,const std::string & VarName,const PolyList & PL)478 void WritePolyListInVar(std::ostream& out, 479 const std::string& VarName, 480 const PolyList& PL) 481 { 482 // out << VarName << " := "; 483 WritePolyList(out, PL); 484 // out << ";" << endl; 485 } 486 487 WriteVectorListInVar(std::ostream & out,const std::string & VarName,const VectorList & VL)488 void WriteVectorListInVar(std::ostream& out, 489 const std::string& VarName, 490 const VectorList& VL) 491 { 492 out << VarName << " := [];" << endl; 493 for (VectorList::const_iterator it=VL.begin(); it!=VL.end(); ++it) 494 out << "Append(" << VarName << ", Vector(" << *it << "));" << endl; 495 } 496 497 PrintTimeToLog(double T)498 void PrintTimeToLog(double T) 499 { 500 GlobalLogput() << "[log] TotalTime=" 501 << T << endl; 502 } 503 504 PrintTimeToCoCoA5(double T)505 void PrintTimeToCoCoA5(double T) 506 { 507 GlobalOutput() << "--CoCoAServer: computing Cpu Time = " 508 << T << endl; 509 } 510 511 PrintVersionToCoCoA5()512 void PrintVersionToCoCoA5() 513 { 514 GlobalOutput() << "--CoCoAServer: CoCoALib version " 515 << BuildInfo::version() << endl; 516 } 517 EndOfTransmissionToCoCoA5()518 void EndOfTransmissionToCoCoA5() 519 { 520 // The CoCoA4 parser interprets the character '\001' as meaning end of file; 521 // we use this character to mark the end of a transmission. 522 GlobalOutput() << char(1) << flush; 523 } 524 525 //---------------------------------------------------------------------- 526 ReadPolyRingOrdering(std::istream & in,long NumInds,SkipTagType ST)527 PPOrdering ReadPolyRingOrdering(std::istream& in, long NumInds, SkipTagType ST) 528 { 529 if (ST == GetTag) SkipTag(in, "<ordering_grading>"); 530 string tag; 531 SkipTag(in, "ordering_type"); 532 in >> tag; 533 InputFailCheck(in, "ReadPolyRingOrdering -- tag"); 534 switch (tag[9]) 535 { 536 case 'p': AssertTag(tag, "lexicographic"); 537 SkipTag(in, "</ordering_grading>"); 538 return lex(NumInds); 539 case 'v': AssertTag(tag, "graded_reverse_lexicographic"); 540 SkipTag(in, "</ordering_grading>"); 541 return StdDegRevLex(NumInds); 542 case 'x': AssertTag(tag, "graded_lexicographic"); 543 SkipTag(in, "</ordering_grading>"); 544 return StdDegLex(NumInds); 545 case 'd': AssertTag(tag, "matrix_ordering"); 546 { 547 long GrDim; 548 SkipTag(in, "grading_dim"); 549 in >> GrDim; 550 InputFailCheck(in, "ReadPolyRingOrdering -- GrDim"); 551 matrix M = ReadIntegerMatrix(in, GetTag); 552 if (NumRows(M) != NumInds || NumCols(M) != NumInds) 553 CoCoA_ERROR(ERR::BadMatrixSize, "ReadPolyRingOrdering"); 554 SkipTag(in, "</ordering_grading>"); 555 return NewMatrixOrdering(M, GrDim); 556 } 557 default: ThrowInputError(tag); 558 } 559 return StdDegRevLex(NumInds); // to stop compilation warning 560 } 561 562 NewCoeffRing(const BigInt & charact,long FloatPrecision,long NumParams)563 ring NewCoeffRing(const BigInt& charact, long FloatPrecision, long NumParams) 564 { 565 if (NumParams == 0) 566 { 567 if (IsZero(charact) && FloatPrecision==0) return RingQQ(); 568 if (IsZero(charact)) return NewRingTwinFloat(FloatPrecision); 569 return NewZZmod(charact); 570 } 571 572 //-------- Parameter Ring --------// 573 const vector<symbol> ParamNames(SymbolRange("a", 0, NumParams-1)); 574 if (IsZero(charact) && FloatPrecision!=0) 575 return NewPolyRing_DMPI(NewRingTwinFloat(FloatPrecision), NumParams); 576 if (IsZero(charact)) 577 return NewFractionField(NewPolyRing_DMPI(RingQQ(), ParamNames)); 578 ring Zmod = NewZZmod(charact); 579 if (IsRingFp(Zmod)) 580 return NewFractionField(NewPolyRing_DMPII(Zmod, ParamNames)); 581 else 582 return NewFractionField(NewPolyRing_DMPI(Zmod, ParamNames)); 583 } 584 585 NewPolyRingServer(const BigInt & charact,long FloatPrecision,long NumParams,const PPOrdering & O)586 SparsePolyRing NewPolyRingServer(const BigInt& charact, long FloatPrecision, long NumParams, const PPOrdering& O) 587 { 588 //-------- coefficient ring --------// 589 ring R = NewCoeffRing(charact, FloatPrecision, NumParams); 590 const vector<symbol> IndetNames(SymbolRange("x", 0, NumIndets(O)-1)); 591 592 //-------- PolyRing --------// 593 if (IsRingFp(R)) 594 return NewPolyRing_DMPII(R, IndetNames, O); 595 /*else*/ 596 return NewPolyRing_DMPI(R, IndetNames, O); 597 } 598 599 600 //---------------------------------------------------------------------- 601 ThrowInputError(const std::string & unknown_tag)602 void ThrowInputError(const std::string& unknown_tag) 603 { 604 CoCoA_ERROR("UNKNOWN TAG: " + unknown_tag, "ThrowInputError"); 605 } 606 607 AssertTag(const std::string & input_tag,const std::string & expected_tag)608 void AssertTag(const std::string& input_tag, const std::string& expected_tag) 609 { 610 if (input_tag == expected_tag) return; 611 CoCoA_ERROR("Expected tag: " + expected_tag + 612 "; Read tag: " + input_tag, 613 "CoCoAServer"); 614 } 615 616 SkipTag(std::istream & in,const std::string & expected_tag)617 void SkipTag(std::istream& in, const std::string& expected_tag) 618 { 619 string tag; 620 in >> tag; 621 InputFailCheck(in, "SkipTag "+expected_tag); 622 AssertTag(tag, expected_tag); 623 } 624 625 } 626 627 // $Header: /Volumes/Home_1/cocoa/cvs-repository/CoCoALib-0.99/src/server/CoCoA5io.C,v 1.2 2019/03/27 15:01:02 bigatti Exp $ 628 // $Log: CoCoA5io.C,v $ 629 // Revision 1.2 2019/03/27 15:01:02 bigatti 630 // -- minor changes, needs more cleaning, but it works 631 // 632 // Revision 1.1 2019/03/20 16:22:15 bigatti 633 // -- first import 634 // 635 // Revision 1.15 2019/03/19 12:53:00 bigatti 636 // -- just some debugging info 637 // 638 // Revision 1.14 2018/05/18 16:56:06 bigatti 639 // -- added include SparsePolyOps-RingElem.H 640 // 641 // Revision 1.13 2018/05/18 14:54:17 bigatti 642 // -- renamed IntOperations --> BigIntOps 643 // 644 // Revision 1.12 2017/11/10 16:28:17 abbott 645 // Summary: Ooops forgot this one 646 // 647 // Revision 1.11 2017/04/18 16:24:54 bigatti 648 // -- removed use of stats level 649 // 650 // Revision 1.10 2015/12/01 17:05:29 abbott 651 // Summary: Updated to new interface for NewMatrixOrdering 652 // 653 // Revision 1.9 2014/07/31 14:45:19 abbott 654 // Summary: Merged io.H and UtilsTemplate.H into new header VectorOperations.H 655 // Author: JAA 656 // 657 // Revision 1.8 2014/07/30 15:06:57 abbott 658 // Summary: Changed BaseRing into RingOf 659 // Author: JAA 660 // 661 // Revision 1.7 2014/07/09 11:45:08 abbott 662 // Summary: Removed AsRingTwinFloat 663 // Author: JAA 664 // 665 // Revision 1.6 2014/07/08 16:04:58 abbott 666 // Summary: Removed AsQuotientRing 667 // Author: JAA 668 // 669 // Revision 1.5 2014/07/08 09:17:44 abbott 670 // Summary: Removed AsFractionField, removed AsSparsePolyRing 671 // Author: JAA 672 // 673 // Revision 1.4 2014/05/15 12:31:34 abbott 674 // Summary: Now using new files server/GlobalIO.HC (previously in CoCoA/io.H) 675 // Author: JAA 676 // 677 // Revision 1.3 2013/06/03 10:47:52 bigatti 678 // renamed ModuleTermOrdering into ModuleOrdering 679 // 680 // Revision 1.2 2013/05/27 17:12:35 bigatti 681 // -- new name for ModuleOrderingCtor 682 // 683 // Revision 1.1 2013/05/27 12:57:39 abbott 684 // Moved all server-related code into src/server/ 685 // 686 // Revision 1.21 2012/10/02 10:36:12 abbott 687 // Revised interface to BuildInfo information strings. 688 // Several consequential changes. 689 // 690 // Revision 1.20 2012/05/28 09:18:21 abbott 691 // Created IntOperations which gathers together all operations on 692 // integers (both big and small). Many consequential changes. 693 // 694 // Revision 1.19 2012/02/10 10:26:40 bigatti 695 // -- changed RingZ.H, RingQ.H --> RingZZ.H, RingQQ.H 696 // 697 // Revision 1.18 2012/02/08 17:11:09 bigatti 698 // -- changed: Z,Q -> ZZ,QQ 699 // 700 // Revision 1.17 2011/08/14 15:52:17 abbott 701 // Changed ZZ into BigInt (phase 1: just the library sources). 702 // 703 // Revision 1.16 2011/03/10 16:11:13 bigatti 704 // -- using long instead of size_t 705 // 706 // Revision 1.15 2010/02/03 11:24:02 bigatti 707 // -- minor change for too small timing to cocoa-4 708 // 709 // Revision 1.14 2009/10/29 19:12:59 abbott 710 // Added EndOfTransmissionToCoCoA4 function. 711 // Used this new function in CoCoAServer to implement "over-and-out" handshake 712 // at the end of a CoCoA4-CoCoAServer session. 713 // New version number to mark this change -- not backward compatible! 714 // 715 // Revision 1.13 2009/10/27 13:05:41 bigatti 716 // -- renamed ostringstream variables "stream" and "s" into "buf 717 // 718 // Revision 1.12 2009/10/26 17:20:03 bigatti 719 // -- trying to avoid sending small strings to sockets... 720 // 721 // Revision 1.11 2009/09/25 10:26:20 bigatti 722 // -- replaced some "endl" with "\n" 723 // 724 // Revision 1.10 2009/05/20 14:24:59 abbott 725 // Some code cleaning (e.g. adding const where I could). 726 // Code now uses InputFailCheck after attempting to read input. 727 // 728 // Revision 1.9 2009/01/26 15:55:23 bigatti 729 // -- minor cleanup 730 // -- added WriteIdeal, WriteMatrix, WritePoly, WritePolyList 731 // -- sorted included files 732 // 733 // Revision 1.8 2008/11/19 16:32:50 bigatti 734 // -- added WriteMatrix 735 // 736 // Revision 1.7 2008/09/19 11:34:16 bigatti 737 // -- new mechanism for passing verbosity level (or StatLevel) 738 // [only partially tested] 739 // 740 // Revision 1.6 2008/05/28 16:19:02 bigatti 741 // -- added ReadPPs for reading a list of power-products in PPMonoidEv 742 // (fo exponent overflow in PPMonoidOv) 743 // 744 // Revision 1.5 2008/04/18 15:35:57 abbott 745 // (long overdue) Major revision to matrices 746 // 747 // Revision 1.4 2007/10/30 17:14:08 abbott 748 // Changed licence from GPL-2 only to GPL-3 or later. 749 // New version for such an important change. 750 // 751 // Revision 1.3 2007/06/21 21:29:47 abbott 752 // Changed name of RingFloat into RingTwinFloat. 753 // 754 // Revision 1.2 2007/05/03 10:36:25 abbott 755 // Now has explicit includes instead of simply including library.H. 756 // 757 // Revision 1.1 2007/04/27 14:54:22 bigatti 758 // -- content of CoCoAServer.C split into dedicated files 759 // -- new registration mechanism (through include "RegisterServerOps.H") 760 // 761