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 void * iiI2P (void *data)
 
static void * iiBI2P (void *data)
 
static void iiBu2P (leftv out, leftv in)
 
static void * iiI2V (void *data)
 
static void * iiBI2V (void *data)
 
static void * iiI2Id (void *data)
 
static void * iiBI2Id (void *data)
 
static void * iiBu2V (void *data)
 
static void * iiP2V (void *data)
 
static void * iiBu2Id (void *data)
 
static void * iiP2Id (void *data)
 
static void * iiV2Ma (void *data)
 
static void * iiN2P (void *data)
 
static void * iiDummy (void *data)
 
static void * iiMo2Ma (void *data)
 
static void * iiMa2Mo (void *data)
 
static void * iiI2Iv (void *data)
 
static void * iiI2N (void *data)
 
static void * iiI2BI (void *data)
 
static void * iiBI2N (void *data)
 
static void * iiIm2Ma (void *data)
 
static void * iiIm2Bim (void *data)
 
static void * iiN2Ma (void *data)
 
static void * iiS2Link (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 428 of file ipconv.cc.

◆ IPCONV

#define IPCONV

Definition at line 427 of file ipconv.cc.

◆ NULL_VAL

#define NULL_VAL   NULL

Definition at line 429 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 101 of file ipconv.cc.

102{
103 ideal I=idInit(1,1);
105 if (nMap==NULL)
106 {
107 Werror("no conversion from bigint to %s", nCoeffName(currRing->cf));
108 return NULL;
109 }
110 number n=nMap((number)data,coeffs_BIGINT,currRing->cf);
111 n_Delete((number *)&data,coeffs_BIGINT);
112 poly p=pNSet(n);
113 I->m[0]=p;
114 return (void *)I;
115}
int p
Definition: cfModGcd.cc:4078
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:697
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:960
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
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
Definition: simpleideals.cc:35

◆ iiBI2N()

static void * iiBI2N ( void *  data)
static

Definition at line 241 of file ipconv.cc.

242{
243 if (currRing==NULL) return NULL;
245 if (nMap==NULL)
246 {
247 Werror("no conversion from bigint to %s", nCoeffName(currRing->cf));
248 return NULL;
249 }
250 number n=nMap((number)data,coeffs_BIGINT,currRing->cf);
251 n_Delete((number *)&data, coeffs_BIGINT);
252 return (void*)n;
253}

◆ 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 }
58 number n=nMap((number)data,coeffs_BIGINT,currRing->cf);
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:1473

◆ 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 }
87 number n=nMap((number)data,coeffs_BIGINT,currRing->cf);
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 136 of file ipconv.cc.

137{
138 ideal I=idInit(1,1);
139
140 if (data!=NULL)
141 {
142 sBucket_pt b=(sBucket_pt)data;
143 poly p; int l;
145 I->m[0]=p;
146 }
147 return (void *)I;
148}
int l
Definition: cfEzgcd.cc:100
CanonicalForm b
Definition: cfModGcd.cc:4103
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{
67 poly p; int l;
69 out->data=(void*)p;
70}
void * CopyD(int t)
Definition: subexpr.cc:710
void * data
Definition: subexpr.h:88

◆ iiBu2V()

static void * iiBu2V ( void *  data)
static

Definition at line 116 of file ipconv.cc.

117{
118 poly p=NULL;
119 if (data!=NULL)
120 {
121 sBucket_pt b=(sBucket_pt)data;
122 int l;
124 if (p!=NULL) pSetCompP(p,1);
125 }
126 return (void *)p;
127}
#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 435 of file ipconv.cc.

436{
437 output->Init();
438 if ((inputType==outputType)
439 || (outputType==DEF_CMD)
440 || ((outputType==IDHDL)&&(input->rtyp==IDHDL)))
441 {
442 memcpy(output,input,sizeof(*output));
443 input->Init();
444 return FALSE;
445 }
446 else if (outputType==ANY_TYPE)
447 {
448 output->rtyp=ANY_TYPE;
449 output->data=(char *)(long)input->Typ();
450 /* the name of the object:*/
451 if (input->e==NULL)
452 {
453 if (input->rtyp==IDHDL)
454 /* preserve name: copy it */
455 output->name=omStrDup(IDID((idhdl)(input->data)));
456 else if (input->name!=NULL)
457 {
458 if (input->rtyp==ALIAS_CMD)
459 output->name=omStrDup(input->name);
460 else
461 {
462 output->name=input->name;
463 input->name=NULL;
464 }
465 }
466 else if ((input->rtyp==POLY_CMD) && (input->name==NULL))
467 {
468 if (input->data!=NULL)
469 {
470 int nr=pIsPurePower((poly)input->data);
471 if (nr!=0)
472 {
473 if (pGetExp((poly)input->data,nr)==1)
474 {
475 output->name=omStrDup(currRing->names[nr-1]);
476 }
477 else
478 {
479 char *tmp=(char *)omAlloc(4);
480 sprintf(tmp,"%c%d",*(currRing->names[nr-1]),
481 (int)pGetExp((poly)input->data,nr));
482 output->name=tmp;
483 }
484 }
485 else if(pIsConstant((poly)input->data))
486 {
487 StringSetS("");
488 number n=(pGetCoeff((poly)input->data));
489 n_Write(n, currRing->cf);
490 (pGetCoeff((poly)input->data))=n; // n_Write may have changed n
491 output->name=StringEndS();
492 }
493 }
494 }
495 else if ((input->rtyp==NUMBER_CMD) && (input->name==NULL))
496 {
497 StringSetS("");
498 number n=(number)input->data;
499 n_Write(n, currRing->cf);
500 input->data=(void*)n; // n_Write may have changed n
501 output->name=StringEndS();
502 }
503 else
504 {
505 /* no need to preserve name: use it */
506 output->name=input->name;
507 input->name=NULL;
508 }
509 }
510 output->next=input->next;
511 input->next=NULL;
512 if (!errorreported) input->CleanUp();
513 return errorreported;
514 }
515 if (index!=0) /* iiTestConvert does not returned 'failure' */
516 {
517 index--;
518
519 if((dConvertTypes[index].i_typ==inputType)
520 &&(dConvertTypes[index].o_typ==outputType))
521 {
523 {
524 Print("automatic conversion %s -> %s\n",
525 Tok2Cmdname(inputType),Tok2Cmdname(outputType));
526 }
527 if ((currRing==NULL) && (outputType>BEGIN_RING) && (outputType<END_RING))
528 return TRUE;
529 output->rtyp=outputType;
531 {
532 output->data=dConvertTypes[index].p(input->CopyD());
533 }
534 else
535 {
536 dConvertTypes[index].pl(output,input);
537 }
538 if ((output->data==NULL)
539 && ((outputType!=INT_CMD)
540 &&(outputType!=POLY_CMD)
541 &&(outputType!=VECTOR_CMD)
542 &&(outputType!=NUMBER_CMD)))
543 {
544 return TRUE;
545 }
546 if (errorreported) return TRUE;
547 output->next=input->next;
548 input->next=NULL;
549 if ((input->rtyp!=IDHDL) && (input->attribute!=NULL))
550 {
551 input->attribute->killAll(currRing);
552 input->attribute=NULL;
553 }
554 if (input->e!=NULL)
555 {
556 Subexpr h;
557 while (input->e!=NULL)
558 {
559 h=input->e->next;
561 input->e=h;
562 }
563 }
564 //input->Init(); // seems that input (rtyp?) is still needed
565 return FALSE;
566 }
567 }
568 return TRUE;
569}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
void * ADDRESS
Definition: auxiliary.h:119
Definition: idrec.h:35
void killAll(const ring r)
Definition: attrib.cc:189
int Typ()
Definition: subexpr.cc:1019
const char * name
Definition: subexpr.h:87
int rtyp
Definition: subexpr.h:91
void Init()
Definition: subexpr.h:107
leftv next
Definition: subexpr.h:86
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
Subexpr e
Definition: subexpr.h:105
attr attribute
Definition: subexpr.h:89
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:588
#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:310
@ BEGIN_RING
Definition: grammar.cc:282
@ VECTOR_CMD
Definition: grammar.cc:292
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
const struct sConvertTypes dConvertTypes[]
Definition: table.h:1285
#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)
Definition: omAllocDecl.h:263
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
#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 176 of file ipconv.cc.

177{
178 return data;
179}

◆ iiI2BI()

static void * iiI2BI ( void *  data)
static

Definition at line 206 of file ipconv.cc.

207{
208 number n=n_Init((int)(long)data, coeffs_BIGINT);
209 return (void *)n;
210}
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:535

◆ iiI2Id()

static void * iiI2Id ( void *  data)
static

Definition at line 94 of file ipconv.cc.

95{
96 ideal I=idInit(1,1);
97 I->m[0]=pISet((int)(long)data);
98 return (void *)I;
99}
#define pISet(i)
Definition: polys.h:312

◆ iiI2Iv()

static void * iiI2Iv ( void *  data)
static

Definition at line 193 of file ipconv.cc.

194{
195 int s=(int)(long)data;
196 intvec *iv=new intvec(s,s);
197 return (void *)iv;
198}
Definition: intvec.h:23
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ iiI2N()

static void * iiI2N ( void *  data)
static

Definition at line 200 of file ipconv.cc.

201{
202 number n=nInit((int)(long)data);
203 return (void *)n;
204}
#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 354 of file ipconv.cc.

355{
356 intvec *iv=(intvec*)data;
357 void *r=(void *)iv2bim(iv,coeffs_BIGINT);
358 delete iv;
359 return r;
360}
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition: bigintmat.cc:349

◆ iiIm2Ma()

static void * iiIm2Ma ( void *  data)
static

Definition at line 337 of file ipconv.cc.

338{
339 int i, j;
340 intvec *iv = (intvec *)data;
341 matrix m = mpNew(iv->rows(), iv->cols());
342
343 for (i=iv->rows(); i>0; i--)
344 {
345 for (j=iv->cols(); j>0; j--)
346 {
347 MATELEM(m, i, j) = pISet(IMATELEM(*iv, i, j));
348 }
349 }
350 delete iv;
351 return (void *)m;
352}
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

◆ iiL2R()

static void iiL2R ( leftv  out,
leftv  in 
)
static

Definition at line 410 of file ipconv.cc.

411{
412 //int add_row_shift = 0;
413 lists l=(lists)in->Data();
414 intvec *ww=NULL;
415 if (l->nr>=0) ww=(intvec *)atGet(&(l->m[0]),"isHomog",INTVEC_CMD);
416 out->data=(void *)syConvList(l);
417 if (ww!=NULL)
418 {
419 intvec *weights=ivCopy(ww);
420 atSet(out,omStrDup("isHomog"),weights,INTVEC_CMD);
421 }
422}
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
void * Data()
Definition: subexpr.cc:1162
Definition: lists.h:24
intvec * ivCopy(const intvec *o)
Definition: intvec.h:145
syStrategy syConvList(lists li)
Definition: ipshell.cc:3254
slists * lists
Definition: mpr_numeric.h:146
@ INTVEC_CMD
Definition: tok.h:101

◆ iiMa2Mo()

static void * iiMa2Mo ( void *  data)
static

Definition at line 187 of file ipconv.cc.

188{
189 void *res=id_Matrix2Module((matrix)data,currRing);
190 return res;
191}
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 181 of file ipconv.cc.

182{
183 void *res=id_Module2Matrix((ideal)data,currRing);
184 return res;
185}
matrix id_Module2Matrix(ideal mod, const ring R)

◆ iiN2Ma()

static void * iiN2Ma ( void *  data)
static

Definition at line 376 of file ipconv.cc.

377{
378 ideal I=idInit(1,1);
379 if (!nIsZero((number)data))
380 {
381 poly p=pNSet((number)data);
382 I->m[0]=p;
383 }
384 //else
385 //{
386 // nDelete((number *)&data);
387 //}
388 return (void *)I;
389}
#define nIsZero(n)
Definition: numbers.h:19

◆ iiN2P()

static void * iiN2P ( void *  data)
static

Definition at line 362 of file ipconv.cc.

363{
364 poly p=NULL;
365 if (!nIsZero((number)data))
366 {
367 p=pNSet((number)data);
368 }
369 //else
370 //{
371 // nDelete((number *)&data);
372 //}
373 return (void *)p;
374}

◆ iiP2Id()

static void * iiP2Id ( 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 poly p=(poly)data;
157 I->m[0]=p;
158 if (pGetComp(p)!=0) I->rank=pMaxComp(p);
159 }
160 return (void *)I;
161}
#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 129 of file ipconv.cc.

130{
131 poly p=(poly)data;
132 if (p!=NULL) pSetCompP(p,1);
133 return (void *)p;
134}

◆ iiR2L_l()

static void iiR2L_l ( leftv  out,
leftv  in 
)
static

Definition at line 399 of file ipconv.cc.

400{
401 int add_row_shift = 0;
402 intvec *weights=(intvec*)atGet(in,"isHomog",INTVEC_CMD);
403 if (weights!=NULL) add_row_shift=weights->min_in();
404
405 syStrategy tmp=(syStrategy)in->CopyD();
406
407 out->data=(void *)syConvRes(tmp,TRUE,add_row_shift);
408}
int min_in()
Definition: intvec.h:121
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition: ipshell.cc:3182
ssyStrategy * syStrategy
Definition: syz.h:36

◆ iiS2Link()

static void * iiS2Link ( void *  data)
static

Definition at line 391 of file ipconv.cc.

392{
394 slInit(l, (char *) data);
395 omFree((ADDRESS)data);
396 return (void *)l;
397}
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define omFree(addr)
Definition: omAllocDecl.h:261

◆ iiTestConvert()

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

Definition at line 575 of file ipconv.cc.

576{
577 if ((inputType==outputType)
578 || (outputType==DEF_CMD)
579 || (outputType==IDHDL)
580 || (outputType==ANY_TYPE))
581 {
582 return -1;
583 }
584 if (inputType==UNKNOWN) return 0;
585
586 if ((currRing==NULL) && (outputType>BEGIN_RING) && (outputType<END_RING))
587 return 0;
588 //if ((currRing==NULL) && (outputType==CNUMBER_CMD))
589 // return 0;
590
591 // search the list
592 int i=0;
593 while (dConvertTypes[i].i_typ!=0)
594 {
595 if((dConvertTypes[i].i_typ==inputType)
596 &&(dConvertTypes[i].o_typ==outputType))
597 {
598 //Print("test convert %d to %d (%s -> %s):%d\n",inputType,outputType,
599 //Tok2Cmdname(inputType), Tok2Cmdname(outputType),i+1);
600 return i+1;
601 }
602 i++;
603 }
604 //Print("test convert %d to %d (%s -> %s):0, tested:%d\n",inputType,outputType,
605 // Tok2Cmdname(inputType), Tok2Cmdname(outputType),i);
606 return 0;
607}
#define UNKNOWN
Definition: tok.h:222

◆ iiV2Ma()

static void * iiV2Ma ( void *  data)
static

Definition at line 163 of file ipconv.cc.

164{
165 matrix m=(matrix)idVec2Ideal((poly)data);
166 int h=MATCOLS(m);
167 MATCOLS(m)=MATROWS(m);
168 MATROWS(m)=h;
169 m->rank=h;
170 pDelete((poly *)&data);
171 return (void *)m;
172}
static ideal idVec2Ideal(poly vec)
Definition: ideals.h:169
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