BddNodeHandle BddManager::restrict(BddNodeHandle pFst, BddNodeHandle pSnd) { if (pSnd == BDD_TRUE || pFst->isTerminal()) return pFst; if (pSnd == BDD_FALSE) return BDD_FALSE; if (pFst == pSnd) return pFst; if (pFst == makeNeg(pSnd)) return BDD_FALSE; int topVar = max(pFst->getCurDecisionLevel(), pSnd->getCurDecisionLevel()); BddNodeHandle fp = pFst->getPosCofactor(pFst, topVar); BddNodeHandle fn = pFst->getNegCofactor(pFst, topVar); BddNodeHandle gp = pSnd->getPosCofactor(pSnd, topVar); BddNodeHandle gn = pSnd->getNegCofactor(pSnd, topVar); if (gp == BDD_FALSE) return restrict(fn, gn); if (gn == BDD_FALSE) return restrict(fp, gp); if (topVar != pFst->getCurDecisionLevel()) return restrict(pFst, ite(gp, BDD_TRUE, gn)); return ite(makeBddNode(topVar), restrict(fp, gp), restrict(fn, gn)); }
void main(char ch='k') { if(ch=='n') { fout<<"getch();\nclosegraph();\n}"; rename("temp.cpp",f); fout.close(); fout.open("temp.cpp"); write('n'); } else { int a=400,b=400; clrscr(); int gd=DETECT,gm ; initgraph(&gd,&gm,"\\tc\\bgi"); if(password()) { setfillstyle(SOLID_FILL,15); bar(43,62,597,458.5); SCREEN(); mousecall(); restrict(0,640,0,480); setmouse(a,b); write('o'); } } closegraph(); }
void CSpaceRestrictionManager::on_default_restrictions_changed () { CLIENT_RESTRICTIONS::const_iterator I = m_clients->begin(); CLIENT_RESTRICTIONS::const_iterator E = m_clients->end(); for ( ; I != E; ++I) restrict ((*I).first,(*I).second.m_base_out_restrictions,(*I).second.m_base_in_restrictions); }
int _start (int m, int c, struct msgbuf *buf, int bufcnt) { int idman_user_init (void *, char *, int); void *tmp; if (m != MSG_BUF) exitprocess (1); printf ("idman (user) init\n"); usleep_desc = msgopen ("usleep"); if (usleep_desc < 0) { printf ("open usleep failed\n"); exitprocess (1); } tmp = alloc (buf[0].len); memcpy (tmp, buf[0].base, buf[0].len); if (idman_user_init (tmp, buf[1].base, buf[1].len)) { printf ("idman init failed\n"); exitprocess (1); } if (restrict (16384, 8 * 16384)) { printf ("idman restrict failed\n"); exitprocess (1); } printf ("ready\n"); return 0; }
typename cartesian_base<K,N>::State exp( const cartesian<K,N,Constraint>& dom, const typename cartesian_base<K,N>::State& y, const typename tangent_type<cartesian<K,N,Constraint>>::type& t ) { return restrict(dom, y + t); }
typename cartesian_base<K,N>::State random_neighbour(const cartesian_constraint_box<K,N>& dom, const typename cartesian_base<K,N>::State& x, W radius) { typename cartesian_base<K,N>::State y; K r = static_cast<K>(radius); for(unsigned int i=0; i<N; i++) { at(y, i) = at(x,i) + r*math::random_stddev<K>(); } return restrict(dom, y); }
void CSpaceRestrictionManager::add_restrictions (ALife::_OBJECT_ID id, shared_str add_out_restrictions, shared_str add_in_restrictions) { CRestrictionPtr _client_restriction = restriction(id); if (!_client_restriction) { restrict (id,add_out_restrictions,add_in_restrictions); return; } VERIFY (!_client_restriction->applied()); CClientRestriction &client_restriction = (*m_clients)[id]; shared_str new_out_restrictions = client_restriction.m_base_out_restrictions; shared_str new_in_restrictions = client_restriction.m_base_in_restrictions; join_restrictions (new_out_restrictions,add_out_restrictions); join_restrictions (new_in_restrictions,add_in_restrictions); restrict (id,new_out_restrictions,new_in_restrictions); }
void ATC_TransferThermal::init_filter() { // NOTE assume total filtered time derivatives are zero ATC_Transfer::init_filter(); if (integrationType_==TimeIntegrator::VERLET) { // initialize restricted fields // NOTE: comment in to initialize fieldRateNdOld_ to current time deriviative // current assumption is that it is zero //DenseMatrix<double> atomicPower(nLocal_,1); //compute_atomic_power(atomicPower, // lammpsInterface_->vatom(), // lammpsInterface_->fatom()); //restrict(atomicPower,fieldRateNdOld_[TEMPERATURE]); //fieldRateNdOld *= 2.; DENS_MAT atomicKineticEnergy(nLocal_,1); DENS_MAT nodalAtomicTemperature(nNodes_,1); compute_atomic_temperature(atomicKineticEnergy, lammpsInterface_->vatom()); restrict(atomicKineticEnergy, nodalAtomicTemperature); nodalAtomicTemperature *= 2.; fieldNdOld_[TEMPERATURE] = nodalAtomicTemperature; } if (timeFilterManager_.end_equilibrate()) { // set up correct initial lambda power to enforce initial temperature rate of 0 if (integrationType_==TimeIntegrator::VERLET) { if (equilibriumStart_) { if (thermostat_.get_thermostat_type()==Thermostat::FLUX) { // based on FE equation DENS_MAT vdotflamMat(-2.*fieldRateNdFiltered_[TEMPERATURE]); // note 2 is for 1/2 vdotflam addition thermostat_.reset_lambda_power(vdotflamMat); } else { // based on MD temperature equation DENS_MAT vdotflamMat(-1.*fieldRateNdFiltered_[TEMPERATURE]); thermostat_.reset_lambda_power(vdotflamMat); } } } } else { // set up space for filtered atomic power // should set up all data structures common to equilibration and filtering, // specifically filtered atomic power if (integrationType_==TimeIntegrator::FRACTIONAL_STEP) { dot_atomicTemp.reset(nNodes_,1); dot_atomicTempOld.reset(nNodes_,1); dot_dot_atomicTemp.reset(nNodes_,1); dot_dot_atomicTempOld.reset(nNodes_,1); } } }
int _start (int m, int c, struct msgbuf *buf, int bufcnt) { void vpn_user_init (void *, char *, int); if (m != MSG_BUF) exitprocess (1); printf ("vpn (user) init\n"); vpn_user_init (buf[0].base, buf[1].base, buf[1].len); if (restrict (16384, 8 * 16384)) { /* stack must be aligned to 16KiB */ printf ("vpn restrict failed\n"); exitprocess (1); } return 0; }
int main() { miniBDD::mgr mgr; miniBDD::BDD result; #if 0 { auto x=mgr.Var("x"); auto y=mgr.Var("y"); auto z=mgr.Var("z"); result=x | (y & z); } #elif 0 { auto y=mgr.Var("y"); auto x=mgr.Var("x"); auto z=mgr.Var("z"); result=x | (y & z); } #elif 0 { auto x1=mgr.Var("x_1"); auto x2=mgr.Var("x_2"); auto x3=mgr.Var("x_3"); auto x4=mgr.Var("x_4"); result=(x1&x2)|(x3&x4); } #elif 0 { auto x1=mgr.Var("x_1"); auto x2=mgr.Var("x_2"); auto x3=mgr.Var("x_3"); auto x4=mgr.Var("x_4"); auto tmp=(x1&x2)|(x3&x4); result=restrict(tmp, x2.var(), 0); } #else { auto a=mgr.Var("a"); auto b=mgr.Var("b"); auto f=!a|b; auto fp=!b; result=f==fp; } #endif mgr.DumpTikZ(std::cout); }
void CSpaceRestrictionManager::remove_restrictions (ALife::_OBJECT_ID id, shared_str remove_out_restrictions, shared_str remove_in_restrictions) { CRestrictionPtr _client_restriction = restriction(id); if (!_client_restriction) return; VERIFY (!_client_restriction->applied()); CClientRestriction &client_restriction = (*m_clients)[id]; shared_str new_out_restrictions = client_restriction.m_base_out_restrictions; shared_str new_in_restrictions = client_restriction.m_base_in_restrictions; difference_restrictions (new_out_restrictions,remove_out_restrictions); difference_restrictions (new_in_restrictions,remove_in_restrictions); restrict (id,new_out_restrictions,new_in_restrictions); }
void Compression::ZlibDecompress (std::istream& is, std::ostream& os) { char buffer[32]; is.getline (buffer, sizeof(buffer), '#'); int size (atoi (buffer)); if (size == 0) return; filtering_stream<input> fs; fs.push (zlib_decompressor()); fs.push (restrict (is, 0, size)); boost::iostreams::copy(fs, os); // fs.set_auto_close (false); fs.pop (); // Warning filtering stream is closed at destruction causing all underlying device to be clolsed as well. }
typename cartesian_base<K,N>::State mean( const cartesian<K,N,Constraint>& dom, const std::vector<W>& weights, const std::vector<typename cartesian_base<K,N>::State>& states ) { BOOST_ASSERT(states.size() == weights.size()); BOOST_ASSERT(states.size() > 0); K weight_sum = static_cast<K>(weights[0]); typename cartesian_base<K,N>::State x = static_cast<K>(weights[0])*states[0]; const std::size_t n = weights.size(); for(std::size_t i=1; i<n; i++) { K w = static_cast<K>(weights[i]); BOOST_ASSERT(w >= 0); x += w*states[i]; weight_sum += w; } BOOST_ASSERT(weight_sum >= 0); x *= (K(1) / weight_sum); return restrict(dom, x); }
//! Returns the posterior distribution conditioned on an assignment. LabelF posterior(const assignment_type& a) const { LabelF tmp; restrict(a, tmp); tmp.normalize(); return tmp; }
// Copyright (c) Microsoft // All rights reserved // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. // See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. /// <tags>P0</tags> /// <summary>Overload implicit conversions on restriction.</summary> // Case 1: ctor and func are restrict(cpu,amp) struct A { }; struct B1 { B1(A) restrict(cpu,amp) { } }; void func1(B1) restrict(cpu,amp) { } void entry1() restrict(cpu,amp) { A s; func1(s); } // Case 2: ctor has seperate implementations for restrict(cpu) and restrict(amp), func uses restrict(cpu,amp) struct B2 { B2(A) restrict(cpu) { } B2(A) restrict(amp) { } }; void func2(B2) restrict(cpu,amp) { }
void Mouse(char ch) { if(ch=='o') bar(0); else if(ch=='n') { setfillstyle(SOLID_FILL,15); hidemouse(); bar(42,62,598,458); mousecall(); setcolor(c); bar(c); } int cl,x5,y5,tool; int x1=604,y1=70,z=616,w=84; setfillstyle(cc,c); bar(12,290,27,310); //fillp show bar do { if(ch=='n') { ch='k'; if(tool==4) fout<<"setfillstyle(SOLID_FILL,"<<c<<");\n"; else if(tool==1) fout<<"setfillstyle(SOLID_FILL,15);\n"; else if(tool==6) fout<<"setfillstyle("<<cc<<','<<c<<");\n"; fout<<"setcolor("<<c<<");\n"; fout<<"rectangle(42,62,598,458);\n"; } mousecall(); x1=604,y1=70,z=616,w=84; for(int i=0;i<8;i++,y1+=25,w+=25) { mousepos(cl,x5,y5); if(x5>=x1&&x5<=z&&y5>=y1&&y5<=w) if(cl==1) { static int v=1; if(v!=c) { fout<<"setfillstyle(SOLID_FILL,"<<c<<");\n"; fout<<"setcolor("<<c<<");\n"; fout<<"rectangle(42,62,598,458);\n"; v=c; } c=i; setfillstyle(cc,c); bar(12,290,27,310); setfillstyle(SOLID_FILL,c); } } x1=621,y1=70,z=633,w=84; for( i=8;i<16;i++,y1+=25,w+=25) { mousepos(cl,x5,y5); if(x5>=x1&&x5<=z&&y5>=y1&&y5<=w) if(cl==1) { static int v=0; c=i; setfillstyle(cc,c); bar(12,290,27,310); setfillstyle(SOLID_FILL,c); if(v!=c) { fout<<"setfillstyle(SOLID_FILL,"<<c<<");\n"; fout<<"setcolor("<<c<<");\n"; fout<<"rectangle(42,62,598,458);\n"; v=c; } } } x1=605,y1=320,z=637,w=457; for(i=7;i<11;i++,y1+=25,w+=25) { mousepos(cl,x5,y5); if(x5>=x1&&x5<=z&&y5>=y1&&y5<=w) if(cl==1) { static int v=0; cc=i; setfillstyle(cc,c); bar(12,290,27,310); if(v!=cc) { fout<<"setfillstyle("<<cc<<','<<c<<");\n"; v=cc; } } } x1=5,y1=320,z=37,w=457; for(i=2;i<7;i++,y1+=25,w+=25) { mousepos(cl,x5,y5); if(x5>=x1&&x5<=z&&y5>=y1&&y5<=w) if(cl==1) { static int v=0; cc=i; setfillstyle(cc,c); bar(12,290,27,310); if(v!=cc) { fout<<"setfillstyle("<<cc<<','<<c<<");\n"; v=cc; } } } bar(c); delay(100); mousepos(cl,x5,y5); if(x5>=621&&x5<=635&&y5>=3&&y5<=16) //changes made !!! { if(cl==1) { hidemouse(); break; } } mousepos(cl,x5,y5); int gg=0; gg=help_bar(gg); while(x5>=24&&x5<=36&&y5>=70&&y5<=84) { mousepos(cl,x5,y5); setcolor(0); settextstyle(SMALL_FONT,0,4); outtextxy(45,464,"RECTANGLE "); gg=1; if(cl==1) { tool=0; } } gg=help_bar(gg); static int er=1; mousepos(cl,x5,y5); while(x5>=6&&x5<=18&&y5>=145&&y5<=159) { mousepos(cl,x5,y5); setcolor(0); settextstyle(SMALL_FONT,0,4); outtextxy(45,464,"ERASER "); gg=1; if(cl==1 && er==1) { tool=1; bar(15); fout<<"setfillstyle(SOLID_FILL,15);\n"; fout<<"setcolor(15);\n"; er=2; } } if(tool!=1) { bar(c); er=1; } gg=help_bar(gg); mousepos(cl,x5,y5); while(x5>=6&&x5<=18&&y5>=70&&y5<=84) { mousepos(cl,x5,y5); setcolor(0); settextstyle(SMALL_FONT,0,4); outtextxy(45,464,"LINE"); gg=1; if(cl==1) { tool=2; } } gg=help_bar(gg); mousepos(cl,x5,y5); while(x5>=6&&x5<=18&&y5>=90&&y5<=109) { mousepos(cl,x5,y5); setcolor(0); settextstyle(SMALL_FONT,0,4); outtextxy(45,464,"CIRCLE"); gg=1; if(cl==1) { tool=3; } } gg=help_bar(gg); mousepos(cl,x5,y5); while(x5>=24&&x5<=36&&y5>=120&&y5<=134) { mousepos(cl,x5,y5); setcolor(0); settextstyle(SMALL_FONT,0,4); outtextxy(45,464,"BUCKET"); gg=1; if(cl==1) { if(cc!=1) { fout<<"setfillstyle(SOLID_FILL,"<<c<<");\n"; cc=1; } tool=4; } } gg=help_bar(gg); mousepos(cl,x5,y5); while(x5>=24&&x5<=36&&y5>=90&&y5<=109) { mousepos(cl,x5,y5); setcolor(0); settextstyle(SMALL_FONT,0,4); outtextxy(45,464,"BRUSH "); gg=1; if(cl==1) { tool=5; } } gg=help_bar(gg); mousepos(cl,x5,y5); while(x5>=6&&x5<=18&&y5>=120&&y5<=134) { mousepos(cl,x5,y5); setcolor(0); settextstyle(SMALL_FONT,0,4); gg=1; outtextxy(45,464,"FILLER"); if(cl==1) { tool=6; } } gg=help_bar(gg); mousepos(cl,x5,y5); static int v=0; if(x5>39 && x5<78 && y5>=42 && y5<=55) //save { if(cl==1) { char f[20]; hidemouse(); SBMP("temp.bmp"); if(op('b')) { strcpy(f,s); if(!strchr(f,'.')) strcat(f,".bmp"); int check; check=rename("temp.bmp",f); if(check==-1) { remove(f); rename("temp.bmp",f); } } if(v==0) { if(op('c')) { v=1; if(!strchr(s,'.')) strcat(s,".cpp"); strcpy(::f,s); } else if(bmp("temp.bmp",0,0)) {} else bmp(f,0,0); } if(bmp(f,0,0)); else bmp("temp.bmp",0,0); mousecall(); } } mousepos(cl,x5,y5); if(x5>=10 && x5<39 && y5>=42 && y5<=55) //open { if(cl==1) { hidemouse(); SBMP("temp.bmp"); if(op('o')) { if(!strchr(s,'.')) strcat(s,".bmp"); if(bmp(s,0,0)) { settextstyle(2,0,7); cleardevice(); setcolor(RED); outtextxy(200,220," SUCH FILE DOES NOT EXIST"); outtextxy(200,280,"PRESS ENTER TO CONTINUE:"); getch(); bmp("temp.bmp",0,0); } } else bmp("temp.bmp",0,0); mousecall(); } } mousepos(cl,x5,y5); if(x5>78 && x5<111 && y5>=42 && y5<=55) //new { if(cl==1) { v=0; main('n'); } } mousepos(cl,x5,y5); if(x5>111 && x5<174 && y5>=42 && y5<=55) //password change { if(cl==1) { hidemouse(); SBMP("temp.bmp"); if(op('p')) { ofstream fout("pass.txt"); char t[20]; for(int m=0;s[m]!='\0';m++) { t[m]=s[m]-27; } t[m]='\0'; fout<<t; fout.close(); } bmp("temp.bmp",0,0); mousecall(); } } mousepos(cl,x5,y5); if(x5>174 && x5<217 && y5>=42 && y5<=55) //help { if(cl==1) { hidemouse(); SBMP("temp.bmp"); help(); bmp("temp.bmp",0,0); mousecall(); } } while(x5>43 && x5<597 && y5>63 && y5<457) { mousepos(cl,x5,y5); mousecall(); if(cl==1 && x5>43 && x5<597 && y5>63 && y5<457 ) { double a,b,p,x1,y1,x2,y2; static int v1=0,v2=0,v3=0,v4=0; double r; switch(tool) { case 0://rectangle mousecall(); x1=x5; y1=y5; delay(500); restrict(43,597,63,457); mousepos(cl,x5,y5); x2=x5,y2=y5; setcolor(c); hidemouse(); rectangle(x1,y1,x2,y2); if(v1!=x1 || v2!=x2 || v3!=y1 || v4!=y2) { fout<<"rectangle("<<x1<<','<<y1<<','<<x2<<','<<y2<<");\n"; v1=x1,v2=x2,v3=y1,v4=y2; } mousecall(); restrict(0,640,0,480); break; case 1:eraser(); break; case 2://line(); mousecall(); x1=x5; y1=y5; delay(500); restrict(43,597,63,457); mousepos(cl,x5,y5); x2=x5,y2=y5; setcolor(c); hidemouse(); line(x1,y1,x2,y2); if(v1!=x1 || v2!=x2 || v3!=y1 || v4!=y2) { fout<<"line("<<x1<<','<<y1<<','<<x2<<','<<y2<<");\n"; v1=x1,v2=x2,v3=y1,v4=y2; } mousecall(); restrict(0,640,0,480); break; case 3://circle(); mousecall(); x1=x5; y1=y5; delay(500); restrict(43,597,63,457); mousepos(cl,x5,y5); x2=x5,y2=y5; a=(x1-x2)*(x1-x2),b=(y1-y2)*(y1-y2); p=a+b; r=SQRT(p); setcolor(c); int c1=x1+r,c2=x1-r,c3=y1+r,c4=y1-r; hidemouse(); circle(x1,y1,r); if(v1!=x1 || v2!=y1) { fout<<"circle("<<x1<<','<<y1<<','<<r<<");\n"; v1=x1,v2=y1; } if(c1>597 || c2<43 || c3>457 || c4<63) SCREEN(); mousecall(); restrict(0,640,0,480); break; case 4:bucket(); break; case 5:brush(x5,y5); break; case 6:fillp(); break; default:brush(x5,y5); } } } }while(1); }