1 # ifndef CPPAD_LOCAL_SPARSE_PACK_HPP
2 # define CPPAD_LOCAL_SPARSE_PACK_HPP
17 namespace CppAD {
namespace local {
22 class sparse_pack_const_iterator;
84 for(
size_t i = 0; i < right.
size(); ++i)
176 {
static Pack one(1);
179 for(
size_t k = 0; k <
n_pack_; k++)
183 for(
size_t bit = 0; bit < n; bit++)
235 {
static Pack one(1);
238 size_t j = element /
n_bit_;
239 size_t k = element - j *
n_bit_;
240 Pack mask = one << k;
254 {
static Pack one(1);
258 size_t j = element /
n_bit_;
259 size_t k = element - j *
n_bit_;
260 Pack mask = one << k;
310 size_t t = this_target *
n_pack_;
311 size_t v = other_value *
n_pack_;
354 size_t t = this_target *
n_pack_;
355 size_t l = this_left *
n_pack_;
356 size_t r = other_right *
n_pack_;
399 size_t t = this_target *
n_pack_;
400 size_t l = this_left *
n_pack_;
401 size_t r = other_right *
n_pack_;
438 void print(
void)
const;
480 {
static Pack one(1);
496 {
static Pack one(1);
512 size_t mask = one << k;
558 { std::cout <<
"sparse_pack:\n";
559 for(
size_t i = 0; i <
n_set(); i++)
560 { std::cout <<
"set[" << i <<
"] = {";
562 while( *itr !=
end() )
564 if( *(++itr) !=
end() )
601 template<
class VectorSet>
604 const VectorSet& user ,
608 const char* error_msg )
612 internal.resize(n_set, end);
616 for(
size_t j = 0; j < end; j++)
617 {
for(
size_t i = 0; i < n_set; i++)
618 {
if( user[ j * n_set + i ] )
619 internal.add_element(i, j);
625 {
for(
size_t i = 0; i < n_set; i++)
626 {
for(
size_t j = 0; j < end; j++)
627 {
if( user[ i * end + j ] )
628 internal.add_element(i, j);
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
size_t operator*(void) const
obtain value of this element of the set of positive integers (end_ for no such element) ...
const size_t set_index_
index of this set in the vector of sets;
void resize(size_t n)
resize the vector (existing elements preserved when n <= capacity_).
void clear(void)
Remove all the elements from this vector and free its memory.
size_t n_set(void) const
Fetch n_set for vector of sets object.
size_t n_set_
Number of sets that we are representing (set by constructor and resize).
const size_t end_
Possible elements in each set are 0, 1, ..., end_ - 1;.
void operator=(const sparse_pack &other)
Assignment operator.
void print(void) const
Print the vector of sets (used for debugging)
void process_post(size_t i)
process post entries for a specific set.
size_t end_
Possible elements in each set are 0, 1, ..., end_ - 1 (set by constructor and resize).
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
const pod_vector< Pack > & data_
data for the entire vector of sets
size_t memory(void) const
Amount of memory used by this vector of sets.
sparse_pack_const_iterator & operator++(void)
advance to next element in this set
size_t end(void) const
Fetch end for this vector of sets object.
void binary_union(size_t this_target, size_t this_left, size_t other_right, const sparse_pack &other)
Assing a set equal to the union of two other sets.
File used to define pod_vector class.
void binary_union(size_t target, size_t left, const pod_vector< size_t > &right)
Assign a set equal to the union of a set and a vector;.
~sparse_pack(void)
Destructor.
void post_element(size_t i, size_t element)
Post an element for delayed addition to a set.
sparse_pack_const_iterator const_iterator
declare a const iterator
size_t next_element_
value of the next element in this set (use end_ for no such element exists; i.e., past end of the set...
size_t number_elements(size_t i) const
Count number of elements in a set.
void clear(size_t target)
Assign the empty set to one of the sets.
Vector of sets of postivie integers, each set stored as a packed boolean array.
sparse_pack_const_iterator(const sparse_pack &pack, size_t set_index)
construct a const_iterator for a set in a sparse_pack object
All tthese defaults correspond to errors.
pod_vector< Pack > data_
Data for all the sets.
size_t size(void) const
current number of elements in this vector.
const size_t n_pack_
Number of Pack values necessary to represent end_ bits.
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
bool is_element(size_t i, size_t element) const
Is an element of a set.
void assignment(size_t this_target, size_t other_value, const sparse_pack &other)
Assign one set equal to another set.
const size_t n_bit_
Number of bits per Pack value.
sparse_pack(const sparse_pack &v)
Make use of copy constructor an error.
void add_element(size_t i, size_t element)
Add one element to a set.
size_t n_pack_
Number of Pack values necessary to represent end_ bits. (set by constructor and resize).
const size_t n_bit_
Number of bits per Pack value.
cons_iterator for one set of positive integers in a sparse_pack object.
sparse_pack(void)
Default constructor (no sets)
void binary_intersection(size_t this_target, size_t this_left, size_t other_right, const sparse_pack &other)
Assing a set equal to the intersection of two other sets.
size_t capacity(void) const
current capacity (amount of allocated storage) for this vector.
size_t Pack
Type used to pack elements (should be the same as corresponding typedef in multiple_n_bit() in test_m...
sparse_pack::Pack Pack
Type used to pack elements in sparse_pack.
void sparsity_user2internal(sparse_list &internal, const VectorSet &user, size_t n_set, size_t end, bool transpose, const char *error_msg)
Copy a user vector of sets sparsity pattern to an internal sparse_list object.
void resize(size_t n_set, size_t end)
Change number of sets, set end, and initialize all sets as empty.