polylib: vector.c File Reference

# vector.c File Reference

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <polylib/polylib.h>`

Go to the source code of this file.

## Defines
#define | MAX_CACHE_SIZE 20
## Functions
void | Factorial (int n, Value *fact)
void | Binomial (int n, int p, Value *result)
void | CNP (int a, int b, Value *result)
void | Gcd (Value a, Value b, Value *result)
int | First_Non_Zero (Value *p, unsigned length)
Vector * | Vector_Alloc (unsigned length)
void | Vector_Free (Vector *vector)
void | Vector_Print (FILE *Dst, const char *Format, Vector *vector)
Vector * | Vector_Read ()
void | Vector_Set (Value *p, int n, unsigned length)
void | Vector_Exchange (Value *p1, Value *p2, unsigned length)
void | Vector_Copy (Value *p1, Value *p2, unsigned length)
void | Vector_Add (Value *p1, Value *p2, Value *p3, unsigned length)
void | Vector_Sub (Value *p1, Value *p2, Value *p3, unsigned length)
void | Vector_Or (Value *p1, Value *p2, Value *p3, unsigned length)
void | Vector_Scale (Value *p1, Value *p2, Value lambda, unsigned length)
void | Vector_AntiScale (Value *p1, Value *p2, Value lambda, unsigned length)
void | Vector_Oppose (Value *p1, Value *p2, unsigned len)
void | Inner_Product (Value *p1, Value *p2, unsigned length, Value *ip)
void | Vector_Max (Value *p, unsigned length, Value *max)
void | Vector_Min (Value *p, unsigned length, Value *min)
void | Vector_Combine (Value *p1, Value *p2, Value *p3, Value lambda, Value mu, unsigned length)
int | Vector_Equal (Value *Vec1, Value *Vec2, unsigned n)
void | Vector_Min_Not_Zero (Value *p, unsigned length, int *index, Value *min)
void | Vector_Gcd (Value *p, unsigned length, Value *min)
void | Vector_Map (Value *p1, Value *p2, Value *p3, unsigned length, Value *(*f)(Value, Value))
void | Vector_Normalize (Value *p, unsigned length)
void | Vector_Normalize_Positive (Value *p, int length, int pos)
void | Vector_Reduce (Value *p, unsigned length, void(*f)(Value, Value *), Value *r)
void | Vector_Sort (Value *vector, unsigned n)
int | ConstraintSimplify (Value *old, Value *newp, int len, Value *v)
int | Vector_IsZero (Value *v, unsigned length)
Value * | value_alloc (int want, int *got)
void | value_free (Value *p, int size)
## Variables
struct {
Value * p
int size
} | cache [MAX_CACHE_SIZE]
static int | cache_size = 0

## Define Documentation

#define MAX_CACHE_SIZE 20

Definition at line 758 of file vector.c.

Referenced by value_free().

## Function Documentation

void Binomial | ( | int | n,
|  | int | p,
|  | Value * | result |
| ) |  |  |

Definition at line 61 of file vector.c.

References Factorial(), value_clear, value_division, value_init, value_multiply, and value_set_si.

void CNP | ( | int | a,
|  | int | b,
|  | Value * | result |
| ) |  |  |

Definition at line 89 of file vector.c.

References value_clear, value_division, value_init, value_multiply, and value_set_si.

int ConstraintSimplify | ( | Value * | old,
|  | Value * | newp,
|  | int | len,
|  | Value * | v |
| ) |  |  |

Definition at line 730 of file vector.c.

References value_notone_p, value_one_p, value_pdivision, Vector_AntiScale(), and Vector_Gcd().

Referenced by Constraints2Polyhedron(), and p_simplify_constraints().

void Factorial | ( | int | n,
|  | Value * | fact |
| ) |  |  |

Definition at line 43 of file vector.c.

References value_clear, value_init, value_multiply, and value_set_si.

Referenced by Binomial().

int First_Non_Zero | ( | Value * | p,
|  | unsigned | length |
| ) |  |  |

Definition at line 137 of file vector.c.

References value_notzero_p.

Referenced by Constraints2Polyhedron(), Constraints_Remove_parm_eqs(), ImplicitEqualities(), Remove_Redundants(), and Vector_Min_Not_Zero().

void Gcd | ( | Value | a,
|  | Value | b,
|  | Value * | result |
| ) |  |  |

Definition at line 116 of file vector.c.

References value_absolute, value_assign, value_clear, value_init, value_modulus, and value_notzero_p.

Referenced by Lcm3().

void Inner_Product | ( | Value * | p1,
|  | Value * | p2,
|  | unsigned | length,
|  | Value * | ip |
| ) |  |  |

Definition at line 384 of file vector.c.

References value_addmul, value_multiply, and value_set_si.

Referenced by lower_upper_bounds(), and test_Constraints_fullDimensionize().

Value* value_alloc | ( | int | want,
|  | int * | got |
| ) |  |  |

Definition at line 765 of file vector.c.

References cache, size, value_init, and Vector_Set().

Referenced by Matrix_Alloc(), and Polyhedron_Alloc().

void value_free | ( | Value * | p,
|  | int | size |
| ) |  |  |

Definition at line 807 of file vector.c.

References cache, MAX_CACHE_SIZE, and value_clear.

Referenced by Matrix_Free(), and Polyhedron_Free().

void Vector_Add | ( | Value * | p1,
|  | Value * | p2,
|  | Value * | p3,
|  | unsigned | length |
| ) |  |  |

Definition at line 286 of file vector.c.

References value_addto.

Vector* Vector_Alloc | ( | unsigned | length | ) |

Definition at line 154 of file vector.c.

References errormsg1(), Vector::p, Vector::Size, and value_init.

Referenced by DomainConstraintSimplify(), Orthogonal_Base(), Param_Polyhedron_Scale_Integer(), Polyhedron_Image_Enumerate(), Remove_Redundants(), SolveDiophantine(), and Vector_Read().

void Vector_AntiScale | ( | Value * | p1,
|  | Value * | p2,
|  | Value | lambda,
|  | unsigned | length |
| ) |  |  |

Definition at line 362 of file vector.c.

References value_divexact.

Referenced by ConstraintSimplify(), Gauss4(), mpolyhedron_simplify(), Orthogonal_Base(), Rays_Mult(), Rays_Mult_Transpose(), Vector_Normalize(), and Vector_Normalize_Positive().

void Vector_Combine | ( | Value * | p1,
|  | Value * | p2,
|  | Value * | p3,
|  | Value | lambda,
|  | Value | mu,
|  | unsigned | length |
| ) |  |  |

Definition at line 434 of file vector.c.

References value_addmul, value_assign, value_clear, value_init, and value_multiply.

Referenced by Combine(), GaussSimplify(), and old_Polyhedron_Preprocess().

void Vector_Copy | ( | Value * | p1,
|  | Value * | p2,
|  | unsigned | length |
| ) |  |  |

Definition at line 269 of file vector.c.

References value_assign.

Referenced by AddConstraints(), AddRays(), align_context(), Chernikova(), ComputeNPLinesRays(), Constraints2Polyhedron(), Constraints_Remove_parm_eqs(), Constraints_removeElimCols(), dehomogenize_polyhedron(), DomainSimplify(), Find_m_faces(), FindSimple(), LexSmaller(), Matrix_copySubMatrix(), Matrix_subMatrix(), p_simplify_constraints(), Polyhedron2Constraints(), Polyhedron2Rays(), Polyhedron_Copy(), Polyhedron_Preprocess(), Recession_Cone(), Remove_Redundants(), RemoveColumn(), RemoveNColumns(), RemoveRow(), right_hermite(), SimplifyConstraints(), SimplifyEqualities(), Stras_DomainSimplify(), SubConstraint(), and traite_m_face().

int Vector_Equal | ( | Value * | Vec1,
|  | Value * | Vec2,
|  | unsigned | n |
| ) |  |  |

Definition at line 453 of file vector.c.

References value_ne.

Referenced by Remove_Redundants().

void Vector_Exchange | ( | Value * | p1,
|  | Value * | p2,
|  | unsigned | length |
| ) |  |  |

Definition at line 256 of file vector.c.

References value_swap.

Referenced by Chernikova(), Gauss4(), GaussSimplify(), hermite(), RaySort(), Remove_Redundants(), and SortConstraints().

void Vector_Free | ( | Vector * | vector | ) |

Definition at line 179 of file vector.c.

References Vector::p, Vector::Size, and value_clear.

Referenced by DomainConstraintSimplify(), findHermiteBasis(), LatticeIntersection(), LatticePreimage(), main(), Param_Polyhedron_Scale_Integer(), Polyhedron_Image_Enumerate(), and Remove_Redundants().

void Vector_Gcd | ( | Value * | p,
|  | unsigned | length,
|  | Value * | min |
| ) |  |  |

Definition at line 498 of file vector.c.

References value_absolute, value_clear, value_init, value_modulus, value_notone_p, value_notzero_p, and Vector_Min_Not_Zero().

Referenced by ConstraintSimplify(), Gauss4(), GaussSimplify(), MatInverse(), Matrix_Inverse(), mpolyhedron_simplify(), Orthogonal_Base(), Rays_Mult(), Rays_Mult_Transpose(), Vector_Normalize(), and Vector_Normalize_Positive().

int Vector_IsZero | ( | Value * | v,
|  | unsigned | length |
| ) |  |  |

Definition at line 747 of file vector.c.

References value_notzero_p, value_set_si, and value_zero_p.

Referenced by eliminable_vars(), and int_ker().

void Vector_Map | ( | Value * | p1,
|  | Value * | p2,
|  | Value * | p3,
|  | unsigned | length,
|  | Value *(*)(Value, Value) | f |
| ) |  |  |

Definition at line 547 of file vector.c.

References value_assign.

void Vector_Max | ( | Value * | p,
|  | unsigned | length,
|  | Value * | max |
| ) |  |  |

Definition at line 399 of file vector.c.

References value_assign, and value_maximum.

void Vector_Min | ( | Value * | p,
|  | unsigned | length,
|  | Value * | min |
| ) |  |  |

Definition at line 416 of file vector.c.

References value_assign, and value_minimum.

void Vector_Min_Not_Zero | ( | Value * | p,
|  | unsigned | length,
|  | int * | index,
|  | Value * | min |
| ) |  |  |

Definition at line 469 of file vector.c.

References First_Non_Zero(), value_absolute, value_assign, value_clear, value_init, value_lt, value_set_si, and value_zero_p.

Referenced by Vector_Gcd().

void Vector_Normalize | ( | Value * | p,
|  | unsigned | length |
| ) |  |  |

Definition at line 568 of file vector.c.

References value_clear, value_init, value_notone_p, Vector_AntiScale(), and Vector_Gcd().

Referenced by Combine(), GaussSimplify(), old_Polyhedron_Preprocess(), and Param_Polyhedron_Scale_Integer().

void Vector_Normalize_Positive | ( | Value * | p,
|  | int | length,
|  | int | pos |
| ) |  |  |

Definition at line 587 of file vector.c.

References value_clear, value_init, value_neg_p, value_notone_p, value_oppose, Vector_AntiScale(), and Vector_Gcd().

Referenced by MatInverse(), and rat_prodmat().

void Vector_Oppose | ( | Value * | p1,
|  | Value * | p2,
|  | unsigned | len |
| ) |  |  |

Definition at line 373 of file vector.c.

References value_oppose.

Referenced by Gauss4().

void Vector_Or | ( | Value * | p1,
|  | Value * | p2,
|  | Value * | p3,
|  | unsigned | length |
| ) |  |  |

Definition at line 324 of file vector.c.

References value_orto.

void Vector_Print | ( | FILE * | Dst,
|  | const char * | Format,
|  | Vector * | vector |
| ) |  |  |

Definition at line 193 of file vector.c.

References Vector::p, p, P_VALUE_FMT, Vector::Size, and value_print.

Referenced by main().

Vector* Vector_Read | ( | void |  | ) |

Definition at line 215 of file vector.c.

References errormsg1(), Vector::p, p, value_read, and Vector_Alloc().

void Vector_Reduce | ( | Value * | p,
|  | unsigned | length,
|  | void(*)(Value, Value *) | f,
|  | Value * | r |
| ) |  |  |

Definition at line 604 of file vector.c.

References value_assign.

void Vector_Scale | ( | Value * | p1,
|  | Value * | p2,
|  | Value | lambda,
|  | unsigned | length |
| ) |  |  |

Definition at line 343 of file vector.c.

References value_multiply.

Referenced by Param_Polyhedron_Scale_Integer(), and Remove_Redundants().

void Vector_Set | ( | Value * | p,
|  | int | n,
|  | unsigned | length |
| ) |  |  |

Definition at line 240 of file vector.c.

References value_set_si.

Referenced by Constraints2Polyhedron(), Ehrhart_Quick_Apx_Full_Dim(), Empty_Polyhedron(), Enumerate_NoParameters(), Equalities_validityLattice(), FindSimple(), ImplicitEqualities(), left_hermite(), MatInverse(), Matrix_Extend(), Matrix_Inverse(), Polyhedron_Enumerate(), Polyhedron_Not_Empty(), Polyhedron_Scan(), PolyhedronLTQ(), Rays2Polyhedron(), Remove_Redundants(), right_hermite(), Universe_Polyhedron(), and value_alloc().

void Vector_Sort | ( | Value * | vector,
|  | unsigned | n |
| ) |  |  |

Definition at line 620 of file vector.c.

References value_assign, value_clear, value_init, and value_lt.

void Vector_Sub | ( | Value * | p1,
|  | Value * | p2,
|  | Value * | p3,
|  | unsigned | length |
| ) |  |  |

Definition at line 305 of file vector.c.

References value_subtract.

## Variable Documentation

struct { ... } cache[MAX_CACHE_SIZE]`[static]`

Referenced by value_alloc(), and value_free().

int cache_size = 0`[static]`

Definition at line 763 of file vector.c.

Value* p

Definition at line 760 of file vector.c.

Referenced by addeliminatedparams_evalue(), AddPolyToDomain(), aep_evalue(), AffConstraints(), AffinePartCompare(), AffineSmith(), align_context(), CalcBase(), DomainConvex(), DomainImage(), DomainPreimage(), emul(), Find_m_faces(), free_evalue_refs(), LinearPartCompare(), main(), Matrix_Alloc(), Matrix_Extend(), Matrix_Print(), Matrix_Read_Input(), new_eadd(), old_Polyhedron_Preprocess(), Orthogonal_Base(), Polyhedron_Alloc(), Polyhedron_Print(), PolyhedronTSort(), reduce_evalue(), Reduce_Matrix(), SMAlloc(), SMPrint(), SolveDiophantine(), Soustraire_ligne(), Vector_Print(), and Vector_Read().

int size

Definition at line 761 of file vector.c.

Referenced by GenParamPolyhedron(), and value_alloc().