Gröbner basis project
Codebase for research into Gröbner basis computation

a ray defined by nonnegative coordinates \((a_1,\ldots,a_n)\) More...

#include <lp_solver.hpp>

Public Member Functions

Construction
 ray (NVAR_TYPE, long=-1)
 Creates a ray with the given number of variables, all set to 0. More...
 
 ray (NVAR_TYPE, const RAYENT_TYPE [])
 Creates a ray with the given number of variables, with coordinates set to the value of the array. More...
 
 ray (NVAR_TYPE, const EXP_TYPE [])
 Creates a ray with the given number of variables, with coordinates set to the value of the array. More...
 
 ray (const vector< RAYENT_TYPE > &)
 Creates a ray whose coordinates are given by the vector. More...
 
 ray (const ray &)
 Copies the coordinates of the other ray. More...
 
Destruction
 ~ray ()
 Deletes memory allocated by the constructor. More...
 
Basic properies
NVAR_TYPE get_dimension () const
 Returns the dimension of this ray.
 
RAYENT_TYPE operator[] (NVAR_TYPE index) const
 Returns the entry indicated. Numbering starts at 0.
 
const RAYENT_TYPE * weights () const
 Returns the weights.
 
const RAYENT_TYPE coordinate (NVAR_TYPE index)
 Synonym for []. I have no idea why I added this.
 
bool is_active_at (const constraint &hyperplane) const
 Returns true if and only if the hyperplane is active at this ray. More...
 
bool is_above (constraint &hyperplane)
 Returns true if and only if this ray is above the hyperplane. More...
 
bool is_below (constraint &hyperplane)
 Returns true if and only if this ray is below the hyperplane. More...
 
Computation
DOTPROD_TYPE obtain_dot_product (const constraint &) const
 Convenience function to compute dot product between ray and constraint. More...
 
Modification
void simplify_ray ()
 Simplifies the ray by dividing its components by the least common denominator.
 
rayoperator= (const ray &)
 Assignment operator; assigns the value of other to this. More...
 
void swap (ray &)
 Swap two rays of equal dimension by swapping their data, avoiding memory reallocation. More...
 

Friends

Comparison
bool operator== (const ray &, const ray &)
 Indicates whether the two rays are equal. More...
 
bool operator!= (const ray &, const ray &)
 
bool operator!= (ray &r, ray &s)
 Indicates whether the two rays are unequal. More...
 
bool operator== (const ray &, const ray &)
 Returns true if and only if the coordinates of the two rays are equal. More...
 
bool operator< (const ray &, const ray &)
 Lexicographic comparison of rays. More...
 
I/O
ostream & operator<< (ostream &, const ray &)
 Output is of the form \((r_1, \ldots, r_n)\).
 

Detailed Description

a ray defined by nonnegative coordinates \((a_1,\ldots,a_n)\)

Author
John Perry
Version
1.0
Date
October 2014

This class encapsulates a ray, one major part of the definition of a skeleton. Rays can be initialized to a particular set of coefficients, or to a particular axis (which is then translated into the corresponding coefficients).

A special feature is that a rays can track the constraints known to be active at the ray, allowing for more efficient computation in the double description method. Adding known constraints can be done with or without checking whether the constraint actually is active, so this should be done with care.

Definition at line 165 of file lp_solver.hpp.

Constructor & Destructor Documentation

◆ ray() [1/5]

ray::ray ( NVAR_TYPE  dimension,
long  direction = -1 
)

Creates a ray with the given number of variables, all set to 0.

The optional second argument specifies a direction, and sets that coordinate to 1. In this case, there is no need to set the ray's known active constraints, as this is known and populated automatically.

Precondition
The dimension should be greater than zero. While the direction need not be specified… (see postcondition)
Postcondition
…the result when the direction is zero is a zero ray. If the direction is \( i \), then the result is the \(i\)th canonical vector.

Definition at line 115 of file lp_solver.cpp.

◆ ray() [2/5]

ray::ray ( NVAR_TYPE  dimension,
const RAYENT_TYPE  entries[] 
)

Creates a ray with the given number of variables, with coordinates set to the value of the array.

Precondition
the size of the array needs to be at least as long as the number of variables!

Definition at line 126 of file lp_solver.cpp.

◆ ray() [3/5]

ray::ray ( NVAR_TYPE  dimension,
const EXP_TYPE  entries[] 
)

Creates a ray with the given number of variables, with coordinates set to the value of the array.

Precondition
the size of the array needs to be at least as long as the number of variables!

Definition at line 135 of file lp_solver.cpp.

◆ ray() [4/5]

ray::ray ( const vector< RAYENT_TYPE > &  entries)

Creates a ray whose coordinates are given by the vector.

Postcondition
The dimension of this ray will equal the number of entries in the vector, and the values of their entries will be equal.

Definition at line 144 of file lp_solver.cpp.

◆ ray() [5/5]

ray::ray ( const ray old_ray)

Copies the coordinates of the other ray.

Allocates new memory, and copies the active constraints.

Definition at line 153 of file lp_solver.cpp.

◆ ~ray()

ray::~ray ( )

Deletes memory allocated by the constructor.

Currently, that means it deletes coords.

Definition at line 163 of file lp_solver.cpp.

Member Function Documentation

◆ is_above()

bool ray::is_above ( constraint hyperplane)
inline

Returns true if and only if this ray is above the hyperplane.

Practically speaking, if the hyperplane is defined by the vector \( \mathbf c \) and the ray is defined by \( \mathbf r \) , this function returns true if and only if \( c\cdot r > 0 \).

Definition at line 264 of file lp_solver.hpp.

◆ is_active_at()

bool ray::is_active_at ( const constraint hyperplane) const
inline

Returns true if and only if the hyperplane is active at this ray.

Practically speaking, if the hyperplane is defined by the vector \( \mathbf c \) and the ray is defined by \( \mathbf r \) , this function returns true if and only if \( c\cdot r = 0 \).

Definition at line 252 of file lp_solver.hpp.

◆ is_below()

bool ray::is_below ( constraint hyperplane)
inline

Returns true if and only if this ray is below the hyperplane.

Practically speaking, if the hyperplane is defined by the vector \( \mathbf c \) and the ray is defined by \( \mathbf r \) , this function returns true if and only if \( c\cdot r < 0 \).

Definition at line 276 of file lp_solver.hpp.

◆ obtain_dot_product()

DOTPROD_TYPE ray::obtain_dot_product ( const constraint hyperplane) const

Convenience function to compute dot product between ray and constraint.

Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 195 of file lp_solver.cpp.

◆ operator=()

ray & ray::operator= ( const ray other)

Assignment operator; assigns the value of other to this.

Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 313 of file lp_solver.cpp.

◆ swap()

void ray::swap ( ray other)

Swap two rays of equal dimension by swapping their data, avoiding memory reallocation.

Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 333 of file lp_solver.cpp.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( ray r,
ray s 
)
friend

Indicates whether the two rays are unequal.

Warning
This is unsafe when number of variables is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 299 of file lp_solver.hpp.

◆ operator<

bool operator< ( const ray first_ray,
const ray second_ray 
)
friend

Lexicographic comparison of rays.

Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 344 of file lp_solver.cpp.

◆ operator== [1/2]

bool operator== ( const ray r1,
const ray r2 
)
friend

Indicates whether the two rays are equal.

Warning
This is unsafe when number of variables is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 287 of file lp_solver.cpp.

◆ operator== [2/2]

bool operator== ( const ray r1,
const ray r2 
)
friend

Returns true if and only if the coordinates of the two rays are equal.

Warning
This is unsafe when number of variables is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 287 of file lp_solver.cpp.


The documentation for this class was generated from the following files: