My Project  UNKNOWN_GIT_VERSION
Functions
number2.cc File Reference
#include "kernel/mod2.h"
#include "reporter/reporter.h"
#include "coeffs/numbers.h"
#include "coeffs/rmodulon.h"
#include "coeffs/bigintmat.h"
#include "coeffs/longrat.h"
#include "polys/ext_fields/algext.h"
#include "misc/prime.h"
#include "Singular/blackbox.h"
#include "Singular/ipshell.h"
#include "Singular/ipconv.h"
#include "Singular/ipid.h"
#include "Singular/number2.h"

Go to the source code of this file.

Functions

char * crString (coeffs c)
 
void crPrint (coeffs c)
 
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)
 
BOOLEAN jjR2_CR (leftv res, leftv a)
 

Function Documentation

◆ crPrint()

void crPrint ( coeffs  c)

Definition at line 25 of file number2.cc.

26 {
27  char *s=crString(c);
28  PrintS(s);
29  omFree(s);
30 }

◆ 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 }

◆ 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  {
94  ZnmInfo info;
95  mpz_t modBase;
96  mpz_init(modBase);
97  nlGMP(i2,modBase,coeffs_BIGINT); // FIXME? TODO? // extern void nlGMP(number &i, mpz_t n, const coeffs r); // to be replaced with n_MPZ(modBase,i2,coeffs_BIGINT); // ?
98  info.base= (mpz_ptr)modBase;
99  info.exp= 1;
100  if (mpz_popcount(modBase)==1) // is a power of 2
101  {
102  // is exponent <=2^(8*sizeof(unsigned long))
103  mp_bitcnt_t l=mpz_scan1 (modBase,0);
104  if ((l>0) && (l<=8*sizeof(unsigned long)))
105  {
106  res->data=(void *) nInitChar(n_Z2m,(void*)(long)l);
107  }
108  else
109  {
110  mpz_set_ui(modBase,2);
111  info.exp= l;
112  res->data=(void *) nInitChar(n_Znm,&info);
113  }
114  mpz_clear(modBase);
115  return FALSE;
116  }
117  res->data=(void *)nInitChar(n_Zn,&info);
118  mpz_clear(modBase);
119  return FALSE;
120  }
121  return TRUE;
122 }

◆ 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  long i2=(long)b->Data();
39  if (c1->type==n_Z)
40  {
41  if (i2==IsPrime(i2))
42  {
43  #ifndef TEST_ZN_AS_ZP
44  res->data=(void *)nInitChar(n_Zp,(void*)i2);
45  #else
46  ZnmInfo info;
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  {
57  ZnmInfo info;
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 }

◆ jjEQUAL_CR()

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

Definition at line 124 of file number2.cc.

125 {
126  coeffs a2=(coeffs)a->Data();
127  coeffs b2=(coeffs)b->Data();
128  res->data=(void*)(long)(a2==b2);
129  return FALSE;
130 }

◆ 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 }
FALSE
#define FALSE
Definition: auxiliary.h:94
n_Zn
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
sleftv::Data
void * Data()
Definition: subexpr.cc:1182
IsPrime
int IsPrime(int p)
Definition: prime.cc:61
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
n_Z2m
@ n_Z2m
only used if HAVE_RINGS is defined
Definition: coeffs.h:47
SI_LOG2
static int SI_LOG2(int v)
Definition: auxiliary.h:119
cf
CanonicalForm cf
Definition: cfModGcd.cc:4024
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:350
n_Znm
@ n_Znm
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
b
CanonicalForm b
Definition: cfModGcd.cc:4044
TRUE
#define TRUE
Definition: auxiliary.h:98
AlgExtInfo
struct for passing initialization parameters to naInitChar
Definition: algext.h:37
res
CanonicalForm res
Definition: facAbsFact.cc:64
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
coeffs
n_Z
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
crString
char * crString(coeffs c)
Definition: number2.cc:17
n_transExt
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
coeffs_BIGINT
coeffs coeffs_BIGINT
Definition: ipid.cc:52
n_Zp
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:30
NULL
#define NULL
Definition: omList.c:10
nCoeffName
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:985
l
int l
Definition: cfEzgcd.cc:93
ZnmInfo
Definition: rmodulon.h:18
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
AlgExtInfo::r
ring r
Definition: algext.h:39
info
const ExtensionInfo & info
< [in] sqrfree poly
Definition: facFqFactorize.h:38
nlGMP
void nlGMP(number &i, mpz_t n, const coeffs r)
Definition: longrat.cc:1478