My Project
Loading...
Searching...
No Matches
Functions
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.

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

◆ crString()

char * crString ( coeffs  c)

Definition at line 17 of file number2.cc.

18{
19 if (c==NULL)
20 {
21 return omStrDup("oo");
22 }
23 return omStrDup(nCoeffName(c));
24}
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:960
#define omStrDup(s)
Definition: omAllocDecl.h:263
#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.

89{
90 coeffs c1=(coeffs)a->Data();
91 number i2=(number)b->Data();
92 if (c1->type==n_Z)
93 {
95 mpz_t modBase;
96 nlMPZ(modBase,i2,coeffs_BIGINT);
97 info.base= (mpz_ptr)modBase;
98 info.exp= 1;
99 if (mpz_popcount(modBase)==1) // is a power of 2
100 {
101 // is exponent <=2^(8*sizeof(unsigned long))
102 mp_bitcnt_t l=mpz_scan1 (modBase,0);
103 if ((l>0) && (l<=8*sizeof(unsigned long)))
104 {
105 res->data=(void *) nInitChar(n_Z2m,(void*)(long)l);
106 }
107 else
108 {
109 mpz_set_ui(modBase,2);
110 info.exp= l;
111 res->data=(void *) nInitChar(n_Znm,&info);
112 }
113 mpz_clear(modBase);
114 return FALSE;
115 }
116 res->data=(void *)nInitChar(n_Zn,&info);
117 mpz_clear(modBase);
118 return FALSE;
119 }
120 return TRUE;
121}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int l
Definition: cfEzgcd.cc:100
CanonicalForm b
Definition: cfModGcd.cc:4103
void * Data()
Definition: subexpr.cc:1162
@ n_Znm
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
@ n_Z2m
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:413
CanonicalForm res
Definition: facAbsFact.cc:60
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50
#define info
Definition: libparse.cc:1256
void nlMPZ(mpz_t m, number &n, const coeffs r)
Definition: longrat.cc:2819
The main handler for Singular numbers which are suitable for Singular polynomials.

◆ jjCRING_Zp()

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

Definition at line 35 of file number2.cc.

36{
37 coeffs c1=(coeffs)a->Data();
38 unsigned long i2=(unsigned long)b->Data();
39 if (c1->type==n_Z)
40 {
41 if (i2==(unsigned long)IsPrime(i2))
42 {
43 #ifndef TEST_ZN_AS_ZP
44 res->data=(void *)nInitChar(n_Zp,(void*)i2);
45 #else
47 mpz_t modBase;
48 mpz_init_set_ui(modBase,i2);
49 info.base= modBase;
50 info.exp= 1;
51 res->data=(void *)nInitChar(n_Zn,&info);
52 mpz_clear(modBase);
53 #endif
54 }
55 else
56 {
58 mpz_t modBase;
59 mpz_init_set_ui(modBase,i2);
60 info.base= modBase;
61 info.exp= 1;
62 if (mpz_popcount((mpz_ptr)modBase)==1) // is a power of 2
63 {
64 i2=SI_LOG2(i2);
65 // is exponent <=2^(8*sizeof(unsigned long))
66 if (i2<(8*sizeof(unsigned long)))
67 {
68 mpz_clear(modBase);
69 res->data=(void *) nInitChar(n_Z2m,(void*)i2);
70 return FALSE;
71 }
72 else
73 {
74 mpz_set_ui(modBase,2);
75 info.exp=i2;
76 res->data=(void *) nInitChar(n_Znm,&info);
77 mpz_clear(modBase);
78 return FALSE;
79 }
80 }
81 res->data=(void *)nInitChar(n_Zn,&info);
82 mpz_clear(modBase);
83 }
84 return FALSE;
85 }
86 return TRUE;
87}
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
int IsPrime(int p)
Definition: prime.cc:61
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.

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

◆ jjR2_CR()

BOOLEAN jjR2_CR ( leftv  res,
leftv  a 
)

Definition at line 132 of file number2.cc.

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