Loading...
Searching...
No Matches
number2.h File Reference
`#include "kernel/mod2.h"`
`#include "omalloc/omalloc.h"`
`#include "coeffs/coeffs.h"`
`#include "kernel/structs.h"`

Go to the source code of this file.

## Functions

char * | crString (coeffs c)
void | crPrint (coeffs cf)
BOOLEAN | jjR2_CR (leftv res, leftv a)
BOOLEAN | jjCRING_Zp (leftv res, leftv a, leftv b)
BOOLEAN | jjCRING_Zm (leftv res, leftv a, leftv b)
BOOLEAN | jjEQUAL_CR (leftv res, leftv a, leftv b)

## Function Documentation

## crPrint()

void crPrint | ( | coeffs | cf | ) |

Definition at line 25 of file number2.cc.

{
char *s=crString(c);
PrintS(s);
omFree(s);
}
s
const CanonicalForm int s
Definition facAbsFact.cc:51
crString
char * crString(coeffs c)
Definition number2.cc:17
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## crString()

char * crString | ( | coeffs | c | ) |

Definition at line 17 of file number2.cc.

{
if (c==NULL)
{
return omStrDup("oo");
}
return omStrDup(nCoeffName(c));
}
nCoeffName
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:962
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
NULL
#define NULL
Definition omList.c:12

## jjCRING_Zm()

BOOLEAN jjCRING_Zm | ( | leftv | res,
|  | leftv | a,
|  | leftv | b )

Definition at line 88 of file number2.cc.

{
coeffs c1=(coeffs)a->Data();
number i2=(number)b->Data();
if (c1->type==n_Z)
{
ZnmInfo info;
mpz_t modBase;
nlMPZ(modBase,i2,coeffs_BIGINT);
info.base= (mpz_ptr)modBase;
info.exp= 1;
if (mpz_popcount(modBase)==1) // is a power of 2
{
// is exponent <=2^(8*sizeof(unsigned long))
mp_bitcnt_t l=mpz_scan1 (modBase,0);
if ((l>0) && (l<=8*sizeof(unsigned long)))
{
res->data=(void *) nInitChar(n_Z2m,(void*)(long)l);
}
else
{
mpz_set_ui(modBase,2);
info.exp= l;
res->data=(void *) nInitChar(n_Znm,&info);
}
mpz_clear(modBase);
return FALSE;
}
res->data=(void *)nInitChar(n_Zn,&info);
mpz_clear(modBase);
return FALSE;
}
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
l
int l
Definition cfEzgcd.cc:100
b
CanonicalForm b
Definition cfModGcd.cc:4111
sleftv::Data
void * Data()
Definition subexpr.cc:1192
n_Znm
@ n_Znm
only used if HAVE_RINGS is defined
Definition coeffs.h:45
n_Zn
@ n_Zn
only used if HAVE_RINGS is defined
Definition coeffs.h:44
n_Z2m
@ n_Z2m
only used if HAVE_RINGS is defined
Definition coeffs.h:46
n_Z
@ n_Z
only used if HAVE_RINGS is defined
Definition coeffs.h:43
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
res
CanonicalForm res
Definition facAbsFact.cc:60
info
#define info
Definition libparse.cc:1256
nlMPZ
void nlMPZ(mpz_t m, number &n, const coeffs r)
get numerator as mpz_t
Definition longrat.cc:2790
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
coeffs_BIGINT
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
ZnmInfo
Definition rmodulon.h:17

## jjCRING_Zp()

BOOLEAN jjCRING_Zp | ( | leftv | res,
|  | leftv | a,
|  | leftv | b )

Definition at line 35 of file number2.cc.

{
coeffs c1=(coeffs)a->Data();
unsigned long i2=(unsigned long)b->Data();
if (c1->type==n_Z)
{
if (i2==(unsigned long)IsPrime(i2))
{
#ifndef TEST_ZN_AS_ZP
res->data=(void *)nInitChar(n_Zp,(void*)i2);
#else
ZnmInfo info;
mpz_t modBase;
mpz_init_set_ui(modBase,i2);
info.base= modBase;
info.exp= 1;
res->data=(void *)nInitChar(n_Zn,&info);
mpz_clear(modBase);
#endif
}
else
{
ZnmInfo info;
mpz_t modBase;
mpz_init_set_ui(modBase,i2);
info.base= modBase;
info.exp= 1;
if (mpz_popcount((mpz_ptr)modBase)==1) // is a power of 2
{
i2=SI_LOG2(i2);
// is exponent <=2^(8*sizeof(unsigned long))
if (i2<(8*sizeof(unsigned long)))
{
mpz_clear(modBase);
res->data=(void *) nInitChar(n_Z2m,(void*)i2);
return FALSE;
}
else
{
mpz_set_ui(modBase,2);
info.exp=i2;
res->data=(void *) nInitChar(n_Znm,&info);
mpz_clear(modBase);
return FALSE;
}
}
res->data=(void *)nInitChar(n_Zn,&info);
mpz_clear(modBase);
}
return FALSE;
}
return TRUE;
}
n_Zp
@ n_Zp
\F{p < 2^31}
Definition coeffs.h:29
IsPrime
int IsPrime(int p)
Definition prime.cc:61
SI_LOG2
static int SI_LOG2(int v)
Definition si_log2.h:6

## jjEQUAL_CR()

BOOLEAN jjEQUAL_CR | ( | leftv | res,
|  | leftv | a,
|  | leftv | b )

Definition at line 123 of file number2.cc.

{
coeffs a2=(coeffs)a->Data();
coeffs b2=(coeffs)b->Data();
res->data=(void*)(long)(a2==b2);
if (iiOp==NOTEQUAL) res->data=(char *)(!(long)res->data);
return FALSE;
}
NOTEQUAL
@ NOTEQUAL
Definition grammar.cc:273
iiOp
VAR int iiOp
Definition iparith.cc:219

## jjR2_CR()

BOOLEAN jjR2_CR | ( | leftv | res,
|  | leftv | a )

Definition at line 132 of file number2.cc.

{
ring r=(ring)a->Data();
AlgExtInfo extParam;
extParam.r = r;
coeffs cf=nInitChar(n_transExt,&extParam);
res->data=(void*)cf;
return FALSE;
}
AlgExtInfo::r
ring r
Definition algext.h:37
AlgExtInfo
struct for passing initialization parameters to naInitChar
Definition algext.h:37
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
n_transExt
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition coeffs.h:38