Loading...
Searching...
No Matches
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 450 of file ipconv.cc.

{
output->Init();
if ((inputType==outputType)
|| (outputType==DEF_CMD)
|| ((outputType==IDHDL)&&(input->rtyp==IDHDL)))
{
memcpy(output,input,sizeof(*output));
input->Init();
return FALSE;
}
else if (outputType==ANY_TYPE)
{
output->rtyp=ANY_TYPE;
output->data=(char *)(long)input->Typ();
/* the name of the object:*/
if (input->e==NULL)
{
if (input->rtyp==IDHDL)
/* preserve name: copy it */
output->name=omStrDup(IDID((idhdl)(input->data)));
else if (input->name!=NULL)
{
if (input->rtyp==ALIAS_CMD)
output->name=omStrDup(input->name);
else
{
output->name=input->name;
input->name=NULL;
}
}
else if ((input->rtyp==POLY_CMD) && (input->name==NULL))
{
if (input->data!=NULL)
{
int nr=pIsPurePower((poly)input->data);
if (nr!=0)
{
if (pGetExp((poly)input->data,nr)==1)
{
output->name=omStrDup(currRing->names[nr-1]);
}
else
{
char *tmp=(char *)omAlloc(8);
snprintf(tmp,8,"%c%d",*(currRing->names[nr-1]),
(int)pGetExp((poly)input->data,nr));
output->name=tmp;
}
}
else if(pIsConstant((poly)input->data))
{
StringSetS("");
number n=(pGetCoeff((poly)input->data));
n_Write(n, currRing->cf);
(pGetCoeff((poly)input->data))=n; // n_Write may have changed n
output->name=StringEndS();
}
}
}
else if ((input->rtyp==NUMBER_CMD) && (input->name==NULL))
{
StringSetS("");
number n=(number)input->data;
n_Write(n, currRing->cf);
input->data=(void*)n; // n_Write may have changed n
output->name=StringEndS();
}
else
{
/* no need to preserve name: use it */
output->name=input->name;
input->name=NULL;
}
}
output->next=input->next;
input->next=NULL;
if (!errorreported) input->CleanUp();
return errorreported;
}
if (index!=0) /* iiTestConvert does not returned 'failure' */
{
index--;
if((dConvertTypes[index].i_typ==inputType)
&&(dConvertTypes[index].o_typ==outputType))
{
if(traceit&TRACE_CONV)
{
Print("automatic conversion %s -> %s\n",
Tok2Cmdname(inputType),Tok2Cmdname(outputType));
}
if ((currRing==NULL) && (outputType>BEGIN_RING) && (outputType<END_RING))
return TRUE;
output->rtyp=outputType;
if (dConvertTypes[index].p!=NULL)
{
output->data=dConvertTypes[index].p(input->CopyD());
}
else
{
dConvertTypes[index].pl(output,input);
}
if ((output->data==NULL)
&& ((outputType!=INT_CMD)
&&(outputType!=POLY_CMD)
&&(outputType!=VECTOR_CMD)
&&(outputType!=NUMBER_CMD)))
{
return TRUE;
}
if (errorreported) return TRUE;
output->next=input->next;
input->next=NULL;
if ((input->rtyp!=IDHDL) && (input->attribute!=NULL))
{
input->attribute->killAll(currRing);
input->attribute=NULL;
}
if (input->e!=NULL)
{
Subexpr h;
while (input->e!=NULL)
{
h=input->e->next;
omFreeBin((ADDRESS)input->e, sSubexpr_bin);
input->e=h;
}
}
//input->Init(); // seems that input (rtyp?) is still needed
return FALSE;
}
}
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
p
int p
Definition cfModGcd.cc:4086
sattr::killAll
void killAll(const ring r)
Definition attrib.cc:189
sleftv::CopyD
void * CopyD(int t)
Definition subexpr.cc:714
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
sleftv::name
const char * name
Definition subexpr.h:87
sleftv::rtyp
int rtyp
Definition subexpr.h:91
sleftv::Init
void Init()
Definition subexpr.h:107
sleftv::next
leftv next
Definition subexpr.h:86
sleftv::data
void * data
Definition subexpr.h:88
sleftv::CleanUp
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
sleftv::e
Subexpr e
Definition subexpr.h:105
sleftv::attribute
attr attribute
Definition subexpr.h:89
n_Write
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:594
Print
#define Print
Definition emacs.cc:80
errorreported
VAR short errorreported
Definition feFopen.cc:23
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
END_RING
@ END_RING
Definition grammar.cc:311
BEGIN_RING
@ BEGIN_RING
Definition grammar.cc:283
VECTOR_CMD
@ VECTOR_CMD
Definition grammar.cc:293
NUMBER_CMD
@ NUMBER_CMD
Definition grammar.cc:289
POLY_CMD
@ POLY_CMD
Definition grammar.cc:290
dConvertTypes
const struct sConvertTypes dConvertTypes[]
Definition table.h:1321
IDID
#define IDID(a)
Definition ipid.h:122
h
STATIC_VAR Poly * h
Definition janet.cc:971
pGetCoeff
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
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259
NULL
#define NULL
Definition omList.c:12
index
static int index(p_Length length, p_Ord ord)
Definition p_Procs_Impl.h:592
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
pIsConstant
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239
pGetExp
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
pIsPurePower
#define pIsPurePower(p)
Definition polys.h:249
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
StringEndS
char * StringEndS()
Definition reporter.cc:151
traceit
EXTERN_VAR int traceit
Definition reporter.h:24
TRACE_CONV
#define TRACE_CONV
Definition reporter.h:48
idhdl
idrec * idhdl
Definition ring.h:22
sSubexpr_bin
VAR omBin sSubexpr_bin
Definition subexpr.cc:40
IDHDL
#define IDHDL
Definition tok.h:31
ALIAS_CMD
@ ALIAS_CMD
Definition tok.h:34
DEF_CMD
@ DEF_CMD
Definition tok.h:58
INT_CMD
@ INT_CMD
Definition tok.h:96
ANY_TYPE
#define ANY_TYPE
Definition tok.h:30

## iiTestConvert()

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

Definition at line 590 of file ipconv.cc.

{
if ((inputType==outputType)
|| (outputType==DEF_CMD)
|| (outputType==IDHDL)
|| (outputType==ANY_TYPE))
{
return -1;
}
if (inputType==UNKNOWN) return 0;
if ((currRing==NULL) && (outputType>BEGIN_RING) && (outputType<END_RING))
return 0;
//if ((currRing==NULL) && (outputType==CNUMBER_CMD))
// return 0;
// search the list
int i=0;
while (dConvertTypes[i].i_typ!=0)
{
if((dConvertTypes[i].i_typ==inputType)
&&(dConvertTypes[i].o_typ==outputType))
{
//Print("test convert %d to %d (%s -> %s):%d\n",inputType,outputType,
//Tok2Cmdname(inputType), Tok2Cmdname(outputType),i+1);
return i+1;
}
i++;
}
//Print("test convert %d to %d (%s -> %s):0, tested:%d\n",inputType,outputType,
// Tok2Cmdname(inputType), Tok2Cmdname(outputType),i);
return 0;
}
i
int i
Definition cfEzgcd.cc:132
UNKNOWN
#define UNKNOWN
Definition tok.h:224

## Variable Documentation

## dConvertTypes

const struct sConvertTypes dConvertTypes[]

extern

Definition at line 1321 of file table.h.

{
// input type output type convert procedure(destr.)/(non-destr.)
// int -> bigint
{ INT_CMD, BIGINT_CMD, D(iiI2BI) , NULL_VAL },
{ INT_CMD, BIGINTVEC_CMD, D(iiI2BIV) , NULL_VAL },
// int -> number
{ INT_CMD, NUMBER_CMD, D(iiI2N) , NULL_VAL },
{ BIGINT_CMD, NUMBER_CMD, D(iiBI2N) , NULL_VAL },
// int -> poly
{ INT_CMD, POLY_CMD, D(iiI2P) , NULL_VAL },
{ BIGINT_CMD, POLY_CMD, D(iiBI2P) , NULL_VAL },
{ BUCKET_CMD, POLY_CMD, NULL_VAL, D(iiBu2P) },
// int -> vector
{ INT_CMD, VECTOR_CMD, D(iiI2V) , NULL_VAL },
{ BIGINT_CMD, VECTOR_CMD, D(iiBI2V) , NULL_VAL },
// int -> ideal
{ INT_CMD, IDEAL_CMD, D(iiI2Id) , NULL_VAL },
{ BIGINT_CMD, IDEAL_CMD, D(iiBI2Id) , NULL_VAL },
// int -> matrix
{ INT_CMD, MATRIX_CMD, D(iiI2Id) , NULL_VAL },
{ BIGINT_CMD, MATRIX_CMD, D(iiBI2Id) , NULL_VAL },
// int -> intvec
{ INT_CMD, INTVEC_CMD, D(iiI2Iv) , NULL_VAL },
// intvec -> intmat
{ INTVEC_CMD, INTMAT_CMD, D(iiDummy), NULL_VAL },
{ INTVEC_CMD, BIGINTVEC_CMD, D(iiIV2BIV), NULL_VAL },
// intvec -> matrix
{ INTVEC_CMD, MATRIX_CMD, D(iiIm2Ma) , NULL_VAL },
// intmat -> bigintmat
{ INTMAT_CMD, BIGINTMAT_CMD, D(iiIm2Bim) , NULL_VAL },
// intmat -> matrix
{ INTMAT_CMD, MATRIX_CMD, D(iiIm2Ma) , NULL_VAL },
// bigintvec -> bigintmat
{ BIGINTVEC_CMD, BIGINTMAT_CMD, D(iiDummy) , NULL_VAL },
// number -> poly
{ NUMBER_CMD, POLY_CMD, D(iiN2P) , NULL_VAL },
// number -> matrix
{ NUMBER_CMD, MATRIX_CMD, D(iiN2Ma) , NULL_VAL },
// number -> ideal
// number -> vector
// number -> module
// poly -> number
// poly -> ideal
{ POLY_CMD, IDEAL_CMD, D(iiP2Id) , NULL_VAL },
// poly -> vector
{ POLY_CMD, VECTOR_CMD, D(iiP2V) , NULL_VAL },
// poly -> matrix
{ POLY_CMD, MATRIX_CMD, D(iiP2Id) , NULL_VAL },
// the same for polyBucket:
{ BUCKET_CMD, IDEAL_CMD, D(iiBu2Id) , NULL_VAL },
{ BUCKET_CMD, VECTOR_CMD, D(iiBu2V) , NULL_VAL },
{ BUCKET_CMD, MATRIX_CMD, D(iiBu2Id) , NULL_VAL },
// vector -> module
{ VECTOR_CMD, MODUL_CMD, D(iiP2Id) , NULL_VAL },
// vector -> matrix
{ VECTOR_CMD, MATRIX_CMD, D(iiV2Ma) , NULL_VAL },
// ideal -> module
{ IDEAL_CMD, MODUL_CMD, D(iiMa2Mo) , NULL_VAL },
// ideal -> matrix
{ IDEAL_CMD, MATRIX_CMD, D(iiDummy) , NULL_VAL },
// module -> matrix
{ MODUL_CMD, MATRIX_CMD, D(iiMo2Ma) , NULL_VAL },
// matrix -> ideal
// matrix -> module
{ MATRIX_CMD, MODUL_CMD, D(iiMa2Mo) , NULL_VAL },
// intvec
// string -> link
{ STRING_CMD, LINK_CMD, D(iiS2Link) , NULL_VAL },
// resolution -> list
{ RESOLUTION_CMD, LIST_CMD, NULL_VAL , D(iiR2L_l) },
// list -> resolution
{ LIST_CMD, RESOLUTION_CMD, NULL_VAL , D(iiL2R) },
// matrix -> smatrix
{ MATRIX_CMD, SMATRIX_CMD, D(iiMa2Mo), NULL_VAL },
// module -> smatrix
{ MODUL_CMD, SMATRIX_CMD, D(iiDummy), NULL_VAL },
// smatrix -> matrix
{ SMATRIX_CMD, MATRIX_CMD, D(iiMo2Ma) , NULL_VAL },
// smatrix -> module
{ SMATRIX_CMD, MODUL_CMD, D(iiDummy) , NULL_VAL },
#ifdef SINGULAR_4_2
{ INT_CMD, CNUMBER_CMD, D(iiI2NN) , NULL_VAL },
{ BIGINT_CMD, CNUMBER_CMD, D(iiBI2NN) , NULL_VAL },
{ CNUMBER_CMD, NUMBER_CMD, D(iiNN2N) , NULL_VAL },
{ CNUMBER_CMD, POLY_CMD, D(iiNN2P) , NULL_VAL },
{ INT_CMD, CPOLY_CMD, D(iiI2CP), NULL_VAL },
{ BIGINT_CMD, CPOLY_CMD, D(iiBI2CP), NULL_VAL },
// { NUMBER_CMD, CPOLY_CMD, D(iiN2CP), NULL_VAL },
{ POLY_CMD, CPOLY_CMD, D(iiP2CP), NULL_VAL },
#endif
// end of list
{ 0, 0, NULL_VAL , NULL_VAL }
};
D
#define D(A)
Definition gentable.cc:128
NULL_VAL
#define NULL_VAL
Definition gentable.cc:129
IDEAL_CMD
@ IDEAL_CMD
Definition grammar.cc:285
MATRIX_CMD
@ MATRIX_CMD
Definition grammar.cc:287
BUCKET_CMD
@ BUCKET_CMD
Definition grammar.cc:284
BIGINTMAT_CMD
@ BIGINTMAT_CMD
Definition grammar.cc:278
INTMAT_CMD
@ INTMAT_CMD
Definition grammar.cc:280
MODUL_CMD
@ MODUL_CMD
Definition grammar.cc:288
SMATRIX_CMD
@ SMATRIX_CMD
Definition grammar.cc:292
RESOLUTION_CMD
@ RESOLUTION_CMD
Definition grammar.cc:291
BIGINTVEC_CMD
@ BIGINTVEC_CMD
Definition grammar.cc:279
iiBI2V
static void * iiBI2V(void *data)
Definition ipconv.cc:79
iiP2V
static void * iiP2V(void *data)
Definition ipconv.cc:136
iiL2R
static void iiL2R(leftv out, leftv in)
Definition ipconv.cc:425
iiIm2Ma
static void * iiIm2Ma(void *data)
Definition ipconv.cc:352
iiBI2P
static void * iiBI2P(void *data)
Definition ipconv.cc:50
iiBu2P
static void iiBu2P(leftv out, leftv in)
Definition ipconv.cc:64
iiN2Ma
static void * iiN2Ma(void *data)
Definition ipconv.cc:391
iiN2P
static void * iiN2P(void *data)
Definition ipconv.cc:377
iiV2Ma
static void * iiV2Ma(void *data)
Definition ipconv.cc:170
iiIV2BIV
static void * iiIV2BIV(void *data)
Definition ipconv.cc:94
iiDummy
static void * iiDummy(void *data)
Definition ipconv.cc:183
iiI2BI
static void * iiI2BI(void *data)
Definition ipconv.cc:213
iiP2Id
static void * iiP2Id(void *data)
Definition ipconv.cc:157
iiMa2Mo
static void * iiMa2Mo(void *data)
Definition ipconv.cc:194
iiI2Id
static void * iiI2Id(void *data)
Definition ipconv.cc:101
iiS2Link
static void * iiS2Link(void *data)
Definition ipconv.cc:406
iiI2Iv
static void * iiI2Iv(void *data)
Definition ipconv.cc:200
iiI2N
static void * iiI2N(void *data)
Definition ipconv.cc:207
iiMo2Ma
static void * iiMo2Ma(void *data)
Definition ipconv.cc:188
iiR2L_l
static void iiR2L_l(leftv out, leftv in)
Definition ipconv.cc:414
iiI2V
static void * iiI2V(void *data)
Definition ipconv.cc:72
iiIm2Bim
static void * iiIm2Bim(void *data)
Definition ipconv.cc:369
iiI2BIV
static void * iiI2BIV(void *data)
Definition ipconv.cc:219
iiBu2Id
static void * iiBu2Id(void *data)
Definition ipconv.cc:143
iiBu2V
static void * iiBu2V(void *data)
Definition ipconv.cc:123
iiBI2Id
static void * iiBI2Id(void *data)
Definition ipconv.cc:108
iiI2P
static void * iiI2P(void *data)
Definition ipconv.cc:44
iiBI2N
static void * iiBI2N(void *data)
Definition ipconv.cc:256
BIGINT_CMD
@ BIGINT_CMD
Definition tok.h:38
LIST_CMD
@ LIST_CMD
Definition tok.h:118
INTVEC_CMD
@ INTVEC_CMD
Definition tok.h:101
CNUMBER_CMD
@ CNUMBER_CMD
Definition tok.h:47
LINK_CMD
@ LINK_CMD
Definition tok.h:117
STRING_CMD
@ STRING_CMD
Definition tok.h:187
CPOLY_CMD
@ CPOLY_CMD
Definition tok.h:48