Borderbasix

Iszero.hpp
Go to the documentation of this file.
1 #ifndef ALREADY_Iszero
2 #define ALREADY_Iszero
3 
4 #define SEUIL 9.9e-20
5 //#define SEUIL 1e-100
6 #define PHTABS(x) ((x>(typcoeff)0)?x:(typcoeff)(-1)*x)
7 
8 #ifdef MON_PREMIER
9 template<typename T>
10 inline int Iszero(const Z<MON_PREMIER,T> & c);
11 #endif
12 
13 #if 1
14  int Iszero(const Scl<MPQ> &c)
15  {
16  return c==(int)0;
17  }
18 #endif
19 
20 template<typename typcoeff>
21 inline int Iszero(const typcoeff & c)
22 {
23  int res=0;
24  if(PHTABS(c)<(typcoeff)SEUIL)
25  res=1;
26  return res;
27 }
28 
29 template<typename pol>
30 int Ispolzero(const pol & p)
31 {
32  int res=1;
33  for(int i=0;i<p.size;i++)
34  if (!Iszero(p.nf[i])) {res=0;break;}
35  return res;
36 }
37 
38 template<typename typP>
39 //cf corealgo ligne 310
40 void selectnozero(typP & ttmp)
41 {
42  typedef typename typP::value_type polyalp;
43  typP res;
44  for(typename typP::iterator iterttmp=ttmp.begin();iterttmp!=ttmp.end();iterttmp++)
45  {
46  int yes=0;
47  for(typename polyalp::iterator iter=iterttmp->begin();
48  iter!=iterttmp->end();iter++)
49  if(!Iszero(iter->GetCoeff())) yes=1;
50  if (yes)
51  res.push_back(*iterttmp);
52  }
53  ttmp.swap(res);
54  return;
55 }
56 #undef SEUIL
57 #undef PHTABS
58 #endif //ALREADY_Iszero
#define PHTABS(x)
Definition: Iszero.hpp:6
Definition: pol.hpp:6
int Ispolzero(const pol &p)
Definition: Iszero.hpp:30
void selectnozero(typP &ttmp)
Definition: Iszero.hpp:40
Definition: Zp.hpp:19
Definition: Scl.hpp:26
MSKrealt * c
Definition: mosek.h:2678
MSKint32t MSKint32t MSKint32t i
Definition: mosek.h:2278
int Iszero(const Scl< MPQ > &c)
Definition: Iszero.hpp:14
int size
Definition: pol.hpp:10
#define SEUIL
Definition: Iszero.hpp:4
T * nf
Definition: pol.hpp:12
Home  |  Download & InstallContributions