1 // Copyright (c) 2007-2009 John Abbott and 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 "CoCoA/library.H" 19 #include "CoCoA5io.H" // #include "CoCoA4io.H" 20 #include "GlobalIO.H" 21 #include "ServerOp.H" 22 23 // #include <iostream> --- already included in library.H 24 using std::ostream; 25 using std::istream; 26 using std::endl; 27 // #include <list> --- already included in library.H 28 using std::list; 29 // #include <memory> --- already included in library.H 30 using std::unique_ptr; 31 // #include <string> --- already included in library.H 32 using std::string; 33 // #include <vector> --- already included in library.H 34 using std::vector; 35 36 namespace CoCoA 37 { 38 39 // sublibrary of CoCoALib for groebner related operations 40 // by M.Caboara CoCoALib_groebner()41 const ServerOpBase::LibraryInfo& CoCoALib_groebner() 42 { 43 static const ServerOpBase::LibraryInfo UniqueValue("CoCoALib", BuildInfo::version(), "groebner"); 44 return UniqueValue; 45 } 46 47 // sublibrary of CoCoALib for approx points 48 // by J Abbott, M-L Torrente CoCoALib_approx()49 const ServerOpBase::LibraryInfo& CoCoALib_approx() 50 { 51 static const ServerOpBase::LibraryInfo UniqueValue("CoCoALib", BuildInfo::version(), "approx"); 52 return UniqueValue; 53 } 54 55 // sublibrary of CoCoALib for monomial (squarefree) ideals 56 // by M.Caboara, E.Saenz-de-Cabezon CoCoALib_combinatorics()57 const ServerOpBase::LibraryInfo& CoCoALib_combinatorics() 58 { 59 static const ServerOpBase::LibraryInfo UniqueValue("CoCoALib", BuildInfo::version(), "combinatorics"); 60 return UniqueValue; 61 } 62 63 64 // ---- Verbosity Level as optional last argument 65 66 // int TryReadingVerbosityLevel(istream& in) 67 // { 68 // SkipTag(GlobalInput(), "<verbosity_level>"); 69 // return ReadVerbosityLevel(in, TagWasRead); 70 // } 71 72 73 // // ---- TestSocket ---- 74 // class TestSocket: public ServerOpBase 75 // { 76 // public: 77 // TestSocket(): ServerOpBase(CoCoALib_groebner()) {}; 78 // ~TestSocket() {}; 79 // void myOutputSelf(std::ostream& out) const { out << "TestSocket"; } 80 // void myReadArgs(std::istream& in, int NumArgs); 81 // void myCompute() { /**/ } 82 // void myWriteResult(std::ostream& out) const {out << ourVarName4 << " := True"; } 83 // void myClear() {}; 84 // private: 85 // vector<RingElem> myInPL; // ANNA: this is totally useless, I'll clean it up.. 86 // }; 87 88 89 // void TestSocket::myReadArgs(std::istream& in, int NumArgs) 90 // { 91 // CoCoA_ASSERT(NumArgs==2); 92 // const SparsePolyRing P(ReadPolyRing(in, GetTag)); 93 // ReadPolyList(in, myInPL, P, GetTag); 94 // } 95 96 // ---- CoCoA/GOperations.H by M.Caboara ---- 97 class ModuleGBasis: public ServerOpBase 98 { 99 public: ModuleGBasis()100 ModuleGBasis(): ServerOpBase(CoCoALib_groebner()) {}; ~ModuleGBasis()101 ~ModuleGBasis() {}; myOutputSelf(std::ostream & out)102 void myOutputSelf(std::ostream& out) const { out << "ModuleGBasis"; } 103 void myReadArgs(std::istream& in, int NumArgs); myCompute()104 void myCompute() {VectorList NoUse; ComputeGBasis(myResVL, NoUse, myInVL);} myWriteResult(std::ostream & out)105 void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } myClear()106 void myClear() { myInVL.clear(); myResVL.clear(); } 107 private: 108 VectorList myInVL, myResVL; 109 }; 110 111 myReadArgs(std::istream & in,int NumArgs)112 void ModuleGBasis::myReadArgs(std::istream& in, int NumArgs) 113 { 114 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 115 const FreeModule FM(ReadFreeModule(in, GetTag)); 116 ReadVectorList(in, myInVL, FM, GetTag); 117 } 118 119 120 // ---- CoCoA/GOperations.H by M.Caboara ---- 121 class ModuleLT: public ServerOpBase 122 { 123 public: ModuleLT()124 ModuleLT(): ServerOpBase(CoCoALib_groebner()) {}; ~ModuleLT()125 ~ModuleLT() {}; myOutputSelf(std::ostream & out)126 void myOutputSelf(std::ostream& out) const { out << "ModuleLT"; } 127 void myReadArgs(std::istream& in, int NumArgs); myCompute()128 void myCompute() { ComputeLT(myResVL, myInVL); } myWriteResult(std::ostream & out)129 void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } myClear()130 void myClear() { myInVL.clear(); myResVL.clear(); } 131 private: 132 VectorList myInVL, myResVL; 133 }; 134 135 myReadArgs(std::istream & in,int NumArgs)136 void ModuleLT::myReadArgs(std::istream& in, int NumArgs) 137 { 138 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 139 const FreeModule FM(ReadFreeModule(in, GetTag)); 140 ReadVectorList(in, myInVL, FM, GetTag); 141 } 142 143 // ---- CoCoA/GOperations.H by M.Caboara ---- 144 class ModuleSyzygy: public ServerOpBase 145 { 146 public: ModuleSyzygy()147 ModuleSyzygy(): ServerOpBase(CoCoALib_groebner()) {}; ~ModuleSyzygy()148 ~ModuleSyzygy() {}; myOutputSelf(std::ostream & out)149 void myOutputSelf(std::ostream& out) const { out << "ModuleSyzygy"; } 150 void myReadArgs(std::istream& in, int NumArgs); myCompute()151 void myCompute() { ComputeSyz(myResVL, NewFreeModuleForSyz(myInVL), myInVL); } myWriteResult(std::ostream & out)152 void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } myClear()153 void myClear() { myInVL.clear(); myResVL.clear(); } 154 private: 155 VectorList myInVL, myResVL; 156 }; 157 158 myReadArgs(std::istream & in,int NumArgs)159 void ModuleSyzygy::myReadArgs(std::istream& in, int NumArgs) 160 { 161 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 162 const FreeModule FM(ReadFreeModule(in, GetTag)); 163 ReadVectorList(in, myInVL, FM, GetTag); 164 } 165 166 // ---- CoCoA/GOperations.H by M.Caboara ---- 167 class ModuleIntersection: public ServerOpBase 168 { 169 public: ModuleIntersection()170 ModuleIntersection(): ServerOpBase(CoCoALib_groebner()) {}; ~ModuleIntersection()171 ~ModuleIntersection() {}; myOutputSelf(std::ostream & out)172 void myOutputSelf(std::ostream& out) const { out << "ModuleIntersection"; } 173 void myReadArgs(std::istream& in, int NumArgs); myCompute()174 void myCompute() { ComputeIntersection(myResVL, myInVL1, myInVL2); } myWriteResult(std::ostream & out)175 void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } myClear()176 void myClear() { myInVL1.clear(); myInVL2.clear(); myResVL.clear(); } 177 private: 178 VectorList myInVL1, myInVL2, myResVL; 179 }; 180 181 myReadArgs(std::istream & in,int NumArgs)182 void ModuleIntersection::myReadArgs(std::istream& in, int NumArgs) 183 { 184 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 185 const FreeModule FM(ReadFreeModule(in, GetTag)); 186 ReadVectorList(in, myInVL1, FM, GetTag); 187 ReadVectorList(in, myInVL2, FM, GetTag); 188 } 189 190 // ---- CoCoA/GOperations.H by M.Caboara ---- 191 class ColonModMod: public ServerOpBase 192 { 193 public: ColonModMod()194 ColonModMod(): ServerOpBase(CoCoALib_groebner()) {}; ~ColonModMod()195 ~ColonModMod() {}; myOutputSelf(std::ostream & out)196 void myOutputSelf(std::ostream& out) const { out << "ColonModMod"; } 197 void myReadArgs(std::istream& in, int NumArgs); myCompute()198 void myCompute() { ComputeColon(myResPL, myInVL1, myInVL2); } myWriteResult(std::ostream & out)199 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()200 void myClear() { myInVL1.clear(); myInVL2.clear(); myResPL.clear(); } 201 private: 202 VectorList myInVL1, myInVL2; 203 PolyList myResPL; 204 }; 205 206 myReadArgs(std::istream & in,int NumArgs)207 void ColonModMod::myReadArgs(std::istream& in, int NumArgs) 208 { 209 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 210 const FreeModule FM(ReadFreeModule(in, GetTag)); 211 ReadVectorList(in, myInVL1, FM, GetTag); 212 ReadVectorList(in, myInVL2, FM, GetTag); 213 } 214 215 // ---- CoCoA/GOperations.H by M.Caboara ---- 216 class ModuleSaturation: public ServerOpBase 217 { 218 public: ModuleSaturation()219 ModuleSaturation(): ServerOpBase(CoCoALib_groebner()) {}; ~ModuleSaturation()220 ~ModuleSaturation() {}; myOutputSelf(std::ostream & out)221 void myOutputSelf(std::ostream& out) const { out << "ModuleSaturation"; } 222 void myReadArgs(std::istream& in, int NumArgs); myCompute()223 void myCompute() { ComputeSaturation(myResVL, myInVL, myInPL); } myWriteResult(std::ostream & out)224 void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } myClear()225 void myClear() { myInVL.clear(); myInPL.clear(); myResVL.clear(); } 226 private: 227 VectorList myInVL, myResVL; 228 PolyList myInPL; 229 }; 230 231 myReadArgs(std::istream & in,int NumArgs)232 void ModuleSaturation::myReadArgs(std::istream& in, int NumArgs) 233 { 234 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 235 const FreeModule FM(ReadFreeModule(in, GetTag)); 236 const SparsePolyRing P = RingOf(FM); 237 ReadVectorList(in, myInVL, FM, GetTag); 238 ReadPolyList(in, myInPL, P, GetTag); 239 } 240 241 // ---- CoCoA/GOperations.H by M.Caboara ---- 242 class IdealSaturation: public ServerOpBase 243 { 244 public: IdealSaturation()245 IdealSaturation(): ServerOpBase(CoCoALib_groebner()) {}; ~IdealSaturation()246 ~IdealSaturation() {}; myOutputSelf(std::ostream & out)247 void myOutputSelf(std::ostream& out) const { out << "IdealSaturation"; } 248 void myReadArgs(std::istream& in, int NumArgs); myCompute()249 void myCompute() { ComputeSaturation(myResPL, myInPL1, myInPL2); } myWriteResult(std::ostream & out)250 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()251 void myClear() { myInPL1.clear(); myInPL2.clear(); myResPL.clear(); } 252 private: 253 PolyList myInPL1, myInPL2, myResPL; 254 }; 255 256 myReadArgs(std::istream & in,int NumArgs)257 void IdealSaturation::myReadArgs(std::istream& in, int NumArgs) 258 { 259 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 260 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 261 ReadPolyList(in, myInPL1, P, GetTag); 262 ReadPolyList(in, myInPL2, P, GetTag); 263 } 264 265 // ---- CoCoA/GOperations.H by M.Caboara ---- 266 // class ColonModId: public ServerOpBase 267 // { 268 // public: 269 // ColonModId(): ServerOpBase(CoCoALib_groebner()) {}; 270 // ~ColonModId() {}; 271 // void myOutputSelf(std::ostream& out) const { out << "ColonModId"; } 272 // void myReadArgs(std::istream& in, int NumArgs); 273 // void myCompute() { ComputeCColon(myResVL, myInVL, myInPL); } 274 // void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } 275 // void myClear() { myInVL.clear(); myInPL.clear(); myResVL.clear(); } 276 // private: 277 // VectorList myInVL, myResVL; 278 // PolyList myInPL; 279 // }; 280 281 282 // void ColonModId::myReadArgs(std::istream& in, int NumArgs) 283 // { 284 // const FreeModule FM(ReadFreeModule(in, GetTag)); 285 // const SparsePolyRing P = RingOf(FM); 286 // ReadVectorList(myInVL, FM, GetTag); 287 // ReadPolyList(myInPL, P, GetTag); 288 // } 289 290 // ---- CoCoA/GOperations.H by M.Caboara ---- 291 class ColonIdId: public ServerOpBase 292 { 293 public: ColonIdId()294 ColonIdId(): ServerOpBase(CoCoALib_groebner()) {}; ~ColonIdId()295 ~ColonIdId() {}; myOutputSelf(std::ostream & out)296 void myOutputSelf(std::ostream& out) const { out << "ColonIdId"; } 297 void myReadArgs(std::istream& in, int NumArgs); myCompute()298 void myCompute() { ComputeColon(myResPL, myInPL1, myInPL2); } myWriteResult(std::ostream & out)299 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()300 void myClear() { myInPL1.clear(); myInPL2.clear(); myResPL.clear(); } 301 private: 302 PolyList myInPL1, myInPL2, myResPL; 303 }; 304 305 myReadArgs(std::istream & in,int NumArgs)306 void ColonIdId::myReadArgs(std::istream& in, int NumArgs) 307 { 308 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 309 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 310 ReadPolyList(in, myInPL1, P, GetTag); 311 ReadPolyList(in, myInPL2, P, GetTag); 312 } 313 314 // ---- CoCoA/GOperations.H by M.Caboara ---- 315 class ModuleElim: public ServerOpBase 316 { 317 public: ModuleElim()318 ModuleElim(): ServerOpBase(CoCoALib_groebner()) {}; ~ModuleElim()319 ~ModuleElim() {}; myOutputSelf(std::ostream & out)320 void myOutputSelf(std::ostream& out) const { out << "ModuleElim"; } 321 void myReadArgs(std::istream& in, int NumArgs); myCompute()322 void myCompute() { ComputeElim(myResVL, myInVL, *myInElimPPPtr); } myWriteResult(std::ostream & out)323 void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } myClear()324 void myClear() { myInVL.clear(); myInElimPPPtr.reset(0); myResVL.clear(); } 325 private: 326 VectorList myInVL, myResVL; 327 unique_ptr<PPMonoidElem> myInElimPPPtr; 328 }; 329 330 myReadArgs(std::istream & in,int NumArgs)331 void ModuleElim::myReadArgs(std::istream& in, int NumArgs) 332 { 333 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 334 const FreeModule FM(ReadFreeModule(in, GetTag)); 335 const SparsePolyRing P = RingOf(FM); 336 ReadVectorList(in, myInVL, FM, GetTag); 337 PolyList PL; 338 myInElimPPPtr.reset(new PPMonoidElem(PPM(P))); 339 ReadPolyList(in, PL, P, GetTag); 340 for (PolyList::const_iterator it=PL.begin(); it != PL.end(); ++it) 341 (*myInElimPPPtr) *= LPP(*it); 342 } 343 344 // ---- CoCoA/GOperations.H by M.Caboara ---- 345 class ModuleHomog: public ServerOpBase 346 { 347 public: ModuleHomog()348 ModuleHomog(): ServerOpBase(CoCoALib_groebner()) {}; ~ModuleHomog()349 ~ModuleHomog() {}; myOutputSelf(std::ostream & out)350 void myOutputSelf(std::ostream& out) const { out << "ModuleHomog"; } 351 void myReadArgs(std::istream& in, int NumArgs); myCompute()352 void myCompute() { ComputeHomogenization(myResVL, myInVL, myInHomIndets); } myWriteResult(std::ostream & out)353 void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } myClear()354 void myClear() { myInVL.clear(); myInHomIndets.clear(); myResVL.clear(); } 355 private: 356 VectorList myInVL, myResVL; 357 PolyList myInHomIndets; 358 }; 359 360 myReadArgs(std::istream & in,int NumArgs)361 void ModuleHomog::myReadArgs(std::istream& in, int NumArgs) 362 { 363 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 364 const FreeModule FM(ReadFreeModule(in, GetTag)); 365 const SparsePolyRing P = RingOf(FM); 366 ReadVectorList(in, myInVL, FM, GetTag); 367 ReadPolyList(in, myInHomIndets, P, GetTag); 368 } 369 370 // ---- CoCoA/GOperations.H by M.Caboara ---- 371 class IdealGBasis: public ServerOpBase 372 { 373 public: IdealGBasis()374 IdealGBasis(): ServerOpBase(CoCoALib_groebner()) {}; ~IdealGBasis()375 ~IdealGBasis() {}; myOutputSelf(std::ostream & out)376 void myOutputSelf(std::ostream& out) const { out << "IdealGBasis"; } 377 void myReadArgs(std::istream& in, int NumArgs); myCompute()378 void myCompute() { PolyList tmp; ComputeGBasis(myResPL, tmp, myInPL); } myWriteResult(std::ostream & out)379 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()380 void myClear() { myInPL.clear(); myResPL.clear(); } 381 private: 382 PolyList myInPL, myResPL; 383 }; 384 385 myReadArgs(std::istream & in,int NumArgs)386 void IdealGBasis::myReadArgs(std::istream& in, int NumArgs) 387 { 388 CoCoA_ASSERT(NumArgs==2); 389 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 390 ReadPolyList(in, myInPL, P, GetTag); 391 } 392 393 // ---- CoCoA/GOperations.H by M.Caboara ---- 394 class IdealSATGBasis: public ServerOpBase 395 { 396 public: IdealSATGBasis()397 IdealSATGBasis(): ServerOpBase(CoCoALib_groebner()) {}; ~IdealSATGBasis()398 ~IdealSATGBasis() {}; myOutputSelf(std::ostream & out)399 void myOutputSelf(std::ostream& out) const { out << "IdealSATGBasis"; } 400 void myReadArgs(std::istream& in, int NumArgs); myCompute()401 void myCompute() { ComputeGBasisSelfSatCore(myResPL, myInPL); } myWriteResult(std::ostream & out)402 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()403 void myClear() { myInPL.clear(); myResPL.clear(); } 404 private: 405 PolyList myInPL, myResPL; 406 }; 407 myReadArgs(std::istream & in,int NumArgs)408 void IdealSATGBasis::myReadArgs(std::istream& in, int NumArgs) 409 { 410 CoCoA_ASSERT(NumArgs==2); 411 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 412 ReadPolyList(in, myInPL, P, GetTag); 413 } 414 415 // ---- CoCoA/GOperations.H by M.Caboara ---- 416 // class IdealSATMixGBasis: public ServerOpBase 417 // { 418 // public: 419 // IdealSATMixGBasis(): ServerOpBase(CoCoALib_groebner()) {}; 420 // ~IdealSATMixGBasis() {}; 421 // void myOutputSelf(std::ostream& out) const { out << "IdealSATMixGBasis"; } 422 // void myReadArgs(std::istream& in, int NumArgs); 423 // void myCompute() { ComputeSATMixGBasis(myResPL, myInPL); } 424 // void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } 425 // void myClear() { myInPL.clear(); myResPL.clear(); } 426 // private: 427 // PolyList myInPL, myResPL; 428 // }; 429 430 // void IdealSATMixGBasis::myReadArgs(std::istream& in, int NumArgs) 431 // { 432 // // CoCoA_ASSERT(NumArgs==2 || NumArgs==3); 433 // CoCoA_ASSERT(NumArgs==2); 434 // const SparsePolyRing P(ReadPolyRing(in, GetTag)); 435 // ReadPolyList(in, myInPL, P, GetTag); 436 // } 437 438 // ---- CoCoA/GOperations.H by M.Caboara ---- 439 class IdealLT: public ServerOpBase 440 { 441 public: IdealLT()442 IdealLT(): ServerOpBase(CoCoALib_groebner()) {}; ~IdealLT()443 ~IdealLT() {}; myOutputSelf(std::ostream & out)444 void myOutputSelf(std::ostream& out) const { out << "IdealLT"; } 445 void myReadArgs(std::istream& in, int NumArgs); myCompute()446 void myCompute() { ComputeLT(myResPL, myInPL); } 447 void myWriteResult(std::ostream& out) const; myClear()448 void myClear() { myInPL.clear(); myResPL.clear(); } 449 private: 450 PolyList myInPL, myResPL; 451 // ideal myOutIdeal; 452 }; 453 454 myReadArgs(std::istream & in,int NumArgs)455 void IdealLT::myReadArgs(std::istream& in, int NumArgs) 456 { 457 CoCoA_ASSERT(NumArgs==2); 458 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 459 ReadPolyList(in, myInPL, P, GetTag); 460 } 461 462 myWriteResult(std::ostream & out)463 void IdealLT::myWriteResult(std::ostream& out) const 464 { 465 // this function will be nicer when ComputeLT "returns" an ideal 466 if (myResPL.empty()) 467 out << ourVarName4 << " := ideal()"; 468 else 469 { 470 out << ourVarName4 << " := "; 471 WriteIdeal(out, ideal(myResPL)); 472 } 473 } 474 475 476 // ---- CoCoA/GOperations.H by M.Caboara ---- 477 class IdealSyzygy: public ServerOpBase 478 { 479 public: IdealSyzygy()480 IdealSyzygy(): ServerOpBase(CoCoALib_groebner()) {}; ~IdealSyzygy()481 ~IdealSyzygy() {}; myOutputSelf(std::ostream & out)482 void myOutputSelf(std::ostream& out) const { out << "IdealSyzygy"; } 483 void myReadArgs(std::istream& in, int NumArgs); myCompute()484 void myCompute() { ComputeSyz(myResVL, NewFreeModuleForSyz(myInPL), myInPL); } myWriteResult(std::ostream & out)485 void myWriteResult(std::ostream& out) const { WriteVectorListInVar(out, ourVarName4, myResVL); } myClear()486 void myClear() { myInPL.clear(); myResVL.clear(); } 487 private: 488 PolyList myInPL; 489 VectorList myResVL; 490 }; 491 492 myReadArgs(std::istream & in,int NumArgs)493 void IdealSyzygy::myReadArgs(std::istream& in, int NumArgs) 494 { 495 CoCoA_ASSERT(NumArgs==2); 496 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 497 ReadPolyList(in, myInPL, P, GetTag); 498 } 499 500 // ---- CoCoA/GOperations.H by M.Caboara ---- 501 class IdealIntersection: public ServerOpBase 502 { 503 public: IdealIntersection()504 IdealIntersection(): ServerOpBase(CoCoALib_groebner()) {}; ~IdealIntersection()505 ~IdealIntersection() {}; myOutputSelf(std::ostream & out)506 void myOutputSelf(std::ostream& out) const { out << "IdealIntersection"; } 507 void myReadArgs(std::istream& in, int NumArgs); myCompute()508 void myCompute() { ComputeIntersection(myResPL, myInPL1, myInPL2); } 509 // void myCompute() { myOutIdeal := intersect(myInI1, myInI2); } myWriteResult(std::ostream & out)510 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()511 void myClear() { myInPL1.clear(); myInPL2.clear(); myResPL.clear(); } 512 private: 513 PolyList myInPL1, myInPL2, myResPL; 514 // ideal myInI1, myInI2, myOutI; 515 }; 516 517 myReadArgs(std::istream & in,int NumArgs)518 void IdealIntersection::myReadArgs(std::istream& in, int NumArgs) 519 { 520 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 521 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 522 ReadPolyList(in, myInPL1, P, GetTag); 523 ReadPolyList(in, myInPL2, P, GetTag); 524 } 525 526 527 // void IdealIntersection::myWriteResult(std::ostream& out) const 528 // { 529 // out << ourVarName4 << " := "; 530 // WriteIdeal(out, myOutIdeal); 531 // } 532 533 534 535 // ---- CoCoA/GOperations.H by M.Caboara ---- 536 class IdealElim: public ServerOpBase 537 { 538 public: IdealElim()539 IdealElim(): ServerOpBase(CoCoALib_groebner()) {}; ~IdealElim()540 ~IdealElim() {}; myOutputSelf(std::ostream & out)541 void myOutputSelf(std::ostream& out) const { out << "IdealElim"; } 542 void myReadArgs(std::istream& in, int NumArgs); myCompute()543 void myCompute() { ComputeElim(myResPL, myInPL, *myInElimPPPtr); } myWriteResult(std::ostream & out)544 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()545 void myClear() { myInPL.clear(); myResPL.clear(); myInElimPPPtr.reset(0); } 546 private: 547 PolyList myInPL, myResPL; 548 unique_ptr<PPMonoidElem> myInElimPPPtr; 549 }; 550 551 myReadArgs(std::istream & in,int NumArgs)552 void IdealElim::myReadArgs(std::istream& in, int NumArgs) 553 { 554 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 555 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 556 ReadPolyList(in, myInPL, P, GetTag); 557 PolyList PL; 558 PPMonoidElem t(PPM(P)); 559 ReadPolyList(in, PL, P, GetTag); 560 for (PolyList::const_iterator it=PL.begin(); it != PL.end(); ++it) 561 { 562 if ( !IsIndet(*it) ) 563 CoCoA_THROW_ERROR("Expected indet", "IdealElim::myReadArgs"); 564 t *= LPP(*it); 565 } 566 myInElimPPPtr.reset(new PPMonoidElem(t)); 567 } 568 569 // ---- CoCoA/GOperations.H by M.Caboara ---- 570 class IdealHomog: public ServerOpBase 571 { 572 public: IdealHomog()573 IdealHomog(): ServerOpBase(CoCoALib_groebner()) {}; ~IdealHomog()574 ~IdealHomog() {}; myOutputSelf(std::ostream & out)575 void myOutputSelf(std::ostream& out) const { out << "IdealHomog"; } 576 void myReadArgs(std::istream& in, int NumArgs); myCompute()577 void myCompute() { ComputeHomogenization(myResPL, myInPL, myInHomIndets); } myWriteResult(std::ostream & out)578 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()579 void myClear() { myInPL.clear(); myInHomIndets.clear(); myResPL.clear(); } 580 private: 581 PolyList myInPL, myInHomIndets, myResPL; 582 }; 583 584 myReadArgs(std::istream & in,int NumArgs)585 void IdealHomog::myReadArgs(std::istream& in, int NumArgs) 586 { 587 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 588 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 589 ReadPolyList(in, myInPL, P, GetTag); 590 ReadPolyList(in, myInHomIndets, P, GetTag); 591 } 592 593 // ---- CoCoA/TmpF5.H by A.Arri ---- 594 class F5GBasis: public ServerOpBase 595 { 596 public: F5GBasis()597 F5GBasis(): ServerOpBase(CoCoALib_groebner()) {}; ~F5GBasis()598 ~F5GBasis() {}; myOutputSelf(std::ostream & out)599 void myOutputSelf(std::ostream& out) const { out << "F5GBasis"; } 600 void myReadArgs(std::istream& in, int NumArgs); myCompute()601 void myCompute() { F5(myResPL, myInPL); } myWriteResult(std::ostream & out)602 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, myResPL); } myClear()603 void myClear() { myInPL.clear(); myResPL.clear(); } 604 private: 605 PolyList myInPL, myResPL; 606 }; 607 608 myReadArgs(std::istream & in,int NumArgs)609 void F5GBasis::myReadArgs(std::istream& in, int NumArgs) 610 { 611 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 612 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 613 ReadPolyList(in, myInPL, P, GetTag); 614 } 615 616 // ---- CoCoA/TmpIsTree.H by M.Caboara ---- 617 class IsTreeNoOpt: public ServerOpBase 618 { 619 public: IsTreeNoOpt()620 IsTreeNoOpt(): ServerOpBase(CoCoALib_combinatorics()) {}; ~IsTreeNoOpt()621 ~IsTreeNoOpt() {}; myOutputSelf(std::ostream & out)622 void myOutputSelf(std::ostream& out) const { out << "IsTreeNoOpt"; } 623 void myReadArgs(std::istream& in, int NumArgs); myCompute()624 void myCompute() { myOutCycle = myInComplex.myIsTreeNoOpt(); } myWriteResult(std::ostream & out)625 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, FacetList2PolyList(*myRingPtr,myOutCycle)); } myClear()626 void myClear() { myInComplex.myClear(); myOutCycle.clear(); } 627 private: 628 FacetComplex myInComplex; 629 list<facet> myOutCycle; 630 unique_ptr<SparsePolyRing> myRingPtr; 631 }; 632 633 myReadArgs(std::istream & in,int NumArgs)634 void IsTreeNoOpt::myReadArgs(std::istream& in, int NumArgs) 635 { 636 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 637 PolyList PL; 638 myRingPtr.reset(new SparsePolyRing(ReadPolyRing(in, GetTag))); 639 ReadPolyList(in, PL, *myRingPtr, GetTag); 640 myInComplex = FacetComplex(*myRingPtr, PL); 641 } 642 643 // ---- CoCoA/TmpIsTree.H by M.Caboara ---- 644 class IsTreeOpt: public ServerOpBase 645 { 646 public: IsTreeOpt()647 IsTreeOpt(): ServerOpBase(CoCoALib_combinatorics()) {}; ~IsTreeOpt()648 ~IsTreeOpt() {}; myOutputSelf(std::ostream & out)649 void myOutputSelf(std::ostream& out) const { out << "IsTreeOpt"; } 650 void myReadArgs(std::istream& in, int NumArgs); myCompute()651 void myCompute() { myOutCycle = myInComplex.myIsTreeOpt(); } myWriteResult(std::ostream & out)652 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, FacetList2PolyList(*myRingPtr,myOutCycle)); } myClear()653 void myClear() { myInComplex.myClear(); myOutCycle.clear(); } 654 private: 655 FacetComplex myInComplex; 656 list<facet> myOutCycle; 657 unique_ptr<SparsePolyRing> myRingPtr; 658 }; 659 660 myReadArgs(std::istream & in,int NumArgs)661 void IsTreeOpt::myReadArgs(std::istream& in, int NumArgs) 662 { 663 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 664 PolyList PL; 665 myRingPtr.reset(new SparsePolyRing(ReadPolyRing(in, GetTag))); 666 ReadPolyList(in, PL, *myRingPtr, GetTag); 667 myInComplex = FacetComplex(*myRingPtr, PL); 668 } 669 670 // ---- CoCoA/TmpIsTree.H by M.Caboara ---- 671 class IsTreeCBNoOpt: public ServerOpBase 672 { 673 public: IsTreeCBNoOpt()674 IsTreeCBNoOpt(): ServerOpBase(CoCoALib_combinatorics()) {}; ~IsTreeCBNoOpt()675 ~IsTreeCBNoOpt() {}; myOutputSelf(std::ostream & out)676 void myOutputSelf(std::ostream& out) const { out << "IsTreeCBNoOpt"; } 677 void myReadArgs(std::istream& in, int NumArgs); myCompute()678 void myCompute() { myOutCycle = myInComplex.myIsTreeCBNoOpt(); } myWriteResult(std::ostream & out)679 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, FacetList2PolyList(*myRingPtr,myOutCycle)); } myClear()680 void myClear() { myInComplex.myClear(); myOutCycle.clear(); } 681 private: 682 FacetComplex myInComplex; 683 list<facet> myOutCycle; 684 unique_ptr<SparsePolyRing> myRingPtr; 685 }; 686 687 myReadArgs(std::istream & in,int NumArgs)688 void IsTreeCBNoOpt::myReadArgs(std::istream& in, int NumArgs) 689 { 690 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 691 PolyList PL; 692 myRingPtr.reset(new SparsePolyRing(ReadPolyRing(in, GetTag))); 693 ReadPolyList(in, PL, *myRingPtr, GetTag); 694 myInComplex = FacetComplex(*myRingPtr, PL); 695 } 696 697 // ---- CoCoA/TmpIsTree.H by M.Caboara ---- 698 class IsTreeCBOpt: public ServerOpBase 699 { 700 public: IsTreeCBOpt()701 IsTreeCBOpt(): ServerOpBase(CoCoALib_combinatorics()) {}; ~IsTreeCBOpt()702 ~IsTreeCBOpt() {}; myOutputSelf(std::ostream & out)703 void myOutputSelf(std::ostream& out) const { out << "IsTreeCBOpt"; } 704 void myReadArgs(std::istream& in, int NumArgs); myCompute()705 void myCompute() { myOutCycle = myInComplex.myIsTreeCBOpt(); } myWriteResult(std::ostream & out)706 void myWriteResult(std::ostream& out) const { WritePolyListInVar(out, ourVarName4, FacetList2PolyList(*myRingPtr,myOutCycle)); } myClear()707 void myClear() { myInComplex.myClear(); myOutCycle.clear(); } 708 private: 709 FacetComplex myInComplex; 710 list<facet> myOutCycle; 711 unique_ptr<SparsePolyRing> myRingPtr; 712 }; 713 714 myReadArgs(std::istream & in,int NumArgs)715 void IsTreeCBOpt::myReadArgs(std::istream& in, int NumArgs) 716 { 717 CoCoA_ASSERT(NumArgs<10); // ??? fix with allowed values 718 PolyList PL; 719 myRingPtr.reset(new SparsePolyRing(ReadPolyRing(in, GetTag))); 720 ReadPolyList(in, PL, *myRingPtr, GetTag); 721 myInComplex = FacetComplex(*myRingPtr, PL); 722 } 723 724 725 //---------------------------------------------------- 726 // ---- CoCoA/ApproxPts.H by L.Torrente and J.Abbott ---- 727 class StableBorder: public ServerOpBase 728 { 729 public: StableBorder()730 StableBorder(): ServerOpBase(CoCoALib_approx()) {}; ~StableBorder()731 ~StableBorder() {}; myOutputSelf(std::ostream & out)732 void myOutputSelf(std::ostream& out) const { out << "StableBorder"; } 733 void myReadArgs(std::istream& in, int NumArgs); myCompute()734 void myCompute() { ApproxPts::SOITwinFloat(myOutSOI, myOutBBasis, myOutAlmostVanishing, *myPolyRingPtr, myInPts, myInTolerance, *myInGammaPtr); } 735 void myWriteResult(std::ostream& out) const; myClear()736 void myClear() { myOutSOI.clear(); myOutBBasis.clear(); myOutAlmostVanishing.clear(); myInPts.clear(); myInTolerance.clear(); myInGammaPtr.reset(); } 737 private: 738 unique_ptr<ring> myPolyRingPtr; 739 vector<ApproxPts::PointR> myInPts; 740 vector<RingElem> myInTolerance; 741 unique_ptr<RingElem> myInGammaPtr; /// BUG BUG BUG cannot (yet?) use a plain RingElem (causes "race cond" type problems with RingQQ) 742 vector<PPMonoidElem> myOutSOI; 743 vector<RingElem> myOutBBasis; 744 vector<RingElem> myOutAlmostVanishing; 745 }; 746 747 myWriteResult(std::ostream & out)748 void StableBorder::myWriteResult(std::ostream& out) const 749 { 750 out << ourVarName4 << " := Record[\n" 751 " SOI := " << myOutSOI << ",\n" 752 " AlmostVanishing := " << myOutAlmostVanishing << ",\n"; 753 if (myOutBBasis.empty()) 754 out << " StableBBasisFound := FALSE"; 755 else 756 out << " StableBBasisFound := TRUE,\n" 757 " BBasis := " << myOutBBasis; 758 759 out << "\n];" << endl; 760 } 761 762 myReadArgs(std::istream & in,int NumArgs)763 void StableBorder::myReadArgs(std::istream& in, int NumArgs) 764 { 765 CoCoA_ASSERT(NumArgs == 3+1); 766 767 myPolyRingPtr.reset(new SparsePolyRing(ReadPolyRing(in, GetTag))); 768 matrix PtsMat = ReadRationalMatrix(in, GetTag); 769 matrix TolMat = ReadRationalMatrix(in, GetTag); 770 matrix gamma = ReadRationalMatrix(in, GetTag); 771 if (NumRows(TolMat) != 1) CoCoA_THROW_ERROR("NumRows(TolMat) should be 1","StableBorder"); 772 if (NumCols(TolMat) != NumCols(PtsMat)) 773 CoCoA_THROW_ERROR("PtsMat and TolMat should have same NumCols","StableBorder"); 774 if (NumRows(gamma) != 1 || NumCols(gamma) != 1) 775 CoCoA_THROW_ERROR("gamma should be 1x1 matrix","StableBorder"); 776 777 vector<ApproxPts::PointR> pts(NumRows(PtsMat), ApproxPts::PointR(NumCols(PtsMat), zero(RingQQ()))); 778 for (long i=0; i < NumRows(PtsMat); ++i) 779 for (long j=0; j < NumCols(PtsMat); ++j) 780 pts[i][j] = PtsMat(i,j); 781 782 vector<RingElem> tolerance(NumCols(PtsMat), zero(RingQQ())); 783 for (long j=0; j < NumCols(PtsMat); ++j) 784 tolerance[j] = TolMat(0,j); 785 786 myInGammaPtr.reset(new RingElem(gamma(0,0))); 787 swap(myInPts, pts); 788 swap(myInTolerance, tolerance); 789 } 790 791 792 793 // ---- CoCoA/ApproxPts.H by L.Torrente and J.Abbott ---- 794 class NumBMBorder: public ServerOpBase 795 { 796 public: NumBMBorder()797 NumBMBorder(): ServerOpBase(CoCoALib_approx()) {}; ~NumBMBorder()798 ~NumBMBorder() {}; myOutputSelf(std::ostream & out)799 void myOutputSelf(std::ostream& out) const { out << "NumBMBorder"; } 800 void myReadArgs(std::istream& in, int NumArgs); myCompute()801 void myCompute() { ApproxPts::NBMTwinFloat(myOutQB, myOutBBasis, myOutAlmostVanishing, myInPts, myInTolerance); } 802 void myWriteResult(std::ostream& out) const; myClear()803 void myClear() { myOutQB.clear(); myOutBBasis.clear(); myOutAlmostVanishing.clear(); myInPts.clear(); myInTolerance.clear(); } 804 private: 805 vector<ApproxPts::PointR> myInPts; 806 vector<RingElem> myInTolerance; 807 vector<PPMonoidElem> myOutQB; 808 vector<RingElem> myOutBBasis; 809 vector<RingElem> myOutAlmostVanishing; 810 }; 811 812 myWriteResult(std::ostream & out)813 void NumBMBorder::myWriteResult(std::ostream& out) const 814 { 815 out << ourVarName4 << " := Record[\n" 816 " QB := " << myOutQB << ",\n" 817 " AlmostVanishing := " << myOutAlmostVanishing << ",\n"; 818 if (myOutBBasis.empty()) 819 out << " StableBBasisFound := FALSE"; 820 else 821 out << " StableBBasisFound := TRUE,\n" 822 " BBasis := " << myOutBBasis; 823 824 out << "\n];" << endl; 825 } 826 827 myReadArgs(std::istream & in,int NumArgs)828 void NumBMBorder::myReadArgs(std::istream& in, int NumArgs) 829 { 830 CoCoA_ASSERT(NumArgs == 2+1); 831 832 /*const SparsePolyRing NoUse = */ ReadPolyRing(in, GetTag); 833 matrix PtsMat = ReadRationalMatrix(in, GetTag); 834 matrix TolMat = ReadRationalMatrix(in, GetTag); 835 if (NumRows(TolMat) != 1) CoCoA_THROW_ERROR("NumRows(TolMat) should be 1","StableBorder"); 836 if (NumCols(TolMat) != NumCols(PtsMat)) 837 CoCoA_THROW_ERROR("PtsMat and TolMat should have same NumCols","StableBorder"); 838 839 vector<ApproxPts::PointR> pts(NumRows(PtsMat), ApproxPts::PointR(NumCols(PtsMat), zero(RingQQ()))); 840 for (long i=0; i < NumRows(PtsMat); ++i) 841 for (long j=0; j < NumCols(PtsMat); ++j) 842 pts[i][j] = PtsMat(i,j); 843 844 vector<RingElem> tolerance(NumCols(PtsMat), zero(RingQQ())); 845 for (long j=0; j < NumCols(PtsMat); ++j) 846 tolerance[j] = TolMat(0,j); 847 848 swap(myInPts, pts); 849 swap(myInTolerance, tolerance); 850 } 851 852 853 // ---- CoCoA/ApproxPts.H by L.Torrente and J.Abbott ---- 854 class PreprocessBase: public ServerOpBase 855 { 856 protected: PreprocessBase()857 PreprocessBase(): ServerOpBase(CoCoALib_approx()) {}; ~PreprocessBase()858 virtual ~PreprocessBase() {}; myOutputSelf(std::ostream & out)859 virtual void myOutputSelf(std::ostream& out) const { out << myAlgName(); } 860 virtual void myReadArgs(std::istream& in, int NumArgs); 861 virtual void myWriteResult(std::ostream& out) const; myClear()862 virtual void myClear() { myInPts.clear(); myInTolerance.clear(); myOutPts.clear(); myOutWeights.clear(); } 863 virtual const char* myAlgName() const = 0; 864 protected: 865 vector<ApproxPts::PointR> myInPts, myOutPts; 866 vector<RingElem> myInTolerance; 867 vector<long> myOutWeights; 868 }; 869 870 myReadArgs(std::istream & in,int NumArgs)871 void PreprocessBase::myReadArgs(std::istream& in, int NumArgs) 872 { 873 CoCoA_ASSERT(NumArgs == 3); 874 /*const SparsePolyRing NoUse = */ ReadPolyRing(in, GetTag); 875 matrix PtsMat = ReadRationalMatrix(in, GetTag); 876 matrix TolMat = ReadRationalMatrix(in, GetTag); 877 if (NumRows(TolMat) != 1) CoCoA_THROW_ERROR("NumRows(TolMat) should be 1", myAlgName()); 878 if (NumCols(TolMat) != NumCols(PtsMat)) 879 CoCoA_THROW_ERROR("PtsMat and TolMat should have same NumCols", myAlgName()); 880 881 vector<ApproxPts::PointR> pts(NumRows(PtsMat), ApproxPts::PointR(NumCols(PtsMat), zero(RingQQ()))); 882 for (long i=0; i < NumRows(PtsMat); ++i) 883 for (long j=0; j < NumCols(PtsMat); ++j) 884 pts[i][j] = PtsMat(i,j); 885 886 vector<RingElem> tolerance(NumCols(PtsMat), zero(RingQQ())); 887 for (long j=0; j < NumCols(PtsMat); ++j) 888 tolerance[j] = TolMat(0,j); 889 890 swap(myInTolerance, tolerance); 891 swap(myInPts, pts); 892 } 893 894 myWriteResult(std::ostream & out)895 void PreprocessBase::myWriteResult(std::ostream& out) const 896 { 897 out << ourVarName4 << " := Record[\n" 898 " Points := " << myOutPts << ",\n" 899 " Weights := " << myOutWeights << "\n];" << endl; 900 } 901 902 903 // ---- CoCoA/ApproxPts.H by L.Torrente and J.Abbott ---- 904 class PreprocessAggr: public PreprocessBase 905 { 906 public: myCompute()907 void myCompute() { PreprocessPtsAggr(myOutPts, myOutWeights, myInPts, myInTolerance); } myAlgName()908 const char* myAlgName() const { return "PreprocessAggr"; } 909 }; 910 911 // ---- CoCoA/ApproxPts.H by L.Torrente and J.Abbott ---- 912 class PreprocessSubdiv: public PreprocessBase 913 { 914 public: myCompute()915 void myCompute() { PreprocessPtsSubdiv(myOutPts, myOutWeights, myInPts, myInTolerance); } myAlgName()916 const char* myAlgName() const { return "PreprocessSubdiv"; } 917 }; 918 919 // ---- CoCoA/ApproxPts.H by L.Torrente and J.Abbott ---- 920 class PreprocessGrid: public PreprocessBase 921 { 922 public: myCompute()923 void myCompute() { PreprocessPtsGrid(myOutPts, myOutWeights, myInPts, myInTolerance); } myAlgName()924 const char* myAlgName() const { return "PreprocessGrid"; } 925 }; 926 927 928 929 // ---- CoCoA/TmpMayerVietorisTree.H by E. Saenz-de-Cabezon ---- 930 931 class MVT: public ServerOpBase 932 { 933 public: MVT()934 MVT(): ServerOpBase(CoCoALib_combinatorics()) {}; ~MVT()935 ~MVT() {}; myOutputSelf(std::ostream & out)936 void myOutputSelf(std::ostream& out) const { out << "MV_Tree"; } 937 void myReadArgs(std::istream& in, int NumArgs); myCompute()938 void myCompute() { MayerVietorisTree(*myOutMdMpPtr, *myInPPsPtr); } 939 void myWriteResult(std::ostream& out) const; myClear()940 void myClear() { myInPPsPtr.reset(); myOutMdMpPtr.reset(); } 941 private: 942 unique_ptr<PPVector> myInPPsPtr; 943 unique_ptr<MultidegreeMap> myOutMdMpPtr; 944 }; 945 946 myReadArgs(std::istream & in,int NumArgs)947 void MVT::myReadArgs(std::istream& in, int NumArgs) 948 { 949 CoCoA_ASSERT(NumArgs == 2); // ring and PPList 950 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 951 // PPOrdering ord = NewLexOrdering(NumIndets(P)); 952 PPMonoid PPM = NewPPMonoidEv(SymbolRange("x", 0, NumIndets(P)-1), lex); 953 vector<PPMonoidElem> V; 954 ReadPPs(in, V, PPM, GetTag); 955 DivMaskRule DMR = NewDivMaskEvenPowers(); 956 vector<long> exps(NumIndets(PPM)); 957 myInPPsPtr.reset(new PPVector(PPM, DMR)); 958 myOutMdMpPtr.reset(new MultidegreeMap); 959 960 for (long i=0 ; i<len(V); ++i) 961 { 962 exponents(exps, V[i]); 963 // anna: should find a way to avoid making copies the pps 964 myInPPsPtr->myPushBack(PPMonoidElem(PPM,exps)); 965 } 966 // convert(*myInPPsPtr, V); // ANNA: fix this! 967 968 // GlobalOutput() << "Print " << myInPPsPtr->mySize() << ";"; 969 } 970 971 myWriteResult(std::ostream & out)972 void MVT::myWriteResult(std::ostream& out) const 973 { MultidegreeMap::const_iterator pos; 974 out << ourVarName4 << " := [];"; 975 for (pos= (*myOutMdMpPtr).begin(); pos!=(*myOutMdMpPtr).end();++pos) 976 { 977 out<< "Append(" << ourVarName4<< ", ["<<pos->first; 978 out<<",["; 979 ListOfDims::const_iterator inner_pos; 980 for (inner_pos= (pos->second).begin(); inner_pos!=(pos->second).end();++inner_pos) 981 { 982 out<<"["<<inner_pos->first; 983 list<position_t>::const_iterator my_pos; 984 out<<",["; 985 for (my_pos= (inner_pos->second).begin(); my_pos!=(inner_pos->second).end();++my_pos) 986 { 987 ++my_pos; 988 if(my_pos==(inner_pos->second).end()) 989 {--my_pos; out<<*my_pos;} 990 else 991 {--my_pos; out<<*my_pos<<",";} 992 } 993 ++inner_pos; 994 if(inner_pos==(pos->second).end()) 995 {--inner_pos;out<<"]]";} 996 else 997 {--inner_pos; out<<"]],";} 998 } 999 out<<"]"; 1000 out<< "]);" <<endl; 1001 } 1002 } 1003 1004 // void PrintMultidegreeMap(const MultidegreeMap& myMap) 1005 // { 1006 // MultidegreeMap::const_iterator pos; 1007 // 1008 // } 1009 1010 class MVTN1: public ServerOpBase 1011 { 1012 public: MVTN1()1013 MVTN1(): ServerOpBase(CoCoALib_combinatorics()) {}; ~MVTN1()1014 ~MVTN1() {}; myOutputSelf(std::ostream & out)1015 void myOutputSelf(std::ostream& out) const { out << "MVT_N-1"; } 1016 void myReadArgs(std::istream& in, int NumArgs); myCompute()1017 void myCompute() { MayerVietorisTreeN1(*myOutPPsPtr, *myInPPsPtr); } 1018 void myWriteResult(std::ostream& out) const; myClear()1019 void myClear() { myInPPsPtr.reset(); myOutPPsPtr.reset(); } 1020 private: 1021 unique_ptr<PPVector> myInPPsPtr, myOutPPsPtr; 1022 }; 1023 1024 myReadArgs(std::istream & in,int NumArgs)1025 void MVTN1::myReadArgs(std::istream& in, int NumArgs) 1026 { 1027 CoCoA_ASSERT(NumArgs == 2); // ring and PPList 1028 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 1029 PPMonoid PPM = NewPPMonoidEv(SymbolRange("x", 0, NumIndets(P)-1), lex); 1030 vector<PPMonoidElem> V; 1031 ReadPPs(in, V, PPM, GetTag); 1032 DivMaskRule DMR = NewDivMaskEvenPowers(); 1033 vector<long> exps(NumIndets(PPM)); 1034 myInPPsPtr.reset(new PPVector(PPM, DMR)); 1035 myOutPPsPtr.reset(new PPVector(PPM, DMR)); 1036 1037 for (long i=0; i < len(V); ++i) 1038 { 1039 exponents(exps, V[i]); 1040 // anna: should find a way to avoid making copies the pps 1041 myInPPsPtr->myPushBack(PPMonoidElem(PPM,exps)); 1042 } 1043 // GlobalOutput() << "Print " << myInPPsPtr->mySize() << ";"; 1044 } 1045 1046 myWriteResult(std::ostream & out)1047 void MVTN1::myWriteResult(std::ostream& out) const 1048 { 1049 out << ourVarName4 << " := [];"; 1050 for (long i=0; i < len(*myOutPPsPtr); ++i) 1051 out<< "Append(" << ourVarName4<< ", "<< PP((*myOutPPsPtr)[i]) << ");" <<endl; 1052 } 1053 1054 1055 class MVTReg: public ServerOpBase 1056 { 1057 public: MVTReg()1058 MVTReg(): ServerOpBase(CoCoALib_combinatorics()) {}; ~MVTReg()1059 ~MVTReg() {}; myOutputSelf(std::ostream & out)1060 void myOutputSelf(std::ostream& out) const { out << "MVT_Reg"; } 1061 void myReadArgs(std::istream& in, int NumArgs); myCompute()1062 void myCompute() { myOutReg = MVTRegularity(*myInPPV); } myWriteResult(std::ostream & out)1063 void myWriteResult(std::ostream& out) const { out << ourVarName4 << " := " << myOutReg << ";" << endl; } myClear()1064 void myClear() { myInPPV.reset(); } 1065 private: 1066 unique_ptr<PPVector> myInPPV; 1067 int myOutReg; 1068 }; 1069 myReadArgs(std::istream & in,int NumArgs)1070 void MVTReg::myReadArgs(std::istream& in, int NumArgs) 1071 { 1072 CoCoA_ASSERT(NumArgs == 2); // ring and PPList 1073 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 1074 PPMonoid PPM = NewPPMonoidEv(SymbolRange("x", 0, NumIndets(P)-1), lex); 1075 vector<PPMonoidElem> V; 1076 ReadPPs(in, V, PPM, GetTag); 1077 DivMaskRule DMR = NewDivMaskEvenPowers(); 1078 vector<long> exps(NumIndets(PPM)); 1079 myInPPV.reset(new PPVector(PPM, DMR)); 1080 //myOutPPsPtr.reset(new int); 1081 1082 for (long i=0; i<len(V); ++i) 1083 { 1084 exponents(exps, V[i]); 1085 // anna: should find a way to avoid making copies the pps 1086 myInPPV->myPushBack(PPMonoidElem(PPM,exps)); 1087 } 1088 // GlobalOutput() << "Print " << myInPPsPtr->mySize() << ";"; 1089 } 1090 1091 class MVTRegUB: public ServerOpBase 1092 { 1093 public: MVTRegUB()1094 MVTRegUB(): ServerOpBase(CoCoALib_combinatorics()) {}; ~MVTRegUB()1095 ~MVTRegUB() {}; myOutputSelf(std::ostream & out)1096 void myOutputSelf(std::ostream& out) const { out << "MVT_Reg_Upper_Bound"; } 1097 void myReadArgs(std::istream& in, int NumArgs); myCompute()1098 void myCompute() { myOutReg = MVTRegularityUpperBound(*myInPPV); } myWriteResult(std::ostream & out)1099 void myWriteResult(std::ostream& out) const { out << ourVarName4 << " := " << myOutReg << ";" << endl; } myClear()1100 void myClear() { myInPPV.reset(); } 1101 private: 1102 unique_ptr<PPVector> myInPPV; 1103 int myOutReg; 1104 }; 1105 myReadArgs(std::istream & in,int NumArgs)1106 void MVTRegUB::myReadArgs(std::istream& in, int NumArgs) 1107 { 1108 CoCoA_ASSERT(NumArgs == 2); // ring and PPList 1109 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 1110 PPMonoid PPM = NewPPMonoidEv(SymbolRange("x", 0, NumIndets(P)-1), lex); 1111 vector<PPMonoidElem> V; 1112 ReadPPs(in, V, PPM, GetTag); 1113 DivMaskRule DMR = NewDivMaskEvenPowers(); 1114 vector<long> exps(NumIndets(PPM)); 1115 myInPPV.reset(new PPVector(PPM, DMR)); 1116 //myOutPPsPtr.reset(new int); 1117 1118 for (long i=0; i<len(V); ++i) 1119 { 1120 exponents(exps, V[i]); 1121 // anna: should find a way to avoid making copies the pps 1122 myInPPV->myPushBack(PPMonoidElem(PPM,exps)); 1123 } 1124 // GlobalOutput() << "Print " << myInPPsPtr->mySize() << ";"; 1125 } 1126 1127 class MVTRegLB: public ServerOpBase 1128 { 1129 public: MVTRegLB()1130 MVTRegLB(): ServerOpBase(CoCoALib_combinatorics()) {}; ~MVTRegLB()1131 ~MVTRegLB() {}; myOutputSelf(std::ostream & out)1132 void myOutputSelf(std::ostream& out) const { out << "MVT_Reg_Lower_Bound"; } 1133 void myReadArgs(std::istream& in, int NumArgs); myCompute()1134 void myCompute() { myOutReg = MVTRegularityLowerBound(*myInPPV); } myWriteResult(std::ostream & out)1135 void myWriteResult(std::ostream& out) const { out << ourVarName4 << " := " << myOutReg << ";" << endl; } myClear()1136 void myClear() { myInPPV.reset(); } 1137 private: 1138 unique_ptr<PPVector> myInPPV; 1139 int myOutReg; 1140 }; 1141 myReadArgs(std::istream & in,int NumArgs)1142 void MVTRegLB::myReadArgs(std::istream& in, int NumArgs) 1143 { 1144 CoCoA_ASSERT(NumArgs == 2); // ring and PPList 1145 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 1146 PPMonoid PPM = NewPPMonoidEv(SymbolRange("x", 0, NumIndets(P)-1), lex); 1147 vector<PPMonoidElem> V; 1148 ReadPPs(in, V, PPM, GetTag); 1149 DivMaskRule DMR = NewDivMaskEvenPowers(); 1150 vector<long> exps(NumIndets(PPM)); 1151 myInPPV.reset(new PPVector(PPM, DMR)); 1152 //myOutPPsPtr.reset(new int); 1153 1154 for (long i=0; i<len(V); ++i) 1155 { 1156 exponents(exps, V[i]); 1157 // anna: should find a way to avoid making copies the pps 1158 myInPPV->myPushBack(PPMonoidElem(PPM,exps)); 1159 } 1160 // GlobalOutput() << "Print " << myInPPsPtr->mySize() << ";"; 1161 } 1162 1163 1164 class MVTProjDimension: public ServerOpBase 1165 { 1166 public: MVTProjDimension()1167 MVTProjDimension(): ServerOpBase(CoCoALib_combinatorics()) {}; ~MVTProjDimension()1168 ~MVTProjDimension() {}; myOutputSelf(std::ostream & out)1169 void myOutputSelf(std::ostream& out) const { out << "MVTProjDimension"; } 1170 void myReadArgs(std::istream& in, int NumArgs); myCompute()1171 void myCompute() { myOutProjDim = MVTProjDim(*myInPPV); } myWriteResult(std::ostream & out)1172 void myWriteResult(std::ostream& out) const { out << ourVarName4 << " := " << myOutProjDim << ";" << endl; } myClear()1173 void myClear() { myInPPV.reset(); } 1174 private: 1175 unique_ptr<PPVector> myInPPV; 1176 int myOutProjDim; 1177 }; 1178 myReadArgs(std::istream & in,int NumArgs)1179 void MVTProjDimension::myReadArgs(std::istream& in, int NumArgs) 1180 { 1181 CoCoA_ASSERT(NumArgs == 2); // ring and PPList 1182 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 1183 PPMonoid PPM = NewPPMonoidEv(SymbolRange("x", 0, NumIndets(P)-1), lex); 1184 vector<PPMonoidElem> V; 1185 ReadPPs(in, V, PPM, GetTag); 1186 DivMaskRule DMR = NewDivMaskEvenPowers(); 1187 vector<long> exps(NumIndets(PPM)); 1188 myInPPV.reset(new PPVector(PPM, DMR)); 1189 //myOutPPsPtr.reset(new int); 1190 1191 for (long i=0; i<len(V); ++i) 1192 { 1193 exponents(exps, V[i]); 1194 // anna: should find a way to avoid making copies the pps 1195 myInPPV->myPushBack(PPMonoidElem(PPM,exps)); 1196 } 1197 // GlobalOutput() << "Print " << myInPPsPtr->mySize() << ";"; 1198 } 1199 1200 1201 1202 class MVTProjDimUB: public ServerOpBase 1203 { 1204 public: MVTProjDimUB()1205 MVTProjDimUB(): ServerOpBase(CoCoALib_combinatorics()) {}; ~MVTProjDimUB()1206 ~MVTProjDimUB() {}; myOutputSelf(std::ostream & out)1207 void myOutputSelf(std::ostream& out) const { out << "MVT_ProjDim_Upper_Bound"; } 1208 void myReadArgs(std::istream& in, int NumArgs); myCompute()1209 void myCompute() { myOutProjDim = MVTProjDimUpperBound(*myInPPV); } myWriteResult(std::ostream & out)1210 void myWriteResult(std::ostream& out) const { out << ourVarName4 << " := " << myOutProjDim << ";" << endl; } myClear()1211 void myClear() { myInPPV.reset(); } 1212 private: 1213 unique_ptr<PPVector> myInPPV; 1214 int myOutProjDim; 1215 }; 1216 myReadArgs(std::istream & in,int NumArgs)1217 void MVTProjDimUB::myReadArgs(std::istream& in, int NumArgs) 1218 { 1219 CoCoA_ASSERT(NumArgs == 2); // ring and PPList 1220 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 1221 PPMonoid PPM = NewPPMonoidEv(SymbolRange("x", 0, NumIndets(P)-1), lex); 1222 vector<PPMonoidElem> V; 1223 ReadPPs(in, V, PPM, GetTag); 1224 DivMaskRule DMR = NewDivMaskEvenPowers(); 1225 vector<long> exps(NumIndets(PPM)); 1226 myInPPV.reset(new PPVector(PPM, DMR)); 1227 //myOutPPsPtr.reset(new int); 1228 1229 for (long i=0 ; i<len(V); ++i) 1230 { 1231 exponents(exps, V[i]); 1232 // anna: should find a way to avoid making copies the pps 1233 myInPPV->myPushBack(PPMonoidElem(PPM,exps)); 1234 } 1235 // GlobalOutput() << "Print " << myInPPsPtr->mySize() << ";"; 1236 } 1237 1238 1239 class MVTProjDimLB: public ServerOpBase 1240 { 1241 public: MVTProjDimLB()1242 MVTProjDimLB(): ServerOpBase(CoCoALib_combinatorics()) {}; ~MVTProjDimLB()1243 ~MVTProjDimLB() {}; myOutputSelf(std::ostream & out)1244 void myOutputSelf(std::ostream& out) const { out << "MVT_ProjDim_Lower_Bound"; } 1245 void myReadArgs(std::istream& in, int NumArgs); myCompute()1246 void myCompute() { myOutProjDim = MVTProjDimLowerBound(*myInPPV); } myWriteResult(std::ostream & out)1247 void myWriteResult(std::ostream& out) const { out << ourVarName4 << " := " << myOutProjDim << ";" << endl; } myClear()1248 void myClear() { myInPPV.reset(); } 1249 private: 1250 unique_ptr<PPVector> myInPPV; 1251 int myOutProjDim; 1252 }; 1253 myReadArgs(std::istream & in,int NumArgs)1254 void MVTProjDimLB::myReadArgs(std::istream& in, int NumArgs) 1255 { 1256 CoCoA_ASSERT(NumArgs == 2); // ring and PPList 1257 const SparsePolyRing P(ReadPolyRing(in, GetTag)); 1258 PPMonoid PPM = NewPPMonoidEv(SymbolRange("x", 0, NumIndets(P)-1), lex); 1259 vector<PPMonoidElem> V; 1260 ReadPPs(in, V, PPM, GetTag); 1261 DivMaskRule DMR = NewDivMaskEvenPowers(); 1262 vector<long> exps(NumIndets(PPM)); 1263 myInPPV.reset(new PPVector(PPM, DMR)); 1264 //myOutPPsPtr.reset(new int); 1265 1266 for (long i=0 ; i<len(V); ++i) 1267 { 1268 exponents(exps, V[i]); 1269 // anna: should find a way to avoid making copies the pps 1270 myInPPV->myPushBack(PPMonoidElem(PPM,exps)); 1271 } 1272 // GlobalOutput() << "Print " << myInPPsPtr->mySize() << ";"; 1273 } 1274 1275 1276 // namespace 1277 // { 1278 // class IdealOperationRegistrationClass 1279 // { 1280 // public: 1281 // IdealOperationRegistrationClass() 1282 // { 1283 // } 1284 // } FakeVariable1; 1285 // } 1286 1287 1288 1289 namespace CoCoAServerOperationsFromCoCoALib 1290 { RegisterOps()1291 bool RegisterOps() 1292 { 1293 // RegisterOp("TestSocket", ServerOp(new TestSocket())); 1294 // ideal 1295 RegisterOp("F5", ServerOp(new F5GBasis())); 1296 RegisterOp("ideal_LT", ServerOp(new IdealLT())); 1297 RegisterOp("ideal_colon_ideal", ServerOp(new ColonIdId())); 1298 RegisterOp("ideal_elim", ServerOp(new IdealElim())); 1299 RegisterOp("ideal_groebner", ServerOp(new IdealGBasis())); 1300 RegisterOp("ideal_sat_groebner", ServerOp(new IdealSATGBasis())); 1301 //RegisterOp("ideal_satmix_groebner", ServerOp(new IdealSATMixGBasis())); 1302 RegisterOp("ideal_homogenization", ServerOp(new IdealHomog())); 1303 RegisterOp("ideal_intersection", ServerOp(new IdealIntersection())); 1304 RegisterOp("ideal_saturation", ServerOp(new IdealSaturation())); 1305 RegisterOp("ideal_syzygy", ServerOp(new IdealSyzygy())); 1306 // module 1307 RegisterOp("module_LT", ServerOp(new ModuleLT())); 1308 RegisterOp("module_colon_module", ServerOp(new ColonModMod())); 1309 RegisterOp("module_elim", ServerOp(new ModuleElim())); 1310 RegisterOp("module_groebner", ServerOp(new ModuleGBasis())); 1311 RegisterOp("module_homogenization", ServerOp(new ModuleHomog())); 1312 RegisterOp("module_intersection", ServerOp(new ModuleIntersection())); 1313 RegisterOp("module_saturation", ServerOp(new ModuleSaturation())); 1314 RegisterOp("module_syzygy", ServerOp(new ModuleSyzygy())); 1315 // approx points 1316 RegisterOp("StableBorder", ServerOp(new StableBorder())); 1317 RegisterOp("NumBMBorder", ServerOp(new NumBMBorder())); 1318 RegisterOp("PreprocessAggr", ServerOp(new PreprocessAggr())); 1319 RegisterOp("PreprocessGrid", ServerOp(new PreprocessGrid())); 1320 RegisterOp("PreprocessSubdiv", ServerOp(new PreprocessSubdiv())); 1321 // IsTree 1322 RegisterOp("IsTree_NoOpt", ServerOp(new IsTreeNoOpt())); 1323 RegisterOp("IsTree_Opt", ServerOp(new IsTreeOpt())); 1324 RegisterOp("IsTree_CBOpt", ServerOp(new IsTreeCBOpt())); 1325 RegisterOp("IsTree_CBNoOpt", ServerOp(new IsTreeCBNoOpt())); 1326 // Mayer Vietoris Trees 1327 RegisterOp("Mayer_Vietoris_Tree", ServerOp(new MVT())); 1328 RegisterOp("MVT_N_minus_one", ServerOp(new MVTN1())); 1329 RegisterOp("MVT_Regularity", ServerOp(new MVTReg())); 1330 RegisterOp("MVT_Regularity_Upper_Bound", ServerOp(new MVTRegUB())); 1331 RegisterOp("MVT_Regularity_Lower_Bound", ServerOp(new MVTRegLB())); 1332 RegisterOp("MVT_ProjDim", ServerOp(new MVTProjDimension())); 1333 RegisterOp("MVT_ProjDim_Upper_Bound", ServerOp(new MVTProjDimUB())); 1334 RegisterOp("MVT_ProjDim_Lower_Bound", ServerOp(new MVTProjDimLB())); 1335 return true; 1336 } 1337 1338 RegisterOpsOnce()1339 bool RegisterOpsOnce() 1340 { 1341 static bool EvalOnce = RegisterOps(); 1342 return EvalOnce; 1343 } 1344 } 1345 1346 1347 } 1348 1349 // $Header: /Volumes/Home_1/cocoa/cvs-repository/CoCoALib-0.99/src/server/RegisterServerOps.C,v 1.16 2020/06/17 15:49:31 abbott Exp $ 1350 // $Log: RegisterServerOps.C,v $ 1351 // Revision 1.16 2020/06/17 15:49:31 abbott 1352 // Summary: Changed CoCoA_ERROR into CoCoA_THROW_ERROR 1353 // 1354 // Revision 1.15 2019/03/20 16:20:54 bigatti 1355 // -- updates for the new server 1356 // 1357 // Revision 1.14 2019/03/19 11:05:02 abbott 1358 // Summary: In StableBorder replaced data mem myPolyRing by myPolyRingPtr (o/w tries to create ring before GlobalManager exists) 1359 // 1360 // Revision 1.13 2019/03/04 11:37:14 abbott 1361 // Summary: Changed auto_ptr into unique_ptr 1362 // 1363 // Revision 1.12 2017/11/28 13:27:30 bigatti 1364 // -- fixed IdealSATGBasis 1365 // -- commented out IdealSATMixGBasis 1366 // 1367 // Revision 1.11 2017/11/10 16:02:27 abbott 1368 // Summary: Removed NewLexOrdering, NewStdDegLexOrdering, NewStdDegRevLexOrdering; consequential changes 1369 // 1370 // Revision 1.10 2017/04/18 16:23:20 bigatti 1371 // -- removed use of stats level (to be replaced by VerbosityLevel) 1372 // 1373 // Revision 1.9 2017/04/07 20:06:41 abbott 1374 // Summary: Hacked to make it compile (added member myPolyRing); no idea if it works!!! 1375 // 1376 // Revision 1.8 2015/12/04 15:22:24 bigatti 1377 // -- renamed ComputeSSaturation into ComputeSaturation 1378 // 1379 // Revision 1.7 2015/05/20 13:27:08 bigatti 1380 // -- ComputeCColon --> ComputeColon 1381 // 1382 // Revision 1.6 2014/07/30 15:07:13 abbott 1383 // Summary: Changed BaseRing into RingOf 1384 // Author: JAA 1385 // 1386 // Revision 1.5 2014/07/08 09:18:04 abbott 1387 // Summary: Removed AsSparsePolyRing 1388 // Author: JAA 1389 // 1390 // Revision 1.4 2014/05/15 12:31:34 abbott 1391 // Summary: Now using new files server/GlobalIO.HC (previously in CoCoA/io.H) 1392 // Author: JAA 1393 // 1394 // Revision 1.3 2014/03/26 16:53:38 bigatti 1395 // -- added unused arg in GBasis 1396 // 1397 // Revision 1.2 2013/06/12 08:55:48 bigatti 1398 // -- added unused arg (in ComputeGBasis) 1399 // 1400 // Revision 1.1 2013/05/27 12:57:39 abbott 1401 // Moved all server-related code into src/server/ 1402 // 1403 // Revision 1.46 2013/03/27 18:24:33 abbott 1404 // Added approx point preprocessing to C5; also changed names of the fns, and updated doc. 1405 // 1406 // Revision 1.45 2013/02/21 17:15:06 bigatti 1407 // -- changes syntax for ComputeSyz 1408 // 1409 // Revision 1.44 2012/10/02 10:36:12 abbott 1410 // Revised interface to BuildInfo information strings. 1411 // Several consequential changes. 1412 // 1413 // Revision 1.43 2012/02/08 17:09:42 bigatti 1414 // -- changed: Z,Q -> ZZ,QQ 1415 // 1416 // Revision 1.42 2011/03/11 11:05:24 bigatti 1417 // -- changed size_t --> long 1418 // -- changed size --> len 1419 // 1420 // Revision 1.41 2011/03/10 16:39:34 abbott 1421 // Replaced (very many) size_t by long in function interfaces (for rings, 1422 // PPMonoids and modules). Also replaced most size_t inside fn defns. 1423 // 1424 // Revision 1.40 2010/09/15 21:24:04 abbott 1425 // Corrected assertion for number of args to StableBorder. 1426 // 1427 // Revision 1.39 2010/02/03 18:05:15 bigatti 1428 // -- minor fix 1429 // 1430 // Revision 1.38 2010/02/03 17:04:53 bigatti 1431 // -- first use of "lex" in definition of PPMonoidEv 1432 // -- added commented out code for TestSocket (wip) 1433 // 1434 // Revision 1.37 2009/11/03 17:50:16 bigatti 1435 // -- added MVTProjDim functions by Eduardo Saenz-de-Cabezon 1436 // -- code cleaning 1437 // 1438 // Revision 1.36 2009/11/03 14:57:46 abbott 1439 // Inserted some space to improve code readability. 1440 // Replaced several endls with '\n' to avoid needless flushing, 1441 // and removed some << operators between string literals. 1442 // 1443 // Revision 1.35 2009/10/28 16:09:09 bigatti 1444 // -- modified class name MVTProjDim into MVTProjDimension to avoid name clashing 1445 // 1446 // Revision 1.34 2009/10/28 14:46:37 bigatti 1447 // -- new MVT functions by Eduardo Saenz-de-Cabezon 1448 // 1449 // Revision 1.33 2009/10/27 13:06:12 bigatti 1450 // -- just a "\n" 1451 // 1452 // Revision 1.32 2009/10/26 17:21:27 bigatti 1453 // -- trying to avoid sending small strings to sockets... 1454 // 1455 // Revision 1.31 2009/09/24 15:23:01 abbott 1456 // Added some missing using commands. 1457 // 1458 // Revision 1.30 2009/09/24 14:46:06 abbott 1459 // Removed some unnecessary "std::" prefixes. 1460 // Changed two "unsigned int" into "size_t". 1461 // 1462 // Revision 1.29 2009/07/30 15:46:19 bigatti 1463 // -- IdealLT::myWriteResult using new ideal ctor 1464 // 1465 // Revision 1.28 2009/07/24 14:48:03 abbott 1466 // Corrected an assertion about number of args (for NBM). 1467 // 1468 // Revision 1.27 2009/07/06 12:32:33 abbott 1469 // Removed some useless consts on return type for myAlgName 1470 // (should keep the compiler quiet in debugging mode). 1471 // 1472 // Revision 1.26 2009/04/23 15:20:48 bigatti 1473 // -- changed "=" into ":=" for Records 1474 // -- fixed LT5(Ideal(x)) (WriteIdeal looks at item [0], was [1]) 1475 // -- fixed number of arg for approx functions 1476 // 1477 // Revision 1.25 2009/01/26 15:57:48 bigatti 1478 // -- added "const" to libraries 1479 // -- first use of WriteIdeal 1480 // 1481 // Revision 1.24 2009/01/08 13:11:08 bigatti 1482 // -- fixed MVTN1 bug (myOutPPsPtr is now initialized in myReadArgs) 1483 // 1484 // Revision 1.23 2008/11/24 17:11:12 abbott 1485 // Final tidying of code for preprocessing and SOI/NBM. 1486 // 1487 // Revision 1.22 2008/11/23 18:58:32 abbott 1488 // Major overhaul to preprocessing and SOI/NBM code. 1489 // Split SOI/NBM off into a separate file. 1490 // Preprocessing is now "rational" (but internally guided by C++ doubles). 1491 // SOI/NBM now each have 3 similar interfaces: one purely rational, one for 1492 // input which is represented as doubles, and one which converts the input 1493 // to RingTwinFloat values and produces a result which is over some RingTwinFloat 1494 // (the precision is increased automatically until an answer is obtained). 1495 // 1496 // Revision 1.21 2008/11/21 21:17:35 abbott 1497 // Added 3 new "rational" preprocessing algms. 1498 // 1499 // Revision 1.20 2008/11/20 09:58:53 abbott 1500 // Cleaned up code for Preprocessing: introduced another base class. 1501 // Change the way it sends results to CoCoA4 -- sends both points and weights. 1502 // 1503 // Revision 1.19 2008/11/13 12:13:17 bigatti 1504 // -- NumArgs is now used in every myReadArgs, but usually just a dumb check 1505 // 1506 // Revision 1.18 2008/09/22 16:42:48 bigatti 1507 // -- small fix 1508 // 1509 // Revision 1.17 2008/09/22 16:07:02 bigatti 1510 // -- tested (and fixed) communication with cocoa-4 (number of arguments 1511 // passed to myReadArgs ) 1512 // 1513 // Revision 1.16 2008/09/19 12:20:22 bigatti 1514 // -- fix call to SatGB 1515 // 1516 // Revision 1.15 2008/09/19 11:41:23 bigatti 1517 // -- first fix for new mechanism for passing verbosity 1518 // 1519 // Revision 1.14 2008/09/19 11:34:15 bigatti 1520 // -- new mechanism for passing verbosity level (or StatLevel) 1521 // [only partially tested] 1522 // 1523 // Revision 1.13 2008/09/12 13:28:43 bigatti 1524 // -- new: NBM implementation 1525 // 1526 // Revision 1.12 2008/07/04 09:11:04 bigatti 1527 // -- new PPVector class 1528 // 1529 // Revision 1.11 2008/06/04 18:27:37 abbott 1530 // Modified the server interface for "SOI": it now accepts a 3rd arg (gamma). 1531 // 1532 // Revision 1.10 2008/05/30 14:20:43 abbott 1533 // SOI now returns also the "almost vanishing" polynomials. 1534 // 1535 // Revision 1.9 2008/05/29 15:46:29 bigatti 1536 // -- added Approximate Border Basis (by Abbott,Torrente) 1537 // 1538 // Revision 1.8 2008/05/28 16:21:05 bigatti 1539 // -- using the new function ReadPPs fom MVTN1 1540 // 1541 // Revision 1.7 2008/05/27 16:22:04 bigatti 1542 // -- added MayerVietorisTreeN1 1543 // 1544 // Revision 1.6 2008/04/18 15:35:57 abbott 1545 // (long overdue) Major revision to matrices 1546 // 1547 // Revision 1.5 2007/11/09 10:45:52 bigatti 1548 // -- [caboara] preparation for self-saturating algorithm 1549 // 1550 // Revision 1.4 2007/10/30 17:14:07 abbott 1551 // Changed licence from GPL-2 only to GPL-3 or later. 1552 // New version for such an important change. 1553 // 1554 // Revision 1.3 2007/09/25 16:32:30 abbott 1555 // Several minor changes to silence gcc-4.3: 1556 // more #includes, 1557 // and fixed a template problemm in RegisterServerOps.C 1558 // 1559 // Revision 1.2 2007/09/25 16:28:31 bigatti 1560 // -- ServerOp includes infos about the library it is defined in 1561 // -- CoCoAServer no longer prints its own version 1562 // -- CoCoAServer prints all offered operations 1563 // -- CoCoAServer can change stat_level (Max's verbosity) at runtime 1564 // 1565 // Revision 1.1 2007/04/27 14:54:22 bigatti 1566 // -- content of CoCoAServer.C split into dedicated files 1567 // -- new registration mechanism (through include "RegisterServerOps.H") 1568 // 1569