Esempio n. 1
0
// checks unitarity and can write out a configuration
int
read_and_check( const char *infile ,
		const GLU_bool rtrans , 
		const char *outfile , 
		const GLU_output storage , 
		const char *output_details )
{
  struct head_data HEAD_DATA ;
  struct site *lat = read_file( &HEAD_DATA , infile ) ;
  int FLAG = GLU_SUCCESS ;
  
  // should print out a warning
  if( lat == NULL ) return GLU_FAILURE ;

  // if we want a random transform then here is where we do it
  if( rtrans == GLU_TRUE ) { random_gtrans( lat ) ; }

  gauge( lat ) ;

  if( (Latt.argc-1) == WRITE ) {
    FLAG = write_configuration( lat , outfile , storage , output_details ) ;
  }

  free_lat( lat ) ;

  return FLAG ;
}
Esempio n. 2
0
File: Strings.hpp Progetto: laoo/LSC
  void iterateSuitable( double aFreq, double aAcceptedCents, double aMeasure, double aTension, P p )
  {
    double cent = std::pow( 2, aAcceptedCents / 1200.0 );
    double maxFreq = aFreq * cent;
    double minFreq = aFreq / cent;
    double sqrtTension = sqrt( aTension );

    auto it = std::lower_bound( mElements.cbegin(), mElements.cend(), minFreq, [=]( Element const& e, double aF )
    {
      double f = frequency( aMeasure, aTension, e.gauge, e.density );
      return aF > f;
    } );

    struct EF
    {
      Element const* e;
      double c;
      double t;
      double g;
    };

    std::vector<EF> suitable;

    while ( it != mElements.cend() )
    {
      double f = frequency( aMeasure, aTension, it->gauge, it->density );
      if ( f > maxFreq )
        break;
      double c = 1200.0 * log( aFreq / f ) / log( 2.0 );
      double t = tension( aFreq, aMeasure, it->gauge, it->density );
      double g = gauge( aFreq, sqrtTension, aMeasure, it->density );
      suitable.push_back( { &*it, c, t, g } );
      ++it;
    }

    std::sort( suitable.begin(), suitable.end(), []( EF const& left, EF const& right )
    {
      return std::abs( left.c ) < std::abs( right.c );
    } );

    for ( auto jt = suitable.cbegin(); jt != suitable.cend(); ++jt )
    {
      p( jt->e->name, jt->e->producer, jt->e->material, jt->e->length, jt->c, jt->t, jt->g );
    }
  }
Esempio n. 3
0
HRESULT CChainComparer::Execute()
{
	// if either of the chains is null, nothing to do - everything inserted/deleted - return now
	if (m_pAnchor1 == NULL || m_pAnchor2 == NULL)
		return S_OK;

	CCompareChainsDepthGauge gauge(m_pHost->GetContext());
	m_pHost->SendOccaisionalProgressMessage();
	Prepare();
	DUMP_CHAIN(DBG_START_OF_BINDING, "At start of binding");

	if (m_pHost->DoBothFilesHaveRSIDInfo())
		SequenceIDSensitivePass();

	CompareTheChains();

	DUMP_CHAIN(DBG_END_OF_COMPARE, "At the end of compare chains");
	ProgressMessageWithCancelCheck();
	return S_OK;
}
Esempio n. 4
0
void
HUD::draw(const Player& plyr, const ppogl::Vec2i& resolution)
{
	m_resolution = resolution;
	
	gl::PushMatrix();
	{
	gl::MatrixMode(GL_PROJECTION);
    gl::LoadIdentity();
    gl::Ortho(0.0, m_resolution.x(), 0.0,
			  m_resolution.y(), -1.0, 1.0);
    gl::MatrixMode(GL_MODELVIEW);
    gl::LoadIdentity();
    gl::Translate(0.0, 0.0, -1.0);
	
	set_gl_options( TEXFONT );
		
	for(int i=0; i<m_numElements; i++){	
		switch(m_element[i].type){
			case 0:
				text(i);
				break;
			case 1:
				if(GameConfig::displayFPS){
					fps(i);
    			}	
				break;
			case 2:
				herring(i,plyr.herring);
				break;
			case 3:
				image(i);
				break;
			case 4:
				time(i);
				break;	
			case 5:
				{
				ppogl::Vec3d vel = plyr.vel;
    			speed(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H);
				}
				break;
			case 6:
				{
				ppogl::Vec3d vel = plyr.vel;
				gauge(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H,plyr.control.jump_amt);
				}
				break;
			case 7:
				bar(i,plyr.control.jump_amt);
				break;
			case 8:
				{
				ppogl::Vec3d vel = plyr.vel;
				bar(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H/135);
				}	
				break;
			case 9:
				if(GameConfig::displayCoursePercentage){
					coursePercentage(i, plyr);
				}
				break;
			case 10:
				if(GameConfig::displayCoursePercentage){		
					bar(i,plyr.getCoursePercentage()/100);
				}
				break;
			case 11:
				if(GameConfig::displayCoursePercentage){		
					image(i);
				}
				break;				
			case 12:
				if(GameConfig::displayFPS){
					image(i);
    			}	
				break;
		}
	}
	
	}
	gl::PopMatrix();
}
Esempio n. 5
0
/* Embedded code is not funny at all... */
int
mib_instance_search(struct oid_search_res *ret_oid)
{
  int i;
  Variable *var = &ret_oid->var;
  lua_State *L = mib_lua_state;

  /* Empty lua stack. */
  lua_pop(L, -1);
  /* Get function. */
  lua_rawgeti(L, LUA_ENVIRONINDEX, ret_oid->callback);
  /* op */
  lua_pushinteger(L, ret_oid->request);
  /* req_sub_oid */
  lua_newtable(L);
  for (i = 0; i < ret_oid->inst_id_len; i++) {
    lua_pushinteger(L, ret_oid->inst_id[i]);
    lua_rawseti(L, -2, i + 1);
  }

  if (ret_oid->request == MIB_REQ_SET) {
    /* req_val */
    switch (tag(var)) {
      case ASN1_TAG_INT:
        lua_pushinteger(L, integer(var));
        break;
      case ASN1_TAG_OCTSTR:
        lua_pushlstring(L, octstr(var), length(var));
        break;
      case ASN1_TAG_CNT:
        lua_pushnumber(L, count(var));
        break;
      case ASN1_TAG_IPADDR:
        lua_pushlstring(L, (char *)ipaddr(var), length(var));
        break;
      case ASN1_TAG_OBJID:
        lua_newtable(L);
        for (i = 0; i < length(var); i++) {
          lua_pushnumber(L, oid(var)[i]);
          lua_rawseti(L, -2, i + 1);
        }
        break;
      case ASN1_TAG_GAU:
        lua_pushnumber(L, gauge(var));
        break;
      case ASN1_TAG_TIMETICKS:
        lua_pushnumber(L, timeticks(var));
        break;
      default:
        lua_pushnil(L);
        break;
    }
    /* req_val_type */
    lua_pushinteger(L, tag(var));
  } else {
    /* req_val */
    lua_pushnil(L);
    /* req_val_type */
    lua_pushnil(L);
  }

  if (lua_pcall(L, 4, 4, 0) != 0) {
    SMARTSNMP_LOG(L_ERROR, "MIB search hander %d fail: %s\n", ret_oid->callback, lua_tostring(L, -1));
    tag(var) = ASN1_TAG_NO_SUCH_OBJ;
    return 0;
  }

  ret_oid->err_stat = lua_tointeger(L, -4);
  tag(var) = lua_tonumber(L, -1);

  if (!ret_oid->err_stat && MIB_TAG_VALID(tag(var))) {
    /* Return value */
    if (ret_oid->request != MIB_REQ_SET) {
      switch (tag(var)) {
        case ASN1_TAG_INT:
          length(var) = 1;
          integer(var) = lua_tointeger(L, -2);
          break;
        case ASN1_TAG_OCTSTR:
          length(var) = lua_objlen(L, -2);
          memcpy(octstr(var), lua_tostring(L, -2), length(var));
          break;
        case ASN1_TAG_CNT:
          length(var) = 1;
          count(var) = lua_tonumber(L, -2);
          break;
        case ASN1_TAG_IPADDR:
          length(var) = lua_objlen(L, -2);
          for (i = 0; i < length(var); i++) {
            lua_rawgeti(L, -2, i + 1);
            ipaddr(var)[i] = lua_tointeger(L, -1);
            lua_pop(L, 1);
          }
          break;
        case ASN1_TAG_OBJID:
          length(var) = lua_objlen(L, -2);
          for (i = 0; i < length(var); i++) {
            lua_rawgeti(L, -2, i + 1);
            oid(var)[i] = lua_tointeger(L, -1);
            lua_pop(L, 1);
          }
          break;
        case ASN1_TAG_GAU:
          length(var) = 1;
          gauge(var) = lua_tonumber(L, -2);
          break;
        case ASN1_TAG_TIMETICKS:
          length(var) = 1;
          timeticks(var) = lua_tonumber(L, -2);
          break;
        default:
          assert(0);
      }
    }

    /* For GETNEXT request, return the new oid */
    if (ret_oid->request == MIB_REQ_GETNEXT) {
      ret_oid->inst_id_len = lua_objlen(L, -3);
      for (i = 0; i < ret_oid->inst_id_len; i++) {
        lua_rawgeti(L, -3, i + 1);
        ret_oid->inst_id[i] = lua_tointeger(L, -1);
        lua_pop(L, 1);
      }
    }
  }

  return ret_oid->err_stat;
}
Esempio n. 6
0
/**
 * @brief
 *
 * @param
 *
 * @return
 */
void
gaugeWidgetUpdate(layer l, size_t percentage)
{
    gauge(&(l->matrix[0][1]), l->x - 2, percentage);
}