Macros | Functions | Variables
longrat0.cc File Reference
#include <stdio.h>
#include <string.h>
#include <misc/auxiliary.h>
#include <omalloc/omalloc.h>
#include <reporter/reporter.h>
#include "coeffs.h"
#include "numbers.h"
#include "longrat.h"

Go to the source code of this file.

Macros

#define SR_HDL(A)   ((long)(A))
 
#define SR_TO_INT(SR)   (((long)SR) >> 2)
 

Functions

static const char * nlEatLong (char *s, mpz_ptr i)
 
const char * nlRead (const char *s, number *a, const coeffs r)
 
void nlWrite (number a, const coeffs r)
 

Variables

static const n_coeffType ID = n_Q
 Our Type! More...
 
omBin rnumber_bin = omGetSpecBin(sizeof(snumber))
 

Macro Definition Documentation

#define SR_HDL (   A)    ((long)(A))

Definition at line 26 of file longrat0.cc.

#define SR_TO_INT (   SR)    (((long)SR) >> 2)

Definition at line 29 of file longrat0.cc.

Function Documentation

static const char* nlEatLong ( char *  s,
mpz_ptr  i 
)
static

Definition at line 35 of file longrat0.cc.

36 {
37  const char * start=s;
38 
39  while (*s >= '0' && *s <= '9') s++;
40  if (*s=='\0')
41  {
42  mpz_set_str(i,start,10);
43  }
44  else
45  {
46  char c=*s;
47  *s='\0';
48  mpz_set_str(i,start,10);
49  *s=c;
50  }
51  return s;
52 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int i
Definition: cfEzgcd.cc:123
const char* nlRead ( const char *  s,
number *  a,
const coeffs  r 
)

Definition at line 57 of file longrat0.cc.

58 {
59  if (*s<'0' || *s>'9')
60  {
61  *a = INT_TO_SR(1); /* nlInit(1) */
62  return s;
63  }
64  *a=(number)ALLOC_RNUMBER();
65  {
66  (*a)->s = 3;
67 #if defined(LDEBUG)
68  (*a)->debug=123456;
69 #endif
70  mpz_ptr z=(*a)->z;
71  mpz_ptr n=(*a)->n;
72  mpz_init(z);
73  s = nlEatLong((char *)s, z);
74  if (*s == '/')
75  {
76  mpz_init(n);
77  (*a)->s = 0;
78  s++;
79  s = nlEatLong((char *)s, n);
80  if (mpz_cmp_si(n,0L)==0)
81  {
83  mpz_clear(n);
84  (*a)->s = 3;
85  }
86  else if (mpz_cmp_si(n,1L)==0)
87  {
88  mpz_clear(n);
89  (*a)->s=3;
90  }
91  }
92  if (mpz_cmp_si(z,0L)==0)
93  {
94  mpz_clear(z);
95  FREE_RNUMBER(*a);
96  *a=INT_TO_SR(0);
97  }
98  else if ((*a)->s==3)
99  {
100  number nlShort3_noinline(number x);
101  *a=nlShort3_noinline(*a);
102  }
103  else
104  {
105  number aa=*a;
106  nlNormalize(aa,r); // FIXME? TODO? // extern void nlNormalize(number &x, const coeffs r);
107  *a=aa;
108  }
109  }
110  return s;
111 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define INT_TO_SR(INT)
Definition: longrat.h:66
const poly a
Definition: syzextra.cc:212
#define FREE_RNUMBER(x)
Definition: coeffs.h:85
void WerrorS(const char *s)
Definition: feFopen.cc:24
const char *const nDivBy0
Definition: numbers.h:83
number nlShort3_noinline(number x)
Definition: longrat.cc:172
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1334
#define ALLOC_RNUMBER()
Definition: coeffs.h:86
Variable x
Definition: cfModGcd.cc:4023
static const char * nlEatLong(char *s, mpz_ptr i)
Definition: longrat0.cc:35
void nlWrite ( number  a,
const coeffs  r 
)

Definition at line 116 of file longrat0.cc.

117 {
118  char *s,*z;
119  if (SR_HDL(a) & SR_INT)
120  {
121  StringAppend("%ld",SR_TO_INT(a));
122  }
123  else if (a==NULL)
124  {
125  StringAppendS("o");
126  }
127  else
128  {
129  if (a->s==0)
130  {
131  nlNormalize(a,r); // FIXME? TODO? // extern void nlNormalize(number &x, const coeffs r);
132  nlWrite(a,r);
133  return;
134  }
135  int l=mpz_sizeinbase(a->z,10);
136  if (a->s<2) l=si_max(l,(int)mpz_sizeinbase(a->n,10));
137  l+=2;
138  s=(char*)omAlloc(l);
139  z=mpz_get_str(s,10,a->z);
140  StringAppendS(z);
141  if (a->s!=3)
142  {
143  StringAppendS("/");
144  z=mpz_get_str(s,10,a->n);
145  StringAppendS(z);
146  }
147  omFreeSize((void *)s,l);
148  }
149 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
void nlWrite(number a, const coeffs r)
Definition: longrat0.cc:116
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define SR_HDL(A)
Definition: longrat0.cc:26
#define omAlloc(size)
Definition: omAllocDecl.h:210
void StringAppendS(const char *st)
Definition: reporter.cc:107
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
#define StringAppend
Definition: emacs.cc:82
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1334
#define NULL
Definition: omList.c:10
#define SR_TO_INT(SR)
Definition: longrat0.cc:29
#define SR_INT
Definition: longrat.h:65
int l
Definition: cfEzgcd.cc:94

Variable Documentation

const n_coeffType ID = n_Q
static

Our Type!

Definition at line 21 of file longrat0.cc.

omBin rnumber_bin = omGetSpecBin(sizeof(snumber))

Definition at line 23 of file longrat0.cc.