Loading...
Searching...
No Matches
subsets.cc File Reference
`#include "Singular/libsingular.h"`
`#include <vector>`

Go to the source code of this file.

## Functions

static void | s_subset (std::vector< int > &arr, int size, int left, int index, std::vector< int > &l, std::vector< std::vector< int > > &L)
static BOOLEAN | subsets (leftv res, leftv args)
int SI_MOD_INIT | subsets (SModulFunctions *p)

## Function Documentation

## s_subset()

void s_subset | ( | std::vector< int > & | arr,
|  | int | size,
|  | int | left,
|  | int | index,
|  | std::vector< int > & | l,
|  | std::vector< std::vector< int > > & | L )

static

Definition at line 11 of file subsets.cc.

{
if(left==0)
{
L.push_back(l);
return;
}
for(int i=index; i<size;i++)
{
l.push_back(arr[i]);
s_subset(arr,size,left-1,i+1,l,L);
l.pop_back();
}
}
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
index
static int index(p_Length length, p_Ord ord)
Definition p_Procs_Impl.h:592
s_subset
static void s_subset(std::vector< int > &arr, int size, int left, int index, std::vector< int > &l, std::vector< std::vector< int > > &L)
Definition subsets.cc:11

## subsets() [1/2]

BOOLEAN subsets | ( | leftv | res,
|  | leftv | args )

static

Definition at line 32 of file subsets.cc.

{
leftv u = args;
if ((u!=NULL) && (u->Typ()==INT_CMD))
{
leftv v = u->next;
if ((v!=NULL) && (v->Typ()==INT_CMD) && (v->next==NULL))
{
int n = (int)(long) u->Data();
int k = (int)(long) v->Data();
std::vector<int> array(n);
for (int i=0; i<n; i++)
array[i]=i+1;
std::vector<int> ltemp;
std::vector<std::vector<int> > lt;
s_subset(array,n,k,0,ltemp,lt);
lists Lt = (lists) omAllocBin(slists_bin);
Lt->Init(lt.size());
for (unsigned i=0; i<lt.size(); i++)
{
std::vector<int> lti = lt[i];
lists Lti = (lists) omAllocBin(slists_bin);
Lti->Init(k);
for(unsigned j=0; j<lti.size(); j++)
{
Lti->m[j].rtyp = INT_CMD;
Lti->m[j].data = (void*)(long)lti[j];
}
Lt->m[i].rtyp = LIST_CMD;
Lt->m[i].data = (void*) Lti;
}
res->rtyp = LIST_CMD;
res->data = (void*) Lt;
return FALSE;
}
}
WerrorS("subsets: unexpected parameter");
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
k
int k
Definition cfEzgcd.cc:99
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
sleftv::rtyp
int rtyp
Definition subexpr.h:91
sleftv::Data
void * Data()
Definition subexpr.cc:1192
sleftv::next
leftv next
Definition subexpr.h:86
sleftv::data
void * data
Definition subexpr.h:88
slists::m
sleftv * m
Definition lists.h:46
slists::Init
INLINE_THIS void Init(int l=0)
res
CanonicalForm res
Definition facAbsFact.cc:60
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
j
int j
Definition facHensel.cc:110
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
slists_bin
VAR omBin slists_bin
Definition lists.cc:23
lists
slists * lists
Definition mpr_numeric.h:146
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
NULL
#define NULL
Definition omList.c:12
leftv
sleftv * leftv
Definition structs.h:53
LIST_CMD
@ LIST_CMD
Definition tok.h:118
INT_CMD
@ INT_CMD
Definition tok.h:96

## subsets() [2/2]

int SI_MOD_INIT subsets | ( | SModulFunctions * | p | ) |

Definition at line 76 of file subsets.cc.

{
p->iiAddCproc("subsets.so","subsets",FALSE,subsets);
return (MAX_TOK);
}
p
int p
Definition cfModGcd.cc:4086
subsets
static BOOLEAN subsets(leftv res, leftv args)
Definition subsets.cc:32
MAX_TOK
@ MAX_TOK
Definition tok.h:220