My Project  debian-1:4.1.1-p2+ds-4build4
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:55
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:977
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define NULL
Definition: omList.c:10

◆ jjCRING_Zm()

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

Definition at line 78 of file number2.cc.

79 {
80  coeffs c1=(coeffs)a->Data();
81  number i2=(number)b->Data();
82  if (c1->type==n_Z)
83  {
84  ZnmInfo info;
85  mpz_t modBase;
86  mpz_init(modBase);
87  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); // ?
88  info.base= (mpz_ptr)modBase;
89  info.exp= 1;
90  if (mpz_popcount(modBase)==1) // is a power of 2
91  {
92  // is exponent <=2^(8*sizeof(unsigned long))
93  mp_bitcnt_t l=mpz_scan1 (modBase,0);
94  if ((l>0) && (l<=8*sizeof(unsigned long)))
95  {
96  res->data=(void *) nInitChar(n_Z2m,(void*)(long)l);
97  }
98  else
99  {
100  mpz_set_ui(modBase,2);
101  info.exp= l;
102  res->data=(void *) nInitChar(n_Znm,&info);
103  }
104  mpz_clear(modBase);
105  return FALSE;
106  }
107  res->data=(void *)nInitChar(n_Zn,&info);
108  mpz_clear(modBase);
109  return FALSE;
110  }
111  return TRUE;
112 }
#define TRUE
Definition: auxiliary.h:98
#define FALSE
Definition: auxiliary.h:94
int l
Definition: cfEzgcd.cc:93
CanonicalForm b
Definition: cfModGcd.cc:4044
void * Data()
Definition: subexpr.cc:1134
@ n_Znm
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
@ n_Z2m
only used if HAVE_RINGS is defined
Definition: coeffs.h:47
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:349
CanonicalForm res
Definition: facAbsFact.cc:64
const ExtensionInfo & info
< [in] sqrfree poly
coeffs coeffs_BIGINT
Definition: ipid.cc:52
void nlGMP(number &i, mpz_t n, const coeffs r)
Definition: longrat.cc:1478
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  int i2=(int)(long)b->Data();
39  if (c1->type==n_Z)
40  {
41  if (i2==IsPrime(i2))
42  {
43  res->data=(void *)nInitChar(n_Zp,(void*)(long)i2);
44  }
45  else
46  {
47  ZnmInfo info;
48  mpz_t modBase;
49  mpz_init_set_ui(modBase,i2);
50  info.base= modBase;
51  info.exp= 1;
52  if (mpz_popcount((mpz_ptr)modBase)==1) // is a power of 2
53  {
54  i2=SI_LOG2(i2);
55  // is exponent <=2^(8*sizeof(unsigned long))
56  if (i2<(8*sizeof(unsigned long)))
57  {
58  mpz_clear(modBase);
59  res->data=(void *) nInitChar(n_Z2m,(void*)(long)i2);
60  return FALSE;
61  }
62  else
63  {
64  mpz_set_ui(modBase,2);
65  info.exp=i2;
66  res->data=(void *) nInitChar(n_Znm,&info);
67  mpz_clear(modBase);
68  return FALSE;
69  }
70  }
71  res->data=(void *)nInitChar(n_Zn,&info);
72  mpz_clear(modBase);
73  }
74  return FALSE;
75  }
76  return TRUE;
77 }
static int SI_LOG2(int v)
Definition: auxiliary.h:119
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:30
int IsPrime(int p)
Definition: prime.cc:61

◆ jjEQUAL_CR()

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

Definition at line 114 of file number2.cc.

115 {
116  coeffs a2=(coeffs)a->Data();
117  coeffs b2=(coeffs)b->Data();
118  res->data=(void*)(long)(a2==b2);
119  return FALSE;
120 }

◆ jjR2_CR()

BOOLEAN jjR2_CR ( leftv  res,
leftv  a 
)

Definition at line 122 of file number2.cc.

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