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 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
int p
Definition cfModGcd.cc:4086
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)
#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 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}
int i
Definition cfEzgcd.cc:132
#define UNKNOWN
Definition tok.h:224

Variable Documentation

◆ dConvertTypes

const struct sConvertTypes dConvertTypes[]
extern

Definition at line 1322 of file table.h.

1323{
1324// input type output type convert procedure(destr.)/(non-destr.)
1325// int -> bigint
1327// int -> number
1330// int -> poly
1331 { INT_CMD, POLY_CMD, D(iiI2P) , NULL_VAL },
1334// int -> vector
1337// int -> ideal
1340// int -> matrix
1343// int -> intvec
1345// intvec -> intmat
1348// intvec -> matrix
1350// intmat -> bigintmat
1352// intmat -> matrix
1354// bigintvec -> bigintmat
1356// number -> poly
1358// number -> matrix
1360// number -> ideal
1361// number -> vector
1362// number -> module
1363// poly -> number
1364// poly -> ideal
1366// poly -> vector
1368// poly -> matrix
1370// the same for polyBucket:
1374// vector -> module
1376// vector -> matrix
1378// ideal -> module
1380// ideal -> matrix
1382// module -> matrix
1384// matrix -> ideal
1385// matrix -> module
1387// intvec
1388// string -> link
1390// resolution -> list
1392// list -> resolution
1394// matrix -> smatrix
1396// module -> smatrix
1398// smatrix -> matrix
1400// smatrix -> module
1402#ifdef SINGULAR_4_2
1409// { NUMBER_CMD, CPOLY_CMD, D(iiN2CP), NULL_VAL },
1411#endif
1412// end of list
1413 { 0, 0, NULL_VAL , NULL_VAL }
1414};
#define D(A)
Definition gentable.cc:131
#define NULL_VAL
Definition gentable.cc:132
@ IDEAL_CMD
Definition grammar.cc:285
@ MATRIX_CMD
Definition grammar.cc:287
@ BUCKET_CMD
Definition grammar.cc:284
@ BIGINTMAT_CMD
Definition grammar.cc:278
@ INTMAT_CMD
Definition grammar.cc:280
@ MODUL_CMD
Definition grammar.cc:288
@ SMATRIX_CMD
Definition grammar.cc:292
@ RESOLUTION_CMD
Definition grammar.cc:291
@ BIGINTVEC_CMD
Definition grammar.cc:279
static void * iiBI2V(void *data)
Definition ipconv.cc:79
static void * iiP2V(void *data)
Definition ipconv.cc:143
static void iiL2R(leftv out, leftv in)
Definition ipconv.cc:424
static void * iiIm2Ma(void *data)
Definition ipconv.cc:351
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:390
static void * iiN2P(void *data)
Definition ipconv.cc:376
static void * iiV2Ma(void *data)
Definition ipconv.cc:177
static void * iiIV2BIV(void *data)
Definition ipconv.cc:94
static void * iiDummy(void *data)
Definition ipconv.cc:190
static void * iiI2BI(void *data)
Definition ipconv.cc:220
static void * iiP2Id(void *data)
Definition ipconv.cc:164
static void * iiMa2Mo(void *data)
Definition ipconv.cc:201
static void * iiI2Id(void *data)
Definition ipconv.cc:108
static void * iiS2Link(void *data)
Definition ipconv.cc:405
static void * iiI2Iv(void *data)
Definition ipconv.cc:207
static void * iiI2N(void *data)
Definition ipconv.cc:214
static void * iiMo2Ma(void *data)
Definition ipconv.cc:195
static void iiR2L_l(leftv out, leftv in)
Definition ipconv.cc:413
static void * iiI2V(void *data)
Definition ipconv.cc:72
static void * iiIm2Bim(void *data)
Definition ipconv.cc:368
static void * iiBu2Id(void *data)
Definition ipconv.cc:150
static void * iiBu2V(void *data)
Definition ipconv.cc:130
static void * iiBI2Id(void *data)
Definition ipconv.cc:115
static void * iiI2P(void *data)
Definition ipconv.cc:44
static void * iiBI2N(void *data)
Definition ipconv.cc:255
@ 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:187
@ CPOLY_CMD
Definition tok.h:48