Loading...
Searching...
No Matches
lists.cc File Reference
`#include "kernel/mod2.h"`
`#include "Singular/tok.h"`
`#include "kernel/polys.h"`
`#include "kernel/ideals.h"`
`#include "Singular/attrib.h"`
`#include "Singular/ipshell.h"`
`#include "misc/intvec.h"`
`#include "Singular/lists.h"`

Go to the source code of this file.

## Macros

#define | LISTS_CC

## Functions

int | lSize (lists L)
lists | lCopy (lists L)
BOOLEAN | lAdd (leftv res, leftv u, leftv v)
lists | lInsert0 (lists ul, leftv v, int pos)
BOOLEAN | lInsert (leftv res, leftv u, leftv v)
BOOLEAN | lInsert3 (leftv res, leftv u, leftv v, leftv w)
BOOLEAN | lAppend (leftv res, leftv u, leftv v)
BOOLEAN | lDelete (leftv res, leftv u, leftv v)
BOOLEAN | lDeleteIV (leftv res, leftv u, leftv v)
BOOLEAN | lRingDependend (lists L)
lists | liMakeResolv (resolvente r, int length, int reallen, int typ0, intvec **weights, int add_row_shift)
resolvente | liFindRes (lists L, int *len, int *typ0, intvec ***weights)
char * | lString (lists l, BOOLEAN typed, int dim)

## Variables

VAR omBin | slists_bin = omGetSpecBin(sizeof(slists))

## Macro Definition Documentation

## LISTS_CC

#define LISTS_CC

Definition at line 8 of file lists.cc.

## Function Documentation

## lAdd()

BOOLEAN lAdd | ( | leftv | res,
|  | leftv | u,
|  | leftv | v )

Definition at line 51 of file lists.cc.

{
lists l=(lists) omAllocBin(slists_bin);
lists ul=(lists)u->CopyD();
lists vl=(lists)v->CopyD();
l->Init(ul->nr+vl->nr+2);
int i;
for(i=0;i<=ul->nr;i++)
{
//Print("u[%d]->r[%d]\n",i,i);
l->m[i].rtyp=ul->m[i].rtyp;
l->m[i].data=ul->m[i].data;
}
for(i=0;i<=vl->nr;i++)
{
//Print("v[%d]->r[%d]\n",i,i+ul->nr+1);
l->m[i+ul->nr+1].rtyp=vl->m[i].rtyp;
l->m[i+ul->nr+1].data=vl->m[i].data;
}
if (ul->m != NULL)
omFreeSize((ADDRESS)ul->m,(ul->nr+1)*sizeof(sleftv));
omFreeBin((ADDRESS)ul, slists_bin);
if (vl->m != NULL)
omFreeSize((ADDRESS)vl->m,(vl->nr+1)*sizeof(sleftv));
omFreeBin((ADDRESS)vl, slists_bin);
memset(u,0,sizeof(*u));
memset(v,0,sizeof(*v));
res->data = (char *)l;
//res->Print();
return FALSE;
}
FALSE
#define FALSE
Definition auxiliary.h:97
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
sleftv
Class used for (list of) interpreter objects.
Definition subexpr.h:83
sleftv::CopyD
void * CopyD(int t)
Definition subexpr.cc:714
sleftv::rtyp
int rtyp
Definition subexpr.h:91
sleftv::data
void * data
Definition subexpr.h:88
slists::m
sleftv * m
Definition lists.h:46
slists::nr
int nr
Definition lists.h:44
res
CanonicalForm res
Definition facAbsFact.cc:60
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
slists_bin
VAR omBin slists_bin
Definition lists.cc:23
lists
slists * lists
Definition mpr_numeric.h:146
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259
NULL
#define NULL
Definition omList.c:12

## lAppend()

BOOLEAN lAppend | ( | leftv | res,
|  | leftv | u,
|  | leftv | v )

Definition at line 151 of file lists.cc.

{
lists ul=(lists)u->CopyD();
res->data=(char *)lInsert0(ul,v,ul->nr+1);
return (res->data==NULL);
}
lInsert0
lists lInsert0(lists ul, leftv v, int pos)
Definition lists.cc:87

## lCopy()

lists lCopy | ( | lists | L | ) |

Definition at line 32 of file lists.cc.

{
lists N=(lists)omAlloc0Bin(slists_bin);
int n=L->nr;
if (n>=0)
N->Init(n+1);
else
N->Init();
for(;n>=0;n--)
{
N->m[n].Copy(&L->m[n]);
}
//Print("copy list with %d -> %d elems\n",L->nr,N->nr);
return N;
}
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition omAllocDecl.h:206

## lDelete()

BOOLEAN lDelete | ( | leftv | res,
|  | leftv | u,
|  | leftv | v )

Definition at line 161 of file lists.cc.

{
lists ul=(lists)u->Data();
int VIndex=(int)(long)v->Data()-1;
int EndIndex=lSize(ul);
if((0<=VIndex)&&(VIndex<=ul->nr))
{
ul=(lists)u->CopyD();
int i;
lists l=(lists) omAllocBin(slists_bin);
l->Init(EndIndex+(VIndex>EndIndex));
ul->m[VIndex].CleanUp();
for(i=0;i<VIndex;i++)
{
l->m[i]=ul->m[i];
}
for(i=VIndex+1;i<=ul->nr;i++)
{
l->m[i-1]=ul->m[i];
}
omFreeSize((ADDRESS)ul->m,(ul->nr+1)*sizeof(sleftv));
omFreeBin((ADDRESS)ul, slists_bin);
res->data = (char *)l;
return FALSE;
}
Werror("wrong index %d in list(%d)",VIndex+1,ul->nr+1);
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
sleftv::Data
void * Data()
Definition subexpr.cc:1192
sleftv::CleanUp
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
lSize
int lSize(lists L)
Definition lists.cc:25
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189

## lDeleteIV()

BOOLEAN lDeleteIV | ( | leftv | res,
|  | leftv | u,
|  | leftv | v )

Definition at line 192 of file lists.cc.

{
lists ul=(lists)u->CopyD();
intvec* vl=(intvec*)v->Data();
int i,j,cnt;
cnt=0;
for(i=vl->length()-1;i>=0;i--)
{
j=(*vl)[i];
if ((j>0)&&(j<=ul->nr))
{
cnt++;
ul->m[j-1].CleanUp();
memcpy(&(ul->m[j-1]),&(ul->m[j]),(ul->nr-j+1)*sizeof(sleftv));
ul->m[ul->nr].rtyp=DEF_CMD;
ul->m[ul->nr].data=NULL;
}
}
if ((cnt*2>=ul->nr)||(cnt*sizeof(sleftv)>=1024))
{
ul->m=(leftv)omReallocSize(ul->m,(ul->nr+1)*sizeof(sleftv),(ul->nr-cnt+1)*sizeof(sleftv));
ul->nr -= cnt;
}
res->data = (char *)ul;
return FALSE;
}
intvec
Definition intvec.h:24
intvec::length
int length() const
Definition intvec.h:95
j
int j
Definition facHensel.cc:110
omReallocSize
#define omReallocSize(addr, o_size, size)
Definition omAllocDecl.h:220
leftv
sleftv * leftv
Definition structs.h:53
DEF_CMD
@ DEF_CMD
Definition tok.h:58

## liFindRes()

resolvente liFindRes | ( | lists | L,
|  | int * | len,
|  | int * | typ0,
|  | intvec *** | weights )

Definition at line 344 of file lists.cc.

{
resolvente r;
intvec ** w=NULL,*tw=NULL;
*len=L->nr+1;
if (*len<=0)
{
WerrorS("empty list");
return NULL;
}
r=(ideal *)omAlloc0((*len)*sizeof(ideal));
w=(intvec**)omAlloc0((*len)*sizeof(intvec*));
int i=0;
*typ0=MODUL_CMD;
while (i<(*len))
{
if (L->m[i].rtyp != MODUL_CMD)
{
if (L->m[i].rtyp!=IDEAL_CMD)
{
Werror("element %d is not of type module",i+1);
omFreeSize((ADDRESS)r,(*len)*sizeof(ideal));
return NULL;
}
*typ0=IDEAL_CMD;
}
if ((i>0) && (idIs0(r[i-1])))
{
//*len=i-1;
break;
}
r[i]=(ideal)L->m[i].data;
tw=(intvec*)atGet(&(L->m[i]),"isHomog",INTVEC_CMD);
if (tw!=NULL)
{
w[i]=ivCopy(tw);
}
tw = NULL;
i++;
}
BOOLEAN hom_complex=TRUE;
int j=0;
while ((j<i) && hom_complex)
{
hom_complex = hom_complex && (w[j]!=NULL);
j++;
}
if ((!hom_complex) || (weights==NULL))
{
for (j=0;j<i;j++)
{
if (w[j]!=NULL) delete w[j];
}
omFreeSize((ADDRESS)w,(*len)*sizeof(intvec*));
if (weights!=NULL) *weights=NULL;
}
else
{
*weights = w;
}
//Print("find res of length %d (0..%d) L:%d\n",*len,(*len)-1,L->nr);
return r;
}
atGet
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
w
const CanonicalForm & w
Definition facAbsFact.cc:51
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
IDEAL_CMD
@ IDEAL_CMD
Definition grammar.cc:285
MODUL_CMD
@ MODUL_CMD
Definition grammar.cc:288
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition simpleideals.cc:960
resolvente
ideal * resolvente
Definition ideals.h:18
ivCopy
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
INTVEC_CMD
@ INTVEC_CMD
Definition tok.h:101

## liMakeResolv()

lists liMakeResolv | ( | resolvente | r,
|  | int | length,
|  | int | reallen,
|  | int | typ0,
|  | intvec ** | weights,
|  | int | add_row_shift )

Definition at line 239 of file lists.cc.

{
// re-uses r, weights[i]
lists L=(lists)omAlloc0Bin(slists_bin);
if (length<0)
{
// handle "empty" resolutions
L->Init(0);
}
else if (length==0)
{
L->Init(1);
L->m[0].rtyp=typ0;
L->m[0].data=(void*)idInit(1,1);
}
else
{
int oldlength=length;
while (r[length-1]==NULL) length--;
if (reallen<=0) reallen=currRing->N;
reallen=si_max(reallen,length);
L->Init(reallen);
int i=0;
while (i<length)
{
if (r[i]!=NULL)
{
if (i==0)
{
L->m[i].rtyp=typ0;
int j=IDELEMS(r[0])-1;
while ((j>0) && (r[0]->m[j]==NULL)) j--;
j++;
if (j!=IDELEMS(r[0]))
{
pEnlargeSet(&(r[0]->m),IDELEMS(r[0]),j-IDELEMS(r[0]));
IDELEMS(r[0])=j;
}
}
else
{
L->m[i].rtyp=MODUL_CMD;
int rank=IDELEMS(r[i-1]);
if (idIs0(r[i-1]))
{
idDelete(&(r[i]));
r[i]=id_FreeModule(rank, currRing);
}
else
{
r[i]->rank=si_max(rank,(int)id_RankFreeModule(r[i], currRing));
}
idSkipZeroes(r[i]);
}
L->m[i].data=(void *)r[i];
if ((weights!=NULL) && (weights[i]!=NULL))
{
intvec *w=weights[i];
(*w) += add_row_shift;
atSet((idhdl)&L->m[i],omStrDup("isHomog"),w,INTVEC_CMD);
weights[i] = NULL;
}
}
#ifdef TEST
else
{
// should not happen:
WarnS("internal NULL in resolvente");
L->m[i].data=(void *)idInit(1,1);
}
#endif
i++;
}
omFreeSize((ADDRESS)r,oldlength*sizeof(ideal));
if (weights!=NULL) omFreeSize(weights,oldlength*sizeof(intvec*));
if (i==0)
{
L->m[0].rtyp=typ0;
L->m[0].data=(char *)idInit(1,1);
i=1;
}
while (i<reallen)
{
L->m[i].rtyp=MODUL_CMD;
ideal I=(ideal)L->m[i-1].data;
ideal J;
int rank=IDELEMS(I);
if (idIs0(I))
{
J=idFreeModule(rank);
}
else
{
J=idInit(1,rank);
}
L->m[i].data=(void *)J;
i++;
}
//Print("make res of length %d (0..%d) L:%d\n",length,length-1,L->nr);
}
return L;
}
atSet
void atSet(idhdl root, char *name, void *data, int typ)
Definition attrib.cc:153
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
m
int m
Definition cfEzgcd.cc:128
slists::Init
INLINE_THIS void Init(int l=0)
WarnS
#define WarnS
Definition emacs.cc:78
idDelete
#define idDelete(H)
delete an ideal
Definition ideals.h:29
idFreeModule
ideal idFreeModule(int i)
Definition ideals.h:111
length
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
pEnlargeSet
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3821
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
idhdl
idrec * idhdl
Definition ring.h:22
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
id_FreeModule
ideal id_FreeModule(int i, const ring r)
the free module of rank i
Definition simpleideals.cc:1235
id_RankFreeModule
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition simpleideals.cc:992
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition simpleideals.cc:201
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23

## lInsert()

BOOLEAN lInsert | ( | leftv | res,
|  | leftv | u,
|  | leftv | v )

Definition at line 120 of file lists.cc.

{
lists ul=(lists)u->CopyD();
res->data=(char *)lInsert0(ul,v,0);
if (res->data==NULL)
{
Werror("cannot insert type `%s`",Tok2Cmdname(v->Typ()));
return TRUE;
}
return FALSE;
}
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137

## lInsert0()

lists lInsert0 | ( | lists | ul,
|  | leftv | v,
|  | int | pos )

Definition at line 87 of file lists.cc.

{
if ((pos<0)||(v->rtyp==NONE))
return NULL;
lists l=(lists) omAllocBin(slists_bin);
l->Init(si_max(ul->nr+2,pos+1));
int i,j;
for(i=j=0;i<=ul->nr;i++,j++)
{
if(j==pos) j++;
l->m[j]=ul->m[i];
}
for(j=ul->nr+1;j<pos;j++)
l->m[j].rtyp=DEF_CMD;
// memset(&(l->m[pos]),0,sizeof(sleftv)); - done by Init
l->m[pos].rtyp=v->Typ();
l->m[pos].data=v->CopyD();
l->m[pos].flag=v->flag;
attr *a=v->Attribute();
if ((a!=NULL)&&(*a!=NULL))
{
l->m[pos].attribute=(*a)->Copy();
}
if (ul->m != NULL)
omFreeSize((ADDRESS)ul->m,(ul->nr+1)*sizeof(sleftv));
omFreeBin((ADDRESS)ul, slists_bin);
return l;
}
attr
sattr * attr
Definition attrib.h:16
NONE
#define NONE
Definition tok.h:223

## lInsert3()

BOOLEAN lInsert3 | ( | leftv | res,
|  | leftv | u,
|  | leftv | v,
|  | leftv | w )

Definition at line 135 of file lists.cc.

{
lists ul=(lists)u->CopyD();
res->data=(char *)lInsert0(ul,v,(int)(long)w->Data());
if (res->data==NULL)
{
Werror("cannot insert type `%s` at pos. %d",
Tok2Cmdname(v->Typ()),(int)(long)w->Data());
return TRUE;
}
return FALSE;
}

## lRingDependend()

BOOLEAN lRingDependend | ( | lists | L | ) |

Definition at line 222 of file lists.cc.

{
if (L==NULL) return FALSE;
int i=L->nr;
while (i>=0)
{
REGISTER int t=L->m[i].rtyp;
if ((BEGIN_RING<t /*L->m[i].rtyp*/)
&& (/*L->m[i].rtyp*/ t<END_RING))
return TRUE;
if ((/*L->m[i].rtyp*/ t==LIST_CMD)&&lRingDependend((lists)L->m[i].data))
return TRUE;
i--;
}
return FALSE;
}
END_RING
@ END_RING
Definition grammar.cc:311
BEGIN_RING
@ BEGIN_RING
Definition grammar.cc:283
lRingDependend
BOOLEAN lRingDependend(lists L)
Definition lists.cc:222
REGISTER
#define REGISTER
Definition omalloc.h:27
LIST_CMD
@ LIST_CMD
Definition tok.h:118

## lSize()

int lSize | ( | lists | L | ) |

Definition at line 25 of file lists.cc.

{
int n=L->nr;
while ((n>=0)&&((L->m[n].rtyp==DEF_CMD)||(L->m[n].rtyp==0))) n--;
return n;
}

## lString()

char * lString | ( | lists | l,
|  | BOOLEAN | typed,
|  | int | dim )

Definition at line 409 of file lists.cc.

{
if (l->nr == -1)
{
if (typed) return omStrDup("list()");
return omStrDup("");
}
char** slist = (char**) omAlloc((l->nr+1) * sizeof(char*));
int i, j, k;
char *s;
for (i=0, j = 0, k = 0; i<=l->nr; i++)
{
slist[i] = l->m[i].String(NULL, typed, dim);
assume(slist[i] != NULL);
omCheckAddr(slist[i]);
if (*(slist[i]) != '\0')
{
j += strlen(slist[i]);
k++;
}
}
size_t len=j+k+2+(typed ? 10 : 0) + (dim == 2 ? k : 0);
s = (char*) omAlloc(len);
if (typed)
snprintf(s, len,"list(");
else
*s = '\0';
for (i=0; i<=l->nr; i++)
{
if (*(slist[i]) != '\0')
{
strcat(s, slist[i]);
strcat(s, ",");
if (dim == 2) strcat(s, "\n");
}
omCheckAddr(s);
omFree(slist[i]);
}
if (k > 0) s[strlen(s) - (dim == 2 ? 2 : 1)] = '\0';
if (typed) strcat(s, ")");
omCheckAddr(s);
omFreeSize(slist, (l->nr+1) * sizeof(char*));
return s;
}
k
int k
Definition cfEzgcd.cc:99
s
const CanonicalForm int s
Definition facAbsFact.cc:51
assume
#define assume(x)
Definition mod2.h:389
omCheckAddr
#define omCheckAddr(addr)
Definition omAllocDecl.h:328
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
dim
int dim(ideal I, ring r)
Definition tropicalStrategy.cc:23

## Variable Documentation

## slists_bin

VAR omBin slists_bin = omGetSpecBin(sizeof(slists))

Definition at line 23 of file lists.cc.