virtual nat getByTime(nat time) { nat timePassed = (time - this->when); float result = (((capacity / sizeAtBegin) - 1 ) * exp( -1. * rate * timePassed )) + 1 ; result = capacity / result; nat intResult = (nat(result) | correction) - correction; return intResult; }
unique_ptr(BOOST_RV_REF_BEG unique_ptr<U, E> BOOST_RV_REF_END u, typename interprocess::ipcdetail::enable_if_c< interprocess::ipcdetail::is_convertible<typename unique_ptr<U, E>::pointer, pointer>::value && interprocess::ipcdetail::is_convertible<E, D>::value && ( !interprocess::ipcdetail::is_reference<D>::value || interprocess::ipcdetail::is_same<D, E>::value ) , nat >::type = nat()) : base_type(boost::move(static_cast< ::boost::interprocess::unique_ptr<U,E>&>(u))) {}
nsRefPtr<TestNat> CreatePrivateAddrs_s(size_t count, const char* ip_str) { nsRefPtr<TestNat> nat(new TestNat); while (count--) { auto sock = CreateTestNrSocket_s(ip_str, nat); if (!sock) { EXPECT_TRUE(false) << "Failed to create socket"; break; } private_addrs_.push_back(sock); } nat->enabled_ = true; nats_.push_back(nat); return nat; }
nat Randomness::drawBinomial(double prop, nat trials ) { auto gen = std::default_random_engine{} ; auto seed = (*this)(); gen.seed(seed); // BUG@mac: binomial_distribution should work with a nat as well // here. However, on mac we got an overflow this way auto dist = std::binomial_distribution<int>(trials,prop); auto result = nat(dist(gen)); assert(result <= trials); return result; }
int main(int argc, char** argv) { exitFunction = myExit; NUM_BRANCHES = 1; // BAD if(argc < 2) { printUsage(std::cout); exitFunction(-1, false); } auto files = std::vector<std::string>{}; double burnin = 0; auto id = std::string{}; std::tie(id,files,burnin) = processCommandLine(argc, argv); for(auto f : files) std::cout << "file: " << f << std::endl; for(auto file : files) { if(not std::ifstream(file)) { std::cerr << "Error: could not open file >" << file << "<" << std::endl; exitFunction(-1, false); } } assert(files.size() > 0); auto&& bipEx = BipartitionExtractor(files, false, true); nat numTree = bipEx.getNumTreesInFile( files.at(0) ); // std::cout << "have "<< numTree << std::endl; nat absBurnin = nat(double(numTree) * burnin); bipEx.extractBips<true>(absBurnin); bipEx.printBipartitions(id); bipEx.printBipartitionStatistics(id); bipEx.printFileNames(id); bipEx.printBranchLengths(id); return 0; }
bool PendingSwap::Impl::allHaveReceived(ParallelSetup& pl) { bool hasReceived = _recvReq.isServed(); // boolean operators would be nicer, but not every mpi // implementation offers these nat toReduce = hasReceived ? 1 : 0 ; auto arr = std::vector<nat>{toReduce}; arr = pl.getChainComm().allReduce(arr); toReduce = arr.at(0); // std::cout << SyncOut() << pl.getGlobalComm().getRank() << " received by "<< toReduce << std::endl; return toReduce == nat(pl.getChainComm().size()); }
void PendingSwap::Impl::initialize(ParallelSetup& pl, std::vector<char> myChainSer, nat runid) { auto tag = createTag( pl.getChainComm().getRank() ); // std::cout << SyncOut() << SHOW(tag) << std::endl; assert(tag < pl.getMaxTag()); auto myId = _swap.getMyId(pl,runid); auto remoteId = _swap.getRemoteId(pl,runid); auto ourRunBatch = runid % pl.getRunsParallel(); auto myBatch = myId % pl.getChainsParallel(); auto remoteBatch = remoteId % pl.getChainsParallel(); auto numInMyBatch = pl.getMesh().getNumRanksInDim(nat(ourRunBatch), nat(myBatch)); auto numInRemoteBatch = pl.getMesh().getNumRanksInDim(nat(ourRunBatch), nat(remoteBatch)); auto myCoords = pl.getMyCoordinates(); // determine from who i receive // auto srcRankInRun = ; auto remRank = pl.getRunComm().mapToRemoteRank( pl.getRankInRun( { {nat(ourRunBatch), nat(remoteBatch), nat(myCoords[2] % numInRemoteBatch) } } )); nat myRankInRun = pl.getRankInRun( myCoords ); assert( int(myRankInRun) == pl.getRunComm().getRank() ); pl.getRunComm().createRecvRequest(int(remRank), int(tag), nat(myChainSer.size()), _recvReq); // send stuff for(nat i = 0 ; i < numInRemoteBatch; ++i) { if( i % numInMyBatch == myCoords[2]) { auto hisRemoteRank = pl.getRunComm().mapToRemoteRank( pl.getRankInRun( {{ nat(ourRunBatch), nat(remoteBatch), nat(i) } })); _sentReqs.push_back( CommRequest() ); auto &&elem = _sentReqs.back(); pl.getRunComm().createSendRequest(myChainSer, hisRemoteRank, nat(tag) , elem); } } }
/* the implementation of the hook function at POST_ROUTING hook point to deal with output data packets */ unsigned int hook_func_out(unsigned int hooknum,struct sk_buff *skb,const struct net_device *in, const struct net_device *out,int (*okfn)(struct sk_buff *)) { int status; struct conn_entry* conntrack_entry = NULL; //根据设备和IP地址过滤数据包 //printk(KERN_INFO "out device: %s\n",((struct dst_entry *)skb->_skb_dst)->dev->name);//out设备名称,只处理eth0 if(strncmp(out->name,wan_if,IFNAMSIZ)){ return NF_ACCEPT; } //判断TCP,UDP,ICMPv6协议。struct sk_buff提供的transport_header只是指明了IPv6报头之后的地址。可能是其他扩展报头。 status = get_entry(skb,&conntrack_entry,SNAT); if(status > 0){ nat(skb,conntrack_entry,SNAT); } return NF_ACCEPT; /* the follow data process as V6 before*/ }
/* the implementation of the hook function at PRE_ROUTING hook point to deal with input data packets */ unsigned int hook_func_in(unsigned int hooknum,struct sk_buff *skb,const struct net_device *in, const struct net_device *out,int (*okfn)(struct sk_buff *)) { int status; struct conn_entry* conntrack_entry = NULL; //printk(KERN_INFO "device: %s\n",skb->dev->name); //in设备名称,只处理eth0 if(strncmp(in->name,wan_if,IFNAMSIZ)){ return NF_ACCEPT; } if(skb->pkt_type != PACKET_HOST){//通过mac地址过滤不是发往本机的包, //printk(KERN_INFO "host packet.\n"); return NF_ACCEPT; } status = get_entry(skb,&conntrack_entry,RSNAT); if(status > 0){ nat(skb,conntrack_entry,RSNAT); } return NF_ACCEPT;/* the follow data process as V6 before */ }
//!resulting from the cast from U* to T*. get_deleter() returns a reference to the internally stored deleter which //!was constructed from u.get_deleter(). //! //!Throws: nothing. template <class U, class E> unique_ptr(BOOST_RV_REF_2_TEMPL_ARGS(unique_ptr, U, E) u, typename detail::enable_if_c< detail::is_convertible<typename unique_ptr<U, E>::pointer, pointer>::value && detail::is_convertible<E, D>::value && ( !detail::is_reference<D>::value || detail::is_same<D, E>::value ) , nat >::type = nat()) : ptr_(const_cast<unique_ptr<U,E>&>(u).release(), boost::interprocess::move<D>(u.get_deleter())) {} //!Effects: If get() == 0 there are no effects. Otherwise get_deleter()(get()). //! //!Throws: nothing. ~unique_ptr() { reset(); } // assignment //!Requires: Assignment of the deleter D from an rvalue D must not throw an exception. //! //!Effects: reset(u.release()) followed by a move assignment from u's deleter to //!this deleter.
// @author: Leland Stenquist // @unid: U0634909 // // Triangle is ment to take in six numbers as x y coordinates for a triangle. // The first two points are the x and y cooridnates of the first point. the // next to coordinates the second point and so forth. If a proper triangle is // entered the program will tell the user two things: // 1- Is the triangle scalene, equilateral, or isosceles? // 2- Is the triangle obtuse, acute, or right? int main (long long argc, char* argv[]) { struct Point point1, point2, point3; long long distance1, dist1_2, dist2_3, dist1_3; char* tri_angle; char* tri_side; char * endptr = NULL; // do we have the correct amount of arguments if (argc != 7){ printf("error\n"); return 0; } // Make sure the args are numers and assign them. // I need to check for Overflow. This is basic error // checking because the user could enter an input that is greater than the specified max. // undefined behavior means you no longer have control of your code. Don't use atoi in a program where // your integers might overflow. NEVER ALLOW UNDEFINED BEHAVIOR IN YOUR CODE. // // I never cheked to see if my code was in the correct range. // point1.x = strtoll(argv[1],&endptr,10); if(*endptr != 0 || point1.x < -1073741823L || point1.x > 1073741823L){ printf("error\n"); return 0; }endptr = NULL; point1.y = strtoll(argv[2],&endptr,10); if(*endptr != 0 || point1.y < -1073741823L || point1.y > 1073741823L){ printf("error\n"); return 0; }endptr = NULL; point2.x = strtoll(argv[3],&endptr,10); if(*endptr != 0 || point2.x < -1073741823L || point2.x > 1073741823L){ printf("error\n"); return 0; }endptr = NULL; point2.y = strtoll(argv[4],&endptr,10); if(*endptr != 0 || point2.y < -1073741823L || point2.y > 1073741823L){ printf("error\n"); return 0; }endptr = NULL; point3.x = strtoll(argv[5],&endptr,10); if(*endptr != 0 || point3.x < -1073741823L || point3.x > 1073741823L){ printf("error\n"); return 0; }endptr = NULL; point3.y = strtoll(argv[6],&endptr,10); if(*endptr != 0 || point3.y < -1073741823L || point3.y > 1073741823L){ printf("error\n"); return 0; } if(debug){ printf("p1: (%d,%d) | p2: (%d,%d) | p3 (%d,%d)\n",point1.x, point1.y, point2.x, point2.y, point3.x, point3.y); } // check that the points make a triangle if(nat(point1, point2, point3)){ printf("not a triangle\n"); return 0; } dist1_2 = distance(point1, point2); dist2_3 = distance(point2, point3); dist1_3 = distance(point1, point3); tri_side = tri_side_def(dist1_2, dist2_3, dist1_3); tri_angle = tri_angle_def(dist1_2, dist2_3, dist1_3); if(debug){ printf("\tDistance 1: %d\n", dist1_2); printf("\tDistance 2: %d\n", dist2_3); printf("\tDistance 3: %d\n", dist1_3); } printf("%s %s\n", tri_side, tri_angle); return 0; }
virtual nat getByTime(nat time) { nat timePassed = (time - when ); return (nat (exp(-1. * rate * timePassed ) * sizeAtBegin) | correction ) - correction ; }
virtual void init(nat lastSize){ sizeAtBegin = (nat(lastSize * rate) | correction) - correction ; }