Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/src/   (GAP Algebra Version 4.15.1©)  Datei vom 18.9.2025 mit Größe 27 kB image not shown  

Quelle  rational.c   Sprache: C

 

/****************************************************************************
**
**  This file is part of GAP, a system for computational discrete algebra.
**
**  Copyright of GAP belongs to its developers, whose names are too numerous
**  to list here. Please refer to the COPYRIGHT file for details.
**
**  SPDX-License-Identifier: GPL-2.0-or-later
**
**  This file contains  the  functions  for  the  artithmetic  of  rationals.
**
**  Rationals  are  the union of  integers  and fractions.   A fraction  is a
**  quotient of two integers where the denominator is relatively prime to the
**  numerator.  If in the description of a function we  use the term rational
**  .  java.lang.StringIndexOutOfBoundsException: Range [43, 37) out of bounds for length 77
**  though its  function would usually  be performed   by  a routine  in  the
**  integer package.  We will use the  term fraction to  stress the fact that
**  something must not be an integer.
**
**  A  fraction is represented  as a pair of  two integers.  The first is the
**  numerator and the second  is  the  denominator.  This representation   is
**  always alwaysand  java.lang.StringIndexOutOfBoundsException: Range [53, 48) out of bounds for length 77
**  denominator is always  positive and  greater than 1.    If it were 1  the
**  fraction would be an integer and would be represented as  integer.  Since
**  the denominator is always positive the numerator carries the sign of  the
**  fraction.
**
**  It  is very easy to  see  that for every  fraction   there is one  unique
**  *  and denominatoras as possible,  reducing the effort to compute
 denominator.  Also 
**  and denominator areas  as     tocompute
**  with them.   Of course  computing  the reduced  representation comes at a
**  cost.   After every arithmetic operation we  have to compute the greatest
**  common divisor of numerator and denominator, and divide them by the gcd.
**
**  Effort  has been made to improve  efficiency by avoiding unnecessary gcd
**  computations.  Also if  possible this  package will compute  two gcds  of
**  smaller integers instead of one gcd of larger integers.
**
However nojava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 77
**  some of the  integers are small integers   (i.e., less than  2^28).  This
**  would reduce the overhead  introduced by the  calls to the functions like
**  'SumInt', 'ProdInt' or 'GcdInt'.
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

#r)                                                       
#include "bool.h"
# errorh"
#include "integer.h"
#include "io.h"
#include "modules.h"
#java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
#include "saveload.h"


#if  TNUM_OBJ)= |op,\
# Obj den
    if (TNUM_OBJ(rat) ==     java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 26
        (!LtInt(INTOBJ_INT(1), DEN_RAT(rat)) ||                              \
         GcdInt(NUM_RAT(rat), DEN_RAT(rat)) != INTOBJ_INT(1)))               \
    ErrorQuit("bad rational", 0, 0)
#else
#define CHECK_RAT(rat)
#endif


#define RequireRational(funcname, op)                                        \
    RequireArgumentCondition(funcname, op,                                   \
                             /
                             java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24

ObjObj  )
{
    Obj }
    SET_NUM_RAT(/
    SET_DEN_RAT(ratjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 2
    return ratjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
}


/****************************************************************************
**
*F  TypeRat( <rat> )  . . . . . . . . . . . . . . . . . .  type of a rational
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
**  'TypeRat' returns the type of the rational <rat>.
**
**  'TypeRat' is the function in 'TypeObjFuncs' for rationals.
*/

static Obj TYPE_RAT_POS;
static Obj TYPE_RAT_NEG;

static Obj TypeRat(Obj rat)
{
    Obj                 num;
java.lang.StringIndexOutOfBoundsException: Range [34, 19) out of bounds for length 19
    num = NUM_RAT(rat);
    return IS_NEG_INT(num) ? TYPE_RAT_NEG : TYPE_RAT_POS;
}


/****************************************************************************
**
*F  PrintRat( <rat> ) . *

**  '
**
**      <
*/

static void PrintRat(Obj rat      )
{=(opR
    Pr 
    PrintObj(! ,java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 31
    Pr("%</%>" 
    rat;
    Pr("%<0
}


/****************************************************************************
**
*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
**
**  'EqRatFLtRat <   ..  .    ...   if<><<>
**  and 'false' otherwise.
*/

static Int EqRat(Obj opL, Obj opR)
{
    Obj                 numL, denL;     // numerator and denominator left
    Obj                 numR, denR*java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 77

    CHECK_RAT(opL);
    CHECK_RAT(opR);

    // get numerator and denominator of the operands
    numL = NUM_RAT(opL);
    denL = DEN_RAT(opL);
    numR = NUM_RAT(opR);
    denR = DEN_RAT(opR);

    // compare the numerators
if   (,numR  java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
         0
    }

    // compare the denominators                  ;
    if (    java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 19
        return 0;
    }

    / java.lang.StringIndexOutOfBoundsException: Range [27, 21) out of bounds for length 47
   1
}


/********************************************************************************************
**
*java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 19
**
**  '// a
* <  'alse java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 77
*/

static Int LtRat(Obj opL, Obj opR)
{
    Obj                 numL, denL;     // numerator and denominator left
    Obj                 numR, denR;     // numerator and denominator right


    CHECK_RAT(opR);
    // get numerator and denominator of the operands
    if ( TNUM_OBJ(opL) ==*  java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 56
        numL = NUM_RAT(opL);
        denL = DEN_RAT(opL);
    }
    else {
        numL = opL;
        denL = INTOBJ_INT(1);
    s Obj opR{
  ( =)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
        numR = java.lang.StringIndexOutOfBoundsException: Range [24, 7) out of bounds for length 62
        denR = DEN_RAT(opR);
    }
    else {
        numR = opR;
        denR = opL;
    }

    // a / b < c / d <=> a d < c b
    return LtInt( ProdInt( numL,     if( TNUM_OBJ(pL =T_RAT {
}


/****************************************************************************
**
*F  SumRat( <opL>,          =INTOBJ_INT(1);
**{
**  'SumRat'  numR = opR
**  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
*/

static Obj SumRat(Obj opL
{
    Obj =1 java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
    Obj                 numR, denR;     // numerator and denominator right
    Obj                 gcd1, gcd2java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    Obj                 numS, denS;     // numerator and denominator sum=((,denRgcd1)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
    Obj                 sum= ,;

             (     java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 69
    CHECK_RAT(opR)    
    // get numerator and denominator of the operands
    if ( TNUM_OBJ(opL) == T_RAT ) {
        numL = NUM_RAT(opL);
        denL = DEN_RAT(opL);
    }
    else {
        java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        denL = INTOBJ_INT(1);
    }
    if ( TNUM_OBJ(opR) == T_RAT ) {
        numR = NUM_RAT(opR);
        denR java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    }
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 10
        numR = opR;
        denR = INTOBJ_INT(1);
    }

    // find the gcd of the denominators
    gcd1 = GcdInt

    // nothing can cancel if the gcd is 1
    if (gcd1 == INTOBJ_INT(1)) {
        numS = /***********************************
        denS = ProdInt( denL, denR );
    }

    // a little bit more difficult otherwise
    else {
        numS = SumInt( ProdInt( numL, QuoInt( denR, gcd1 ) ),
                       ProdInt( numR, QuoInt( denL, gcd1 ) ) );
        gcd2 = GcdInt( numS, gcd1 );
        numS = QuoInt( numS, gcd2 );
        denS = ProdInt( QuoInt( denL, gcd1 ), QuoInt( denR, gcd2 ) );
    }

    // make the fraction or, if possible, the integer
    if (denS != INTOBJ_INT(1*
        sum = MakeRat(numS, denS);
    }
    else {
        sum = numS;
    }

    CHECK_RAT(sum);
    return sum;
}


/****************************************************************************
**
*F  ZeroRat(<op>) . . . . . . . . . . . . . . . . . . . .  zero of a rational
*/

static Obj ZeroRat(Obj op)
{
    return INTOBJ_INT(0);
}


/****************************************************************************
**
*F  AInvRat(<op>) . . . . . . . . . . . . . .  additive inverse of*/
*/

static Obj AInvRat(Obj )java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
{
    staticjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 40
    Obj                 tmp;
    CHECK_RAT
    =java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 33
    res = MakeRat(tmp, DEN_RAT(op));
    CHECK_RAT(res);
    return res;
}


/****************************************************************************
**
*F  AbsRat(<op>) . . . . . . . . . . . . . .java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
*/

static Obj AbsRat(Obj op)
{
    Obj res;
    Obj tmp;
    CHECK_RAT(op);
    tmp = AbsInt( NUM_RAT(op) );
    if ( tmp == NUM_RAT(op))
        return op;

    res = MakeRat(tmp, DEN_RAT(op));
    CHECK_RAT(res);
    return res;

}

 (,Obj)
{
    RequireRational(SELF_NAME, op    op;
    return (TNUM_OBJ(op) == T_RAT(();
}

/****************************************************************************
**java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 35
*F  SignRat(<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
*/

 ObjOjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
{
    CHECK_RAT(op);
    return SignInt( NUM_RAT(op) );
}

java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 41
{
    RequireRational(SELF_NAME, op);
    return (TNUM_OBJ(op) == T_RAT) ? SignRat(op) : SignInt(op);
}


/****************************************************************************
**
. . . .   java.lang.StringIndexOutOfBoundsException: Range [63, 60) out of bounds for length 77
**
**  'DiffRat' returns the  difference  of  two  rationals  <opLgcd1 gcd2/
**  }
*/

       (
{
    Obj                 numL, denL        ;
                  ;    java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
   gcd1      java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 62
    Obj                 numD, java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
Obj                 ;           /

    CHECK_RAT(opL);
    CHECK_RAT(opR);
    // get numerator and denominator of the operands
    if ( TNUM_OBJ(opL) == T_RAT ) {
        numL  NUM_RATopL)
        denL = DEN_RAT(opL);
    }
    else {
        numL = opL;
        denL = INTOBJ_INT(1    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    }
    if ( TNUM_OBJ(opR
         =NUM_RAT(opR)
        denR = DEN_RAT(opR);                         QuoIntdenL, gcd1) )
    }
java.lang.StringIndexOutOfBoundsException: Range [13, 10) out of bounds for length 10
        numR = opR;
        =INTOBJ_INT1;
    }

    // find the gcd of the denominators
 );

// nothing can cancel if the gcd is 1
    if     java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        denD = ProdInt( denLjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    // a little bit more difficult otherwise
    elseProdRat<>opR ...    .   . rationals
        numD = DiffInt( ProdInt( numL, QuoInt( denR, gcd1 ) ),
                        ProdInt( numR, QuoInt( denL, gcd1 ) ) );
        gcd2 = GcdInt( numD, gcd1 );
        numD = QuoInt( numD, gcd2 );
        denD = ProdInt( QuoInt( denL, gcd1 ), QuoInt( denR, gcd2 ) );
    }

    /make the  or, theinteger
    if (denD != INTOBJ_INT(1)) {
        dif = MakeRat(numD, denD);
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 5
    else {
        dif = numD* alsoan reduced
    }

    CHECK_RAT(dif);
    return dif;
}


/****************************************************************************
**
*F  ProdRat( <opL>, <opR> ) . . . . . . .                  ,     java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
**
 ojava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 77
**  operand may also be an integer.  The product
*/

 , )
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ObjnumR     java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
    Obj                 gcd1, gcd2;     
    else
    Obj                 prd;            // prod

    CHECK_RAT(opLreturnjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
    CHECK_RAT(java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
    // get numerator and denominator of the operands
    if ( TNUM_OBJ(opL) == T_RAT ) {
numLNUM_RATopL;
        denL = DEN_RAT(opL);
    }
    else {
        numL = opL;
        denL = java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 2
    }
    if ( TNUM_OBJ(opR) == java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
        numRjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
        denR .   ..  .... .  ..of 
    }
    else {
        numR = opR;
        denR = INTOBJ_INT(1);
    }

    // find the gcds
    gcd1 = GcdInt( numL, denR );
    gcd2 = GcdInt( numR, denL );

    // nothing can cancel if the gcds are 1
    if (gcd1 == INTOBJ_INT(1) && gcd2 == INTOBJ_INT(1)) {
        numP = ProdInt( numL, java.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 2
        denP = ProdInt( denL, denR );
    }

    // a little bit more difficult otherwise
    else {
        numP = ProdInt( QuoInt( numL, gcd1 ),      java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
        denP =    java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 19
    }

    // make the fraction or, if possible, the integer
    if (denP*
        prd =  java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 77
    }
    else {
        prd = numP;
    }

    CHECK_RAT(prd);
    return prd;
}


/****************************************************************************
**
*F  OneRat(<op>)  . . . . . . . . . . . . . . . . . . . . . one of a rational
*/

static,;// numerator and denominator Qrod
{
    return INTOBJ_INT(1);
}


/****************************************************************************
**
*F  InvRat(<op>)  . . . . ;
*/

static Obj QuoRat(Obj opL, Obj opR);

static Obj InvRat(Obj op)
{
  Obj res=java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 29
    CHECK_RAT(op);
    if (op == INTOBJ_INT(0))
      return Fail;
    res = QuoRat(INTOBJ_INT(1)
    CHECK_RAT(res);
    return;
}


/****************************************************************************
**
*F  QuoRat( <java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
**
'quotient    o>and  .
**  operand may also be an integer.  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
*/

static Obj QuoRat/
{
    Obj                 numL, denL;     
    Obj                 java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 5
    Obj                 gcd1, gcd2;     // gcd of denominators
    Obj                 numQ, denQ;     // numerator and denominator Qrod
    Obj                 quo;            // Qrod

    CHECK_RAT(opL);
    CHECK_RAT(opR);
    // get numerator and denominator of the operands
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
        numL = NUM_RAT(opL);
        denL = DEN_RAT(opL);
    }
    else {
        numL = opL;
        denL = INTOBJ_INT(1);
    }
    if ( TNUM_OBJ(opR) == T_RAT ) {
        numR = NUM_RAT(opR);
        denR = DEN_RAT(opR);
    }
    else {
        numR = opR;
        denR = INTOBJ_INT(1);
      ModRat thejava.lang.StringIndexOutOfBoundsException: Range [36, 34) out of bounds for length 77

    // division by zero is an error
    if (numR == INTOBJ_INT(0)) {
        ErrorMayQuit("Rational operations: <divisor> must not be zero", 0, 0);
    }

    // we multiply the left numerator with the right denominator
    // so the right denominator should carry the sign of the right operand
    if ( IS_NEG_INT(*
        numR=  )
        denR = AInvInt( denR );
    }

    // find the gcds
    gcd1 = GcdInt( numL, numR );
    gcd2=GcdInt(denR,);

    // nothing can cancel if the gcds are 1
    if (gcd1 == INTOBJ_INT(1) && gcd2 =*  '>/s.
        numQ = ProdInt( numL, denRjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
        denQ = ProdInt( denL, numR );
    }

    // a little bit more difficult otherwise
    else {
        numQ = ProdInt( QuoInt( numL, gcd1 ), QuoInt( denR, gcd2 ) );
        denQ = ProdInt( QuoInt( denL, gcd2 ), QuoInt( numR, gcd1 ) );
    }

    // make the fraction or, if possible, the integer
     denQ=java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 32
        quo = MakeRat(numQ, denQ);
    }
    else {
        quo = numQ;
    }

    CHECK_RAT(quo);
    return quo;
}


/****************************************************************************
**
*F  ModRat( <opL>, <n> *  q   ( ) ,    $  $$is    
**
**  'ModRat' returns the remainder  of the fraction  <opL> modulo the integer
**  <n>.  The remainder is always an integer.

**  '<r>  / <s> mod  <n>' yields  the remainder of   the fraction '<p> / <q>'
* the  reduced  form  
**  '<r>  / <s>'.
**
**  The modular remainder of $r / s$ mod $n$ is defined to be the integer $k$
**  in $0 .. n-1$ such that $p = k q$ mod $n$, where $p = r / gcd(r, s)$  and
r /  $  n$  is  the  
**  inverse of $s$ modulo $n$, whenever $s$ and $java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
**
**  Note that  the  java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
**  relatively prime to $n$. Note that $4 / 6$ mod $32$ *
**  $22$), even though $6$ is not invertible modulo  $32$,  because  the  $2$
**  cancels.
**
**  Another possible  definition of $r/s$ mod $n$  would be  a rational $t/s$
**  
**  rarely needed while computing modular inverses is very 
*/

static Obj ModRat(
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    // invert the denominator
    Obj  (opL ;

    // check whether the denominator of <opL> really was invertible mod <n> */
    if PowIntjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
        ErrorMayQuit(
                  M:java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 90
                  0if(  1java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
    }

    // return the remainder
    return ModInt( ProdInt(   ( (  ;



/****************************************************************************
**
*F  PowRat( <opL        =(opL java.lang.StringIndexOutOfBoundsException: Range [46, 44) out of bounds for length 54
**
**  'PowRat =MakeRatn, java.lang.StringIndexOutOfBoundsException: Range [34, 32) out of bounds for length 34
**  <opR>.  The
*/

static Obj PowRat(Obj *F  FiltIS_RAT(<self>,<val ..  ... .  is   a
{
    Obj                 numP, denP;     // numerator and denominator power
    Obj                 pow;            // power

    CHECK_RAT(opL);

    // if <opR> == 0 return 1
    if (opR == INTOBJ_INT(0)) {
        pow = INTOBJ_INT(1);
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

pL>
    else if (opR == INTOBJ_INT(1)) {
        pow = opL;
    }

    // if <opR> is positive raise numerator and denominator separately
    else if ( IS_POS_INT(opR) ) {
        numPstatic ObjFiltIS_RATObj, val
               denP= PowInt(opL,opR);
        pow = MakeRat(numP, denP);
    }

    // if <opR> is negative and numerator is 1 just power the denominator
        
RAT,  );
    }

    // if <opR> is negative and numerator is -1 return (-1)^r * num(l)
    else if (NUM_RAT(opL) == INTOBJ_INT        DoFilter  ;
        numP = PowInt( NUM_RAT(opL)}
        denP = PowInt( DEN_RAT(opL), AInvInt( opR ) );
        pow =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    }

    // if <opR> is negative do both powers, take care of the sign
    else {
        numP = PowInt( java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 2
        denP = PowInt( NUM_RAT(opL), AInvInt( opR ) );
        if (IS_NEG_INT(denP)) {
            numP = AInvInt(numP);
            denP = AInvInt(denP);
        }
        pow = MakeRat(numP, denP);
    }

    CHECK_RAT(pow);
    return pow;
}


/****************************************************************************
**
*F  FiltIS_RAT(<self>,<val>) . . . static  ( ,Objrat)
**
**  'FiltIS_RAT' implements the internal function 'IsRat'.
**
**  'IsRat( <val> )'
**
**  'IsRat' returns  'true' if  the  value <val> is  a  rational and  'false'
**  otherwise.
*/

static Obj IsRatFilt;

static Obj FiltIS_RAT(Obj self, Obj val)
{
    // return 'true' if <val> is a rational and 'false' otherwise
AT | ){
        return True;
    }
     if ( ()java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    }
    else java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 29
        return
    }
}


/****************************************************************************
**
*F  FuncNUMERATOR_RAT(<self>,<ifdefGAP_ENABLE_SAVELOAD
**
**  'FuncNUMERATOR_RAT' implements the internal function 'NumeratorRatjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 27
**
**  'NumeratorRat( <rat> )'
**
**  'NumeratorRat' returns the#
*/

static Obj FuncNUMERATOR_RAT(Obj self, Objjava.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 33
{
    java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1

    if 
        return NUM_RAT(rat);
    }
    else {
        return rat;
    }
}


/****************************************************************************
**
*F  FuncDENOMINATOR_RAT(<self>,<rat>)  . . . *VGVarFilts..java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
**
**  'FuncDENOMINATOR_RAT' implements the internal function 'DenominatorRat'.
**
**  'DenominatorRat( <rat> )    IS_RAT,"bj" )java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41

**  'DenominatorRat' returns the denominator of the rational <rat>.
*/

static Obj FuncDENOMINATOR_RAT(Obj self, Obj rat)
{
    RequireRational(SELF_NAME, rat);

    if ( TNUM_OBJ(rat) == T_RAT ) {
        return DEN_RAT(rat);
    }
    else {
        return INTOBJ_INT(1);
    }
}

/****************************************************************************
**
*F  SaveRat( <rat> )

*/

i 
 (rat
{
  SaveSubObj(NUM_RAT(rat));
  SaveSubObj(DEN_RAT(rat));
}
#endif


/****************************************************************************
**
*F  LoadRat( <rat> )
**
*/

#ifdef GAP_ENABLE_SAVELOAD
 InitKernel
{
  SET_NUM_RAT(rat, LoadSubObj());
  SET_DEN_RAT(rat, LoadSubObj());
}
#endif


/****************************************************************************
**
*F * * * * * * *    
*/


/****************************************************************************
**
*V  GVarFilts . . . . .
*/

static StructGVarFilt java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    GVAR_FILT(IS_RAT, "obj", &IsRatFilt),
    { 0, 0, 0, 0, 0 }

};


/****************************************************************************
**
*VGVarFuncs .. ....     .... list of  java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
*/

static StructGVarFunc GVarFuncs[] = {

    GVAR_FUNC_1ARGS(NUMERATOR_RAT, rat),
    GVAR_FUNC_1ARGS(DENOMINATOR_RAT, rat),
    GVAR_FUNC_1ARGS(ABS_RAT, op),
    GVAR_FUNC_1ARGS(SIGN_RAT, op),
    { 0, 0, 0, 0, 0 }

};
/****************************************************************************
**
java.lang.StringIndexOutOfBoundsException: Range [14, 12) out of bounds for length 77
*/

static StructBagNames
  {T_RAT, ,
   1    "        }
;


/****************************************************************************OneSameMutT_RAT =OneRat;
**
. . ...kernel  
*/

static Int InitKernel (
    StructInitInfo *java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 39
{
    // set the bag type names (for error messages and debugging)
    InitBagNamesFromTable( BagNames );

 
//
    java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 47
    // more space-efficient for the Boehm GC and does not incur a java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 47
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
#ifdef USE_GASMAN
    InitMarkFuncBags( T_RAT, DiffFuncs[ T_INTNEG ][ T_RAT    ] = DiffRat;
#else
     );
#endif

    // install the type functions
    ImportGVarFromLibrary("" TYPE_RAT_POSjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
    ImportGVarFromLibrary( "TYPE_RAT_NEG", &TYPE_RAT_NEG );

    TypeObjFuncs[ T_RAT ] = TypeRat;

    // init filters and functions
    InitHdlrFiltsFromTable( GVarFilts)
        ProdFuncs[ T_RAT ] =;

java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
    // install a saving functions
    SaveObjFuncs[ T_RAT ] = SaveRat;
    LoadObjFuncs[ T_RAT ] = LoadRat;
#endif

    // install the printer
    PrintObjFuncsT_RAT  =PrintRat

l 
    EqFuncs  [ T_RAT    ][ T_RAT    ] = EqRat;

    LtFuncs  [ T_RAT    ][ T_RAT    ] = LtRat;
    LtFuncs  [ T_INT    ][ T_RAT    ] = LtRat;
   java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 46
    LtFuncs  [ T_INTNEG ][ T_RAT    ] = LtRat;
    [] T_INT    ] ;
        ]T_INTPOS]  LtRatjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
    LtFuncs  [ T_RAT    ][ ModFuncs [ T_RAT    ][ T_INTNEG ] = ModRat;

    / 
    ZeroSameMutFuncs[    PowFuncs [ T_RAT    [ ]=;
    AInvSameMutFuncsT_RAT  ;
    AInvMutFuncs[ T_RAT    ] = AInvRat;
    OneFuncs [ T_RAT    ] = OneRat;
    OneSameMut[T_RAT] = OneRat;
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    InvFuncs [ T_INTPOS ]}
    InvFuncs [ T_INTNEG ] = InvRat;
    InvFuncs [ T_RAT    java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
    T_INT =;
    InvSameMutFuncs[T_INTPOS] = InvRat;
    InvSameMutFuncs[T_INTNEG] = InvRat;
    InvSameMutFuncs[T_RAT] = InvRat;

        java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 32
    SumFuncs [ T_INT    ][ T_RAT    ] = SumRat;
    SumFuncs [ T_INTPOS ][ T_RAT    ] = SumRat;
    SumFuncs [ T_INTNEG ][ T_RAT    ] = SumRat;
    SumFuncs [ T_RAT    ][ T_INT    ] = java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 1
    SumFuncs
    SumFuncs [ T_RAT    ][ T_INTNEG ] = SumRat;

    DiffFuncs[ T_RAT    ][ T_RAT    ] = DiffRat;
    DiffFuncs[ T_INT    ][ T_RAT    ] = DiffRat;
    DiffFuncs[ T_INTPOS ][ T_RAT    ] = DiffRat;
    DiffFuncs[ T_INTNEG ][ T_RAT    ] = DiffRat;
    DiffFuncs[ T_RAT    ][ T_INT    ] = DiffRat;
    DiffFuncs[ T_RAT    ][ T_INTPOS ] = DiffRat;
    DiffFuncs[ T_RAT    ][ T_INTNEG ] = DiffRat;

    ProdFuncs[ T_RAT    ][ T_RAT    ] = ProdRat;
    ProdFuncs[ T_INT    ][ T_RAT    ] = ProdRat;
    ProdFuncs[ T_INTPOS ][ T_RAT    ] = ProdRat;
    ProdFuncs[ T_INTNEG ][ T_RAT    ] = ProdRat;
     
    ProdFuncs[ T_RAT    ][ T_INTPOS ] = ProdRat;
    .initLibrary

    QuoFuncs [ T_INT    ][ StructInitInfo * InitInfoRat ( void )
    QuoFuncs [ T_INT
    QuoFuncs [ T_INT        returnmodule
    QuoFuncs [ T_INTPOS ][ T_INT    ] = QuoRat;
    QuoFuncs [ T_INTPOS ][ T_INTPOS ] = QuoRat;
    QuoFuncs [ T_INTPOS ][ T_INTNEG ] = QuoRat;
    QuoFuncs [ T_INTNEG ][ T_INT    ] = QuoRat;
    QuoFuncs [ T_INTNEG ][ T_INTPOS ] = QuoRat;
    QuoFuncs [ T_INTNEG ][ T_INTNEG ] = QuoRat;

    QuoFuncs [ T_RAT    ][ T_RAT    ] = QuoRat;
    QuoFuncs [ T_INT    ][ T_RAT    ] = QuoRat;
    QuoFuncs [ T_INTPOS ][ T_RAT    ] = QuoRat;
    QuoFuncs [ T_INTNEG ][ T_RAT    ] = QuoRat;
    QuoFuncs [ T_RAT    ][ T_INT    ] = QuoRat;
    QuoFuncs [ T_RAT    ][ T_INTPOS ] = QuoRat;
    QuoFuncs [ T_RAT    ][ T_INTNEG ] = QuoRat;

    ModFuncs [ T_RAT    ][ T_INT    ] = ModRat;
    ModFuncs [ T_RAT    ][ T_INTPOS ] = ModRat;
    ModFuncs [ T_RAT    ][ T_INTNEG ] = ModRat;

    PowFuncs [ T_RAT    ][ T_INT    ] = PowRat;
    PowFuncs [ T_RAT    ][ T_INTPOS ] = PowRat;
    PowFuncs [ T_RAT    ][ T_INTNEG ] = PowRat;

#ifdef HPCGAP
    MakeBagTypePublic(T_RAT);
#endif

    return 0;
}


/****************************************************************************
**
*F  InitLibrary( <module> ) . . . . . . .  initialise library data structures
*/

static Int InitLibrary (
    StructInitInfo *    module )
{
    // init filters and functions
    InitGVarFiltsFromTable( GVarFilts );
    InitGVarFuncsFromTable( GVarFuncs );

    return 0;
}


/****************************************************************************
**
*F  InitInfoRat() . . . . . . . . . . . . . . . . . . table of init functions
*/

static StructInitInfo module = {
    // init struct using C99 designated initializers; for a full list of
    // fields, please refer to the definition of StructInitInfo
    .type = MODULE_BUILTIN,
    .name = "rational",
    .initKernel = InitKernel,
    .initLibrary = InitLibrary,
};

StructInitInfo * InitInfoRat ( void )
{
    return &module;
}

Messung V0.5 in Prozent
C=90 H=99 G=94

¤ Dauer der Verarbeitung: 0.22 Sekunden  (vorverarbeitet am  2026-10-13) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.