My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
longrat0.cc File Reference
#include <stdio.h>
#include <string.h>
#include "misc/auxiliary.h"
#include "reporter/reporter.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/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

const char * nlRead (const char *s, number *a, const coeffs r)
 
void nlWrite (number a, const coeffs)
 

Variables

VAR omBin rnumber_bin = omGetSpecBin(sizeof(snumber))
 

Macro Definition Documentation

◆ SR_HDL

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

Definition at line 22 of file longrat0.cc.

◆ SR_TO_INT

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

Definition at line 25 of file longrat0.cc.

Function Documentation

◆ nlRead()

const char * nlRead ( const char *  s,
number *  a,
const coeffs  r 
)

Definition at line 31 of file longrat0.cc.

32{
33 if (*s<'0' || *s>'9')
34 {
35 *a = INT_TO_SR(1); /* nlInit(1) */
36 return s;
37 }
38 *a=(number)ALLOC_RNUMBER();
39 {
40 (*a)->s = 3;
41#if defined(LDEBUG)
42 (*a)->debug=123456;
43#endif
44 mpz_ptr z=(*a)->z;
45 mpz_ptr n=(*a)->n;
46 mpz_init(z);
47 s = nEatLong((char *)s, z);
48 if (*s == '/')
49 {
50 mpz_init(n);
51 (*a)->s = 0;
52 s++;
53 s = nEatLong((char *)s, n);
54 if (mpz_cmp_si(n,0L)==0)
55 {
57 mpz_clear(n);
58 (*a)->s = 3;
59 }
60 else if (mpz_cmp_si(n,1L)==0)
61 {
62 mpz_clear(n);
63 (*a)->s=3;
64 }
65 }
66 if (mpz_cmp_si(z,0L)==0)
67 {
68 mpz_clear(z);
69 FREE_RNUMBER(*a);
70 *a=INT_TO_SR(0);
71 }
72 else if ((*a)->s==3)
73 {
74 number nlShort3_noinline(number x);
75 *a=nlShort3_noinline(*a);
76 }
77 else
78 {
79 number aa=*a;
80 nlNormalize(aa,r); // FIXME? TODO? // extern void nlNormalize(number &x, const coeffs r);
81 *a=aa;
82 }
83 }
84 return s;
85}
Variable x
Definition: cfModGcd.cc:4082
#define ALLOC_RNUMBER()
Definition: coeffs.h:87
#define FREE_RNUMBER(x)
Definition: coeffs.h:86
const CanonicalForm int s
Definition: facAbsFact.cc:51
void WerrorS(const char *s)
Definition: feFopen.cc:24
number nlShort3_noinline(number x)
Definition: longrat.cc:159
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1486
#define INT_TO_SR(INT)
Definition: longrat.h:68
char * nEatLong(char *s, mpz_ptr i)
extracts a long integer from s, returns the rest
Definition: numbers.cc:718
const char *const nDivBy0
Definition: numbers.h:89

◆ nlWrite()

void nlWrite ( number  a,
const  coeffs 
)

Definition at line 90 of file longrat0.cc.

91{
92 char *s,*z;
93 if (SR_HDL(a) & SR_INT)
94 {
95 StringAppend("%ld",SR_TO_INT(a));
96 }
97 else if (a==NULL)
98 {
99 StringAppendS("o");
100 }
101 else
102 {
103 int l=mpz_sizeinbase(a->z,10);
104 if (a->s<2) l=si_max(l,(int)mpz_sizeinbase(a->n,10));
105 l+=2;
106 s=(char*)omAlloc(l);
107 z=mpz_get_str(s,10,a->z);
108 StringAppendS(z);
109 if (a->s!=3)
110 {
111 StringAppendS("/");
112 z=mpz_get_str(s,10,a->n);
113 StringAppendS(z);
114 }
115 omFreeSize((void *)s,l);
116 }
117}
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
int l
Definition: cfEzgcd.cc:100
#define StringAppend
Definition: emacs.cc:79
#define SR_HDL(A)
Definition: longrat0.cc:22
#define SR_TO_INT(SR)
Definition: longrat0.cc:25
#define SR_INT
Definition: longrat.h:67
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:12
void StringAppendS(const char *st)
Definition: reporter.cc:107

Variable Documentation

◆ rnumber_bin

VAR omBin rnumber_bin = omGetSpecBin(sizeof(snumber))

Definition at line 19 of file longrat0.cc.