My Project
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
ipconv.cc File Reference
#include "kernel/mod2.h"
#include "Singular/tok.h"
#include "Singular/ipid.h"
#include "misc/intvec.h"
#include "misc/options.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "Singular/subexpr.h"
#include "coeffs/numbers.h"
#include "coeffs/coeffs.h"
#include "coeffs/bigintmat.h"
#include "polys/matpol.h"
#include "Singular/links/silink.h"
#include "kernel/GBEngine/syz.h"
#include "Singular/attrib.h"
#include "polys/monomials/ring.h"
#include "Singular/ipshell.h"
#include "Singular/number2.h"
#include "Singular/ipconv.h"
#include "Singular/table.h"

Go to the source code of this file.

Data Structures

struct  sConvertTypes
 

Macros

#define IPCONV
 
#define D(A)   A
 
#define NULL_VAL   NULL
 

Typedefs

typedef void *(* iiConvertProc) (void *data)
 
typedef void(* iiConvertProcL) (leftv out, leftv in)
 

Functions

static voidiiI2P (void *data)
 
static voidiiBI2P (void *data)
 
static void iiBu2P (leftv out, leftv in)
 
static voidiiI2V (void *data)
 
static voidiiBI2V (void *data)
 
static voidiiIV2BIV (void *data)
 
static voidiiI2Id (void *data)
 
static voidiiBI2Id (void *data)
 
static voidiiBu2V (void *data)
 
static voidiiP2V (void *data)
 
static voidiiBu2Id (void *data)
 
static voidiiP2Id (void *data)
 
static voidiiV2Ma (void *data)
 
static voidiiN2P (void *data)
 
static voidiiDummy (void *data)
 
static voidiiMo2Ma (void *data)
 
static voidiiMa2Mo (void *data)
 
static voidiiI2Iv (void *data)
 
static voidiiI2N (void *data)
 
static voidiiI2BI (void *data)
 
static voidiiBI2N (void *data)
 
static voidiiIm2Ma (void *data)
 
static voidiiIm2Bim (void *data)
 
static voidiiN2Ma (void *data)
 
static voidiiS2Link (void *data)
 
static void iiR2L_l (leftv out, leftv in)
 
static void iiL2R (leftv out, leftv in)
 
BOOLEAN iiConvert (int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
 
int iiTestConvert (int inputType, int outputType, const struct sConvertTypes *dConvertTypes)
 

Data Structure Documentation

◆ sConvertTypes

struct sConvertTypes

Definition at line 118 of file gentable.cc.

Data Fields
int i_typ
int o_typ
int p
iiConvertProc p
int pl
iiConvertProcL pl

Macro Definition Documentation

◆ D

#define D ( A)    A

Definition at line 442 of file ipconv.cc.

◆ IPCONV

#define IPCONV

Definition at line 441 of file ipconv.cc.

◆ NULL_VAL

#define NULL_VAL   NULL

Definition at line 443 of file ipconv.cc.

Typedef Documentation

◆ iiConvertProc

typedef void *(* iiConvertProc) (void *data)

Definition at line 32 of file ipconv.cc.

◆ iiConvertProcL

typedef void(* iiConvertProcL) (leftv out, leftv in)

Definition at line 33 of file ipconv.cc.

Function Documentation

◆ iiBI2Id()

static void * iiBI2Id ( void * data)
static

Definition at line 115 of file ipconv.cc.

116{
117 ideal I=idInit(1,1);
119 if (nMap==NULL)
120 {
121 Werror("no conversion from bigint to %s", nCoeffName(currRing->cf));
122 return NULL;
123 }
125 n_Delete((number *)&data,coeffs_BIGINT);
126 poly p=pNSet(n);
127 I->m[0]=p;
128 return (void *)I;
129}
int p
Definition cfModGcd.cc:4086
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:704
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:967
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
VAR coeffs coeffs_BIGINT
Definition ipid.cc:50
#define NULL
Definition omList.c:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pNSet(n)
Definition polys.h:313
void Werror(const char *fmt,...)
Definition reporter.cc:189
ideal idInit(int idsize, int rank)
initialise an ideal / module

◆ iiBI2N()

static void * iiBI2N ( void * data)
static

Definition at line 255 of file ipconv.cc.

256{
257 if (currRing==NULL) return NULL;
259 if (nMap==NULL)
260 {
261 Werror("no conversion from bigint to %s", nCoeffName(currRing->cf));
262 return NULL;
263 }
265 n_Delete((number *)&data, coeffs_BIGINT);
266 return (void*)n;
267}

◆ iiBI2P()

static void * iiBI2P ( void * data)
static

Definition at line 50 of file ipconv.cc.

51{
53 if (nMap==NULL)
54 {
55 Werror("no conversion from bigint to %s", nCoeffName(currRing->cf));
56 return NULL;
57 }
59 n_Delete((number *)&data, coeffs_BIGINT);
60 poly p=p_NSet(n, currRing);
61 return (void *)p;
62}
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition p_polys.cc:1476

◆ iiBI2V()

static void * iiBI2V ( void * data)
static

Definition at line 79 of file ipconv.cc.

80{
82 if (nMap==NULL)
83 {
84 Werror("no conversion from bigint to %s", nCoeffName(currRing->cf));
85 return NULL;
86 }
88 n_Delete((number *)&data, coeffs_BIGINT);
89 poly p=p_NSet(n, currRing);
90 if (p!=NULL) pSetComp(p,1);
91 return (void *)p;
92}
#define pSetComp(p, v)
Definition polys.h:38

◆ iiBu2Id()

static void * iiBu2Id ( void * data)
static

Definition at line 150 of file ipconv.cc.

151{
152 ideal I=idInit(1,1);
153
154 if (data!=NULL)
155 {
156 sBucket_pt b=(sBucket_pt)data;
157 poly p; int l;
159 I->m[0]=p;
160 }
161 return (void *)I;
162}
int l
Definition cfEzgcd.cc:100
CanonicalForm b
Definition cfModGcd.cc:4111
sBucket * sBucket_pt
Definition sbuckets.h:16
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68

◆ iiBu2P()

static void iiBu2P ( leftv out,
leftv in )
static

Definition at line 64 of file ipconv.cc.

65{
66 sBucket_pt b=(sBucket_pt)in->CopyD();
67 poly p; int l;
69 out->data=(void*)p;
70}

◆ iiBu2V()

static void * iiBu2V ( void * data)
static

Definition at line 130 of file ipconv.cc.

131{
132 poly p=NULL;
133 if (data!=NULL)
134 {
135 sBucket_pt b=(sBucket_pt)data;
136 int l;
138 if (p!=NULL) pSetCompP(p,1);
139 }
140 return (void *)p;
141}
#define pSetCompP(a, i)
Definition polys.h:303

◆ iiConvert()

BOOLEAN iiConvert ( int inputType,
int outputType,
int index,
leftv input,
leftv output,
const struct sConvertTypes * dConvertTypes )

Definition at line 449 of file ipconv.cc.

450{
451 output->Init();
452 if ((inputType==outputType)
453 || (outputType==DEF_CMD)
454 || ((outputType==IDHDL)&&(input->rtyp==IDHDL)))
455 {
456 memcpy(output,input,sizeof(*output));
457 input->Init();
458 return FALSE;
459 }
460 else if (outputType==ANY_TYPE)
461 {
462 output->rtyp=ANY_TYPE;
463 output->data=(char *)(long)input->Typ();
464 /* the name of the object:*/
465 if (input->e==NULL)
466 {
467 if (input->rtyp==IDHDL)
468 /* preserve name: copy it */
469 output->name=omStrDup(IDID((idhdl)(input->data)));
470 else if (input->name!=NULL)
471 {
472 if (input->rtyp==ALIAS_CMD)
473 output->name=omStrDup(input->name);
474 else
475 {
476 output->name=input->name;
477 input->name=NULL;
478 }
479 }
480 else if ((input->rtyp==POLY_CMD) && (input->name==NULL))
481 {
482 if (input->data!=NULL)
483 {
484 int nr=pIsPurePower((poly)input->data);
485 if (nr!=0)
486 {
487 if (pGetExp((poly)input->data,nr)==1)
488 {
489 output->name=omStrDup(currRing->names[nr-1]);
490 }
491 else
492 {
493 char *tmp=(char *)omAlloc(8);
494 snprintf(tmp,8,"%c%d",*(currRing->names[nr-1]),
495 (int)pGetExp((poly)input->data,nr));
496 output->name=tmp;
497 }
498 }
499 else if(pIsConstant((poly)input->data))
500 {
501 StringSetS("");
502 number n=(pGetCoeff((poly)input->data));
503 n_Write(n, currRing->cf);
504 (pGetCoeff((poly)input->data))=n; // n_Write may have changed n
505 output->name=StringEndS();
506 }
507 }
508 }
509 else if ((input->rtyp==NUMBER_CMD) && (input->name==NULL))
510 {
511 StringSetS("");
512 number n=(number)input->data;
513 n_Write(n, currRing->cf);
514 input->data=(void*)n; // n_Write may have changed n
515 output->name=StringEndS();
516 }
517 else
518 {
519 /* no need to preserve name: use it */
520 output->name=input->name;
521 input->name=NULL;
522 }
523 }
524 output->next=input->next;
525 input->next=NULL;
526 if (!errorreported) input->CleanUp();
527 return errorreported;
528 }
529 if (index!=0) /* iiTestConvert does not returned 'failure' */
530 {
531 index--;
532
533 if((dConvertTypes[index].i_typ==inputType)
534 &&(dConvertTypes[index].o_typ==outputType))
535 {
537 {
538 Print("automatic conversion %s -> %s\n",
540 }
542 return TRUE;
543 output->rtyp=outputType;
545 {
546 output->data=dConvertTypes[index].p(input->CopyD());
547 }
548 else
549 {
551 }
552 if ((output->data==NULL)
553 && ((outputType!=INT_CMD)
557 {
558 return TRUE;
559 }
560 if (errorreported) return TRUE;
561 output->next=input->next;
562 input->next=NULL;
563 if ((input->rtyp!=IDHDL) && (input->attribute!=NULL))
564 {
565 input->attribute->killAll(currRing);
566 input->attribute=NULL;
567 }
568 if (input->e!=NULL)
569 {
570 Subexpr h;
571 while (input->e!=NULL)
572 {
573 h=input->e->next;
575 input->e=h;
576 }
577 }
578 //input->Init(); // seems that input (rtyp?) is still needed
579 return FALSE;
580 }
581 }
582 return TRUE;
583}
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
Definition idrec.h:35
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:595
#define Print
Definition emacs.cc:80
VAR short errorreported
Definition feFopen.cc:23
const char * Tok2Cmdname(int tok)
Definition gentable.cc:140
@ END_RING
Definition grammar.cc:311
@ BEGIN_RING
Definition grammar.cc:283
@ VECTOR_CMD
Definition grammar.cc:293
@ NUMBER_CMD
Definition grammar.cc:289
@ POLY_CMD
Definition grammar.cc:290
const struct sConvertTypes dConvertTypes[]
Definition table.h:1322
#define IDID(a)
Definition ipid.h:122
STATIC_VAR Poly * h
Definition janet.cc:971
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
#define omStrDup(s)
#define omAlloc(size)
#define omFreeBin(addr, bin)
static int index(p_Length length, p_Ord ord)
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:238
#define pGetExp(p, i)
Exponent.
Definition polys.h:41
#define pIsPurePower(p)
Definition polys.h:248
void StringSetS(const char *st)
Definition reporter.cc:128
char * StringEndS()
Definition reporter.cc:151
EXTERN_VAR int traceit
Definition reporter.h:24
#define TRACE_CONV
Definition reporter.h:48
VAR omBin sSubexpr_bin
Definition subexpr.cc:40
#define IDHDL
Definition tok.h:31
@ ALIAS_CMD
Definition tok.h:34
@ DEF_CMD
Definition tok.h:58
@ INT_CMD
Definition tok.h:96
#define ANY_TYPE
Definition tok.h:30

◆ iiDummy()

static void * iiDummy ( void * data)
static

Definition at line 190 of file ipconv.cc.

191{
192 return data;
193}

◆ iiI2BI()

static void * iiI2BI ( void * data)
static

Definition at line 220 of file ipconv.cc.

221{
222 number n=n_Init((int)(long)data, coeffs_BIGINT);
223 return (void *)n;
224}
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:542

◆ iiI2Id()

static void * iiI2Id ( void * data)
static

Definition at line 108 of file ipconv.cc.

109{
110 ideal I=idInit(1,1);
111 I->m[0]=pISet((int)(long)data);
112 return (void *)I;
113}
#define pISet(i)
Definition polys.h:312

◆ iiI2Iv()

static void * iiI2Iv ( void * data)
static

Definition at line 207 of file ipconv.cc.

208{
209 int s=(int)(long)data;
210 intvec *iv=new intvec(s,s);
211 return (void *)iv;
212}
const CanonicalForm int s
Definition facAbsFact.cc:51

◆ iiI2N()

static void * iiI2N ( void * data)
static

Definition at line 214 of file ipconv.cc.

215{
216 number n=nInit((int)(long)data);
217 return (void *)n;
218}
#define nInit(i)
Definition numbers.h:24

◆ iiI2P()

static void * iiI2P ( void * data)
static

Definition at line 44 of file ipconv.cc.

45{
46 poly p=pISet((int)(long)data);
47 return (void *)p;
48}

◆ iiI2V()

static void * iiI2V ( void * data)
static

Definition at line 72 of file ipconv.cc.

73{
74 poly p=pISet((int)(long)data);
75 if (p!=NULL) pSetComp(p,1);
76 return (void *)p;
77}

◆ iiIm2Bim()

static void * iiIm2Bim ( void * data)
static

Definition at line 368 of file ipconv.cc.

369{
370 intvec *iv=(intvec*)data;
371 void *r=(void *)iv2bim(iv,coeffs_BIGINT);
372 delete iv;
373 return r;
374}
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition bigintmat.cc:349

◆ iiIm2Ma()

static void * iiIm2Ma ( void * data)
static

Definition at line 351 of file ipconv.cc.

352{
353 int i, j;
354 intvec *iv = (intvec *)data;
355 matrix m = mpNew(iv->rows(), iv->cols());
356
357 for (i=iv->rows(); i>0; i--)
358 {
359 for (j=iv->cols(); j>0; j--)
360 {
361 MATELEM(m, i, j) = pISet(IMATELEM(*iv, i, j));
362 }
363 }
364 delete iv;
365 return (void *)m;
366}
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int cols() const
Definition intvec.h:95
int rows() const
Definition intvec.h:96
int j
Definition facHensel.cc:110
#define IMATELEM(M, I, J)
Definition intvec.h:85
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29

◆ iiIV2BIV()

static void * iiIV2BIV ( void * data)
static

Definition at line 94 of file ipconv.cc.

95{
96 intvec *aa=(intvec*)data;
97 int l=aa->rows();
99 for(int i=0;i<l;i++)
100 {
102 n_Delete(&BIMATELEM((*bim),1,i+1), coeffs_BIGINT);
103 BIMATELEM((*bim),1,i+1)=tp;
104 }
105 return (void *)bim;
106}
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
Matrices of numbers.
Definition bigintmat.h:51

◆ iiL2R()

static void iiL2R ( leftv out,
leftv in )
static

Definition at line 424 of file ipconv.cc.

425{
426 //int add_row_shift = 0;
427 lists l=(lists)in->Data();
428 intvec *ww=NULL;
429 if (l->nr>=0) ww=(intvec *)atGet(&(l->m[0]),"isHomog",INTVEC_CMD);
430 out->data=(void *)syConvList(l);
431 if (ww!=NULL)
432 {
433 intvec *weights=ivCopy(ww);
434 atSet(out,omStrDup("isHomog"),weights,INTVEC_CMD);
435 }
436}
void atSet(idhdl root, char *name, void *data, int typ)
Definition attrib.cc:153
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
Definition lists.h:24
intvec * ivCopy(const intvec *o)
Definition intvec.h:145
syStrategy syConvList(lists li)
Definition ipshell.cc:3256
slists * lists
@ INTVEC_CMD
Definition tok.h:101

◆ iiMa2Mo()

static void * iiMa2Mo ( void * data)
static

Definition at line 201 of file ipconv.cc.

202{
203 void *res=id_Matrix2Module((matrix)data,currRing);
204 return res;
205}
CanonicalForm res
Definition facAbsFact.cc:60
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat

◆ iiMo2Ma()

static void * iiMo2Ma ( void * data)
static

Definition at line 195 of file ipconv.cc.

196{
197 void *res=id_Module2Matrix((ideal)data,currRing);
198 return res;
199}
matrix id_Module2Matrix(ideal mod, const ring R)

◆ iiN2Ma()

static void * iiN2Ma ( void * data)
static

Definition at line 390 of file ipconv.cc.

391{
392 ideal I=idInit(1,1);
393 if (!nIsZero((number)data))
394 {
395 poly p=pNSet((number)data);
396 I->m[0]=p;
397 }
398 //else
399 //{
400 // nDelete((number *)&data);
401 //}
402 return (void *)I;
403}
#define nIsZero(n)
Definition numbers.h:19

◆ iiN2P()

static void * iiN2P ( void * data)
static

Definition at line 376 of file ipconv.cc.

377{
378 poly p=NULL;
379 if (!nIsZero((number)data))
380 {
381 p=pNSet((number)data);
382 }
383 //else
384 //{
385 // nDelete((number *)&data);
386 //}
387 return (void *)p;
388}

◆ iiP2Id()

static void * iiP2Id ( void * data)
static

Definition at line 164 of file ipconv.cc.

165{
166 ideal I=idInit(1,1);
167
168 if (data!=NULL)
169 {
170 poly p=(poly)data;
171 I->m[0]=p;
172 if (pGetComp(p)!=0) I->rank=pMaxComp(p);
173 }
174 return (void *)I;
175}
#define pGetComp(p)
Component.
Definition polys.h:37
#define pMaxComp(p)
Definition polys.h:299

◆ iiP2V()

static void * iiP2V ( void * data)
static

Definition at line 143 of file ipconv.cc.

144{
145 poly p=(poly)data;
146 if (p!=NULL) pSetCompP(p,1);
147 return (void *)p;
148}

◆ iiR2L_l()

static void iiR2L_l ( leftv out,
leftv in )
static

Definition at line 413 of file ipconv.cc.

414{
415 int add_row_shift = 0;
416 intvec *weights=(intvec*)atGet(in,"isHomog",INTVEC_CMD);
417 if (weights!=NULL) add_row_shift=weights->min_in();
418
419 syStrategy tmp=(syStrategy)in->CopyD();
420
421 out->data=(void *)syConvRes(tmp,TRUE,add_row_shift);
422}
int min_in()
Definition intvec.h:121
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3184
ssyStrategy * syStrategy
Definition syz.h:36

◆ iiS2Link()

static void * iiS2Link ( void * data)
static

Definition at line 405 of file ipconv.cc.

406{
408 slInit(l, (char *) data);
409 omFree((ADDRESS)data);
410 return (void *)l;
411}
#define omAlloc0Bin(bin)
#define omFree(addr)

◆ iiTestConvert()

int iiTestConvert ( int inputType,
int outputType,
const struct sConvertTypes * dConvertTypes )

Definition at line 589 of file ipconv.cc.

590{
591 if ((inputType==outputType)
592 || (outputType==DEF_CMD)
593 || (outputType==IDHDL)
594 || (outputType==ANY_TYPE))
595 {
596 return -1;
597 }
598 if (inputType==UNKNOWN) return 0;
599
601 return 0;
602 //if ((currRing==NULL) && (outputType==CNUMBER_CMD))
603 // return 0;
604
605 // search the list
606 int i=0;
607 while (dConvertTypes[i].i_typ!=0)
608 {
609 if((dConvertTypes[i].i_typ==inputType)
610 &&(dConvertTypes[i].o_typ==outputType))
611 {
612 //Print("test convert %d to %d (%s -> %s):%d\n",inputType,outputType,
613 //Tok2Cmdname(inputType), Tok2Cmdname(outputType),i+1);
614 return i+1;
615 }
616 i++;
617 }
618 //Print("test convert %d to %d (%s -> %s):0, tested:%d\n",inputType,outputType,
619 // Tok2Cmdname(inputType), Tok2Cmdname(outputType),i);
620 return 0;
621}
#define UNKNOWN
Definition tok.h:224

◆ iiV2Ma()

static void * iiV2Ma ( void * data)
static

Definition at line 177 of file ipconv.cc.

178{
179 matrix m=(matrix)idVec2Ideal((poly)data);
180 int h=MATCOLS(m);
181 MATCOLS(m)=MATROWS(m);
182 MATROWS(m)=h;
183 m->rank=h;
184 pDelete((poly *)&data);
185 return (void *)m;
186}
static ideal idVec2Ideal(poly vec)
Definition ideals.h:172
ip_smatrix * matrix
Definition matpol.h:43
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
#define pDelete(p_ptr)
Definition polys.h:186