Example #1
0
 FrobeniusLossWeighted(data_type const& data)
     : 	n_samples(data.get_A().n_samples),
        n_responses(data.get_B().n_groups),
        Y(data.get_B().response),
        W(data.get_C().data),
        lp(n_samples, n_responses) {
 }
Example #2
0
std::string document_info_context_to<DocumentInfo>::
	to_string(const data_type& from) const
{
	std::stringstream stream;
	on_stream_setup(stream);
	stream << from->get_owner_id() << ' ' << from->get_id();
	return stream.str();
}
Example #3
0
void Ecppll::onHtml(const std::string& html)
{
  if (inLang)
  {
    std::ostringstream msg;
    std::transform(
      html.begin(),
      html.end(),
      std::ostream_iterator<const char*>(msg),
      tnt::stringescaper(false));

    bool found = true;

    if (next == replacetokens.end()
     || next->first != msg.str())
    {
      // nächster Token passt nicht (oder kommt keiner mehr) - suche, ob wir ihn
      // noch finden
      replacetokens_type::const_iterator it;
      for (it = next;
           it != replacetokens.end() && it->first != msg.str();
           ++it)
        ;

      if (it == replacetokens.end())
      {
        std::cerr << "warning: replacement-text \"" << html << "\" not found ("
          << data.size() << ')'
          << std::endl;
        warn();
        found = false;
      }
      else
      {
        for (replacetokens_type::const_iterator it2 = next;
             it2 != it; ++it2)
          std::cerr << "warning: replacement-text \"" << it2->first << "\" skipped ("
            << data.size() << ')'
            << std::endl;
        next = it;
        warn();
      }
    }

    if (found)
    {
      data.push_back(next->second);
      ++next;
    }
    else
      data.push_back(html);
  }
  else
  {
    data.push_back(html);
  }
}
 // Обязателен вызов перед формированием ответа адвайсом пользователя
 void reserve(size_t s) 
 {
   /*if ( _data.size() < s + 128 )
   {*/
     _data.resize(s + 16635, 0);
     char* beg = &(_data[0]);
     char* end = beg + _data.size();
     _outgoing = amj::json_pack( beg, end );
   // }
 }
Example #5
0
void session_interface::save_data(data_type const &data,std::string &s)
{
	s.clear();
	data_type::const_iterator p;
	for(p=data.begin();p!=data.end();++p) {
		packed header(p->first.size(),p->second.exposed,p->second.value.size());
		char *ptr=(char *)&header;
		s.append(ptr,ptr+sizeof(header));
		s.append(p->first.begin(),p->first.end());
		s.append(p->second.value.begin(),p->second.value.end());
	}
}
void task4_5::solution::start(const data_type& data) const
{
	if (data.size()==0)
	{
		min=max=0;
		return;
	}
	boost::thread_group t;
	for (int i=0;i<data.size();i++)
		t.create_thread( boost::bind(&task4_5::solution::solve,this,boost::ref(data[i])));
	t.join_all();
}
Example #7
0
 void datastructure::data_write(std::string const& symbolic_name
     , std::size_t num_instances, std::size_t my_cardinality
     , data_type client_data)
 {
     // get_config(gid_component);  implement?
     //distributed::config_comp config_data = get_config();
     if(config_data_.my_cardinality_ != my_cardinality)
         config_data_.my_cardinality_ = my_cardinality;
     if(data_.size() != client_data.size())
         data_.resize(client_data.size());
     data_ = client_data;
     for (data_type::iterator itr = data_.begin(); itr != data_.end(); ++itr)
         std::cout << "Data:" << *itr << std::endl;
     std::cout<< "Write Data Part for component:" << my_cardinality << std::endl;
 }
Example #8
0
task4_5::solution::solution( const data_type& data )
{
	if(!data.empty())
	{
		m_max = data[0][0];
		m_min = data[0][0];
		m_current_vector = data.size();
		calculate_result(data);
	}
	else
	{
		m_max = 0;
		m_min = 0;
	}
}
 void decrement_use_count()
 {
     if (0 == --ref_count_)
     {
         data_.second()(this);
     }
 }
			void put(data_type const & E, std::pair<uint64_t,uint64_t> const & P)
			{
				libmaus2::util::NumberSerialisation::serialiseNumber(stream,P.first);
				libmaus2::util::NumberSerialisation::serialiseNumber(stream,P.second);
				E.serialise(stream);				
				ic += 1;
			}
        T get_value(Key const& key, bool erase)
        {
            typename data_type::iterator it = partition_unordered_map_.find(key);
            if (it == partition_unordered_map_.end())
            {
                HPX_THROW_EXCEPTION(bad_parameter,
                    "partition_unordered_map::get_value",
                    "unable to find requested key in this partition of the "
                    "unordered_map");
            }

            if (!erase)
                return it->second;

            erase_on_exit t(partition_unordered_map_, it);
            return it->second;
        }
Example #12
0
task4_5::solution::solution( const data_type& data )
{
	
	min_of_min = INT32_MAX;
	max_of_max = INT32_MIN;
	curr_vector = data.begin();
	end_of_data = data.end();
	data_size = data.size();
	
	for( size_t i = 0; i < threads_count; i++ )
	{
		threads.create_thread( boost::bind( &task4_5::solution::solve, this  ) );
	}

	threads.join_all();

}
Example #13
0
void task4_5:: solution:: create_thr( const data_type& data) 
{
	boost::thread_group tg;
	for( size_t i = 1; i < data.size(); ++i )
		tg.create_thread( boost::bind( &solution::process, this , boost::ref(data[i]) ) );

	tg.join_all();
	
}
        /// Copy the value of \a val for the elements at positions \a pos in
        /// the partition_unordered_map container.
        ///
        /// \param pos   Positions of the elements in the partition_unordered_map
        ///
        /// \param val   The value to be copied
        ///
        void set_values(std::vector<Key> const& keys,
            std::vector<T> const& val)
        {
            HPX_ASSERT(keys.size() == val.size());
            HPX_ASSERT(keys.size() <= partition_unordered_map_.size());

            for (std::size_t i = 0; i != keys.size(); ++i)
                partition_unordered_map_[keys[i]] = val[i];
        }
        /// Copy the value of \a val for the elements at positions \a pos in
        /// the partition_vector container.
        ///
        /// \param pos   Positions of the elements in the partition_vector
        ///
        /// \param val   The value to be copied
        ///
        void set_values(std::vector<size_type> const& pos,
            std::vector<T> const& val)
        {
            HPX_ASSERT(pos.size() == val.size());
            HPX_ASSERT(pos.size() <= partition_vector_.size());

            for (std::size_t i = 0; i != pos.size(); ++i)
                partition_vector_[pos[i]] = val[i];
        }
Example #16
0
task4_5::solution::solution( const data_type& data )
{
	if(data.size() == 0)
	{
		max_=min_=0;
		return;
	}
	min_ = std::numeric_limits< int >().max();
	max_ = std::numeric_limits< int >().min();
	create_thr( data);

}
Example #17
0
task4_5::solution::solution(const data_type& data) : min(std::numeric_limits< int >().max()), max(std::numeric_limits< int >().min())
{
	boost::thread_group threads;

	if (!data.empty())
	{
		for (size_t i = 0; i < data.size(); i++)
		{
			threads.create_thread(boost::bind(&task4_5::solution::search_min, this, boost::ref(data[i])));
			threads.create_thread(boost::bind(&task4_5::solution::search_max, this, boost::ref(data[i])));
		}

		threads.join_all();

	}
	else
	{
		min = 0;
		max = 0;
	}
}
        /// Return the element at the position \a pos in the partition_unordered_map
        /// container.
        ///
        /// \param pos Positions of the elements in the partition_unordered_map
        ///
        /// \return Return the values of the elements at position represented
        ///         by \a pos.
        ///
        std::vector<T> get_values(std::vector<Key> const& keys)
        {
            std::vector<T> result;
            result.reserve(keys.size());

            for (std::size_t i = 0; i != keys.size(); ++i)
            {
                typename data_type::iterator it =
                    partition_unordered_map_.find(keys[i]);
                if (it == partition_unordered_map_.end())
                {
                    HPX_THROW_EXCEPTION(bad_parameter,
                        "partition_unordered_map::get_values",
                        "unable to find requested key in this partition of the "
                        "unordered_map");
                    break;
                }
                result.push_back(it->second);
            }
            return result;
        }
Example #19
0
task4_5::solution::solution(const data_type& data) : min_(0), max_(0)
{
	std::vector<std::future<std::pair<int, int>>> futures;
	if (data.empty())
	{
		min_ = 0;
		max_ = 0;
	}
	else
	{
		min_ = std::numeric_limits<int>().max();
		max_ = std::numeric_limits<int>().min();
	}
	for (size_t i = 0; i < data.size(); ++i)
		futures.push_back(std::async(&VectMinMaxFindingFunc, std::cref(data[i])));
	for (auto & ftr : futures)
	{
		const auto ftrAns = ftr.get();
		min_ = std::min(min_, ftrAns.first);
		max_ = std::max(max_, ftrAns.second);
	}
}
Example #20
0
task4_5::solution::solution( const data_type& data ) : min_(0), max_(0)
{		
	if (!data.empty())
	{
		data_ = data;

		min_ = std::numeric_limits< int >().max();
		max_ = std::numeric_limits< int >().min();

		cur_it_ = data_.begin();

		boost::thread_group thread_group;
		for(int i = 0; i < 4; ++i)
		{
			thread_group.create_thread(boost::bind(&solution::thread_fun, this));
		}

		thread_group.join_all();
	}
}
Example #21
0
void session_interface::load_data(data_type &data,std::string const &s)
{
	data.clear();
	char const *begin=s.data(),*end=begin+s.size();
	while(begin < end) {
		packed p(begin,end);
		begin +=sizeof(p);
		if(end - begin >= int(p.key_size + p.data_size)) {
			string key(begin,begin+p.key_size);
			begin+=p.key_size;
			string val(begin,begin+p.data_size);
			begin+=p.data_size;
			entry &ent=data[key];
			ent.exposed = p.exposed;
			ent.value.swap(val);
		}
		else {
			throw cppcms_error("sessions::format violation data");
		}

	}

}
 const_iterator_type cend() const
 {
     return partition_vector_.cend();
 }
 iterator_type end()
 {
     return partition_vector_.end();
 }
 const_iterator_type cbegin() const
 {
     return partition_vector_.cbegin();
 }
 iterator_type begin()
 {
     return partition_vector_.begin();
 }
 /** @brief Remove all elements from the vector leaving the
     *          partition_vector with size 0.
     */
 void clear()
 {
     partition_vector_.clear();
 }
 /** @brief Remove the last element from partition_vector effectively
  *          reducing the size by one. The removed element is destroyed.
  */
 void pop_back()
 {
     partition_vector_.pop_back();
 }
 /** @brief Add new element at the end of partition_vector. The added
  *          element contain the \a val as value.
  *
  * @param val Value to be copied to new element
  */
 void push_back(T const& val)
 {
     partition_vector_.push_back(val);
 }
 /** @brief Assigns new contents to the partition_vector, replacing its
  *          current contents and modifying its size accordingly.
  *
  * @param n     new size of partition_vector
  * @param val   Value to fill the container with
  */
 void assign(size_type n, T const& val)
 {
     partition_vector_.assign(n, val);
 }
 /** @brief Access the value of last element in the partition_vector.
  *
  *  Calling the function on empty container cause undefined behavior.
  *
  * @return Return the value of the last element in the partition_vector
  */
 T back() const
 {
     return partition_vector_.back();
 }