[BACK]Return to rat.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

File: [local] / OpenXM / src / kan96xx / Kan / rat.c (download)

Revision 1.4, Thu Jun 16 05:07:23 2005 UTC (18 years, 11 months ago) by takayama
Branch: MAIN
Changes since 1.3: +2 -2 lines

The initialization of the variables of the type struct object
are added.  It is necessary to initialize the field "attr"
(object attribute) of stuct object.  cf. misc-2005/06/gfan/opt.sm1 test2.

/* $OpenXM: OpenXM/src/kan96xx/Kan/rat.c,v 1.4 2005/06/16 05:07:23 takayama Exp $ */

/* rat.c: rational functions */
#include <stdio.h>
#include "datatype.h"
#include "stackm.h"
#include "extern.h"
#include "extern2.h"

static void errorRationalFunction(char *str);
static void warningRationalFunction(char *str);

struct object KnewRationalFunction0(op1,op2)
     objectp op1;
     objectp op2;
{
  struct object rob = OINIT;
  rob.tag = SrationalFunction;
  Knumerator(rob) = op1;
  Kdenominator(rob) = op2;
  KisInvalidRational(&rob);
  return(rob);
}

  
int KisZeroObject(op)
     objectp op;
{
  switch(op->tag) {
  case Spoly:
    if ((op->lc.poly) ISZERO) return(1);
    else return(0);
    break;
  case SuniversalNumber:
    if (isZero( op->lc.universalNumber)) return(1);
    else return(0);
    break;
  default:
    warningRationalFunction("KisZeroObject() does not support this object.");
    return(0);
  }
}

objectp copyObjectp(op)
     objectp op;
{
  objectp rop;
  rop = newObject();
  *rop = *op;
  return(rop);
}

void errorRationalFunction(str)
     char *str;
{
  fprintf(stderr,"Error(rat.c): %s\n",str);
  exit(20);
}

void warningRationalFunction(str)
     char *str;
{
  fprintf(stderr,"Warning(rat.c): %s\n",str);
}