SheafSystem  0.0.0.0
sheaf::zn_to_bool Class Reference

A map from Zn (the integers mod n) to bools. A characteristic function used to represent subsets of Zn. More...

#include <zn_to_bool.h>

Public Types

enum  static_const_int { BITS_PER_WORD = std::numeric_limits<word_t>::digits }
 Number of bits per word. More...
 
typedef unsigned int word_t
 The type of the private, internal representation used for bits; Unsigned int is the type used in the interface to exchange bits with the public. Currently the two types are the same. More...
 

Public Member Functions

bool invariant () const
 Class Invariant. More...
 
 zn_to_bool ()
 Default constructor. More...
 
 zn_to_bool (const zn_to_bool &xother)
 Copy constructor. More...
 
 zn_to_bool (int xub, bool xinitialize=true)
 Create an instance with ub() = xub; if xinitialize, initialize so is_false() = true. More...
 
 zn_to_bool (int xub, unsigned *values)
 Create an instance with ub() = xub, initialized with bits from `values'. [j] is true if the bit at offset j from address `values' is 1 and false otherwise. More...
 
 ~zn_to_bool ()
 Destructor. More...
 
bool domain_is_valid () const
 True if domain properly allocated. More...
 
int ub () const
 The upper bound for the domain index. More...
 
bool index_in_bounds (int i) const
 True if index i is in bounds for this vector. More...
 
bool index_in_bounds (const block< int > *indices) const
 True if for all i in indices: i is in bounds for this vector. More...
 
int ct () const
 The number of members in the domain. More...
 
int true_ct () const
 The number of members with value = true. More...
 
int false_ct () const
 The number of members with value = false. More...
 
void extend_to (int xub)
 Make the upper bound at least xub. More...
 
size_t capacity () const
 The number of members this can extend_to() without reallocating. More...
 
bool operator[] (int i) const
 Value at i. More...
 
bool is_true_for (const block< int > *indices) const
 True if for all i in indices: member with index i is true. More...
 
bool is_false_for (const block< int > *indices) const
 True if for all i in indices: member with index i is false. More...
 
void put (int i, bool value)
 Sets i-th member to value. More...
 
void put (const block< int > *indices, bool value)
 For all i in indices: sets i-th member to value. More...
 
void force (int i, bool value)
 Sets the i-th member to value, extends the upper bound if necessary. More...
 
void put_not (int i)
 Sets i-th member to its complement. More...
 
void put_not (const block< int > *indices)
 For all i in indices: sets i-th member to its complement. More...
 
bool is_true () const
 True function is true everywhere on domain. More...
 
bool is_false () const
 True if function is false evrywhere on domain. More...
 
bool is_equal_to (const zn_to_bool *other) const
 OBSOLETE: use operator==(const zn_to_bool&). True if function is equal to other evrywhere on domain. More...
 
bool operator== (const zn_to_bool &other) const
 True if function is equal to other evrywhere on domain. More...
 
bool includes (const zn_to_bool *other) const
 True if this function is true everywhere other is true. More...
 
bool is_not (const zn_to_bool *other) const
 True if function is complement of other evrywhere on domain. More...
 
zn_to_boolmake_true ()
 Constant function true, auto-allocated. More...
 
void make_true_sa ()
 Constant function true, self-allocated.
Note on terminology: "true" is a keyword, so this function can not be just "true" More...
 
zn_to_boolmake_false ()
 Constant function false, auto-allocated.
Note on terminology: "false" is a keyword, so this function can not be just "false" More...
 
void make_false_sa ()
 Constant function false, self-allocated.
Note on terminology: "false" is a keyword, so this function can not be just "false" More...
 
zn_to_boolequal ()
 OBSOLETE; use copy contructor. More...
 
void equal_pa (const zn_to_bool *result)
 OBSOLETE; use assignment operator. More...
 
zn_to_booloperator= (const zn_to_bool &xother)
 Assignment operator. More...
 
zn_to_boolb_not ()
 Boolean complement, auto-allocated. More...
 
void b_not_pa (const zn_to_bool *other)
 Boolean complement, pre-allocated. More...
 
void b_not_sa ()
 Boolean complement, self-allocated. More...
 
zn_to_boolb_and (const zn_to_bool *other)
 This AND other, auto-allocated. More...
 
void b_and_pa (const zn_to_bool *other, zn_to_bool *result)
 This AND other, pre-allocated. More...
 
void b_and_sa (const zn_to_bool *other)
 This AND other, self-allocated. More...
 
zn_to_boolb_or (const zn_to_bool *other)
 This OR other, auto-allocated. More...
 
void b_or_pa (const zn_to_bool *other, zn_to_bool *result)
 This OR other, pre-allocated. More...
 
void b_or_sa (const zn_to_bool *other)
 This OR other, self-allocated. More...
 
zn_to_boolb_and_not (const zn_to_bool *other)
 This AND NOT other, auto-allocated. More...
 
void b_and_not_pa (const zn_to_bool *other, zn_to_bool *result)
 This AND NOT other, pre-allocated. More...
 
void b_and_not_sa (const zn_to_bool *other)
 This AND NOT other, self-allocated. More...
 

Friends

class index_iterator
 
class subposet
 
SHEAF_DLL_SPEC std::ostream & operator<< (std::ostream &os, zn_to_bool &zn)
 Insert zn_to_bool& zn into ostream& os. More...
 
SHEAF_DLL_SPEC size_t deep_size (const zn_to_bool &zn, bool xinclude_shallow)
 The deep size of the referenced object of type zn_to_bool. More...
 

Detailed Description

A map from Zn (the integers mod n) to bools. A characteristic function used to represent subsets of Zn.

Definition at line 52 of file zn_to_bool.h.

Member Typedef Documentation

◆ word_t

typedef unsigned int sheaf::zn_to_bool::word_t

The type of the private, internal representation used for bits; Unsigned int is the type used in the interface to exchange bits with the public. Currently the two types are the same.

Definition at line 160 of file zn_to_bool.h.

Member Enumeration Documentation

◆ static_const_int

Number of bits per word.

Hack:
Inline initialization of static const integral data members causes link error in MSC++; use enum instead.

Definition at line 167 of file zn_to_bool.h.

Constructor & Destructor Documentation

◆ zn_to_bool() [1/4]

sheaf::zn_to_bool::zn_to_bool ( )

Default constructor.

Postcondition

Definition at line 53 of file zn_to_bool.cc.

Referenced by invariant(), and zn_to_bool().

◆ zn_to_bool() [2/4]

sheaf::zn_to_bool::zn_to_bool ( const zn_to_bool xother)

Copy constructor.

Postcondition
  • is_equal_to(&xother)

Definition at line 77 of file zn_to_bool.cc.

References zn_to_bool().

◆ zn_to_bool() [3/4]

sheaf::zn_to_bool::zn_to_bool ( int  xub,
bool  xinitialize = true 
)

Create an instance with ub() = xub; if xinitialize, initialize so is_false() = true.

Precondition
  • xub >= 0
Postcondition

Definition at line 109 of file zn_to_bool.cc.

References zn_to_bool().

◆ zn_to_bool() [4/4]

sheaf::zn_to_bool::zn_to_bool ( int  xub,
unsigned *  values 
)

Create an instance with ub() = xub, initialized with bits from `values'. [j] is true if the bit at offset j from address `values' is 1 and false otherwise.

Precondition
  • xub > 0
  • values != 0
Hack:
an implicit assumption that values points to xub unsigned ints
Postcondition

Definition at line 141 of file zn_to_bool.cc.

References ~zn_to_bool().

◆ ~zn_to_bool()

sheaf::zn_to_bool::~zn_to_bool ( )

Destructor.

Definition at line 174 of file zn_to_bool.cc.

References domain_is_valid().

Referenced by zn_to_bool().

Member Function Documentation

◆ b_and()

sheaf::zn_to_bool * sheaf::zn_to_bool::b_and ( const zn_to_bool other)

This AND other, auto-allocated.

Precondition
Postcondition

Definition at line 1128 of file zn_to_bool.cc.

References b_and_pa(), invariant(), and ub().

Referenced by b_not_sa().

◆ b_and_not()

sheaf::zn_to_bool * sheaf::zn_to_bool::b_and_not ( const zn_to_bool other)

This AND NOT other, auto-allocated.

Precondition
Postcondition

Definition at line 1276 of file zn_to_bool.cc.

References b_and_not_pa(), invariant(), and ub().

Referenced by b_or_sa().

◆ b_and_not_pa()

void sheaf::zn_to_bool::b_and_not_pa ( const zn_to_bool other,
zn_to_bool result 
)

This AND NOT other, pre-allocated.

Precondition
  • (other != 0)
  • result != 0

Definition at line 1303 of file zn_to_bool.cc.

References b_and_not_sa(), and ub().

Referenced by b_and_not().

◆ b_and_not_sa()

void sheaf::zn_to_bool::b_and_not_sa ( const zn_to_bool other)

This AND NOT other, self-allocated.

Precondition

Definition at line 1329 of file zn_to_bool.cc.

References ub().

Referenced by b_and_not_pa().

◆ b_and_pa()

void sheaf::zn_to_bool::b_and_pa ( const zn_to_bool other,
zn_to_bool result 
)

This AND other, pre-allocated.

Precondition
  • (other != 0)
  • result != 0

Definition at line 1155 of file zn_to_bool.cc.

References b_and_sa(), and ub().

Referenced by b_and().

◆ b_and_sa()

void sheaf::zn_to_bool::b_and_sa ( const zn_to_bool other)

This AND other, self-allocated.

Precondition

Definition at line 1181 of file zn_to_bool.cc.

References b_or(), and ub().

Referenced by b_and_pa(), sheaf::subposet_member_iterator::initialize_filter(), and sheaf::depth_first_iterator::initialize_filter().

◆ b_not()

sheaf::zn_to_bool * sheaf::zn_to_bool::b_not ( )

Boolean complement, auto-allocated.

Postcondition
  • is_not(result)

Definition at line 1060 of file zn_to_bool.cc.

References b_not_pa(), and invariant().

Referenced by operator=().

◆ b_not_pa()

void sheaf::zn_to_bool::b_not_pa ( const zn_to_bool other)

Boolean complement, pre-allocated.

Definition at line 1087 of file zn_to_bool.cc.

References b_not_sa().

Referenced by b_not().

◆ b_not_sa()

void sheaf::zn_to_bool::b_not_sa ( )

Boolean complement, self-allocated.

Definition at line 1108 of file zn_to_bool.cc.

References b_and().

Referenced by b_not_pa().

◆ b_or()

sheaf::zn_to_bool * sheaf::zn_to_bool::b_or ( const zn_to_bool other)

This OR other, auto-allocated.

Precondition
Postcondition

Definition at line 1202 of file zn_to_bool.cc.

References b_or_pa(), invariant(), and ub().

Referenced by b_and_sa().

◆ b_or_pa()

void sheaf::zn_to_bool::b_or_pa ( const zn_to_bool other,
zn_to_bool result 
)

This OR other, pre-allocated.

Precondition
  • (other != 0)
  • result != 0

Definition at line 1229 of file zn_to_bool.cc.

References b_or_sa(), and ub().

Referenced by b_or().

◆ b_or_sa()

void sheaf::zn_to_bool::b_or_sa ( const zn_to_bool other)

This OR other, self-allocated.

Precondition

Definition at line 1255 of file zn_to_bool.cc.

References b_and_not(), and ub().

Referenced by b_or_pa().

◆ capacity()

size_t sheaf::zn_to_bool::capacity ( ) const

The number of members this can extend_to() without reallocating.

Definition at line 450 of file zn_to_bool.cc.

References is_true_for().

Referenced by extend_to().

◆ ct()

int sheaf::zn_to_bool::ct ( ) const

The number of members in the domain.

Postcondition
  • result >= 0

Definition at line 287 of file zn_to_bool.cc.

References true_ct().

Referenced by index_in_bounds().

◆ domain_is_valid()

bool sheaf::zn_to_bool::domain_is_valid ( ) const

True if domain properly allocated.

Definition at line 192 of file zn_to_bool.cc.

References ub().

Referenced by ~zn_to_bool().

◆ equal()

sheaf::zn_to_bool * sheaf::zn_to_bool::equal ( )

OBSOLETE; use copy contructor.

Postcondition
  • is_equal_to(result)

Definition at line 978 of file zn_to_bool.cc.

References equal_pa(), and invariant().

Referenced by make_false_sa().

◆ equal_pa()

void sheaf::zn_to_bool::equal_pa ( const zn_to_bool result)

OBSOLETE; use assignment operator.

Postcondition
  • is_equal_to(result)

Definition at line 1005 of file zn_to_bool.cc.

References operator=().

Referenced by equal(), sheaf::subposet::make_equal_to(), and sheaf::subposet::subposet().

◆ extend_to()

void sheaf::zn_to_bool::extend_to ( int  xub)

◆ false_ct()

int sheaf::zn_to_bool::false_ct ( ) const

The number of members with value = false.

Postcondition

Definition at line 346 of file zn_to_bool.cc.

References extend_to().

Referenced by true_ct().

◆ force()

void sheaf::zn_to_bool::force ( int  i,
bool  value 
)

◆ includes()

bool sheaf::zn_to_bool::includes ( const zn_to_bool other) const

True if this function is true everywhere other is true.

Precondition

Definition at line 821 of file zn_to_bool.cc.

References is_not(), and ub().

Referenced by operator==().

◆ index_in_bounds() [1/2]

bool sheaf::zn_to_bool::index_in_bounds ( int  i) const

True if index i is in bounds for this vector.

Postcondition
  • result == ((0 <= i) && (i < ub()))

Definition at line 233 of file zn_to_bool.cc.

Referenced by sheaf::subposet::contains_member(), and ub().

◆ index_in_bounds() [2/2]

bool sheaf::zn_to_bool::index_in_bounds ( const block< int > *  indices) const

True if for all i in indices: i is in bounds for this vector.

Definition at line 257 of file zn_to_bool.cc.

References ct().

◆ invariant()

bool sheaf::zn_to_bool::invariant ( ) const

Class Invariant.

Invariant

Definition at line 36 of file zn_to_bool.cc.

References zn_to_bool().

Referenced by b_and(), b_and_not(), b_not(), b_or(), equal(), make_false(), and make_true().

◆ is_equal_to()

bool sheaf::zn_to_bool::is_equal_to ( const zn_to_bool other) const

OBSOLETE: use operator==(const zn_to_bool&). True if function is equal to other evrywhere on domain.

Precondition

Definition at line 763 of file zn_to_bool.cc.

References operator==(), and ub().

Referenced by is_false().

◆ is_false()

bool sheaf::zn_to_bool::is_false ( ) const

True if function is false evrywhere on domain.

Definition at line 735 of file zn_to_bool.cc.

References is_equal_to().

Referenced by is_true(), make_false(), and sheaf::poset_traverser::no_members_visited().

◆ is_false_for()

bool sheaf::zn_to_bool::is_false_for ( const block< int > *  indices) const

True if for all i in indices: member with index i is false.

Precondition
  • index_in_bounds(indices)

Definition at line 507 of file zn_to_bool.cc.

References put().

Referenced by is_true_for().

◆ is_not()

bool sheaf::zn_to_bool::is_not ( const zn_to_bool other) const

True if function is complement of other evrywhere on domain.

Precondition

Definition at line 852 of file zn_to_bool.cc.

References make_true(), and ub().

Referenced by includes().

◆ is_true()

bool sheaf::zn_to_bool::is_true ( ) const

True function is true everywhere on domain.

Definition at line 707 of file zn_to_bool.cc.

References is_false().

Referenced by make_true(), and put_not().

◆ is_true_for()

bool sheaf::zn_to_bool::is_true_for ( const block< int > *  indices) const

True if for all i in indices: member with index i is true.

Precondition
  • index_in_bounds(indices)

Definition at line 477 of file zn_to_bool.cc.

References is_false_for().

Referenced by capacity().

◆ make_false()

sheaf::zn_to_bool * sheaf::zn_to_bool::make_false ( )

Constant function false, auto-allocated.
Note on terminology: "false" is a keyword, so this function can not be just "false"

Postcondition

Definition at line 930 of file zn_to_bool.cc.

References invariant(), is_false(), and make_false_sa().

Referenced by make_true_sa(), and fields::field_eval_iterator::reset().

◆ make_false_sa()

void sheaf::zn_to_bool::make_false_sa ( )

Constant function false, self-allocated.
Note on terminology: "false" is a keyword, so this function can not be just "false"

Postcondition

Definition at line 955 of file zn_to_bool.cc.

References equal().

Referenced by make_false(), sheaf::poset_traverser::mark_members_not_visited(), and sheaf::depth_first_iterator::reset().

◆ make_true()

sheaf::zn_to_bool * sheaf::zn_to_bool::make_true ( )

Constant function true, auto-allocated.

Postcondition

Definition at line 880 of file zn_to_bool.cc.

References invariant(), is_true(), and make_true_sa().

Referenced by is_not().

◆ make_true_sa()

void sheaf::zn_to_bool::make_true_sa ( )

Constant function true, self-allocated.
Note on terminology: "true" is a keyword, so this function can not be just "true"

Postcondition

Definition at line 907 of file zn_to_bool.cc.

References make_false().

Referenced by make_true().

◆ operator=()

sheaf::zn_to_bool & sheaf::zn_to_bool::operator= ( const zn_to_bool xother)

Assignment operator.

Postcondition
  • *this == xother

Definition at line 1028 of file zn_to_bool.cc.

References b_not().

Referenced by equal_pa().

◆ operator==()

bool sheaf::zn_to_bool::operator== ( const zn_to_bool other) const

True if function is equal to other evrywhere on domain.

Precondition
  • other.ub() == ub()

Definition at line 791 of file zn_to_bool.cc.

References includes(), and ub().

Referenced by is_equal_to().

◆ operator[]()

bool sheaf::zn_to_bool::operator[] ( int  i) const
inline

Value at i.

Precondition
  • index_in_bounds(i)

Definition at line 217 of file zn_to_bool.h.

References sheaf::operator==().

◆ put() [1/2]

◆ put() [2/2]

void sheaf::zn_to_bool::put ( const block< int > *  indices,
bool  value 
)

For all i in indices: sets i-th member to value.

Precondition
  • indices != 0
  • index_in_bounds(indices)
Postcondition
  • val ? is_true_for(indices) : is_false_for(indices)

Definition at line 570 of file zn_to_bool.cc.

References sheaf::auto_block< T, S >::ct(), and force().

◆ put_not() [1/2]

void sheaf::zn_to_bool::put_not ( int  i)

Sets i-th member to its complement.

Precondition
  • index_in_bounds(xindex)
Postcondition

Definition at line 639 of file zn_to_bool.cc.

Referenced by force().

◆ put_not() [2/2]

void sheaf::zn_to_bool::put_not ( const block< int > *  indices)

For all i in indices: sets i-th member to its complement.

Precondition
  • indices != 0
  • index_in_bounds(indices)
Postcondition
  • -unexecutable( "for all i in indices: (*this)[i] = ! old (*this)[i]" )

Definition at line 670 of file zn_to_bool.cc.

References sheaf::auto_block< T, S >::ct(), and is_true().

◆ true_ct()

int sheaf::zn_to_bool::true_ct ( ) const

The number of members with value = true.

Postcondition
  • result >= 0

Definition at line 306 of file zn_to_bool.cc.

References false_ct().

Referenced by ct().

◆ ub()

Friends And Related Function Documentation

◆ deep_size

SHEAF_DLL_SPEC size_t deep_size ( const zn_to_bool zn,
bool  xinclude_shallow 
)
friend

The deep size of the referenced object of type zn_to_bool.

◆ operator<<

SHEAF_DLL_SPEC std::ostream& operator<< ( std::ostream &  os,
zn_to_bool zn 
)
friend

Insert zn_to_bool& zn into ostream& os.


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