MCPcopy Create free account
hub / github.com/Singular/Singular / iiConvert

Function iiConvert

Singular/ipconv.cc:457–591  ·  view source on GitHub ↗

2 * try to convert 'input' of type 'inputType' to 'output' of type 'outputType' * return FALSE on success */

Source from the content-addressed store, hash-verified

455* return FALSE on success
456*/
457BOOLEAN iiConvert (int inputType, int outputType, int index, leftv input, leftv output,const struct sConvertTypes *dConvertTypes)
458{
459 output->Init();
460 if ((inputType==outputType)
461 || (outputType==DEF_CMD)
462 || ((outputType==IDHDL)&&(input->rtyp==IDHDL)))
463 {
464 memcpy(output,input,sizeof(*output));
465 input->Init();
466 return FALSE;
467 }
468 else if (outputType==ANY_TYPE)
469 {
470 output->rtyp=ANY_TYPE;
471 output->data=(char *)(long)input->Typ();
472 /* the name of the object:*/
473 if (input->e==NULL)
474 {
475 if (input->rtyp==IDHDL)
476 /* preserve name: copy it */
477 output->name=omStrDup(IDID((idhdl)(input->data)));
478 else if (input->name!=NULL)
479 {
480 if (input->rtyp==ALIAS_CMD)
481 output->name=omStrDup(input->name);
482 else
483 {
484 output->name=input->name;
485 input->name=NULL;
486 }
487 }
488 else if ((input->rtyp==POLY_CMD) && (input->name==NULL))
489 {
490 if (input->data!=NULL)
491 {
492 int nr=pIsPurePower((poly)input->data);
493 if (nr!=0)
494 {
495 if (pGetExp((poly)input->data,nr)==1)
496 {
497 output->name=omStrDup(currRing->names[nr-1]);
498 }
499 else
500 {
501 char *tmp=(char *)omAlloc(8);
502 snprintf(tmp,8,"%c%d",*(currRing->names[nr-1]),
503 (int)pGetExp((poly)input->data,nr));
504 output->name=tmp;
505 }
506 }
507 else if(pIsConstant((poly)input->data))
508 {
509 StringSetS("");
510 number n=(pGetCoeff((poly)input->data));
511 n_Write(n, currRing->cf);
512 (pGetCoeff((poly)input->data))=n; // n_Write may have changed n
513 output->name=StringEndS();
514 }

Callers 15

jjNUMBER2_OP2Function · 0.85
jjPOLY2_OP2Function · 0.85
jjTENSOR_MaFunction · 0.85
jjMINOR_MFunction · 0.85
jjSUBST_Id_XFunction · 0.85
jjDIVISION4Function · 0.85
jjIDEAL_PLFunction · 0.85
jjINTERSECT_PLFunction · 0.85
iiExprArith2TabInternFunction · 0.85
iiExprArith1TabFunction · 0.85
iiExprArith3TabInternFunction · 0.85
jiAssign_1Function · 0.85

Calls 11

StringSetSFunction · 0.85
n_WriteFunction · 0.85
StringEndSFunction · 0.85
omFreeBinFunction · 0.85
CleanUpMethod · 0.80
killAllMethod · 0.80
Tok2CmdnameFunction · 0.70
PrintFunction · 0.50
InitMethod · 0.45
TypMethod · 0.45
CopyDMethod · 0.45

Tested by

no test coverage detected