My Project
Loading...
Searching...
No Matches
Functions | Variables
ipconv.h File Reference
#include "kernel/structs.h"

Go to the source code of this file.

Functions

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

Variables

const struct sConvertTypes dConvertTypes []
 

Function Documentation

◆ iiConvert()

BOOLEAN iiConvert ( int  inputType,
int  outputType,
int  index,
leftv  input,
leftv  output,
const struct sConvertTypes dCT = 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",
526 }
528 return TRUE;
529 output->rtyp=outputType;
531 {
532 output->data=dConvertTypes[index].p(input->CopyD());
533 }
534 else
535 {
537 }
538 if ((output->data==NULL)
539 && ((outputType!=INT_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
int p
Definition cfModGcd.cc:4079
Definition idrec.h:35
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:1287
#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)
#define NULL
Definition omList.c:12
static int index(p_Length length, p_Ord ord)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#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

◆ iiTestConvert()

int iiTestConvert ( int  inputType,
int  outputType,
const struct sConvertTypes dCT = 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
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}
int i
Definition cfEzgcd.cc:132
#define UNKNOWN
Definition tok.h:222

Variable Documentation

◆ dConvertTypes

const struct sConvertTypes dConvertTypes[]
extern

Definition at line 1287 of file table.h.

1288{
1289// input type output type convert procedure(destr.)/(non-destr.)
1290// int -> bigint
1292// int -> number
1295// int -> poly
1296 { INT_CMD, POLY_CMD, D(iiI2P) , NULL_VAL },
1299// int -> vector
1302// int -> ideal
1305// int -> matrix
1308// int -> intvec
1310// intvec -> intmat
1312// intvec -> matrix
1314// intmat -> bigintmat
1316// intmat -> matrix
1318// number -> poly
1320// number -> matrix
1322// number -> ideal
1323// number -> vector
1324// number -> module
1325// poly -> number
1326// poly -> ideal
1328// poly -> vector
1330// poly -> matrix
1332// the same for polyBucket:
1336// vector -> module
1338// vector -> matrix
1340// ideal -> module
1342// ideal -> matrix
1344// module -> matrix
1346// matrix -> ideal
1347// matrix -> module
1349// intvec
1350// string -> link
1352// resolution -> list
1354// list -> resolution
1356// matrix -> smatrix
1358// module -> smatrix
1360// smatrix -> matrix
1362// smatrix -> module
1364#ifdef SINGULAR_4_2
1371// { NUMBER_CMD, CPOLY_CMD, D(iiN2CP), NULL_VAL },
1373#endif
1374// end of list
1375 { 0, 0, NULL_VAL , NULL_VAL }
1376};
#define D(A)
Definition gentable.cc:131
#define NULL_VAL
Definition gentable.cc:132
@ IDEAL_CMD
Definition grammar.cc:284
@ MATRIX_CMD
Definition grammar.cc:286
@ BUCKET_CMD
Definition grammar.cc:283
@ BIGINTMAT_CMD
Definition grammar.cc:278
@ INTMAT_CMD
Definition grammar.cc:279
@ MODUL_CMD
Definition grammar.cc:287
@ SMATRIX_CMD
Definition grammar.cc:291
@ RESOLUTION_CMD
Definition grammar.cc:290
static void * iiBI2V(void *data)
Definition ipconv.cc:79
static void * iiP2V(void *data)
Definition ipconv.cc:129
static void iiL2R(leftv out, leftv in)
Definition ipconv.cc:410
static void * iiIm2Ma(void *data)
Definition ipconv.cc:337
static void * iiBI2P(void *data)
Definition ipconv.cc:50
static void iiBu2P(leftv out, leftv in)
Definition ipconv.cc:64
static void * iiN2Ma(void *data)
Definition ipconv.cc:376
static void * iiN2P(void *data)
Definition ipconv.cc:362
static void * iiV2Ma(void *data)
Definition ipconv.cc:163
static void * iiDummy(void *data)
Definition ipconv.cc:176
static void * iiI2BI(void *data)
Definition ipconv.cc:206
static void * iiP2Id(void *data)
Definition ipconv.cc:150
static void * iiMa2Mo(void *data)
Definition ipconv.cc:187
static void * iiI2Id(void *data)
Definition ipconv.cc:94
static void * iiS2Link(void *data)
Definition ipconv.cc:391
static void * iiI2Iv(void *data)
Definition ipconv.cc:193
static void * iiI2N(void *data)
Definition ipconv.cc:200
static void * iiMo2Ma(void *data)
Definition ipconv.cc:181
static void iiR2L_l(leftv out, leftv in)
Definition ipconv.cc:399
static void * iiI2V(void *data)
Definition ipconv.cc:72
static void * iiIm2Bim(void *data)
Definition ipconv.cc:354
static void * iiBu2Id(void *data)
Definition ipconv.cc:136
static void * iiBu2V(void *data)
Definition ipconv.cc:116
static void * iiBI2Id(void *data)
Definition ipconv.cc:101
static void * iiI2P(void *data)
Definition ipconv.cc:44
static void * iiBI2N(void *data)
Definition ipconv.cc:241
@ BIGINT_CMD
Definition tok.h:38
@ LIST_CMD
Definition tok.h:118
@ INTVEC_CMD
Definition tok.h:101
@ CNUMBER_CMD
Definition tok.h:47
@ LINK_CMD
Definition tok.h:117
@ STRING_CMD
Definition tok.h:185
@ CPOLY_CMD
Definition tok.h:48