Exemplo n.º 1
0
void ResolutionComputation::betti_display(buffer &o, M2_arrayint ar)
{
  int *a = ar->array;
  int total_sum = 0;
  int lo = a[0];
  int hi = a[1];
  int len = a[2] + 1;
  o << "total  ";
  for (int lev = 0; lev < len; lev++)
    {
      int sum = 0;
      for (int d = lo; d <= hi; d++) sum += a[len * (d - lo) + lev + 3];
      total_sum += sum;
      o.put(sum, 6);
      o << ' ';
    }
  o << " [" << total_sum << "]" << newline;
  for (int d = lo; d <= hi; d++)
    {
      o.put(d, 5);
      o << ": ";
      for (int lev = 0; lev < len; lev++)
        {
          int c = a[len * (d - lo) + lev + 3];
          if (c != 0)
            o.put(c, 6);
          else
            o << "     -";
          o << " ";
        }
      o << newline;
    }
}
Exemplo n.º 2
0
  void ARingCC::elem_text_out(buffer &o,
                              const ElementType &ap,
                              bool p_one,
                              bool p_plus,
                              bool p_parens) const
  {
    ElementType& ap1 = const_cast<ElementType&>(ap);
    gmp_CC_struct g;
    g.re = getmemstructtype(gmp_RR);
    g.im = getmemstructtype(gmp_RR);
    mpfr_init2(g.re,53);
    mpfr_init2(g.im,53);
    mpfr_set_d(g.re, ap1.re, GMP_RNDN);
    mpfr_set_d(g.im, ap1.im, GMP_RNDN);
    M2_string s = p_parens ? 
      (*gmp_tonetCCparenpointer)(&g) : (*gmp_tonetCCpointer)(&g);
    mpfr_clear(g.im);
    mpfr_clear(g.re);
    delete g.re;
    delete g.im;

    bool prepend_plus = p_plus && (s->array[0] != '-');
    bool strip_last = !p_one && (
				 (s->len == 1 && s->array[0] == '1')
				 || (s->len == 2 && s->array[1] == '1' && s->array[0] == '-'));
    
    if (prepend_plus)
      o << "+";
    if (strip_last)
      o.put(s->array, s->len-1);
    else
      o.put(s->array, s->len);
    
  }
Exemplo n.º 3
0
io_status pstring::cdrOut(buffer& buf)
{
   primitive::cdrOut(buf);
   buf.put(v_str_ptr.loc);
   buf.put(v_sz);
   return done;
}
Exemplo n.º 4
0
inline void device_buf::out(byte p)
{
	// TODO: If out_buf was resized so that it would be full at the next flush moment,
	// we only need to do one check here.
	out_buf.put(p);
	if(out_buf.size() > out_buffer_size)
		flush(); // Time to flush
}
Exemplo n.º 5
0
io_status dl_list::cdrOut(buffer& buf)
{
   composite::cdrOut(buf);
   v_dl_list_head.cdrOut(buf);
   v_dl_list_tail.cdrOut(buf);
   buf.put(v_num_indices);
   return done;
}
Exemplo n.º 6
0
io_status compressed_pstring::cdrOut(buffer& buf)
{
//MESSAGE(cerr, "compressed_pstring: cdrOut()");
//debug(cerr, compress_agent_id);

   pstring::cdrOut(buf);
   buf.put(v_uncompressed_sz);
   return compress_agent_id.cdrOut(buf);
}
Exemplo n.º 7
0
stream::state_t
socks5_proxy::send( buffer &in_buf, buffer &out_buf )
{
	if ( m_state == stream::state_t::handshaking )
	{
		if ( !m_sent_greeting )
		{
			if ( proxy::manager::shared().authorization().size() > 0 )
			{
				out_buf.size( 4 );
			
				out_buf.put( 0, 0x05 );
				out_buf.put( 1, 0x02 );
				out_buf.put( 2, 0x00 );
				out_buf.put( 3, 0x02 );
			}
			else
			{
				out_buf.size( 3 );
				
				out_buf.put( 0, 0x05 );
				out_buf.put( 1, 0x01 );
				out_buf.put( 2, 0x00 );
			}
			
			m_sent_greeting = true;
		}
		
		m_send_queue.append( in_buf );
		
		m_state5 = waiting_for_opening_response;
		m_state = stream::state_t::connected;
	}
	else if ( m_state5 != connected )
	{
		m_send_queue.append( in_buf );
	}
	else
	{
		out_buf = std::move( in_buf );
	}
	
	return m_state;
}
Exemplo n.º 8
0
void ARingRRR::elem_text_out(buffer &o,
                             const ElementType &ap,
                             bool p_one,
                             bool p_plus,
                             bool p_parens) const
{
  mpfr_ptr a = &const_cast<ElementType &>(ap);
  M2_string s = (*gmp_tostringRRpointer)(a);
  bool prepend_plus = p_plus && (s->array[0] != '-');
  bool strip_last =
      !p_one && ((s->len == 1 && s->array[0] == '1') ||
                 (s->len == 2 && s->array[1] == '1' && s->array[0] == '-'));

  if (prepend_plus) o << "+";
  if (strip_last)
    o.put(s->array, s->len - 1);
  else
    o.put(s->array, s->len);
}
Exemplo n.º 9
0
void writer()
{
    for (int n = 0; n < ITERS; ++n)
    {
        {
            boost::mutex::scoped_lock lock(io_mutex);
            std::cout << "sending: "
                      << n << std::endl;
        }
        buf.put(n);
    }
}