Borderbasix

macaulay.hpp
Go to the documentation of this file.
1 #include<vector>
2 
3 #if 0
4 long long binom(int n, int m)
5 //C_m^n
6 {
7  long long res=1;
8  if(n>m || m<0 || n<0)
9  return 0;
10  for(int i=m;i>m-n;i--)
11  res*=i;
12  for(int i=1;i<=n;i++)
13  res/=i;
14  return res;
15 }
16 #endif
17 
18 QQ binom(int n, int m)
19 //C_m^n
20 {
21  QQ res=1;
22  if(n>m || m<0 || n<0)
23  return 0;
24  for(int i=m;i>m-n;i--)
25  res*=i;
26  for(QQ i=1;i<=n;i+=1)
27  res/=i;
28  return res;
29 }
30 
31 
32 void Macaulay_dec(std::vector<int> &coeff_mac, int k, int dim)
33 {
34  QQ mydim=dim;
35  for(int kk=k;kk>0;kk--)
36  {
37  int tmp;
38  for(tmp=kk;binom(kk,tmp)<=mydim;tmp++);
39  tmp--;
40  mydim-=binom(kk,tmp);
41  coeff_mac.push_back(tmp);
42  }
43 }
44 
45 long nextdim(std::vector<int> &coeff_mac, int k)
46 {
47  QQ res=0;
48  for(std::vector<int>::iterator iter=coeff_mac.begin();
49  iter!=coeff_mac.end();iter++)
50  res+=binom(k--+1,*iter+1);
51  int tmpres=0;
52  for(tmpres=0;res>tmpres;tmpres++);
53  return tmpres;
54 }
long nextdim(std::vector< int > &coeff_mac, int k)
Definition: macaulay.hpp:45
MSKint32t MSKCONST MSKint32t * dim
Definition: mosek.h:2407
MSKint32t k
Definition: mosek.h:2713
QQ binom(int n, int m)
Definition: macaulay.hpp:18
Definition: Scl.hpp:26
MSKint32t MSKint32t MSKint32t i
Definition: mosek.h:2278
void Macaulay_dec(std::vector< int > &coeff_mac, int k, int dim)
Definition: macaulay.hpp:32
Home  |  Download & InstallContributions