MCPcopy Create free account
hub / github.com/coin-or/CppAD / post_element

Method post_element

include/cppad/local/sparse/svec_setvec.hpp:691–733  ·  view source on GitHub ↗

------------------------------------------------------------------ ! Post an element for delayed addition to a set. \param i is the index for this set in the vector of sets. \param element is the value of the element that we are posting. The same element may be posted multiple times. \par It is faster to post multiple elements to set i and then call process_post(i) th

Source from the content-addressed store, hash-verified

689 before processing the posts to set i.
690 */
691 void post_element(size_t i, size_t element)
692 { CPPAD_ASSERT_UNKNOWN( i < start_.size() );
693 CPPAD_ASSERT_UNKNOWN( element < end_ );
694
695 size_t post = post_[i];
696 if( post == 0 )
697 { // minimum capacity for an post vector
698 size_t min_capacity = 10;
699 size_t post_new = data_.extend(min_capacity + 2);
700 data_[post_new] = 1; // length
701 data_[post_new + 1] = min_capacity; // capacity
702 data_[post_new + 2] = element;
703 post_[i] = post_new;
704 }
705 else
706 { size_t length = data_[post];
707 size_t capacity = data_[post + 1];
708 if( length == capacity )
709 {
710 size_t post_new = data_.extend( 2 * capacity );
711 //
712 data_[post_new] = length + 1;
713 data_[post_new + 1] = 2 * capacity;
714 //
715 for(size_t j = 0; j < length; j++)
716 data_[post_new + 2 + j] = data_[post + 2 + j];
717 data_[post_new + 2 + length] = element;
718 //
719 post_[i] = post_new;
720 size_t number_lost = length + 2;
721 data_not_used_ += number_lost;
722 }
723 else
724 { data_[post] = length + 1;
725 data_[post + 2 + length] = element;
726 }
727 }
728
729 // check amount of data_not_used_
730 collect_garbage();
731
732 return;
733 }
734 // -----------------------------------------------------------------
735 /*!
736 process post entries for a specific set.

Callers 15

test_postFunction · 0.45
RevSparseJacCaseMethod · 0.45
ForSparseJacCaseMethod · 0.45
for_hes_sparsityMethod · 0.45
for_jac_sparsityMethod · 0.45
rev_jac_sparsityMethod · 0.45
for_hes_sparsityMethod · 0.45
for_jac_sparsityMethod · 0.45

Calls 2

sizeMethod · 0.45
extendMethod · 0.45

Tested by 1

test_postFunction · 0.36