PIPS
pnome-error.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "polynome.h"
+ Include dependency graph for pnome-error.c:

Go to the source code of this file.

Functions

void polynome_error (const char *name, char *fmt,...)
 INTLIBRARY. More...
 
void good_polynome_assert (char *function,...)
 void good_polynome_assert(va_alist) Check if the second argument is a valid polynomial. More...
 
bool monome_check (Pmonome pm)
 bool monome_check(Pmonome pm) Return true if all's right. More...
 
bool polynome_check (Ppolynome pp)
 bool polynome_check(Ppolynome pp) Return true if all's right. More...
 
bool is_polynome_a_monome (Ppolynome pp)
 bool is_polynome_a_monome(Ppolynome pp) Return true if the pp is just a monome. More...
 

Function Documentation

◆ good_polynome_assert()

void good_polynome_assert ( char *  function,
  ... 
)

void good_polynome_assert(va_alist) Check if the second argument is a valid polynomial.

If not, print first argument ((char *) function name) and abort.

Parameters
functionunction

Definition at line 84 of file pnome-error.c.

85 {
86  va_list args;
87  Ppolynome pp;
88 
89  va_start(args, function);
90  pp = va_arg(args, Ppolynome);
91 
92  if (polynome_check(pp)) return;
93 
94  fprintf(stderr, "Bad internal polynomial representation in %s\n", function);
95  va_end(args);
96  abort();
97 }
#define abort()
Definition: misc-local.h:53
bool polynome_check(Ppolynome pp)
bool polynome_check(Ppolynome pp) Return true if all's right.
Definition: pnome-error.c:131
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References abort, fprintf(), and polynome_check().

Referenced by polynome_monome_add(), and polynome_monome_addition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_polynome_a_monome()

bool is_polynome_a_monome ( Ppolynome  pp)

bool is_polynome_a_monome(Ppolynome pp) Return true if the pp is just a monome.

that means the polynom has only one term Check each monomial, make sure there's no nul or undefined monomial, then check unicity of each monomial.

LZ 06 Nov. 92

Parameters
ppp

Definition at line 162 of file pnome-error.c.

164 {
165  if ( ! polynome_check(pp) )
166  return (false);
167  else if ( pp != POLYNOME_NUL && polynome_succ(pp) == POLYNOME_NUL )
168  return (true);
169  else
170  return (false);
171 }
#define POLYNOME_NUL
#define polynome_succ(pp)

References polynome_check(), POLYNOME_NUL, and polynome_succ.

Referenced by polynome_power_n().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ monome_check()

bool monome_check ( Pmonome  pm)

bool monome_check(Pmonome pm) Return true if all's right.

Looks if pm is MONOME_UNDEFINED; if not: make sure that the coeff is non nul, that the term is non nul, and checks the (Pvecteur) term. All this also checks that pm is pointing to a valid address.

Modification:

  • MONOME_NUL means 0 monome, and it's a good monome. LZ 10/10/91
Parameters
pmm

Definition at line 110 of file pnome-error.c.

112 {
113  if ( MONOME_UNDEFINED_P(pm) )
114  return (false);
115  else if (MONOME_NUL_P(pm) )
116  return (true);
117  else
118  return ((monome_coeff(pm) != 0) &&
119  !VECTEUR_NUL_P(monome_term(pm)) &&
120  vect_check(monome_term(pm)));
121 }
bool vect_check(Pvecteur cv)
bool vect_check(Pvecteur v): renvoie true si le vecteur v est coherent avec les specifications du pac...
Definition: reductions.c:529
#define monome_term(pm)
#define MONOME_UNDEFINED_P(pm)
#define monome_coeff(pm)
Macros definitions.
#define MONOME_NUL_P(pm)
#define VECTEUR_NUL_P(v)

References monome_coeff, MONOME_NUL_P, monome_term, MONOME_UNDEFINED_P, vect_check(), and VECTEUR_NUL_P.

Referenced by polynome_check().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ polynome_check()

bool polynome_check ( Ppolynome  pp)

bool polynome_check(Ppolynome pp) Return true if all's right.

Check each monomial, make sure there's no nul or undefined monomial, then check unicity of each monomial.

Modification:

  • POLYNOME_NUL means 0 polynome, and it's a good one. LZ 10/10/91
Parameters
ppp

Definition at line 131 of file pnome-error.c.

133 {
134  if ( POLYNOME_UNDEFINED_P(pp) )
135  return (false);
136  if ( POLYNOME_NUL_P(pp) )
137  return (true);
138  else {
139  Ppolynome curpp, curpp2;
140 
141  for (curpp = pp; curpp != POLYNOME_NUL; curpp = polynome_succ(curpp)) {
142  if ( !monome_check(polynome_monome(curpp)) ) {
143  return (false);
144  }
145  for (curpp2 = polynome_succ(curpp); curpp2 != POLYNOME_NUL;
146  curpp2 = polynome_succ(curpp2))
147  if (monome_colin(polynome_monome(curpp),polynome_monome(curpp2)))
148  return (false);
149  }
150  return (true);
151  }
152 }
bool monome_check(Pmonome pm)
bool monome_check(Pmonome pm) Return true if all's right.
Definition: pnome-error.c:110
bool monome_colin(Pmonome pm1, Pmonome pm2)
bool monome_colin(Pmonome pm1, Pmonome pm2) PRIVATE returns true if the two monomials are "colinear":...
Definition: pnome-private.c:77
#define POLYNOME_UNDEFINED_P(pp)
#define polynome_monome(pp)
#define POLYNOME_NUL_P(pp)

References monome_check(), monome_colin(), polynome_monome, POLYNOME_NUL, POLYNOME_NUL_P, polynome_succ, and POLYNOME_UNDEFINED_P.

Referenced by complexity_check(), good_polynome_assert(), and is_polynome_a_monome().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ polynome_error()

void polynome_error ( const char *  name,
char *  fmt,
  ... 
)

INTLIBRARY.

pnome-error.c

void polynome_error(va_dcl va_list): should be called to terminate execution and to core dump when data structures are corrupted or when an undefined operation is requested (zero divide for instance). polynome_error should be called as:

polynome_error(function_name, format, expression-list)

where function_name is a string containing the name of the function calling POLYNOME_ERROR, and where format and expression-list are passed as arguments to vprintf. POLYNOME_ERROR terminates execution with abort. Ex: polynome_error("polynome_power_n", "negative power: %d\n", p); ARARGS0

print name of function causing error

print out remainder of message

create a core file for debug

Parameters
nameame
fmtmt

Definition at line 62 of file pnome-error.c.

63 {
64  va_list args;
65 
66  va_start(args, fmt);
67 
68  /* print name of function causing error */
69  (void) fprintf(stderr, "\npolynome error in %s: ", name);
70 
71  /* print out remainder of message */
72  (void) vfprintf(stderr, fmt, args);
73  va_end(args);
74 
75  /* create a core file for debug */
76  (void) abort();
77 }

References abort, and fprintf().

Referenced by Bernouilli(), factorielle(), monome_monome_div(), polynome_equal(), polynome_power_n(), polynome_roots(), polynome_sum_of_power(), and polynome_used_var().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: