本文整理汇总了C++中Var函数的典型用法代码示例。如果您正苦于以下问题:C++ Var函数的具体用法?C++ Var怎么用?C++ Var使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Var函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
inline result_type operator()(const T &t) const
{
//std::cout<<"unary energy\n";
std::map< std::string,double > dist,hasWindow;
_lot->dist2borders(t,dist,hasWindow);
std::map<Var,double> var_value;
std::map< std::string,double >::iterator it;
for(it=dist.begin(); it!=dist.end(); ++it)
{
if(it->second!=it->second || isinf(it->second))
return _eRej*3;
var_value.insert(std::make_pair(Var("d"+it->first),it->second));
}
for(it=hasWindow.begin();it!=hasWindow.end();++it)
var_value.insert(std::make_pair(Var("hasWindow"+it->first),it->second));
var_value.insert(std::make_pair(Var("h"),t.h()));
result_type eFront=0,eSide=0,eBack=0;
if(_lot->hasRule(RuleType::DistFront))
eFront = (_lot->ruleEnergy(RuleType::DistFront))->energy(var_value);
if(_lot->hasRule(RuleType::DistSide))
eSide = (_lot->ruleEnergy(RuleType::DistSide))->energy(var_value);
if(_lot->hasRule(RuleType::DistBack))
eBack = (_lot->ruleEnergy(RuleType::DistBack))->energy(var_value);
return (eFront+eSide+eBack)*_eRej;
}
示例2: Relative
static void
Relative(struct dataset *ds, struct dataset *rs, int confidx)
{
double spool, s, d, e, t;
int i;
i = ds->n + rs->n - 2;
if (i > NSTUDENT)
t = student[0][confidx];
else
t = student[i][confidx];
spool = (ds->n - 1) * Var(ds) + (rs->n - 1) * Var(rs);
spool /= ds->n + rs->n - 2;
spool = sqrt(spool);
s = spool * sqrt(1.0 / ds->n + 1.0 / rs->n);
d = Avg(ds) - Avg(rs);
e = t * s;
if (fabs(d) > e) {
printf("Difference at %.1f%% confidence\n", studentpct[confidx]);
printf(" %g +/- %g\n", d, e);
printf(" %g%% +/- %g%%\n", d * 100 / Avg(rs), e * 100 / Avg(rs));
printf(" (Student's t, pooled s = %g)\n", spool);
} else {
printf("No difference proven at %.1f%% confidence\n",
studentpct[confidx]);
}
}
示例3: CreateContructionNear
func CreateContructionNear(id def, int x, int y, int owner)
{
Var(0)=x; Var(1)=y;
if (!FindConstructionSite(def, 0,1)) return 0;
x=Var(0); y=Var(1);
return CreateConstruction(def, x,y, owner, 100, true);
}
示例4: load_str
Lua::Var Lua::State :: load_str(std::string &str)
{ int n = lua_gettop(vm);
if(luaL_dostring(vm, str.c_str()))
lua_error(vm);
int t = lua_gettop(vm) - n;
if (t > 0) return Var(this, n + 1, t);
else return Var();
}
示例5: load_file
Lua::Var Lua::State :: load_file(const char* fileName)
{ int n = lua_gettop(vm);
if(luaL_dofile(vm, fileName))
lua_error(vm);
int t = lua_gettop(vm) - n;
if (t > 0) return Var(this, n + 1, t);
else return Var();
}
示例6: load_data
Lua::Var Lua::State :: load_data(Data* data)
{ int n = lua_gettop(vm);
if(luaL_loadbuffer(vm, (const char*)data -> getPtr(), data ->getLength(),
"") || lua_pcall(vm, 0, LUA_MULTRET, 0))
lua_error(vm);
int t = lua_gettop(vm) - n;
if (t > 0) return Var(this, n + 1, t);
else return Var();
}
示例7: constraints
void constraints() {
OKLIB_MODELS_CONCEPT_TAG(Var, VariablesAsIndex);
OKLIB_MODELS_CONCEPT_REQUIRES(Var, VariablesWithIndex);
OKLIB_MODELS_CONCEPT_TAG(Var, VariablesWithIndex);
dummy_use_v(Var(i));
dummy_use_v(Var(ic));
}
示例8: nrVars
void CBP::construct() {
// prepare datastructures for compression
for (size_t i=0; i<nrVars(); i++) {
_gndVarToSuperVar[i] = i;
}
for (size_t i=0; i<nrFactors(); i++) {
_gndFacToSuperFac[i] = i;
}
// create edge properties
_edges.clear();
_edges.reserve( nrVars() );
for( size_t i = 0; i < nrVars(); ++i ) {
_edges.push_back( vector<EdgeProp>() );
_edges[i].reserve( nbV(i).size() );
foreach( const Neighbor &I, nbV(i) ) {
EdgeProp newEP;
size_t edgeCount = factor(I).counts()[I.dual].size();
newEP.message = vector<Prob>(edgeCount,Prob( var(i).states() ));
newEP.newMessage = vector<Prob>(edgeCount,Prob( var(i).states() ));
newEP.count = vector<int>(edgeCount);
newEP.index = vector<ind_t>(edgeCount);
newEP.nrPos = edgeCount;
// simulate orginal varSet with possibly more variables, must ensure that the number of variables is equal to number of ground variables
VarSet gndVarSet;
size_t varCount = 0;
foreach(const Neighbor &tmpVar, nbF(I)) {
for(map<size_t, int>::const_iterator iter=factor(I).counts()[tmpVar.iter].begin(); iter!=factor(I).counts()[tmpVar.iter].end();iter++) {
gndVarSet |= Var(varCount, var(tmpVar).states());
varCount++;
}
}
varCount = 0;
foreach(const Neighbor &tmpVar, nbF(I)) {
size_t pos=0;
for(map<size_t, int>::const_iterator iter=factor(I).counts()[tmpVar.iter].begin(); iter!=factor(I).counts()[tmpVar.iter].end();iter++,pos++) {
if (tmpVar == i) {
// assumes that counts are iterated in increases order of positions
size_t sortedPos = factor(I).sigma()[(*iter).first];
newEP.count[pos] = (*iter).second;
newEP.index[pos].reserve( factor(I).states() );
for( IndexFor k( Var(sortedPos, var(i).states()), gndVarSet ); k >= 0; ++k ) {
newEP.index[pos].push_back( k );
}
}
varCount++;
}
}
_edges[i].push_back( newEP );
}
示例9: TEST
TEST(Util, NormalSampleTest) {
VReal tmp;
for (int i = 0; i < 1000000; i++) {
tmp.push_back(NormalSample() / 100);
}
EXPECT_LT(std::abs(0.0 - Mean(tmp)), 0.00001);
EXPECT_LT(std::abs(0.0001 - Var(tmp)), 0.00001);
VVVReal tmp2;
RandomInit(100, 100, 100, &tmp2);
EXPECT_LT(std::abs(0.0 - Mean(tmp2)), 0.00001);
EXPECT_LT(std::abs(0.0001 - Var(tmp2)), 0.00001);
}
示例10: content
TensorIndex::TensorIndex(std::string name, pe::PathExpression pexpr)
: content(new Content) {
content->name = name;
content->pexpr = pexpr;
content->kind = PExpr;
string prefix = (name == "") ? name : name + ".";
content->coordArray = Var(prefix + "coords",
ArrayType::make(ScalarType::Int));
content->sinkArray = Var(prefix + "sinks",
ArrayType::make(ScalarType::Int));
}
示例11: ExtraLog
global func ExtraLog(szString, a,b,c,d,e,f,g,e,h)
{
var obj, i;
// Alle vorigen Logs speichern und verschieben
while(obj = FindObject(_LOG, 0-GetX(), 0-GetY(), -1, -1, 0, 0, 0, 0, obj)) Var(i++) = obj;
while(--i>=0) SetPosition(GetX(Var(i)), GetY(Var(i))+18, Var(i));
// Neues Log hinzufügen
var szText = Format(szString, a,b,c,d,e,f,g,e,h);
obj = CreateObject(_LOG, -GetX(), 138-GetY(), -1);
AddEffect("Log", obj, 1, 1, 0, _LOG, szText);
return(1);
}
示例12: cst
Var Interpreter::make_Callable( Vec<Var> lst, Var self ) {
// remove doubles
for( int i = 0; i < lst.size(); ++i )
for( int j = i + 1; j < lst.size(); ++j )
if ( lst[ i ].expr() == lst[ j ].expr() )
lst.remove_unordered( j-- );
//
Expr surdef_list_data = cst( SI32( lst.size() ) );
for( int i = 0; i < lst.size(); ++i )
surdef_list_data = concat( surdef_list_data, pointer_on( lst[ i ].expr() ) );
Var surdef_list( &type_SurdefList, surdef_list_data );
//
Var self_type = type_of( self ); // returns void if self is not defined
// -> Callable[ surdef_list, self_type, parm_type ]
Var *parms[ 3 ];
parms[ 0 ] = &surdef_list;
parms[ 1 ] = &self_type;
parms[ 2 ] = &void_var;
Var *callable_type = type_for( class_info( class_Callable ), parms );
return Var( callable_type, self ? pointer_on( self.expr() ) : cst() ).add_ref( 0, self );
}
示例13: Var
Var Interpreter::ext_method( const Var &var ) {
if ( isa_Def( var ) )
if ( DefInfo *d = def_info( pointer_on( var.expr() ) ) )
if ( d->self_as_arg() )
return var;
return Var();
}
示例14: rebelege_Verz
__inline__ bool rebelege_Verz(LIT x)
/* Macht x -> 0 wieder rueckgaengig fuer eine Verzweigungsvariable. */
/* rebelege_Verz = true falls verzweigt werden muss. */
{
LITV y, z;
LIT kx;
VAR v;
for (y = erstesVork(x); echtesVork(y, x); y = naechstesVork(y))
{
bindeLK(y);
LaengeP1(KlnVk(y));
}
for (y = erstesVork(kx = Komp(x)); echtesVork(y, kx); y = naechstesVork(y))
for (z = naechstesVorkK(y); z != y; z = naechstesVorkK(z))
bindeLv(z);
bindeV(v = Var(x));
setzenbelegt(v, false);
return enthalten(v);
}
示例15: reduce_phase2
void * reduce_phase2(const void * _exp)
{
if(isA(_exp, Integer()))
return domainCast(_exp, Real());
else if(isA(_exp, Real()) || isA(_exp, Var()))
return copy(_exp);
else if(isA(_exp, Sum()) || isA(_exp, Product()))
{
void * s = copy(_exp);
size_t i;
for(i = 0; i < size(s); ++i)
{
delete(argv(s, i));
setArgv(s, i, reduce_phase2(argv(_exp, i)));
}
return s;
}
else if(isA(_exp, Pow()))
{
void * p = copy(_exp);
delete(base(p));
delete(power(p));
setBase(p, reduce_phase2(base(_exp)));
setPower(p, reduce_phase2(power(_exp)));
return p;
}
else if(isOf(_exp, Apply_1()))
{
void * f = copy(_exp);
delete(arg(f));
setArg(f, reduce_phase2(arg(_exp)));
return f;
}
assert(0);
}