PIPS
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "linear_assert.h"
#include <ctype.h>
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "polynome.h"
Go to the source code of this file.
Macros | |
#define | POLYNOME_BUFFER_SIZE 20480 |
Functions | |
void | float_to_frac (float x, char **ps) |
void float_to_frac(float x, char** ps) PRIVATE returns the simplest representation of floating-point number x tries to make an integer, then a small fraction, then a floating-point, then a floating-point with exponent. More... | |
void | monome_fprint (FILE *fd, Pmonome pm, Pbase pb, bool plus_sign, char *(*variable_name)(Variable)) |
void monome_fprint(FILE* fd, Pmonome pm, Pbase pb, bool plus_sign, char* (*variable_name)()) PRIVATE Outputs to file fd an ASCII form of monomial pm, naming variables with the "variable-name" function, ordering them with the basis pb. More... | |
char * | monome_sprint (Pmonome pm, Pbase pb, bool plus_sign, char *(*variable_name)(Variable)) |
char monome_sprint(Pmonome pm, Pbase pb, bool plus_sign, char (*variable_name)()) PRIVATE Outputs a string representing monomial pm, naming variables with the "variable-name" function, ordering them with the basis pb. More... | |
void | polynome_fprint (FILE *fd, Ppolynome pp, char *(*variable_name)(Variable), int *is_inferior_var) |
void polynome_fprint(FILE* fd, Ppolynome pp, char* (*variable_name)(), bool (*is_inferior_var)()) Outputs to file fd an ASCII form of polynomial pp, using the user-provided function variable_name(Variable var) to associate the "Variable" pointers with the variable names. More... | |
char * | polynome_sprint (Ppolynome pp, char *(*variable_name)(Variable), int *is_inferior_var) |
char polynome_sprint(Ppolynome pp, char (*variable_name)(), bool (*is_inferior_var)()) Outputs to file fd an ASCII form of polynomial pp, using the user-provided function variable_name(Variable var) to associate the "Variable" pointers with the variable names. More... | |
char * | default_variable_name (Variable var) |
char *default_variable_name(Variable var) returns for variable var the name "Vxxxx" where xxxx are four letters computed from (int) var. More... | |
int | default_is_inferior_var (Variable var1, Variable var2) |
bool default_is_inferior_var(Variable var1, Variable var2) return true if var1 is before var2, lexicographically, according to the "default_variable_name" naming. More... | |
int | default_is_inferior_varval (Pvecteur varval1, Pvecteur varval2) |
bool default_is_inferior_varval(Pvecteur varval1, Pvecteur varval2) return true if var1 is before var2, lexicographically, according to the "default_variable_name" naming. More... | |
int | default_is_inferior_pvarval (Pvecteur *pvarval1, Pvecteur *pvarval2) |
bool default_is_inferior_pvarval(Pvecteur * pvarval1, Pvecteur * pvarval2) return true if var1 is before var2, lexicographically, according to the "default_variable_name" naming. More... | |
static void | remove_blanks (char **ps) |
static float | parse_coeff (char **ps) |
static char * | parse_var_name (char **ps) |
Ppolynome | polynome_sscanf (char *sp, Variable(*name_to_variable)(Variable)) |
Ppolynome polynome_sscanf(char *sp, (*name_to_variable)()) converts into polynomial structure the expression passed in ASCII form in string sp. More... | |
#define POLYNOME_BUFFER_SIZE 20480 |
bool default_is_inferior_pvarval(Pvecteur * pvarval1, Pvecteur * pvarval2) return true if var1 is before var2, lexicographically, according to the "default_variable_name" naming.
pvarval1 | varval1 |
pvarval2 | varval2 |
Definition at line 286 of file pnome-io.c.
References default_variable_name(), and vecteur_var.
Referenced by block_to_complexity(), final_statement_to_complexity_evaluation(), and polynome_equal().
bool default_is_inferior_var(Variable var1, Variable var2) return true if var1 is before var2, lexicographically, according to the "default_variable_name" naming.
var1 | ar1 |
var2 | ar2 |
Definition at line 265 of file pnome-io.c.
References default_variable_name().
bool default_is_inferior_varval(Pvecteur varval1, Pvecteur varval2) return true if var1 is before var2, lexicographically, according to the "default_variable_name" naming.
varval1 | arval1 |
varval2 | arval2 |
Definition at line 276 of file pnome-io.c.
References default_variable_name(), and vecteur_var.
char* default_variable_name | ( | Variable | var | ) |
char *default_variable_name(Variable var) returns for variable var the name "Vxxxx" where xxxx are four letters computed from (int) var.
I guess that many variables can have the same name since the naming is done modulo 26^4 ? RK. To be fixed...
var | ar |
Definition at line 242 of file pnome-io.c.
References intptr_t, malloc(), and TCST.
Referenced by default_is_inferior_pvarval(), default_is_inferior_var(), and default_is_inferior_varval().
void float_to_frac | ( | float | x, |
char ** | ps | ||
) |
void float_to_frac(float x, char** ps) PRIVATE returns the simplest representation of floating-point number x tries to make an integer, then a small fraction, then a floating-point, then a floating-point with exponent.
if too little or too big print it with an exponent
default printing: as a float
if x is close enough up to a little fraction
rint it as a fraction
Definition at line 54 of file pnome-io.c.
References intpower(), PNOME_FLOAT_N_DECIMALES, PNOME_FLOAT_TO_EXP_LEVEL, PNOME_FLOAT_TO_FRAC_LEVEL, and x.
Referenced by monome_sprint().
void monome_fprint | ( | FILE * | fd, |
Pmonome | pm, | ||
Pbase | pb, | ||
bool | plus_sign, | ||
char * (*)(Variable) | variable_name | ||
) |
void monome_fprint(FILE* fd, Pmonome pm, Pbase pb, bool plus_sign, char* (*variable_name)()) PRIVATE Outputs to file fd an ASCII form of monomial pm, naming variables with the "variable-name" function, ordering them with the basis pb.
the "+" sign is printed if plus_sign == true.
Definition at line 90 of file pnome-io.c.
References fprintf(), free(), monome_sprint(), and variable_name().
char monome_sprint(Pmonome pm, Pbase pb, bool plus_sign, char (*variable_name)()) PRIVATE Outputs a string representing monomial pm, naming variables with the "variable-name" function, ordering them with the basis pb.
the "+" sign is printed if plus_sign == true.
Definition at line 109 of file pnome-io.c.
References float_to_frac(), free(), malloc(), monome_coeff, MONOME_COEFF_MULTIPLY_SYMBOL, MONOME_NUL_SYMBOL, monome_term, MONOME_UNDEFINED_P, MONOME_UNDEFINED_SYMBOL, MONOME_VAR_MULTIPLY_SYMBOL, strdup(), TCST, variable_name(), vect_coeff(), vect_sprint_as_monome(), and x.
Referenced by monome_fprint(), and polynome_sprint().
|
static |
handle fractionnal coefficients
Definition at line 307 of file pnome-io.c.
Referenced by polynome_sscanf().
|
static |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
THE ':' STANDS FOR MODULE_SEP_STRING OF Linear/C3 Library
TO BE ABLE TO HANDLE VARIABLES SUCH AS P:I
Definition at line 337 of file pnome-io.c.
References malloc(), and MAX_NAME_LENGTH.
Referenced by polynome_sscanf().
void polynome_fprint | ( | FILE * | fd, |
Ppolynome | pp, | ||
char * (*)(Variable) | variable_name, | ||
int * | is_inferior_var | ||
) |
void polynome_fprint(FILE* fd, Ppolynome pp, char* (*variable_name)(), bool (*is_inferior_var)()) Outputs to file fd an ASCII form of polynomial pp, using the user-provided function variable_name(Variable var) to associate the "Variable" pointers with the variable names.
is_inferior_var(Variable var1, Variable var2) is also given by the user: it must return true if var1 must be printed before var2 in monomials.
For the moment, monomials are not sorted. No "\n" is printed after the polynomial.
Definition at line 173 of file pnome-io.c.
References fprintf(), free(), is_inferior_var(), polynome_sprint(), and variable_name().
Referenced by fprint_pla_pp_dims(), is_not_trivial_p(), mapping_on_broadcast(), nullify_factors(), partition_unknowns(), plc_fprint_distance(), plc_fprint_proto(), plc_make_distance(), prgm_mapping(), prototype_dimension(), prp(), and valuer().
char polynome_sprint(Ppolynome pp, char (*variable_name)(), bool (*is_inferior_var)()) Outputs to file fd an ASCII form of polynomial pp, using the user-provided function variable_name(Variable var) to associate the "Variable" pointers with the variable names.
is_inferior_var(Variable var1, Variable var2) is also given by the user: it must return true if var1 must be printed before var2 in monomials.
For the moment, monomials are not sorted. No "\n" is printed after the polynomial.
The following line is added by L.Zhou Mar. 26, 91
Definition at line 197 of file pnome-io.c.
References assert, free(), is_inferior_var(), monome_sprint(), POLYNOME_BUFFER_SIZE, polynome_monome, POLYNOME_NUL_P, POLYNOME_NUL_SYMBOL, polynome_sort(), polynome_succ, POLYNOME_UNDEFINED_P, POLYNOME_UNDEFINED_SYMBOL, polynome_used_var(), strdup(), and variable_name().
Referenced by complexity_sprint(), and polynome_fprint().
Ppolynome polynome_sscanf(char *sp, (*name_to_variable)()) converts into polynomial structure the expression passed in ASCII form in string sp.
(for debug only) pas vraiment quick mais bien dirty
printf(stderr, "\ns='%s'\n", s);
printf(stderr, "au milieu: s='%s'\n", s);
sp | p |
Definition at line 359 of file pnome-io.c.
References float_to_value, make_monome(), MONOME_NUL_P, monome_rm(), monome_term, name_to_variable(), parse_coeff(), parse_var_name(), polynome_monome_add(), POLYNOME_NUL, remove_blanks(), strdup(), VALUE_ONE, and vect_add_elem().
|
static |
Definition at line 292 of file pnome-io.c.
Referenced by polynome_sscanf().