Loading...
Searching...
No Matches
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)
#define | SR_TO_INT(SR)

## 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 | ) |

Value:
((long)(A))
A
#define A
Definition sirandom.c:24

Definition at line 22 of file longrat0.cc.

## SR_TO_INT

#define SR_TO_INT | ( |  | SR | ) |

Value:
(((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.

{
if (*s<'0' || *s>'9')
{
*a = INT_TO_SR(1); /* nlInit(1) */
return s;
}
*a=(number)ALLOC_RNUMBER();
{
(*a)->s = 3;
#if defined(LDEBUG)
(*a)->debug=123456;
#endif
mpz_ptr z=(*a)->z;
mpz_ptr n=(*a)->n;
mpz_init(z);
s = nEatLong((char *)s, z);
if (*s == '/')
{
mpz_init(n);
(*a)->s = 0;
s++;
s = nEatLong((char *)s, n);
if (mpz_cmp_si(n,0L)==0)
{
WerrorS(nDivBy0);
mpz_clear(n);
(*a)->s = 3;
}
else if (mpz_cmp_si(n,1L)==0)
{
mpz_clear(n);
(*a)->s=3;
}
}
if (mpz_cmp_si(z,0L)==0)
{
mpz_clear(z);
FREE_RNUMBER(*a);
*a=INT_TO_SR(0);
}
else if ((*a)->s==3)
{
number nlShort3_noinline(number x);
*a=nlShort3_noinline(*a);
}
else
{
number aa=*a;
nlNormalize(aa,r); // FIXME? TODO? // extern void nlNormalize(number &x, const coeffs r);
*a=aa;
}
}
return s;
}
x
Variable x
Definition cfModGcd.cc:4090
ALLOC_RNUMBER
#define ALLOC_RNUMBER()
Definition coeffs.h:94
FREE_RNUMBER
#define FREE_RNUMBER(x)
Definition coeffs.h:93
s
const CanonicalForm int s
Definition facAbsFact.cc:51
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
nlShort3_noinline
number nlShort3_noinline(number x)
Definition longrat.cc:159
nlNormalize
void nlNormalize(number &x, const coeffs r)
Definition longrat.cc:1481
INT_TO_SR
#define INT_TO_SR(INT)
Definition longrat.h:68
nEatLong
char * nEatLong(char *s, mpz_ptr i)
extracts a long integer from s, returns the rest
Definition numbers.cc:713
nDivBy0
const char *const nDivBy0
Definition numbers.h:90

## nlWrite()

void nlWrite | ( | number | a,
|  | const coeffs | r )

Definition at line 90 of file longrat0.cc.

{
char *s,*z;
if (SR_HDL(a) & SR_INT)
{
StringAppend("%ld",SR_TO_INT(a));
}
else if (a==NULL)
{
StringAppendS("o");
}
else
{
int l=mpz_sizeinbase(a->z,10);
if (a->s<2) l=si_max(l,(int)mpz_sizeinbase(a->n,10));
l+=2;
s=(char*)omAlloc(l);
z=mpz_get_str(s,10,a->z);
StringAppendS(z);
if (a->s!=3)
{
StringAppendS("/");
z=mpz_get_str(s,10,a->n);
StringAppendS(z);
}
omFreeSize((void *)s,l);
}
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
l
int l
Definition cfEzgcd.cc:100
StringAppend
#define StringAppend
Definition emacs.cc:79
SR_HDL
#define SR_HDL(A)
Definition longrat0.cc:22
SR_TO_INT
#define SR_TO_INT(SR)
Definition longrat0.cc:25
SR_INT
#define SR_INT
Definition longrat.h:67
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
NULL
#define NULL
Definition omList.c:12
StringAppendS
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.