示例#1
0
void bi::Cache::resize(const int size) {
  /* pre-condition */
  BI_ASSERT(size >= 0);

  int oldSize = this->size();
  valids.resize(size, true);  // true is to preserve contents here
  dirties.resize(size, true);
  if (size > oldSize) {
    set_elements(subrange(valids, oldSize, size - oldSize), false);
    set_elements(subrange(dirties, oldSize, size - oldSize), false);
  }
}
示例#2
0
void rectangle::initialize( platform::context &ctxt )
{
	if ( !_stash )
	{
		if ( ctxt.retrieve_common( this, _stash ) )
		{
			// new object
			//
			// Setup program with vertex and fragment shaders
			_stash->_mesh.set_program( new_program( ctxt.api(), "simple.vert", "single_color.frag" ) );

			// Setup vertices
			gl::vertex_buffer_data<gl::vec2> vertices;
			vertices.push_back( { 0.F, 0.F } );
			vertices.push_back( { 1.F, 0.F } );
			vertices.push_back( { 1.F, 1.F } );
			vertices.push_back( { 0.F, 1.F } );
			vertices.vbo( gl::buffer_usage::STATIC_DRAW );

			gl::element_buffer_data elements { 0, 3, 1, 1, 3, 2 };
			{
				auto bound = _stash->_mesh.bind();
				bound.vertex_attribute( "position", vertices );
				bound.set_elements( elements );
			}

			_stash->_mesh.add_triangles( 6 );
			_stash->_matrix_loc = _stash->_mesh.get_uniform_location( "matrix" );
			_stash->_color_loc = _stash->_mesh.get_uniform_location( "color" );
		}
	}
}
示例#3
0
文件: misc.hpp 项目: milthorpe/LibBi
inline void bi::mean(const GammaPdf& q, V1 mu) {
  /* pre-condition */
  BI_ASSERT(mu.size() == q.size());

  real alpha = q.shape();
  real beta = q.scale();

  set_elements(mu, alpha*beta);
}
示例#4
0
文件: misc.hpp 项目: milthorpe/LibBi
void bi::mean(const M1 X, V1 mu) {
  /* pre-condition */
  BI_ASSERT(X.size2() == mu.size());

  const int N = X.size1();
  typename sim_temp_vector<V1>::type w(N);
  set_elements(w, 1.0);
  gemv(1.0/N, X, w, 0.0, mu, 'T');
}
示例#5
0
文件: misc.hpp 项目: milthorpe/LibBi
void bi::det_rows(const M2 X, const V2& is, V3 det) {
  BOOST_AUTO(iter, is.begin());
  BOOST_AUTO(end, is.end());

  set_elements(det, 1.0);
  for (; iter != end; ++iter) {
    mul_elements(det, column(X, *iter), det);
  }
}
示例#6
0
文件: misc.hpp 项目: milthorpe/LibBi
inline void bi::mean(const InverseGammaPdf& q, V1 mu) {
  /* pre-condition */
  BI_ASSERT(mu.size() == q.size());
  BI_ASSERT(q.shape() > 1.0);

  real alpha = q.shape();
  real beta = q.scale();

  set_elements(mu, alpha*std::pow(beta, 2));
}
示例#7
0
文件: misc.hpp 项目: milthorpe/LibBi
void bi::cov(const GammaPdf& q, M1 Sigma) {
  /* pre-condition */
  BI_ASSERT(Sigma.size1() == q.size());
  BI_ASSERT(Sigma.size2() == q.size());

  real alpha = q.shape();
  real beta = q.scale();
  real sigma = alpha*std::pow(beta, 2);

  Sigma.clear();
  set_elements(diagonal(Sigma), sigma);
}
示例#8
0
文件: misc.hpp 项目: milthorpe/LibBi
void bi::cov(const InverseGammaPdf& q, M1 Sigma) {
  /* pre-condition */
  BI_ASSERT(Sigma.size1() == q.size());
  BI_ASSERT(Sigma.size2() == q.size());
  BI_ASSERT(q.shape() > 2.0);

  real alpha = q.shape();
  real beta = q.scale();
  real sigma = std::pow(beta, 2)/(std::pow(alpha - 1.0, 2)*(alpha - 2.0));

  Sigma.clear();
  set_elements(diagonal(Sigma), sigma);
}
示例#9
0
CayleyGraph::CayleyGraph (const CayleyGraph& C) {
	int ** in = C.get_in_edges();
	int ** out = C.get_out_edges();
	
	order = C.get_order();
	
	in_edges = new int*[order];
	out_edges = new int*[order];
	
	for (int i = 0; i < order; i++) {
		in_edges[i] = new int[MAX_GENERATORS];
		out_edges[i] = new int[MAX_GENERATORS];
		for (int j = 0; j < MAX_GENERATORS; j++) {
			in_edges[i][j] = in[i][j];
			out_edges[i][j] = out[i][j];
		}
	}
	
	set_elements();
	set_orders();
}
示例#10
0
void DynStructImpl::set_members(const DynamicAny::NameValuePairSeq& value)
   throw(DynamicAny::DynAny::TypeMismatch,
         DynamicAny::DynAny::InvalidValue, CORBA::SystemException)
{
   if (_destroyed)
   {
      throw CORBA::OBJECT_NOT_EXIST("DynAny destroyed");
   }

   reset();

   if (value.length() != _component_count)
   {
      throw DynamicAny::DynAny::TypeMismatch();
   }

   DynamicAny::AnySeq* members_values= new DynamicAny::AnySeq(_component_count);

   if (_component_count > 0){

     members_values->length(_component_count);
     
     for (CORBA::ULong i=0; i < _component_count; i++)
       {
         (*members_values)[i] = value[i].value;
         
         if (strcmp(_base_type->member_name(i), value[i].id))
           {
             throw DynamicAny::DynAny::InvalidValue();
           }
       }

     set_elements(*members_values);
   }
   delete members_values;

}
示例#11
0
void bi::Cache::clear() {
  set_elements(valids, false);
  set_elements(dirties, false);
}
示例#12
0
void bi::Cache::flush() {
  set_elements(dirties, false);
}
示例#13
0
void bi::Cache::setDirty(const int p, const int len, const bool dirty) {
  /* pre-condition */
  BI_ASSERT(p >= 0 && p + len <= (int )dirties.size());

  set_elements(subrange(dirties, p, len), dirty);
}
示例#14
0
void bi::Cache::setValid(const int p, const int len, const bool valid) {
  /* pre-condition */
  BI_ASSERT(p >= 0 && p + len <= (int )valids.size());

  set_elements(subrange(valids, p, len), valid);
}