Functions | Variables
attrib.cc File Reference
#include <kernel/mod2.h>
#include <omalloc/omalloc.h>
#include <misc/options.h>
#include <misc/intvec.h>
#include <polys/matpol.h>
#include <kernel/polys.h>
#include <kernel/ideals.h>
#include <Singular/tok.h>
#include <Singular/ipid.h>
#include <Singular/ipshell.h>
#include <Singular/attrib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>

Go to the source code of this file.

Functions

static void attr_free (attr h, const ring r=currRing)
 
void * atGet (idhdl root, const char *name, int t, void *defaultReturnValue)
 
void * atGet (leftv root, const char *name, int t)
 
void atSet (idhdl root, char *name, void *data, int typ)
 
void atSet (leftv root, char *name, void *data, int typ)
 
void at_Kill (idhdl root, const char *name, const ring r)
 
void at_KillAll (idhdl root, const ring r)
 
void at_KillAll (leftv root, const ring r)
 
BOOLEAN atATTRIB1 (leftv res, leftv v)
 
BOOLEAN atATTRIB2 (leftv res, leftv v, leftv b)
 
BOOLEAN atATTRIB3 (leftv, leftv v, leftv b, leftv c)
 
BOOLEAN atKILLATTR1 (leftv, leftv a)
 
BOOLEAN atKILLATTR2 (leftv, leftv a, leftv b)
 

Variables

static omBin sattr_bin = omGetSpecBin(sizeof(sattr))
 

Function Documentation

◆ at_Kill()

void at_Kill ( idhdl  root,
const char *  name,
const ring  r 
)

Definition at line 207 of file attrib.cc.

208 {
209  attr temp = root->attribute->get(name);
210  if (temp!=NULL)
211  {
212  attr N = temp->next;
213  attr temp1 = root->attribute;
214  if (temp1==temp)
215  {
216  root->attribute = N;
217  }
218  else
219  {
220  while (temp1->next!=temp) temp1 = temp1->next;
221  temp1->next = N;
222  }
223  temp->kill(r);
224  }
225 }
Definition: attrib.h:15
void kill(const ring r)
Definition: attrib.cc:188
const ring r
Definition: syzextra.cc:208
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
char name(const Variable &v)
Definition: factory.h:178
#define NULL
Definition: omList.c:10
attr attribute
Definition: idrec.h:41
attr next
Definition: attrib.h:21
attr get(const char *s)
Definition: attrib.cc:98

◆ at_KillAll() [1/2]

void at_KillAll ( idhdl  root,
const ring  r 
)

Definition at line 227 of file attrib.cc.

228 {
229  root->attribute->killAll(r);
230  root->attribute = NULL;
231 }
void killAll(const ring r)
Definition: attrib.cc:194
const ring r
Definition: syzextra.cc:208
#define NULL
Definition: omList.c:10
attr attribute
Definition: idrec.h:41

◆ at_KillAll() [2/2]

void at_KillAll ( leftv  root,
const ring  r 
)

Definition at line 233 of file attrib.cc.

234 {
235  root->attribute->killAll(r);
236  root->attribute = NULL;
237 }
void killAll(const ring r)
Definition: attrib.cc:194
const ring r
Definition: syzextra.cc:208
#define NULL
Definition: omList.c:10
attr attribute
Definition: subexpr.h:89

◆ atATTRIB1()

BOOLEAN atATTRIB1 ( leftv  res,
leftv  v 
)

Definition at line 239 of file attrib.cc.

240 {
241  attr *aa=(v->Attribute());
242  if (aa==NULL)
243  {
244  WerrorS("this object cannot have attributes");
245  return TRUE;
246  }
247  attr a=*aa;
248  BOOLEAN haveNoAttribute=TRUE;
249  if (v->e==NULL)
250  {
251  if (hasFlag(v,FLAG_STD))
252  {
253  PrintS("attr:isSB, type int\n");
254  haveNoAttribute=FALSE;
255  }
256  if (hasFlag(v,FLAG_QRING))
257  {
258  PrintS("attr:qringNF, type int\n");
259  haveNoAttribute=FALSE;
260  }
261  if (v->Typ()==RING_CMD)
262  {
263  PrintS("attr:cf_class, type int\n");
264  PrintS("attr:global, type int\n");
265  PrintS("attr:maxExp, type int\n");
266  PrintS("attr:ring_cf, type int\n");
267  #ifdef HAVE_SHIFTBBA
268  PrintS("attr:isLPring, type int\n");
269  #endif
270 
271  haveNoAttribute=FALSE;
272  }
273  }
274  else
275  {
276  leftv at=v->LData();
277  return atATTRIB1(res,at);
278  }
279  if (a!=NULL) a->Print();
280  else if(haveNoAttribute) PrintS("no attributes\n");
281  return FALSE;
282 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
const poly a
Definition: syzextra.cc:212
Definition: attrib.h:15
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
poly res
Definition: myNF.cc:322
#define FLAG_QRING
Definition: ipid.h:108
void PrintS(const char *s)
Definition: reporter.cc:284
#define FLAG_STD
Definition: ipid.h:106
BOOLEAN atATTRIB1(leftv res, leftv v)
Definition: attrib.cc:239
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
#define hasFlag(A, F)
Definition: ipid.h:109
int BOOLEAN
Definition: auxiliary.h:85

◆ atATTRIB2()

BOOLEAN atATTRIB2 ( leftv  res,
leftv  v,
leftv  b 
)

Definition at line 283 of file attrib.cc.

284 {
285  char *name=(char *)b->Data();
286  int t=v->Typ();
287  leftv at=NULL;
288  if (v->e!=NULL)
289  at=v->LData();
290  if (strcmp(name,"isSB")==0)
291  {
292  res->rtyp=INT_CMD;
293  res->data=(void *)(long)hasFlag(v,FLAG_STD);
294  if (at!=NULL) res->data=(void *)(long)(hasFlag(v,FLAG_STD)||(hasFlag(at,FLAG_STD)));
295  }
296  else if ((strcmp(name,"rank")==0)&&(/*v->Typ()*/t==MODUL_CMD))
297  {
298  res->rtyp=INT_CMD;
299  res->data=(void *)(((ideal)v->Data())->rank);
300  }
301  else if ((strcmp(name,"global")==0)
302  &&(/*v->Typ()*/t==RING_CMD))
303  {
304  res->rtyp=INT_CMD;
305  res->data=(void *)(((ring)v->Data())->OrdSgn==1);
306  }
307  else if ((strcmp(name,"maxExp")==0)
308  &&(/*v->Typ()*/t==RING_CMD))
309  {
310  res->rtyp=INT_CMD;
311  res->data=(void *)(long)(((ring)v->Data())->bitmask/2);
312  }
313  else if ((strcmp(name,"ring_cf")==0)
314  &&(/*v->Typ()*/t==RING_CMD))
315  {
316  res->rtyp=INT_CMD;
317  res->data=(void *)(long)(rField_is_Ring((ring)v->Data()));
318  }
319  else if ((strcmp(name,"cf_class")==0)
320  &&(/*v->Typ()*/t==RING_CMD))
321  {
322  res->rtyp=INT_CMD;
323  coeffs cf;
324  if (t==RING_CMD) cf=((ring)v->Data())->cf;
325  else cf=(coeffs)v->Data();
326  res->data=(void *)(long)(cf->type);
327  }
328  else if (strcmp(name,"qringNF")==0)
329  {
330  res->rtyp=INT_CMD;
331  res->data=(void *)(long)hasFlag(v,FLAG_QRING);
332  if (at!=NULL) res->data=(void *)(long)(hasFlag(v,FLAG_QRING)||(hasFlag(at,FLAG_QRING)));
333  }
334 #ifdef HAVE_SHIFTBBA
335  else if ((strcmp(name,"isLPring")==0)
336  &&(/*v->Typ()*/t==RING_CMD))
337  {
338  res->rtyp=INT_CMD;
339  res->data=(void *)(long)(((ring)v->Data())->isLPring);
340  }
341 #endif
342  else
343  {
344  attr *aa=v->Attribute();
345  if (aa==NULL)
346  {
347  WerrorS("this object cannot have attributes");
348  return TRUE;
349  }
350  attr a=*aa;
351  a=a->get(name);
352  if (a!=NULL)
353  {
354  res->rtyp=a->atyp;
355  res->data=a->CopyA();
356  }
357  else
358  {
359  res->rtyp=STRING_CMD;
360  res->data=omStrDup("");
361  }
362  }
363  return FALSE;
364 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
const poly a
Definition: syzextra.cc:212
Definition: tok.h:95
Definition: attrib.h:15
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
poly res
Definition: myNF.cc:322
The main handler for Singular numbers which are suitable for Singular polynomials.
#define FLAG_QRING
Definition: ipid.h:108
char name(const Variable &v)
Definition: factory.h:178
#define FLAG_STD
Definition: ipid.h:106
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
CanonicalForm cf
Definition: cfModGcd.cc:4024
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
#define hasFlag(A, F)
Definition: ipid.h:109
const poly b
Definition: syzextra.cc:213
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ atATTRIB3()

BOOLEAN atATTRIB3 ( leftv  ,
leftv  v,
leftv  b,
leftv  c 
)

Definition at line 365 of file attrib.cc.

366 {
367  idhdl h=(idhdl)v->data;
368  if (v->e!=NULL)
369  {
370  v=v->LData();
371  if (v==NULL) return TRUE;
372  h=NULL;
373  }
374  else if (v->rtyp!=IDHDL) h=NULL;
375  int t=v->Typ();
376 
377  char *name=(char *)b->Data();
378  if (strcmp(name,"isSB")==0)
379  {
380  if (c->Typ()!=INT_CMD)
381  {
382  WerrorS("attribute isSB must be int");
383  return TRUE;
384  }
385  if (((long)c->Data())!=0L)
386  {
387  if (h!=NULL) setFlag(h,FLAG_STD);
388  setFlag(v,FLAG_STD);
389  }
390  else
391  {
392  if (h!=NULL) resetFlag(h,FLAG_STD);
394  }
395  }
396  else if (strcmp(name,"qringNF")==0)
397  {
398  if (c->Typ()!=INT_CMD)
399  {
400  WerrorS("attribute qringNF must be int");
401  return TRUE;
402  }
403  if (((long)c->Data())!=0L)
404  {
405  if (h!=NULL) setFlag(h,FLAG_QRING);
407  }
408  else
409  {
410  if (h!=NULL) resetFlag(h,FLAG_QRING);
412  }
413  }
414  else if ((strcmp(name,"rank")==0)&&(/*v->Typ()*/t==MODUL_CMD))
415  {
416  if (c->Typ()!=INT_CMD)
417  {
418  WerrorS("attribute `rank` must be int");
419  return TRUE;
420  }
421  ideal I=(ideal)v->Data();
422  int rk=id_RankFreeModule(I,currRing);
423  I->rank=si_max(rk,(int)((long)c->Data()));
424  }
425  else if (((strcmp(name,"global")==0)
426  || (strcmp(name,"cf_class")==0)
427  || (strcmp(name,"ring_cf")==0)
428  || (strcmp(name,"maxExp")==0))
429  &&(/*v->Typ()*/t==RING_CMD))
430  {
431  Werror("can not set attribute `%s`",name);
432  return TRUE;
433  }
434 #ifdef HAVE_SHIFTBBA
435  else if ((strcmp(name,"isLPring")==0)
436  &&(/*v->Typ()*/t==RING_CMD))
437  {
438  if (c->Typ()==INT_CMD)
439  ((ring)v->Data())->isLPring=(int)(long)c->Data();
440  else
441  {
442  WerrorS("attribute `isLPring` must be int");
443  return TRUE;
444  }
445  }
446 #endif
447  else
448  {
449  int typ=c->Typ();
450  if (h!=NULL) atSet(h,omStrDup(name),c->CopyD(typ),typ/*c->T(yp()*/);
451  else atSet(v,omStrDup(name),c->CopyD(typ),typ/*c->T(yp()*/);
452  }
453  return FALSE;
454 }
Definition: tok.h:95
if(0 > strat->sl)
Definition: myNF.cc:73
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:31
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define setFlag(A, F)
Definition: ipid.h:110
void atSet(idhdl root, char *name, void *data, int typ)
Definition: attrib.cc:158
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
idrec * idhdl
Definition: ring.h:18
#define FLAG_QRING
Definition: ipid.h:108
char name(const Variable &v)
Definition: factory.h:178
#define FLAG_STD
Definition: ipid.h:106
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
void * Data()
Definition: subexpr.cc:1137
#define resetFlag(A, F)
Definition: ipid.h:111
static Poly * h
Definition: janet.cc:978
const poly b
Definition: syzextra.cc:213
void Werror(const char *fmt,...)
Definition: reporter.cc:189
void * CopyD(int t)
Definition: subexpr.cc:707
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ atGet() [1/2]

void* atGet ( idhdl  root,
const char *  name,
int  t,
void *  defaultReturnValue 
)

Definition at line 137 of file attrib.cc.

138 {
139  attr temp = root->attribute->get(name);
140  if ((temp!=NULL) && (temp->atyp==t))
141  return temp->data;
142  else
143  return defaultReturnValue;
144 }
Definition: attrib.h:15
void * data
Definition: attrib.h:20
char name(const Variable &v)
Definition: factory.h:178
#define NULL
Definition: omList.c:10
attr attribute
Definition: idrec.h:41
attr get(const char *s)
Definition: attrib.cc:98
int atyp
Definition: attrib.h:22

◆ atGet() [2/2]

void* atGet ( leftv  root,
const char *  name,
int  t 
)

Definition at line 146 of file attrib.cc.

147 {
148  attr *a=(root->Attribute());
149  if (a!=NULL)
150  {
151  attr temp = (*a)->get(name);
152  if ((temp!=NULL) && (temp->atyp==t))
153  return temp->data;
154  }
155  return NULL;
156 }
const poly a
Definition: syzextra.cc:212
Definition: attrib.h:15
attr * Attribute()
Definition: subexpr.cc:1392
void * data
Definition: attrib.h:20
char name(const Variable &v)
Definition: factory.h:178
#define NULL
Definition: omList.c:10
attr get(const char *s)
Definition: attrib.cc:98
int atyp
Definition: attrib.h:22

◆ atKILLATTR1()

BOOLEAN atKILLATTR1 ( leftv  ,
leftv  a 
)

Definition at line 456 of file attrib.cc.

457 {
458  idhdl h=NULL;
459  if ((a->rtyp==IDHDL)&&(a->e==NULL))
460  {
461  h=(idhdl)a->data;
462  resetFlag((idhdl)a->data,FLAG_STD);
463  }
465  if (h->attribute!=NULL)
466  {
467  atKillAll(h);
468  a->attribute=NULL;
469  }
470  else atKillAll(a);
471  return FALSE;
472 }
const poly a
Definition: syzextra.cc:212
#define FALSE
Definition: auxiliary.h:94
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:31
idrec * idhdl
Definition: ring.h:18
#define FLAG_STD
Definition: ipid.h:106
#define atKillAll(H)
Definition: attrib.h:42
#define NULL
Definition: omList.c:10
#define resetFlag(A, F)
Definition: ipid.h:111
static Poly * h
Definition: janet.cc:978

◆ atKILLATTR2()

BOOLEAN atKILLATTR2 ( leftv  ,
leftv  a,
leftv  b 
)

Definition at line 473 of file attrib.cc.

474 {
475  if ((a->rtyp!=IDHDL)||(a->e!=NULL))
476  {
477  WerrorS("object must have a name");
478  return TRUE;
479  }
480  char *name=(char *)b->Data();
481  if (strcmp(name,"isSB")==0)
482  {
484  resetFlag((idhdl)a->data,FLAG_STD);
485  }
486  else if (strcmp(name,"global")==0)
487  {
488  WerrorS("can not set attribut `global`");
489  return TRUE;
490  }
491  else
492  {
493  atKill((idhdl)a->data,name);
494  }
495  return FALSE;
496 }
const poly a
Definition: syzextra.cc:212
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
void WerrorS(const char *s)
Definition: feFopen.cc:24
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:31
char name(const Variable &v)
Definition: factory.h:178
#define atKill(H, A)
Definition: attrib.h:44
#define FLAG_STD
Definition: ipid.h:106
#define NULL
Definition: omList.c:10
#define resetFlag(A, F)
Definition: ipid.h:111
const poly b
Definition: syzextra.cc:213

◆ atSet() [1/2]

void atSet ( idhdl  root,
char *  name,
void *  data,
int  typ 
)

Definition at line 158 of file attrib.cc.

159 {
160  if (root!=NULL)
161  {
162  if ((IDTYP(root)!=RING_CMD)
163  && (!RingDependend(IDTYP(root)))&&(RingDependend(typ)))
164  WerrorS("cannot set ring-dependend objects at this type");
165  else
166  root->attribute=root->attribute->set(name,data,typ);
167  }
168 }
attr set(char *s, void *data, int t)
Definition: attrib.cc:75
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define IDTYP(a)
Definition: ipid.h:116
int RingDependend(int t)
Definition: gentable.cc:23
char name(const Variable &v)
Definition: factory.h:178
#define NULL
Definition: omList.c:10
attr attribute
Definition: idrec.h:41

◆ atSet() [2/2]

void atSet ( leftv  root,
char *  name,
void *  data,
int  typ 
)

Definition at line 170 of file attrib.cc.

171 {
172  if (root!=NULL)
173  {
174  attr *a=root->Attribute();
175  int rt=root->Typ();
176  if (a==NULL)
177  WerrorS("cannot set attributes of this object");
178  else if ((rt!=RING_CMD)
179  && (!RingDependend(rt))&&(RingDependend(typ)))
180  WerrorS("cannot set ring-dependend objects at this type");
181  else
182  {
183  *a=(*a)->set(name,data,typ);
184  }
185  }
186 }
const poly a
Definition: syzextra.cc:212
Definition: attrib.h:15
attr * Attribute()
Definition: subexpr.cc:1392
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:995
int RingDependend(int t)
Definition: gentable.cc:23
char name(const Variable &v)
Definition: factory.h:178
#define NULL
Definition: omList.c:10

◆ attr_free()

static void attr_free ( attr  h,
const ring  r = currRing 
)
static

Definition at line 64 of file attrib.cc.

65 {
66  if (h->data!=NULL) /*avoid assume failure */
67  {
68  s_internalDelete(h->atyp,h->data,r);
69  h->data=NULL;
70  omFree(h->name);
71  h->name=NULL;
72  }
73 }
const ring r
Definition: syzextra.cc:208
#define omFree(addr)
Definition: omAllocDecl.h:261
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:495
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978

Variable Documentation

◆ sattr_bin

omBin sattr_bin = omGetSpecBin(sizeof(sattr))
static

Definition at line 32 of file attrib.cc.