1 // Copyright (c) 2016-2018 John Abbott, Anna M. 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 19 #include "CoCoA/library.H" 20 21 #include <string> 22 #include<iostream> 23 using std::endl; 24 25 namespace CoCoA 26 { 27 28 namespace // anonymous for file local fn 29 { 30 // Procedure to give error if obsolescent fns are forbidden, and otherwise print out a warning on CoCoA::LogStream. LogObsolescentFn(const char * const FnName,const char * const UsefulAdvice)31 void LogObsolescentFn(const char* const FnName, const char* const UsefulAdvice) 32 { 33 if (!IsAllowedObsolescentFnCall()) 34 CoCoA_THROW_ERROR(ERR::OBSOLESCENT, FnName + std::string(" -- ") + UsefulAdvice); 35 LogStream() << "WARNING: called obsolescent fn `" << FnName << "' -- " << UsefulAdvice << endl; 36 } 37 38 } // end of namespace anonymous 39 40 41 /////////////////////////////////////////////////////// 42 // The obsolescent fns below are ALWAYS defined. 43 IsRadical(ConstRefPPMonoidElem pp)44 bool IsRadical(ConstRefPPMonoidElem pp) // RENAMED to IsSqFree 45 { 46 LogObsolescentFn("IsRadical(ConstRefPPMonoidElem)", "renamed to IsSqFree"); 47 return IsSqFree(pp); 48 } 49 50 AreGensSquareFreeMonomial(const ideal & I)51 bool AreGensSquareFreeMonomial(const ideal& I) 52 { 53 LogObsolescentFn("AreGensSquareFreeMonomial(ideal)", 54 "renamed to AreGensSqFreeMonomial"); 55 return AreGensSqFreeMonomial(I); 56 } 57 58 NewLexOrdering(const MachineInt & NumIndets)59 PPOrdering NewLexOrdering(const MachineInt& NumIndets) 60 { 61 LogObsolescentFn("NewLexOrdering", "use pseudo-ctor `lex'"); 62 return lex(NumIndets); 63 } 64 NewStdDegLexOrdering(const MachineInt & NumIndets)65 PPOrdering NewStdDegLexOrdering(const MachineInt& NumIndets) 66 { 67 LogObsolescentFn("NewStdDegLexOrdering", "use pseudo-ctor `StdDegLex'"); 68 return StdDegLex(NumIndets); 69 } 70 NewStdDegRevLexOrdering(const MachineInt & NumIndets)71 PPOrdering NewStdDegRevLexOrdering(const MachineInt& NumIndets) 72 { 73 LogObsolescentFn("NewStdDegRevLexOrdering", "use pseudo-ctor `StdDegRevLex'"); 74 return StdDegRevLex(NumIndets); 75 } 76 minimalize(const ideal & I)77 ideal minimalize(const ideal& I) 78 { 79 LogObsolescentFn("minimalize", "use \"IdealOfMinGens\""); 80 return IdealOfMinGens(I); 81 } 82 minimalize(const FGModule & M)83 FGModule minimalize(const FGModule& M) 84 { 85 LogObsolescentFn("minimalize", "use \"SubmoduleOfMinGens\""); 86 return SubmoduleOfMinGens(M); 87 } 88 89 NewPolyRing(const ring & CoeffRing,long NumIndets,const PPOrdering & ord)90 SparsePolyRing NewPolyRing(const ring& CoeffRing, long NumIndets, const PPOrdering& ord) 91 { 92 LogObsolescentFn("NewPolyRing (without symbol names)", "use \"SymbolRange\""); 93 return NewPolyRing(CoeffRing, SymbolRange("x", 0, NumIndets-1), ord); 94 // if (IsRingFp(CoeffRing)) 95 // return NewPolyRing_DMPII(CoeffRing, NumIndets, OrdCtor); 96 // return NewPolyRing_DMPI(CoeffRing, NumIndets, OrdCtor); 97 } 98 NewPolyRing(const ring & CoeffRing,long NumIndets,const PPOrderingCtor & OrdCtor)99 SparsePolyRing NewPolyRing(const ring& CoeffRing, long NumIndets, const PPOrderingCtor& OrdCtor) 100 { 101 LogObsolescentFn("NewPolyRing (without symbol names)", "use \"SymbolRange\""); 102 return NewPolyRing(CoeffRing, SymbolRange("x", 0, NumIndets-1), OrdCtor); 103 // if (IsRingFp(CoeffRing)) 104 // return NewPolyRing_DMPII(CoeffRing, NumIndets, OrdCtor); 105 // return NewPolyRing_DMPI(CoeffRing, NumIndets, OrdCtor); 106 } 107 NewPolyRing(const ring & CoeffRing,long NumIndets)108 SparsePolyRing NewPolyRing(const ring& CoeffRing, long NumIndets) 109 { 110 LogObsolescentFn("NewPolyRing (without symbol names)", "use \"SymbolRange\""); 111 return NewPolyRing(CoeffRing, SymbolRange("x", 0, NumIndets-1), StdDegRevLex); 112 } 113 114 iroot(const MachineInt & n,const MachineInt & r)115 const BigInt iroot(const MachineInt& n, const MachineInt& r) 116 { 117 LogObsolescentFn("iroot", "use \"FloorRoot\""); 118 if (IsNegative(n)) CoCoA_THROW_ERROR("iroot","1st arg must be non-negative"); 119 return FloorRoot(n,r); 120 } 121 iroot(const MachineInt & n,const BigInt & R)122 const BigInt iroot(const MachineInt& n, const BigInt& R) 123 { 124 LogObsolescentFn("iroot", "use \"FloorRoot\""); 125 if (IsNegative(n)) CoCoA_THROW_ERROR("iroot","1st arg must be non-negative"); 126 return FloorRoot(n,R); 127 } 128 iroot(const BigInt & N,const MachineInt & r)129 const BigInt iroot(const BigInt& N, const MachineInt& r) 130 { 131 LogObsolescentFn("iroot", "use \"FloorRoot\""); 132 if (N < 0) CoCoA_THROW_ERROR("iroot","1st arg must be non-negative"); 133 return FloorRoot(N,r); 134 } 135 iroot(const BigInt & N,const BigInt & R)136 const BigInt iroot(const BigInt& N, const BigInt& R) 137 { 138 LogObsolescentFn("iroot", "use \"FloorRoot\""); 139 if (N < 0) CoCoA_THROW_ERROR("iroot","1st arg must be non-negative"); 140 return FloorRoot(N,R); 141 } 142 143 jacobian(const std::vector<RingElem> & polys)144 matrix jacobian(const std::vector<RingElem>& polys) 145 { 146 LogObsolescentFn("jacobian", "use \"JacobianMat\""); 147 return JacobianMat(polys); 148 } 149 jacobian(const std::vector<RingElem> & polys,const std::vector<RingElem> & inds)150 matrix jacobian(const std::vector<RingElem>& polys, const std::vector<RingElem>& inds) 151 { 152 LogObsolescentFn("jacobian", "use \"JacobianMat\""); 153 return JacobianMat(polys,inds); 154 } 155 TensorMat(ConstMatrixView A,ConstMatrixView B)156 matrix TensorMat(ConstMatrixView A, ConstMatrixView B) 157 { 158 LogObsolescentFn("TensorMat", "use \"KroneckerProd\""); 159 return KroneckerProd(A,B); 160 } 161 162 163 } // end of namespace CoCoA 164 165 166 // RCS header/log in the next few lines 167 // $Header: /Volumes/Home_1/cocoa/cvs-repository/CoCoALib-0.99/src/AlgebraicCore/obsolescent.C,v 1.13 2020/06/17 15:49:30 abbott Exp $ 168 // $Log: obsolescent.C,v $ 169 // Revision 1.13 2020/06/17 15:49:30 abbott 170 // Summary: Changed CoCoA_ERROR into CoCoA_THROW_ERROR 171 // 172 // Revision 1.12 2020/05/26 12:06:19 abbott 173 // Summary: Renamed TensorMat to KroneckerProd; doc & tests updated 174 // 175 // Revision 1.11 2019/10/11 19:54:29 abbott 176 // Summary: Renamed jacobian to JacobianMat 177 // 178 // Revision 1.10 2019/09/16 14:36:30 abbott 179 // Summary: NewPolyRing no calls LogObsolescentFn; added iroot & IsExactIroot 180 // 181 // Revision 1.9 2018/10/02 09:45:30 abbott 182 // Summary: Moved pseudo-ctors NewPolyRing(CoeffRing, NumIndets, ...) to obsolescent 183 // 184 // Revision 1.8 2017/11/20 20:38:27 bigatti 185 // -- added minimalized 186 // 187 // Revision 1.7 2017/11/10 16:02:27 abbott 188 // Summary: Removed NewLexOrdering, NewStdDegLexOrdering, NewStdDegRevLexOrdering; consequential changes 189 // 190 // Revision 1.6 2017/03/29 15:40:40 abbott 191 // Summary: Now prints UsefulAdvice in log message 192 // 193 // Revision 1.5 2017/01/25 13:01:44 abbott 194 // Summary: Warning message now output to CoCoA::LogStream (instead of clog) 195 // 196 // Revision 1.4 2016/11/07 14:16:50 bigatti 197 // -- added AreGensSquareFreeMonomial 198 // 199 // Revision 1.3 2016/11/05 16:34:17 abbott 200 // Summary: Put LogObsolescentFn into anon namespace 201 // 202 // Revision 1.2 2016/11/04 20:44:07 abbott 203 // Summary: Cleaned and simplified 204 // 205 // Revision 1.1 2016/11/03 12:29:58 abbott 206 // Summary: Added file for obsolescent fns; also there is a global flag saying whether to give error if calling one. 207 // 208 // 209