constexpr bool test_checked_multiply(
    T v1,
    T v2,
    char expected_result
){
    using namespace boost::safe_numerics;
    const T result = v1 * v2;
    switch(expected_result){
    case '0':
    case '.':
        if(result.exception()){
            return false;
        }
        if(expected_result == '0'
        && result != T(0)
        ){
           return false;
        }
        return true;
    case '-':
        return safe_numerics_error::negative_overflow_error == result.m_e;
    case '+':
        return safe_numerics_error::positive_overflow_error == result.m_e;
    case '!':
        return safe_numerics_error::range_error == result.m_e;
    }
    return false;
}
	void reset()
	{
		xp.reset();
		yp.reset();
		zp.reset();
		pp.reset();
	}
Example #3
0
  MatrixXi compute_boundary()
  {
    std::vector<std::pair<size_t, size_t> > bd;
    // for (T::All_edges_iterator it = _t.all_edges_begin();
    // 	 it != _t.all_edges_end(); ++it)
    for (T::Finite_edges_iterator it = _t.finite_edges_begin();
	 it != _t.finite_edges_end(); ++it)
      {
	T::Edge e = *it;
	// std::cerr << e.first->vertex(e.second)->info()
	// 	  << " -> ["
	// 	  << e.first->vertex((e.second+1)%3)->info() << ", "
	// 	  << e.first->vertex((e.second+2)%3)->info() << "]\n";
	if (_t.is_infinite(e.first->vertex(e.second)))
	  {
	    int i1= e.first->vertex((e.second+1)%3)->info();
	    int i2= e.first->vertex((e.second+2)%3)->info();
	    bd.push_back(std::make_pair(i1,i2));
	  }
      }
    size_t N = bd.size();
    MatrixXi X(N, 2);
    for (size_t i = 0; i < N; ++i)
      {
	X(i,0) = bd[i].first;
	X(i,1) = bd[i].second;
      }
    return X;
  }
Example #4
0
	/// Ctor. Prepares session for connection as an initiator.
	ClientSession (const F8MetaCntx& ctx, const std::string& conf_file,
		const std::string& session_name, bool init_con_later=false) :
		ClientSessionBase(ctx, conf_file, session_name),
		_sci(get_sender_comp_id(_ses)), _tci(get_target_comp_id(_ses)),
		_id(_ctx._beginStr, _sci, _tci),
		_log(create_logger(_ses, session_log, &_id)),
		_plog(create_logger(_ses, protocol_log, &_id)),
		_persist(create_persister(_ses, nullptr, this->_loginParameters._reset_sequence_numbers)),
		_session(new T(_ctx, _id, _persist, _log, _plog)),
		_addr(get_address(_ses))
#ifdef FIX8_HAVE_OPENSSL
		,_ssl(get_ssl_context(_ses), true)
#endif
	{
		if (!init_con_later)
		{
#ifdef FIX8_HAVE_OPENSSL
			bool secured(_ssl.is_secure());
			_sock = secured
				? new Poco::Net::SecureStreamSocket(_ssl._context)
				: new Poco::Net::StreamSocket;
#else
			bool secured(false);
			_sock = new Poco::Net::StreamSocket;
#endif
			_cc = new ClientConnection(_sock, _addr, *_session, this->_loginParameters._hb_int, get_process_model(_ses), true, secured);
		}

		_session->set_login_parameters(this->_loginParameters);
		_session->set_session_config(this);
	}
Example #5
0
	// return all nodes matching the volume-query
	// description, starting search at the subtree
	// with node-index <nodeNum>
	//
	// NOTE: do not call before balancing the tree
	void GetNodes(NodeVolumeQuery<T>* query, size_t nodeNum, unsigned int depth = 0) {
		if (nodeNum >= nodes.size()) {
			return;
		}

		const T nodeInst = nodes[nodeNum];
		float nodeDist = 0.0f;

		if ((nodeNum << 1) < nodes.size()) {
			// if in the left half of the array, we can examine child nodes
			nodeDist = query->GetPos()[nodeInst->GetAxis()] - nodeInst->GetPos()[nodeInst->GetAxis()];

			if (nodeDist > 0.0f) {
				// search right of the axis-plane first
				GetNodes(query, (nodeNum << 1) + 1, depth + 1);

				if ((nodeDist * nodeDist) < query->GetMaxNodeDist()) {
					GetNodes(query, (nodeNum << 1), depth + 1);
				}
			} else {
				// search left of the axis-plane first
				GetNodes(query, (nodeNum << 1), depth + 1);

				if ((nodeDist * nodeDist) < query->GetMaxNodeDist()) {
					GetNodes(query, (nodeNum << 1) + 1, depth + 1);
				}
			}
		}

		query->AddNode(nodeInst);
	}
Example #6
0
 Mutex(const std::string& s, bool exclusive=false)
     : m_lock(s.c_str())
 {
     if (exclusive)
         m_lock.lock();
     else
         m_lock.lock_sharable();
 }
Example #7
0
  ~PtrGuard()
  {
    if( container != NULL)
      for( SizeT s=container->size(); s > cSize; s--)
	{
	  delete container->back();
	  container->pop_back();
	}
  }
Example #8
0
 void step() {
     while (stop == false ) {
         //cout << "Appending, i="<<i<<endl;
         while ( mlst->append( Dummy(i,i,i) ) ) { ++i; ++appends; }
         //cout << "Erasing, i="<<i<<endl;
         while ( mlst->erase( Dummy(i-1,i-1,i-1) ) ) { --i; ++erases; }
     }
     //cout << "Stopping, i="<<i<<endl;
 }
Example #9
0
 void MakeHash(std::enable_if_t<U::HasHash>* = 0) {
   m_hash = 0;
   m_hash ^= m_vertex.Hash();
   m_hash ^= m_fragment.Hash();
   m_hash ^= m_geometry.Hash();
   m_hash ^= m_control.Hash();
   m_hash ^= m_evaluation.Hash();
   m_hash ^= XXH64(&m_additionalInfo, sizeof(m_additionalInfo), 0);
 }
Example #10
0
File: t.cpp Project: rsadhu/work
int
main (void)
{
  T x;
  const T y;
  x.display (10);
  y.display (20);
  return 0;
}
void multipleEnd() {
  for (S::iterator i = s.begin(); i != s.end(); ++i)
    MutableVal k = *i;

  for (T::iterator i = t.begin(); i != t.end(); ++i)
    int k = *i;

  for (U::iterator i = u.begin(); i != u.end(); ++i)
    Val k = *i;
}
 void init() {
     if(pointee != NULL) {
         if(!pointee->isShareable()) {
             pointee = new T(*pointee);
         }
         else {
             pointee->addReference();
         }
     }
 }
Example #13
0
		//-----------------------------------------------------------------//
		bool write(utils::file_io& fout) {
			size_t s = waves_.size();
			if(zero_.bits() == 24) {
				for(auto w : waves_) {
					if(fout.write(&w, zero_.size()) != zero_.size()) return false;
				}
			} else {
				if(fout.write(&waves_[0], zero_.size(), s) != s) return false;
			}
			return true;
		}
T get_nan() {
    static T r;
    static bool init = false;

    if (!init) {
        init = true;
        r._data().make_nan();
    }

    return BOOST_XINT_MOVE(r);
}
Example #15
0
		//-----------------------------------------------------------------//
		bool read(utils::file_io& fin) {
			size_t s = waves_.size();
			if(zero_.bits() == 24) {
				for(size_t i = 0; i < s; ++i) {
					if(fin.read(&waves_[i], zero_.size()) != zero_.size()) return false;
				}
			} else {
				if(fin.read(&waves_[0], zero_.size(), s) != s) return false;
			}
			return true;
		}
 assign_base(unsigned int count1, unsigned int count2, int tag1, int tag2,
             float mlf1 = 0.85, float mlf2 = 0.85) :
     x_values(count1),
     y_values(count2),
     x(x_values.begin(), x_values.end(), 0, hasher(tag1), key_equal(tag1),
       allocator_type(tag1)),
     y(y_values.begin(), y_values.end(), 0, hasher(tag2), key_equal(tag2),
       allocator_type(tag2))
 {
     x.max_load_factor(mlf1);
     y.max_load_factor(mlf2);
 }
Example #17
0
  double mass()
  {
    double total(0);
    for (auto f = _t.finite_faces_begin();
	 f != _t.finite_faces_end(); ++f)
      {
	total += MA::integrate_centroid<double>(f->vertex(0)->point(),
						f->vertex(1)->point(),
						f->vertex(2)->point(),
						_functions[f]);
      }
    return total;
  }
Example #18
0
    virtual void run()
    {
        ops = 0;
        while( LB_LIKELY( _running ))
        {
            lock->set();
#ifndef _MSC_VER
            TEST( lock->isSet( ));
#endif
            lock->unset();
            ++ops;
        }
    }
Example #19
0
void Hansen_example<T>::evaluate(const T v[]) const {

	const T& x = v[X];
	const T& y = v[Y];

	const T xy = x*y;

	xy.mark_as_common_subexpression();

	const T z = (5*x-4*sqr(y)+14*xy)/(sqr(x)+y+xy);

	z.equals(14.5);
}
Example #20
0
void test () {
#if _LIBCPP_STD_VER > 11
    {
        constexpr T sv1;
        static_assert ( sv1.size() == 0, "" );
        static_assert ( sv1.empty(), "");
    }
#endif

    {
        T sv1;
        assert ( sv1.size() == 0 );
        assert ( sv1.empty());
    }
}
Example #21
0
	inline void CopyTo(T **out)
	{
		if (out) {
			if (ptr) ptr->AddRef();
			*out = ptr;
		}
	}
  inline AzReg_TreeReg *reg_forNewLeaf(int tx) {
    int t_num = areg.size(); 
    if (tx < t_num) return areg.point_u(tx); 

    temporary_reg.copyParam_from(&template_reg); 
    return &temporary_reg; /* should be root-only tree */
  }
Example #23
0
	inline void Clear()
	{
		if (ptr) {
			ptr->Release();
			ptr = nullptr;
		}
	}
Example #24
0
 RefObject(RefObject<T> &rhs)
 {
     F;
     mObj = rhs.mObj;
     if(mObj)
         mObj->inc();
 }
Example #25
0
 Pointer<T> &operator=(const Pointer<T> &other) {
     T *q = other.p;
     if (q) q->incRef();
     if (p) p->decRef();
     p = q;
     return *this;
 }
Example #26
0
 void addSoundfile(
     const char* label,
     const char* filename,
     Soundfile** sf_zone) override
 {
   t.addSoundfile(label, filename, sf_zone);
 }
Example #27
0
 void step() {
     Dummy* d = orig;
     while (stop == false ) {
         //cout << "Appending, i="<<i<<endl;
         if ( mlst->enqueue( d ) ) { ++appends; }
         //cout << "Erasing, i="<<i<<endl;
         if ( mlst->dequeue( d ) ) {
             if( *d != *orig) {
                 os::MutexLock lock(m);
                 assert(*d == *orig); // exercise reading returned memory.
             }
             ++erases;
         }
     }
     //cout << "Stopping, i="<<i<<endl;
 }
Example #28
0
	inline void Clear()
	{
		if (ptr) {
			ptr->Release();
			ptr = NULL;
		}
	}
Example #29
0
			void reset() {
				if(owns_lock()) {
					ptr->unlock();
					IsLock=false;
				}
				ptr=0;
			}
Example #30
0
	~ComPtr()
	{
		if (m_ptr)
		{
			m_ptr->Release();
		}
	}