void set_to_zero(Coll& collection, tag::std_vector, ashape::scal) { using math::zero; typename Collection<Coll>::value_type ref, my_zero(zero(ref)); std::fill(collection.begin(), collection.end(), my_zero); }
void set_to_zero(Coll& collection, tag::contiguous_dense, ashape::scal) { using math::zero; typename Collection<Coll>::value_type ref, my_zero(zero(ref)); std::fill(collection.elements(), collection.elements()+collection.used_memory(), my_zero); }
int main(int, char**) try { dummies_.clear(); for(int i = 0; i < 12; ++i) dummies_.push_back(Dummy(i)); test(vector<Dummy>()); test(RefVector<Coll>()); test(PtrVector<Dummy>()); test(OwnVector<Dummy>()); return 0; } catch(cms::Exception const& e) { std::cerr << e.explainSelf() << std::endl; return 1; } catch(std::exception const& e) { std::cerr << e.what() << std::endl; return 1; }
inline void tokenize(const std::string& str, Coll &token, const std::string& separators = std::string(" /\t:,()")) { std::string input(str); std::string::size_type idx = 0; if ((idx = input.find_first_not_of(separators)) == std::string::npos) { return; } input = input.substr(idx); while ((idx = input.find_first_of(separators)) != std::string::npos) { token.push_back(input.substr(0, idx)); input = input.substr(idx + 1); idx = input.find_first_not_of(separators); if (idx == std::string::npos) { break; } input = input.substr(idx); } if ((input.find_first_of(separators)) == std::string::npos) { token.push_back(input); } }
void PartyShuffle::setOperand( Coll& operand ) { removeOperand(); xmmsv_coll_add_operand( coll_, operand.getColl() ); }
void Unary::setOperand( Coll& operand ) { removeOperand(); xmmsv_coll_add_operand( coll_, operand.getColl() ); }
void Nary::removeOperand( Coll& operand ) { xmmsv_coll_remove_operand( coll_, operand.getColl() ); }
void Nary::addOperand( Coll& operand ) { xmmsv_coll_add_operand( coll_, operand.getColl() ); }
void set_to_zero(Coll& collection, tag::sparse, ashape::universe) { collection.make_empty(); }
void set_to_zero(Coll& collection, tag::contiguous_dense, ashape::nonscal) { for (typename Collection<Coll>::size_type i= 0; i < collection.used_memory(); ++i) set_to_zero(collection.value_n(i)); }
void set_to_zero(Coll& collection, tag::multi_vector, ashape::universe) { using mtl::vector::set_to_zero; for (typename Collection<Coll>::size_type i= 0; i < num_cols(collection); ++i) set_to_zero(collection.vector(i)); }