blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
26ccd2a943f9ce47915788c027fa3303d771e9d9
8a5f01447a0cf775ebf2b11e15c903f2a4e9f7da
/src_traditional_2pl_2pc/common/connection.cc
06515275ab6de14b605ca9e9a88ed7df0cf1835b
[]
no_license
jingleyang/Calvin_mod
4c408464a80e83c0926db71e69a4d075a247bb69
e789c003d2675391c2b0f467c10e06bfe5f41de1
refs/heads/master
2021-01-10T09:11:12.710714
2016-03-03T15:35:08
2016-03-03T15:35:08
52,209,368
1
1
null
null
null
null
UTF-8
C++
false
false
15,024
cc
// Author: Kun Ren ([email protected]) // Author: Alexander Thomson ([email protected]) #include "common/connection.h" #include <cstdio> #include <iostream> #include "common/configuration.h" #include "common/utils.h" #include "sequencer/sequencer.h" using zmq::socket_t; ConnectionMultiplexer::ConnectionMultiplexer(Configuration* config) : configuration_(config), context_(1), new_connection_channel_(NULL), delete_connection_channel_(NULL), deconstructor_invoked_(false) { // Lookup port. (Pick semi-arbitrary port if node id < 0). if (config->this_node_id < 0) port_ = config->all_nodes.begin()->second->port; else port_ = config->all_nodes.find(config->this_node_id)->second->port; // Bind local (inproc) incoming socket. inproc_in_ = new socket_t(context_, ZMQ_PULL); inproc_in_->bind("inproc://__inproc_in_endpoint__"); // Bind port for remote incoming socket. char endpoint[256]; snprintf(endpoint, sizeof(endpoint), "tcp://*:%d", port_); remote_in_ = new socket_t(context_, ZMQ_PULL); remote_in_->bind(endpoint); // Wait for other nodes to bind sockets before connecting to them. Spin(0.1); send_mutex_ = new pthread_mutex_t[(int)config->all_nodes.size()]; // Connect to remote outgoing sockets. for (map<int, Node*>::const_iterator it = config->all_nodes.begin(); it != config->all_nodes.end(); ++it) { if (it->second->node_id != config->this_node_id) { // Only remote nodes. snprintf(endpoint, sizeof(endpoint), "tcp://%s:%d", it->second->host.c_str(), it->second->port); remote_out_[it->second->node_id] = new socket_t(context_, ZMQ_PUSH); remote_out_[it->second->node_id]->connect(endpoint); pthread_mutex_init(&send_mutex_[it->second->node_id], NULL); } } cpu_set_t cpuset; pthread_attr_t attr; pthread_attr_init(&attr); //pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); CPU_ZERO(&cpuset); CPU_SET(3, &cpuset); //CPU_SET(4, &cpuset); //CPU_SET(5, &cpuset); //CPU_SET(6, &cpuset); //CPU_SET(7, &cpuset); pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset); // Start Multiplexer main loop running in background thread. pthread_create(&thread_, &attr, RunMultiplexer, reinterpret_cast<void*>(this)); // Initialize mutex for future calls to NewConnection. pthread_mutex_init(&new_connection_mutex_, NULL); new_connection_channel_ = NULL; // Just to be safe, wait a bit longer for all other nodes to finish // multiplexer initialization before returning to the caller, who may start // sending messages immediately. Spin(0.1); } ConnectionMultiplexer::~ConnectionMultiplexer() { // Stop the multixplexer's main loop. deconstructor_invoked_ = true; pthread_join(thread_, NULL); // Close tcp sockets. delete remote_in_; for (unordered_map<int, zmq::socket_t*>::iterator it = remote_out_.begin(); it != remote_out_.end(); ++it) { delete it->second; } // Close inproc sockets. delete inproc_in_; for (unordered_map<string, zmq::socket_t*>::iterator it = inproc_out_.begin(); it != inproc_out_.end(); ++it) { delete it->second; } for (unordered_map<string, AtomicQueue<MessageProto>*>::iterator it = remote_result_.begin(); it != remote_result_.end(); ++it) { delete it->second; } for (unordered_map<string, AtomicQueue<MessageProto>*>::iterator it = link_unlink_queue_.begin(); it != link_unlink_queue_.end(); ++it) { delete it->second; } } Connection* ConnectionMultiplexer::NewConnection(const string& channel) { // Disallow concurrent calls to NewConnection/~Connection. pthread_mutex_lock(&new_connection_mutex_); // Register the new connection request. new_connection_channel_ = &channel; // Wait for the Run() loop to create the Connection object. (It will reset // new_connection_channel_ to NULL when the new connection has been created. while (new_connection_channel_ != NULL) {} Connection* connection = new_connection_; new_connection_ = NULL; // Allow future calls to NewConnection/~Connection. pthread_mutex_unlock(&new_connection_mutex_); return connection; } Connection* ConnectionMultiplexer::NewConnection(const string& channel, AtomicQueue<MessageProto>** aa) { // Disallow concurrent calls to NewConnection/~Connection. pthread_mutex_lock(&new_connection_mutex_); remote_result_[channel] = *aa; // Register the new connection request. new_connection_channel_ = &channel; // Wait for the Run() loop to create the Connection object. (It will reset // new_connection_channel_ to NULL when the new connection has been created. while (new_connection_channel_ != NULL) {} Connection* connection = new_connection_; new_connection_ = NULL; // Allow future calls to NewConnection/~Connection. pthread_mutex_unlock(&new_connection_mutex_); return connection; } void ConnectionMultiplexer::Run() { MessageProto message; zmq::message_t msg; while (!deconstructor_invoked_) { // Serve any pending NewConnection request. if (new_connection_channel_ != NULL) { if (inproc_out_.count(*new_connection_channel_) > 0) { // Channel name already in use. Report an error and set new_connection_ // (which NewConnection() will return) to NULL. std::cerr << "Attempt to create channel that already exists: " << (*new_connection_channel_) << "\n" << std::flush; new_connection_ = NULL; } else { // Channel name is not already in use. Create a new Connection object // and connect it to this multiplexer. new_connection_ = new Connection(); new_connection_->channel_ = *new_connection_channel_; new_connection_->multiplexer_ = this; char endpoint[256]; snprintf(endpoint, sizeof(endpoint), "inproc://%s", new_connection_channel_->c_str()); inproc_out_[*new_connection_channel_] = new socket_t(context_, ZMQ_PUSH); inproc_out_[*new_connection_channel_]->bind(endpoint); new_connection_->socket_in_ = new socket_t(context_, ZMQ_PULL); new_connection_->socket_in_->connect(endpoint); new_connection_->socket_out_ = new socket_t(context_, ZMQ_PUSH); new_connection_->socket_out_ ->connect("inproc://__inproc_in_endpoint__"); // Forward on any messages sent to this channel before it existed. vector<MessageProto>::iterator i; for (i = undelivered_messages_[*new_connection_channel_].begin(); i != undelivered_messages_[*new_connection_channel_].end(); ++i) { Send(*i); } undelivered_messages_.erase(*new_connection_channel_); } if (new_connection_channel_->substr(0, 6) == "worker") { link_unlink_queue_[*new_connection_channel_] = new AtomicQueue<MessageProto>(); } // Reset request variable. new_connection_channel_ = NULL; } // Serve any pending (valid) connection deletion request. if (delete_connection_channel_ != NULL && inproc_out_.count(*delete_connection_channel_) > 0) { delete inproc_out_[*delete_connection_channel_]; inproc_out_.erase(*delete_connection_channel_); delete_connection_channel_ = NULL; // TODO(alex): Should we also be emptying deleted channels of messages // and storing them in 'undelivered_messages_' in case the channel is // reopened/relinked? Probably. } // Forward next message from a remote node (if any). if (remote_in_->recv(&msg, ZMQ_NOBLOCK)) { message.ParseFromArray(msg.data(), msg.size()); Send(message); } // Forward next message from a local component (if any), intercepting // local Link/UnlinkChannel requests. if (inproc_in_->recv(&msg, ZMQ_NOBLOCK)) { message.ParseFromArray(msg.data(), msg.size()); // Normal message. Forward appropriately. Send(message); } for (unordered_map<string, AtomicQueue<MessageProto>*>::iterator it = link_unlink_queue_.begin(); it != link_unlink_queue_.end(); ++it) { MessageProto message; bool got_it = it->second->Pop(&message); if (got_it == true) { if (message.type() == MessageProto::LINK_CHANNEL) { remote_result_[message.channel_request()] = remote_result_[it->first]; // Forward on any messages sent to this channel before it existed. vector<MessageProto>::iterator i; for (i = undelivered_messages_[message.channel_request()].begin(); i != undelivered_messages_[message.channel_request()].end(); ++i) { Send(*i); } undelivered_messages_.erase(message.channel_request()); if (doing_deadlocks.count(message.channel_request()) > 0) { MessageProto message1; message1.set_type(MessageProto::TXN_ABORT); message1.set_destination_channel(message.channel_request()); message1.set_destination_node(configuration_->this_node_id); Send(message1); } } else if (message.type() == MessageProto::UNLINK_CHANNEL) { remote_result_.erase(message.channel_request()); } } } } } // Function to call multiplexer->Run() in a new pthread. void* ConnectionMultiplexer::RunMultiplexer(void *multiplexer) { reinterpret_cast<ConnectionMultiplexer*>(multiplexer)->Run(); return NULL; } void ConnectionMultiplexer::Send(const MessageProto& message) { if ((message.destination_node() == configuration_->this_node_id) && (message.type() == MessageProto::TXN_ABORT)) { if (undelivered_messages_.count(message.destination_channel()) > 0) { undelivered_messages_.erase(message.destination_channel()); remote_result_["force_abort_unactive_txn"]->Push(message); doing_deadlocks[message.destination_channel()] = 1; } else { if (remote_result_.count(message.destination_channel()) == 0) { remote_result_["force_abort_unactive_txn"]->Push(message); doing_deadlocks[message.destination_channel()] = 1; } else { remote_result_[message.destination_channel()]->Push(message); } } return ; } if ((message.destination_node() == configuration_->this_node_id) && (message.type() == MessageProto::READ_RESULT || message.type() == MessageProto::PREPARED || message.type() == MessageProto::PREPARED_REPLY || message.type() == MessageProto::COMMIT || message.type() == MessageProto::COMMIT_REPLY || message.type() == MessageProto::WAIT_FOR_GRAPH)) { if (remote_result_.count(message.destination_channel()) > 0) { remote_result_[message.destination_channel()]->Push(message); } else { undelivered_messages_[message.destination_channel()].push_back(message); } } else { // Prepare message. string* message_string = new string(); message.SerializeToString(message_string); zmq::message_t msg(reinterpret_cast<void*>( const_cast<char*>(message_string->data())), message_string->size(), DeleteString, message_string); // Send message. if (message.destination_node() == configuration_->this_node_id) { // Message is addressed to a local channel. If channel is valid, send the // message on, else store it to be delivered if the channel is ever created. if (inproc_out_.count(message.destination_channel()) > 0) inproc_out_[message.destination_channel()]->send(msg); else undelivered_messages_[message.destination_channel()].push_back(message); } else { // Message is addressed to valid remote node. Channel validity will be // checked by the remote multiplexer. pthread_mutex_lock(&send_mutex_[message.destination_node()]); remote_out_[message.destination_node()]->send(msg); pthread_mutex_unlock(&send_mutex_[message.destination_node()]); } } } Connection::~Connection() { // Unlink any linked channels. for (set<string>::iterator it = linked_channels_.begin(); it != linked_channels_.end(); ++it) { UnlinkChannel(*it); } // Disallow concurrent calls to NewConnection/~Connection. pthread_mutex_lock(&(multiplexer_->new_connection_mutex_)); // Delete socket on Connection end. delete socket_in_; delete socket_out_; // Prompt multiplexer to delete socket on its end. multiplexer_->delete_connection_channel_ = &channel_; // Wait for the Run() loop to delete its socket for this Connection object. // (It will then reset delete_connection_channel_ to NULL.) while (multiplexer_->delete_connection_channel_ != NULL) {} // Allow future calls to NewConnection/~Connection. pthread_mutex_unlock(&(multiplexer_->new_connection_mutex_)); } void Connection::Send(const MessageProto& message) { // Prepare message. string* message_string = new string(); message.SerializeToString(message_string); zmq::message_t msg(reinterpret_cast<void*>( const_cast<char*>(message_string->data())), message_string->size(), DeleteString, message_string); // Send message. socket_out_->send(msg); } void Connection::Send1(const MessageProto& message) { // Prepare message. string* message_string = new string(); message.SerializeToString(message_string); zmq::message_t msg(reinterpret_cast<void*>( const_cast<char*>(message_string->data())), message_string->size(), DeleteString, message_string); pthread_mutex_lock(&multiplexer()->send_mutex_[message.destination_node()]); multiplexer()->remote_out_[message.destination_node()]->send(msg); pthread_mutex_unlock(&multiplexer()->send_mutex_[message.destination_node()]); } bool Connection::GetMessage(MessageProto* message) { zmq::message_t msg_; if (socket_in_->recv(&msg_, ZMQ_NOBLOCK)) { // Received a message. message->ParseFromArray(msg_.data(), msg_.size()); return true; } else { // No message received at this time. return false; } } bool Connection::GetMessageBlocking(MessageProto* message, double max_wait_time) { double start = GetTime(); do { if (GetMessage(message)) { // Received a message. return true; } } while (GetTime() < start + max_wait_time); // Waited for max_wait_time, but no message was received. return false; } void Connection::LinkChannel(const string& channel) { MessageProto m; m.set_type(MessageProto::LINK_CHANNEL); m.set_channel_request(channel); multiplexer()->link_unlink_queue_[channel_]->Push(m); } void Connection::UnlinkChannel(const string& channel) { MessageProto m; m.set_type(MessageProto::UNLINK_CHANNEL); m.set_channel_request(channel); multiplexer()->link_unlink_queue_[channel_]->Push(m); }
2d6a2f07afa5206f5f2e4dd5fb663d992bd01d35
d35d86a90eb171ccd4ae8a3c9b0ffdeadb0165ed
/src/AIS_GoToUnseenPosition.cpp
5cdb30dc8fa4d348e7503cad9250ef9879b0fdfe
[]
no_license
fosterkong/terrainExploration
f7aa033cd79b5e10f17534899b81b0534d65b9ef
a2d4fa9392acc43355218b0af5add0d229150c9a
refs/heads/master
2021-12-05T20:44:15.433154
2015-08-24T14:40:18
2015-08-24T14:40:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,492
cpp
#include "AIS_GoToUnseenPosition.h" #include "f_vector.h" #include "f_global.h" #include "f_misc.h" #include "f_distance.h" #include "f_intersection.h" #include "f_node.h" #include "draw.h" #include "FollowNode.h" #include "FollowNLS.h" #include "simulationDefinitions.h" #include "LineSegmentVisibility.h" #include "AIB_ExploreNewTerritory.h" #include "ShortestPathGenerator.h" CAIS_GoToUnseenPosition::CAIS_GoToUnseenPosition(const CVector &_position,CAIBehaviour* _behaviour) { directionFree = false; behaviour = _behaviour; USPosition = CVector(-1,-23);//bzvz follow = 0; moveAlongPath = new CMoveAlongPath(this->behaviour->CE, &path); USPNManager.Initialize(behaviour->CE->FOV); } bool CAIS_GoToUnseenPosition::Run() { CEPosFNUpdated = false; moveAlongPath->path = &path; moveAlongPath->CE = behaviour->CE; if(F::GLOBAL::globalGoal) { if(USPosition != *F::GLOBAL::globalGoal) { USPosition = *F::GLOBAL::globalGoal; if(behaviour->CE->currentPath.firstPoint) behaviour->CE->changeVelocity = true; USPositionFN.position = USPosition; USPNManager.InitializeNewUSPN(&USPositionFN); } } else return true; direction = F::VECTOR::GetVectorFromAToB(behaviour->CE->positionViewRadius.position, USPosition).Direction(); behaviour->CE->UpdateFOV(); USPNManager.UpdateConnectivity(); if(behaviour->CE->FOV->PointInVisibleObstacles(USPosition)) { delete F::GLOBAL::globalGoal; F::GLOBAL::globalGoal = 0; return true; } if(F::DISTANCE::GetDistanceSq(behaviour->CE->positionViewRadius.position, USPosition) < behaviour->CE->speed*behaviour->CE->speed ) { directionFree = false; if(follow) delete follow; follow = 0; behaviour->CE->changeVelocity = true; behaviour->CE->velocity = CVector(0,0); delete F::GLOBAL::globalGoal; F::GLOBAL::globalGoal = 0; return true; } if(DirectionFree()) { ClearFollow(); behaviour->CE->velocity = direction; if(!directionFree) { behaviour->CE->changeVelocity = true; directionFree = true; } return true; } directionFree = false; UpdateFollow(); moveAlongPath->Update(); lenghtToGoal = moveAlongPath->GetLenghtToGoal(); return true; } bool CAIS_GoToUnseenPosition::DirectionFree() { CLineSegment ls(USPosition, behaviour->CE->positionViewRadius.position); return !behaviour->CE->FOV->LineSegmentIntersectsVisibleObstacles(ls); } void CAIS_GoToUnseenPosition::UpdateTempCEPosFNWithoutLSITest(CFollow* _follow) { CFieldOfView* FOV = behaviour->CE->FOV; int origFOVNodesSize = FOV->origFOVNodes.size(); int allFOVNodesSize = origFOVNodesSize + FOV->edgdeFOVNodes.size(); CFOVNode* current; for(int i=0; i<allFOVNodesSize; i++) { if(i<origFOVNodesSize) current = FOV->origFOVNodes[i]; else { current = FOV->edgdeFOVNodes[i-origFOVNodesSize]; if(current->origNode) continue; } if(_follow) if(_follow->DiscardFNode(current)) continue; AddNeighbourToCEPositionFN(current, false); } } void CAIS_GoToUnseenPosition::SetUpTempNodes( CFollow* _follow) { CEPosFN.ClearNeighbours(); CEPosFN.position = behaviour->CE->positionViewRadius.position; CFieldOfView* FOV = behaviour->CE->FOV; int origFOVNodesSize = FOV->origFOVNodes.size(); int allFOVNodesSize = origFOVNodesSize + FOV->edgdeFOVNodes.size(); CLineSegment toGoalFromCE(behaviour->CE->positionViewRadius.position, USPosition); CNodeLineSegment* nearestToGoal = FOV->GetLineSegmentIntersectsVisibleObstaclesClosestToPointB(toGoalFromCE); CObstacle* obst = 0; if(nearestToGoal) obst = nearestToGoal->polygon; CFOVNode* current; for(int i=0; i<allFOVNodesSize; i++) { if(i<origFOVNodesSize) current = FOV->origFOVNodes[i]; else { current = FOV->edgdeFOVNodes[i-origFOVNodesSize]; if(current->origNode) continue; } if(_follow) if(_follow->DiscardFNode(current)) continue; AddNeighbourToCEPositionFN(current); USPNManager.ConnectNodeToUSPNode(current,true, obst); } if(!USPNManager.connectedToUSPNNodes.size()) { for(int i=0; i<allFOVNodesSize; i++) { if(i<origFOVNodesSize) current = FOV->origFOVNodes[i]; else { current = FOV->edgdeFOVNodes[i-origFOVNodesSize]; if(current->origNode) continue; } if(_follow) if(_follow->DiscardFNode(current)) continue; USPNManager.ConnectNodeToUSPNode(current); } } } void CAIS_GoToUnseenPosition::ClearFollow() { if(follow) { delete follow; follow =0; } } void CAIS_GoToUnseenPosition::UpdateFollow() { if(follow) { follow->Update(); if(follow->FollowHasChanged()) ChangeFollow(); } if(!follow) CreateNewFollow(); } void CAIS_GoToUnseenPosition::CreateNewFollow() { behaviour->CE->UpdateFOVConnections(); SetUpTempNodes(); if(CEPosFNNotConnected()) UpdateTempCEPosFNWithoutLSITest(); path.clear(); vector<CPathFindingNode*> nodesPath; CShortestPathGenerator::Generate(&CEPosFN, &USPositionFN, nodesPath); CShortestPathGenerator::SavePathGValues(nodesPath, moveAlongPath->pathGValues); ClearPathGenerationVariables(); F::MISC::PathFindingNodePathToVectorPath(nodesPath, path); moveAlongPath->path = &path; moveAlongPath->lenght = CShortestPathGenerator::pathLenght; moveAlongPath->Reset(); CFOVNode* lastFOVNInPath = dynamic_cast<CFOVNode*>(nodesPath[nodesPath.size()-2]); if(lastFOVNInPath->origNode) follow = new CFollowNode(lastFOVNInPath, this); else follow = new CFollowNLS(lastFOVNInPath, this); } void CAIS_GoToUnseenPosition::ChangeFollow() { CFOVNode *fnodeToFollow = follow->lastPathFN; delete follow; if(fnodeToFollow->origNode) follow = new CFollowNode(fnodeToFollow, this); else follow = new CFollowNLS(fnodeToFollow, this); } void CAIS_GoToUnseenPosition::ClearPathGenerationVariables() { CShortestPathGenerator::Clean(); USPNManager.DisconectNodesFromUSPNode(); } void CAIS_GoToUnseenPosition::AddNeighbourToCEPositionFN( CFOVNode *_fnode, bool _LSITest ) { bool visible = false; CLineSegment ls(_fnode->position, CEPosFN.position); if(_fnode->origNode) visible = !U_FAG->LineSegmentCollisionWithObstacles_ForbiddenNodes(ls, _fnode->origNode); else visible = !U_FAG->LineSegmentCollisionWithObstacles_ForbiddenNLSs(ls, _fnode->origNLS); if(visible) { bool visible2 = false; if(_LSITest) { if(F::INTERSECTION::PointInCircleWithRadiusOffset(_fnode->position, behaviour->CE->positionViewRadius, 1)) visible2 = true; if(!visible2) if(CLineSegmentVisibility::Test(ls, behaviour->CE->paths)) visible2 = true; } else visible2 = true; if(visible2) { if(_fnode->origNode) CEPosFN.origNeighbours.push_back(_fnode); else CEPosFN.NLSNeighbours.push_back(_fnode); } } } void CAIS_GoToUnseenPosition::Draw() { CLineSegment ls(direction*behaviour->CE->positionViewRadius.r + behaviour->CE->positionViewRadius.position, behaviour->CE->positionViewRadius.position); ls.Draw(); if(F::GLOBAL::globalGoal) { glColor3f(1,0,1); Draw::CircleFill(USPosition, 100,100); } Draw::VectorObjectContainerAsOpenLine(path); if(follow) follow->Draw(); } bool CAIS_GoToUnseenPosition::CEPosFNNotConnected() { return !CEPosFN.origNeighbours.size() && !CEPosFN.NLSNeighbours.size(); }
1760e0b3f80308bddbc7a858ba52fbd025339704
2666facc0e254b66a63e6007f1e7412b09dc8ab3
/Vivado_HLS/vgg_11_src/tb.cpp
a745a96c3ff4fc6755d0c05e9e85e99f80f5d5e6
[]
no_license
AILearnerLi/Winograd_CNN_accelerator
ced6f4115cffc3765952f1f7abdea268db52d4e9
cb2dd447aeb4c002eca3445404b6882306c658d7
refs/heads/main
2023-08-17T14:52:50.964820
2021-10-09T18:53:30
2021-10-09T18:53:30
448,947,120
1
0
null
2022-01-17T15:25:11
2022-01-17T15:25:10
null
UTF-8
C++
false
false
4,637
cpp
#include <iostream> #include <fstream> using namespace std; ofstream in_sdk_file("../dbg/input_sdk.txt"); ofstream out_sdk_file("../dbg/out_L2_sdk.txt"); #include "core.h" #include "data_loader.cpp" //#include "interpret.hpp" /* * Mode 1: Output bitwidth = 8*4 * * Mode 2: Out bitwidth = 64 * * */ int mode = 1; int main() { cout<<"Vals per input = "<< Vals_per_Input <<", Input depth = "<<INPUT_depth<<endl; load_parameters(2); // int state = read_parameters(); // if(state == 1) // return 1; // std::cout.setstate(std::ios_base::failbit); hls::stream<ap_uint<simd*8*4*4>> inStream("tb_input_stream"); // hls::stream<ap_uint<8*out_parallel_C2>> outStream("tb_output_stream"); TO_32 outStream[(OFM_DIM_C2*OFM_DIM_C2*OFM_CH_C2*NUM_REPS)/4] = {0}; ap_uint<simd*8*4*4> input[ifmChannels/simd]; int rep = 1; cout<<"Loading image ..."<<endl; ap_uint<bitw> image[NUM_REPS][IMG_CH][IMG_DIM][IMG_DIM] = { // #include "7_padded.txt" #include "../data/weights_bn_v1_pack/input_image.txt" }; cout<<"Packing image ..."<<endl; ap_uint<MEM_BANDWIDTH> packed_image[INPUT_depth * NUM_REPS] = {0}; unsigned packed_iter=0; unsigned int num=0; ap_uint<MEM_BANDWIDTH> temp1 = 0; for(int rep=0; rep < NUM_REPS; rep++) for(int r = 0; r<IMG_DIM; r++){ for(int c = 0; c<IMG_DIM; c++){ for(int dp=0; dp<IMG_CH; dp++){ unsigned int lowBit = num * 8; unsigned int highBit = (num+1)*8 - 1; temp1.range(highBit,lowBit) = image[rep][dp][r][c]; if(++num == (MEM_BANDWIDTH/8)){ packed_image[packed_iter++] = temp1; in_sdk_file <<hex<<temp1<<","<<endl; cout<<(packed_iter-1)<<" "; num = 0; temp1 = 0; } } } } in_sdk_file.close(); cout <<"Running Image..."<<endl; nn_top(packed_image, outStream, false, 0, 0, 0, 0, 0, NUM_REPS); cout<<"Run completed."<<endl; int diff = 0; int temp_diff = 0; int c_pool = 0; //int pool1_gold[3136] = { //#include "pool1(gold).txt" //}; int pool2_gold[980*NUM_REPS]={ #include "../data/weights_bn_v1_pack/pool2(gold).txt" }; // cout.clear(); int outData[NUM_REPS][OFM_CH_C2][OFM_DIM_C2][OFM_DIM_C2] = {0}; // int outData_sdk[(OFM_DIM_C2*OFM_DIM_C2*OFM_CH_C2)] = {0}; // cout<<"Output stream size = "<<outStream.size()<<endl; // if(outStream.empty()) // cout<<"Output Stream empty"<<endl; // int out_size = outStream.size(); TO_32 temp_out = 0; packed_iter = 0; int depth_iter=0; int row_iter=0; int col_iter=0; // if(mode == 2) // { // for(int i=0; i<(OFM_DIM_C2*OFM_DIM_C2*OFM_CH_C2)/(MEM_BANDWIDTH/8)+1; i++) // { // temp_out = outStream[packed_iter++]; // out_sdk_file << hex<<temp_out<<endl; // for(int j=0; j<4; j++) // { // if(depth_iter >= OFM_CH_C2) // { // col_iter++; // if(col_iter >= OFM_DIM_C2){ // row_iter++; // if(row_iter >= OFM_DIM_C2) // break; // } // } // unsigned int lowBit = j * 8; // unsigned int highBit = (j+1)*8 - 1; // outData[depth_iter++][row_iter][col_iter] = temp_out.range(highBit,lowBit); // // } // // if(row_iter >= OFM_DIM_C2) // break; // } // cout<<"output unpacked ..."<<endl; // out_sdk_file.close(); // } if (mode == 1) { temp_out = 0; packed_iter = 0; for(int rep=0; rep<NUM_REPS; rep++) for(int r = 0; r<OFM_DIM_C2; r++) for(int c = 0; c<OFM_DIM_C2; c++) for(int i = 0; i<OFM_CH_C2/4; i++) { // temp_out = outStream.read(); temp_out = outStream[packed_iter++]; out_sdk_file << hex<<temp_out<<endl; for(int j =0; j<4; j++) { unsigned int lowBit = j * 8; unsigned int highBit = (j+1)*8 - 1; outData[rep][i*4 + j][r][c] = temp_out.range(highBit,lowBit); } } cout<<"output unpacked ..."<<endl; out_sdk_file.close(); } int count = 0; // cout.clear(); cout<<"Printing Output"<<endl; c_pool = 0; for(int rep=0; rep<NUM_REPS; rep++) for(int i = 0; i<OFM_CH_C2; i++) { for(int r = 0; r<OFM_DIM_C2; r++) { for(int c = 0; c<OFM_DIM_C2; c++) {cout<<outData[rep][i][r][c]; temp_diff = abs(outData[rep][i][r][c] - pool2_gold[c_pool++]); if(temp_diff > 22) {cout<<"Diff = "<< temp_diff <<" @"<<c_pool-1; diff++; } cout<<endl; } } } cout.clear(); cout<<"Differences calculated"<<endl; cout<<"Total Differences = "<<diff<<endl; for(int rep=0; rep<NUM_REPS; rep++){ cout<<"Image: "<<rep+1<<endl; for(int r=0;r<OFM_DIM_C2; r++) { for(int c=0; c<OFM_DIM_C2; c++) cout<<outData[rep][0][r][c]<<" "; cout<<endl; } } if (diff == 0) return 0; else return 1; }
1d543e9af2892b2f511c6a665cb769c41371647e
e11c26521b062073ac6c42f772d4a59e92448d59
/utils/ClockTicks.cpp
e411f29df3347c5b5953b89fa48c5f0d7516f75d
[]
no_license
mfkiwl/RVV_FEM
377980a1d459ea8b96d146c08b1dd31d10d35976
26499e66377619184d40234e9c1491038751f7b4
refs/heads/master
2022-01-08T16:29:53.148109
2019-05-04T02:02:10
2019-05-04T02:02:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,239
cpp
#include "ClockTicks.hpp" #include <stdint.h> #ifdef __riscv #define read_csr(reg) ({ unsigned long __tmp; \ asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \ __tmp; }) #else #define read_csr(reg) 0; #endif #ifdef __riscv unsigned long long int ch_ticks() { uint64_t ticks = read_csr(cycle); // uint64_t diff = ticks - CH_pticks; // CH_pticks = ticks; // return diff; return ticks; } uint64_t CH_vl = 0; uint64_t CH_vi = 0; uint64_t CH_flops = 0; uint64_t CH_mem = 0; double ch_avl() { // uint64_t vl = read_csr(hpmcounter3); // uint64_t vi = read_csr(hpmcounter4); // uint64_t vle = vl - CH_vl; // uint64_t vie = vi - CH_vi; // CH_vl = vl; // CH_vi = vi; // if (vie == 0) return 0; // if (vi == 0) return 0; // return (double)vle/vie; // return (double)vl/vi; return 0; } double ch_q() { // uint64_t mem = read_csr(hpmcounter5); // uint64_t flops = read_csr(hpmcounter6); // uint64_t meme = mem - CH_mem; // uint64_t flopse = flops - CH_flops; // CH_mem = mem; // CH_flops = flops; // if (flopse==0 or meme==0) return 0; // return (double)flopse/meme; // return (double)flops/mem; return 0; } #else double ch_avl() {return 0; } double ch_q() {return 0.; } #endif
8e69789a58ab695748d455bf932eea457c6d7cc9
8e34f7785aa0c795ba21a2348e134ae73702dc6e
/stdafx.h
417b59e581fd866b5efe5f667c9263ea65f4f639
[]
no_license
hedgehog-qd/self-made_Pacman
7f5a7db40bebc1cf7977b4e1079070dc0bb944ef
8561d85c355a15b52648c9961e01f5989a585d57
refs/heads/master
2022-12-16T11:32:00.024094
2020-09-22T12:19:01
2020-09-22T12:19:01
297,632,624
1
0
null
null
null
null
UTF-8
C++
false
false
547
h
// stdafx.h : 标准系统包含文件的包含文件, // 或是经常使用但不常更改的 // 特定于项目的包含文件 // #pragma once #include "targetver.h" #define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料 // Windows 头文件: #include <windows.h> // C 运行时头文件 #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <tchar.h> // TODO: 在此处引用程序需要的其他头文件 #include <memory> #include <vector> #include <algorithm> #include <functional>
b2bc6e10a6e79f45a2d6bd50885887b2b31ac18e
dbd9488801484f78f74f6fbc1b87be035cf7a48f
/Assignments/Pc/Assignment_2/Serial.cpp
4b1498681f1b57d006bbcfbd6798a87802615180
[ "MIT" ]
permissive
jeevanpuchakay/a2oj
a5a069c72fd1b6ec3f92763e10b23454d3fdc2ec
f867e9b2ced6619be3ca6b1a1a1838107322782d
refs/heads/master
2023-08-19T05:45:44.226044
2021-07-19T10:04:23
2021-07-19T10:04:23
192,790,577
0
0
null
null
null
null
UTF-8
C++
false
false
1,078
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int no_of_nodes,no_of_edges; cin>>no_of_nodes>>no_of_edges; int weights[n][n];int distance[n][n]; for(int i=0;i<no_of_nodes;i++){ for(int j=0;j<no_of_nodes;j++){ distance[i][j]=32000; } distance[i][i]=0; } int src,dest,weight; for(int i=0;i<no_of_edges;i++){ cin>>src>>dest>>weight; weights[src][dest]=weight; weights[src][dest]=weight; distance[src][dest]=weight; distance[src][dest]=weight; } for(int intermediate=0;intermediate<no_of_nodes;intermediate++){ for(src=0;src<no_of_nodes;src++){ for(dest=0;dest<no_of_nodes;dest++){ if(distance[src][intermediate]==32000||distance[intermediate][dest]==32000)continue; if(distance[src][dest]>distance[src][intermediate]+distance[intermediate][dest]){ distance[src][dest]=distance[src][intermediate]+distance[intermediate][dest]; } } } } }
f27555f525f4787bfbb9ffe21d618da13abc62e6
0dca74ba205f42b38c1d1a474350e57ff78352b4
/Alignment/CocoaDDLObjects/src/CocoaSolidShapeTubs.cc
5f4c8854bb78ddeacb1140ce1559ee489bd7d4c2
[ "Apache-2.0" ]
permissive
jaimeleonh/cmssw
7fd567997a244934d6c78e9087cb2843330ebe09
b26fdc373052d67c64a1b5635399ec14525f66e8
refs/heads/AM_106X_dev
2023-04-06T14:42:57.263616
2019-08-09T09:08:29
2019-08-09T09:08:29
181,003,620
1
0
Apache-2.0
2019-04-12T12:28:16
2019-04-12T12:28:15
null
UTF-8
C++
false
false
553
cc
// COCOA class implementation file //Id: CocoaSolidShapeTubs.cc //CAT: Model // // History: v1.0 // Pedro Arce #include <map> #include <fstream> #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeTubs.h" CocoaSolidShapeTubs::CocoaSolidShapeTubs( const ALIstring type, ALIfloat pRMin, ALIfloat pRMax, ALIfloat pDz, ALIfloat pSPhi, ALIfloat pDPhi ) : CocoaSolidShape( type ) { theInnerRadius = pRMin; theOuterRadius = pRMax; theZHalfLength = pDz; theStartPhiAngle = pSPhi; theDeltaPhiAngle = pDPhi; }
59ea1a6cc23c89009485e79e949a4cdd98f9d78d
41495754cf8b951b23cece87b5c79a726748cff7
/Solutions/UVA/CF-C2/334.cpp
a481d49d4f370880daad29fe9cba717962efec89
[]
no_license
PedroAngeli/Competitive-Programming
86ad490eced6980d7bc3376a49744832e470c639
ff64a092023987d5e3fdd720f56c62b99ad175a6
refs/heads/master
2021-10-23T04:49:51.508166
2021-10-13T21:39:21
2021-10-13T21:39:21
198,916,501
1
0
null
null
null
null
UTF-8
C++
false
false
1,511
cpp
#include <bits/stdc++.h> using namespace std; #define endl '\n' int main(){ ios_base :: sync_with_stdio(false); cin.tie(NULL); int nc; int test = 1; while(cin >> nc && nc){ vector <string> events(200); map <string,int> mp; vector <vector <bool> > pairs(200,vector <bool>(200,false)); int v = 0; for(int i=0;i<nc;i++){ int ne; cin >> ne; for(int j=0;j<ne;j++){ string s; cin >> s; events[v] = s; mp[s] = v; if(j < ne-1) pairs[v][v+1] = true; v++; } } int nm; cin >> nm; while(nm--){ string s1,s2; cin >> s1 >> s2; int u1 = mp[s1]; int u2 = mp[s2]; pairs[u1][u2] = true; } for(int k=0;k<v;k++) for(int i=0;i<v;i++) for(int j=0;j<v;j++) pairs[i][j] = pairs[i][j] || (pairs[i][k] && pairs[k][j]); int ans = 0; vector <pair <string,string> > vet; for(int i=0;i<v;i++) for(int j=i+1;j<v;j++) if(!pairs[i][j] && !pairs[j][i]){ ans++; if(vet.size() < 2) vet.push_back({events[i],events[j]}); } if(ans == 0){ cout << "Case " << test++ << ", no concurrent events." << endl; continue; } cout << "Case " << test++ << ", " << ans << " concurrent events:" << endl; for(int i=0;i<min(ans,2);i++) cout << "(" << vet[i].first << "," << vet[i].second << ")" << " "; cout << endl; } return 0; }
e0eddd02cebc59dc22da2100f18cb488f40e6849
3cf9e141cc8fee9d490224741297d3eca3f5feff
/C++ Benchmark Programs/Benchmark Files 1/classtester/autogen-sources/source-11101.cpp
9b27bffca78f7f3449fb489cd6a62d1a996ea28d
[]
no_license
TeamVault/tauCFI
e0ac60b8106fc1bb9874adc515fc01672b775123
e677d8cc7acd0b1dd0ac0212ff8362fcd4178c10
refs/heads/master
2023-05-30T20:57:13.450360
2021-06-14T09:10:24
2021-06-14T09:10:24
154,563,655
0
1
null
null
null
null
UTF-8
C++
false
false
2,493
cpp
struct c0; void __attribute__ ((noinline)) tester0(c0* p); struct c0 { bool active0; c0() : active0(true) {} virtual ~c0() { tester0(this); active0 = false; } virtual void f0(){} }; void __attribute__ ((noinline)) tester0(c0* p) { p->f0(); } struct c1; void __attribute__ ((noinline)) tester1(c1* p); struct c1 { bool active1; c1() : active1(true) {} virtual ~c1() { tester1(this); active1 = false; } virtual void f1(){} }; void __attribute__ ((noinline)) tester1(c1* p) { p->f1(); } struct c2; void __attribute__ ((noinline)) tester2(c2* p); struct c2 : virtual c1 { bool active2; c2() : active2(true) {} virtual ~c2() { tester2(this); c1 *p1_0 = (c1*)(c2*)(this); tester1(p1_0); active2 = false; } virtual void f2(){} }; void __attribute__ ((noinline)) tester2(c2* p) { p->f2(); if (p->active1) p->f1(); } struct c3; void __attribute__ ((noinline)) tester3(c3* p); struct c3 : virtual c1 { bool active3; c3() : active3(true) {} virtual ~c3() { tester3(this); c1 *p1_0 = (c1*)(c3*)(this); tester1(p1_0); active3 = false; } virtual void f3(){} }; void __attribute__ ((noinline)) tester3(c3* p) { p->f3(); if (p->active1) p->f1(); } struct c4; void __attribute__ ((noinline)) tester4(c4* p); struct c4 : c0, virtual c1, virtual c2 { bool active4; c4() : active4(true) {} virtual ~c4() { tester4(this); c0 *p0_0 = (c0*)(c4*)(this); tester0(p0_0); c1 *p1_0 = (c1*)(c4*)(this); tester1(p1_0); c1 *p1_1 = (c1*)(c2*)(c4*)(this); tester1(p1_1); c2 *p2_0 = (c2*)(c4*)(this); tester2(p2_0); active4 = false; } virtual void f4(){} }; void __attribute__ ((noinline)) tester4(c4* p) { p->f4(); if (p->active0) p->f0(); if (p->active1) p->f1(); if (p->active2) p->f2(); } int __attribute__ ((noinline)) inc(int v) {return ++v;} int main() { c0* ptrs0[25]; ptrs0[0] = (c0*)(new c0()); ptrs0[1] = (c0*)(c4*)(new c4()); for (int i=0;i<2;i=inc(i)) { tester0(ptrs0[i]); delete ptrs0[i]; } c1* ptrs1[25]; ptrs1[0] = (c1*)(new c1()); ptrs1[1] = (c1*)(c2*)(new c2()); ptrs1[2] = (c1*)(c3*)(new c3()); ptrs1[3] = (c1*)(c4*)(new c4()); ptrs1[4] = (c1*)(c2*)(c4*)(new c4()); for (int i=0;i<5;i=inc(i)) { tester1(ptrs1[i]); delete ptrs1[i]; } c2* ptrs2[25]; ptrs2[0] = (c2*)(new c2()); ptrs2[1] = (c2*)(c4*)(new c4()); for (int i=0;i<2;i=inc(i)) { tester2(ptrs2[i]); delete ptrs2[i]; } c3* ptrs3[25]; ptrs3[0] = (c3*)(new c3()); for (int i=0;i<1;i=inc(i)) { tester3(ptrs3[i]); delete ptrs3[i]; } c4* ptrs4[25]; ptrs4[0] = (c4*)(new c4()); for (int i=0;i<1;i=inc(i)) { tester4(ptrs4[i]); delete ptrs4[i]; } return 0; }
797e06fc96c7152f15a15f13155ac3b7a70e170f
d4e96aa48ddff651558a3fe2212ebb3a3afe5ac3
/Modules/Core/Mesh/include/itkInteriorExteriorMeshFilter.hxx
0f3610f5166165b3f02488b52b32681e4c0af5c6
[ "SMLNJ", "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-mit-old-style", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-warranty-disclaimer", "NTP", "IJG", "GPL-1.0-or-later", "libtiff", "BSD-4.3TAHOE", "Zlib", "MIT", "LicenseRef-scancode-proprietary-license", "Spencer-86", "Apache-2.0", "FSFUL", "LicenseRef-scancode-public-domain", "Libpng", "BSD-2-Clause" ]
permissive
nalinimsingh/ITK_4D
18e8929672df64df58a6446f047e6ec04d3c2616
95a2eacaeaffe572889832ef0894239f89e3f303
refs/heads/master
2020-03-17T18:58:50.953317
2018-10-01T20:46:43
2018-10-01T21:21:01
133,841,430
0
0
Apache-2.0
2018-05-17T16:34:54
2018-05-17T16:34:53
null
UTF-8
C++
false
false
4,809
hxx
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef itkInteriorExteriorMeshFilter_hxx #define itkInteriorExteriorMeshFilter_hxx #include "itkInteriorExteriorMeshFilter.h" #include "itkNumericTraits.h" #include "itkProgressReporter.h" namespace itk { /** * */ template< typename TInputMesh, typename TOutputMesh, typename TSpatialFunction > InteriorExteriorMeshFilter< TInputMesh, TOutputMesh, TSpatialFunction > ::InteriorExteriorMeshFilter() { m_SpatialFunction = SpatialFunctionType::New(); SpatialFunctionDataObjectPointer spatialFunctionObject = SpatialFunctionDataObjectType::New(); spatialFunctionObject->Set(m_SpatialFunction); this->ProcessObject::SetNthInput(1, spatialFunctionObject); } /** * */ template< typename TInputMesh, typename TOutputMesh, typename TSpatialFunction > void InteriorExteriorMeshFilter< TInputMesh, TOutputMesh, TSpatialFunction > ::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); os << indent << m_SpatialFunction << std::endl; } /** * This method causes the filter to generate its output. */ template< typename TInputMesh, typename TOutputMesh, typename TSpatialFunction > void InteriorExteriorMeshFilter< TInputMesh, TOutputMesh, TSpatialFunction > ::GenerateData(void) { typedef typename TInputMesh::PointsContainer InputPointsContainer; typedef typename TInputMesh::PointsContainerConstPointer InputPointsContainerConstPointer; typedef typename TInputMesh::PointDataContainer InputPointDataContainer; typedef typename TInputMesh::PointDataContainerConstPointer InputPointDataContainerConstPointer; const InputMeshType *inputMesh = this->GetInput(); OutputMeshPointer outputMesh = this->GetOutput(); if ( !inputMesh ) { ExceptionObject exception(__FILE__, __LINE__); exception.SetDescription("Missing Input Mesh"); exception.SetLocation(ITK_LOCATION); throw exception; } if ( !outputMesh ) { ExceptionObject exception(__FILE__, __LINE__); exception.SetDescription("Missing Output Mesh"); exception.SetLocation(ITK_LOCATION); throw exception; } outputMesh->SetBufferedRegion( outputMesh->GetRequestedRegion() ); InputPointsContainerConstPointer inPoints = inputMesh->GetPoints(); InputPointDataContainerConstPointer inData = inputMesh->GetPointData(); typename InputPointsContainer::ConstIterator inputPoint = inPoints->Begin(); typename InputPointDataContainer::ConstIterator inputData; bool inputDataExists = false; if ( inData ) { inputDataExists = true; } if ( inputDataExists ) { inputData = inData->Begin(); } // support progress methods/callbacks ProgressReporter progress( this, 0, inPoints->Size() ); typedef typename TSpatialFunction::OutputType ValueType; typedef typename TOutputMesh::PointIdentifier PointIdType; PointIdType pointId = NumericTraits< PointIdType >::ZeroValue(); while ( inputPoint != inPoints->End() ) { ValueType value = m_SpatialFunction->Evaluate( inputPoint.Value() ); if ( value ) // Assumes return type is "bool" { outputMesh->SetPoint( pointId, inputPoint.Value() ); if ( inputDataExists ) { outputMesh->SetPointData( pointId, inputData.Value() ); } pointId++; } ++inputPoint; if ( inputDataExists ) { ++inputData; } progress.CompletedPixel(); } // Create duplicate references to the rest of data in the mesh this->CopyInputMeshToOutputMeshCellLinks(); this->CopyInputMeshToOutputMeshCells(); this->CopyInputMeshToOutputMeshCellData(); unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; for ( unsigned int dim = 0; dim < maxDimension; dim++ ) { outputMesh->SetBoundaryAssignments( dim, inputMesh->GetBoundaryAssignments(dim) ); } } } // end namespace itk #endif
5b017acd074d82f15f7942e3fa2628b5fb460e86
12aab740ed7830d83200e3e0d1bf6be8c88369b5
/src/example_ros_client.cpp
b4e13988f195ccc7918984dbd90b3a70a8890928
[]
no_license
matmill5/Mobile-Robotics-PS2-Heading-Service
2a37ad5d342fc3de594d45d23f6ebce51e3814a1
cf41a40dca5cc4b63673d2a5664917f369b1546a
refs/heads/main
2023-03-04T18:27:15.466767
2021-02-17T23:27:49
2021-02-17T23:27:49
339,597,366
2
0
null
null
null
null
UTF-8
C++
false
false
843
cpp
//example ROS client: // first run: rosrun heading_ros_service heading_ROS_service // then start this node: rosrun heading_ros_service heading_ros_client #include <ros/ros.h> #include <heading_ros_service/ExampleServiceMsg.h> // this message type is defined in the current package #include <iostream> #include <string> using namespace std; int main(int argc, char **argv) { ros::init(argc, argv, "example_ros_client"); ros::NodeHandle n; ros::ServiceClient client = n.serviceClient<heading_ros_service::ExampleServiceMsg>("heading_controller_service"); heading_ros_service::ExampleServiceMsg srv; double desired_heading; while (ros::ok()) { cout << "Enter a desired heading: "; cin >> desired_heading; srv.request.desired_heading = desired_heading; client.call(srv); } return 0; }
2910159dee496506be546e65aab92a868427b2c6
a2d74f1929768f584593080f660285b9be34b74b
/acmicpc.net/problem/1504_eub.cpp
2d76446f868eb9ec56b2813eb5e9f0267a5b4d7e
[]
no_license
eubnaraAlgorithmStudy/400617
c66091db2106de92dfeacdf10701032a2b888aa3
56aef7894e23d64e37efa7b789f3c0da47e98451
refs/heads/master
2021-01-13T12:17:20.544944
2018-02-25T04:35:02
2018-02-25T04:35:02
78,322,588
4
0
null
null
null
null
UTF-8
C++
false
false
2,092
cpp
#include <iostream> #include <cstring> #include <queue> #include <vector> using namespace std; const int INF = 2147483647; int N, E; bool completed[800+1]; typedef struct Vertex { int v; int w; Vertex(int V, int W): v(V), w(W) {} } VERTEX; vector<VERTEX> edges[800+1]; bool operator<(const VERTEX& x, const VERTEX& y) { return x.w > y.w; } int dijkstra(int s, int e) { int cost[800+1]; priority_queue<VERTEX> pq; // I made an error on hits line. // "completed" should be initialized with the length of not N but N+1 memset(completed, false, sizeof(bool) * (N + 1)); for(int i=1;i<=N;i++) { cost[i] = INF; } cost[s] = 0; pq.push(VERTEX(s, 0)); while(!pq.empty()) { VERTEX cur = pq.top(); pq.pop(); if(completed[cur.v]) { continue; } if(cur.v == e) { break; } for(auto it = edges[cur.v].begin();it != edges[cur.v].end(); it++) { if (cost[cur.v] + it->w < cost[it->v]) { cost[it->v] = cost[cur.v] + it->w; pq.push(VERTEX(it->v, cost[it->v])); } } completed[cur.v] = true; } return cost[e]; } int main(void) { scanf("%d %d", &N, &E); for(int i=0;i<E;i++) { int from, to, w; scanf("%d %d %d", &from, &to, &w); edges[from].push_back(VERTEX(to, w)); edges[to].push_back(VERTEX(from, w)); } int path[2][4] = {{1,0,0,N},{1,0,0,N}}; int m1, m2; scanf("%d %d", &m1, &m2); path[0][1] = path[1][2] = m1; path[0][2] = path[1][1] = m2; int dist[2] = {0, 0}; for(int i=0;i<2;i++) { for (int j=0;j<3;j++) { int temp = dijkstra(path[i][j], path[i][j+1]); if (INF == temp) { dist[i] = INF; break; } else { dist[i] += temp; } } } int ans = dist[0] < dist[1] ? dist[0] : dist[1]; if (INF == ans) { printf("-1\n"); } else { printf("%d\n", ans); } return 0; }
b34090348dba67512dea4a66fb9ad11662bc5708
57a4164c221428d9f91714c44b265c8ec42fc3af
/29/Grapher/make_maps.cpp
4c00fae0f91fbeaadc5775a65950a055acfce7d4
[]
no_license
ivanmkrchk/OOP
725b0f3e5f512e333de8c1c83657ee4bb2ddf6b2
ce8c106ffa1c9189b2a7ab545e72c055e775ef93
refs/heads/master
2020-04-08T20:18:10.434847
2018-12-03T15:06:56
2018-12-03T15:06:56
159,693,217
0
0
null
null
null
null
UTF-8
C++
false
false
175
cpp
#include "expression.h" map <string, const int> operators_identifiers = create_operators_map(); map <string, const int> functions_identifiers = create_functions_map();
1148f244b500c3ba496303d7a8d4309a434d60a3
9030ce2789a58888904d0c50c21591632eddffd7
/SDK/ARKSurvivalEvolved_Crab_Character_BP_Summoned_classes.hpp
9b3a1aa3b9dba4d08f0f3315949c133348c1f9b2
[ "MIT" ]
permissive
2bite/ARK-SDK
8ce93f504b2e3bd4f8e7ced184980b13f127b7bf
ce1f4906ccf82ed38518558c0163c4f92f5f7b14
refs/heads/master
2022-09-19T06:28:20.076298
2022-09-03T17:21:00
2022-09-03T17:21:00
232,411,353
14
5
null
null
null
null
UTF-8
C++
false
false
863
hpp
#pragma once // ARKSurvivalEvolved (332.8) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_Crab_Character_BP_Summoned_structs.hpp" namespace sdk { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass Crab_Character_BP_Summoned.Crab_Character_BP_Summoned_C // 0x0000 (0x27F8 - 0x27F8) class ACrab_Character_BP_Summoned_C : public ACrab_Character_BP_C { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass Crab_Character_BP_Summoned.Crab_Character_BP_Summoned_C"); return ptr; } void UserConstructionScript(); void ExecuteUbergraph_Crab_Character_BP_Summoned(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
657369b8c690f3b1b51efdea7548d1f94827cd63
519d937bf1d1c3022966a4361c3d1e5d86f801e6
/Mid_Term/2-syntax_6_simultant/lex.yy.cc
b81dae6844fb9853b1317c301cee3fb897fc1dfa
[]
no_license
nabeel405/ELTE-Compilers
74c3b4c0d6b4d6868f0eedd02f9113f019f74c04
540fa02f16a1b843b8b96fb323f0b4f97c28029f
refs/heads/main
2023-01-08T00:20:43.423552
2020-11-05T10:31:56
2020-11-05T10:31:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
48,270
cc
#line 3 "lex.yy.cc" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 #define YY_FLEX_SUBMINOR_VERSION 1 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* The c++ scanner is a mess. The FlexLexer.h header file relies on the * following macro. This is required in order to pass the c++-multiple-scanners * test in the regression suite. We get reports that it breaks inheritance. * We will address this in a future release of flex, or omit the C++ scanner * altogether. */ #define yyFlexLexer yyFlexLexer /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include <inttypes.h> typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ /* begin standard C++ headers. */ #include <iostream> #include <errno.h> #include <cstdlib> #include <cstdio> #include <cstring> /* end standard C++ headers. */ /* TODO: this is always defined, so inline it */ #define yyconst const #if defined(__GNUC__) && __GNUC__ >= 3 #define yynoreturn __attribute__((__noreturn__)) #else #define yynoreturn #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k. * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. * Ditto for the __ia64__ case accordingly. */ #define YY_BUF_SIZE 32768 #else #define YY_BUF_SIZE 16384 #endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif extern int yyleng; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break * existing scanners that call yyless() from OUTSIDE yylex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-yylineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. */ #define YY_LESS_LINENO(n) \ do { \ int yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ }while(0) #define YY_LINENO_REWIND_TO(dst) \ do {\ const char *p;\ for ( p = yy_cp-1; p >= (dst); --p)\ if ( *p == '\n' )\ --yylineno;\ }while(0) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { std::streambuf* yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] void *yyalloc (yy_size_t ); void *yyrealloc (void *,yy_size_t ); void yyfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; #define yytext_ptr yytext #define YY_INTERACTIVE #include <FlexLexer.h> int yyFlexLexer::yywrap() { return 1; } /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 35 #define YY_END_OF_BUFFER 36 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[100] = { 0, 0, 0, 36, 34, 33, 33, 34, 25, 26, 19, 17, 27, 18, 28, 34, 12, 15, 14, 16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 0, 31, 28, 13, 32, 32, 32, 32, 32, 32, 32, 32, 7, 32, 32, 32, 21, 32, 32, 32, 32, 32, 32, 20, 32, 32, 23, 32, 3, 32, 32, 24, 22, 32, 32, 32, 32, 32, 32, 32, 32, 8, 32, 32, 32, 10, 6, 29, 32, 32, 2, 32, 30, 32, 32, 9, 11, 32, 32, 32, 5, 4, 1, 0 } ; static yyconst YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 5, 6, 7, 8, 9, 10, 1, 1, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 13, 14, 15, 16, 1, 1, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 1, 1, 1, 18, 1, 19, 20, 17, 21, 22, 23, 24, 25, 26, 17, 27, 28, 29, 30, 31, 32, 17, 33, 34, 35, 36, 37, 38, 17, 17, 17, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst YY_CHAR yy_meta[39] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } ; static yyconst flex_uint16_t yy_base[102] = { 0, 0, 0, 111, 112, 37, 39, 107, 112, 112, 112, 112, 112, 112, 98, 93, 112, 112, 112, 112, 0, 77, 21, 80, 16, 86, 24, 73, 72, 69, 68, 78, 72, 65, 20, 46, 94, 112, 85, 112, 0, 74, 70, 62, 55, 57, 69, 61, 0, 53, 66, 51, 0, 54, 65, 57, 46, 55, 54, 0, 53, 50, 0, 55, 0, 42, 53, 0, 0, 50, 52, 40, 49, 42, 34, 38, 45, 0, 44, 41, 31, 0, 0, 0, 41, 40, 0, 42, 0, 38, 40, 0, 0, 28, 24, 22, 0, 0, 0, 112, 54, 48 } ; static yyconst flex_int16_t yy_def[102] = { 0, 99, 1, 99, 99, 99, 99, 100, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 99, 100, 99, 99, 99, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 0, 99, 99 } ; static yyconst flex_uint16_t yy_nxt[151] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 4, 21, 22, 23, 24, 25, 20, 20, 26, 20, 20, 27, 28, 29, 30, 31, 32, 33, 20, 20, 34, 35, 35, 35, 35, 42, 45, 57, 46, 48, 35, 35, 40, 98, 43, 58, 49, 36, 36, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 38, 37, 56, 55, 54, 53, 52, 51, 50, 47, 44, 41, 39, 38, 37, 99, 3, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 } ; static yyconst flex_int16_t yy_chk[151] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 6, 6, 22, 24, 34, 24, 26, 35, 35, 101, 95, 22, 34, 26, 100, 100, 94, 93, 90, 89, 87, 85, 84, 80, 79, 78, 76, 75, 74, 73, 72, 71, 70, 69, 66, 65, 63, 61, 60, 58, 57, 56, 55, 54, 53, 51, 50, 49, 47, 46, 45, 44, 43, 42, 41, 38, 36, 33, 32, 31, 30, 29, 28, 27, 25, 23, 21, 15, 14, 7, 3, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[36] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET #line 1 "while.l" #line 4 "while.l" #include <iostream> #include <stdlib.h> #include "Parserbase.h" #line 499 "lex.yy.cc" #define INITIAL 0 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include <unistd.h> #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k */ #define YY_READ_BUF_SIZE 16384 #else #define YY_READ_BUF_SIZE 8192 #endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO #define ECHO LexerOutput( yytext, yyleng ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ \ if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) LexerError( msg ) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 #define YY_DECL int yyFlexLexer::yylex() #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK /*LINTED*/break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { yy_state_type yy_current_state; char *yy_cp, *yy_bp; int yy_act; if ( !(yy_init) ) { (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin.rdbuf(std::cin.rdbuf()); if ( ! yyout ) yyout.rdbuf(std::cout.rdbuf()); if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE ); } yy_load_buffer_state( ); } { #line 13 "while.l" #line 634 "lex.yy.cc" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = (yy_start); yy_match: do { YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 100 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 112 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { int yyl; for ( yyl = 0; yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) yylineno++; ; } do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = (yy_hold_char); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: YY_RULE_SETUP #line 15 "while.l" return Parser::T_PROGRAM; YY_BREAK case 2: YY_RULE_SETUP #line 16 "while.l" return Parser::T_BEGIN; YY_BREAK case 3: YY_RULE_SETUP #line 17 "while.l" return Parser::T_END; YY_BREAK case 4: YY_RULE_SETUP #line 18 "while.l" return Parser::T_INTEGER; YY_BREAK case 5: YY_RULE_SETUP #line 19 "while.l" return Parser::T_BOOLEAN; YY_BREAK case 6: YY_RULE_SETUP #line 20 "while.l" return Parser::T_SKIP; YY_BREAK case 7: YY_RULE_SETUP #line 21 "while.l" return Parser::T_IF; YY_BREAK case 8: YY_RULE_SETUP #line 22 "while.l" return Parser::T_ELSE; YY_BREAK case 9: YY_RULE_SETUP #line 23 "while.l" return Parser::T_WHILE; YY_BREAK case 10: YY_RULE_SETUP #line 24 "while.l" return Parser::T_READ; YY_BREAK case 11: YY_RULE_SETUP #line 25 "while.l" return Parser::T_WRITE; YY_BREAK case 12: YY_RULE_SETUP #line 26 "while.l" return Parser::T_SEMICOLON; YY_BREAK case 13: YY_RULE_SETUP #line 27 "while.l" return Parser::T_ASSIGN; YY_BREAK case 14: YY_RULE_SETUP #line 28 "while.l" return Parser::T_EQ; YY_BREAK case 15: YY_RULE_SETUP #line 29 "while.l" return Parser::T_LESS; YY_BREAK case 16: YY_RULE_SETUP #line 30 "while.l" return Parser::T_GR; YY_BREAK case 17: YY_RULE_SETUP #line 31 "while.l" return Parser::T_ADD; YY_BREAK case 18: YY_RULE_SETUP #line 32 "while.l" return Parser::T_SUB; YY_BREAK case 19: YY_RULE_SETUP #line 33 "while.l" return Parser::T_MUL; YY_BREAK case 20: YY_RULE_SETUP #line 34 "while.l" return Parser::T_AND; YY_BREAK case 21: YY_RULE_SETUP #line 35 "while.l" return Parser::T_OR; YY_BREAK case 22: YY_RULE_SETUP #line 36 "while.l" return Parser::T_NOT; YY_BREAK case 23: YY_RULE_SETUP #line 37 "while.l" return Parser::T_DIV; YY_BREAK case 24: YY_RULE_SETUP #line 38 "while.l" return Parser::T_MOD; YY_BREAK case 25: YY_RULE_SETUP #line 39 "while.l" return Parser::T_OPEN; YY_BREAK case 26: YY_RULE_SETUP #line 40 "while.l" return Parser::T_CLOSE; YY_BREAK case 27: YY_RULE_SETUP #line 41 "while.l" return Parser::T_COMMA; YY_BREAK case 28: YY_RULE_SETUP #line 43 "while.l" return Parser::T_NUM; YY_BREAK case 29: YY_RULE_SETUP #line 44 "while.l" return Parser::T_TRUE; YY_BREAK case 30: YY_RULE_SETUP #line 45 "while.l" return Parser::T_FALSE; YY_BREAK case 31: /* rule 31 can match eol */ YY_RULE_SETUP #line 47 "while.l" // nothing to do YY_BREAK case 32: YY_RULE_SETUP #line 49 "while.l" return Parser::T_ID; YY_BREAK case 33: /* rule 33 can match eol */ YY_RULE_SETUP #line 51 "while.l" // nothing to do YY_BREAK case 34: YY_RULE_SETUP #line 53 "while.l" { std::cerr << "Line " << lineno() << ": Lexical error." << std::endl; exit(1); } YY_BREAK case 35: YY_RULE_SETUP #line 58 "while.l" ECHO; YY_BREAK #line 881 "lex.yy.cc" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = (yy_hold_char); YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = (yy_c_buf_p); goto yy_find_action; } } else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { (yy_did_buffer_switch_on_eof) = 0; if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ } /* end of yylex */ /* The contents of this function are C++ specific, so the () macro is not used. * This constructor simply maintains backward compatibility. * DEPRECATED */ yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ): yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) { ctor_common(); } /* The contents of this function are C++ specific, so the () macro is not used. */ yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): yyin(arg_yyin.rdbuf()), yyout(arg_yyout.rdbuf()) { ctor_common(); } /* The contents of this function are C++ specific, so the () macro is not used. */ void yyFlexLexer::ctor_common() { yy_c_buf_p = 0; yy_init = 0; yy_start = 0; yy_flex_debug = 0; yylineno = 1; // this will only get updated if %option yylineno yy_did_buffer_switch_on_eof = 0; yy_looking_for_trail_begin = 0; yy_more_flag = 0; yy_more_len = 0; yy_more_offset = yy_prev_more_offset = 0; yy_start_stack_ptr = yy_start_stack_depth = 0; yy_start_stack = NULL; yy_buffer_stack = NULL; yy_buffer_stack_top = 0; yy_buffer_stack_max = 0; yy_state_buf = 0; } /* The contents of this function are C++ specific, so the () macro is not used. */ yyFlexLexer::~yyFlexLexer() { delete [] yy_state_buf; yyfree(yy_start_stack ); yy_delete_buffer( YY_CURRENT_BUFFER ); yyfree(yy_buffer_stack ); } /* The contents of this function are C++ specific, so the () macro is not used. */ void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) { // was if( new_in ) yy_delete_buffer( YY_CURRENT_BUFFER ); yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); // was if( new_out ) yyout.rdbuf(new_out.rdbuf()); } /* The contents of this function are C++ specific, so the () macro is not used. */ void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) { if( ! new_in ) { new_in = &yyin; } if ( ! new_out ) { new_out = &yyout; } switch_streams(*new_in, *new_out); } #ifdef YY_INTERACTIVE int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) #else int yyFlexLexer::LexerInput( char* buf, int max_size ) #endif { if ( yyin.eof() || yyin.fail() ) return 0; #ifdef YY_INTERACTIVE yyin.get( buf[0] ); if ( yyin.eof() ) return 0; if ( yyin.bad() ) return -1; return 1; #else (void) yyin.read( buf, max_size ); if ( yyin.bad() ) return -1; else return yyin.gcount(); #endif } void yyFlexLexer::LexerOutput( const char* buf, int size ) { (void) yyout.write( buf, size ); } /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ int yyFlexLexer::yy_get_next_buffer() { char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = (yytext_ptr); int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ yy_state_type yyFlexLexer::yy_get_previous_state() { yy_state_type yy_current_state; char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 100 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) { int yy_is_jam; char *yy_cp = (yy_c_buf_p); YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 100 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; yy_is_jam = (yy_current_state == 99); return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_UNPUT void yyFlexLexer::yyunput( int c, char* yy_bp) { char *yy_cp; yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ int number_to_move = (yy_n_chars) + 2; char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; if ( c == '\n' ){ --yylineno; } (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } #endif int yyFlexLexer::yyinput() { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ int offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); if ( c == '\n' ) yylineno++; ; return c; } /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyFlexLexer::yyrestart( std::istream& input_file ) { if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer( yyin, YY_BUF_SIZE ); } yy_init_buffer( YY_CURRENT_BUFFER, input_file ); yy_load_buffer_state( ); } /** Delegate to the new version that takes an istream reference. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyFlexLexer::yyrestart( std::istream* input_file ) { yyrestart( *input_file ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } void yyFlexLexer::yy_load_buffer_state() { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = (yy_size_t)size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } /** Delegate creation of buffers to the new version that takes an istream reference. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) { return yy_create_buffer( *file, size ); } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * */ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yyfree((void *) b->yy_ch_buf ); yyfree((void *) b ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) { int oerrno = errno; yy_flush_buffer( b ); b->yy_input_file = file.rdbuf(); b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) { if (new_buffer == NULL) return; yyensure_buffer_stack(); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void yyFlexLexer::yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ void yyFlexLexer::yyensure_buffer_stack(void) { int num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } void yyFlexLexer::yy_push_state( int _new_state ) { if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) { yy_size_t new_size; (yy_start_stack_depth) += YY_START_STACK_INCR; new_size = (yy_size_t) (yy_start_stack_depth) * sizeof( int ); if ( ! (yy_start_stack) ) (yy_start_stack) = (int *) yyalloc(new_size ); else (yy_start_stack) = (int *) yyrealloc((void *) (yy_start_stack),new_size ); if ( ! (yy_start_stack) ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; BEGIN(_new_state); } void yyFlexLexer::yy_pop_state() { if ( --(yy_start_stack_ptr) < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); } int yyFlexLexer::yy_top_state() { return (yy_start_stack)[(yy_start_stack_ptr) - 1]; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif void yyFlexLexer::LexerError( yyconst char* msg ) { std::cerr << msg << std::endl; exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *yyalloc (yy_size_t size ) { return malloc(size); } void *yyrealloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return realloc(ptr, size); } void yyfree (void * ptr ) { free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 58 "while.l"
2938065161c7cb301fe0a477c120fc3c3af07959
edadfc63d9257990a61b8b55e02f7bb7796832aa
/bigmap.h
8379017d15b874ff5acfdcb0d6aac82113f3e6d7
[]
no_license
destinyvoilet/Mouse_Maze
93d6a1b98bd5963cdd355d305bcfe2087fff48d9
139e4768582efb6e107455b2b2c09a5686000abf
refs/heads/main
2023-01-08T06:08:10.852874
2020-10-24T05:58:12
2020-10-24T05:58:12
306,814,878
0
0
null
null
null
null
UTF-8
C++
false
false
2,382
h
#ifndef BIGMAP_H #define BIGMAP_H #include <QWidget> #include <QTimer> #include <QIcon> #include <QPainter> #include <QMouseEvent> #include <QProgressBar> #include <QPushButton> #include <QLabel> #include <QPoint> #include <QString> #include <QFont> #include <QMovie> #include <QLabel> #include <QSound> #include <mapix.h> #include <vector> #include <ctime> #include <cmath> #include <string.h> #include "config.h" #include "mouse.h" #include "wall.h" #include "road.h" #include "barn.h" #include "losegame.h" #define down 1 #define RIGHT 2 #define LEFT 4 #define up 8 #define QAQ pow(2,choice-1)*10+1 class BigMap : public QWidget { Q_OBJECT public: explicit BigMap(QWidget *parent = nullptr); //void initmap(); void playGame(); //void updatePosition(); void map(); void settime(double); void setchoice(int); void generate_map(); void FindBlock(int,int); Mouse myMouse; Barn myBarn; QSound *lose_Sound; QSound *win_Sound; Road myRoad[ROAD_NUM]; Wall myWall[WALL_NUM]; QProgressBar myBlood; int blood_max; LoseGame GameOver; QSound *bg_music; void paintEvent(QPaintEvent *event); void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event); void timerEvent(QTimerEvent *event); int Alive; bool Save; int MouseMove(); void Map_move(bool); bool power; int choice; int Map_size; int size=50; int Wall_num; int Road_num; int Wall_num_max; int Road_num_max; int Score_Sum; int Only_One; int xp[MOUSE_INTERVAL]; int yp[MOUSE_INTERVAL]; bool first; QTimer myTimer; struct block { int row, column, direction; block(int _row, int _column, int _direction) { row = _row; column = _column; direction = _direction; } }; struct point { int x; int y; }start, end; std::vector<block> myblock; int x_num = 1, y_num = 1;//矿工位置 ~BigMap(); signals: public slots: void ReStart();//重置函数 private: QPushButton Button1; QPushButton Button2; QLabel *Label1; QLabel *Label2; QLabel *Label3; int Time_game; }; #endif // BIGMAP_H
9ac867db8ea70d33264956425d248f37f6021452
3ae80dbc18ed3e89bedf846d098b2a98d8e4b776
/header/SSWR/AVIReadCE/AVIRCEBaseForm.h
3752c7fe2009ed7623df6c005b4b10d57f587df9
[]
no_license
sswroom/SClass
deee467349ca249a7401f5d3c177cdf763a253ca
9a403ec67c6c4dfd2402f19d44c6573e25d4b347
refs/heads/main
2023-09-01T07:24:58.907606
2023-08-31T11:24:34
2023-08-31T11:24:34
329,970,172
10
7
null
null
null
null
UTF-8
C++
false
false
1,171
h
#ifndef _SM_SSWR_AVIREADCE_AVIRCEBASEFORM #define _SM_SSWR_AVIREADCE_AVIRCEBASEFORM #include "Data/FastMap.h" #include "SSWR/AVIRead/AVIRCore.h" #include "UI/GUIForm.h" #include "UI/GUIHSplitter.h" #include "UI/GUIListBox.h" namespace SSWR { namespace AVIReadCE { class AVIRCEBaseForm : public UI::GUIForm { private: typedef struct { const WChar *name; Int32 item; } MenuInfo; private: NotNullPtr<SSWR::AVIRead::AVIRCore> core; UI::GUIListBox *lbCategory; UI::GUIHSplitter *hspMain; UI::GUIListBox *lbContent; Data::Int32FastMap<Data::ArrayList<MenuInfo*>*> *menuItems; private: static void __stdcall FileHandler(void *userObj, const UTF8Char **files, OSInt nFiles); static void __stdcall OnCategoryChg(void *userObj); static void __stdcall OnContentClick(void *userObj); static MenuInfo *__stdcall NewMenuItem(const WChar *name, Int32 item); public: AVIRCEBaseForm(UI::GUIClientControl *parent, NotNullPtr<UI::GUICore> ui, NotNullPtr<SSWR::AVIRead::AVIRCore> core); virtual ~AVIRCEBaseForm(); virtual void EventMenuClicked(UInt16 cmdId); }; }; }; #endif
78b9b898336d901cbf51d7d5a1c7c765ba7c5c0f
711e5c8b643dd2a93fbcbada982d7ad489fb0169
/XPSP1/NT/inetsrv/iis/svcs/nntp/server/post/utest/nntpsrvi.h
68b06e167ee6851e7b6b4de72df9274d0d09f84b
[]
no_license
aurantst/windows-XP-SP1
629a7763c082fd04d3b881e0d32a1cfbd523b5ce
d521b6360fcff4294ae6c5651c539f1b9a6cbb49
refs/heads/master
2023-03-21T01:08:39.870106
2020-09-28T08:10:11
2020-09-28T08:10:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,097
h
// // Copyright (c) 1998 Microsoft Corporation // // Module Name: // // nntpsrvi.h // // Abstract: // // Defines CNntpServer, which implements the INntpServer interface // // Author: // // Alex Wetmore // // class CNntpServer : public INntpServer { private: // // Reference counting // LONG m_cRef; public: // // Constructors // CNntpServer() { m_cRef = 1; } public: // // INntpServer ---------------------------------------------------- // // // find the primary groupid/articleid for an article given the secondary // groupid/articleid // // returns: // S_OK - found primary // S_FALSE - the values given were the primary // otherwise error // void __stdcall FindPrimaryArticle(INNTPPropertyBag *pgroupSecondary, DWORD artidSecondary, INNTPPropertyBag **pgroupPrimary, DWORD *partidPrimary, INntpComplete *pComplete) { pComplete->SetResult(E_NOTIMPL); pComplete->Release(); } // // IUnknown ------------------------------------------------------ // HRESULT __stdcall QueryInterface(const IID& iid, VOID** ppv) { if (iid == IID_IUnknown) { *ppv = static_cast<IUnknown*>(this); } else if (iid == IID_INntpServer) { *ppv = static_cast<INntpServer*>(this); } else { *ppv = NULL; return E_NOINTERFACE; } reinterpret_cast<IUnknown*>(*ppv)->AddRef(); return S_OK; } ULONG __stdcall AddRef() { return InterlockedIncrement(&m_cRef); } ULONG __stdcall Release() { if ( InterlockedDecrement(&m_cRef) == 0 ) { // we should never hit zero because the instance creates // us and should always have one reference _ASSERT( 0 ); } return m_cRef; } };
309f681d70c288dcea10ea49d11dd3b0f2a4e62a
12d49cf0bdd8844d747f40783ce547e940540f0c
/grail/classes/fm/reach.cpp
250a552e93c99798fa012bee695c4b45cfcee94c
[]
no_license
guenhae/Orbit
42375d44a0d8a047243b89826815512e4723fb0a
5d676bdb92a85702d24e39064ed04ee2ffd92b6a
refs/heads/master
2021-01-10T10:58:24.647783
2016-01-27T23:29:12
2016-01-27T23:29:12
50,544,898
0
0
null
null
null
null
UTF-8
C++
false
false
1,764
cpp
// This code copyright (c) by the Grail project. // No commercial use permitted without written consent. // May 1993 /*************************************************************************** File: classes/fm/reach.cpp ----- Description: ------------ This file contains the definition of the following function: void fm<Label>::reachable_fm() This function is a public member of the template class fm (declared in classes/fm/fm.h). Revision History: ----------------- The Grail Project Initial version of source code M.Hoeberechts 98/09/07 Added header and comments ***************************************************************************/ /*************************************************************************** void fm<Label>::reachable_fm() Description: This function is a public member of the template class fm (declared in classes/re/fm.h). Reduce the state set in this fm to states which are reachable from a start state. This function can be called in the following way: this_fm.reachable_fm(); Parameters: none Return Value: none ***************************************************************************/ template <class Label> void fm<Label>::reachable_fm() { int i; state m1; state m2; fm<Label> result; set<state> r_states; reachable_states(r_states); result.start_states = start_states; // keep only reachable final states result.final_states.intersect(final_states, r_states); for (i=0; i<size(); ++i) { m1 = arcs[i].get_source(); m2 = arcs[i].get_sink(); if ((r_states.member(m1) >= 0) && (r_states.member(m2) >= 0)) result.disjoint_union(arcs[i]); } *this = result; }
9c135f93d3eda72f86f99cb49cc5d9b22e1ba27c
4be41ae28bd7d5cbff5ca173a88f113219d9ec75
/src/google/protobuf/parse_context.h
63a11ad2645e3be0eae7bc61b9c52c58cfc99b8b
[ "LicenseRef-scancode-protobuf" ]
permissive
YixuanBan/protobuf-310
ef76fc3aaf88f690fe6e91dd5b1f658beb53814f
cf0110b5b8d476df7a9014b68bc9b1c9b53d9d49
refs/heads/master
2023-03-30T18:30:28.179733
2020-06-08T03:49:37
2020-06-08T03:49:37
270,517,595
0
0
NOASSERTION
2021-03-31T22:09:52
2020-06-08T03:43:15
C++
UTF-8
C++
false
false
29,137
h
// Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef GOOGLE_PROTOBUF_PARSE_CONTEXT_H__ #define GOOGLE_PROTOBUF_PARSE_CONTEXT_H__ #include <cstring> #include <string> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/arenastring.h> #include <google/protobuf/implicit_weak_message.h> #include <google/protobuf/metadata_lite.h> #include <google/protobuf/port.h> #include <google/protobuf/repeated_field.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/port_def.inc> namespace google2 { namespace protobuf { class UnknownFieldSet; class DescriptorPool; class MessageFactory; namespace internal { // Template code below needs to know about the existence of these functions. PROTOBUF_EXPORT void WriteVarint(uint32 num, uint64 val, std::string* s); PROTOBUF_EXPORT void WriteLengthDelimited(uint32 num, StringPiece val, std::string* s); // Inline because it is just forwarding to s->WriteVarint inline void WriteVarint(uint32 num, uint64 val, UnknownFieldSet* s); inline void WriteLengthDelimited(uint32 num, StringPiece val, UnknownFieldSet* s); // The basic abstraction the parser is designed for is a slight modification // of the ZeroCopyInputStream (ZCIS) abstraction. A ZCIS presents a serialized // stream as a series of buffers that concatenate to the full stream. // Pictorially a ZCIS presents a stream in chunks like so // [---------------------------------------------------------------] // [---------------------] chunk 1 // [----------------------------] chunk 2 // chunk 3 [--------------] // // Where the '-' represent the bytes which are vertically lined up with the // bytes of the stream. The proto parser requires its input to be presented // similarily with the extra // property that each chunk has kSlopBytes past its end that overlaps with the // first kSlopBytes of the next chunk, or if there is no next chunk at least its // still valid to read those bytes. Again, pictorially, we now have // // [---------------------------------------------------------------] // [-------------------....] chunk 1 // [------------------------....] chunk 2 // chunk 3 [------------------..**] // chunk 4 [--****] // Here '-' mean the bytes of the stream or chunk and '.' means bytes past the // chunk that match up with the start of the next chunk. Above each chunk has // 4 '.' after the chunk. In the case these 'overflow' bytes represents bytes // past the stream, indicated by '*' above, their values are unspecified. It is // still legal to read them (ie. should not segfault). Reading past the // end should be detected by the user and indicated as an error. // // The reason for this, admittedly, unconventional invariant is to ruthlessly // optimize the protobuf parser. Having an overlap helps in two important ways. // Firstly it alleviates having to performing bounds checks if a piece of code // is guaranteed to not read more than kSlopBytes. Secondly, and more // importantly, the protobuf wireformat is such that reading a key/value pair is // always less than 16 bytes. This removes the need to change to next buffer in // the middle of reading primitive values. Hence there is no need to store and // load the current position. class PROTOBUF_EXPORT EpsCopyInputStream { public: enum { kSlopBytes = 16, kMaxCordBytesToCopy = 512 }; explicit EpsCopyInputStream(bool enable_aliasing) : aliasing_(enable_aliasing ? kOnPatch : kNoAliasing) {} void BackUp(const char* ptr) { GOOGLE_DCHECK(ptr <= buffer_end_ + kSlopBytes); int count; if (next_chunk_ == buffer_) { count = static_cast<int>(buffer_end_ + kSlopBytes - ptr); } else { count = size_ + static_cast<int>(buffer_end_ - ptr); } if (count > 0) zcis_->BackUp(count); } // If return value is negative it's an error PROTOBUF_MUST_USE_RESULT int PushLimit(const char* ptr, int limit) { GOOGLE_DCHECK(limit >= 0); limit += ptr - buffer_end_; limit_end_ = buffer_end_ + (std::min)(0, limit); auto old_limit = limit_; limit_ = limit; return old_limit - limit; } PROTOBUF_MUST_USE_RESULT bool PopLimit(int delta) { if (PROTOBUF_PREDICT_FALSE(!EndedAtLimit())) return false; limit_ = limit_ + delta; // TODO(gerbens) We could remove this line and hoist the code to // DoneFallback. Study the perf/bin-size effects. limit_end_ = buffer_end_ + (std::min)(0, limit_); return true; } PROTOBUF_MUST_USE_RESULT const char* Skip(const char* ptr, int size) { if (size <= buffer_end_ + kSlopBytes - ptr) { return ptr + size; } return SkipFallback(ptr, size); } PROTOBUF_MUST_USE_RESULT const char* ReadString(const char* ptr, int size, std::string* s) { if (size <= buffer_end_ + kSlopBytes - ptr) { s->assign(ptr, size); return ptr + size; } return ReadStringFallback(ptr, size, s); } PROTOBUF_MUST_USE_RESULT const char* AppendString(const char* ptr, int size, std::string* s) { if (size <= buffer_end_ + kSlopBytes - ptr) { s->append(ptr, size); return ptr + size; } return AppendStringFallback(ptr, size, s); } template <typename Tag, typename T> PROTOBUF_MUST_USE_RESULT const char* ReadRepeatedFixed(const char* ptr, Tag expected_tag, RepeatedField<T>* out); template <typename T> PROTOBUF_MUST_USE_RESULT const char* ReadPackedFixed(const char* ptr, int size, RepeatedField<T>* out); template <typename Add> PROTOBUF_MUST_USE_RESULT const char* ReadPackedVarint(const char* ptr, Add add); uint32 LastTag() const { return last_tag_minus_1_ + 1; } bool ConsumeEndGroup(uint32 start_tag) { bool res = last_tag_minus_1_ == start_tag; last_tag_minus_1_ = 0; return res; } bool EndedAtLimit() const { return last_tag_minus_1_ == 0; } bool EndedAtEndOfStream() const { return last_tag_minus_1_ == 1; } void SetLastTag(uint32 tag) { last_tag_minus_1_ = tag - 1; } void SetEndOfStream() { last_tag_minus_1_ = 1; } bool IsExceedingLimit(const char* ptr) { return ptr > limit_end_ && (next_chunk_ == nullptr || ptr - buffer_end_ > limit_); } // Returns true if more data is available, if false is returned one has to // call Done for further checks. bool DataAvailable(const char* ptr) { return ptr < limit_end_; } protected: // Returns true is limit (either an explicit limit or end of stream) is // reached. It aligns *ptr across buffer seams. // If limit is exceeded it returns true and ptr is set to null. bool DoneWithCheck(const char** ptr, int d) { GOOGLE_DCHECK(*ptr); if (PROTOBUF_PREDICT_TRUE(*ptr < limit_end_)) return false; // No need to fetch buffer if we ended on a limit in the slop region if ((*ptr - buffer_end_) == limit_) return true; auto res = DoneFallback(*ptr, d); *ptr = res.first; return res.second; } const char* InitFrom(StringPiece flat) { overall_limit_ = 0; if (flat.size() > kSlopBytes) { limit_ = kSlopBytes; limit_end_ = buffer_end_ = flat.end() - kSlopBytes; next_chunk_ = buffer_; if (aliasing_ == kOnPatch) aliasing_ = kNoDelta; return flat.begin(); } else { std::memcpy(buffer_, flat.begin(), flat.size()); limit_ = 0; limit_end_ = buffer_end_ = buffer_ + flat.size(); next_chunk_ = nullptr; if (aliasing_ == kOnPatch) { aliasing_ = reinterpret_cast<std::uintptr_t>(flat.data()) - reinterpret_cast<std::uintptr_t>(buffer_); } return buffer_; } } const char* InitFrom(io::ZeroCopyInputStream* zcis); const char* InitFrom(io::ZeroCopyInputStream* zcis, int limit) { overall_limit_ = limit; auto res = InitFrom(zcis); limit_ = limit - static_cast<int>(buffer_end_ - res); limit_end_ = buffer_end_ + (std::min)(0, limit_); return res; } private: const char* limit_end_; // buffer_end_ + min(limit_, 0) const char* buffer_end_; const char* next_chunk_; int size_; int limit_; // relative to buffer_end_; io::ZeroCopyInputStream* zcis_ = nullptr; char buffer_[2 * kSlopBytes] = {}; enum { kNoAliasing = 0, kOnPatch = 1, kNoDelta = 2 }; std::uintptr_t aliasing_ = kNoAliasing; // This variable is used to communicate how the parse ended, in order to // completely verify the parsed data. A wire-format parse can end because of // one of the following conditions: // 1) A parse can end on a pushed limit. // 2) A parse can end on End Of Stream (EOS). // 3) A parse can end on 0 tag (only valid for toplevel message). // 4) A parse can end on an end-group tag. // This variable should always be set to 0, which indicates case 1. If the // parse terminated due to EOS (case 2), it's set to 1. In case the parse // ended due to a terminating tag (case 3 and 4) it's set to (tag - 1). // This var doesn't really belong in EpsCopyInputStream and should be part of // the ParseContext, but case 2 is most easily and optimally implemented in // DoneFallback. uint32 last_tag_minus_1_ = 0; int overall_limit_ = INT_MAX; // Overall limit independent of pushed limits. std::pair<const char*, bool> DoneFallback(const char* ptr, int d); const char* Next(int overrun, int d); const char* SkipFallback(const char* ptr, int size); const char* AppendStringFallback(const char* ptr, int size, std::string* str); const char* ReadStringFallback(const char* ptr, int size, std::string* str); template <typename A> const char* AppendSize(const char* ptr, int size, const A& append) { int chunk_size = buffer_end_ + kSlopBytes - ptr; do { GOOGLE_DCHECK(size > chunk_size); append(ptr, chunk_size); ptr += chunk_size; size -= chunk_size; // DoneFallBack asserts it isn't called when exactly on the limit. If this // happens we fail the parse, as we are at the limit and still more bytes // to read. if (limit_ == kSlopBytes) return nullptr; auto res = DoneFallback(ptr, -1); if (res.second) return nullptr; // If done we passed the limit ptr = res.first; chunk_size = buffer_end_ + kSlopBytes - ptr; } while (size > chunk_size); append(ptr, size); return ptr + size; } // AppendUntilEnd appends data until a limit (either a PushLimit or end of // stream. Normal payloads are from length delimited fields which have an // explicit size. Reading until limit only comes when the string takes // the place of a protobuf, ie RawMessage/StringRawMessage, lazy fields and // implicit weak messages. We keep these methods private and friend them. template <typename A> const char* AppendUntilEnd(const char* ptr, const A& append) { while (!DoneWithCheck(&ptr, -1)) { append(ptr, limit_end_ - ptr); ptr = limit_end_; } return ptr; } PROTOBUF_MUST_USE_RESULT const char* AppendString(const char* ptr, std::string* str) { return AppendUntilEnd( ptr, [str](const char* p, ptrdiff_t s) { str->append(p, s); }); } friend class ImplicitWeakMessage; }; // ParseContext holds all data that is global to the entire parse. Most // importantly it contains the input stream, but also recursion depth and also // stores the end group tag, in case a parser ended on a endgroup, to verify // matching start/end group tags. class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream { public: struct Data { const DescriptorPool* pool = nullptr; MessageFactory* factory = nullptr; }; template <typename... T> ParseContext(int depth, bool aliasing, const char** start, T&&... args) : EpsCopyInputStream(aliasing), depth_(depth) { *start = InitFrom(std::forward<T>(args)...); } void TrackCorrectEnding() { group_depth_ = 0; } bool Done(const char** ptr) { return DoneWithCheck(ptr, group_depth_); } bool DoneNoSlopCheck(const char** ptr) { return DoneWithCheck(ptr, -1); } int depth() const { return depth_; } Data& data() { return data_; } const Data& data() const { return data_; } template <typename T> PROTOBUF_MUST_USE_RESULT PROTOBUF_ALWAYS_INLINE const char* ParseMessage( T* msg, const char* ptr); // We outline when the type is generic and we go through a virtual const char* ParseMessage(MessageLite* msg, const char* ptr); const char* ParseMessage(Message* msg, const char* ptr); template <typename T> PROTOBUF_MUST_USE_RESULT PROTOBUF_ALWAYS_INLINE const char* ParseGroup( T* msg, const char* ptr, uint32 tag) { if (--depth_ < 0) return nullptr; group_depth_++; ptr = msg->_InternalParse(ptr, this); group_depth_--; depth_++; if (PROTOBUF_PREDICT_FALSE(!ConsumeEndGroup(tag))) return nullptr; return ptr; } private: // The context keeps an internal stack to keep track of the recursive // part of the parse state. // Current depth of the active parser, depth counts down. // This is used to limit recursion depth (to prevent overflow on malicious // data), but is also used to index in stack_ to store the current state. int depth_; // Unfortunately necessary for the fringe case of ending on 0 or end-group tag // in the last kSlopBytes of a ZeroCopyInputStream chunk. int group_depth_ = INT_MIN; Data data_; }; template <typename T> T UnalignedLoad(const void* p) { T res; memcpy(&res, p, sizeof(T)); return res; } // TODO(gerbens) Experiment with best implementation. // Clang unrolls loop and generating pretty good code on O2, gcc doesn't. // Unclear if we want 64 bit parse loop unrolled, inlined or opaque function // call. Hence experimentation is needed. // Important guarantee is that it doesn't read more than size bytes from p. template <int size, typename T> PROTOBUF_MUST_USE_RESULT const char* VarintParse(const char* p, T* out) { T res = 1; for (int i = 0; i < size; i++) { T byte = static_cast<uint8>(p[i]); res += (byte - 1) << (i * 7); int j = i + 1; if (PROTOBUF_PREDICT_TRUE(byte < 128)) { *out = res; return p + j; } } *out = 0; return nullptr; } // Decode 2 consecutive bytes of a varint and returns the value, shifted left // by 1. It simultaneous updates *ptr to *ptr + 1 or *ptr + 2 depending if the // first byte's continuation bit is set. // If bit 15 of return value is set (equivalent to the continuation bits of both // bytes being set) the varint continues, otherwise the parse is done. On x86 // movsx eax, dil // add edi, eax // adc [rsi], 1 // add eax, eax // and eax, edi inline uint32 DecodeTwoBytes(uint32 value, const char** ptr) { // Sign extend the low byte continuation bit uint32_t x = static_cast<int8_t>(value); // This add is an amazing operation, it cancels the low byte continuation bit // from y transferring it to the carry. Simultaneously it also shifts the 7 // LSB left by one tightly against high byte varint bits. Hence value now // contains the unpacked value shifted left by 1. value += x; // Use the carry to update the ptr appropriately. *ptr += value < x ? 2 : 1; return value & (x + x); // Mask out the high byte iff no continuation } // Used for tags, could read up to 5 bytes which must be available. // Caller must ensure its safe to call. std::pair<const char*, uint32> ReadTagFallback(const char* p, uint32 res); inline const char* ReadTag(const char* p, uint32* out) { uint32 res = static_cast<uint8>(p[0]); if (res < 128) { *out = res; return p + 1; } uint32 second = static_cast<uint8>(p[1]); res += (second - 1) << 7; if (second < 128) { *out = res; return p + 2; } auto tmp = ReadTagFallback(p + 2, res); *out = tmp.second; return tmp.first; } // Will preload the next 2 bytes inline const char* ReadTag(const char* p, uint32* out, uint32* preload) { uint32 res = static_cast<uint8>(p[0]); if (res < 128) { *out = res; *preload = UnalignedLoad<uint16>(p + 1); return p + 1; } uint32 second = static_cast<uint8>(p[1]); res += (second - 1) << 7; if (second < 128) { *out = res; *preload = UnalignedLoad<uint16>(p + 2); return p + 2; } auto tmp = ReadTagFallback(p + 2, res); *out = tmp.second; return tmp.first; } inline std::pair<const char*, uint64> ParseVarint64FallbackInline(const char* p, uint64 res) { res >>= 1; for (std::uint32_t i = 0; i < 4; i++) { auto pnew = p + 2 * i; auto tmp = DecodeTwoBytes(UnalignedLoad<uint16>(pnew), &pnew); res += (static_cast<std::uint64_t>(tmp) - 2) << (14 * (i + 1) - 1); if (PROTOBUF_PREDICT_TRUE(std::int16_t(tmp) >= 0)) { return {pnew, res}; } } return {nullptr, res}; } inline const char* ParseVarint64Inline(const char* p, uint64* out) { auto tmp = DecodeTwoBytes(UnalignedLoad<uint16>(p), &p); if (PROTOBUF_PREDICT_TRUE(static_cast<int16>(tmp) >= 0)) { *out = tmp >> 1; return p; } auto x = ParseVarint64FallbackInline(p, tmp); *out = x.second; return x.first; } std::pair<const char*, uint64> ParseVarint64Fallback(const char* p, uint64 res); inline const char* ParseVarint64(const char* p, uint32 preload, uint64* out) { auto tmp = DecodeTwoBytes(preload, &p); if (PROTOBUF_PREDICT_TRUE(static_cast<int16>(tmp) >= 0)) { *out = tmp >> 1; return p; } auto x = ParseVarint64Fallback(p, tmp); *out = x.second; return x.first; } // Used for reading varint wiretype values, could read up to 10 bytes. // Caller must ensure its safe to call. inline const char* ParseVarint64(const char* p, uint64* out) { return ParseVarint64(p, UnalignedLoad<uint16>(p), out); } std::pair<const char*, int32> ReadSizeFallback(const char* p, uint32 first); // Used for tags, could read up to 5 bytes which must be available. Additionally // it makes sure the unsigned value fits a int32, otherwise returns nullptr. // Caller must ensure its safe to call. inline uint32 ReadSize(const char** pp) { auto p = *pp; uint32 res = static_cast<uint8>(p[0]); if (res < 128) { *pp = p + 1; return res; } auto x = ReadSizeFallback(p, res); *pp = x.first; return x.second; } // Some convenience functions to simplify the generated parse loop code. // Returning the value and updating the buffer pointer allows for nicer // function composition. We rely on the compiler to inline this. // Also in debug compiles having local scoped variables tend to generated // stack frames that scale as O(num fields). inline uint64 ReadVarint(const char** p) { uint64 tmp; *p = ParseVarint64(*p, &tmp); return tmp; } inline int64 ReadVarintZigZag64(const char** p) { uint64 tmp; *p = ParseVarint64(*p, &tmp); return WireFormatLite::ZigZagDecode64(tmp); } inline int32 ReadVarintZigZag32(const char** p) { uint64 tmp; *p = ParseVarint64(*p, &tmp); return WireFormatLite::ZigZagDecode32(static_cast<uint32>(tmp)); } inline uint64 ReadVarint(const char** p, uint32 preload) { uint64 tmp; *p = ParseVarint64(*p, preload, &tmp); return tmp; } inline int64 ReadVarintZigZag64(const char** p, uint32 preload) { uint64 tmp; *p = ParseVarint64(*p, preload, &tmp); return WireFormatLite::ZigZagDecode64(tmp); } inline int32 ReadVarintZigZag32(const char** p, uint32 preload) { uint64 tmp; *p = ParseVarint64(*p, preload, &tmp); return WireFormatLite::ZigZagDecode32(static_cast<uint32>(tmp)); } template <typename T> PROTOBUF_MUST_USE_RESULT const char* ParseContext::ParseMessage( T* msg, const char* ptr) { int size = ReadSize(&ptr); if (!ptr) return nullptr; auto old = PushLimit(ptr, size); if (--depth_ < 0) return nullptr; ptr = msg->_InternalParse(ptr, this); if (PROTOBUF_PREDICT_FALSE(ptr == nullptr)) return nullptr; depth_++; if (!PopLimit(old)) return nullptr; return ptr; } template <typename Add> const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) { int size = ReadSize(&ptr); if (ptr == nullptr) return nullptr; auto old = PushLimit(ptr, size); if (old < 0) return nullptr; while (!DoneWithCheck(&ptr, -1)) { uint64 varint; ptr = ParseVarint64(ptr, &varint); if (!ptr) return nullptr; add(varint); } if (!PopLimit(old)) return nullptr; return ptr; } // Helper for verification of utf8 PROTOBUF_EXPORT bool VerifyUTF8(StringPiece s, const char* field_name); // All the string parsers with or without UTF checking and for all CTypes. PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* InlineGreedyStringParser( std::string* s, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* InlineGreedyStringParserUTF8(std::string* s, const char* ptr, ParseContext* ctx, const char* field_name); // Inline because we don't want to pay the price of field_name in opt mode. inline PROTOBUF_MUST_USE_RESULT const char* InlineGreedyStringParserUTF8Verify( std::string* s, const char* ptr, ParseContext* ctx, const char* field_name) { auto p = InlineGreedyStringParser(s, ptr, ctx); #ifndef NDEBUG VerifyUTF8(*s, field_name); #endif // !NDEBUG return p; } // Add any of the following lines to debug which parse function is failing. #define GOOGLE_PROTOBUF_ASSERT_RETURN(predicate, ret) \ if (!(predicate)) { \ /* ::raise(SIGINT); */ \ /* GOOGLE_LOG(ERROR) << "Parse failure"; */ \ return ret; \ } #define GOOGLE_PROTOBUF_PARSER_ASSERT(predicate) \ GOOGLE_PROTOBUF_ASSERT_RETURN(predicate, nullptr) template <typename T> PROTOBUF_MUST_USE_RESULT const char* FieldParser(uint64 tag, T& field_parser, const char* ptr, ParseContext* ctx) { uint32 number = tag >> 3; GOOGLE_PROTOBUF_PARSER_ASSERT(number != 0); using WireType = internal::WireFormatLite::WireType; switch (tag & 7) { case WireType::WIRETYPE_VARINT: { uint64 value; ptr = ParseVarint64(ptr, &value); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); field_parser.AddVarint(number, value); break; } case WireType::WIRETYPE_FIXED64: { uint64 value = UnalignedLoad<uint64>(ptr); ptr += 8; field_parser.AddFixed64(number, value); break; } case WireType::WIRETYPE_LENGTH_DELIMITED: { ptr = field_parser.ParseLengthDelimited(number, ptr, ctx); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); break; } case WireType::WIRETYPE_START_GROUP: { ptr = field_parser.ParseGroup(number, ptr, ctx); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); break; } case WireType::WIRETYPE_END_GROUP: { GOOGLE_LOG(FATAL) << "Can't happen"; break; } case WireType::WIRETYPE_FIXED32: { uint32 value = UnalignedLoad<uint32>(ptr); ptr += 4; field_parser.AddFixed32(number, value); break; } default: return nullptr; } return ptr; } template <typename T> PROTOBUF_MUST_USE_RESULT const char* WireFormatParser(T& field_parser, const char* ptr, ParseContext* ctx) { while (!ctx->Done(&ptr)) { uint32 tag; ptr = ReadTag(ptr, &tag); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr); if (tag == 0 || (tag & 7) == 4) { ctx->SetLastTag(tag); return ptr; } ptr = FieldParser(tag, field_parser, ptr, ctx); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr); } return ptr; } // The packed parsers parse repeated numeric primitives directly into the // corresponding field // These are packed varints PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedInt32Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedUInt32Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedInt64Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedUInt64Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedSInt32Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedSInt64Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParser( void* object, const char* ptr, ParseContext* ctx, bool (*is_valid)(int), std::string* unknown, int field_num); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedEnumParserArg( void* object, const char* ptr, ParseContext* ctx, bool (*is_valid)(const void*, int), const void* data, std::string* unknown, int field_num); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedBoolParser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedFixed32Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedSFixed32Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedFixed64Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedSFixed64Parser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedFloatParser( void* object, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* PackedDoubleParser( void* object, const char* ptr, ParseContext* ctx); // This is the only recursive parser. PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* UnknownGroupLiteParse( std::string* unknown, const char* ptr, ParseContext* ctx); // This is a helper to for the UnknownGroupLiteParse but is actually also // useful in the generated code. It uses overload on std::string* vs // UnknownFieldSet* to make the generated code isomorphic between full and lite. PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* UnknownFieldParse( uint32 tag, std::string* unknown, const char* ptr, ParseContext* ctx); PROTOBUF_EXPORT PROTOBUF_MUST_USE_RESULT const char* UnknownFieldParse( uint32 tag, InternalMetadataWithArenaLite* metadata, const char* ptr, ParseContext* ctx); } // namespace internal } // namespace protobuf } // namespace google #include <google/protobuf/port_undef.inc> #endif // GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
45a7e621da7f3bac42bf7f5ea9c79f306c620ff3
ade480c9aa88dd0aed3c87087e0d3364393851d8
/term_paper/build-Term_paper-Desktop_Qt_5_10_1_MinGW_32bit-Release/App/release/moc_textedit.cpp
0926b5c5d7fc28b6fa593d1de60cf65377a12b0e
[]
no_license
46ccac1474d000676430445ffc4b160a/Algo
97f49ff7eaf53e933ca4f16c76459de986f55441
01fbc4e1e8dc24358f29cd220a1843b18e26aa42
refs/heads/master
2020-03-19T05:18:36.090372
2018-06-30T09:27:59
2018-06-30T09:27:59
124,790,880
0
0
null
null
null
null
UTF-8
C++
false
false
7,338
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'textedit.hpp' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.10.1) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../Term_paper/App/TextEdit/textedit.hpp" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'textedit.hpp' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.10.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_TextEdit_t { QByteArrayData data[12]; char stringdata0[113]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_TextEdit_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_TextEdit_t qt_meta_stringdata_TextEdit = { { QT_MOC_LITERAL(0, 0, 8), // "TextEdit" QT_MOC_LITERAL(1, 9, 15), // "fileNameChanged" QT_MOC_LITERAL(2, 25, 0), // "" QT_MOC_LITERAL(3, 26, 8), // "fileName" QT_MOC_LITERAL(4, 35, 18), // "on_callSuggestions" QT_MOC_LITERAL(5, 54, 1), // "n" QT_MOC_LITERAL(6, 56, 20), // "on_textCursorChanged" QT_MOC_LITERAL(7, 77, 4), // "open" QT_MOC_LITERAL(8, 82, 4), // "file" QT_MOC_LITERAL(9, 87, 4), // "save" QT_MOC_LITERAL(10, 92, 8), // "filename" QT_MOC_LITERAL(11, 101, 11) // "setFileName" }, "TextEdit\0fileNameChanged\0\0fileName\0" "on_callSuggestions\0n\0on_textCursorChanged\0" "open\0file\0save\0filename\0setFileName" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_TextEdit[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 7, 14, // methods 1, 66, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 1, // signalCount // signals: name, argc, parameters, tag, flags 1, 1, 49, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags 4, 1, 52, 2, 0x08 /* Private */, 4, 0, 55, 2, 0x28 /* Private | MethodCloned */, 6, 0, 56, 2, 0x08 /* Private */, 7, 1, 57, 2, 0x0a /* Public */, 9, 1, 60, 2, 0x0a /* Public */, 11, 1, 63, 2, 0x0a /* Public */, // signals: parameters QMetaType::Void, QMetaType::QString, 3, // slots: parameters QMetaType::Void, QMetaType::Int, 5, QMetaType::Void, QMetaType::Void, QMetaType::Bool, QMetaType::QString, 8, QMetaType::Bool, QMetaType::QString, 10, QMetaType::Void, QMetaType::QString, 3, // properties: name, type, flags 3, QMetaType::QString, 0x00495103, // properties: notify_signal_id 0, 0 // eod }; void TextEdit::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { TextEdit *_t = static_cast<TextEdit *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->fileNameChanged((*reinterpret_cast< QString(*)>(_a[1]))); break; case 1: _t->on_callSuggestions((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: _t->on_callSuggestions(); break; case 3: _t->on_textCursorChanged(); break; case 4: { bool _r = _t->open((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = std::move(_r); } break; case 5: { bool _r = _t->save((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = std::move(_r); } break; case 6: _t->setFileName((*reinterpret_cast< const QString(*)>(_a[1]))); break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast<int *>(_a[0]); { typedef void (TextEdit::*_t)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TextEdit::fileNameChanged)) { *result = 0; return; } } } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { TextEdit *_t = static_cast<TextEdit *>(_o); Q_UNUSED(_t) void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = _t->fileName(); break; default: break; } } else if (_c == QMetaObject::WriteProperty) { TextEdit *_t = static_cast<TextEdit *>(_o); Q_UNUSED(_t) void *_v = _a[0]; switch (_id) { case 0: _t->setFileName(*reinterpret_cast< QString*>(_v)); break; default: break; } } else if (_c == QMetaObject::ResetProperty) { } #endif // QT_NO_PROPERTIES } QT_INIT_METAOBJECT const QMetaObject TextEdit::staticMetaObject = { { &QTextEdit::staticMetaObject, qt_meta_stringdata_TextEdit.data, qt_meta_data_TextEdit, qt_static_metacall, nullptr, nullptr} }; const QMetaObject *TextEdit::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *TextEdit::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_TextEdit.stringdata0)) return static_cast<void*>(this); return QTextEdit::qt_metacast(_clname); } int TextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QTextEdit::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 7) qt_static_metacall(this, _c, _id, _a); _id -= 7; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 7) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 7; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty || _c == QMetaObject::ResetProperty || _c == QMetaObject::RegisterPropertyMetaType) { qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; } // SIGNAL 0 void TextEdit::fileNameChanged(QString _t1) { void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 0, _a); } QT_WARNING_POP QT_END_MOC_NAMESPACE
e21c7f2934c5ca4139b62565b9143244e1e9373f
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/admin/controls/smonctrl/appearprop.cpp
2f81a9b369cf98dc8c64e70e73dfc6f1c667dd58
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,099
cpp
/*++ Copyright (C) 1996-1999 Microsoft Corporation Module Name: srcprop.cpp Abstract: Implementation of the Appearance property page. --*/ #include <windows.h> #include <stdio.h> #include <assert.h> #include "polyline.h" #include "appearprop.h" #include "utils.h" #include <pdhmsg.h> #include "smonmsg.h" #include "strids.h" #include "unihelpr.h" #include "winhelpr.h" #include <Commdlg.h> COLORREF CustomColors[16]; CAppearPropPage::CAppearPropPage() { m_uIDDialog = IDD_APPEAR_PROPP_DLG; m_uIDTitle = IDS_APPEAR_PROPP_TITLE; } CAppearPropPage::~CAppearPropPage( void ) { return; } BOOL CAppearPropPage::InitControls ( void ) { BOOL bResult = TRUE; HWND hWnd; for (int i=0; i<16; i++){ CustomColors[i]=RGB(255, 255, 255); } hWnd = GetDlgItem( m_hDlg, IDC_COLOROBJECTS ); if( NULL != hWnd ){ CBInsert( hWnd, GraphColor, ResourceString(IDS_COLORCHOICE_GRAPH) ); CBInsert( hWnd, ControlColor, ResourceString(IDS_COLORCHOICE_CONTROL) ); CBInsert( hWnd, TextColor, ResourceString(IDS_COLORCHOICE_TEXT) ); CBInsert( hWnd, GridColor, ResourceString(IDS_COLORCHOICE_GRID) ); CBInsert( hWnd, TimebarColor, ResourceString(IDS_COLORCHOICE_TIMEBAR) ); CBSetSelection( hWnd, 0 ); } return bResult; } void CAppearPropPage::ColorizeButton() { HBRUSH hbr; RECT rect; int shift = 3; HWND hWnd; hWnd = GetDlgItem( m_hDlg, IDC_COLOROBJECTS ); if( hWnd != NULL ){ ColorChoices sel = (ColorChoices)CBSelection( hWnd ); COLORREF color = (COLORREF)CBData( hWnd, sel ); HWND hDlg = GetDlgItem( m_hDlg, IDC_COLORSAMPLE ); if( hDlg != NULL ){ HDC hDC = GetWindowDC( hDlg ); if( hDC != NULL ){ hbr = CreateSolidBrush( color ); GetClientRect( hDlg, &rect ); rect.top += shift; rect.bottom += shift; rect.left += shift; rect.right += shift; if ( NULL != hbr ) { FillRect(hDC, (LPRECT)&rect, hbr); } ReleaseDC( hDlg, hDC ); } } } } void CAppearPropPage::SampleFont() { HFONT hFont; HWND hSample = GetDlgItem( m_hDlg, IDC_FONTSAMPLE ); if( hSample != NULL ){ hFont = CreateFontIndirect( &m_Font ); if( hFont != NULL ){ SendMessage( hSample, WM_SETFONT, (WPARAM)hFont, (LPARAM)TRUE ); } } } BOOL CAppearPropPage::WndProc( UINT uMsg, WPARAM /* wParam */, LPARAM /* lParam */) { if( uMsg == WM_CTLCOLORBTN ){ ColorizeButton(); return TRUE; } return FALSE; } /* * CAppearPropPage::GetProperties * */ BOOL CAppearPropPage::GetProperties(void) { BOOL bReturn = TRUE; ISystemMonitor *pObj; CImpISystemMonitor *pPrivObj; IFontDisp* pFontDisp; LPFONT pIFont; HFONT hFont; HRESULT hr; HWND hWnd; if (m_cObjects == 0) { bReturn = FALSE; } else { pObj = m_ppISysmon[0]; // Get pointer to actual object for internal methods pPrivObj = (CImpISystemMonitor*)pObj; pPrivObj->get_Font( &pFontDisp ); if ( NULL == pFontDisp ) { bReturn = FALSE; } else { hr = pFontDisp->QueryInterface(IID_IFont, (PPVOID)&pIFont); if (SUCCEEDED(hr)) { pIFont->get_hFont( &hFont ); GetObject( hFont, sizeof(LOGFONT), &m_Font ); pIFont->Release(); } SampleFont(); } hWnd = GetDlgItem( m_hDlg, IDC_COLOROBJECTS ); if( hWnd != NULL ){ OLE_COLOR color; pPrivObj->get_BackColor( &color ); CBSetData( hWnd, GraphColor, color ); pPrivObj->get_BackColorCtl( &color ); CBSetData( hWnd, ControlColor, color ); pPrivObj->get_ForeColor( &color ); CBSetData( hWnd, TextColor, color ); pPrivObj->get_GridColor( &color ); CBSetData( hWnd, GridColor, color ); pPrivObj->get_TimeBarColor( &color ); CBSetData( hWnd, TimebarColor, color ); ColorizeButton(); } } return bReturn; } /* * CAppearPropPage::SetProperties * */ BOOL CAppearPropPage::SetProperties(void) { BOOL bReturn = TRUE; IFontDisp* pFontDisp; ISystemMonitor *pObj; CImpISystemMonitor *pPrivObj; if (m_cObjects == 0) { bReturn = FALSE; } else { FONTDESC fd; pObj = m_ppISysmon[0]; pPrivObj = (CImpISystemMonitor*)pObj; fd.cbSizeofstruct = sizeof(FONTDESC); fd.lpstrName = m_Font.lfFaceName; fd.sWeight = (short)m_Font.lfWeight; fd.sCharset = m_Font.lfCharSet; fd.fItalic = m_Font.lfItalic; fd.fUnderline = m_Font.lfUnderline; fd.fStrikethrough = m_Font.lfStrikeOut; long lfHeight = m_Font.lfHeight; int ppi; HDC hdc; if (lfHeight < 0){ lfHeight = -lfHeight; } hdc = ::GetDC(GetDesktopWindow()); ppi = GetDeviceCaps(hdc, LOGPIXELSY); ::ReleaseDC(GetDesktopWindow(), hdc); fd.cySize.Lo = lfHeight * 720000 / ppi; fd.cySize.Hi = 0; OleCreateFontIndirect(&fd, IID_IFontDisp, (void**) &pFontDisp); pPrivObj->putref_Font( pFontDisp ); pFontDisp->Release(); HWND hWnd = GetDlgItem( m_hDlg, IDC_COLOROBJECTS ); if( hWnd != NULL ){ OLE_COLOR color; color = (OLE_COLOR)CBData( hWnd, GraphColor ); pPrivObj->put_BackColor( color ); color = (OLE_COLOR)CBData( hWnd, ControlColor ); pPrivObj->put_BackColorCtl( color ); color = (OLE_COLOR)CBData( hWnd, TextColor ); pPrivObj->put_ForeColor( color ); color = (OLE_COLOR)CBData( hWnd, GridColor ); pPrivObj->put_GridColor( color ); color = (OLE_COLOR)CBData( hWnd, TimebarColor ); pPrivObj->put_TimeBarColor( color ); } } return bReturn; } void CAppearPropPage::DialogItemChange( WORD wID, WORD /* wMsg */) { BOOL bChanged = FALSE; switch(wID) { case IDC_COLOROBJECTS: ColorizeButton(); break; case IDC_COLORSAMPLE: case IDC_COLORBUTTON: { CHOOSECOLOR cc; OLE_COLOR color; HWND hWnd = GetDlgItem( m_hDlg, IDC_COLOROBJECTS ); if( NULL != hWnd ){ ColorChoices sel = (ColorChoices)CBSelection( hWnd ); color = (COLORREF)CBData( hWnd, sel ); memset(&cc, 0, sizeof(CHOOSECOLOR)); cc.lStructSize=sizeof(CHOOSECOLOR); cc.lpCustColors=CustomColors; cc.hwndOwner = m_hDlg; cc.Flags=CC_RGBINIT; cc.rgbResult = color; if( ChooseColor(&cc) ){ CBSetData( hWnd, sel, cc.rgbResult ); ColorizeButton(); bChanged = TRUE; } } break; } case IDC_FONTBUTTON: case IDC_FONTSAMPLE: { CHOOSEFONT cf; LOGFONT lf; memset(&cf, 0, sizeof(CHOOSEFONT)); memcpy( &lf, &m_Font, sizeof(LOGFONT) ); cf.lStructSize = sizeof(CHOOSEFONT); cf.hwndOwner = m_hDlg; cf.lpLogFont = &lf; // give initial font cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_FORCEFONTEXIST | CF_SCREENFONTS; cf.nSizeMin = 5; cf.nSizeMax = 50; if( ChooseFont(&cf) ){ memcpy( &m_Font, &lf, sizeof(LOGFONT) ); SampleFont(); bChanged = TRUE; } break; } } if( bChanged == TRUE ){ SetChange(); } }
3478a01a702a9be63f6685f6e9dd363365ec56e2
5092733b09fdf1d0e15ad84a44dbc3ecc247e4fe
/muxer.cpp
26dbfe04f7d09fa36c2bddecd50f7d812f7a4aac
[]
no_license
linuxmap/VisualizerQml
1264d5fa1819bc5351c082e50d44a4eb80595913
6fd586eee0bd5867c8b0470cd253b9dc914d005a
refs/heads/master
2020-03-06T18:07:48.857693
2018-03-27T14:41:22
2018-03-27T14:41:22
127,000,811
3
2
null
null
null
null
UTF-8
C++
false
false
3,930
cpp
#include "muxer.h" muxer::muxer(QObject * parent) : QObject(parent) { } muxer::~muxer() { } bool muxer::startMux(const char *filename) { int have_video = 0, have_audio = 0; int encode_video = 0, encode_audio = 0; av_register_all(); avformat_alloc_output_context2(&m_pOCtx, NULL, NULL, filename); if (!m_pOCtx) { printf("Could not deduce output format from file extension: using MPEG.\n"); avformat_alloc_output_context2(&m_pOCtx, NULL, "mpeg", filename); return false; } m_pFormat = m_pOCtx->oformat; /* Add the audio and video streams using the default format codecs * and initialize the codecs. */ if (m_pFormat->video_codec != AV_CODEC_ID_NONE) { add_stream(&video_st, m_pOCtx, &video_codec, m_pFormat->video_codec); have_video = 1; encode_video = 1; } if (m_pFormat->audio_codec != AV_CODEC_ID_NONE) { add_stream(&audio_st, m_pOCtx, &audio_codec, m_pFormat->audio_codec); have_audio = 1; encode_audio = 1; } return true; } void muxer::add_stream(OutputStream *ost, AVFormatContext *oc, AVCodec **codec, enum AVCodecID codec_id) { AVCodecContext *c; int i; /* find the encoder */ *codec = avcodec_find_encoder(codec_id); if (!(*codec)) { fprintf(stderr, "Could not find encoder for '%s'\n", avcodec_get_name(codec_id)); exit(1); } ost->st = avformat_new_stream(oc, NULL); if (!ost->st) { fprintf(stderr, "Could not allocate stream\n"); exit(1); } ost->st->id = oc->nb_streams - 1; c = avcodec_alloc_context3(*codec); if (!c) { fprintf(stderr, "Could not alloc an encoding context\n"); exit(1); } ost->enc = c; switch ((*codec)->type) { case AVMEDIA_TYPE_AUDIO: c->sample_fmt = (*codec)->sample_fmts ? (*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP; c->bit_rate = 64000; c->sample_rate = 44100; if ((*codec)->supported_samplerates) { c->sample_rate = (*codec)->supported_samplerates[0]; for (i = 0; (*codec)->supported_samplerates[i]; i++) { if ((*codec)->supported_samplerates[i] == 44100) c->sample_rate = 44100; } } c->channels = av_get_channel_layout_nb_channels(c->channel_layout); c->channel_layout = AV_CH_LAYOUT_STEREO; if ((*codec)->channel_layouts) { c->channel_layout = (*codec)->channel_layouts[0]; for (i = 0; (*codec)->channel_layouts[i]; i++) { if ((*codec)->channel_layouts[i] == AV_CH_LAYOUT_STEREO) c->channel_layout = AV_CH_LAYOUT_STEREO; } } c->channels = av_get_channel_layout_nb_channels(c->channel_layout); ost->st->time_base.num = 1; ost->st->time_base.den = c->sample_rate; //ost->st->time_base = (AVRational) { 1, c->sample_rate }; break; case AVMEDIA_TYPE_VIDEO: c->codec_id = codec_id; c->bit_rate = 400000; /* Resolution must be a multiple of two. */ c->width = 352; c->height = 288; /* timebase: This is the fundamental unit of time (in seconds) in terms * of which frame timestamps are represented. For fixed-fps content, * timebase should be 1/framerate and timestamp increments should be * identical to 1. */ //ost->st->time_base = (AVRational) { 1, STREAM_FRAME_RATE }; ost->st->time_base.num = 1; ost->st->time_base.den = STREAM_FRAME_RATE; c->time_base = ost->st->time_base; c->gop_size = 12; /* emit one intra frame every twelve frames at most */ c->pix_fmt = STREAM_PIX_FMT; if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) { /* just for testing, we also add B-frames */ c->max_b_frames = 2; } if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) { /* Needed to avoid using macroblocks in which some coeffs overflow. * This does not happen with normal video, it just happens here as * the motion of the chroma plane does not match the luma plane. */ c->mb_decision = 2; } break; default: break; } /* Some formats want stream headers to be separate. */ if (oc->oformat->flags & AVFMT_GLOBALHEADER) c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; }
a1be7e60b8c95ce9275d15192291591c5fae8258
a85c2066a3d5de26b95a23ae5b719fbdf74be145
/atcoder/abc115/c.cpp
f7539d993adfc72cbb79cabae0e6485a5cd1b768
[]
no_license
stqp/algorithm
fcebef84d2eeccfd9f0261b2ca74a0a5f1766f8e
03802b8dae14fd2da7e2715f29c23385094938b4
refs/heads/master
2023-04-05T15:21:37.388939
2023-03-30T04:39:57
2023-03-30T04:39:57
141,453,915
0
0
null
null
null
null
UTF-8
C++
false
false
244
cpp
#include <iostream> #include <fstream> #include <string> #include <algorithm> #include <vector> #include <list> #include <math.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int n;cin>>n; int k;cin>>k; }
8241832e15ce0f0ae407d71d42066a4fa5adf53c
39b1499479b9e876442b9e80f89c6990bd54b3e5
/ESP32-CAM_Firebase/ESP32-CAM_Firebase.ino
d3f072134f4fe68ec56dcc55c4e5df8244689585
[]
no_license
tranthanh1699/Arduino_IoT
eee960bdebe8a6368b9b301264325aa6296f25de
95e4e7715a30b8d8919db20d22a43c8c1d62ea7c
refs/heads/master
2023-04-16T05:49:19.768890
2021-04-04T16:10:35
2021-04-04T16:10:35
353,409,352
0
0
null
null
null
null
UTF-8
C++
false
false
5,744
ino
/* ESP32-CAM Save a captured photo(Base64) to firebase. Author : ChungYi Fu (Kaohsiung, Taiwan) 2019-8-16 23:00 https://www.facebook.com/francefu Arduino IDE Library Firebase ESP32 Client by Mobizt version 3.2.1 ESP32-CAM How to save a captured photo to Firebase https://youtu.be/Hx7bdpev1ug How to set up Firebase https://iotdesignpro.com/projects/iot-controlled-led-using-firebase-database-and-esp32 */ const char* ssid = "xxxxxxxxxx"; const char* password = "xxxxxxxxxx"; //https://console.firebase.google.com/project/xxxxxxxxxx/settings/serviceaccounts/databasesecrets String FIREBASE_HOST = "xxxxxxxxxx.firebaseio.com"; String FIREBASE_AUTH = "xxxxxxxxxxxxxxxxxxxx"; #include "FirebaseESP32.h" FirebaseData firebaseData; #include <WiFi.h> #include "soc/soc.h" #include "soc/rtc_cntl_reg.h" #include "Base64.h" #include "esp_camera.h" // WARNING!!! Make sure that you have either selected ESP32 Wrover Module, // or another board which has PSRAM enabled //CAMERA_MODEL_AI_THINKER #define PWDN_GPIO_NUM 32 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM 0 #define SIOD_GPIO_NUM 26 #define SIOC_GPIO_NUM 27 #define Y9_GPIO_NUM 35 #define Y8_GPIO_NUM 34 #define Y7_GPIO_NUM 39 #define Y6_GPIO_NUM 36 #define Y5_GPIO_NUM 21 #define Y4_GPIO_NUM 19 #define Y3_GPIO_NUM 18 #define Y2_GPIO_NUM 5 #define VSYNC_GPIO_NUM 25 #define HREF_GPIO_NUM 23 #define PCLK_GPIO_NUM 22 void setup() { WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); Serial.begin(115200); Serial.setDebugOutput(true); Serial.println(); Serial.println("ssid: " + (String)ssid); Serial.println("password: " + (String)password); WiFi.begin(ssid, password); long int StartTime=millis(); while (WiFi.status() != WL_CONNECTED) { delay(500); if ((StartTime+10000) < millis()) break; } if (WiFi.status() == WL_CONNECTED) { char* apssid = "ESP32-CAM"; char* appassword = "12345678"; //AP password require at least 8 characters. Serial.println(""); Serial.print("Camera Ready! Use 'http://"); Serial.print(WiFi.localIP()); Serial.println("' to connect"); WiFi.softAP((WiFi.localIP().toString()+"_"+(String)apssid).c_str(), appassword); } else { Serial.println("Connection failed"); return; } camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = Y2_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000; config.pixel_format = PIXFORMAT_JPEG; //init with high specs to pre-allocate larger buffers if(psramFound()){ config.frame_size = FRAMESIZE_UXGA; config.jpeg_quality = 10; //0-63 lower number means higher quality config.fb_count = 2; } else { config.frame_size = FRAMESIZE_SVGA; config.jpeg_quality = 12; //0-63 lower number means higher quality config.fb_count = 1; } // camera init esp_err_t err = esp_camera_init(&config); if (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err); delay(1000); ESP.restart(); } //drop down frame size for higher initial frame rate sensor_t * s = esp_camera_sensor_get(); s->set_framesize(s, FRAMESIZE_QQVGA); // VGA|CIF|QVGA|HQVGA|QQVGA ( UXGA? SXGA? XGA? SVGA? ) Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); Firebase.reconnectWiFi(true); Firebase.setMaxRetry(firebaseData, 3); Firebase.setMaxErrorQueue(firebaseData, 30); Firebase.enableClassicRequest(firebaseData, true); String jsonData = "{\"photo\":\"" + Photo2Base64() + "\"}"; String photoPath = "/esp32-cam"; if (Firebase.pushJSON(firebaseData, photoPath, jsonData)) { Serial.println(firebaseData.dataPath()); Serial.println(firebaseData.pushName()); Serial.println(firebaseData.dataPath() + "/"+ firebaseData.pushName()); } else { Serial.println(firebaseData.errorReason()); } } void loop() { delay(10000); } String Photo2Base64() { camera_fb_t * fb = NULL; fb = esp_camera_fb_get(); if(!fb) { Serial.println("Camera capture failed"); return ""; } String imageFile = "data:image/jpeg;base64,"; char *input = (char *)fb->buf; char output[base64_enc_len(3)]; for (int i=0;i<fb->len;i++) { base64_encode(output, (input++), 3); if (i%3==0) imageFile += urlencode(String(output)); } esp_camera_fb_return(fb); return imageFile; } //https://github.com/zenmanenergy/ESP8266-Arduino-Examples/ String urlencode(String str) { String encodedString=""; char c; char code0; char code1; char code2; for (int i =0; i < str.length(); i++){ c=str.charAt(i); if (c == ' '){ encodedString+= '+'; } else if (isalnum(c)){ encodedString+=c; } else{ code1=(c & 0xf)+'0'; if ((c & 0xf) >9){ code1=(c & 0xf) - 10 + 'A'; } c=(c>>4)&0xf; code0=c+'0'; if (c > 9){ code0=c - 10 + 'A'; } code2='\0'; encodedString+='%'; encodedString+=code0; encodedString+=code1; //encodedString+=code2; } yield(); } return encodedString; }
87a7fab328a6596e7fa786581e810d2586fb75c2
5b2504f42c2bcbffcfae00bde549be74c9e62a60
/vb_simulation_pkgs/hrwros_gazebo/include/hrwros_gazebo/urdf_creator.h
138fe310a4f93df930a5b3719cb882ab24227281
[ "MIT" ]
permissive
ROBODITYA/Eyantra-2021-Vargi-Bots
0996937b48b6ac61a90f55fb8a405c026aa83ce8
f1c6a82c46e6e84486a4832b3fbcd02625849447
refs/heads/main
2023-05-11T17:39:10.012824
2021-06-03T12:53:48
2021-06-03T12:53:48
369,171,672
0
0
MIT
2021-06-05T07:58:07
2021-05-20T10:38:28
C++
UTF-8
C++
false
false
3,948
h
#ifndef GILBRETH_GAZEBO_URDF_CREATOR_H #define GILBRETH_GAZEBO_URDF_CREATOR_H #include <tinyxml.h> namespace hrwros { namespace simulation { struct InertiaTag { InertiaTag(const std::string& ixx = "1", const std::string& iyy = "1", const std::string& izz = "1", const std::string& ixy = "0", const std::string& iyz = "0", const std::string& ixz = "0") : self(new TiXmlElement ("inertia")) { self->SetAttribute("ixx", ixx); self->SetAttribute("iyy", iyy); self->SetAttribute("izz", izz); self->SetAttribute("ixy", ixy); self->SetAttribute("iyz", iyz); self->SetAttribute("ixz", ixz); } TiXmlElement* self; }; struct OriginTag { OriginTag(const std::string& xyz = "0 0 0", const std::string& rpy = "0 0 0") : self(new TiXmlElement ("origin")) { self->SetAttribute("xyz", xyz); self->SetAttribute("rpy", rpy); } TiXmlElement* self; }; struct GeometryTag { GeometryTag(const std::string& mesh_filename) : self(new TiXmlElement ("geometry")) , mesh(new TiXmlElement ("mesh")) { mesh->SetAttribute("filename", mesh_filename); self->LinkEndChild(mesh); } TiXmlElement* self; TiXmlElement* mesh; }; struct MaterialTag { MaterialTag(const std::string& color_name = "medium_gray", const std::string& color_string = "0.5 0.5 0.5 1.0") : self(new TiXmlElement ("material")) , color(new TiXmlElement ("color")) { color->SetAttribute("rgba", color_string); self->SetAttribute("name", color_name); self->LinkEndChild(color); } MaterialTag(const std::string& color_name) : self(new TiXmlElement ("material")) { self->SetAttribute("name", color_name); } TiXmlElement* self; TiXmlElement* color; }; struct VisualTag { VisualTag(const GeometryTag& geometry_tag, const MaterialTag& material_tag = MaterialTag(), const OriginTag& origin_tag = OriginTag()) : self(new TiXmlElement ("visual")) { self->LinkEndChild(origin_tag.self); self->LinkEndChild(geometry_tag.self); self->LinkEndChild(material_tag.self); } TiXmlElement* self; }; struct CollisionTag { CollisionTag(const GeometryTag& geometry_tag, const MaterialTag& material_tag = MaterialTag(), const OriginTag& origin_tag = OriginTag()) : self(new TiXmlElement ("collision")) { self->LinkEndChild(origin_tag.self); self->LinkEndChild(geometry_tag.self); self->LinkEndChild(material_tag.self); } TiXmlElement* self; }; struct InertialTag { InertialTag(const std::string& mass_value = "0.2", const InertiaTag& inertia_tag = InertiaTag(), const OriginTag& origin_tag = OriginTag()) : self(new TiXmlElement ("inertial")) , mass(new TiXmlElement ("mass")) { mass->SetAttribute("value", mass_value); self->LinkEndChild(mass); self->LinkEndChild(inertia_tag.self); self->LinkEndChild(origin_tag.self); } TiXmlElement* self; TiXmlElement* mass; }; struct RobotTag { RobotTag(const std::string& name, const VisualTag& visual_tag, const CollisionTag& collision_tag, const InertialTag& inertial_tag = InertialTag()) : self(new TiXmlElement ("robot")) , link(new TiXmlElement ("link")) { self->SetAttribute("name", name); self->SetAttribute("xmlns:xacro", "https://www.ros.org/wiki/xacro"); link->SetAttribute("name", name + "_base_link"); link->LinkEndChild(visual_tag.self); link->LinkEndChild(collision_tag.self); link->LinkEndChild(inertial_tag.self); self->LinkEndChild(link); } TiXmlElement* self; TiXmlElement* link; }; std::string createObjectURDF(const std::string& object_name, const std::string& mesh_filename); } // namespace simulation } // namespace hrwros #endif // GILBRETH_GAZEBO_URDF_CREATOR_H
20a0aff83b8eaf1da60b2586519663c0b4f308e5
f20e965e19b749e84281cb35baea6787f815f777
/Online/Online/MooreStandalone/src/MooreMainMenu.cpp
1c4abde40ef9f6859101fceaa9f449f3c3ff9fb2
[]
no_license
marromlam/lhcb-software
f677abc9c6a27aa82a9b68c062eab587e6883906
f3a80ecab090d9ec1b33e12b987d3d743884dc24
refs/heads/master
2020-12-23T15:26:01.606128
2016-04-08T15:48:59
2016-04-08T15:48:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,341
cpp
// $Id: EventServerRunable.h,v 1.7 2008-10-14 08:37:21 frankb Exp $ //==================================================================== // MooreTestSvc //-------------------------------------------------------------------- // // Description: GUI to run Moore standalone on a single node. // Author : M.Frank //==================================================================== // $Header: $ #include "RTL/rtl.h" #include "CPP/Event.h" #include "CPP/IocSensor.h" #include "CPP/TimeSensor.h" #include "UPI/upi_menu.h" #include "UPI/UpiSensor.h" #include "UPI/UpiDisplay.h" #include "MBM/Monitor.h" #include "MooreMainMenu.h" #include "UpiMooreMonitor.h" #include "Internals.h" #include "GaudiKernel/SmartIF.h" #include "GaudiKernel/IService.h" #include "GaudiKernel/Bootstrap.h" #include "GaudiKernel/IAppMgrUI.h" #include "GaudiKernel/IProperty.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Property.h" #include <cstdlib> extern "C" void scrc_resetANSI(); using namespace LHCb; using namespace std; static MooreMainMenu* s_mainMenu = 0; enum Commands { CMD_BACKSPACE = -1, CMD_MBMMON_CLOSE = UPI::UpiDisplay::CMD_CLOSE, COMMENT_CONTEXT = 200000, COMMENT0, COM_RESULT, CMD_PAR_RESULT, COM_LOG, CMD_PAR_LOG, COM_OPTS, CMD_PAR_OPTS, COM_OPT_LINE, CMD_MBMMON, CMD_EVTMON, CMD_RATEMON, CMD_ALLMON, COM_START_LINE, CMD_START, CMD_STOP, CMD_STOP_CLOSE, CMD_ENABLE, CMD_TERMINATE, CMD_REFEED, CMD_CLEAN_STRING, CMD_WRITE_MESSAGE, CMD_EXIT = MooreTest::CMD_MOORE_EXIT, CMD_REFRESH, CMD_LAST_OF_MENU }; namespace LHCb { /** class MessageLogger Small helper class to catch output of a running Gaudi task @author M.Frank @version 1.0 */ class MessageLogger : public std::streambuf { public: /// Standard Constructor MessageLogger (Interactor* iface); /// Standard destructor ~MessageLogger (); /// Callback to fill stream buffer int overflow (int c); /// Callback indicating EOF int underflow (); private: /// Save old stream buffer std::streambuf* _old; /// String currently beeing assembled std::string _buf; /// Connection to java environment Interactor* _writer; }; /// Standard Constructor MessageLogger::MessageLogger (Interactor* iface) : _buf(""), _writer(iface) { _old = std::cout.rdbuf (this); } /// Standard Destructor MessageLogger::~MessageLogger () { std::cout.rdbuf(_old); } /// Callback when filling the stream buffer int MessageLogger::overflow (int c) { if (c == '\n') { IocSensor::instance().send(_writer,CMD_WRITE_MESSAGE,strdup(_buf.c_str())); _buf = ""; return c; } _buf += c; return c; } /// Callback on EOF int MessageLogger::underflow () { return (EOF); } } static void clean_str(char* n,size_t len) { n[len-1] = 0; if ( ::strchr(n,' ') ) *::strchr(n,' ') = 0; } static char* string_copy(char* to, const char* from, size_t len) { char* c = ::strncpy(to,from,len); to[len-1] = 0; return c; } MooreMainMenu::MooreMainMenu(const string& opts) : Interactor(), m_exec(0), m_id(0), m_log(0), m_mbmMon(0), m_evtMon(0), m_rateMon(0), m_allMon(0), m_svcLocator(0), m_terminate(false) { char cwd[PATH_MAX]; m_id = UpiSensor::newID(); m_ioc = &IocSensor::instance(); m_logger = new MessageLogger(this); string_copy(m_resFile,"MooreTest.txt",sizeof(m_resFile)); string_copy(m_logFile,"MooreTest.log",sizeof(m_logFile)); string_copy(m_myOpts,opts.c_str(),sizeof(m_myOpts)); ::upic_open_menu(m_id,0,0,"MooreTest","Standalone","MooreTest"); ::upic_declare_callback(m_id,CALL_ON_BACK_SPACE,(Routine)backSpaceCallBack,this); //::upic_add_comment(COM_RESULT, "Test Result file name:",""); //::upic_set_param(m_resFile,1,"A30",m_resFile,0,0,0,0,0); //::upic_add_command(CMD_PAR_RESULT, " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",""); ::upic_add_comment(COM_LOG, "Test log file name:",""); ::upic_set_param(m_logFile,1,"A30",m_logFile,0,0,0,0,0); ::upic_add_command(CMD_PAR_LOG, " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",""); ::upic_add_comment(COM_OPTS, " Steering options:",""); ::upic_set_param(m_myOpts,1,"A30",m_myOpts,0,0,0,0,0); ::upic_add_command(CMD_PAR_OPTS, " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",""); ::upic_add_comment(COM_OPT_LINE, "-------------------------------",""); ::upic_add_command(CMD_MBMMON, " MBM Monitor>",""); ::upic_add_command(CMD_EVTMON, " Event Monitor>",""); ::upic_add_command(CMD_RATEMON, " Rate Monitor>",""); ::upic_add_command(CMD_ALLMON, " Full Monitor>",""); ::upic_add_comment(COM_START_LINE, "-------------------------------",""); ::upic_add_command(CMD_START, " Start>",""); ::upic_add_command(CMD_STOP, " Stop>",""); ::upic_add_command(CMD_STOP_CLOSE, " Stop and close child menus>",""); ::upic_add_command(CMD_TERMINATE, " Terminate>",""); ::upic_close_menu(); ::upic_disable_command(m_id,CMD_STOP); ::upic_disable_command(m_id,CMD_STOP_CLOSE); ::upic_disable_command(m_id,CMD_EVTMON); ::upic_disable_command(m_id,CMD_RATEMON); ::upic_disable_command(m_id,CMD_ALLMON); ::upic_disable_command(m_id,CMD_MBMMON); ::upic_set_cursor(m_id,CMD_PAR_RESULT,0); ::snprintf(cwd,sizeof(cwd),"Current working directory: "); ::getcwd(cwd+strlen(cwd),sizeof(cwd)-strlen(cwd)); ::upic_write_message(cwd,""); s_mainMenu = this; UpiSensor::instance().add(this,m_id); } /// Default destructor MooreMainMenu::~MooreMainMenu() { } /// Destroy windows, but do not destruct object void MooreMainMenu::destroy() { if ( m_mbmMon ) delete m_mbmMon; if ( m_evtMon ) handleMonitor(m_evtMon,0); if ( m_allMon ) handleMonitor(m_allMon,0); if ( m_rateMon ) handleMonitor(m_rateMon,0); ::upic_delete_menu(m_id); if ( m_logger ) delete m_logger; m_mbmMon = 0; m_allMon = 0; m_evtMon = 0; m_rateMon = 0; m_logger = 0; } void MooreMainMenu::backSpaceCallBack (int menu,int /* cmd */,int par,const void* param) { Event ev; ev.target = (Interactor*)param; ev.eventtype = UpiEvent; ev.menu_id = menu; ev.command_id = CMD_BACKSPACE; ev.param_id = par; ev.index_id = 0; ev.target->handle(ev); } void MooreMainMenu::handleUPI(int cmd, int par, int index) { char buff[132]; switch(cmd) { case CMD_PAR_LOG: clean_str(m_logFile,sizeof(m_logFile)); break; case CMD_PAR_RESULT: clean_str(m_resFile,sizeof(m_resFile)); break; case CMD_PAR_OPTS: clean_str(m_myOpts,sizeof(m_myOpts)); break; case CMD_STOP: case CMD_STOP_CLOSE: case CMD_START: case CMD_MBMMON: case CMD_ALLMON: case CMD_EVTMON: case CMD_RATEMON: case CMD_TERMINATE: case CMD_MBMMON_CLOSE: m_ioc->send(this,cmd); break; default: sprintf(buff,"Unhandled CMD=%d,Param=%d,IDX=%d",cmd,par,index); ::upic_write_message(buff,""); break; } } void MooreMainMenu::handle (const Event& e) { switch ( e.eventtype ) { case IocEvent: switch(e.type) { case CMD_MBMMON_CLOSE: if ( m_mbmMon ) { delete m_mbmMon; m_mbmMon = 0; } break; case CMD_MBMMON: if ( 0 == m_mbmMon ) { const char *argv[] = {"Monitor","-s",0}; UPI::UpiDisplay* disp = new UPI::UpiDisplay(132,66); m_mbmMon = new MBM::Monitor(2, (char**)argv, disp); disp->setClient(this); m_mbmMon->monitor(); m_mbmMon->updateDisplay(); m_mbmMon->updateDisplay(); TimeSensor::instance().add(m_mbmMon,1,0); } break; case MooreTest::CMD_REMOVE_MOORE_CLIENT: if ( e.data == m_evtMon ) { m_evtMon = 0; } else if ( e.data == m_allMon ) { m_allMon = 0; } else if ( e.data == m_rateMon ) { m_rateMon = 0; } break; case CMD_REFEED: if ( e.data ) reconnectMonitor((UpiMooreMonitor*)e.data); break; case CMD_RATEMON: if ( !handleMonitor(m_rateMon,0) ) ::upic_set_cursor(m_id,CMD_RATEMON,0); break; case CMD_EVTMON: if ( !handleMonitor(m_evtMon,1) ) ::upic_set_cursor(m_id,CMD_EVTMON,0); break; case CMD_ALLMON: if ( !handleMonitor(m_allMon,2) ) ::upic_set_cursor(m_id,CMD_ALLMON,0); break; case CMD_ENABLE: enableTesting(); break; case CMD_START: startExecution(); break; case CMD_STOP_CLOSE: closeMenus(); finishExecution(); break; case CMD_STOP: finishExecution(); break; case CMD_TERMINATE: terminate(); break; case CMD_EXIT: if ( m_terminate ) { //destroy(); ::scrc_resetANSI(); _exit(0); } break; case CMD_WRITE_MESSAGE: if ( e.data ) { ::upic_write_message((char*)e.data,""); if ( m_log ) { ::fprintf(m_log,"%s\n",(char*)e.data); } ::free(e.data); } break; default: break; } break; case UpiEvent: handleUPI(e.command_id, e.param_id, e.index_id); break; case TimeEvent: m_ioc->send(this,CMD_EXIT); break; default: break; } } /// Output and printing helper function size_t MooreMainMenu::write_message(void* param, int, const char* fmt, va_list args) { char str[4096]; // string (like printf) size_t il=0, len = vsnprintf(str+il,sizeof(str)-il-2,fmt,args); str[il+len] = '\0'; str[il+len+1] = '\0'; MooreMainMenu* menu = (MooreMainMenu*)param; menu->write_message(str); return il; } /// Output and printing helper function void MooreMainMenu::write_message(const char* str) { m_ioc->send(this,CMD_WRITE_MESSAGE,strdup(str)); } bool MooreMainMenu::startExecution() { ::upic_disable_command(m_id,CMD_PAR_LOG); //::upic_disable_command(m_id,CMD_PAR_RESULT); ::upic_disable_command(m_id,CMD_START); ::upic_write_message("+++++ Starting thread with moore execution.......",""); if ( m_exec ) { ::lib_rtl_delete_thread(m_exec); m_exec = 0; } clean_str(m_logFile,sizeof(m_logFile)); if ( ::strlen(m_logFile) > 0 ) { m_log = ::fopen(m_logFile,"w"); } ::setenv("MOORESTANDALONE_LOGGER_OUTPUT",m_logFile,1); ::setenv("MOORESTANDALONE_FILE_OUTPUT",m_resFile,1); int ret = ::lib_rtl_start_thread(run,this,&m_exec); if ( !lib_rtl_is_success(ret) ) { string err = RTL::errorString(); ::upic_write_message(("Failed to start execution thread.... ["+err+"]").c_str(),""); return false; } ::lib_rtl_sleep(2000); ::upic_enable_command(m_id,CMD_MBMMON); ::upic_enable_command(m_id,CMD_EVTMON); ::upic_enable_command(m_id,CMD_RATEMON); ::upic_enable_command(m_id,CMD_ALLMON); ::upic_enable_command(m_id,CMD_STOP); ::upic_enable_command(m_id,CMD_STOP_CLOSE); ::upic_set_cursor(m_id,CMD_STOP,0); m_ioc->send(this,CMD_REFEED,m_evtMon); m_ioc->send(this,CMD_REFEED,m_allMon); m_ioc->send(this,CMD_REFEED,m_rateMon); return true; } bool MooreMainMenu::finishExecution() { if ( sendInterrupt("Runable",MooreTest::CMD_MOORE_EXIT,this) ) { write_message("Successfully send STOP command to tester."); return true; } write_message("CANNOT send STOP command to tester. [Invalid Gaudi-state]"); return false; } bool MooreMainMenu::enableTesting() { if ( m_log ) ::fclose(m_log); m_log = 0; ::upic_enable_command(m_id,CMD_PAR_LOG); //::upic_enable_command(m_id,CMD_PAR_RESULT); ::upic_enable_command(m_id,CMD_START); ::upic_disable_command(m_id,CMD_STOP); ::upic_disable_command(m_id,CMD_STOP_CLOSE); ::upic_disable_command(m_id,CMD_EVTMON); ::upic_disable_command(m_id,CMD_RATEMON); ::upic_disable_command(m_id,CMD_ALLMON); ::upic_disable_command(m_id,CMD_MBMMON); ::upic_set_cursor(m_id,CMD_START,0); return true; } /// Close all monitor menues in one go.... void MooreMainMenu::closeMenus() { if ( m_rateMon ) m_ioc->send(m_rateMon,MooreTest::CMD_CLOSE); if ( m_evtMon ) m_ioc->send(m_evtMon,MooreTest::CMD_CLOSE); if ( m_allMon ) m_ioc->send(m_allMon,MooreTest::CMD_CLOSE); m_allMon = 0; m_evtMon = 0; m_rateMon = 0; } void MooreMainMenu::terminate() { closeMenus(); m_terminate = true; if ( !finishExecution() ) TimeSensor::instance().add(this,1,0); } bool MooreMainMenu::reconnectMonitor(UpiMooreMonitor* s) { if ( s ) { if ( m_svcLocator ) { SmartIF<IService> svc = m_svcLocator->service("LHCb::MooreMonitorSvc",true); if ( svc ) { Interactor* a = dynamic_cast<Interactor*>(svc.get()); if ( a ) { s->setFeed(a); } } } } return false; } bool MooreMainMenu::handleMonitor(UpiMooreMonitor*& m, int typ) { if ( m != 0 ) { m_ioc->send(m,MooreTest::CMD_CLOSE); m = 0; } else if ( m_svcLocator ) { SmartIF<IService> svc = m_svcLocator->service("LHCb::MooreMonitorSvc",true); if ( svc ) { Interactor* a = dynamic_cast<Interactor*>(svc.get()); if ( a ) { m = new UpiMooreMonitor(typ, this, a); return true; } } } return false; } bool MooreMainMenu::sendInterrupt(const string& service, int code, void* param) { if ( m_svcLocator ) { SmartIF<IService> svc = m_svcLocator->service(service,false); if ( svc ) { Interactor* a = dynamic_cast<Interactor*>(svc.get()); if ( a ) { m_ioc->send(a,code,param); return true; } } } return false; } int MooreMainMenu::run(void* param) { MooreMainMenu* m = (MooreMainMenu*)param; int ret = m->runMoore(m->m_myOpts); return ret; } int MooreMainMenu::runMoore(const string& opts) { Gaudi::setInstance((IAppMgrUI*)0); IInterface* iface = Gaudi::createApplicationMgr(); SmartIF<IProperty> propMgr ( iface ); SmartIF<IAppMgrUI> appMgr ( iface ); if( !appMgr.isValid() || !propMgr.isValid() ) { write_message("Fatal error while creating the ApplicationMgr "); return 1; } propMgr->setProperty( "JobOptionsPath", opts ).ignore(); propMgr->setProperty( "MessageSvcType","LHCb::GenericMessageSvc"); // Run the application manager and process events StatusCode sc = StatusCode::SUCCESS; { SmartIF<ISvcLocator> loc(iface); m_svcLocator = loc.get(); TimeSensor::instance().add(this,1,0); sc = appMgr->run(); m_svcLocator = 0; } IntegerProperty returnCode("ReturnCode", 0); propMgr->getProperty(&returnCode).ignore(); // Release Application Manager iface->release(); // All done - exit if (sc.isFailure() && returnCode.value() == 0) { // propagate a valid error code in case of failure returnCode.setValue(1); } m_ioc->send(this,CMD_MBMMON_CLOSE); m_ioc->send(this,CMD_ENABLE); return returnCode.value(); } extern "C" int log_write_message(const char* text) { s_mainMenu->write_message(text); return 0x1; } static void help() { ::printf(" Usage: moore_standalone -opt [-opt]\n" " -o(ptions)=<file-name> Main steering options. \n"); _exit(0); } extern "C" int moore_standalone(int argc, char** argv) { string opts; RTL::CLI cli(argc, argv, help); if ( cli.getopt("debug",1) ) lib_rtl_start_debugger(); cli.getopt("options",1,opts); if ( opts.empty() ) { help(); } int status = ::upic_attach_terminal(); if(status != UPI_NORMAL) exit(EXIT_FAILURE); Sensor& s = UpiSensor::instance(); MooreMainMenu t(opts); ::lib_rtl_install_printer(MooreMainMenu::write_message,&t); s.run(); return 1; }
a9b2f2b3be48ee7aaecc85639f8e64a83779d2b2
7238587c3149d79cf7305c2ace9907e1fb77a4f4
/DialogErrAns.h
28ecb2ae0fa082be3c87bb49cdc50f73d78daf9d
[]
no_license
FordHsieh/EnglishTestWin
2b1eafaf4e924c4b6ee69d0d4892e6ac75e241e9
c82c677a048833055d44fd2103cbfdc0a48c5b17
refs/heads/master
2022-11-14T23:07:33.061369
2020-07-10T14:32:49
2020-07-10T14:32:49
277,544,776
0
0
null
null
null
null
UTF-8
C++
false
false
1,205
h
#if !defined(AFX_DIALOGERRANS_H__BF56790A_5AA4_4675_BE87_1D8DCAB6E8F0__INCLUDED_) #define AFX_DIALOGERRANS_H__BF56790A_5AA4_4675_BE87_1D8DCAB6E8F0__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // DialogErrAns.h : header file // ///////////////////////////////////////////////////////////////////////////// // CDialogErrAns dialog class CDialogErrAns : public CDialog { // Construction public: CDialogErrAns(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CDialogErrAns) enum { IDD = IDD_DIALOG_ERRANS }; CString m_RightWord; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDialogErrAns) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CDialogErrAns) afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DIALOGERRANS_H__BF56790A_5AA4_4675_BE87_1D8DCAB6E8F0__INCLUDED_)
daad6c0f335fb31655b7d59cf80164cbaadf6a40
9f70efdaaaafe2e635c5e1fa80bc07b02d651d13
/rbot250_A3_ws/install/turtlesim/include/turtlesim/srv/detail/teleport_absolute__rosidl_typesupport_fastrtps_cpp.hpp
858a8436d8db22c81ab46978ed2b7dc7860fce2e
[]
no_license
glemelleii-brandeis/Assignment_3_ROS
f5a6beffde3ac03504519a47087da1040ba34111
55908e935a3a5723b4bafdd12d369d440ce7499a
refs/heads/main
2023-08-20T22:21:17.045530
2021-10-31T16:44:25
2021-10-31T16:44:25
421,452,421
0
0
null
null
null
null
UTF-8
C++
false
false
4,590
hpp
// generated from rosidl_typesupport_fastrtps_cpp/resource/idl__rosidl_typesupport_fastrtps_cpp.hpp.em // with input from turtlesim:srv/TeleportAbsolute.idl // generated code does not contain a copyright notice #ifndef TURTLESIM__SRV__DETAIL__TELEPORT_ABSOLUTE__ROSIDL_TYPESUPPORT_FASTRTPS_CPP_HPP_ #define TURTLESIM__SRV__DETAIL__TELEPORT_ABSOLUTE__ROSIDL_TYPESUPPORT_FASTRTPS_CPP_HPP_ #include "rosidl_runtime_c/message_type_support_struct.h" #include "rosidl_typesupport_interface/macros.h" #include "turtlesim/msg/rosidl_typesupport_fastrtps_cpp__visibility_control.h" #include "turtlesim/srv/detail/teleport_absolute__struct.hpp" #ifndef _WIN32 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-parameter" # ifdef __clang__ # pragma clang diagnostic ignored "-Wdeprecated-register" # pragma clang diagnostic ignored "-Wreturn-type-c-linkage" # endif #endif #ifndef _WIN32 # pragma GCC diagnostic pop #endif #include "fastcdr/Cdr.h" namespace turtlesim { namespace srv { namespace typesupport_fastrtps_cpp { bool ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim cdr_serialize( const turtlesim::srv::TeleportAbsolute_Request & ros_message, eprosima::fastcdr::Cdr & cdr); bool ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim cdr_deserialize( eprosima::fastcdr::Cdr & cdr, turtlesim::srv::TeleportAbsolute_Request & ros_message); size_t ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim get_serialized_size( const turtlesim::srv::TeleportAbsolute_Request & ros_message, size_t current_alignment); size_t ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim max_serialized_size_TeleportAbsolute_Request( bool & full_bounded, bool & is_plain, size_t current_alignment); } // namespace typesupport_fastrtps_cpp } // namespace srv } // namespace turtlesim #ifdef __cplusplus extern "C" { #endif ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim const rosidl_message_type_support_t * ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_fastrtps_cpp, turtlesim, srv, TeleportAbsolute_Request)(); #ifdef __cplusplus } #endif // already included above // #include "rosidl_runtime_c/message_type_support_struct.h" // already included above // #include "rosidl_typesupport_interface/macros.h" // already included above // #include "turtlesim/msg/rosidl_typesupport_fastrtps_cpp__visibility_control.h" // already included above // #include "turtlesim/srv/detail/teleport_absolute__struct.hpp" #ifndef _WIN32 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-parameter" # ifdef __clang__ # pragma clang diagnostic ignored "-Wdeprecated-register" # pragma clang diagnostic ignored "-Wreturn-type-c-linkage" # endif #endif #ifndef _WIN32 # pragma GCC diagnostic pop #endif // already included above // #include "fastcdr/Cdr.h" namespace turtlesim { namespace srv { namespace typesupport_fastrtps_cpp { bool ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim cdr_serialize( const turtlesim::srv::TeleportAbsolute_Response & ros_message, eprosima::fastcdr::Cdr & cdr); bool ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim cdr_deserialize( eprosima::fastcdr::Cdr & cdr, turtlesim::srv::TeleportAbsolute_Response & ros_message); size_t ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim get_serialized_size( const turtlesim::srv::TeleportAbsolute_Response & ros_message, size_t current_alignment); size_t ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim max_serialized_size_TeleportAbsolute_Response( bool & full_bounded, bool & is_plain, size_t current_alignment); } // namespace typesupport_fastrtps_cpp } // namespace srv } // namespace turtlesim #ifdef __cplusplus extern "C" { #endif ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim const rosidl_message_type_support_t * ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_fastrtps_cpp, turtlesim, srv, TeleportAbsolute_Response)(); #ifdef __cplusplus } #endif #include "rmw/types.h" #include "rosidl_typesupport_cpp/service_type_support.hpp" // already included above // #include "rosidl_typesupport_interface/macros.h" // already included above // #include "turtlesim/msg/rosidl_typesupport_fastrtps_cpp__visibility_control.h" #ifdef __cplusplus extern "C" { #endif ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_turtlesim const rosidl_service_type_support_t * ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_fastrtps_cpp, turtlesim, srv, TeleportAbsolute)(); #ifdef __cplusplus } #endif #endif // TURTLESIM__SRV__DETAIL__TELEPORT_ABSOLUTE__ROSIDL_TYPESUPPORT_FASTRTPS_CPP_HPP_
3e8c6fc30372e1e3c7a795c90136550379ed1568
0f8559dad8e89d112362f9770a4551149d4e738f
/Wall_Destruction/Havok/Source/Physics/Dynamics/Action/hkpActionListener.h
f83c433ccefb1f334be5f0fcdf7e97d153fbae05
[]
no_license
TheProjecter/olafurabertaymsc
9360ad4c988d921e55b8cef9b8dcf1959e92d814
456d4d87699342c5459534a7992f04669e75d2e1
refs/heads/master
2021-01-10T15:15:49.289873
2010-09-20T12:58:48
2010-09-20T12:58:48
45,933,002
0
0
null
null
null
null
UTF-8
C++
false
false
1,659
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HK_DYNAMICS2_ACTION_LISTENER_H #define HK_DYNAMICS2_ACTION_LISTENER_H class hkpAction; /// hkpActionListener. class hkpActionListener { public: virtual ~hkpActionListener() {} /// Called when an action is added to the world. virtual void actionAddedCallback( hkpAction* action ) {} /// Called when an action is removed from the world. virtual void actionRemovedCallback( hkpAction* action ) {} }; #endif // HK_DYNAMICS2_ACTION_LISTENER_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222) * * Confidential Information of Havok. (C) Copyright 1999-2009 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at www.havok.com/tryhavok. * */
ace097458612ff112ace79064683833892344272
9ed1141efe9555f55c28974b8b29486c981eb97c
/6_4单词拆分/6_4单词拆分/6_4拆分单词.cpp
94d9a65fada77adfdaca42aef95246442441955c
[]
no_license
fwqaq/vscode
d7e6f17b3ddb1280f207e03006ccf45c70b4e22e
c69794ec1e3ea719226c719b7109319a16fda52a
refs/heads/master
2022-03-02T21:08:03.918960
2019-08-29T15:16:56
2019-08-29T15:16:56
160,153,996
0
0
null
null
null
null
UTF-8
C++
false
false
805
cpp
#include <iostream> #include <vector> #include <string> #include <unordered_set> using namespace std; class Solution { public: bool wordBreak(string s, vector<string>& wordDict) { int m = s.size(); vector<bool> dp(m, false); unordered_set<string> set_s(wordDict.begin(), wordDict.end()); int i = 0; for (; i < m; i++) { string it = s.substr(0, i + 1); if (set_s.find(it) != set_s.end()) break; } for (; i < m; i++) { for (int j = i; j >= 0; j--) { string it = s.substr(j, i - j + 1); if (set_s.find(it) != set_s.end()) { if (j == 0 || dp[j - 1]) { dp[i] = true; break; } } } } return dp[m - 1]; } }; int main(){ Solution s; vector<string>vv{ "leet", "code" }; cout<<s.wordBreak("leetcode",vv); system("pause"); return EXIT_SUCCESS; }
63d49daf55efaeaadbbf49e22e4361f56b71b538
fb689146cc19e1113e095e6dfd12f8b73177b22f
/source/base/quadrature_selector.cc
41cdb00a11d0b62907b85a086a7d6decf8d72982
[]
no_license
qsnake/deal.II
0418a4c9371e2630a0fce65b8de3529fa168d675
79c0458c8cc3fa03e5d89357a53a4f9397ead5c3
refs/heads/master
2021-01-01T15:55:27.801304
2012-07-27T13:31:57
2012-07-27T14:16:10
5,205,180
3
1
null
null
null
null
UTF-8
C++
false
false
2,067
cc
//--------------------------------------------------------------------------- // $Id: quadrature_selector.cc 23709 2011-05-17 04:34:08Z bangerth $ // Version: $Name$ // // Copyright (C) 2003, 2005, 2006, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer // to the file deal.II/doc/license.html for the text and // further information on this license. // //--------------------------------------------------------------------------- #include <deal.II/base/quadrature_selector.h> #include <deal.II/base/quadrature_lib.h> DEAL_II_NAMESPACE_OPEN template <int dim> Quadrature<dim> QuadratureSelector<dim>:: create_quadrature (const std::string &s, const unsigned int order) { if(s == "gauss") { AssertThrow(order >= 2, ExcInvalidQGaussOrder(order)); return QGauss<dim>(order); } else { AssertThrow(order == 0, ExcInvalidOrder(s, order)); if (s == "midpoint") return QMidpoint<dim>(); else if (s == "milne") return QMilne<dim>(); else if (s == "simpson") return QSimpson<dim>(); else if (s == "trapez") return QTrapez<dim>(); else if (s == "weddle") return QWeddle<dim>(); } // we didn't find this name AssertThrow (false, ExcInvalidQuadrature(s)); // return something to suppress // stupid warnings by some // compilers return Quadrature<dim>(); } template <int dim> QuadratureSelector<dim>::QuadratureSelector (const std::string &s, const unsigned int order) : Quadrature<dim> (create_quadrature(s, order).get_points(), create_quadrature(s, order).get_weights()) { } template <int dim> std::string QuadratureSelector<dim>::get_quadrature_names() { return std::string("gauss|midpoint|milne|simpson|trapez|weddle"); } // explicit instantiations template class QuadratureSelector<1>; template class QuadratureSelector<2>; template class QuadratureSelector<3>; DEAL_II_NAMESPACE_CLOSE
31f58959e441870fe0027c5e4bac7992a4440194
cf8ddfc720bf6451c4ef4fa01684327431db1919
/SDK/ARKSurvivalEvolved_OilHarvestComponent_structs.hpp
7c8b9b773ee9622fbea72156a817473773032760
[ "MIT" ]
permissive
git-Charlie/ARK-SDK
75337684b11e7b9f668da1f15e8054052a3b600f
c38ca9925309516b2093ad8c3a70ed9489e1d573
refs/heads/master
2023-06-20T06:30:33.550123
2021-07-11T13:41:45
2021-07-11T13:41:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
278
hpp
#pragma once // ARKSurvivalEvolved (329.9) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_Basic.hpp" #include "ARKSurvivalEvolved_StoneHarvestComponent_RequiresMetal_classes.hpp" namespace sdk { } #ifdef _MSC_VER #pragma pack(pop) #endif
8798c9c9bde2d16d2a58dcce0bcb4ff05a420d25
5ab9081001e78e13045e3d5f55b5182ed56015e3
/demos/zombie/src/player.cpp~
23c65dc2342c982996f9f8106b7e963eb43c06d5
[ "Zlib", "MIT" ]
permissive
leftidev/leng
1aedd2f987b781c16d6be43a8de3302ece3128fa
9df738a9f5d8f90d2a01234d4d4b13311017d93e
refs/heads/master
2021-01-12T12:13:02.689071
2016-10-30T19:11:48
2016-10-30T19:11:48
72,369,202
0
0
null
null
null
null
UTF-8
C++
false
false
453
#include "player.h" namespace leng { Player::Player(float x, float y, float width, float height, const std::string& path) : Entity(x, y, width, height, path) { upHeld = false; downHeld = false; vel.y = 0.5f; } Player::~Player() { } void Player::update(float deltaTime) { Entity::update(deltaTime); if(upHeld) { pos.y += vel.y * deltaTime; } if(downHeld) { pos.y -= vel.y * deltaTime; } } } // namespace leng
a269b52f4b19f4261962d510f099a45396232be5
5b4c05354c147917b636e611ba6ac3fdee86f353
/src/MWeeds.h
7d0e32a69841f1eb15beb4c8e74cfaa8d062305a
[]
no_license
vesabios/matador
ad7a1bf29ca1008a288d8056097d7a07e27ddc55
a212ca4459cfcaa031c9d2fff05a5f367d767a65
refs/heads/master
2021-01-10T02:00:13.969343
2015-11-04T02:23:15
2015-11-04T02:23:15
44,342,051
0
0
null
null
null
null
UTF-8
C++
false
false
2,962
h
// // MWeeds.h // matador // // Created by vesabios on 10/7/15. // // #ifndef MWeeds_h #define MWeeds_h #include <stdio.h> //#include "ofMain.h" //#include "Defines.h" #include "Material.h" class MWeeds : public Material { public: int cLUT[8] ={ 243, 243, CHAR_PLANTS0, CHAR_PLANTS1, CHAR_PLANTS2, 218, CHAR_PLANTS3, 182 }; int fgLUT[8][3]= { {0, 1, 0}, // memory {0, 2, 0}, {0, 2, 0}, {0, 2, 1}, {0, 2, 1}, {0, 3, 1}, {0, 3, 1}, {0, 4, 2} }; int bgLUT[8][3]= { {0, 0, 0}, // memory {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} }; MWeeds(Material::MaterialType mt) : Material(mt) {} string getName() override { return "Weeds"; } float isOpaque() override { 0.1f; } DEBT traversable() override { return TRAVERSE_SLIPPERY; } Pixel operator()(ofVec2i pos, float luma) override { Pixel p; char l = 0; char gc = 0; char lm; if (luma>0) { float noise = (ofNoise(pos.x, pos.y)*0.2f) + 0.8f; lm = dither(pos.x, pos.y, luma * noise * 6.0f); l = MAX(MIN(lm-1,5),0); if (l>1) { float grassNoise = ofNoise(pos.x, pos.y); l = MIN(int (grassNoise * 7.0f), 6); } // 2,3,1, 1,2,1 if (l>3) { p.fg = makeColor(lm*0.4,lm*0.6,lm*0.2); p.bg = makeColor(lm*0.2,lm*0.4,lm*0.2); } else { p.fg = makeColor(lm*0.4,lm*0.4,lm*0.0); p.bg = makeColor(lm*0.2,lm*0.4,lm*0.2); } } else { p.fg = makeColor(fgLUT[l][0],fgLUT[l][1],fgLUT[l][2]); p.bg = makeColor(bgLUT[l][0],bgLUT[l][1],bgLUT[l][2]); } p.c = cLUT[l]; return p; }; /* if (v<=0) { c = 243;//toascii(' '); } else if (v<=1) { c = 243; } else { float grassNoise = ofNoise(mx*1.0f, my*1.0f); if (grassNoise>0.9) { c = CHAR_PLANTS0; } else if (grassNoise>0.8) { c = CHAR_PLANTS1; } else if (grassNoise>0.7) { c = CHAR_PLANTS2; } else if (grassNoise>0.6) { c = CHAR_PLANTS3; } else if (grassNoise>0.5) { c = 242; } else { c = 243; } } v = MIN(2,ditherValue(mx, my, att*flickerValue*aa * 6))+2; console.setPixel(x,y, makeColor(v*0.3,v*0.6,v*0.2),makeColor(v*0.1,v*0.4,v*0.2), c); */ }; #endif
c182d35548d4d295408256cdaabd2aafa729fa9e
1061073e26b14264fb2ad09defc01ef378127ed9
/Server_Storage/src/acquisition_task.cpp
1daa9c84b94efecc89a72e9dd009a52274f19377
[]
no_license
quepas/Stormy
11be3189c0fd96ac6a05e251892922aefa366985
268bf6932c82cafa09108e0a2d83532b72bb1fd4
refs/heads/master
2021-01-16T19:00:44.526416
2014-11-23T20:51:26
2014-11-23T20:51:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,282
cpp
#include "acquisition_task.h" #include <ctime> #include <cstdint> #include <map> #include <boost/range/algorithm/copy.hpp> #include <Poco/NumberFormatter.h> #include <Poco/Stopwatch.h> #include "common/entity_measurement.h" #include "common/entity_station.h" #include "acquisition_http_connector.h" #include "acquisition_json_util.h" using namespace stormy::common; using boost::copy; using std::back_inserter; using std::string; using std::vector; using std::map; using std::time_t; using std::tm; using Poco::Logger; using Poco::NumberFormatter; using Poco::Stopwatch; namespace stormy { namespace acquisition { Task::Task(db::Storage* db_storage, RemoteServerSetting server) : logger_(Logger::get("acquisition/task")), db_storage_(db_storage), server_(server) { } Task::~Task() { } void Task::run() { Stopwatch stopwatch; stopwatch.start(); HTTPConnector http_connector(server_.host, server_.port); logger_.notice("[acquisition/Task] Start fetching data from " + server_.name); // metrics auto metrics = http_connector.FetchMetrics(); db_storage_ -> InsertMetrics(metrics); // stations auto stations = http_connector.FetchStations(); db_storage_ -> InsertStations(stations); uint32_t measurementCounter = 0; // data Each(stations, [&](entity::Station station) { tm newestMeasureForStation = db_storage_ -> GetNewestStationMeasureTime(station.uid); map<time_t, vector<entity::Measurement>> measurement_sets; time_t newest_measure_time = mktime(&newestMeasureForStation); if(newest_measure_time > 0) { // make time locale (UTC/GMT+1) => +3600 // look for greater&equal => +1 measurement_sets = http_connector .FetchMeasureSets(station.uid, newest_measure_time+3600+1); } else { measurement_sets = http_connector .FetchMeasureSets(station.uid, 0); } measurementCounter += measurement_sets.size(); db_storage_ -> InsertMeasureSets(measurement_sets); measurement_sets.clear(); }); logger_.notice("[acquisition/Task] Fetched " + NumberFormatter::format(measurementCounter) + " measure sets. It took: " + NumberFormatter::format(stopwatch.elapsed() / 1000.0) + "ms."); metrics.clear(); stations.clear(); stopwatch.stop(); } // ~~ stormy::acquisition::Task }}
cd95024a32e57e3358dd225e9f7f1e9c769039de
7dc9e1aaa72cad9ddbe4e1cd6d75a8dca4c19b8b
/tutapp/ch_wall.cpp
3ac254de8140e7b25482a272aa54eab820a5209f
[]
no_license
yuriv/sandbox
79d2d771aea2c5621da0ef541f5a1682cf0c2571
9ec6f4800e607096fb633ffdac18818fc1feb93c
refs/heads/master
2020-04-18T01:31:51.521287
2014-12-19T21:48:07
2014-12-19T21:48:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,490
cpp
#include <gp.hxx> #include <gp_XYZ.hxx> #include "ch_arch_builder.h" #include "ch_wall_face.h" #include "ch_wall_base.h" #include "ch_wall.h" ch_wall::ch_wall() : ch_arch_object(0, TopAbs_UNKNOWN) { length(min_size().Y()); width(ch_arch::_wall_width); height(ch_arch::_wall_height); _end = gp_Pnt(_start.X(), _start.Y() + length(), _start.Z()); add(new ch_wall_face(this, _start, _end, TopAbs_IN)); add(new ch_wall_face(this, _start, _end, TopAbs_OUT)); add(new ch_wall_base(this, _start, _end)); connect_all(); } ch_wall::ch_wall(ch_wall const& other) { *this = other; connect_all(); } ch_wall::~ch_wall() { disconnect(); } ArchObjectType ch_wall::arch_type() const { return aotWall; } TopAbs_ShapeEnum ch_wall::topo_type() const { return ShapeType(); } void ch_wall::on_begin_construct(Handle_V3d_View const view, gp_Pnt2d const& p2D) { if(ch_arch::to_3D(view, p2D, _start, Standard_False)) { _end = gp_Pnt(_start.X(), _start.Y() + length(), _start.Z()); _direction = gp_Vec(_start, _end); ch_arch::rot_3D(view, _start, _end, _direction, _rotation); emit build(*this); emit constructed(*this); } } void ch_wall::on_constructing(Handle_V3d_View const view, gp_Pnt2d const& p2D) { if(ch_arch::to_3D(view, p2D, _end, Standard_False)) { length(std::max(_start.Distance(_end), min_size().Y())); ch_arch::rot_3D(view, _start, _end, _direction, _rotation); emit build(*this); emit constructed(*this); } } void ch_wall::on_cancel_construct() { emit canceled(*this); } void ch_wall::on_end_construct(Handle_V3d_View const view, gp_Pnt2d const& p2D) { on_constructing(view, p2D); disconnect(); } void ch_wall::connect_all() { connect(this, SIGNAL(build(ch_arch_object&)), ch_arch::arch_builder(), SLOT(on_build(ch_arch_object&))); connect(this, SIGNAL(length_changed(ch_arch_object&, Standard_Real)), ch_arch::arch_builder(), SLOT(on_wall_length_changed(ch_arch_object&, Standard_Real))); connect(this, SIGNAL(width_changed(ch_arch_object&, Standard_Real)), ch_arch::arch_builder(), SLOT(on_wall_width_changed(ch_arch_object&, Standard_Real))); connect(this, SIGNAL(height_changed(ch_arch_object&, Standard_Real)), ch_arch::arch_builder(), SLOT(on_wall_height_changed(ch_arch_object&, Standard_Real))); connect(this, SIGNAL(LWH_changed(ch_arch_object&, Standard_Real, Standard_Real, Standard_Real)), ch_arch::arch_builder(), SLOT(on_wall_LWH_changed(ch_arch_object&, Standard_Real, Standard_Real, Standard_Real))); }
0698c234a25bd4ad6e394a550efece7dde8370bc
f75485044a472796dc48566869464c8ce1a2eac5
/brolib/BroLib/Gnd.cpp
11062e8e1eb3e8fc8fbcddbd3b1465eb14520852
[]
no_license
tsan79/browedit
215d92a86d663b9fe6db03ee4b6a227d040239d8
9cae73cd08b879c9f3c8e016db65a025ce8d2c98
refs/heads/master
2021-01-01T19:54:01.930646
2017-07-29T07:11:08
2017-07-29T07:11:08
98,715,566
1
0
null
2017-07-29T07:13:21
2017-07-29T07:13:21
null
UTF-8
C++
false
false
12,386
cpp
#include "Gnd.h" #include <set> #include <blib/util/FileSystem.h> #include <blib/util/Log.h> #include <blib/linq.h> #include <blib/Texture.h> #include <blib/ResourceManager.h> using blib::util::Log; Gnd::Gnd(int width, int height) { version = 0x0107; this->width = width; this->height = height; tileScale = 10.0f; maxTexName = 80; lightmapWidth = 8; lightmapHeight = 8; gridSizeCell = 1; cubes.resize(width, std::vector<Cube*>(height, NULL)); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Cube* cube = new Cube(); cube->h1 = cube->h2 = cube->h3 = cube->h4 = 0; cube->tileUp = -1; cube->tileSide = -1; cube->tileFront = -1; cube->calcNormal(); cubes[x][y] = cube; } } } Gnd::Gnd( const std::string &fileName ) { blib::util::StreamInFile* file = blib::util::FileSystem::openRead(fileName + ".gnd"); if(!file || !file->opened()) { width = 0; height = 0; Log::err<<"GND: Unable to open gnd file: "<<fileName<<".gnd"<<Log::newline; return; } Log::out<<"GND: Reading gnd file"<<Log::newline; char header[4]; file->read(header, 4); if(header[0] == 'G' && header[1] == 'R' && header[2] == 'G' && header[3] == 'N') version = file->readShort(); else { version = 0; Log::out << "GND: Invalid GND file" << Log::newline; } int textureCount = 0; if(version > 0) { width = file->readInt(); height = file->readInt(); tileScale = file->readFloat(); textureCount = file->readInt(); maxTexName = file->readInt();// 80 } else { file->seek(6, blib::util::StreamSeekable::CURRENT);//TODO: test this width = file->readInt(); height = file->readInt(); textureCount = file->readInt(); } textures.reserve(textureCount); for(int i = 0; i < textureCount; i++) { Texture* texture = new Texture(); texture->file = file->readString(40); texture->name = file->readString(40); //texture->texture = new Texture("data/texture/" + texture->file); //TODO: blib loader textures.push_back(texture); } if(version > 0) { int lightmapCount = file->readInt(); lightmapWidth = file->readInt(); lightmapHeight = file->readInt(); gridSizeCell = file->readInt(); //Fix lightmap format if it was invalid. by Henko if (lightmapWidth != 8 || lightmapHeight != 8 || gridSizeCell != 1) { Log::err<<"GND: Invalid Lightmap Format in "<<fileName<<".gnd"<<Log::newline; lightmapWidth = 8; lightmapHeight = 8; gridSizeCell = 1; } lightmaps.reserve(lightmapCount); for(int i = 0; i < lightmapCount; i++) { Lightmap* lightmap = new Lightmap(); file->read((char*)lightmap->data, 256); lightmaps.push_back(lightmap); } int tileCount = file->readInt(); tiles.reserve(tileCount); for(int i = 0; i < tileCount; i++) { Tile* tile = new Tile(); tile->v1.x = file->readFloat(); tile->v2.x = file->readFloat(); tile->v3.x = file->readFloat(); tile->v4.x = file->readFloat(); tile->v1.y = file->readFloat(); tile->v2.y = file->readFloat(); tile->v3.y = file->readFloat(); tile->v4.y = file->readFloat(); tile->textureIndex = file->readWord(); tile->lightmapIndex= file->readWord(); if (tile->lightmapIndex < 0) { tile->lightmapIndex = 0; } tile->color.b = (unsigned char)file->get(); tile->color.g = (unsigned char)file->get(); tile->color.r = (unsigned char)file->get(); tile->color.a = (unsigned char)file->get(); tiles.push_back(tile); } cubes.resize(width, std::vector<Cube*>(height, NULL)); for(int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Cube* cube = new Cube(); cube->h1 = file->readFloat(); cube->h2 = file->readFloat(); cube->h3 = file->readFloat(); cube->h4 = file->readFloat(); cube->calcNormal(); if (version >= 0x0106) { cube->tileUp = file->readInt(); cube->tileSide = file->readInt(); cube->tileFront = file->readInt(); } else { cube->tileUp = file->readWord(); cube->tileSide = file->readWord(); cube->tileFront = file->readWord(); } if (cube->tileUp >= (int)tiles.size()) { Log::out << "Wrong value for tileup at " << x << ", " << y << Log::newline; cube->tileUp = -1; } if (cube->tileSide >= (int)tiles.size()) { Log::out << "Wrong value for tileside at " << x << ", " << y << Log::newline; cube->tileSide = -1; } if (cube->tileFront >= (int)tiles.size()) { Log::out << "Wrong value for tilefront at " << x << ", " << y << Log::newline; cube->tileFront = -1; } cubes[x][y] = cube; } } } else { //TODO: port code...too lazy for now } delete file; Log::out<<"GND: Done reading gnd file"<<Log::newline; for (int x = 1; x < width-1; x++) { for (int y = 1; y < height-1; y++) { cubes[x][y]->calcNormals(this, x, y); } } Log::out<<"GND: Done calculating normals" << Log::newline; } Gnd::~Gnd() { blib::linq::deleteall(textures); blib::linq::deleteall(lightmaps); blib::linq::deleteall(tiles); for (size_t i = 0; i < cubes.size(); i++) for (size_t ii = 0; ii < cubes[i].size(); ii++) if (cubes[i][ii]) delete cubes[i][ii]; } void Gnd::save(std::string fileName) { blib::util::PhysicalFileSystemHandler::StreamOutFilePhysical* pFile = new blib::util::PhysicalFileSystemHandler::StreamOutFilePhysical(fileName + ".gnd"); char header[5] = "GRGN"; pFile->write(header, 4); pFile->writeShort(version); if (version > 0) { pFile->writeInt(width); pFile->writeInt(height); pFile->writeFloat(tileScale); pFile->writeInt(textures.size()); pFile->writeInt(maxTexName);// iunno } for (size_t i = 0; i < textures.size(); i++) { pFile->writeString(textures[i]->file, 40); pFile->writeString(textures[i]->name, 40); } if (version > 0) { pFile->writeInt(lightmaps.size()); pFile->writeInt(lightmapWidth); pFile->writeInt(lightmapHeight); pFile->writeInt(gridSizeCell); for (size_t i = 0; i < lightmaps.size(); i++) pFile->write((char*)lightmaps[i]->data, 256); pFile->writeInt(tiles.size()); for (size_t i = 0; i < tiles.size(); i++) { Tile* tile = tiles[i]; pFile->writeFloat(tile->v1.x); pFile->writeFloat(tile->v2.x); pFile->writeFloat(tile->v3.x); pFile->writeFloat(tile->v4.x); pFile->writeFloat(tile->v1.y); pFile->writeFloat(tile->v2.y); pFile->writeFloat(tile->v3.y); pFile->writeFloat(tile->v4.y); pFile->writeWord(tile->textureIndex); pFile->writeWord(tile->lightmapIndex); pFile->put(tile->color.b); pFile->put(tile->color.g); pFile->put(tile->color.r); pFile->put(tile->color.a); } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Cube* cube = cubes[x][y]; pFile->writeFloat(cube->h1); pFile->writeFloat(cube->h2); pFile->writeFloat(cube->h3); pFile->writeFloat(cube->h4); if (version >= 0x0106) { pFile->writeInt(cube->tileUp); pFile->writeInt(cube->tileSide); pFile->writeInt(cube->tileFront); } else { pFile->writeWord(cube->tileUp); pFile->writeWord(cube->tileSide); pFile->writeWord(cube->tileFront); } } } } delete pFile; } Gnd::Texture::Texture() { texture = NULL; } Gnd::Texture::~Texture() { if(texture) blib::ResourceManager::getInstance().dispose(texture); texture = NULL; } void Gnd::Cube::calcNormal() { /* 1----2 |\ | | \ | | \ | | \| 3----4 */ glm::vec3 v1(10, -h1, 0); glm::vec3 v2(0, -h2, 0); glm::vec3 v3(10, -h3, 10); glm::vec3 v4(0, -h4, 10); glm::vec3 normal1 = glm::normalize(glm::cross(v4 - v3, v1 - v3)); glm::vec3 normal2 = glm::normalize(glm::cross(v1 - v2, v4 - v2)); normal = glm::normalize(normal1 + normal2); for (int i = 0; i < 4; i++) normals[i] = normal; } void Gnd::Cube::calcNormals(Gnd* gnd, int x, int y) { for (int i = 0; i < 4; i++) { normals[i] = glm::vec3(0, 0, 0); for (int ii = 0; ii < 4; ii++) { int xx = (ii % 2) * ((i % 2 == 0) ? -1 : 1); int yy = (ii / 2) * (i < 2 ? -1 : 1); if (x+xx >= 0 && x+xx < gnd->width && y+yy >= 0 && y+yy < gnd->height) normals[i] += gnd->cubes[x + xx][y + yy]->normal; } normals[i] = glm::normalize(normals[i]); } } void Gnd::makeLightmapsUnique() { std::set<int> taken; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (cubes[x][y]->tileUp == -1) continue; if (taken.find(cubes[x][y]->tileUp) == taken.end()) taken.insert(cubes[x][y]->tileUp); else { Tile* t = new Tile(*tiles[cubes[x][y]->tileUp]); cubes[x][y]->tileUp = tiles.size(); tiles.push_back(t); } } } taken.clear(); for (Tile* t : tiles) { if (taken.find(t->lightmapIndex) == taken.end()) taken.insert(t->lightmapIndex); else { Lightmap* l = new Lightmap(*lightmaps[t->lightmapIndex]); t->lightmapIndex = lightmaps.size(); lightmaps.push_back(l); } } } void Gnd::makeLightmapBorders() { makeLightmapsUnique(); Log::out << "Fixing borders" << Log::newline; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Gnd::Cube* cube = cubes[x][y]; int tileId = cube->tileUp; if (tileId == -1) continue; Gnd::Tile* tile = tiles[tileId]; assert(tile && tile->lightmapIndex != -1); Gnd::Lightmap* lightmap = lightmaps[tile->lightmapIndex]; for (int i = 0; i < 8; i++) { lightmap->data[i + 8 * 0] = getLightmapBrightness(x, y - 1, i, 6); lightmap->data[i + 8 * 7] = getLightmapBrightness(x, y + 1, i, 1); lightmap->data[0 + 8 * i] = getLightmapBrightness(x - 1, y, 6, i); lightmap->data[7 + 8 * i] = getLightmapBrightness(x + 1, y, 1, i); for (int c = 0; c < 3; c++) { lightmap->data[64 + 3 * (i + 8 * 0) + c] = getLightmapColor(x, y - 1, i, 6)[c]; lightmap->data[64 + 3 * (i + 8 * 7) + c] = getLightmapColor(x, y + 1, i, 1)[c]; lightmap->data[64 + 3 * (0 + 8 * i) + c] = getLightmapColor(x - 1, y, 6, i)[c]; lightmap->data[64 + 3 * (7 + 8 * i) + c] = getLightmapColor(x + 1, y, 1, i)[c]; } } } } } int Gnd::getLightmapBrightness(int x, int y, int lightmapX, int lightmapY) { if (x < 0 || y < 0 || x >= width || y >= height) return 0; Gnd::Cube* cube = cubes[x][y]; int tileId = cube->tileUp; if (tileId == -1) return 0; Gnd::Tile* tile = tiles[tileId]; assert(tile && tile->lightmapIndex != -1); Gnd::Lightmap* lightmap = lightmaps[tile->lightmapIndex]; return lightmap->data[lightmapX + 8 * lightmapY]; } glm::ivec3 Gnd::getLightmapColor(int x, int y, int lightmapX, int lightmapY) { if (x < 0 || y < 0 || x >= width || y >= height) return glm::ivec3(0, 0, 0); Gnd::Cube* cube = cubes[x][y]; int tileId = cube->tileUp; if (tileId == -1) return glm::ivec3(0,0,0); Gnd::Tile* tile = tiles[tileId]; assert(tile && tile->lightmapIndex != -1); Gnd::Lightmap* lightmap = lightmaps[tile->lightmapIndex]; return glm::ivec3( lightmap->data[64 + (lightmapX + 8 * lightmapY) * 3 + 0], lightmap->data[64 + (lightmapX + 8 * lightmapY) * 3 + 1], lightmap->data[64 + (lightmapX + 8 * lightmapY) * 3 + 2]); } void Gnd::makeLightmapsSmooth() { Log::out << "Smoothing..." << Log::newline; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Gnd::Cube* cube = cubes[x][y]; int tileId = cube->tileUp; if (tileId == -1) continue; Gnd::Tile* tile = tiles[tileId]; assert(tile && tile->lightmapIndex != -1); Gnd::Lightmap* lightmap = lightmaps[tile->lightmapIndex]; char newData[64]; for (int xx = 1; xx < 7; xx++) { for (int yy = 1; yy < 7; yy++) { int total = 0; for (int xxx = xx - 1; xxx <= xx + 1; xxx++) for (int yyy = yy - 1; yyy <= yy + 1; yyy++) total += lightmap->data[xxx + 8 * yyy]; newData[xx + 8 * yy] = total / 9; } } memcpy(lightmap->data, newData, 64 * sizeof(char)); } } }
9f9ec2d9e8d3286ec9c2c2a4da8cdc6f34fd3b85
7e62f0928681aaaecae7daf360bdd9166299b000
/external/DirectXShaderCompiler/tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
5ee7dc688d13495fcf700913df7a8a38d76a737e
[ "NCSA", "LicenseRef-scancode-unknown-license-reference" ]
permissive
yuri410/rpg
949b001bd0aec47e2a046421da0ff2a1db62ce34
266282ed8cfc7cd82e8c853f6f01706903c24628
refs/heads/master
2020-08-03T09:39:42.253100
2020-06-16T15:38:03
2020-06-16T15:38:03
211,698,323
0
0
null
null
null
null
UTF-8
C++
false
false
14,650
h
//===--- BugReporterVisitor.h - Generate PathDiagnostics -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file declares BugReporterVisitors, which are used to generate enhanced // diagnostic traces. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITOR_H #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITOR_H #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "llvm/ADT/FoldingSet.h" namespace clang { namespace ento { class BugReport; class BugReporterContext; class ExplodedNode; class MemRegion; class PathDiagnosticPiece; /// \brief BugReporterVisitors are used to add custom diagnostics along a path. /// /// Custom visitors should subclass the BugReporterVisitorImpl class for a /// default implementation of the clone() method. /// (Warning: if you have a deep subclass of BugReporterVisitorImpl, the /// default implementation of clone() will NOT do the right thing, and you /// will have to provide your own implementation.) class BugReporterVisitor : public llvm::FoldingSetNode { public: virtual ~BugReporterVisitor(); /// \brief Returns a copy of this BugReporter. /// /// Custom BugReporterVisitors should not override this method directly. /// Instead, they should inherit from BugReporterVisitorImpl and provide /// a protected or public copy constructor. /// /// (Warning: if you have a deep subclass of BugReporterVisitorImpl, the /// default implementation of clone() will NOT do the right thing, and you /// will have to provide your own implementation.) virtual std::unique_ptr<BugReporterVisitor> clone() const = 0; /// \brief Return a diagnostic piece which should be associated with the /// given node. /// /// The last parameter can be used to register a new visitor with the given /// BugReport while processing a node. virtual PathDiagnosticPiece *VisitNode(const ExplodedNode *Succ, const ExplodedNode *Pred, BugReporterContext &BRC, BugReport &BR) = 0; /// \brief Provide custom definition for the final diagnostic piece on the /// path - the piece, which is displayed before the path is expanded. /// /// If returns NULL the default implementation will be used. /// Also note that at most one visitor of a BugReport should generate a /// non-NULL end of path diagnostic piece. virtual std::unique_ptr<PathDiagnosticPiece> getEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR); virtual void Profile(llvm::FoldingSetNodeID &ID) const = 0; /// \brief Generates the default final diagnostic piece. static std::unique_ptr<PathDiagnosticPiece> getDefaultEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR); }; /// This class provides a convenience implementation for clone() using the /// Curiously-Recurring Template Pattern. If you are implementing a custom /// BugReporterVisitor, subclass BugReporterVisitorImpl and provide a public /// or protected copy constructor. /// /// (Warning: if you have a deep subclass of BugReporterVisitorImpl, the /// default implementation of clone() will NOT do the right thing, and you /// will have to provide your own implementation.) template <class DERIVED> class BugReporterVisitorImpl : public BugReporterVisitor { std::unique_ptr<BugReporterVisitor> clone() const override { return llvm::make_unique<DERIVED>(*static_cast<const DERIVED *>(this)); } }; class FindLastStoreBRVisitor : public BugReporterVisitorImpl<FindLastStoreBRVisitor> { const MemRegion *R; SVal V; bool Satisfied; /// If the visitor is tracking the value directly responsible for the /// bug, we are going to employ false positive suppression. bool EnableNullFPSuppression; public: /// Creates a visitor for every VarDecl inside a Stmt and registers it with /// the BugReport. static void registerStatementVarDecls(BugReport &BR, const Stmt *S, bool EnableNullFPSuppression); FindLastStoreBRVisitor(KnownSVal V, const MemRegion *R, bool InEnableNullFPSuppression) : R(R), V(V), Satisfied(false), EnableNullFPSuppression(InEnableNullFPSuppression) {} void Profile(llvm::FoldingSetNodeID &ID) const override; PathDiagnosticPiece *VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) override; }; class TrackConstraintBRVisitor : public BugReporterVisitorImpl<TrackConstraintBRVisitor> { DefinedSVal Constraint; bool Assumption; bool IsSatisfied; bool IsZeroCheck; /// We should start tracking from the last node along the path in which the /// value is constrained. bool IsTrackingTurnedOn; public: TrackConstraintBRVisitor(DefinedSVal constraint, bool assumption) : Constraint(constraint), Assumption(assumption), IsSatisfied(false), IsZeroCheck(!Assumption && Constraint.getAs<Loc>()), IsTrackingTurnedOn(false) {} void Profile(llvm::FoldingSetNodeID &ID) const override; /// Return the tag associated with this visitor. This tag will be used /// to make all PathDiagnosticPieces created by this visitor. static const char *getTag(); PathDiagnosticPiece *VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) override; private: /// Checks if the constraint is valid in the current state. bool isUnderconstrained(const ExplodedNode *N) const; }; /// \class NilReceiverBRVisitor /// \brief Prints path notes when a message is sent to a nil receiver. class NilReceiverBRVisitor : public BugReporterVisitorImpl<NilReceiverBRVisitor> { public: void Profile(llvm::FoldingSetNodeID &ID) const override { static int x = 0; ID.AddPointer(&x); } PathDiagnosticPiece *VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) override; /// If the statement is a message send expression with nil receiver, returns /// the receiver expression. Returns NULL otherwise. static const Expr *getNilReceiver(const Stmt *S, const ExplodedNode *N); }; /// Visitor that tries to report interesting diagnostics from conditions. class ConditionBRVisitor : public BugReporterVisitorImpl<ConditionBRVisitor> { public: void Profile(llvm::FoldingSetNodeID &ID) const override { static int x = 0; ID.AddPointer(&x); } /// Return the tag associated with this visitor. This tag will be used /// to make all PathDiagnosticPieces created by this visitor. static const char *getTag(); PathDiagnosticPiece *VisitNode(const ExplodedNode *N, const ExplodedNode *Prev, BugReporterContext &BRC, BugReport &BR) override; PathDiagnosticPiece *VisitNodeImpl(const ExplodedNode *N, const ExplodedNode *Prev, BugReporterContext &BRC, BugReport &BR); PathDiagnosticPiece *VisitTerminator(const Stmt *Term, const ExplodedNode *N, const CFGBlock *srcBlk, const CFGBlock *dstBlk, BugReport &R, BugReporterContext &BRC); PathDiagnosticPiece *VisitTrueTest(const Expr *Cond, bool tookTrue, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N); PathDiagnosticPiece *VisitTrueTest(const Expr *Cond, const DeclRefExpr *DR, const bool tookTrue, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N); PathDiagnosticPiece *VisitTrueTest(const Expr *Cond, const BinaryOperator *BExpr, const bool tookTrue, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N); PathDiagnosticPiece *VisitConditionVariable(StringRef LhsString, const Expr *CondVarExpr, const bool tookTrue, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N); bool patternMatch(const Expr *Ex, raw_ostream &Out, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N, Optional<bool> &prunable); }; /// \brief Suppress reports that might lead to known false positives. /// /// Currently this suppresses reports based on locations of bugs. class LikelyFalsePositiveSuppressionBRVisitor : public BugReporterVisitorImpl<LikelyFalsePositiveSuppressionBRVisitor> { public: static void *getTag() { static int Tag = 0; return static_cast<void *>(&Tag); } void Profile(llvm::FoldingSetNodeID &ID) const override { ID.AddPointer(getTag()); } PathDiagnosticPiece *VisitNode(const ExplodedNode *N, const ExplodedNode *Prev, BugReporterContext &BRC, BugReport &BR) override { return nullptr; } std::unique_ptr<PathDiagnosticPiece> getEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR) override; }; /// \brief When a region containing undefined value or '0' value is passed /// as an argument in a call, marks the call as interesting. /// /// As a result, BugReporter will not prune the path through the function even /// if the region's contents are not modified/accessed by the call. class UndefOrNullArgVisitor : public BugReporterVisitorImpl<UndefOrNullArgVisitor> { /// The interesting memory region this visitor is tracking. const MemRegion *R; public: UndefOrNullArgVisitor(const MemRegion *InR) : R(InR) {} void Profile(llvm::FoldingSetNodeID &ID) const override { static int Tag = 0; ID.AddPointer(&Tag); ID.AddPointer(R); } PathDiagnosticPiece *VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) override; }; class SuppressInlineDefensiveChecksVisitor : public BugReporterVisitorImpl<SuppressInlineDefensiveChecksVisitor> { /// The symbolic value for which we are tracking constraints. /// This value is constrained to null in the end of path. DefinedSVal V; /// Track if we found the node where the constraint was first added. bool IsSatisfied; /// Since the visitors can be registered on nodes previous to the last /// node in the BugReport, but the path traversal always starts with the last /// node, the visitor invariant (that we start with a node in which V is null) /// might not hold when node visitation starts. We are going to start tracking /// from the last node in which the value is null. bool IsTrackingTurnedOn; public: SuppressInlineDefensiveChecksVisitor(DefinedSVal Val, const ExplodedNode *N); void Profile(llvm::FoldingSetNodeID &ID) const override; /// Return the tag associated with this visitor. This tag will be used /// to make all PathDiagnosticPieces created by this visitor. static const char *getTag(); PathDiagnosticPiece *VisitNode(const ExplodedNode *Succ, const ExplodedNode *Pred, BugReporterContext &BRC, BugReport &BR) override; }; namespace bugreporter { /// Attempts to add visitors to trace a null or undefined value back to its /// point of origin, whether it is a symbol constrained to null or an explicit /// assignment. /// /// \param N A node "downstream" from the evaluation of the statement. /// \param S The statement whose value is null or undefined. /// \param R The bug report to which visitors should be attached. /// \param IsArg Whether the statement is an argument to an inlined function. /// If this is the case, \p N \em must be the CallEnter node for /// the function. /// \param EnableNullFPSuppression Whether we should employ false positive /// suppression (inlined defensive checks, returned null). /// /// \return Whether or not the function was able to add visitors for this /// statement. Note that returning \c true does not actually imply /// that any visitors were added. bool trackNullOrUndefValue(const ExplodedNode *N, const Stmt *S, BugReport &R, bool IsArg = false, bool EnableNullFPSuppression = true); const Expr *getDerefExpr(const Stmt *S); const Stmt *GetDenomExpr(const ExplodedNode *N); const Stmt *GetRetValExpr(const ExplodedNode *N); bool isDeclRefExprToReference(const Expr *E); } // end namespace clang } // end namespace ento } // end namespace bugreporter #endif
cec8874d02a580827c73a2d3f8f4c2f078462aa6
88c24b5c352dfaa6e1c6dc0c9495b4f3b8b5e7fe
/src/skland/gui/internal/commit-task.hpp
7a811e2280231d13665662c6bb593ca26456156a
[ "Apache-2.0" ]
permissive
ttldtor/skland
4edb880eed685e5259cbdd4b096c89bd2c0ba281
cd012a2d0df2ba63902adbe25bcc4c9b5df72cfa
refs/heads/master
2021-01-20T03:06:11.251587
2017-02-28T09:17:52
2017-02-28T09:17:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,108
hpp
/* * Copyright 2016 Freeman Zhang <[email protected]> * * 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 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SKLAND_GUI_INTERNAL_COMMIT_TASK_HPP_ #define SKLAND_GUI_INTERNAL_COMMIT_TASK_HPP_ #include <skland/gui/task.hpp> namespace skland { class Surface; struct CommitTask : public Task { CommitTask(const CommitTask &) = delete; CommitTask &operator=(const CommitTask &) = delete; CommitTask(Surface *surface) : Task(), surface(surface) {} virtual ~CommitTask() {} virtual void Run() const; Surface *surface; }; } #endif // SKLAND_GUI_INTERNAL_COMMIT_TASK_HPP_
1eb5a16a1fbfc7db03f2fda6230c29638e972a10
949c10f93c05d2658e5ba7c8ed2e87b58ce770e0
/Oriantation/0d_01.RefacterOrientation(EnemyBase)/Enemy3.h
20854e58a166ce16ab2ae7739d0f0b6d04f95918
[]
no_license
vm-t-yui/school
364078da802698991ea961e86459437c4753e70b
e33891bff32b29999a5c87941209cb8d50c86166
refs/heads/master
2023-07-21T10:16:33.984459
2023-07-06T01:38:12
2023-07-06T01:38:12
191,517,637
0
21
null
null
null
null
UTF-8
C++
false
false
237
h
#pragma once #include "Common.h" #include "EnemyBase.h" /// <summary> /// 大きくて固いエネミー /// </summary> class Enemy3 : public EnemyBase { public: void Init(); // 初期化 void Update(); // アップデート };
7cb367865d418b9b0343851a1b48651c70965e36
f10d1b91d98932ad5d208d0dd84f4c4a9b28df7f
/src/cryptonote_basic/account_boost_serialization.h
00b4bef774fc2a210fc7597a7b01e8b7f7654680
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
yagamidev/ditTest
4ff157817a412a25c87259dcd3c27dd1d03867f4
5d94cf6b9d91a4d104f341b896509f5738d22341
refs/heads/master
2021-01-24T09:17:12.335368
2018-02-26T20:36:49
2018-02-26T20:36:49
123,006,852
0
0
null
null
null
null
UTF-8
C++
false
false
2,320
h
// Copyright (c) 2014-2017, The Ditcoin Project // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once #include "account.h" #include "cryptonote_boost_serialization.h" //namespace cryptonote { namespace boost { namespace serialization { template <class Archive> inline void serialize(Archive &a, cryptonote::account_keys &x, const boost::serialization::version_type ver) { a & x.m_account_address; a & x.m_spend_secret_key; a & x.m_view_secret_key; } template <class Archive> inline void serialize(Archive &a, cryptonote::account_public_address &x, const boost::serialization::version_type ver) { a & x.m_spend_public_key; a & x.m_view_public_key; } } }
8ecc12309b5f89d9068b0aa40869a35272af4b26
e97a088590c4292e4817403d36971e25e27718ac
/test/testset0002.cpp
3eb78956aa1c690e74300278da6a4e35248428f6
[]
no_license
chuffman93/cdh-fsw
aa898d6d98fedbb8fe814f1ba6049b173818e80f
b56ec0cd6c40b882e03ae78aab0be7868881ce6d
refs/heads/master
2020-04-14T21:33:43.373147
2019-01-04T16:58:29
2019-01-04T16:58:29
164,132,853
0
0
null
null
null
null
UTF-8
C++
false
false
1,016
cpp
/*! \file testset0002.cpp * Created on: Jul 9, 2014 * Author: fsw * * \brief Test 2 of the Setting Class. * * This test verifies that the constructor with ConfigItemType * and VariableTypeData parameters correctly initalizes item and data * to the parameter's values. * */ #include <iostream> #include "POSIX.h" #include "gtest/gtest.h" #include "core/Setting.h" using namespace std; using namespace rel_ops; using namespace AllStar::Core; #define TEST_VALUE "wow" #define TEST_CONFIG 234 TEST(TestSetting, Constructor2) { VariableTypeData v1(TEST_VALUE); Setting s1(TEST_CONFIG, v1); // Check item if (s1.GetItem() != TEST_CONFIG) { cout << "Default constructor for Setting failed to set item to parameter's value." << endl; ASSERT_TRUE(false); } // Check data if (s1.GetValue() != v1) { cout << "Default constructor for Setting failed to initialize data with parameter's value." << endl; ASSERT_TRUE(false); } }
852148c5e37d003b78d6c05fdcad3fd9b07fbd7b
f7ea85a1afbf3909464ee7bffcfc6a96d91be3be
/OOP_lab3/OOP_lab3/Engineer.h
75c197d998ebb9b7639966b57c04ceda2ba15d07
[]
no_license
NikitaMel456/OOP11
408385950b9879c36871d0b167feb8e202baf23f
5e7d07e24137998d2c5d2f0e0c6678321f72fe00
refs/heads/master
2020-12-25T14:48:37.999542
2016-12-27T17:44:02
2016-12-27T17:44:02
67,273,489
0
0
null
null
null
null
UTF-8
C++
false
false
211
h
#pragma once #include "stdafx.h" #include "Worker.h" #include <string> class Engineer: public Worker { string sphere; public: Engineer(void); ~Engineer(void); void setSphere(string); void getSphere(); };
5531fa07e3ad324346f8992020c88c99f066ab1e
3c0e44329641e7f47eb0b0c432cc0fea33a75b01
/reverseList/solution.cpp
c8edfca0928f178235b03d3c62169111300b3d98
[]
no_license
ysatiche/algorithmInn
eaaa86c766b854ee417c1220a663667b64dcf8d4
96d33986fe767ade9bc1a5ee5e9fa1069dbb923c
refs/heads/master
2022-12-02T03:53:48.967476
2020-08-26T08:18:37
2020-08-26T08:18:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
794
cpp
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* ReverseList(ListNode* head) { // 链表为空返回null if(head==NULL) return NULL; ListNode *newHead = NULL; ListNode *pNode = head; ListNode *pPrev = NULL; //遍历链表的每个节点 while(pNode!=NULL){ // 新建节点,初始化为当前节点的下一个节点 ListNode *pNext = pNode->next; if(pNext==NULL) newHead = pNode; // 前后节点置换 pNode->next = pPrev; pPrev = pNode; pNode = pNext; } return newHead; } };
44ae0f1e051369aa733326988bd35ff37ea6296b
a84fede257786041f970501e9d2c7cb81392570f
/01输入输出/08字符三角形.cpp
1b288f116a93f50f44555c020ec0165fb60c5b6e
[]
no_license
Satar07/code
9e7a453bc142297d2f45da7cd083bc3f560f2ff9
8a2e4ceb14e08d98f05b38f6a96402e641dd5d74
refs/heads/master
2023-04-05T16:46:23.466637
2021-05-07T10:32:06
2021-05-07T10:32:06
335,522,020
0
0
null
null
null
null
UTF-8
C++
false
false
182
cpp
#include<iostream> #include<cstdio> using namespace std; int main(){ char a; cin>>a; cout<<" "<<a<<endl; cout<<" "<<a<<a<<a<<endl; cout<<a<<a<<a<<a<<a<<endl; return 0; }
4a8d6e9de5c3aab9bbfe69f79444a8bdf92e6265
04251e142abab46720229970dab4f7060456d361
/lib/rosetta/source/src/protocols/evolution/AlignmentAAFinderFilter.hh
ca68a9067db92890ef13074a6911e210d697e8b9
[]
no_license
sailfish009/binding_affinity_calculator
216257449a627d196709f9743ca58d8764043f12
7af9ce221519e373aa823dadc2005de7a377670d
refs/heads/master
2022-12-29T11:15:45.164881
2020-10-22T09:35:32
2020-10-22T09:35:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,436
hh
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*- // vi: set ts=2 noet: // // (c) Copyright Rosetta Commons Member Institutions. // (c) This file is part of the Rosetta software suite and is made available under license. // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. // (c) For more information, see http://www.rosettacommons.org. Questions about this can be // (c) addressed to University of Washington CoMotion, email: [email protected]. /// @file protocols/evolution/AlignmentAAFinderFilter.hh #ifndef INCLUDED_protocols_evolution_AlignmentAAFinderFilter_hh #define INCLUDED_protocols_evolution_AlignmentAAFinderFilter_hh //unit headers #include <protocols/evolution/AlignmentAAFinderFilter.fwd.hh> // Project Headers #include <protocols/filters/Filter.hh> #include <core/pose/Pose.fwd.hh> #include <basic/datacache/DataMap.fwd.hh> #include <protocols/moves/Mover.fwd.hh> #include <core/scoring/ScoreFunction.fwd.hh> #include <utility/vector1.hh> typedef utility::vector1< bool > bools; namespace protocols { namespace evolution { /// @brief test whether a pose contains a comment that evaluates to a predefined value. This is useful in controlling execution flow in RosettaScripts. class AlignmentAAFinder : public filters::Filter { public: AlignmentAAFinder(); ~AlignmentAAFinder() override; filters::FilterOP clone() const override { return utility::pointer::make_shared< AlignmentAAFinder >( *this ); } filters::FilterOP fresh_instance() const override{ return utility::pointer::make_shared< AlignmentAAFinder >(); } bool apply( core::pose::Pose const & p ) const override; void report( std::ostream & out, core::pose::Pose const & pose ) const override; core::Real report_sm( core::pose::Pose const & pose ) const override; void parse_my_tag( utility::tag::TagCOP tag, basic::datacache::DataMap &data ) override; core::Real exclude_AA_threshold() const { return exclude_AA_threshold_; } void exclude_AA_threshold( core::Real const & t ) { exclude_AA_threshold_ = t; } std::string alignment_file() const { return alignment_file_; } void alignment_file( std::string const & a ) { alignment_file_ = a; } std::string available_AAs_file() const { return available_AAs_file_; } void available_AAs_file( std::string const & a ) { available_AAs_file_ = a; } core::Size indel_motif_radius() const { return indel_motif_radius_; } void indel_motif_radius( core::Size const & r ) { indel_motif_radius_ = r; } core::Real loop_seqid_threshold() const { return loop_seqid_threshold_; } void loop_seqid_threshold( core::Real const & t ) { loop_seqid_threshold_ = t; } core::scoring::ScoreFunctionOP scorefxn() const{ return scorefxn_; } void scorefxn( core::scoring::ScoreFunctionOP scorefxn ) { scorefxn_ = scorefxn; } protocols::moves::MoverOP relax_mover() const { return relax_mover_; }; void relax_mover( protocols::moves::MoverOP mover ) { relax_mover_ = mover; }; std::string name() const override; static std::string class_name(); static void provide_xml_schema( utility::tag::XMLSchemaDefinition & xsd ); private: core::Real exclude_AA_threshold_; std::string alignment_file_; std::string available_AAs_file_; core::Size indel_motif_radius_; core::Real loop_seqid_threshold_; core::scoring::ScoreFunctionOP scorefxn_; protocols::moves::MoverOP relax_mover_; }; } } #endif
e9fca6d0c000af9ed3f6a00493b0797bfe6929e7
56a93dd9fc7fb7a64b58d784a880d90e59f23b07
/Code/Struct/FlyWeight/main.cpp
590d25cf84dd49b15dfc73a5ed092d2bf4586f22
[]
no_license
shadow-lr/LearnDesignPattern
84c058779470ba67c819f4b4024a9e8f12f12679
b4d271f29e0b9ac870b7445102024f1767bbd49b
refs/heads/main
2023-05-29T14:03:42.566002
2021-06-22T03:26:29
2021-06-22T03:26:29
371,347,801
2
0
null
null
null
null
UTF-8
C++
false
false
468
cpp
#include "Flyweight.h" #include "ConcreteFlyweight.h" #include "FlyweightFactory.h" #include <iostream> #include <memory> // 享元模式 int main() { { std::shared_ptr<FlyweightFactory> fc = std::make_shared<FlyweightFactory>(); std::shared_ptr<Flyweight> fw1 = fc->GetFlyweight("hello"); std::shared_ptr<Flyweight> fw2 = fc->GetFlyweight("world"); std::shared_ptr<Flyweight> fw3 = fc->GetFlyweight("hello"); } }
bb4053d55c32106c0f3332c29fb3587ce8a171ec
dfc6089491650208bc4fe5ccc6e153d770789447
/Bullet/src/Bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
daa33cf990bddc10ea1994d471d1ea8927a8ed57
[ "Zlib", "MIT" ]
permissive
BertilBraun/Oath3D
669aad253eb7c342e8c6226b8d778f056e69efd4
e713f4f97bd1998d6c7a67414ff5f80d6d30e7f9
refs/heads/master
2020-04-15T23:09:57.475019
2020-03-08T20:09:01
2020-03-08T20:09:01
165,096,271
3
1
null
null
null
null
UTF-8
C++
false
false
105,025
cpp
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ //#define COMPUTE_IMPULSE_DENOM 1 //#define BT_ADDITIONAL_DEBUG //It is not necessary (redundant) to refresh contact manifolds, this refresh has been moved to the collision algorithms. #include "btSequentialImpulseConstraintSolver.h" #include "Bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" #include "Bullet/LinearMath/btIDebugDraw.h" #include "Bullet/LinearMath/btCpuFeatureUtility.h" //#include "btJacobianEntry.h" #include "Bullet/LinearMath/btMinMax.h" #include "Bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.h" #include <new> #include "Bullet/LinearMath/btStackAlloc.h" #include "Bullet/LinearMath/btQuickprof.h" //#include "btSolverBody.h" //#include "btSolverConstraint.h" #include "Bullet/LinearMath/btAlignedObjectArray.h" #include <string.h> //for memset int gNumSplitImpulseRecoveries = 0; #include "Bullet/BulletDynamics/Dynamics/btRigidBody.h" //#define VERBOSE_RESIDUAL_PRINTF 1 ///This is the scalar reference implementation of solving a single constraint row, the innerloop of the Projected Gauss Seidel/Sequential Impulse constraint solver ///Below are optional SSE2 and SSE4/FMA3 versions. We assume most hardware has SSE2. For SSE4/FMA3 we perform a CPU feature check. static btScalar gResolveSingleConstraintRowGeneric_scalar_reference(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { btScalar deltaImpulse = c.m_rhs - btScalar(c.m_appliedImpulse) * c.m_cfm; const btScalar deltaVel1Dotn = c.m_contactNormal1.dot(bodyA.internalGetDeltaLinearVelocity()) + c.m_relpos1CrossNormal.dot(bodyA.internalGetDeltaAngularVelocity()); const btScalar deltaVel2Dotn = c.m_contactNormal2.dot(bodyB.internalGetDeltaLinearVelocity()) + c.m_relpos2CrossNormal.dot(bodyB.internalGetDeltaAngularVelocity()); // const btScalar delta_rel_vel = deltaVel1Dotn-deltaVel2Dotn; deltaImpulse -= deltaVel1Dotn * c.m_jacDiagABInv; deltaImpulse -= deltaVel2Dotn * c.m_jacDiagABInv; const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; if (sum < c.m_lowerLimit) { deltaImpulse = c.m_lowerLimit - c.m_appliedImpulse; c.m_appliedImpulse = c.m_lowerLimit; } else if (sum > c.m_upperLimit) { deltaImpulse = c.m_upperLimit - c.m_appliedImpulse; c.m_appliedImpulse = c.m_upperLimit; } else { c.m_appliedImpulse = sum; } bodyA.internalApplyImpulse(c.m_contactNormal1 * bodyA.internalGetInvMass(), c.m_angularComponentA, deltaImpulse); bodyB.internalApplyImpulse(c.m_contactNormal2 * bodyB.internalGetInvMass(), c.m_angularComponentB, deltaImpulse); return deltaImpulse * (1. / c.m_jacDiagABInv); } static btScalar gResolveSingleConstraintRowLowerLimit_scalar_reference(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { btScalar deltaImpulse = c.m_rhs - btScalar(c.m_appliedImpulse) * c.m_cfm; const btScalar deltaVel1Dotn = c.m_contactNormal1.dot(bodyA.internalGetDeltaLinearVelocity()) + c.m_relpos1CrossNormal.dot(bodyA.internalGetDeltaAngularVelocity()); const btScalar deltaVel2Dotn = c.m_contactNormal2.dot(bodyB.internalGetDeltaLinearVelocity()) + c.m_relpos2CrossNormal.dot(bodyB.internalGetDeltaAngularVelocity()); deltaImpulse -= deltaVel1Dotn * c.m_jacDiagABInv; deltaImpulse -= deltaVel2Dotn * c.m_jacDiagABInv; const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; if (sum < c.m_lowerLimit) { deltaImpulse = c.m_lowerLimit - c.m_appliedImpulse; c.m_appliedImpulse = c.m_lowerLimit; } else { c.m_appliedImpulse = sum; } bodyA.internalApplyImpulse(c.m_contactNormal1 * bodyA.internalGetInvMass(), c.m_angularComponentA, deltaImpulse); bodyB.internalApplyImpulse(c.m_contactNormal2 * bodyB.internalGetInvMass(), c.m_angularComponentB, deltaImpulse); return deltaImpulse * (1. / c.m_jacDiagABInv); } #ifdef USE_SIMD #include <emmintrin.h> #define btVecSplat(x, e) _mm_shuffle_ps(x, x, _MM_SHUFFLE(e, e, e, e)) static inline __m128 btSimdDot3(__m128 vec0, __m128 vec1) { __m128 result = _mm_mul_ps(vec0, vec1); return _mm_add_ps(btVecSplat(result, 0), _mm_add_ps(btVecSplat(result, 1), btVecSplat(result, 2))); } #if defined(BT_ALLOW_SSE4) #include <intrin.h> #define USE_FMA 1 #define USE_FMA3_INSTEAD_FMA4 1 #define USE_SSE4_DOT 1 #define SSE4_DP(a, b) _mm_dp_ps(a, b, 0x7f) #define SSE4_DP_FP(a, b) _mm_cvtss_f32(_mm_dp_ps(a, b, 0x7f)) #if USE_SSE4_DOT #define DOT_PRODUCT(a, b) SSE4_DP(a, b) #else #define DOT_PRODUCT(a, b) btSimdDot3(a, b) #endif #if USE_FMA #if USE_FMA3_INSTEAD_FMA4 // a*b + c #define FMADD(a, b, c) _mm_fmadd_ps(a, b, c) // -(a*b) + c #define FMNADD(a, b, c) _mm_fnmadd_ps(a, b, c) #else // USE_FMA3 // a*b + c #define FMADD(a, b, c) _mm_macc_ps(a, b, c) // -(a*b) + c #define FMNADD(a, b, c) _mm_nmacc_ps(a, b, c) #endif #else // USE_FMA // c + a*b #define FMADD(a, b, c) _mm_add_ps(c, _mm_mul_ps(a, b)) // c - a*b #define FMNADD(a, b, c) _mm_sub_ps(c, _mm_mul_ps(a, b)) #endif #endif // Project Gauss Seidel or the equivalent Sequential Impulse static btScalar gResolveSingleConstraintRowGeneric_sse2(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedImpulse); __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); btSimdScalar deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse), _mm_set1_ps(c.m_cfm))); __m128 deltaVel1Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal1.mVec128, bodyA.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos1CrossNormal.mVec128, bodyA.internalGetDeltaAngularVelocity().mVec128)); __m128 deltaVel2Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal2.mVec128, bodyB.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos2CrossNormal.mVec128, bodyB.internalGetDeltaAngularVelocity().mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse, _mm_mul_ps(deltaVel1Dotn, _mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse, _mm_mul_ps(deltaVel2Dotn, _mm_set1_ps(c.m_jacDiagABInv))); btSimdScalar sum = _mm_add_ps(cpAppliedImp, deltaImpulse); btSimdScalar resultLowerLess, resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum, lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum, upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1, cpAppliedImp); deltaImpulse = _mm_or_ps(_mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse)); c.m_appliedImpulse = _mm_or_ps(_mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum)); __m128 upperMinApplied = _mm_sub_ps(upperLimit1, cpAppliedImp); deltaImpulse = _mm_or_ps(_mm_and_ps(resultUpperLess, deltaImpulse), _mm_andnot_ps(resultUpperLess, upperMinApplied)); c.m_appliedImpulse = _mm_or_ps(_mm_and_ps(resultUpperLess, c.m_appliedImpulse), _mm_andnot_ps(resultUpperLess, upperLimit1)); __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal1.mVec128, bodyA.internalGetInvMass().mVec128); __m128 linearComponentB = _mm_mul_ps((c.m_contactNormal2).mVec128, bodyB.internalGetInvMass().mVec128); __m128 impulseMagnitude = deltaImpulse; bodyA.internalGetDeltaLinearVelocity().mVec128 = _mm_add_ps(bodyA.internalGetDeltaLinearVelocity().mVec128, _mm_mul_ps(linearComponentA, impulseMagnitude)); bodyA.internalGetDeltaAngularVelocity().mVec128 = _mm_add_ps(bodyA.internalGetDeltaAngularVelocity().mVec128, _mm_mul_ps(c.m_angularComponentA.mVec128, impulseMagnitude)); bodyB.internalGetDeltaLinearVelocity().mVec128 = _mm_add_ps(bodyB.internalGetDeltaLinearVelocity().mVec128, _mm_mul_ps(linearComponentB, impulseMagnitude)); bodyB.internalGetDeltaAngularVelocity().mVec128 = _mm_add_ps(bodyB.internalGetDeltaAngularVelocity().mVec128, _mm_mul_ps(c.m_angularComponentB.mVec128, impulseMagnitude)); return deltaImpulse.m_floats[0] / c.m_jacDiagABInv; } // Enhanced version of gResolveSingleConstraintRowGeneric_sse2 with SSE4.1 and FMA3 static btScalar gResolveSingleConstraintRowGeneric_sse4_1_fma3(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { #if defined(BT_ALLOW_SSE4) __m128 tmp = _mm_set_ps1(c.m_jacDiagABInv); __m128 deltaImpulse = _mm_set_ps1(c.m_rhs - btScalar(c.m_appliedImpulse) * c.m_cfm); const __m128 lowerLimit = _mm_set_ps1(c.m_lowerLimit); const __m128 upperLimit = _mm_set_ps1(c.m_upperLimit); const __m128 deltaVel1Dotn = _mm_add_ps(DOT_PRODUCT(c.m_contactNormal1.mVec128, bodyA.internalGetDeltaLinearVelocity().mVec128), DOT_PRODUCT(c.m_relpos1CrossNormal.mVec128, bodyA.internalGetDeltaAngularVelocity().mVec128)); const __m128 deltaVel2Dotn = _mm_add_ps(DOT_PRODUCT(c.m_contactNormal2.mVec128, bodyB.internalGetDeltaLinearVelocity().mVec128), DOT_PRODUCT(c.m_relpos2CrossNormal.mVec128, bodyB.internalGetDeltaAngularVelocity().mVec128)); deltaImpulse = FMNADD(deltaVel1Dotn, tmp, deltaImpulse); deltaImpulse = FMNADD(deltaVel2Dotn, tmp, deltaImpulse); tmp = _mm_add_ps(c.m_appliedImpulse, deltaImpulse); // sum const __m128 maskLower = _mm_cmpgt_ps(tmp, lowerLimit); const __m128 maskUpper = _mm_cmpgt_ps(upperLimit, tmp); deltaImpulse = _mm_blendv_ps(_mm_sub_ps(lowerLimit, c.m_appliedImpulse), _mm_blendv_ps(_mm_sub_ps(upperLimit, c.m_appliedImpulse), deltaImpulse, maskUpper), maskLower); c.m_appliedImpulse = _mm_blendv_ps(lowerLimit, _mm_blendv_ps(upperLimit, tmp, maskUpper), maskLower); bodyA.internalGetDeltaLinearVelocity().mVec128 = FMADD(_mm_mul_ps(c.m_contactNormal1.mVec128, bodyA.internalGetInvMass().mVec128), deltaImpulse, bodyA.internalGetDeltaLinearVelocity().mVec128); bodyA.internalGetDeltaAngularVelocity().mVec128 = FMADD(c.m_angularComponentA.mVec128, deltaImpulse, bodyA.internalGetDeltaAngularVelocity().mVec128); bodyB.internalGetDeltaLinearVelocity().mVec128 = FMADD(_mm_mul_ps(c.m_contactNormal2.mVec128, bodyB.internalGetInvMass().mVec128), deltaImpulse, bodyB.internalGetDeltaLinearVelocity().mVec128); bodyB.internalGetDeltaAngularVelocity().mVec128 = FMADD(c.m_angularComponentB.mVec128, deltaImpulse, bodyB.internalGetDeltaAngularVelocity().mVec128); btSimdScalar deltaImp = deltaImpulse; return deltaImp.m_floats[0] * (1. / c.m_jacDiagABInv); #else return gResolveSingleConstraintRowGeneric_sse2(bodyA, bodyB, c); #endif } static btScalar gResolveSingleConstraintRowLowerLimit_sse2(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedImpulse); __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); btSimdScalar deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse), _mm_set1_ps(c.m_cfm))); __m128 deltaVel1Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal1.mVec128, bodyA.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos1CrossNormal.mVec128, bodyA.internalGetDeltaAngularVelocity().mVec128)); __m128 deltaVel2Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal2.mVec128, bodyB.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos2CrossNormal.mVec128, bodyB.internalGetDeltaAngularVelocity().mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse, _mm_mul_ps(deltaVel1Dotn, _mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse, _mm_mul_ps(deltaVel2Dotn, _mm_set1_ps(c.m_jacDiagABInv))); btSimdScalar sum = _mm_add_ps(cpAppliedImp, deltaImpulse); btSimdScalar resultLowerLess, resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum, lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum, upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1, cpAppliedImp); deltaImpulse = _mm_or_ps(_mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse)); c.m_appliedImpulse = _mm_or_ps(_mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum)); __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal1.mVec128, bodyA.internalGetInvMass().mVec128); __m128 linearComponentB = _mm_mul_ps(c.m_contactNormal2.mVec128, bodyB.internalGetInvMass().mVec128); __m128 impulseMagnitude = deltaImpulse; bodyA.internalGetDeltaLinearVelocity().mVec128 = _mm_add_ps(bodyA.internalGetDeltaLinearVelocity().mVec128, _mm_mul_ps(linearComponentA, impulseMagnitude)); bodyA.internalGetDeltaAngularVelocity().mVec128 = _mm_add_ps(bodyA.internalGetDeltaAngularVelocity().mVec128, _mm_mul_ps(c.m_angularComponentA.mVec128, impulseMagnitude)); bodyB.internalGetDeltaLinearVelocity().mVec128 = _mm_add_ps(bodyB.internalGetDeltaLinearVelocity().mVec128, _mm_mul_ps(linearComponentB, impulseMagnitude)); bodyB.internalGetDeltaAngularVelocity().mVec128 = _mm_add_ps(bodyB.internalGetDeltaAngularVelocity().mVec128, _mm_mul_ps(c.m_angularComponentB.mVec128, impulseMagnitude)); return deltaImpulse.m_floats[0] / c.m_jacDiagABInv; } // Enhanced version of gResolveSingleConstraintRowGeneric_sse2 with SSE4.1 and FMA3 static btScalar gResolveSingleConstraintRowLowerLimit_sse4_1_fma3(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { #ifdef BT_ALLOW_SSE4 __m128 tmp = _mm_set_ps1(c.m_jacDiagABInv); __m128 deltaImpulse = _mm_set_ps1(c.m_rhs - btScalar(c.m_appliedImpulse) * c.m_cfm); const __m128 lowerLimit = _mm_set_ps1(c.m_lowerLimit); const __m128 deltaVel1Dotn = _mm_add_ps(DOT_PRODUCT(c.m_contactNormal1.mVec128, bodyA.internalGetDeltaLinearVelocity().mVec128), DOT_PRODUCT(c.m_relpos1CrossNormal.mVec128, bodyA.internalGetDeltaAngularVelocity().mVec128)); const __m128 deltaVel2Dotn = _mm_add_ps(DOT_PRODUCT(c.m_contactNormal2.mVec128, bodyB.internalGetDeltaLinearVelocity().mVec128), DOT_PRODUCT(c.m_relpos2CrossNormal.mVec128, bodyB.internalGetDeltaAngularVelocity().mVec128)); deltaImpulse = FMNADD(deltaVel1Dotn, tmp, deltaImpulse); deltaImpulse = FMNADD(deltaVel2Dotn, tmp, deltaImpulse); tmp = _mm_add_ps(c.m_appliedImpulse, deltaImpulse); const __m128 mask = _mm_cmpgt_ps(tmp, lowerLimit); deltaImpulse = _mm_blendv_ps(_mm_sub_ps(lowerLimit, c.m_appliedImpulse), deltaImpulse, mask); c.m_appliedImpulse = _mm_blendv_ps(lowerLimit, tmp, mask); bodyA.internalGetDeltaLinearVelocity().mVec128 = FMADD(_mm_mul_ps(c.m_contactNormal1.mVec128, bodyA.internalGetInvMass().mVec128), deltaImpulse, bodyA.internalGetDeltaLinearVelocity().mVec128); bodyA.internalGetDeltaAngularVelocity().mVec128 = FMADD(c.m_angularComponentA.mVec128, deltaImpulse, bodyA.internalGetDeltaAngularVelocity().mVec128); bodyB.internalGetDeltaLinearVelocity().mVec128 = FMADD(_mm_mul_ps(c.m_contactNormal2.mVec128, bodyB.internalGetInvMass().mVec128), deltaImpulse, bodyB.internalGetDeltaLinearVelocity().mVec128); bodyB.internalGetDeltaAngularVelocity().mVec128 = FMADD(c.m_angularComponentB.mVec128, deltaImpulse, bodyB.internalGetDeltaAngularVelocity().mVec128); btSimdScalar deltaImp = deltaImpulse; return deltaImp.m_floats[0] * (1. / c.m_jacDiagABInv); #else return gResolveSingleConstraintRowLowerLimit_sse2(bodyA, bodyB, c); #endif //BT_ALLOW_SSE4 } #endif //USE_SIMD btScalar btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { return m_resolveSingleConstraintRowGeneric(bodyA, bodyB, c); } // Project Gauss Seidel or the equivalent Sequential Impulse btScalar btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGeneric(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { return m_resolveSingleConstraintRowGeneric(bodyA, bodyB, c); } btScalar btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { return m_resolveSingleConstraintRowLowerLimit(bodyA, bodyB, c); } btScalar btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { return m_resolveSingleConstraintRowLowerLimit(bodyA, bodyB, c); } static btScalar gResolveSplitPenetrationImpulse_scalar_reference( btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { btScalar deltaImpulse = 0.f; if (c.m_rhsPenetration) { gNumSplitImpulseRecoveries++; deltaImpulse = c.m_rhsPenetration - btScalar(c.m_appliedPushImpulse) * c.m_cfm; const btScalar deltaVel1Dotn = c.m_contactNormal1.dot(bodyA.internalGetPushVelocity()) + c.m_relpos1CrossNormal.dot(bodyA.internalGetTurnVelocity()); const btScalar deltaVel2Dotn = c.m_contactNormal2.dot(bodyB.internalGetPushVelocity()) + c.m_relpos2CrossNormal.dot(bodyB.internalGetTurnVelocity()); deltaImpulse -= deltaVel1Dotn * c.m_jacDiagABInv; deltaImpulse -= deltaVel2Dotn * c.m_jacDiagABInv; const btScalar sum = btScalar(c.m_appliedPushImpulse) + deltaImpulse; if (sum < c.m_lowerLimit) { deltaImpulse = c.m_lowerLimit - c.m_appliedPushImpulse; c.m_appliedPushImpulse = c.m_lowerLimit; } else { c.m_appliedPushImpulse = sum; } bodyA.internalApplyPushImpulse(c.m_contactNormal1 * bodyA.internalGetInvMass(), c.m_angularComponentA, deltaImpulse); bodyB.internalApplyPushImpulse(c.m_contactNormal2 * bodyB.internalGetInvMass(), c.m_angularComponentB, deltaImpulse); } return deltaImpulse * (1. / c.m_jacDiagABInv); } static btScalar gResolveSplitPenetrationImpulse_sse2(btSolverBody& bodyA, btSolverBody& bodyB, const btSolverConstraint& c) { #ifdef USE_SIMD if (!c.m_rhsPenetration) return 0.f; gNumSplitImpulseRecoveries++; __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedPushImpulse); __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhsPenetration), _mm_mul_ps(_mm_set1_ps(c.m_appliedPushImpulse), _mm_set1_ps(c.m_cfm))); __m128 deltaVel1Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal1.mVec128, bodyA.internalGetPushVelocity().mVec128), btSimdDot3(c.m_relpos1CrossNormal.mVec128, bodyA.internalGetTurnVelocity().mVec128)); __m128 deltaVel2Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal2.mVec128, bodyB.internalGetPushVelocity().mVec128), btSimdDot3(c.m_relpos2CrossNormal.mVec128, bodyB.internalGetTurnVelocity().mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse, _mm_mul_ps(deltaVel1Dotn, _mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse, _mm_mul_ps(deltaVel2Dotn, _mm_set1_ps(c.m_jacDiagABInv))); btSimdScalar sum = _mm_add_ps(cpAppliedImp, deltaImpulse); btSimdScalar resultLowerLess, resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum, lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum, upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1, cpAppliedImp); deltaImpulse = _mm_or_ps(_mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse)); c.m_appliedPushImpulse = _mm_or_ps(_mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum)); __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal1.mVec128, bodyA.internalGetInvMass().mVec128); __m128 linearComponentB = _mm_mul_ps(c.m_contactNormal2.mVec128, bodyB.internalGetInvMass().mVec128); __m128 impulseMagnitude = deltaImpulse; bodyA.internalGetPushVelocity().mVec128 = _mm_add_ps(bodyA.internalGetPushVelocity().mVec128, _mm_mul_ps(linearComponentA, impulseMagnitude)); bodyA.internalGetTurnVelocity().mVec128 = _mm_add_ps(bodyA.internalGetTurnVelocity().mVec128, _mm_mul_ps(c.m_angularComponentA.mVec128, impulseMagnitude)); bodyB.internalGetPushVelocity().mVec128 = _mm_add_ps(bodyB.internalGetPushVelocity().mVec128, _mm_mul_ps(linearComponentB, impulseMagnitude)); bodyB.internalGetTurnVelocity().mVec128 = _mm_add_ps(bodyB.internalGetTurnVelocity().mVec128, _mm_mul_ps(c.m_angularComponentB.mVec128, impulseMagnitude)); btSimdScalar deltaImp = deltaImpulse; return deltaImp.m_floats[0] * (1. / c.m_jacDiagABInv); #else return gResolveSplitPenetrationImpulse_scalar_reference(bodyA, bodyB, c); #endif } btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver() { m_btSeed2 = 0; m_cachedSolverMode = 0; setupSolverFunctions(false); } void btSequentialImpulseConstraintSolver::setupSolverFunctions(bool useSimd) { m_resolveSingleConstraintRowGeneric = gResolveSingleConstraintRowGeneric_scalar_reference; m_resolveSingleConstraintRowLowerLimit = gResolveSingleConstraintRowLowerLimit_scalar_reference; m_resolveSplitPenetrationImpulse = gResolveSplitPenetrationImpulse_scalar_reference; if (useSimd) { #ifdef USE_SIMD m_resolveSingleConstraintRowGeneric = gResolveSingleConstraintRowGeneric_sse2; m_resolveSingleConstraintRowLowerLimit = gResolveSingleConstraintRowLowerLimit_sse2; m_resolveSplitPenetrationImpulse = gResolveSplitPenetrationImpulse_sse2; #ifdef BT_ALLOW_SSE4 int cpuFeatures = btCpuFeatureUtility::getCpuFeatures(); if ((cpuFeatures & btCpuFeatureUtility::CPU_FEATURE_FMA3) && (cpuFeatures & btCpuFeatureUtility::CPU_FEATURE_SSE4_1)) { m_resolveSingleConstraintRowGeneric = gResolveSingleConstraintRowGeneric_sse4_1_fma3; m_resolveSingleConstraintRowLowerLimit = gResolveSingleConstraintRowLowerLimit_sse4_1_fma3; } #endif //BT_ALLOW_SSE4 #endif //USE_SIMD } } btSequentialImpulseConstraintSolver::~btSequentialImpulseConstraintSolver() { } btSingleConstraintRowSolver btSequentialImpulseConstraintSolver::getScalarConstraintRowSolverGeneric() { return gResolveSingleConstraintRowGeneric_scalar_reference; } btSingleConstraintRowSolver btSequentialImpulseConstraintSolver::getScalarConstraintRowSolverLowerLimit() { return gResolveSingleConstraintRowLowerLimit_scalar_reference; } btSingleConstraintRowSolver btSequentialImpulseConstraintSolver::getScalarSplitPenetrationImpulseGeneric() { return gResolveSplitPenetrationImpulse_scalar_reference; } btSingleConstraintRowSolver btSequentialImpulseConstraintSolver::getSSE2SplitPenetrationImpulseGeneric() { return gResolveSplitPenetrationImpulse_sse2; } #ifdef USE_SIMD btSingleConstraintRowSolver btSequentialImpulseConstraintSolver::getSSE2ConstraintRowSolverGeneric() { return gResolveSingleConstraintRowGeneric_sse2; } btSingleConstraintRowSolver btSequentialImpulseConstraintSolver::getSSE2ConstraintRowSolverLowerLimit() { return gResolveSingleConstraintRowLowerLimit_sse2; } #ifdef BT_ALLOW_SSE4 btSingleConstraintRowSolver btSequentialImpulseConstraintSolver::getSSE4_1ConstraintRowSolverGeneric() { return gResolveSingleConstraintRowGeneric_sse4_1_fma3; } btSingleConstraintRowSolver btSequentialImpulseConstraintSolver::getSSE4_1ConstraintRowSolverLowerLimit() { return gResolveSingleConstraintRowLowerLimit_sse4_1_fma3; } #endif //BT_ALLOW_SSE4 #endif //USE_SIMD unsigned long btSequentialImpulseConstraintSolver::btRand2() { m_btSeed2 = (1664525L * m_btSeed2 + 1013904223L) & 0xffffffff; return m_btSeed2; } unsigned long btSequentialImpulseConstraintSolver::btRand2a(unsigned long& seed) { seed = (1664525L * seed + 1013904223L) & 0xffffffff; return seed; } //See ODE: adam's all-int straightforward(?) dRandInt (0..n-1) int btSequentialImpulseConstraintSolver::btRandInt2(int n) { // seems good; xor-fold and modulus const unsigned long un = static_cast<unsigned long>(n); unsigned long r = btRand2(); // note: probably more aggressive than it needs to be -- might be // able to get away without one or two of the innermost branches. if (un <= 0x00010000UL) { r ^= (r >> 16); if (un <= 0x00000100UL) { r ^= (r >> 8); if (un <= 0x00000010UL) { r ^= (r >> 4); if (un <= 0x00000004UL) { r ^= (r >> 2); if (un <= 0x00000002UL) { r ^= (r >> 1); } } } } } return (int)(r % un); } int btSequentialImpulseConstraintSolver::btRandInt2a(int n, unsigned long& seed) { // seems good; xor-fold and modulus const unsigned long un = static_cast<unsigned long>(n); unsigned long r = btSequentialImpulseConstraintSolver::btRand2a(seed); // note: probably more aggressive than it needs to be -- might be // able to get away without one or two of the innermost branches. if (un <= 0x00010000UL) { r ^= (r >> 16); if (un <= 0x00000100UL) { r ^= (r >> 8); if (un <= 0x00000010UL) { r ^= (r >> 4); if (un <= 0x00000004UL) { r ^= (r >> 2); if (un <= 0x00000002UL) { r ^= (r >> 1); } } } } } return (int)(r % un); } void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject, btScalar timeStep) { btSISolverSingleIterationData::initSolverBody(solverBody, collisionObject, timeStep); } btScalar btSequentialImpulseConstraintSolver::restitutionCurveInternal(btScalar rel_vel, btScalar restitution, btScalar velocityThreshold) { //printf("rel_vel =%f\n", rel_vel); if (btFabs(rel_vel) < velocityThreshold) return 0.; btScalar rest = restitution * -rel_vel; return rest; } btScalar btSequentialImpulseConstraintSolver::restitutionCurve(btScalar rel_vel, btScalar restitution, btScalar velocityThreshold) { return btSequentialImpulseConstraintSolver::restitutionCurveInternal(rel_vel, restitution, velocityThreshold); } void btSequentialImpulseConstraintSolver::applyAnisotropicFriction(btCollisionObject* colObj, btVector3& frictionDirection, int frictionMode) { if (colObj && colObj->hasAnisotropicFriction(frictionMode)) { // transform to local coordinates btVector3 loc_lateral = frictionDirection * colObj->getWorldTransform().getBasis(); const btVector3& friction_scaling = colObj->getAnisotropicFriction(); //apply anisotropic friction loc_lateral *= friction_scaling; // ... and transform it back to global coordinates frictionDirection = colObj->getWorldTransform().getBasis() * loc_lateral; } } void btSequentialImpulseConstraintSolver::setupFrictionConstraintInternal(btAlignedObjectArray<btSolverBody>& tmpSolverBodyPool, btSolverConstraint& solverConstraint, const btVector3& normalAxis, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, const btVector3& rel_pos1, const btVector3& rel_pos2, btCollisionObject* colObj0, btCollisionObject* colObj1, btScalar relaxation, const btContactSolverInfo& infoGlobal, btScalar desiredVelocity, btScalar cfmSlip) { btSolverBody& solverBodyA = tmpSolverBodyPool[solverBodyIdA]; btSolverBody& solverBodyB = tmpSolverBodyPool[solverBodyIdB]; btRigidBody* body0 = tmpSolverBodyPool[solverBodyIdA].m_originalBody; btRigidBody* bodyA = tmpSolverBodyPool[solverBodyIdB].m_originalBody; solverConstraint.m_solverBodyIdA = solverBodyIdA; solverConstraint.m_solverBodyIdB = solverBodyIdB; solverConstraint.m_friction = cp.m_combinedFriction; solverConstraint.m_originalContactPoint = 0; solverConstraint.m_appliedImpulse = 0.f; solverConstraint.m_appliedPushImpulse = 0.f; if (body0) { solverConstraint.m_contactNormal1 = normalAxis; btVector3 ftorqueAxis1 = rel_pos1.cross(solverConstraint.m_contactNormal1); solverConstraint.m_relpos1CrossNormal = ftorqueAxis1; solverConstraint.m_angularComponentA = body0->getInvInertiaTensorWorld() * ftorqueAxis1 * body0->getAngularFactor(); } else { solverConstraint.m_contactNormal1.setZero(); solverConstraint.m_relpos1CrossNormal.setZero(); solverConstraint.m_angularComponentA.setZero(); } if (bodyA) { solverConstraint.m_contactNormal2 = -normalAxis; btVector3 ftorqueAxis1 = rel_pos2.cross(solverConstraint.m_contactNormal2); solverConstraint.m_relpos2CrossNormal = ftorqueAxis1; solverConstraint.m_angularComponentB = bodyA->getInvInertiaTensorWorld() * ftorqueAxis1 * bodyA->getAngularFactor(); } else { solverConstraint.m_contactNormal2.setZero(); solverConstraint.m_relpos2CrossNormal.setZero(); solverConstraint.m_angularComponentB.setZero(); } { btVector3 vec; btScalar denom0 = 0.f; btScalar denom1 = 0.f; if (body0) { vec = (solverConstraint.m_angularComponentA).cross(rel_pos1); denom0 = body0->getInvMass() + normalAxis.dot(vec); } if (bodyA) { vec = (-solverConstraint.m_angularComponentB).cross(rel_pos2); denom1 = bodyA->getInvMass() + normalAxis.dot(vec); } btScalar denom = relaxation / (denom0 + denom1); solverConstraint.m_jacDiagABInv = denom; } { btScalar rel_vel; btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0 ? solverBodyA.m_linearVelocity + solverBodyA.m_externalForceImpulse : btVector3(0, 0, 0)) + solverConstraint.m_relpos1CrossNormal.dot(body0 ? solverBodyA.m_angularVelocity : btVector3(0, 0, 0)); btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(bodyA ? solverBodyB.m_linearVelocity + solverBodyB.m_externalForceImpulse : btVector3(0, 0, 0)) + solverConstraint.m_relpos2CrossNormal.dot(bodyA ? solverBodyB.m_angularVelocity : btVector3(0, 0, 0)); rel_vel = vel1Dotn + vel2Dotn; // btScalar positionalError = 0.f; btScalar velocityError = desiredVelocity - rel_vel; btScalar velocityImpulse = velocityError * solverConstraint.m_jacDiagABInv; btScalar penetrationImpulse = btScalar(0); if (cp.m_contactPointFlags & BT_CONTACT_FLAG_FRICTION_ANCHOR) { btScalar distance = (cp.getPositionWorldOnA() - cp.getPositionWorldOnB()).dot(normalAxis); btScalar positionalError = -distance * infoGlobal.m_frictionERP / infoGlobal.m_timeStep; penetrationImpulse = positionalError * solverConstraint.m_jacDiagABInv; } solverConstraint.m_rhs = penetrationImpulse + velocityImpulse; solverConstraint.m_rhsPenetration = 0.f; solverConstraint.m_cfm = cfmSlip; solverConstraint.m_lowerLimit = -solverConstraint.m_friction; solverConstraint.m_upperLimit = solverConstraint.m_friction; } } void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstraint& solverConstraint, const btVector3& normalAxis, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, const btVector3& rel_pos1, const btVector3& rel_pos2, btCollisionObject* colObj0, btCollisionObject* colObj1, btScalar relaxation, const btContactSolverInfo& infoGlobal, btScalar desiredVelocity, btScalar cfmSlip) { btSequentialImpulseConstraintSolver::setupFrictionConstraintInternal(m_tmpSolverBodyPool, solverConstraint, normalAxis, solverBodyIdA, solverBodyIdB, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal, desiredVelocity, cfmSlip); } btSolverConstraint& btSequentialImpulseConstraintSolver::addFrictionConstraintInternal(btAlignedObjectArray<btSolverBody>& tmpSolverBodyPool, btConstraintArray& tmpSolverContactFrictionConstraintPool, const btVector3& normalAxis, int solverBodyIdA, int solverBodyIdB, int frictionIndex, btManifoldPoint& cp, const btVector3& rel_pos1, const btVector3& rel_pos2, btCollisionObject* colObj0, btCollisionObject* colObj1, btScalar relaxation, const btContactSolverInfo& infoGlobal, btScalar desiredVelocity, btScalar cfmSlip) { btSolverConstraint& solverConstraint = tmpSolverContactFrictionConstraintPool.expandNonInitializing(); solverConstraint.m_frictionIndex = frictionIndex; setupFrictionConstraintInternal(tmpSolverBodyPool, solverConstraint, normalAxis, solverBodyIdA, solverBodyIdB, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal, desiredVelocity, cfmSlip); return solverConstraint; } btSolverConstraint& btSequentialImpulseConstraintSolver::addFrictionConstraint(const btVector3& normalAxis, int solverBodyIdA, int solverBodyIdB, int frictionIndex, btManifoldPoint& cp, const btVector3& rel_pos1, const btVector3& rel_pos2, btCollisionObject* colObj0, btCollisionObject* colObj1, btScalar relaxation, const btContactSolverInfo& infoGlobal, btScalar desiredVelocity, btScalar cfmSlip) { btSolverConstraint& solverConstraint = m_tmpSolverContactFrictionConstraintPool.expandNonInitializing(); solverConstraint.m_frictionIndex = frictionIndex; setupFrictionConstraint(solverConstraint, normalAxis, solverBodyIdA, solverBodyIdB, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal, desiredVelocity, cfmSlip); return solverConstraint; } void btSequentialImpulseConstraintSolver::setupTorsionalFrictionConstraintInternal(btAlignedObjectArray<btSolverBody>& tmpSolverBodyPool, btSolverConstraint& solverConstraint, const btVector3& normalAxis1, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, btScalar combinedTorsionalFriction, const btVector3& rel_pos1, const btVector3& rel_pos2, btCollisionObject* colObj0, btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity, btScalar cfmSlip) { btVector3 normalAxis(0, 0, 0); solverConstraint.m_contactNormal1 = normalAxis; solverConstraint.m_contactNormal2 = -normalAxis; btSolverBody& solverBodyA = tmpSolverBodyPool[solverBodyIdA]; btSolverBody& solverBodyB = tmpSolverBodyPool[solverBodyIdB]; btRigidBody* body0 = tmpSolverBodyPool[solverBodyIdA].m_originalBody; btRigidBody* bodyA = tmpSolverBodyPool[solverBodyIdB].m_originalBody; solverConstraint.m_solverBodyIdA = solverBodyIdA; solverConstraint.m_solverBodyIdB = solverBodyIdB; solverConstraint.m_friction = combinedTorsionalFriction; solverConstraint.m_originalContactPoint = 0; solverConstraint.m_appliedImpulse = 0.f; solverConstraint.m_appliedPushImpulse = 0.f; { btVector3 ftorqueAxis1 = -normalAxis1; solverConstraint.m_relpos1CrossNormal = ftorqueAxis1; solverConstraint.m_angularComponentA = body0 ? body0->getInvInertiaTensorWorld() * ftorqueAxis1 * body0->getAngularFactor() : btVector3(0, 0, 0); } { btVector3 ftorqueAxis1 = normalAxis1; solverConstraint.m_relpos2CrossNormal = ftorqueAxis1; solverConstraint.m_angularComponentB = bodyA ? bodyA->getInvInertiaTensorWorld() * ftorqueAxis1 * bodyA->getAngularFactor() : btVector3(0, 0, 0); } { btVector3 iMJaA = body0 ? body0->getInvInertiaTensorWorld() * solverConstraint.m_relpos1CrossNormal : btVector3(0, 0, 0); btVector3 iMJaB = bodyA ? bodyA->getInvInertiaTensorWorld() * solverConstraint.m_relpos2CrossNormal : btVector3(0, 0, 0); btScalar sum = 0; sum += iMJaA.dot(solverConstraint.m_relpos1CrossNormal); sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal); solverConstraint.m_jacDiagABInv = btScalar(1.) / sum; } { btScalar rel_vel; btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0 ? solverBodyA.m_linearVelocity + solverBodyA.m_externalForceImpulse : btVector3(0, 0, 0)) + solverConstraint.m_relpos1CrossNormal.dot(body0 ? solverBodyA.m_angularVelocity : btVector3(0, 0, 0)); btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(bodyA ? solverBodyB.m_linearVelocity + solverBodyB.m_externalForceImpulse : btVector3(0, 0, 0)) + solverConstraint.m_relpos2CrossNormal.dot(bodyA ? solverBodyB.m_angularVelocity : btVector3(0, 0, 0)); rel_vel = vel1Dotn + vel2Dotn; // btScalar positionalError = 0.f; btSimdScalar velocityError = desiredVelocity - rel_vel; btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv); solverConstraint.m_rhs = velocityImpulse; solverConstraint.m_cfm = cfmSlip; solverConstraint.m_lowerLimit = -solverConstraint.m_friction; solverConstraint.m_upperLimit = solverConstraint.m_friction; } } void btSequentialImpulseConstraintSolver::setupTorsionalFrictionConstraint(btSolverConstraint& solverConstraint, const btVector3& normalAxis1, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, btScalar combinedTorsionalFriction, const btVector3& rel_pos1, const btVector3& rel_pos2, btCollisionObject* colObj0, btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity, btScalar cfmSlip) { setupTorsionalFrictionConstraintInternal(m_tmpSolverBodyPool, solverConstraint, normalAxis1, solverBodyIdA, solverBodyIdB, cp, combinedTorsionalFriction, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, desiredVelocity, cfmSlip); } btSolverConstraint& btSequentialImpulseConstraintSolver::addTorsionalFrictionConstraintInternal(btAlignedObjectArray<btSolverBody>& tmpSolverBodyPool, btConstraintArray& tmpSolverContactRollingFrictionConstraintPool, const btVector3& normalAxis, int solverBodyIdA, int solverBodyIdB, int frictionIndex, btManifoldPoint& cp, btScalar combinedTorsionalFriction, const btVector3& rel_pos1, const btVector3& rel_pos2, btCollisionObject* colObj0, btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity, btScalar cfmSlip) { btSolverConstraint& solverConstraint = tmpSolverContactRollingFrictionConstraintPool.expandNonInitializing(); solverConstraint.m_frictionIndex = frictionIndex; setupTorsionalFrictionConstraintInternal(tmpSolverBodyPool, solverConstraint, normalAxis, solverBodyIdA, solverBodyIdB, cp, combinedTorsionalFriction, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, desiredVelocity, cfmSlip); return solverConstraint; } btSolverConstraint& btSequentialImpulseConstraintSolver::addTorsionalFrictionConstraint(const btVector3& normalAxis, int solverBodyIdA, int solverBodyIdB, int frictionIndex, btManifoldPoint& cp, btScalar combinedTorsionalFriction, const btVector3& rel_pos1, const btVector3& rel_pos2, btCollisionObject* colObj0, btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity, btScalar cfmSlip) { btSolverConstraint& solverConstraint = m_tmpSolverContactRollingFrictionConstraintPool.expandNonInitializing(); solverConstraint.m_frictionIndex = frictionIndex; setupTorsionalFrictionConstraint(solverConstraint, normalAxis, solverBodyIdA, solverBodyIdB, cp, combinedTorsionalFriction, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, desiredVelocity, cfmSlip); return solverConstraint; } int btSISolverSingleIterationData::getOrInitSolverBody(btCollisionObject & body, btScalar timeStep) { #if BT_THREADSAFE int solverBodyId = -1; bool isRigidBodyType = btRigidBody::upcast(&body) != NULL; if (isRigidBodyType && !body.isStaticOrKinematicObject()) { // dynamic body // Dynamic bodies can only be in one island, so it's safe to write to the companionId solverBodyId = body.getCompanionId(); if (solverBodyId < 0) { solverBodyId = m_tmpSolverBodyPool.size(); btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); initSolverBody(&solverBody, &body, timeStep); body.setCompanionId(solverBodyId); } } else if (isRigidBodyType && body.isKinematicObject()) { // // NOTE: must test for kinematic before static because some kinematic objects also // identify as "static" // // Kinematic bodies can be in multiple islands at once, so it is a // race condition to write to them, so we use an alternate method // to record the solverBodyId int uniqueId = body.getWorldArrayIndex(); const int INVALID_SOLVER_BODY_ID = -1; if (uniqueId >= m_kinematicBodyUniqueIdToSolverBodyTable.size()) { m_kinematicBodyUniqueIdToSolverBodyTable.resize(uniqueId + 1, INVALID_SOLVER_BODY_ID); } solverBodyId = m_kinematicBodyUniqueIdToSolverBodyTable[uniqueId]; // if no table entry yet, if (solverBodyId == INVALID_SOLVER_BODY_ID) { // create a table entry for this body solverBodyId = m_tmpSolverBodyPool.size(); btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); initSolverBody(&solverBody, &body, timeStep); m_kinematicBodyUniqueIdToSolverBodyTable[uniqueId] = solverBodyId; } } else { bool isMultiBodyType = (body.getInternalType() & btCollisionObject::CO_FEATHERSTONE_LINK); // Incorrectly set collision object flags can degrade performance in various ways. if (!isMultiBodyType) { btAssert(body.isStaticOrKinematicObject()); } //it could be a multibody link collider // all fixed bodies (inf mass) get mapped to a single solver id if (m_fixedBodyId < 0) { m_fixedBodyId = m_tmpSolverBodyPool.size(); btSolverBody& fixedBody = m_tmpSolverBodyPool.expand(); initSolverBody(&fixedBody, 0, timeStep); } solverBodyId = m_fixedBodyId; } btAssert(solverBodyId >= 0 && solverBodyId < m_tmpSolverBodyPool.size()); return solverBodyId; #else // BT_THREADSAFE int solverBodyIdA = -1; if (body.getCompanionId() >= 0) { //body has already been converted solverBodyIdA = body.getCompanionId(); btAssert(solverBodyIdA < m_tmpSolverBodyPool.size()); } else { btRigidBody* rb = btRigidBody::upcast(&body); //convert both active and kinematic objects (for their velocity) if (rb && (rb->getInvMass() || rb->isKinematicObject())) { solverBodyIdA = m_tmpSolverBodyPool.size(); btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); initSolverBody(&solverBody, &body, timeStep); body.setCompanionId(solverBodyIdA); } else { if (m_fixedBodyId < 0) { m_fixedBodyId = m_tmpSolverBodyPool.size(); btSolverBody& fixedBody = m_tmpSolverBodyPool.expand(); initSolverBody(&fixedBody, 0, timeStep); } return m_fixedBodyId; // return 0;//assume first one is a fixed solver body } } return solverBodyIdA; #endif // BT_THREADSAFE } void btSISolverSingleIterationData::initSolverBody(btSolverBody * solverBody, btCollisionObject * collisionObject, btScalar timeStep) { btRigidBody* rb = collisionObject ? btRigidBody::upcast(collisionObject) : 0; solverBody->internalGetDeltaLinearVelocity().setValue(0.f, 0.f, 0.f); solverBody->internalGetDeltaAngularVelocity().setValue(0.f, 0.f, 0.f); solverBody->internalGetPushVelocity().setValue(0.f, 0.f, 0.f); solverBody->internalGetTurnVelocity().setValue(0.f, 0.f, 0.f); if (rb) { solverBody->m_worldTransform = rb->getWorldTransform(); solverBody->internalSetInvMass(btVector3(rb->getInvMass(), rb->getInvMass(), rb->getInvMass()) * rb->getLinearFactor()); solverBody->m_originalBody = rb; solverBody->m_angularFactor = rb->getAngularFactor(); solverBody->m_linearFactor = rb->getLinearFactor(); solverBody->m_linearVelocity = rb->getLinearVelocity(); solverBody->m_angularVelocity = rb->getAngularVelocity(); solverBody->m_externalForceImpulse = rb->getTotalForce() * rb->getInvMass() * timeStep; solverBody->m_externalTorqueImpulse = rb->getTotalTorque() * rb->getInvInertiaTensorWorld() * timeStep; } else { solverBody->m_worldTransform.setIdentity(); solverBody->internalSetInvMass(btVector3(0, 0, 0)); solverBody->m_originalBody = 0; solverBody->m_angularFactor.setValue(1, 1, 1); solverBody->m_linearFactor.setValue(1, 1, 1); solverBody->m_linearVelocity.setValue(0, 0, 0); solverBody->m_angularVelocity.setValue(0, 0, 0); solverBody->m_externalForceImpulse.setValue(0, 0, 0); solverBody->m_externalTorqueImpulse.setValue(0, 0, 0); } } int btSISolverSingleIterationData::getSolverBody(btCollisionObject& body) const { #if BT_THREADSAFE int solverBodyId = -1; bool isRigidBodyType = btRigidBody::upcast(&body) != NULL; if (isRigidBodyType && !body.isStaticOrKinematicObject()) { // dynamic body // Dynamic bodies can only be in one island, so it's safe to write to the companionId solverBodyId = body.getCompanionId(); btAssert(solverBodyId >= 0); } else if (isRigidBodyType && body.isKinematicObject()) { // // NOTE: must test for kinematic before static because some kinematic objects also // identify as "static" // // Kinematic bodies can be in multiple islands at once, so it is a // race condition to write to them, so we use an alternate method // to record the solverBodyId int uniqueId = body.getWorldArrayIndex(); const int INVALID_SOLVER_BODY_ID = -1; if (uniqueId >= m_kinematicBodyUniqueIdToSolverBodyTable.size()) { m_kinematicBodyUniqueIdToSolverBodyTable.resize(uniqueId + 1, INVALID_SOLVER_BODY_ID); } solverBodyId = m_kinematicBodyUniqueIdToSolverBodyTable[uniqueId]; btAssert(solverBodyId != INVALID_SOLVER_BODY_ID); } else { bool isMultiBodyType = (body.getInternalType() & btCollisionObject::CO_FEATHERSTONE_LINK); // Incorrectly set collision object flags can degrade performance in various ways. if (!isMultiBodyType) { btAssert(body.isStaticOrKinematicObject()); } btAssert(m_fixedBodyId >= 0); solverBodyId = m_fixedBodyId; } btAssert(solverBodyId >= 0 && solverBodyId < m_tmpSolverBodyPool.size()); return solverBodyId; #else // BT_THREADSAFE int solverBodyIdA = -1; if (body.getCompanionId() >= 0) { //body has already been converted solverBodyIdA = body.getCompanionId(); btAssert(solverBodyIdA < m_tmpSolverBodyPool.size()); } else { btRigidBody* rb = btRigidBody::upcast(&body); //convert both active and kinematic objects (for their velocity) if (rb && (rb->getInvMass() || rb->isKinematicObject())) { btAssert(0); } else { if (m_fixedBodyId < 0) { btAssert(0); } return m_fixedBodyId; // return 0;//assume first one is a fixed solver body } } return solverBodyIdA; #endif // BT_THREADSAFE } int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& body, btScalar timeStep) { #if BT_THREADSAFE int solverBodyId = -1; bool isRigidBodyType = btRigidBody::upcast(&body) != NULL; if (isRigidBodyType && !body.isStaticOrKinematicObject()) { // dynamic body // Dynamic bodies can only be in one island, so it's safe to write to the companionId solverBodyId = body.getCompanionId(); if (solverBodyId < 0) { solverBodyId = m_tmpSolverBodyPool.size(); btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); initSolverBody(&solverBody, &body, timeStep); body.setCompanionId(solverBodyId); } } else if (isRigidBodyType && body.isKinematicObject()) { // // NOTE: must test for kinematic before static because some kinematic objects also // identify as "static" // // Kinematic bodies can be in multiple islands at once, so it is a // race condition to write to them, so we use an alternate method // to record the solverBodyId int uniqueId = body.getWorldArrayIndex(); const int INVALID_SOLVER_BODY_ID = -1; if (uniqueId >= m_kinematicBodyUniqueIdToSolverBodyTable.size()) { m_kinematicBodyUniqueIdToSolverBodyTable.resize(uniqueId + 1, INVALID_SOLVER_BODY_ID); } solverBodyId = m_kinematicBodyUniqueIdToSolverBodyTable[uniqueId]; // if no table entry yet, if (solverBodyId == INVALID_SOLVER_BODY_ID) { // create a table entry for this body solverBodyId = m_tmpSolverBodyPool.size(); btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); initSolverBody(&solverBody, &body, timeStep); m_kinematicBodyUniqueIdToSolverBodyTable[uniqueId] = solverBodyId; } } else { bool isMultiBodyType = (body.getInternalType() & btCollisionObject::CO_FEATHERSTONE_LINK); // Incorrectly set collision object flags can degrade performance in various ways. if (!isMultiBodyType) { btAssert(body.isStaticOrKinematicObject()); } //it could be a multibody link collider // all fixed bodies (inf mass) get mapped to a single solver id if (m_fixedBodyId < 0) { m_fixedBodyId = m_tmpSolverBodyPool.size(); btSolverBody& fixedBody = m_tmpSolverBodyPool.expand(); initSolverBody(&fixedBody, 0, timeStep); } solverBodyId = m_fixedBodyId; } btAssert(solverBodyId >= 0 && solverBodyId < m_tmpSolverBodyPool.size()); return solverBodyId; #else // BT_THREADSAFE int solverBodyIdA = -1; if (body.getCompanionId() >= 0) { //body has already been converted solverBodyIdA = body.getCompanionId(); btAssert(solverBodyIdA < m_tmpSolverBodyPool.size()); } else { btRigidBody* rb = btRigidBody::upcast(&body); //convert both active and kinematic objects (for their velocity) if (rb && (rb->getInvMass() || rb->isKinematicObject())) { solverBodyIdA = m_tmpSolverBodyPool.size(); btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); initSolverBody(&solverBody, &body, timeStep); body.setCompanionId(solverBodyIdA); } else { if (m_fixedBodyId < 0) { m_fixedBodyId = m_tmpSolverBodyPool.size(); btSolverBody& fixedBody = m_tmpSolverBodyPool.expand(); initSolverBody(&fixedBody, 0, timeStep); } return m_fixedBodyId; // return 0;//assume first one is a fixed solver body } } return solverBodyIdA; #endif // BT_THREADSAFE } #include <stdio.h> void btSequentialImpulseConstraintSolver::setupContactConstraintInternal(btSISolverSingleIterationData& siData, btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, const btContactSolverInfo& infoGlobal, btScalar& relaxation, const btVector3& rel_pos1, const btVector3& rel_pos2) { // const btVector3& pos1 = cp.getPositionWorldOnA(); // const btVector3& pos2 = cp.getPositionWorldOnB(); btSolverBody* bodyA = &siData.m_tmpSolverBodyPool[solverBodyIdA]; btSolverBody* bodyB = &siData.m_tmpSolverBodyPool[solverBodyIdB]; btRigidBody* rb0 = bodyA->m_originalBody; btRigidBody* rb1 = bodyB->m_originalBody; // btVector3 rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); // btVector3 rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin(); //rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin(); //rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin(); relaxation = infoGlobal.m_sor; btScalar invTimeStep = btScalar(1) / infoGlobal.m_timeStep; //cfm = 1 / ( dt * kp + kd ) //erp = dt * kp / ( dt * kp + kd ) btScalar cfm = infoGlobal.m_globalCfm; btScalar erp = infoGlobal.m_erp2; if ((cp.m_contactPointFlags & BT_CONTACT_FLAG_HAS_CONTACT_CFM) || (cp.m_contactPointFlags & BT_CONTACT_FLAG_HAS_CONTACT_ERP)) { if (cp.m_contactPointFlags & BT_CONTACT_FLAG_HAS_CONTACT_CFM) cfm = cp.m_contactCFM; if (cp.m_contactPointFlags & BT_CONTACT_FLAG_HAS_CONTACT_ERP) erp = cp.m_contactERP; } else { if (cp.m_contactPointFlags & BT_CONTACT_FLAG_CONTACT_STIFFNESS_DAMPING) { btScalar denom = (infoGlobal.m_timeStep * cp.m_combinedContactStiffness1 + cp.m_combinedContactDamping1); if (denom < SIMD_EPSILON) { denom = SIMD_EPSILON; } cfm = btScalar(1) / denom; erp = (infoGlobal.m_timeStep * cp.m_combinedContactStiffness1) / denom; } } cfm *= invTimeStep; btVector3 torqueAxis0 = rel_pos1.cross(cp.m_normalWorldOnB); solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld() * torqueAxis0 * rb0->getAngularFactor() : btVector3(0, 0, 0); btVector3 torqueAxis1 = rel_pos2.cross(cp.m_normalWorldOnB); solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld() * -torqueAxis1 * rb1->getAngularFactor() : btVector3(0, 0, 0); { #ifdef COMPUTE_IMPULSE_DENOM btScalar denom0 = rb0->computeImpulseDenominator(pos1, cp.m_normalWorldOnB); btScalar denom1 = rb1->computeImpulseDenominator(pos2, cp.m_normalWorldOnB); #else btVector3 vec; btScalar denom0 = 0.f; btScalar denom1 = 0.f; if (rb0) { vec = (solverConstraint.m_angularComponentA).cross(rel_pos1); denom0 = rb0->getInvMass() + cp.m_normalWorldOnB.dot(vec); } if (rb1) { vec = (-solverConstraint.m_angularComponentB).cross(rel_pos2); denom1 = rb1->getInvMass() + cp.m_normalWorldOnB.dot(vec); } #endif //COMPUTE_IMPULSE_DENOM btScalar denom = relaxation / (denom0 + denom1 + cfm); solverConstraint.m_jacDiagABInv = denom; } if (rb0) { solverConstraint.m_contactNormal1 = cp.m_normalWorldOnB; solverConstraint.m_relpos1CrossNormal = torqueAxis0; } else { solverConstraint.m_contactNormal1.setZero(); solverConstraint.m_relpos1CrossNormal.setZero(); } if (rb1) { solverConstraint.m_contactNormal2 = -cp.m_normalWorldOnB; solverConstraint.m_relpos2CrossNormal = -torqueAxis1; } else { solverConstraint.m_contactNormal2.setZero(); solverConstraint.m_relpos2CrossNormal.setZero(); } btScalar restitution = 0.f; btScalar penetration = cp.getDistance() + infoGlobal.m_linearSlop; { btVector3 vel1, vel2; vel1 = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0, 0, 0); vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0, 0, 0); // btVector3 vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0); btVector3 vel = vel1 - vel2; btScalar rel_vel = cp.m_normalWorldOnB.dot(vel); solverConstraint.m_friction = cp.m_combinedFriction; restitution = btSequentialImpulseConstraintSolver::restitutionCurveInternal(rel_vel, cp.m_combinedRestitution, infoGlobal.m_restitutionVelocityThreshold); if (restitution <= btScalar(0.)) { restitution = 0.f; }; } ///warm starting (or zero if disabled) if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) { solverConstraint.m_appliedImpulse = cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor; if (rb0) bodyA->internalApplyImpulse(solverConstraint.m_contactNormal1 * bodyA->internalGetInvMass(), solverConstraint.m_angularComponentA, solverConstraint.m_appliedImpulse); if (rb1) bodyB->internalApplyImpulse(-solverConstraint.m_contactNormal2 * bodyB->internalGetInvMass(), -solverConstraint.m_angularComponentB, -(btScalar)solverConstraint.m_appliedImpulse); } else { solverConstraint.m_appliedImpulse = 0.f; } solverConstraint.m_appliedPushImpulse = 0.f; { btVector3 externalForceImpulseA = bodyA->m_originalBody ? bodyA->m_externalForceImpulse : btVector3(0, 0, 0); btVector3 externalTorqueImpulseA = bodyA->m_originalBody ? bodyA->m_externalTorqueImpulse : btVector3(0, 0, 0); btVector3 externalForceImpulseB = bodyB->m_originalBody ? bodyB->m_externalForceImpulse : btVector3(0, 0, 0); btVector3 externalTorqueImpulseB = bodyB->m_originalBody ? bodyB->m_externalTorqueImpulse : btVector3(0, 0, 0); btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(bodyA->m_linearVelocity + externalForceImpulseA) + solverConstraint.m_relpos1CrossNormal.dot(bodyA->m_angularVelocity + externalTorqueImpulseA); btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(bodyB->m_linearVelocity + externalForceImpulseB) + solverConstraint.m_relpos2CrossNormal.dot(bodyB->m_angularVelocity + externalTorqueImpulseB); btScalar rel_vel = vel1Dotn + vel2Dotn; btScalar positionalError = 0.f; btScalar velocityError = restitution - rel_vel; // * damping; if (penetration > 0) { positionalError = 0; velocityError -= penetration * invTimeStep; } else { positionalError = -penetration * erp * invTimeStep; } btScalar penetrationImpulse = positionalError * solverConstraint.m_jacDiagABInv; btScalar velocityImpulse = velocityError * solverConstraint.m_jacDiagABInv; if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) { //combine position and velocity into rhs solverConstraint.m_rhs = penetrationImpulse + velocityImpulse; //-solverConstraint.m_contactNormal1.dot(bodyA->m_externalForce*bodyA->m_invMass-bodyB->m_externalForce/bodyB->m_invMass)*solverConstraint.m_jacDiagABInv; solverConstraint.m_rhsPenetration = 0.f; } else { //split position and velocity into rhs and m_rhsPenetration solverConstraint.m_rhs = velocityImpulse; solverConstraint.m_rhsPenetration = penetrationImpulse; } solverConstraint.m_cfm = cfm * solverConstraint.m_jacDiagABInv; solverConstraint.m_lowerLimit = 0; solverConstraint.m_upperLimit = 1e10f; } } void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, const btContactSolverInfo& infoGlobal, btScalar& relaxation, const btVector3& rel_pos1, const btVector3& rel_pos2) { btSISolverSingleIterationData siData(m_tmpSolverBodyPool, m_tmpSolverContactConstraintPool, m_tmpSolverNonContactConstraintPool, m_tmpSolverContactFrictionConstraintPool, m_tmpSolverContactRollingFrictionConstraintPool, m_orderTmpConstraintPool, m_orderNonContactConstraintPool, m_orderFrictionConstraintPool, m_tmpConstraintSizesPool, m_resolveSingleConstraintRowGeneric, m_resolveSingleConstraintRowLowerLimit, m_resolveSplitPenetrationImpulse, m_kinematicBodyUniqueIdToSolverBodyTable, m_btSeed2, m_fixedBodyId, m_maxOverrideNumSolverIterations ); setupContactConstraintInternal(siData, solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal, relaxation, rel_pos1, rel_pos2); } void btSequentialImpulseConstraintSolver::setFrictionConstraintImpulseInternal(btAlignedObjectArray<btSolverBody>& tmpSolverBodyPool, btConstraintArray& tmpSolverContactFrictionConstraintPool, btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, const btContactSolverInfo& infoGlobal) { btSolverBody* bodyA = &tmpSolverBodyPool[solverBodyIdA]; btSolverBody* bodyB = &tmpSolverBodyPool[solverBodyIdB]; btRigidBody* rb0 = bodyA->m_originalBody; btRigidBody* rb1 = bodyB->m_originalBody; { btSolverConstraint& frictionConstraint1 = tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex]; if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) { frictionConstraint1.m_appliedImpulse = cp.m_appliedImpulseLateral1 * infoGlobal.m_warmstartingFactor; if (rb0) bodyA->internalApplyImpulse(frictionConstraint1.m_contactNormal1 * rb0->getInvMass(), frictionConstraint1.m_angularComponentA, frictionConstraint1.m_appliedImpulse); if (rb1) bodyB->internalApplyImpulse(-frictionConstraint1.m_contactNormal2 * rb1->getInvMass(), -frictionConstraint1.m_angularComponentB, -(btScalar)frictionConstraint1.m_appliedImpulse); } else { frictionConstraint1.m_appliedImpulse = 0.f; } } if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { btSolverConstraint& frictionConstraint2 = tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex + 1]; if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) { frictionConstraint2.m_appliedImpulse = cp.m_appliedImpulseLateral2 * infoGlobal.m_warmstartingFactor; if (rb0) bodyA->internalApplyImpulse(frictionConstraint2.m_contactNormal1 * rb0->getInvMass(), frictionConstraint2.m_angularComponentA, frictionConstraint2.m_appliedImpulse); if (rb1) bodyB->internalApplyImpulse(-frictionConstraint2.m_contactNormal2 * rb1->getInvMass(), -frictionConstraint2.m_angularComponentB, -(btScalar)frictionConstraint2.m_appliedImpulse); } else { frictionConstraint2.m_appliedImpulse = 0.f; } } } void btSequentialImpulseConstraintSolver::setFrictionConstraintImpulse(btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, const btContactSolverInfo& infoGlobal) { setFrictionConstraintImpulseInternal(m_tmpSolverBodyPool, m_tmpSolverContactFrictionConstraintPool, solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal); } void btSequentialImpulseConstraintSolver::convertContactInternal(btSISolverSingleIterationData& siData, btPersistentManifold* manifold, const btContactSolverInfo& infoGlobal) { btCollisionObject *colObj0 = 0, *colObj1 = 0; colObj0 = (btCollisionObject*)manifold->getBody0(); colObj1 = (btCollisionObject*)manifold->getBody1(); int solverBodyIdA = siData.getOrInitSolverBody(*colObj0, infoGlobal.m_timeStep); int solverBodyIdB = siData.getOrInitSolverBody(*colObj1, infoGlobal.m_timeStep); // btRigidBody* bodyA = btRigidBody::upcast(colObj0); // btRigidBody* bodyB = btRigidBody::upcast(colObj1); btSolverBody* solverBodyA = &siData.m_tmpSolverBodyPool[solverBodyIdA]; btSolverBody* solverBodyB = &siData.m_tmpSolverBodyPool[solverBodyIdB]; ///avoid collision response between two static objects if (!solverBodyA || (solverBodyA->m_invMass.fuzzyZero() && (!solverBodyB || solverBodyB->m_invMass.fuzzyZero()))) return; int rollingFriction = 1; for (int j = 0; j < manifold->getNumContacts(); j++) { btManifoldPoint& cp = manifold->getContactPoint(j); if (cp.getDistance() <= manifold->getContactProcessingThreshold()) { btVector3 rel_pos1; btVector3 rel_pos2; btScalar relaxation; int frictionIndex = siData.m_tmpSolverContactConstraintPool.size(); btSolverConstraint& solverConstraint = siData.m_tmpSolverContactConstraintPool.expandNonInitializing(); solverConstraint.m_solverBodyIdA = solverBodyIdA; solverConstraint.m_solverBodyIdB = solverBodyIdB; solverConstraint.m_originalContactPoint = &cp; const btVector3& pos1 = cp.getPositionWorldOnA(); const btVector3& pos2 = cp.getPositionWorldOnB(); rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin(); btVector3 vel1; btVector3 vel2; solverBodyA->getVelocityInLocalPointNoDelta(rel_pos1, vel1); solverBodyB->getVelocityInLocalPointNoDelta(rel_pos2, vel2); btVector3 vel = vel1 - vel2; btScalar rel_vel = cp.m_normalWorldOnB.dot(vel); setupContactConstraintInternal(siData, solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal, relaxation, rel_pos1, rel_pos2); /////setup the friction constraints solverConstraint.m_frictionIndex = siData.m_tmpSolverContactFrictionConstraintPool.size(); if ((cp.m_combinedRollingFriction > 0.f) && (rollingFriction > 0)) { { btSequentialImpulseConstraintSolver::addTorsionalFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactRollingFrictionConstraintPool, cp.m_normalWorldOnB, solverBodyIdA, solverBodyIdB, frictionIndex, cp, cp.m_combinedSpinningFriction, rel_pos1, rel_pos2, colObj0, colObj1, relaxation); btVector3 axis0, axis1; btPlaneSpace1(cp.m_normalWorldOnB, axis0, axis1); axis0.normalize(); axis1.normalize(); applyAnisotropicFriction(colObj0, axis0, btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); applyAnisotropicFriction(colObj1, axis0, btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); applyAnisotropicFriction(colObj0, axis1, btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); applyAnisotropicFriction(colObj1, axis1, btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); if (axis0.length() > 0.001) { btSequentialImpulseConstraintSolver::addTorsionalFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactRollingFrictionConstraintPool, axis0, solverBodyIdA, solverBodyIdB, frictionIndex, cp, cp.m_combinedRollingFriction, rel_pos1, rel_pos2, colObj0, colObj1, relaxation); } if (axis1.length() > 0.001) { btSequentialImpulseConstraintSolver::addTorsionalFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactRollingFrictionConstraintPool, axis1, solverBodyIdA, solverBodyIdB, frictionIndex, cp, cp.m_combinedRollingFriction, rel_pos1, rel_pos2, colObj0, colObj1, relaxation); } } } ///Bullet has several options to set the friction directions ///By default, each contact has only a single friction direction that is recomputed automatically very frame ///based on the relative linear velocity. ///If the relative velocity it zero, it will automatically compute a friction direction. ///You can also enable two friction directions, using the SOLVER_USE_2_FRICTION_DIRECTIONS. ///In that case, the second friction direction will be orthogonal to both contact normal and first friction direction. /// ///If you choose SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION, then the friction will be independent from the relative projected velocity. /// ///The user can manually override the friction directions for certain contacts using a contact callback, ///and use contactPoint.m_contactPointFlags |= BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED ///In that case, you can set the target relative motion in each friction direction (cp.m_contactMotion1 and cp.m_contactMotion2) ///this will give a conveyor belt effect /// if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !(cp.m_contactPointFlags & BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED)) { cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) { cp.m_lateralFrictionDir1 *= 1.f / btSqrt(lat_rel_vel); applyAnisotropicFriction(colObj0, cp.m_lateralFrictionDir1, btCollisionObject::CF_ANISOTROPIC_FRICTION); applyAnisotropicFriction(colObj1, cp.m_lateralFrictionDir1, btCollisionObject::CF_ANISOTROPIC_FRICTION); btSequentialImpulseConstraintSolver::addFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactFrictionConstraintPool, cp.m_lateralFrictionDir1, solverBodyIdA, solverBodyIdB, frictionIndex, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); cp.m_lateralFrictionDir2.normalize(); //?? applyAnisotropicFriction(colObj0, cp.m_lateralFrictionDir2, btCollisionObject::CF_ANISOTROPIC_FRICTION); applyAnisotropicFriction(colObj1, cp.m_lateralFrictionDir2, btCollisionObject::CF_ANISOTROPIC_FRICTION); btSequentialImpulseConstraintSolver::addFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactFrictionConstraintPool, cp.m_lateralFrictionDir2, solverBodyIdA, solverBodyIdB, frictionIndex, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal); } } else { btPlaneSpace1(cp.m_normalWorldOnB, cp.m_lateralFrictionDir1, cp.m_lateralFrictionDir2); applyAnisotropicFriction(colObj0, cp.m_lateralFrictionDir1, btCollisionObject::CF_ANISOTROPIC_FRICTION); applyAnisotropicFriction(colObj1, cp.m_lateralFrictionDir1, btCollisionObject::CF_ANISOTROPIC_FRICTION); btSequentialImpulseConstraintSolver::addFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactFrictionConstraintPool, cp.m_lateralFrictionDir1, solverBodyIdA, solverBodyIdB, frictionIndex, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { applyAnisotropicFriction(colObj0, cp.m_lateralFrictionDir2, btCollisionObject::CF_ANISOTROPIC_FRICTION); applyAnisotropicFriction(colObj1, cp.m_lateralFrictionDir2, btCollisionObject::CF_ANISOTROPIC_FRICTION); btSequentialImpulseConstraintSolver::addFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactFrictionConstraintPool, cp.m_lateralFrictionDir2, solverBodyIdA, solverBodyIdB, frictionIndex, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal); } if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION)) { cp.m_contactPointFlags |= BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED; } } } else { btSequentialImpulseConstraintSolver::addFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactFrictionConstraintPool, cp.m_lateralFrictionDir1, solverBodyIdA, solverBodyIdB, frictionIndex, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal, cp.m_contactMotion1, cp.m_frictionCFM); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { btSequentialImpulseConstraintSolver::addFrictionConstraintInternal(siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactFrictionConstraintPool, cp.m_lateralFrictionDir2, solverBodyIdA, solverBodyIdB, frictionIndex, cp, rel_pos1, rel_pos2, colObj0, colObj1, relaxation, infoGlobal, cp.m_contactMotion2, cp.m_frictionCFM); } } btSequentialImpulseConstraintSolver::setFrictionConstraintImpulseInternal( siData.m_tmpSolverBodyPool, siData.m_tmpSolverContactFrictionConstraintPool, solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal); } } } void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* manifold, const btContactSolverInfo& infoGlobal) { btSISolverSingleIterationData siData(m_tmpSolverBodyPool, m_tmpSolverContactConstraintPool, m_tmpSolverNonContactConstraintPool, m_tmpSolverContactFrictionConstraintPool, m_tmpSolverContactRollingFrictionConstraintPool, m_orderTmpConstraintPool, m_orderNonContactConstraintPool, m_orderFrictionConstraintPool, m_tmpConstraintSizesPool, m_resolveSingleConstraintRowGeneric, m_resolveSingleConstraintRowLowerLimit, m_resolveSplitPenetrationImpulse, m_kinematicBodyUniqueIdToSolverBodyTable, m_btSeed2, m_fixedBodyId, m_maxOverrideNumSolverIterations); btSequentialImpulseConstraintSolver::convertContactInternal(siData, manifold, infoGlobal); } void btSequentialImpulseConstraintSolver::convertContacts(btPersistentManifold** manifoldPtr, int numManifolds, const btContactSolverInfo& infoGlobal) { int i; btPersistentManifold* manifold = 0; // btCollisionObject* colObj0=0,*colObj1=0; for (i = 0; i < numManifolds; i++) { manifold = manifoldPtr[i]; convertContact(manifold, infoGlobal); } } void btSequentialImpulseConstraintSolver::convertJointInternal(btAlignedObjectArray<btSolverBody>& tmpSolverBodyPool, int& maxOverrideNumSolverIterations, btSolverConstraint* currentConstraintRow, btTypedConstraint* constraint, const btTypedConstraint::btConstraintInfo1& info1, int solverBodyIdA, int solverBodyIdB, const btContactSolverInfo& infoGlobal) { const btRigidBody& rbA = constraint->getRigidBodyA(); const btRigidBody& rbB = constraint->getRigidBodyB(); const btSolverBody* bodyAPtr = &tmpSolverBodyPool[solverBodyIdA]; const btSolverBody* bodyBPtr = &tmpSolverBodyPool[solverBodyIdB]; int overrideNumSolverIterations = constraint->getOverrideNumSolverIterations() > 0 ? constraint->getOverrideNumSolverIterations() : infoGlobal.m_numIterations; if (overrideNumSolverIterations > maxOverrideNumSolverIterations) maxOverrideNumSolverIterations = overrideNumSolverIterations; for (int j = 0; j < info1.m_numConstraintRows; j++) { memset(&currentConstraintRow[j], 0, sizeof(btSolverConstraint)); currentConstraintRow[j].m_lowerLimit = -SIMD_INFINITY; currentConstraintRow[j].m_upperLimit = SIMD_INFINITY; currentConstraintRow[j].m_appliedImpulse = 0.f; currentConstraintRow[j].m_appliedPushImpulse = 0.f; currentConstraintRow[j].m_solverBodyIdA = solverBodyIdA; currentConstraintRow[j].m_solverBodyIdB = solverBodyIdB; currentConstraintRow[j].m_overrideNumSolverIterations = overrideNumSolverIterations; } // these vectors are already cleared in initSolverBody, no need to redundantly clear again btAssert(bodyAPtr->getDeltaLinearVelocity().isZero()); btAssert(bodyAPtr->getDeltaAngularVelocity().isZero()); btAssert(bodyAPtr->getPushVelocity().isZero()); btAssert(bodyAPtr->getTurnVelocity().isZero()); btAssert(bodyBPtr->getDeltaLinearVelocity().isZero()); btAssert(bodyBPtr->getDeltaAngularVelocity().isZero()); btAssert(bodyBPtr->getPushVelocity().isZero()); btAssert(bodyBPtr->getTurnVelocity().isZero()); //bodyAPtr->internalGetDeltaLinearVelocity().setValue(0.f,0.f,0.f); //bodyAPtr->internalGetDeltaAngularVelocity().setValue(0.f,0.f,0.f); //bodyAPtr->internalGetPushVelocity().setValue(0.f,0.f,0.f); //bodyAPtr->internalGetTurnVelocity().setValue(0.f,0.f,0.f); //bodyBPtr->internalGetDeltaLinearVelocity().setValue(0.f,0.f,0.f); //bodyBPtr->internalGetDeltaAngularVelocity().setValue(0.f,0.f,0.f); //bodyBPtr->internalGetPushVelocity().setValue(0.f,0.f,0.f); //bodyBPtr->internalGetTurnVelocity().setValue(0.f,0.f,0.f); btTypedConstraint::btConstraintInfo2 info2; info2.fps = 1.f / infoGlobal.m_timeStep; info2.erp = infoGlobal.m_erp; info2.m_J1linearAxis = currentConstraintRow->m_contactNormal1; info2.m_J1angularAxis = currentConstraintRow->m_relpos1CrossNormal; info2.m_J2linearAxis = currentConstraintRow->m_contactNormal2; info2.m_J2angularAxis = currentConstraintRow->m_relpos2CrossNormal; info2.rowskip = sizeof(btSolverConstraint) / sizeof(btScalar); //check this ///the size of btSolverConstraint needs be a multiple of btScalar btAssert(info2.rowskip * sizeof(btScalar) == sizeof(btSolverConstraint)); info2.m_constraintError = &currentConstraintRow->m_rhs; currentConstraintRow->m_cfm = infoGlobal.m_globalCfm; info2.m_damping = infoGlobal.m_damping; info2.cfm = &currentConstraintRow->m_cfm; info2.m_lowerLimit = &currentConstraintRow->m_lowerLimit; info2.m_upperLimit = &currentConstraintRow->m_upperLimit; info2.m_numIterations = infoGlobal.m_numIterations; constraint->getInfo2(&info2); ///finalize the constraint setup for (int j = 0; j < info1.m_numConstraintRows; j++) { btSolverConstraint& solverConstraint = currentConstraintRow[j]; if (solverConstraint.m_upperLimit >= constraint->getBreakingImpulseThreshold()) { solverConstraint.m_upperLimit = constraint->getBreakingImpulseThreshold(); } if (solverConstraint.m_lowerLimit <= -constraint->getBreakingImpulseThreshold()) { solverConstraint.m_lowerLimit = -constraint->getBreakingImpulseThreshold(); } solverConstraint.m_originalContactPoint = constraint; { const btVector3& ftorqueAxis1 = solverConstraint.m_relpos1CrossNormal; solverConstraint.m_angularComponentA = constraint->getRigidBodyA().getInvInertiaTensorWorld() * ftorqueAxis1 * constraint->getRigidBodyA().getAngularFactor(); } { const btVector3& ftorqueAxis2 = solverConstraint.m_relpos2CrossNormal; solverConstraint.m_angularComponentB = constraint->getRigidBodyB().getInvInertiaTensorWorld() * ftorqueAxis2 * constraint->getRigidBodyB().getAngularFactor(); } { btVector3 iMJlA = solverConstraint.m_contactNormal1 * rbA.getInvMass(); btVector3 iMJaA = rbA.getInvInertiaTensorWorld() * solverConstraint.m_relpos1CrossNormal; btVector3 iMJlB = solverConstraint.m_contactNormal2 * rbB.getInvMass(); //sign of normal? btVector3 iMJaB = rbB.getInvInertiaTensorWorld() * solverConstraint.m_relpos2CrossNormal; btScalar sum = iMJlA.dot(solverConstraint.m_contactNormal1); sum += iMJaA.dot(solverConstraint.m_relpos1CrossNormal); sum += iMJlB.dot(solverConstraint.m_contactNormal2); sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal); btScalar fsum = btFabs(sum); btAssert(fsum > SIMD_EPSILON); btScalar sorRelaxation = 1.f; //todo: get from globalInfo? solverConstraint.m_jacDiagABInv = fsum > SIMD_EPSILON ? sorRelaxation / sum : 0.f; } { btScalar rel_vel; btVector3 externalForceImpulseA = bodyAPtr->m_originalBody ? bodyAPtr->m_externalForceImpulse : btVector3(0, 0, 0); btVector3 externalTorqueImpulseA = bodyAPtr->m_originalBody ? bodyAPtr->m_externalTorqueImpulse : btVector3(0, 0, 0); btVector3 externalForceImpulseB = bodyBPtr->m_originalBody ? bodyBPtr->m_externalForceImpulse : btVector3(0, 0, 0); btVector3 externalTorqueImpulseB = bodyBPtr->m_originalBody ? bodyBPtr->m_externalTorqueImpulse : btVector3(0, 0, 0); btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(rbA.getLinearVelocity() + externalForceImpulseA) + solverConstraint.m_relpos1CrossNormal.dot(rbA.getAngularVelocity() + externalTorqueImpulseA); btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(rbB.getLinearVelocity() + externalForceImpulseB) + solverConstraint.m_relpos2CrossNormal.dot(rbB.getAngularVelocity() + externalTorqueImpulseB); rel_vel = vel1Dotn + vel2Dotn; btScalar restitution = 0.f; btScalar positionalError = solverConstraint.m_rhs; //already filled in by getConstraintInfo2 btScalar velocityError = restitution - rel_vel * info2.m_damping; btScalar penetrationImpulse = positionalError * solverConstraint.m_jacDiagABInv; btScalar velocityImpulse = velocityError * solverConstraint.m_jacDiagABInv; solverConstraint.m_rhs = penetrationImpulse + velocityImpulse; solverConstraint.m_appliedImpulse = 0.f; } } } void btSequentialImpulseConstraintSolver::convertJoint(btSolverConstraint* currentConstraintRow, btTypedConstraint* constraint, const btTypedConstraint::btConstraintInfo1& info1, int solverBodyIdA, int solverBodyIdB, const btContactSolverInfo& infoGlobal) { } void btSequentialImpulseConstraintSolver::convertJointsInternal(btSISolverSingleIterationData& siData, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal) { BT_PROFILE("convertJoints"); for (int j = 0; j < numConstraints; j++) { btTypedConstraint* constraint = constraints[j]; constraint->buildJacobian(); constraint->internalSetAppliedImpulse(0.0f); } int totalNumRows = 0; siData.m_tmpConstraintSizesPool.resizeNoInitialize(numConstraints); //calculate the total number of contraint rows for (int i = 0; i < numConstraints; i++) { btTypedConstraint::btConstraintInfo1& info1 = siData.m_tmpConstraintSizesPool[i]; btJointFeedback* fb = constraints[i]->getJointFeedback(); if (fb) { fb->m_appliedForceBodyA.setZero(); fb->m_appliedTorqueBodyA.setZero(); fb->m_appliedForceBodyB.setZero(); fb->m_appliedTorqueBodyB.setZero(); } if (constraints[i]->isEnabled()) { constraints[i]->getInfo1(&info1); } else { info1.m_numConstraintRows = 0; info1.nub = 0; } totalNumRows += info1.m_numConstraintRows; } siData.m_tmpSolverNonContactConstraintPool.resizeNoInitialize(totalNumRows); ///setup the btSolverConstraints int currentRow = 0; for (int i = 0; i < numConstraints; i++) { const btTypedConstraint::btConstraintInfo1& info1 = siData.m_tmpConstraintSizesPool[i]; if (info1.m_numConstraintRows) { btAssert(currentRow < totalNumRows); btSolverConstraint* currentConstraintRow = &siData.m_tmpSolverNonContactConstraintPool[currentRow]; btTypedConstraint* constraint = constraints[i]; btRigidBody& rbA = constraint->getRigidBodyA(); btRigidBody& rbB = constraint->getRigidBodyB(); int solverBodyIdA = siData.getOrInitSolverBody(rbA, infoGlobal.m_timeStep); int solverBodyIdB = siData.getOrInitSolverBody(rbB, infoGlobal.m_timeStep); convertJointInternal(siData.m_tmpSolverBodyPool, siData.m_maxOverrideNumSolverIterations, currentConstraintRow, constraint, info1, solverBodyIdA, solverBodyIdB, infoGlobal); } currentRow += info1.m_numConstraintRows; } } void btSequentialImpulseConstraintSolver::convertJoints(btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal) { btSISolverSingleIterationData siData(m_tmpSolverBodyPool, m_tmpSolverContactConstraintPool, m_tmpSolverNonContactConstraintPool, m_tmpSolverContactFrictionConstraintPool, m_tmpSolverContactRollingFrictionConstraintPool, m_orderTmpConstraintPool, m_orderNonContactConstraintPool, m_orderFrictionConstraintPool, m_tmpConstraintSizesPool, m_resolveSingleConstraintRowGeneric, m_resolveSingleConstraintRowLowerLimit, m_resolveSplitPenetrationImpulse, m_kinematicBodyUniqueIdToSolverBodyTable, m_btSeed2, m_fixedBodyId, m_maxOverrideNumSolverIterations); convertJointsInternal(siData, constraints, numConstraints, infoGlobal); } void btSequentialImpulseConstraintSolver::convertBodiesInternal(btSISolverSingleIterationData& siData, btCollisionObject** bodies, int numBodies, const btContactSolverInfo& infoGlobal) { BT_PROFILE("convertBodies"); for (int i = 0; i < numBodies; i++) { bodies[i]->setCompanionId(-1); } #if BT_THREADSAFE siData.m_kinematicBodyUniqueIdToSolverBodyTable.resize(0); #endif // BT_THREADSAFE siData.m_tmpSolverBodyPool.reserve(numBodies + 1); siData.m_tmpSolverBodyPool.resize(0); //btSolverBody& fixedBody = m_tmpSolverBodyPool.expand(); //initSolverBody(&fixedBody,0); for (int i = 0; i < numBodies; i++) { int bodyId = siData.getOrInitSolverBody(*bodies[i], infoGlobal.m_timeStep); btRigidBody* body = btRigidBody::upcast(bodies[i]); if (body && body->getInvMass()) { btSolverBody& solverBody = siData.m_tmpSolverBodyPool[bodyId]; btVector3 gyroForce(0, 0, 0); if (body->getFlags() & BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT) { gyroForce = body->computeGyroscopicForceExplicit(infoGlobal.m_maxGyroscopicForce); solverBody.m_externalTorqueImpulse -= gyroForce * body->getInvInertiaTensorWorld() * infoGlobal.m_timeStep; } if (body->getFlags() & BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD) { gyroForce = body->computeGyroscopicImpulseImplicit_World(infoGlobal.m_timeStep); solverBody.m_externalTorqueImpulse += gyroForce; } if (body->getFlags() & BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY) { gyroForce = body->computeGyroscopicImpulseImplicit_Body(infoGlobal.m_timeStep); solverBody.m_externalTorqueImpulse += gyroForce; } } } } void btSequentialImpulseConstraintSolver::convertBodies(btCollisionObject** bodies, int numBodies, const btContactSolverInfo& infoGlobal) { btSISolverSingleIterationData siData(m_tmpSolverBodyPool, m_tmpSolverContactConstraintPool, m_tmpSolverNonContactConstraintPool, m_tmpSolverContactFrictionConstraintPool, m_tmpSolverContactRollingFrictionConstraintPool, m_orderTmpConstraintPool, m_orderNonContactConstraintPool, m_orderFrictionConstraintPool, m_tmpConstraintSizesPool, m_resolveSingleConstraintRowGeneric, m_resolveSingleConstraintRowLowerLimit, m_resolveSplitPenetrationImpulse, m_kinematicBodyUniqueIdToSolverBodyTable, m_btSeed2, m_fixedBodyId, m_maxOverrideNumSolverIterations); convertBodiesInternal(siData, bodies, numBodies, infoGlobal); } btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal, btIDebugDraw* debugDrawer) { m_fixedBodyId = -1; BT_PROFILE("solveGroupCacheFriendlySetup"); (void)debugDrawer; // if solver mode has changed, if (infoGlobal.m_solverMode != m_cachedSolverMode) { // update solver functions to use SIMD or non-SIMD bool useSimd = !!(infoGlobal.m_solverMode & SOLVER_SIMD); setupSolverFunctions(useSimd); m_cachedSolverMode = infoGlobal.m_solverMode; } m_maxOverrideNumSolverIterations = 0; #ifdef BT_ADDITIONAL_DEBUG //make sure that dynamic bodies exist for all (enabled) constraints for (int i = 0; i < numConstraints; i++) { btTypedConstraint* constraint = constraints[i]; if (constraint->isEnabled()) { if (!constraint->getRigidBodyA().isStaticOrKinematicObject()) { bool found = false; for (int b = 0; b < numBodies; b++) { if (&constraint->getRigidBodyA() == bodies[b]) { found = true; break; } } btAssert(found); } if (!constraint->getRigidBodyB().isStaticOrKinematicObject()) { bool found = false; for (int b = 0; b < numBodies; b++) { if (&constraint->getRigidBodyB() == bodies[b]) { found = true; break; } } btAssert(found); } } } //make sure that dynamic bodies exist for all contact manifolds for (int i = 0; i < numManifolds; i++) { if (!manifoldPtr[i]->getBody0()->isStaticOrKinematicObject()) { bool found = false; for (int b = 0; b < numBodies; b++) { if (manifoldPtr[i]->getBody0() == bodies[b]) { found = true; break; } } btAssert(found); } if (!manifoldPtr[i]->getBody1()->isStaticOrKinematicObject()) { bool found = false; for (int b = 0; b < numBodies; b++) { if (manifoldPtr[i]->getBody1() == bodies[b]) { found = true; break; } } btAssert(found); } } #endif //BT_ADDITIONAL_DEBUG //convert all bodies convertBodies(bodies, numBodies, infoGlobal); convertJoints(constraints, numConstraints, infoGlobal); convertContacts(manifoldPtr, numManifolds, infoGlobal); // btContactSolverInfo info = infoGlobal; int numNonContactPool = m_tmpSolverNonContactConstraintPool.size(); int numConstraintPool = m_tmpSolverContactConstraintPool.size(); int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.size(); ///@todo: use stack allocator for such temporarily memory, same for solver bodies/constraints m_orderNonContactConstraintPool.resizeNoInitialize(numNonContactPool); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) m_orderTmpConstraintPool.resizeNoInitialize(numConstraintPool * 2); else m_orderTmpConstraintPool.resizeNoInitialize(numConstraintPool); m_orderFrictionConstraintPool.resizeNoInitialize(numFrictionPool); { int i; for (i = 0; i < numNonContactPool; i++) { m_orderNonContactConstraintPool[i] = i; } for (i = 0; i < numConstraintPool; i++) { m_orderTmpConstraintPool[i] = i; } for (i = 0; i < numFrictionPool; i++) { m_orderFrictionConstraintPool[i] = i; } } return 0.f; } btScalar btSequentialImpulseConstraintSolver::solveSingleIterationInternal(btSISolverSingleIterationData& siData, int iteration, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal) { BT_PROFILE("solveSingleIteration"); btScalar leastSquaresResidual = 0.f; int numNonContactPool = siData.m_tmpSolverNonContactConstraintPool.size(); int numConstraintPool = siData.m_tmpSolverContactConstraintPool.size(); int numFrictionPool = siData.m_tmpSolverContactFrictionConstraintPool.size(); if (infoGlobal.m_solverMode & SOLVER_RANDMIZE_ORDER) { if (1) // uncomment this for a bit less random ((iteration & 7) == 0) { for (int j = 0; j < numNonContactPool; ++j) { int tmp = siData.m_orderNonContactConstraintPool[j]; int swapi = btRandInt2a(j + 1, siData.m_seed); siData.m_orderNonContactConstraintPool[j] = siData.m_orderNonContactConstraintPool[swapi]; siData.m_orderNonContactConstraintPool[swapi] = tmp; } //contact/friction constraints are not solved more than if (iteration < infoGlobal.m_numIterations) { for (int j = 0; j < numConstraintPool; ++j) { int tmp = siData.m_orderTmpConstraintPool[j]; int swapi = btRandInt2a(j + 1, siData.m_seed); siData.m_orderTmpConstraintPool[j] = siData.m_orderTmpConstraintPool[swapi]; siData.m_orderTmpConstraintPool[swapi] = tmp; } for (int j = 0; j < numFrictionPool; ++j) { int tmp = siData.m_orderFrictionConstraintPool[j]; int swapi = btRandInt2a(j + 1, siData.m_seed); siData.m_orderFrictionConstraintPool[j] = siData.m_orderFrictionConstraintPool[swapi]; siData.m_orderFrictionConstraintPool[swapi] = tmp; } } } } ///solve all joint constraints for (int j = 0; j < siData.m_tmpSolverNonContactConstraintPool.size(); j++) { btSolverConstraint& constraint = siData.m_tmpSolverNonContactConstraintPool[siData.m_orderNonContactConstraintPool[j]]; if (iteration < constraint.m_overrideNumSolverIterations) { btScalar residual = siData.m_resolveSingleConstraintRowGeneric(siData.m_tmpSolverBodyPool[constraint.m_solverBodyIdA], siData.m_tmpSolverBodyPool[constraint.m_solverBodyIdB], constraint); leastSquaresResidual = btMax(leastSquaresResidual, residual * residual); } } if (iteration < infoGlobal.m_numIterations) { for (int j = 0; j < numConstraints; j++) { if (constraints[j]->isEnabled()) { int bodyAid = siData.getSolverBody(constraints[j]->getRigidBodyA()); int bodyBid = siData.getSolverBody(constraints[j]->getRigidBodyB()); btSolverBody& bodyA = siData.m_tmpSolverBodyPool[bodyAid]; btSolverBody& bodyB = siData.m_tmpSolverBodyPool[bodyBid]; constraints[j]->solveConstraintObsolete(bodyA, bodyB, infoGlobal.m_timeStep); } } ///solve all contact constraints if (infoGlobal.m_solverMode & SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS) { int numPoolConstraints = siData.m_tmpSolverContactConstraintPool.size(); int multiplier = (infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) ? 2 : 1; for (int c = 0; c < numPoolConstraints; c++) { btScalar totalImpulse = 0; { const btSolverConstraint& solveManifold = siData.m_tmpSolverContactConstraintPool[siData.m_orderTmpConstraintPool[c]]; btScalar residual = siData.m_resolveSingleConstraintRowLowerLimit(siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB], solveManifold); leastSquaresResidual = btMax(leastSquaresResidual, residual * residual); totalImpulse = solveManifold.m_appliedImpulse; } bool applyFriction = true; if (applyFriction) { { btSolverConstraint& solveManifold = siData.m_tmpSolverContactFrictionConstraintPool[siData.m_orderFrictionConstraintPool[c * multiplier]]; if (totalImpulse > btScalar(0)) { solveManifold.m_lowerLimit = -(solveManifold.m_friction * totalImpulse); solveManifold.m_upperLimit = solveManifold.m_friction * totalImpulse; btScalar residual = siData.m_resolveSingleConstraintRowGeneric(siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB], solveManifold); leastSquaresResidual = btMax(leastSquaresResidual, residual * residual); } } if (infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) { btSolverConstraint& solveManifold = siData.m_tmpSolverContactFrictionConstraintPool[siData.m_orderFrictionConstraintPool[c * multiplier + 1]]; if (totalImpulse > btScalar(0)) { solveManifold.m_lowerLimit = -(solveManifold.m_friction * totalImpulse); solveManifold.m_upperLimit = solveManifold.m_friction * totalImpulse; btScalar residual = siData.m_resolveSingleConstraintRowGeneric(siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB], solveManifold); leastSquaresResidual = btMax(leastSquaresResidual, residual * residual); } } } } } else //SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS { //solve the friction constraints after all contact constraints, don't interleave them int numPoolConstraints = siData.m_tmpSolverContactConstraintPool.size(); int j; for (j = 0; j < numPoolConstraints; j++) { const btSolverConstraint& solveManifold = siData.m_tmpSolverContactConstraintPool[siData.m_orderTmpConstraintPool[j]]; btScalar residual = siData.m_resolveSingleConstraintRowLowerLimit(siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB], solveManifold); leastSquaresResidual = btMax(leastSquaresResidual, residual * residual); } ///solve all friction constraints int numFrictionPoolConstraints = siData.m_tmpSolverContactFrictionConstraintPool.size(); for (j = 0; j < numFrictionPoolConstraints; j++) { btSolverConstraint& solveManifold = siData.m_tmpSolverContactFrictionConstraintPool[siData.m_orderFrictionConstraintPool[j]]; btScalar totalImpulse = siData.m_tmpSolverContactConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; if (totalImpulse > btScalar(0)) { solveManifold.m_lowerLimit = -(solveManifold.m_friction * totalImpulse); solveManifold.m_upperLimit = solveManifold.m_friction * totalImpulse; btScalar residual = siData.m_resolveSingleConstraintRowGeneric(siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB], solveManifold); leastSquaresResidual = btMax(leastSquaresResidual, residual * residual); } } } int numRollingFrictionPoolConstraints = siData.m_tmpSolverContactRollingFrictionConstraintPool.size(); for (int j = 0; j < numRollingFrictionPoolConstraints; j++) { btSolverConstraint& rollingFrictionConstraint = siData.m_tmpSolverContactRollingFrictionConstraintPool[j]; btScalar totalImpulse = siData.m_tmpSolverContactConstraintPool[rollingFrictionConstraint.m_frictionIndex].m_appliedImpulse; if (totalImpulse > btScalar(0)) { btScalar rollingFrictionMagnitude = rollingFrictionConstraint.m_friction * totalImpulse; if (rollingFrictionMagnitude > rollingFrictionConstraint.m_friction) rollingFrictionMagnitude = rollingFrictionConstraint.m_friction; rollingFrictionConstraint.m_lowerLimit = -rollingFrictionMagnitude; rollingFrictionConstraint.m_upperLimit = rollingFrictionMagnitude; btScalar residual = siData.m_resolveSingleConstraintRowGeneric(siData.m_tmpSolverBodyPool[rollingFrictionConstraint.m_solverBodyIdA], siData.m_tmpSolverBodyPool[rollingFrictionConstraint.m_solverBodyIdB], rollingFrictionConstraint); leastSquaresResidual = btMax(leastSquaresResidual, residual * residual); } } } return leastSquaresResidual; } btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration, btCollisionObject** /*bodies */, int /*numBodies*/, btPersistentManifold** /*manifoldPtr*/, int /*numManifolds*/, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal, btIDebugDraw* /*debugDrawer*/) { btSISolverSingleIterationData siData(m_tmpSolverBodyPool, m_tmpSolverContactConstraintPool, m_tmpSolverNonContactConstraintPool, m_tmpSolverContactFrictionConstraintPool, m_tmpSolverContactRollingFrictionConstraintPool, m_orderTmpConstraintPool, m_orderNonContactConstraintPool, m_orderFrictionConstraintPool, m_tmpConstraintSizesPool, m_resolveSingleConstraintRowGeneric, m_resolveSingleConstraintRowLowerLimit, m_resolveSplitPenetrationImpulse, m_kinematicBodyUniqueIdToSolverBodyTable, m_btSeed2, m_fixedBodyId, m_maxOverrideNumSolverIterations); btScalar leastSquaresResidual = btSequentialImpulseConstraintSolver::solveSingleIterationInternal(siData, iteration, constraints, numConstraints, infoGlobal); return leastSquaresResidual; } void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal, btIDebugDraw* debugDrawer) { btSISolverSingleIterationData siData(m_tmpSolverBodyPool, m_tmpSolverContactConstraintPool, m_tmpSolverNonContactConstraintPool, m_tmpSolverContactFrictionConstraintPool, m_tmpSolverContactRollingFrictionConstraintPool, m_orderTmpConstraintPool, m_orderNonContactConstraintPool, m_orderFrictionConstraintPool, m_tmpConstraintSizesPool, m_resolveSingleConstraintRowGeneric, m_resolveSingleConstraintRowLowerLimit, m_resolveSplitPenetrationImpulse, m_kinematicBodyUniqueIdToSolverBodyTable, m_btSeed2, m_fixedBodyId, m_maxOverrideNumSolverIterations); solveGroupCacheFriendlySplitImpulseIterationsInternal(siData, bodies, numBodies, manifoldPtr, numManifolds, constraints, numConstraints, infoGlobal, debugDrawer); } void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIterationsInternal(btSISolverSingleIterationData& siData, btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal, btIDebugDraw* debugDrawer) { BT_PROFILE("solveGroupCacheFriendlySplitImpulseIterations"); int iteration; if (infoGlobal.m_splitImpulse) { { for (iteration = 0; iteration < infoGlobal.m_numIterations; iteration++) { btScalar leastSquaresResidual = 0.f; { int numPoolConstraints = siData.m_tmpSolverContactConstraintPool.size(); int j; for (j = 0; j < numPoolConstraints; j++) { const btSolverConstraint& solveManifold = siData.m_tmpSolverContactConstraintPool[siData.m_orderTmpConstraintPool[j]]; btScalar residual = siData.m_resolveSplitPenetrationImpulse(siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], siData.m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB], solveManifold); leastSquaresResidual = btMax(leastSquaresResidual, residual * residual); } } if (leastSquaresResidual <= infoGlobal.m_leastSquaresResidualThreshold || iteration >= (infoGlobal.m_numIterations - 1)) { #ifdef VERBOSE_RESIDUAL_PRINTF printf("residual = %f at iteration #%d\n", leastSquaresResidual, iteration); #endif break; } } } } } btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal, btIDebugDraw* debugDrawer) { BT_PROFILE("solveGroupCacheFriendlyIterations"); { ///this is a special step to resolve penetrations (just for contacts) solveGroupCacheFriendlySplitImpulseIterations(bodies, numBodies, manifoldPtr, numManifolds, constraints, numConstraints, infoGlobal, debugDrawer); int maxIterations = m_maxOverrideNumSolverIterations > infoGlobal.m_numIterations ? m_maxOverrideNumSolverIterations : infoGlobal.m_numIterations; for (int iteration = 0; iteration < maxIterations; iteration++) //for ( int iteration = maxIterations-1 ; iteration >= 0;iteration--) { m_leastSquaresResidual = solveSingleIteration(iteration, bodies, numBodies, manifoldPtr, numManifolds, constraints, numConstraints, infoGlobal, debugDrawer); if (m_leastSquaresResidual <= infoGlobal.m_leastSquaresResidualThreshold || (iteration >= (maxIterations - 1))) { #ifdef VERBOSE_RESIDUAL_PRINTF printf("residual = %f at iteration #%d\n", m_leastSquaresResidual, iteration); #endif break; } } } return 0.f; } void btSequentialImpulseConstraintSolver::writeBackContactsInternal(btConstraintArray& tmpSolverContactConstraintPool, btConstraintArray& tmpSolverContactFrictionConstraintPool, int iBegin, int iEnd, const btContactSolverInfo& infoGlobal) { for (int j = iBegin; j < iEnd; j++) { const btSolverConstraint& solveManifold = tmpSolverContactConstraintPool[j]; btManifoldPoint* pt = (btManifoldPoint*)solveManifold.m_originalContactPoint; btAssert(pt); pt->m_appliedImpulse = solveManifold.m_appliedImpulse; // float f = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; // printf("pt->m_appliedImpulseLateral1 = %f\n", f); pt->m_appliedImpulseLateral1 = tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; //printf("pt->m_appliedImpulseLateral1 = %f\n", pt->m_appliedImpulseLateral1); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { pt->m_appliedImpulseLateral2 = tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex + 1].m_appliedImpulse; } //do a callback here? } } void btSequentialImpulseConstraintSolver::writeBackContacts(int iBegin, int iEnd, const btContactSolverInfo& infoGlobal) { writeBackContactsInternal(m_tmpSolverContactConstraintPool, m_tmpSolverContactFrictionConstraintPool, iBegin, iEnd, infoGlobal); } void btSequentialImpulseConstraintSolver::writeBackJoints(int iBegin, int iEnd, const btContactSolverInfo& infoGlobal) { writeBackJointsInternal(m_tmpSolverNonContactConstraintPool, iBegin, iEnd, infoGlobal); } void btSequentialImpulseConstraintSolver::writeBackJointsInternal(btConstraintArray& tmpSolverNonContactConstraintPool, int iBegin, int iEnd, const btContactSolverInfo& infoGlobal) { for (int j = iBegin; j < iEnd; j++) { const btSolverConstraint& solverConstr = tmpSolverNonContactConstraintPool[j]; btTypedConstraint* constr = (btTypedConstraint*)solverConstr.m_originalContactPoint; btJointFeedback* fb = constr->getJointFeedback(); if (fb) { fb->m_appliedForceBodyA += solverConstr.m_contactNormal1 * solverConstr.m_appliedImpulse * constr->getRigidBodyA().getLinearFactor() / infoGlobal.m_timeStep; fb->m_appliedForceBodyB += solverConstr.m_contactNormal2 * solverConstr.m_appliedImpulse * constr->getRigidBodyB().getLinearFactor() / infoGlobal.m_timeStep; fb->m_appliedTorqueBodyA += solverConstr.m_relpos1CrossNormal * constr->getRigidBodyA().getAngularFactor() * solverConstr.m_appliedImpulse / infoGlobal.m_timeStep; fb->m_appliedTorqueBodyB += solverConstr.m_relpos2CrossNormal * constr->getRigidBodyB().getAngularFactor() * solverConstr.m_appliedImpulse / infoGlobal.m_timeStep; /*RGM ???? */ } constr->internalSetAppliedImpulse(solverConstr.m_appliedImpulse); if (btFabs(solverConstr.m_appliedImpulse) >= constr->getBreakingImpulseThreshold()) { constr->setEnabled(false); } } } void btSequentialImpulseConstraintSolver::writeBackBodies(int iBegin, int iEnd, const btContactSolverInfo& infoGlobal) { writeBackBodiesInternal(m_tmpSolverBodyPool, iBegin, iEnd, infoGlobal); } void btSequentialImpulseConstraintSolver::writeBackBodiesInternal(btAlignedObjectArray<btSolverBody>& tmpSolverBodyPool, int iBegin, int iEnd, const btContactSolverInfo& infoGlobal) { for (int i = iBegin; i < iEnd; i++) { btRigidBody* body = tmpSolverBodyPool[i].m_originalBody; if (body) { if (infoGlobal.m_splitImpulse) tmpSolverBodyPool[i].writebackVelocityAndTransform(infoGlobal.m_timeStep, infoGlobal.m_splitImpulseTurnErp); else tmpSolverBodyPool[i].writebackVelocity(); tmpSolverBodyPool[i].m_originalBody->setLinearVelocity( tmpSolverBodyPool[i].m_linearVelocity + tmpSolverBodyPool[i].m_externalForceImpulse); tmpSolverBodyPool[i].m_originalBody->setAngularVelocity( tmpSolverBodyPool[i].m_angularVelocity + tmpSolverBodyPool[i].m_externalTorqueImpulse); if (infoGlobal.m_splitImpulse) tmpSolverBodyPool[i].m_originalBody->setWorldTransform(tmpSolverBodyPool[i].m_worldTransform); tmpSolverBodyPool[i].m_originalBody->setCompanionId(-1); } } } btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyFinishInternal(btSISolverSingleIterationData& siData, btCollisionObject** bodies, int numBodies, const btContactSolverInfo& infoGlobal) { BT_PROFILE("solveGroupCacheFriendlyFinish"); if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) { writeBackContactsInternal(siData.m_tmpSolverContactConstraintPool, siData.m_tmpSolverContactFrictionConstraintPool, 0, siData.m_tmpSolverContactConstraintPool.size(), infoGlobal); } writeBackJointsInternal(siData.m_tmpSolverNonContactConstraintPool, 0, siData.m_tmpSolverNonContactConstraintPool.size(), infoGlobal); writeBackBodiesInternal(siData.m_tmpSolverBodyPool, 0, siData.m_tmpSolverBodyPool.size(), infoGlobal); siData.m_tmpSolverContactConstraintPool.resizeNoInitialize(0); siData.m_tmpSolverNonContactConstraintPool.resizeNoInitialize(0); siData.m_tmpSolverContactFrictionConstraintPool.resizeNoInitialize(0); siData.m_tmpSolverContactRollingFrictionConstraintPool.resizeNoInitialize(0); siData.m_tmpSolverBodyPool.resizeNoInitialize(0); return 0.f; } btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyFinish(btCollisionObject** bodies, int numBodies, const btContactSolverInfo& infoGlobal) { btSISolverSingleIterationData siData(m_tmpSolverBodyPool, m_tmpSolverContactConstraintPool, m_tmpSolverNonContactConstraintPool, m_tmpSolverContactFrictionConstraintPool, m_tmpSolverContactRollingFrictionConstraintPool, m_orderTmpConstraintPool, m_orderNonContactConstraintPool, m_orderFrictionConstraintPool, m_tmpConstraintSizesPool, m_resolveSingleConstraintRowGeneric, m_resolveSingleConstraintRowLowerLimit, m_resolveSplitPenetrationImpulse, m_kinematicBodyUniqueIdToSolverBodyTable, m_btSeed2, m_fixedBodyId, m_maxOverrideNumSolverIterations); return btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyFinishInternal(siData, bodies, numBodies, infoGlobal); } /// btSequentialImpulseConstraintSolver Sequentially applies impulses btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal, btIDebugDraw* debugDrawer, btDispatcher* /*dispatcher*/) { BT_PROFILE("solveGroup"); //you need to provide at least some bodies solveGroupCacheFriendlySetup(bodies, numBodies, manifoldPtr, numManifolds, constraints, numConstraints, infoGlobal, debugDrawer); solveGroupCacheFriendlyIterations(bodies, numBodies, manifoldPtr, numManifolds, constraints, numConstraints, infoGlobal, debugDrawer); solveGroupCacheFriendlyFinish(bodies, numBodies, infoGlobal); return 0.f; } void btSequentialImpulseConstraintSolver::reset() { m_btSeed2 = 0; }
c8698623d161b3cb63d251145cda1cae6ad4536e
d17dad93f236e20d8be9e7cf48f67d8e1f03d081
/liblava/app/def.hpp
c2523b583b64422d67378d46fcc680dc52c71ad9
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
torss/liblava
4bd9e3d69ffe8a81ad14df4a7e89246d362210c9
1e7dc2a9e645107e1fa842182986f6307d79c4b1
refs/heads/master
2021-01-16T07:59:41.319311
2020-07-22T17:11:23
2020-07-22T17:11:23
243,033,039
0
0
MIT
2020-02-29T22:01:10
2020-02-25T15:24:31
C++
UTF-8
C++
false
false
636
hpp
// file : liblava/app/def.hpp // copyright : Copyright (c) 2018-present, Lava Block OÜ // license : MIT; see accompanying LICENSE file #pragma once #include <liblava/core/types.hpp> namespace lava { // config constexpr name _paused_ = "paused"; constexpr name _speed_ = "speed"; constexpr name _auto_save_ = "auto save"; constexpr name _save_interval_ = "save interval"; constexpr name _auto_load_ = "auto load"; constexpr name _fixed_delta_ = "fixed delta"; constexpr name _delta_ = "delta"; constexpr name _gui_ = "gui"; constexpr name _v_sync_ = "v-sync"; constexpr name _physical_device_ = "physical device"; } // lava
53910aae75a21cf841528f9d390f32a9da0df380
30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a
/Codes/AC/713.cpp
03123818cb5775bc9863f01d4da860dad6161ad9
[]
no_license
thegamer1907/Code_Analysis
0a2bb97a9fb5faf01d983c223d9715eb419b7519
48079e399321b585efc8a2c6a84c25e2e7a22a61
refs/heads/master
2020-05-27T01:20:55.921937
2019-11-20T11:15:11
2019-11-20T11:15:11
188,403,594
2
1
null
null
null
null
UTF-8
C++
false
false
516
cpp
#include <bits/stdc++.h> using namespace std; vector<int> V; char cc[20]; void dfs(int lv, int sum) { if(sum > 10) return; if(lv == 8 && sum != 10) return; if(lv == 8) { int now; sscanf(cc, "%d", &now); V.emplace_back(now); return; } for(int i = 0; i < 10; ++i) { cc[lv] = i + '0'; dfs(lv + 1, sum + i); } } int main() { // freopen("r", "r", stdin); int n; scanf("%d", &n); V.reserve(100000); dfs(0, 0); printf("%d\n", V[n-1]); }
3097ca086a9d963b9b6d570829da529b74e9704f
d928deb5c5906caea11a39e251c471384f16d7c1
/catkin_ws/src/racer/include/racer/vehicle/configuration.h
dba2937c1a02e5c7e0d1901209b071c4a10f83a3
[ "MIT" ]
permissive
simonrozsival/racer
1f9f50d55c9df33a6dc6828bc4110584617bac58
9212eb176dfa422456440989a8912f0eb6f5aa2d
refs/heads/master
2021-05-01T16:05:18.820862
2020-07-07T21:37:42
2020-07-07T21:37:42
121,040,539
3
1
null
null
null
null
UTF-8
C++
false
false
1,443
h
#pragma once #include "racer/math.h" namespace racer::vehicle { struct configuration { private: racer::math::point location_; racer::math::angle heading_angle_; bool is_valid_; public: configuration(double x, double y, double heading_angle) : location_{x, y}, heading_angle_{heading_angle}, is_valid_{true} { } configuration(racer::math::point location, double heading_angle) : location_{location}, heading_angle_{heading_angle}, is_valid_{true} { } configuration() : location_{0, 0}, heading_angle_{0}, is_valid_{false} { } configuration(const configuration &copy_from) = default; configuration &operator=(const configuration &copy_from) = default; configuration(configuration &&pos) = default; configuration &operator=(configuration &&pos) = default; inline bool operator==(const configuration &other) const { return location_ == other.location_ && heading_angle_ == other.heading_angle_; } inline bool is_valid() const { return is_valid_; } configuration operator+(const configuration &other) const { return configuration(location_ + other.location_, heading_angle_ + other.heading_angle_); } inline const racer::math::point &location() const { return location_; } inline const racer::math::angle &heading_angle() const { return heading_angle_; } }; } // namespace racer
0fa7019cc30102ffd1b2431114e268168406d965
86f9dd1176a3aa6f7a9b472d91de97791c19ae2d
/Domains/ATFMSectorDomain/ATFMSectorDomainRAGS.cpp
69546b6da424802bde0cb315ab19156e2b62f305
[]
no_license
MorS25/libraries
6139f3e6856cdad836930fa51c4790a896ed8dc0
d595819ab2aabbe7b34e0c33898b4682b40532d3
refs/heads/master
2021-05-31T05:36:47.396330
2015-09-19T00:53:52
2015-09-19T00:53:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,278
cpp
#include "ATFMSectorDomainRAGS.h" using namespace std; using namespace easymath; UAV::UAV(XY start_loc, XY goal_loc, UAVType type, vector<XY> &locations, vector<RAGS::edge> &edge_array, matrix2d weights): next_loc(start_loc), end_loc(goal_loc), type_ID(type) { t = 0 ; itsRAGS = new RAGS(locations, edge_array, weights) ; switch(t){ case SLOW: speed = 1; break; case FAST: // substitute: high priority speed = 1; //speed = 2; break; default:{ //printf("no speed found!!"); speed = 1; //system("pause"); break; } } }; void UAV::pathPlan(bool abstraction_mode, vector<double> &connection_time, vector<double> &weights) { if (abstraction_mode){ if (t == 0){ // reached new sector loc = next_loc ; if (!(loc == end_loc)){ // have not reached destination next_loc = itsRAGS->SearchGraph(loc,end_loc,weights) ; int i = itsRAGS->GetEdgeIndex(loc,next_loc) ; t = connection_time[i] ; } } else t-- ; } else { printf("ERROR: Simulation currently only available in abstraction mode. Exiting.\n") ; exit(1) ; } } int UAV::getDirection(){ // Identifies whether traveling in one of four cardinal directions return cardinalDirection(next_loc-loc); } Sector::Sector(XY xy): xy(xy) { } Fix::Fix(XY loc, int ID_set, bool deterministic): is_deterministic(deterministic), ID(ID_set), loc(loc), //p_gen(0.05) // change to 1.0 if traffic controlled elsewhere p_gen(int(is_deterministic)*(1.0-0.05)+0.05), // modifies to depend on if deterministic dist_thresh(2.0) { } bool Fix::atDestinationFix(const UAV &u){ return u.end_loc == loc; } list<UAV*> Fix::generateTraffic(vector<Fix>* allFixes, barrier_grid* obstacle_map, vector<XY> &locations, vector<RAGS::edge> &edge_array, matrix3d &weights){ static int calls = 0; // Creates a new UAV in the world std::list<UAV*> newTraffic; // CONSTANT TRAFFIC FLOW METHOD double coin = COIN_FLOOR0; if (coin<p_gen){ XY end_loc; if (ID==0){ end_loc = allFixes->back().loc; } else { end_loc = allFixes->at(ID-1).loc; // go to previous } UAV::UAVType type_id_set = UAV::UAVType(calls%int(UAV::UAVType::NTYPES)); // EVEN TYPE NUMBER UAV * newUAV = new UAV(loc,end_loc,type_id_set,locations,edge_array,weights[type_id_set]) ; newTraffic.push_back(newUAV); } /* VARIABLE TRAFFIC METHOD double coin = COIN_FLOOR0; if (coin<p_gen){ XY end_loc; do { end_loc = allFixes->at(COIN_FLOOR0*allFixes->size()).loc; } while (end_loc==loc); UAV::UAVType type_id_set = UAV::UAVType(calls%int(UAV::UAVType::NTYPES)); // EVEN TYPE NUMBER newTraffic.push_back(UAV(loc,end_loc,type_id_set,search)); }*/ calls++; return newTraffic; } ATFMSectorDomain::ATFMSectorDomain(bool deterministic): is_deterministic(deterministic), abstraction_mode(true) // hardcode for the abstraction... { // Object creation sectors = new vector<Sector>(); fixes = new vector<Fix>(); UAVs = new list<UAV*>(); // Inheritance elements: constant n_control_elements=4*UAV::NTYPES; n_state_elements=4; // 4 state elements for sectors ( number of planes traveling in cardinal directions) n_steps=100; // steps of simulation time n_types=UAV::NTYPES; // Read in files for sector management obstacle_map = new barrier_grid(256,256); membership_map = new ID_grid(256,256); //HARDCODED load_variable(*membership_map,"agent_map/membership_map.csv"); for (int i=0; i<membership_map->dim1(); i++){ for (int j=0; j<membership_map->dim2(); j++){ obstacle_map->at(i,j) = membership_map->at(i,j)<0; } } matrix2d agent_coords = FileManip::readDouble("agent_map/agent_map.csv"); matrix2d connection_map = FileManip::readDouble("agent_map/connections.csv"); matrix2d fix_locs = FileManip::readDouble("agent_map/fixes.csv"); if (abstraction_mode) fix_locs = agent_coords; // if using an abstraction, have only the centers phsyically located // Add sectors agent_locs = vector<XY>(agent_coords.size()); // save this for later Astar recreation for (unsigned i=0; i<agent_coords.size(); i++){ sectors->push_back(Sector(XY(agent_coords[i][0],agent_coords[i][1]))); agent_locs[i] = sectors->back().xy; } // Initialize fixes for (unsigned i=0; i<fix_locs.size(); i++){ fixes->push_back(Fix(XY(fix_locs[i][0],fix_locs[i][1]),i,is_deterministic)); } // Heterogeneous capacity across all types, currently can handle up to 5 types n_agents = sectors->size(); // number of agents dictated by read in file matrix1d type_capacity ; type_capacity.push_back(TYPE1) ; if (UAV::NTYPES > 1) type_capacity.push_back(TYPE2) ; if (UAV::NTYPES > 2) type_capacity.push_back(TYPE3) ; if (UAV::NTYPES > 3) type_capacity.push_back(TYPE4) ; if (UAV::NTYPES > 4) type_capacity.push_back(TYPE5) ; if (UAV::NTYPES > 5) type_capacity.push_back(TYPE6) ; agent_capacity = matrix2d(n_agents,type_capacity) ; // Adjust the connection map to be the edges // preprocess boolean connection map // map edges to (sector ind, direction ind) for (unsigned i=0; i<connection_map.size(); i++){ for (unsigned j=0; j<connection_map[i].size(); j++){ if (connection_map[i][j] && i!=j){ XY xyi = agent_locs[i]; XY xyj = agent_locs[j]; XY dx_dy = xyj-xyi; int xydir = cardinalDirection(dx_dy); int memj = membership_map->at(xyi); // costs applied to outgoing edges sector_dir_map[edges.size()] = make_pair(memj,xydir); // add at new index edges.push_back(RAGS::edge(i,j)); // JEN: store connection times and capacities for abstraction mode if (abstraction_mode){ if (n_agents!=15){ printf("WRONG CONNECTION SIZE!"); exit(1); } // connection_time.push_back(distance(agent_locs[i],agent_locs[j])); // use Euclidean instead of Manhattan XY diff = agent_locs[i]-agent_locs[j]; connection_time.push_back(abs(diff.x)+abs(diff.y)); // use Manhattan distance } } } } // JEN: Initialise weights with variance, log to weights history // Set base edge costs as connection_time + connection_time * agent_action // initialise agent actions to 1.0 to give initial estimate of cost as 2*connection_time // initialise variance to 0.3 weights = matrix3d(2) ; matrix2d w_mean(UAV::NTYPES) ; matrix2d w_var(UAV::NTYPES) ; for (unsigned i=0; i<w_mean.size(); i++){ w_mean[i] = DotMultiply(connection_time,2.0);//************************************************* w_var[i] = DotMultiply(connection_time,0.3);//************************************************** } weights[0] = w_mean ; weights[1] = w_var ; weights_history.push_back(weights[0]) ; conflict_count = 0; // initialize with no conflicts conflict_count_map = new ID_grid(obstacle_map->dim1(), obstacle_map->dim2()); } ATFMSectorDomain::~ATFMSectorDomain(void) { for (list<UAV*>::iterator u=UAVs->begin(); u!=UAVs->end(); u++){ delete (*u) ; } delete UAVs; delete fixes; delete sectors; delete obstacle_map; delete membership_map; delete conflict_count_map; } vector<double> ATFMSectorDomain::getPerformance(){ if (abstraction_mode){ return globalPerformance ; } else { return matrix1d(sectors->size(),-conflict_count); } } vector<double> ATFMSectorDomain::getRewards(){ // LINEAR REWARD if (!abstraction_mode){ return matrix1d(sectors->size(),-conflict_count); // linear reward // QUADRATIC REWARD /*int conflict_sum = 0; for (int i=0; i<conflict_count_map->size(); i++){ for (int j=0; j<conflict_count_map->at(i).size(); j++){ int c = conflict_count_map->at(i)[j]; conflict_sum += c*c; } } return matrix1d(sectors->size(),-conflict_sum);*/ } else { //int overcap[n_agents][UAV::NTYPES]; matrix1d D ; globalPerformance.clear() ; for (int k = 0; k < n_agents; k++){ double G_c = 0.0 ; double G_reg = 0.0 ; for (unsigned i=0; i<overcap.size(); i++){ for (unsigned j=0; j<overcap[i].size(); j++){ if (overcap[i][j] < 0.0) G_reg -= abs(overcap[i][j]) ; // use linear cost // G -= overcap[i][j]*overcap[i][j]; // worse with higher concentration of planes!********* if (counterOvercap[k][i][j] < 0.0) G_c -= abs(counterOvercap[k][i][j]) ; } } // return matrix1d(n_agents, G); // global reward globalPerformance.push_back(G_reg) ; D.push_back(G_reg - G_c) ; } // clear overcap once used! overcap = matrix2d(n_agents,matrix1d(UAV::NTYPES,0.0)) ; counterOvercap = matrix3d(n_agents,overcap) ; return D ; } } matrix2d ATFMSectorDomain::getStates(){ // States: delay assignments for UAVs that need routing matrix2d allStates(n_agents); for (int i=0; i<n_agents; i++){ allStates[i] = matrix1d(n_state_elements,0.0); // reserves space } for (list<UAV*>::iterator u=UAVs->begin(); u!=UAVs->end(); u++){ allStates[getSector((*u)->loc)][(*u)->getDirection()]+=1.0; // Adds the UAV impact on the state } return allStates; } matrix3d ATFMSectorDomain::getTypeStates(){ matrix3d allStates(n_agents); for (int i=0; i<n_agents; i++){ allStates[i] = matrix2d(n_types); for (int j=0; j<n_types; j++){ allStates[i][j] = matrix1d(n_state_elements,0.0); } } for (list<UAV*>::iterator u=UAVs->begin(); u!=UAVs->end(); u++){ int a = getSector((*u)->loc); int id = (*u)->type_ID; int dir = (*u)->getDirection(); if (a<0){ printf("UAV %i at location %f,%f is in an obstacle.!", (*u)->ID,(*u)->loc.x,(*u)->loc.y); system("pause"); } allStates[a][id][dir]+=1.0; } return allStates; } unsigned int ATFMSectorDomain::getSector(easymath::XY p){ // tests membership for sector, given a location return membership_map->at(p); } void ATFMSectorDomain::getPathPlans(){ // sets own next waypoint for (list<UAV*>::iterator u=UAVs->begin(); u!=UAVs->end(); u++){ matrix2d w = weights_history.back() ; (*u)->pathPlan(abstraction_mode, connection_time, w[(*u)->type_ID]); } } void ATFMSectorDomain::simulateStep(matrix2d agent_actions){ static int calls=0; setCostMaps(agent_actions); absorbUAVTraffic(); if (calls%10==0) getNewUAVTraffic(); calls++; getPathPlans(); detectConflicts(); } void ATFMSectorDomain::setCostMaps(vector<vector<double> > agent_actions){ matrix2d w_val = weights_history.back() ; for (unsigned i=0; i<w_val[0].size(); i++){ for (unsigned j=0; j<UAV::NTYPES; j++){ unsigned s = sector_dir_map[i].first; unsigned d = j + sector_dir_map[i].second*(UAV::NTYPES); if (s < 0 || s >= agent_actions.size()) printf("s: %i", s) ; if (d < 0 || d >= agent_actions[s].size()) printf("d: %i", d) ; // Scale agent actions against connection time to compute edge weight w_val[j][i] = (1.0+agent_actions[s][d]) * connection_time[i] ; if (w_val[j][i] < 0.0){ printf("Negative weight at (j,i): (%i,%i), (s,d): (%i,%i)", j, i, s, d) ; printf("w_val[j][i]: %f, agent_actions[s][d]: %f", w_val[j][i], agent_actions[s][d]) ; } } } weights_history.push_back(w_val) ; // Keep most recent 100 weights if (weights_history.size() > 100) weights_history.pop_front() ; // Calculate new mean and variance for edge weights matrix1d w_t(weights_history.size(),0.0) ; for (int i = 0; i < UAV::NTYPES; i++){ for (unsigned j = 0; j < edges.size(); j++){ int k = 0 ; for (list<matrix2d>::iterator w = weights_history.begin(); w != weights_history.end(); w++){ matrix2d wTemp = *w ; w_t[k++] = wTemp[i][j] ; } matrix1d w_mv = calc_mean_var(w_t) ; // Update weights matrix weights[0][i][j] = w_mv[0] ; weights[1][i][j] = w_mv[1] ; } } } void ATFMSectorDomain::absorbUAVTraffic(){ for (list<UAV*>::iterator u=UAVs->begin(); u!=UAVs->end(); u++){ if ((*u)->loc==(*u)->end_loc){ delete (*u) ; u = UAVs->erase(u) ; } } } void ATFMSectorDomain::getNewUAVTraffic(){ // Create RAGS object with current weights history // Generates (with some probability) plane traffic for each sector list<UAV*> all_new_UAVs; // Collate weights for each type of UAV matrix3d w ; matrix2d w_e ; for (int i = 0; i < UAV::NTYPES; i++){ w_e.clear() ; for (unsigned j = 0; j < edges.size(); j++){ matrix1d w_mv(2) ; w_mv[0] = weights[0][i][j] ; w_mv[1] = weights[1][i][j] ; w_e.push_back(w_mv) ; } w.push_back(w_e) ; } // Call Fixes to generate traffic for (unsigned i=0; i<fixes->size(); i++){ list<UAV*> new_UAVs = fixes->at(i).generateTraffic(fixes, obstacle_map, agent_locs, edges, w); all_new_UAVs.splice(all_new_UAVs.end(),new_UAVs); // obstacle check if (new_UAVs.size() && membership_map->at(new_UAVs.front()->loc)<0){ printf("issue!"); exit(1); } } UAVs->splice(UAVs->end(),all_new_UAVs); } void ATFMSectorDomain::reset(){ // static int calls=0; // Drop all UAVs for (list<UAV*>::iterator u=UAVs->begin(); u!=UAVs->end(); u++) delete (*u) ; UAVs->clear(); // Reset conflict counts conflict_count = 0; // Reset weights weights_history.clear() ; weights = matrix3d(2) ; matrix2d w_mean(UAV::NTYPES) ; matrix2d w_var(UAV::NTYPES) ; for (unsigned i=0; i<w_mean.size(); i++){ w_mean[i] = DotMultiply(connection_time,2.0); w_var[i] = DotMultiply(connection_time,0.1); } weights[0] = w_mean ; weights[1] = w_var ; weights_history.push_back(weights[0]) ; // clear conflict count map for (int i=0; i<conflict_count_map->dim1(); i++){ for (int j=0; j<conflict_count_map->dim2(); j++){ conflict_count_map->at(i,j) = 0; // set all 0 } } } void ATFMSectorDomain::logStep(int step){ } void ATFMSectorDomain::exportLog(std::string fid, double G){ static int calls = 0; PrintOut::toFileMatrix2D(*conflict_count_map,fid+to_string(calls)+".csv"); calls++; } void ATFMSectorDomain::detectConflicts(){ if (abstraction_mode){ count_overcap(); CounterFactual() ; } else { double conflict_thresh = 1.0; for (list<UAV*>::iterator u1=UAVs->begin(); u1!=UAVs->end(); u1++){ for (list<UAV*>::iterator u2=std::next(u1); u2!=UAVs->end(); u2++){ double d = easymath::distance((*u1)->loc,(*u2)->loc); if (u1!=u2){ if (d<conflict_thresh){ conflict_count++; int avgx = ((*u1)->loc.x+(*u2)->loc.x)/2; int avgy = ((*u1)->loc.y+(*u2)->loc.y)/2; conflict_count_map->at(avgx,avgy)++; if ((*u1)->type_ID==UAV::FAST || (*u2)->type_ID==UAV::FAST){ conflict_count+=10; // big penalty for high priority ('fast' here) } } } } } } }
e580310030f9e69eecde4f7bfca2988f18bfa969
f7d983b283289d53cb48f1c252269c439499410d
/LabProject06/stdafx.h
ff1af0880e44bbc7bd6708e5bb93c2ba6a2ffe09
[]
no_license
joon-so/DirectX12
4105521393f421e18f677f961ae6455dfa193bae
5855d4dc7076c83a5974ad2dc7f2515d049d1f99
refs/heads/master
2022-11-11T23:21:49.895614
2020-07-04T17:49:22
2020-07-04T17:49:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,415
h
// header.h: 표준 시스템 포함 파일 // 또는 프로젝트 특정 포함 파일이 들어 있는 포함 파일입니다. // #pragma once #include "targetver.h" #define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용을 Windows 헤더에서 제외합니다. // Windows 헤더 파일 #include <windows.h> // C 런타임 헤더 파일입니다. #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <tchar.h> #include <string> #include <wrl.h> #include <shellapi.h> #include <mmsystem.h> #include <d3d12.h> #include <dxgi1_4.h> #include <d3dcompiler.h> #include <DirectXMath.h> #include <DirectXPackedVector.h> #include <DirectXColors.h> #include <DirectXCollision.h> #include <dxgidebug.h> using namespace DirectX; using namespace DirectX::PackedVector; using Microsoft::WRL::ComPtr; #pragma comment(lib, "d3dcompiler.lib") #pragma comment(lib, "d3d12.lib") #pragma comment(lib, "dxgi.lib") #pragma comment(lib, "dxguid.lib") #pragma comment(lib, "winmm.lib") #define FRAME_BUFFER_WIDTH 800 #define FRAME_BUFFER_HEIGHT 600 extern ID3D12Resource* CreateBufferResource(ID3D12Device* pd3dDevice, ID3D12GraphicsCommandList* pd3dCommandList, void* pData, UINT nBytes, D3D12_HEAP_TYPE d3dHeapType = D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_STATES d3dResourceStates = D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER, ID3D12Resource** ppd3dUploadBuffer = NULL);
72406310b58eb91f2d70f359a44125e06e2d53f8
4455bc7b800671428a766afe903a5919610cc834
/LDNI Sampling/LDNIcuda/LDNIDataBoard.h
9a6063775d5331f61d73f1c91f503dbc6baa63f0
[ "Apache-2.0" ]
permissive
mossmao/Minimizing-printing-time-and-volumetric-error-by-GPU-accelerated-adaptive-slicing
e9f07a046dfa52c2c8ad00a0e41fc8c7ef9311c9
e7deff6757158678ffd0d81130045c78fd1fdd41
refs/heads/main
2023-04-21T00:39:17.606799
2021-05-24T17:58:01
2021-05-24T17:58:01
370,394,426
1
0
null
null
null
null
UTF-8
C++
false
false
1,824
h
/* * Copyright (C) 2014, Geometric Design and Manufacturing Lab in THE CHINESE UNIVERSITY OF HONG KONG * All rights reserved. * * http://ldnibasedsolidmodeling.sourceforge.net/ * * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ #ifndef _CCL_LDNI_DATABOARD #define _CCL_LDNI_DATABOARD class PMBody; class LDNISolidBody; class LDNIDataBoard { public: LDNIDataBoard(void); virtual ~LDNIDataBoard(void); PMBody *m_polyMeshBody; LDNISolidBody *m_solidLDNIBody; bool m_bLDNISampleNormalDisplay; }; #endif
d6a06841e047927d542ccbf1f54906b48d2700c6
ce2ff0d5564f96115920490b11bac438f37bd1aa
/log/c++/main.cpp
08446c0841138c2716449e0bd8047a077a89dfbf
[]
no_license
go-steven/learning
7825cb5c95ee46d18c9bc2db0b9444dbccd692b5
a0ed7224216f5ddc61f923f922aae59eae67b46c
refs/heads/master
2021-05-12T06:50:42.461722
2018-01-12T10:21:19
2018-01-12T10:21:19
117,227,059
0
0
null
null
null
null
UTF-8
C++
false
false
1,007
cpp
// run it with: // g++.exe -c main.cpp ./log4cpp -o main.o -I"./include" -I"E:/Dev-Cpp/MinGW64/include" -I"E:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"E:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include" -I"E:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++" // g++.exe main.o -o main.exe -L"E:/Dev-Cpp/MinGW64/lib" -L"E:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc // main.exe #include <iostream> #include "log4cpp/Category.hh" #include "log4cpp/OstreamAppender.hh" #include "log4cpp/BasicLayout.hh" #include "log4cpp/Priority.hh" using namespace std; int main(int argc, char** argv) { log4cpp::OstreamAppender* osAppender = new log4cpp::OstreamAppender("osAppender", &cout); osAppender->setLayout(new log4cpp::BasicLayout()); log4cpp::Category& root =log4cpp::Category::getRoot(); root.addAppender(osAppender); root.setPriority(log4cpp::Priority::DEBUG); root.error("Hello log4cpp in aError Message!"); log4cpp::Category::shutdown(); return 0; }
43a0faf911302ea29fb6f3491bca9affdc48a3ba
f9a445e5846c4ffd22204c99bf1cf9a5a174b1b1
/searchEngine.h
903e11c71906e8fa12fade01d24327306ed8b369
[]
no_license
skashika/Search-Engine
71f8752e9fe38b191edba6d0222c7a874b60a7ae
ec681f42b6f3329290605ebe54aa86d1adee0580
refs/heads/master
2020-12-19T08:21:03.302771
2020-01-22T22:21:10
2020-01-22T22:21:10
235,678,983
0
0
null
null
null
null
UTF-8
C++
false
false
298
h
/* searchEngine.h -> Header file Author -> Shubham Kashikar Date -> 10/16/2019 Compiler -> Repl IT (Online Compiler) */ #include <iostream> #include <vector> using namespace std; class searchEngine { public: void addIndex(string a, string b); string result(string f); };
4d6deea22d7eff0449fc15340767e129655aecdb
d160bb839227b14bb25e6b1b70c8dffb8d270274
/MCMS/Main/Libs/ProcessBase/HTTPPars.cpp
3b08836c994e0dd549ecffd66a613edb37dae98c
[]
no_license
somesh-ballia/mcms
62a58baffee123a2af427b21fa7979beb1e39dd3
41aaa87d5f3b38bc186749861140fef464ddadd4
refs/heads/master
2020-12-02T22:04:46.442309
2017-07-03T06:02:21
2017-07-03T06:02:21
96,075,113
1
0
null
null
null
null
UTF-8
C++
false
false
12,021
cpp
// HTTPPars.cpp: implementation of the CHTTPHeaderParser class. // ////////////////////////////////////////////////////////////////////// #include <stdlib.h> #include "HTTPPars.h" #include "HTTPDefi.h" #include "Trace.h" #include "UnicodeDefines.h" #include "TraceStream.h" char* CHTTPHeaderParser::WebDirectoryPhysicalNames[] = {"7.256/mcu/WebPages/demo/", "7.256/mcu/WebPages/recording/", "7.256/mcu/schemas/"} ; char* CHTTPHeaderParser::WebDirectoryVirtualNames[] = {"demo", "recording", "schemas"}; char* CHTTPHeaderParser::WebDirectoryDefaultPageNames[] = {"default.asp", "login.htm", ""}; int CHTTPHeaderParser::m_NumOfDirectories=3; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CHTTPHeaderParser::CHTTPHeaderParser() { } CHTTPHeaderParser::~CHTTPHeaderParser() { } WORD CHTTPHeaderParser::GetContentLength(char* pHeader, DWORD* ContentLength) { char* beginContentLength =NULL; char* endContentLength =NULL; char* pContentLength =NULL; int len=0; beginContentLength = strstr(pHeader,"Content-Length: "); if(!beginContentLength) { beginContentLength = strstr(pHeader,"Content-length: "); //try with lower-case l if(!beginContentLength) { FTRACESTR(eLevelInfoNormal) << "CHTTPHeaderParser::GetContentLength - can't find Content-length string"; return FALSE; } } beginContentLength += 16; //go to end of "Content-Length: " endContentLength = strstr(beginContentLength, "\r\n"); if (!endContentLength) { FTRACESTR(eLevelInfoNormal) << "CHTTPHeaderParser::GetContentLength - can't find the end of the content-length"; return FALSE; } len = endContentLength-beginContentLength; pContentLength = new char[len+1]; memcpy(pContentLength,beginContentLength,len); pContentLength[len]='\0'; *ContentLength = atol(pContentLength); delete [] pContentLength; if (*ContentLength==0) { FTRACESTR(eLevelInfoNormal) << "CHTTPHeaderParser::GetContentLength - cant find the content length number"; return FALSE; } else return TRUE; return TRUE; } WORD CHTTPHeaderParser::GetHttpRequestType(char* pHeader, int* HTTPType) { if (strstr(pHeader,"POST ")) { *HTTPType = HTTP_TYPE_POST; } else if (strstr(pHeader,"GET ")) { *HTTPType = HTTP_TYPE_GET; } else if (strstr(pHeader,"HEAD ")) { *HTTPType = HTTP_TYPE_HEAD; } else { *HTTPType = HTTP_TYPE_UNKNOWN; FTRACESTR(eLevelInfoNormal) << "CHTTPHeaderParser::GetHttpRequestType - HTTP_TYPE_UNKNOWN"; return FALSE; } return TRUE; } WORD CHTTPHeaderParser::GetContentEncoding(char* pHeader) { char* lpszTemp =NULL; char* pLastModify =NULL; lpszTemp = strstr(pHeader,"Content-Encoding: zip"); if (lpszTemp == NULL) return CONTENT_ENCODING_NONE; else return CONTENT_ENCODING_ZIP; } void CHTTPHeaderParser::GetContentCharset(const char* pHeader, string &outEncoding) { // "Content-type": "text/xml; charset=UTF-8\r\n" const char *pszContentType = strstr(pHeader, "Content-Type"); if(NULL == pszContentType) { // outEncoding = MCMS_INTERNAL_STRING_ENCODE_TYPE; return; } FPTRACE(eLevelInfoNormal, "cucu-lulu content type"); FPTRACE(eLevelInfoNormal, pszContentType); const char *pszCharsetVal = strstr(pszContentType, "charset="); if(NULL == pszCharsetVal) { // outEncoding = MCMS_INTERNAL_STRING_ENCODE_TYPE; return; } pszCharsetVal += strlen("charset="); const char *pszCharsetValEnd = strstr(pszCharsetVal, "\r\n"); if(NULL == pszCharsetValEnd) { // outEncoding = MCMS_INTERNAL_STRING_ENCODE_TYPE; return; } char buffer [128]; int valLen = pszCharsetValEnd - pszCharsetVal; int minSize = min(valLen, 127); strncpy(buffer, pszCharsetVal, minSize); buffer[minSize] = '\0'; outEncoding = buffer; } WORD CHTTPHeaderParser::GetLastModify(char* pHeader, time_t* time) { char* lpszTemp =NULL; char* pLastModify =NULL; lpszTemp = strstr(pHeader,"If-Modified-Since"); if (lpszTemp == NULL) { return FALSE; } else { lpszTemp = strstr(lpszTemp, " "); lpszTemp++; pLastModify = new char[strlen(lpszTemp)+1]; strcpy(pLastModify, lpszTemp); CutStr(pLastModify,"\r\n"); *time = FromStringTimeToTime_t(pLastModify); delete [] pLastModify; return TRUE; } } WORD CHTTPHeaderParser::GetFilePath(char* pHeader, char** pPath, char** pQueryString, int& DirectoryIndex, BYTE& bDirectory) { char* lpszTemp =NULL; char* lpszCopiedTemp =NULL; char* lpsztempQueryString = NULL; *pPath=NULL; *pQueryString=NULL; lpszTemp = strstr(pHeader,"GET "); if (lpszTemp==NULL) lpszTemp = strstr(pHeader,"HEAD "); if(lpszTemp==NULL) { return HTTP_NOT_SUPPORTED; } lpszCopiedTemp = (char*)calloc (strlen(lpszTemp)+1,1); FPASSERT_AND_RETURN_VALUE(!lpszCopiedTemp,HTTP_UNKNOWN); strcpy (lpszCopiedTemp, lpszTemp); str_tolower(lpszCopiedTemp); //change to lower case for (DirectoryIndex=0; DirectoryIndex<m_NumOfDirectories ; DirectoryIndex++) { lpszTemp = strstr(lpszCopiedTemp,WebDirectoryVirtualNames[DirectoryIndex]); if (lpszTemp != NULL) { lpszTemp--; if ((lpszTemp[0]=='/') && lpszTemp[strlen(WebDirectoryVirtualNames[DirectoryIndex])+1]=='/') //check if this is the virtual directory { lpszTemp+=(strlen(WebDirectoryVirtualNames[DirectoryIndex])+1); //go to the end of the virtual directory break; } } } if(lpszTemp==NULL) { return HTTP_NOT_FOUND; //the virtual directory was not found in the requested adress } CutStr(lpszTemp, " "); //cut what comes after space lpsztempQueryString = strstr(lpszTemp,"?"); if (lpsztempQueryString) //there's something in the querystring { lpsztempQueryString++; //move after the "?" *pQueryString = (char*)calloc (strlen(lpsztempQueryString)+1,1); FPASSERT_AND_RETURN_VALUE(!pQueryString,HTTP_UNKNOWN); strcpy (*pQueryString, lpsztempQueryString); CutStr(lpszTemp, "?"); //cut what comes after ? in the file path } if(strlen(lpszTemp)==0) //if path is only virtual directory name, then send redirect to default page { free(lpszCopiedTemp); return HTTP_MOVED; } if(*lpszTemp!='/') //there's no backslash after the web site name or there's no dot (indicating that not asking for a file) { free(lpszCopiedTemp); return HTTP_NOT_FOUND; } lpszTemp++; //move after the backslash if(strlen(lpszTemp)==0) //if path is only virtual directory name and backslach, ask for default page { *pPath = (char*)calloc (strlen(WebDirectoryDefaultPageNames[DirectoryIndex])+1,1); if(*pPath) strcpy (*pPath, WebDirectoryDefaultPageNames[DirectoryIndex]); else { FTRACESTR(eLevelError) << "CHTTPHeaderParser::GetFilePath - calloc failed"; return HTTP_UNKNOWN; } } else { *pPath = (char*)calloc (strlen(lpszTemp)+1,1); if(*pPath) strcpy (*pPath, lpszTemp); else { FTRACESTR(eLevelError) << "CHTTPHeaderParser::GetFilePath - calloc failed"; return HTTP_UNKNOWN; } } free(lpszCopiedTemp); if(!strstr(*pPath,".")) //there's no dot (indicating that not asking for a file) { if (strcmp(*pPath,"")==0) { bDirectory = TRUE; return HTTP_OK; //get directory file list } free(*pPath); return HTTP_NOT_FOUND; } return HTTP_OK; } char* CHTTPHeaderParser::GetValueFromQueryString(char* pQueryString, char* pValueName) { char* pValue = NULL; if (pQueryString) { char* pTemp = strstr(pQueryString, pValueName); if (pTemp != NULL) { pTemp += (strlen(pValueName)+1); //move after valuename and "=" pValue = (char*)calloc (strlen(pTemp)+1,1); FPASSERT_AND_RETURN_VALUE(!pValue,NULL); strcpy (pValue, pTemp); CutStr(pValue, "&"); } } return pValue; } WORD CHTTPHeaderParser::GetHTTPResponseStatus(char* pHeader, int* status) { char strStatus[10]; pHeader += 9 ; //go after "HTTP/1.1 " strncpy(strStatus, pHeader, sizeof(strStatus) - 1); strStatus[sizeof(strStatus) - 1] = '\0'; CutStr(strStatus, " "); //cut after the status number; *status = atoi(strStatus); if ((*status == HTTP_OK) || (*status == HTTP_NOT_SUPPORTED) || (*status == HTTP_NOT_FOUND) || (*status == HTTP_NOT_MODIFIED) || (*status == HTTP_MOVED) || (*status == HTTP_SERVER_ERROR)) { return TRUE; } else return FALSE; //not one of the known statuses } time_t CHTTPHeaderParser::FromStringTimeToTime_t(char* pTime) { char* temp_str; struct tm tmTime; switch (pTime[3]) { case ',': // read RFC-1123 (preferred).... tmTime.tm_mday = Mid_Num(pTime, 5, 2); tmTime.tm_mon = MonthFromStr(pTime, 8); tmTime.tm_year = Mid_Num(pTime, 12, 4)-1900; tmTime.tm_hour = Mid_Num(pTime, 17, 2); tmTime.tm_min = Mid_Num(pTime, 20, 2); tmTime.tm_sec = Mid_Num(pTime, 23, 2); break; case ' ': // read ANSI-C m_time format.... tmTime.tm_mday = Mid_Num(pTime, 8, 2); tmTime.tm_mon = MonthFromStr(pTime, 4); tmTime.tm_year = Mid_Num(pTime, 20, 4)-1900; tmTime.tm_hour = Mid_Num(pTime, 11, 2); tmTime.tm_min = Mid_Num(pTime, 14, 2); tmTime.tm_sec = Mid_Num(pTime, 17, 2); break; default: temp_str = strstr(pTime, ", "); if (temp_str) { tmTime.tm_mday = Mid_Num(pTime, 2, 2); tmTime.tm_mon = MonthFromStr(pTime, 5); tmTime.tm_year = Mid_Num(pTime, 9, 2); tmTime.tm_hour = Mid_Num(pTime, 12, 2); tmTime.tm_min = Mid_Num(pTime, 15, 2); tmTime.tm_sec = Mid_Num(pTime, 18, 2); // add the correct century.... tmTime.tm_year += (tmTime.tm_year > 50)?0:100; } break; } return mktime(&tmTime); } //////////////////////////////////////////////////////////////////////////////////////////// //Function Name : Mid_Num //Parameters : char* str - the string // int nFirst - the first index of the string // int nCount - number of digits //Return Value : The number //Description : take a part of a string and convert it to an integer //////////////////////////////////////////////////////////////////////////////////////////// int CHTTPHeaderParser::Mid_Num(char* str, int nFirst, int nCount) { char new_str[5]; int i; int num; memset(new_str,0,5); for (i=0; i<nCount; i++) new_str[i]=str[nFirst+i]; new_str[i]='\0'; num = atoi(new_str); return num; } //////////////////////////////////////////////////////////////////////////////////////////// //Function Name : MonthFromStr //Parameters : char* str - the date string // int nFirst - the month first position //Return Value : The number of the month //Description : return the number of the month, according to the month name //////////////////////////////////////////////////////////////////////////////////////////// int CHTTPHeaderParser::MonthFromStr(char* str, int nFirst) { char* aMonths[] = { "xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; int nMonth; char new_str[4]; memset(new_str,0,4); strncpy(new_str, str+nFirst, 3); new_str[3]='\0'; for( nMonth=1; nMonth <= 12; ++nMonth ) { if (strcmp(new_str, aMonths[nMonth])==0) break; } return nMonth-1; } void CHTTPHeaderParser::CutStr(char* strToCut, char* strFromWhereToCut) { char* lpszTemp = strstr(strToCut, strFromWhereToCut); if(lpszTemp) *lpszTemp=0; } char *CHTTPHeaderParser::str_tolower(char *str) { int i=0; while (str[i]!='\0') { if (isupper(str[i])) str[i] = tolower(str[i]); i++; }; return str; }
a8165bab286cf321355c34a3a19b511d6525220b
04b1803adb6653ecb7cb827c4f4aa616afacf629
/cc/trees/single_thread_proxy.cc
d74fe26e408423a6decdcbb6ab64f33d43887206
[ "BSD-3-Clause" ]
permissive
Samsung/Castanets
240d9338e097b75b3f669604315b06f7cf129d64
4896f732fc747dfdcfcbac3d442f2d2d42df264a
refs/heads/castanets_76_dev
2023-08-31T09:01:04.744346
2021-07-30T04:56:25
2021-08-11T05:45:21
125,484,161
58
49
BSD-3-Clause
2022-10-16T19:31:26
2018-03-16T08:07:37
null
UTF-8
C++
false
false
34,316
cc
// Copyright 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "cc/trees/single_thread_proxy.h" #include "base/auto_reset.h" #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/trace_event/trace_event.h" #include "cc/base/devtools_instrumentation.h" #include "cc/benchmarks/benchmark_instrumentation.h" #include "cc/input/browser_controls_offset_manager.h" #include "cc/paint/paint_worklet_layer_painter.h" #include "cc/resources/ui_resource_manager.h" #include "cc/scheduler/commit_earlyout_reason.h" #include "cc/scheduler/compositor_timing_history.h" #include "cc/scheduler/scheduler.h" #include "cc/trees/latency_info_swap_promise.h" #include "cc/trees/layer_tree_frame_sink.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/layer_tree_host_single_thread_client.h" #include "cc/trees/layer_tree_impl.h" #include "cc/trees/mutator_host.h" #include "cc/trees/render_frame_metadata_observer.h" #include "cc/trees/scoped_abort_remaining_swap_promises.h" #include "components/viz/common/frame_sinks/delay_based_time_source.h" #include "components/viz/common/gpu/context_provider.h" namespace cc { std::unique_ptr<Proxy> SingleThreadProxy::Create( LayerTreeHost* layer_tree_host, LayerTreeHostSingleThreadClient* client, TaskRunnerProvider* task_runner_provider) { return base::WrapUnique( new SingleThreadProxy(layer_tree_host, client, task_runner_provider)); } SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host, LayerTreeHostSingleThreadClient* client, TaskRunnerProvider* task_runner_provider) : layer_tree_host_(layer_tree_host), single_thread_client_(client), task_runner_provider_(task_runner_provider), next_frame_is_newly_committed_frame_(false), #if DCHECK_IS_ON() inside_impl_frame_(false), #endif inside_draw_(false), defer_main_frame_update_(false), defer_commits_(true), animate_requested_(false), commit_requested_(false), inside_synchronous_composite_(false), needs_impl_frame_(false), layer_tree_frame_sink_creation_requested_(false), layer_tree_frame_sink_lost_(true), frame_sink_bound_weak_factory_(this), weak_factory_(this) { TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); DCHECK(task_runner_provider_); DCHECK(task_runner_provider_->IsMainThread()); DCHECK(layer_tree_host); } void SingleThreadProxy::Start() { DebugScopedSetImplThread impl(task_runner_provider_); const LayerTreeSettings& settings = layer_tree_host_->GetSettings(); DCHECK(settings.single_thread_proxy_scheduler || !settings.enable_checker_imaging) << "Checker-imaging is not supported in synchronous single threaded mode"; host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); if (settings.single_thread_proxy_scheduler && !scheduler_on_impl_thread_) { SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); scheduler_settings.commit_to_active_tree = CommitToActiveTree(); std::unique_ptr<CompositorTimingHistory> compositor_timing_history( new CompositorTimingHistory( scheduler_settings.using_synchronous_renderer_compositor, CompositorTimingHistory::BROWSER_UMA, layer_tree_host_->rendering_stats_instrumentation(), host_impl_->compositor_frame_reporting_controller())); scheduler_on_impl_thread_.reset( new Scheduler(this, scheduler_settings, layer_tree_host_->GetId(), task_runner_provider_->MainThreadTaskRunner(), std::move(compositor_timing_history))); } } SingleThreadProxy::~SingleThreadProxy() { TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); DCHECK(task_runner_provider_->IsMainThread()); // Make sure Stop() got called or never Started. DCHECK(!host_impl_); } bool SingleThreadProxy::IsStarted() const { DCHECK(task_runner_provider_->IsMainThread()); return !!host_impl_; } bool SingleThreadProxy::CommitToActiveTree() const { // With SingleThreadProxy we skip the pending tree and commit directly to the // active tree. return true; } void SingleThreadProxy::SetVisible(bool visible) { TRACE_EVENT1("cc", "SingleThreadProxy::SetVisible", "visible", visible); DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->SetVisible(visible); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetVisible(host_impl_->visible()); } void SingleThreadProxy::RequestNewLayerTreeFrameSink() { DCHECK(task_runner_provider_->IsMainThread()); layer_tree_frame_sink_creation_callback_.Cancel(); if (layer_tree_frame_sink_creation_requested_) return; layer_tree_frame_sink_creation_requested_ = true; layer_tree_host_->RequestNewLayerTreeFrameSink(); } void SingleThreadProxy::ReleaseLayerTreeFrameSink() { layer_tree_frame_sink_lost_ = true; frame_sink_bound_weak_factory_.InvalidateWeakPtrs(); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->DidLoseLayerTreeFrameSink(); return host_impl_->ReleaseLayerTreeFrameSink(); } void SingleThreadProxy::SetLayerTreeFrameSink( LayerTreeFrameSink* layer_tree_frame_sink) { DCHECK(task_runner_provider_->IsMainThread()); DCHECK(layer_tree_frame_sink_creation_requested_); bool success; { DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); DebugScopedSetImplThread impl(task_runner_provider_); success = host_impl_->InitializeFrameSink(layer_tree_frame_sink); } if (success) { frame_sink_bound_weak_ptr_ = frame_sink_bound_weak_factory_.GetWeakPtr(); layer_tree_host_->DidInitializeLayerTreeFrameSink(); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->DidCreateAndInitializeLayerTreeFrameSink(); else if (!inside_synchronous_composite_) SetNeedsCommit(); layer_tree_frame_sink_creation_requested_ = false; layer_tree_frame_sink_lost_ = false; } else { // DidFailToInitializeLayerTreeFrameSink is treated as a // RequestNewLayerTreeFrameSink, and so // layer_tree_frame_sink_creation_requested remains true. layer_tree_host_->DidFailToInitializeLayerTreeFrameSink(); } } void SingleThreadProxy::SetNeedsAnimate() { TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); DCHECK(task_runner_provider_->IsMainThread()); if (animate_requested_) return; animate_requested_ = true; DebugScopedSetImplThread impl(task_runner_provider_); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); } void SingleThreadProxy::SetNeedsUpdateLayers() { TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); DCHECK(task_runner_provider_->IsMainThread()); SetNeedsCommit(); } void SingleThreadProxy::DoCommit() { TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); DCHECK(task_runner_provider_->IsMainThread()); layer_tree_host_->WillCommit(); devtools_instrumentation::ScopedCommitTrace commit_task( layer_tree_host_->GetId()); // Commit immediately. { DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->ReadyToCommit(); host_impl_->BeginCommit(); if (host_impl_->EvictedUIResourcesExist()) layer_tree_host_->GetUIResourceManager()->RecreateUIResources(); layer_tree_host_->FinishCommitOnImplThread(host_impl_.get()); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->DidCommit(); IssueImageDecodeFinishedCallbacks(); host_impl_->CommitComplete(); // Commit goes directly to the active tree, but we need to synchronously // "activate" the tree still during commit to satisfy any potential // SetNextCommitWaitsForActivation calls. Unfortunately, the tree // might not be ready to draw, so DidActivateSyncTree must set // the flag to force the tree to not draw until textures are ready. NotifyReadyToActivate(); } } void SingleThreadProxy::IssueImageDecodeFinishedCallbacks() { DCHECK(task_runner_provider_->IsImplThread()); layer_tree_host_->ImageDecodesFinished( host_impl_->TakeCompletedImageDecodeRequests()); } void SingleThreadProxy::CommitComplete() { // Commit complete happens on the main side after activate to satisfy any // SetNextCommitWaitsForActivation calls. DCHECK(!host_impl_->pending_tree()) << "Activation is expected to have synchronously occurred by now."; DebugScopedSetMainThread main(task_runner_provider_); layer_tree_host_->CommitComplete(); layer_tree_host_->DidBeginMainFrame(); next_frame_is_newly_committed_frame_ = true; } void SingleThreadProxy::SetNeedsCommit() { DCHECK(task_runner_provider_->IsMainThread()); single_thread_client_->RequestScheduleComposite(); if (commit_requested_) return; commit_requested_ = true; DebugScopedSetImplThread impl(task_runner_provider_); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); } void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); DCHECK(task_runner_provider_->IsMainThread()); DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->SetViewportDamage(damage_rect); SetNeedsRedrawOnImplThread(); } void SingleThreadProxy::SetNextCommitWaitsForActivation() { // Activation always forced in commit, so nothing to do. DCHECK(task_runner_provider_->IsMainThread()); } bool SingleThreadProxy::RequestedAnimatePending() { return animate_requested_ || commit_requested_ || needs_impl_frame_; } void SingleThreadProxy::SetDeferMainFrameUpdate(bool defer_main_frame_update) { DCHECK(task_runner_provider_->IsMainThread()); // Deferring main frame updates only makes sense if there's a scheduler. if (!scheduler_on_impl_thread_) return; if (defer_main_frame_update_ == defer_main_frame_update) return; if (defer_main_frame_update) TRACE_EVENT_ASYNC_BEGIN0("cc", "SingleThreadProxy::SetDeferMainFrameUpdate", this); else TRACE_EVENT_ASYNC_END0("cc", "SingleThreadProxy::SetDeferMainFrameUpdate", this); defer_main_frame_update_ = defer_main_frame_update; // The scheduler needs to know that it should not issue BeginMainFrame. scheduler_on_impl_thread_->SetDeferBeginMainFrame(defer_main_frame_update_); } void SingleThreadProxy::StartDeferringCommits(base::TimeDelta timeout) { DCHECK(task_runner_provider_->IsMainThread()); // Do nothing if already deferring. The timeout remains as it was from when // we most recently began deferring. if (defer_commits_) return; TRACE_EVENT_ASYNC_BEGIN0("cc", "SingleThreadProxy::SetDeferCommits", this); defer_commits_ = true; commits_restart_time_ = base::TimeTicks::Now() + timeout; } void SingleThreadProxy::StopDeferringCommits( PaintHoldingCommitTrigger trigger) { if (!defer_commits_) return; defer_commits_ = false; commits_restart_time_ = base::TimeTicks(); UMA_HISTOGRAM_ENUMERATION("PaintHolding.CommitTrigger", trigger); TRACE_EVENT_ASYNC_END0("cc", "SingleThreadProxy::SetDeferCommits", this); } bool SingleThreadProxy::CommitRequested() const { DCHECK(task_runner_provider_->IsMainThread()); return commit_requested_; } void SingleThreadProxy::Stop() { TRACE_EVENT0("cc", "SingleThreadProxy::stop"); DCHECK(task_runner_provider_->IsMainThread()); { DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); DebugScopedSetImplThread impl(task_runner_provider_); // Prevent the scheduler from performing actions while we're in an // inconsistent state. if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->Stop(); // Take away the LayerTreeFrameSink before destroying things so it doesn't // try to call into its client mid-shutdown. host_impl_->ReleaseLayerTreeFrameSink(); // It is important to destroy LTHI before the Scheduler since it can make // callbacks that access it during destruction cleanup. host_impl_ = nullptr; scheduler_on_impl_thread_ = nullptr; } layer_tree_host_ = nullptr; } void SingleThreadProxy::SetMutator(std::unique_ptr<LayerTreeMutator> mutator) { DCHECK(task_runner_provider_->IsMainThread()); DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->SetLayerTreeMutator(std::move(mutator)); } void SingleThreadProxy::SetPaintWorkletLayerPainter( std::unique_ptr<PaintWorkletLayerPainter> painter) { NOTREACHED(); } void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { TRACE_EVENT1("cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); DCHECK(task_runner_provider_->IsImplThread()); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetCanDraw(can_draw); } void SingleThreadProxy::NotifyReadyToActivate() { TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); DebugScopedSetImplThread impl(task_runner_provider_); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->NotifyReadyToActivate(); } void SingleThreadProxy::NotifyReadyToDraw() { TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToDraw"); DebugScopedSetImplThread impl(task_runner_provider_); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->NotifyReadyToDraw(); } void SingleThreadProxy::SetNeedsRedrawOnImplThread() { single_thread_client_->RequestScheduleComposite(); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetNeedsRedraw(); } void SingleThreadProxy::SetNeedsOneBeginImplFrameOnImplThread() { TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsOneBeginImplFrameOnImplThread"); single_thread_client_->RequestScheduleComposite(); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetNeedsOneBeginImplFrame(); needs_impl_frame_ = true; } void SingleThreadProxy::SetNeedsPrepareTilesOnImplThread() { TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsPrepareTilesOnImplThread"); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetNeedsPrepareTiles(); } void SingleThreadProxy::SetNeedsCommitOnImplThread() { single_thread_client_->RequestScheduleComposite(); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); commit_requested_ = true; } void SingleThreadProxy::SetVideoNeedsBeginFrames(bool needs_begin_frames) { TRACE_EVENT1("cc", "SingleThreadProxy::SetVideoNeedsBeginFrames", "needs_begin_frames", needs_begin_frames); // In tests the layer tree is destroyed after the scheduler is. if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetVideoNeedsBeginFrames(needs_begin_frames); } void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( std::unique_ptr<MutatorEvents> events) { TRACE_EVENT0( "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); DCHECK(task_runner_provider_->IsImplThread()); DebugScopedSetMainThread main(task_runner_provider_); layer_tree_host_->SetAnimationEvents(std::move(events)); } size_t SingleThreadProxy::CompositedAnimationsCount() const { return 0; } size_t SingleThreadProxy::MainThreadAnimationsCount() const { return 0; } bool SingleThreadProxy::CurrentFrameHadRAF() const { return false; } bool SingleThreadProxy::NextFrameHasPendingRAF() const { return false; } bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } void SingleThreadProxy::DidActivateSyncTree() { CommitComplete(); } void SingleThreadProxy::WillPrepareTiles() { DCHECK(task_runner_provider_->IsImplThread()); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->WillPrepareTiles(); } void SingleThreadProxy::DidPrepareTiles() { DCHECK(task_runner_provider_->IsImplThread()); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->DidPrepareTiles(); } void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { layer_tree_host_->DidCompletePageScaleAnimation(); } void SingleThreadProxy::DidLoseLayerTreeFrameSinkOnImplThread() { TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseLayerTreeFrameSinkOnImplThread"); { DebugScopedSetMainThread main(task_runner_provider_); // This must happen before we notify the scheduler as it may try to recreate // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. layer_tree_host_->DidLoseLayerTreeFrameSink(); } single_thread_client_->DidLoseLayerTreeFrameSink(); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->DidLoseLayerTreeFrameSink(); layer_tree_frame_sink_lost_ = true; } void SingleThreadProxy::SetBeginFrameSource(viz::BeginFrameSource* source) { if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->SetBeginFrameSource(source); } void SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread() { TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread"); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->DidReceiveCompositorFrameAck(); if (layer_tree_host_->GetSettings().send_compositor_frame_ack) { // We do a PostTask here because freeing resources in some cases (such as in // TextureLayer) is PostTasked and we want to make sure ack is received // after resources are returned. task_runner_provider_->MainThreadTaskRunner()->PostTask( FROM_HERE, base::BindOnce(&SingleThreadProxy::DidReceiveCompositorFrameAck, frame_sink_bound_weak_ptr_)); } } void SingleThreadProxy::OnDrawForLayerTreeFrameSink( bool resourceless_software_draw, bool skip_draw) { NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; } void SingleThreadProxy::NeedsImplSideInvalidation( bool needs_first_draw_on_activation) { if (scheduler_on_impl_thread_) { scheduler_on_impl_thread_->SetNeedsImplSideInvalidation( needs_first_draw_on_activation); } } void SingleThreadProxy::NotifyImageDecodeRequestFinished() { // If we don't have a scheduler, then just issue the callbacks here. // Otherwise, schedule a commit. if (!scheduler_on_impl_thread_) { DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); DebugScopedSetImplThread impl(task_runner_provider_); IssueImageDecodeFinishedCallbacks(); return; } SetNeedsCommitOnImplThread(); } void SingleThreadProxy::DidPresentCompositorFrameOnImplThread( uint32_t frame_token, std::vector<LayerTreeHost::PresentationTimeCallback> callbacks, const gfx::PresentationFeedback& feedback) { layer_tree_host_->DidPresentCompositorFrame(frame_token, std::move(callbacks), feedback); } void SingleThreadProxy::NotifyAnimationWorkletStateChange( AnimationWorkletMutationState state, ElementListType element_list_type) { layer_tree_host_->NotifyAnimationWorkletStateChange(state, element_list_type); } void SingleThreadProxy::RequestBeginMainFrameNotExpected(bool new_state) { if (scheduler_on_impl_thread_) { scheduler_on_impl_thread_->SetMainThreadWantsBeginMainFrameNotExpected( new_state); } } void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time, bool raster) { TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); DCHECK(task_runner_provider_->IsMainThread()); #if DCHECK_IS_ON() DCHECK(!inside_impl_frame_); #endif base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); if (layer_tree_frame_sink_lost_) { RequestNewLayerTreeFrameSink(); // RequestNewLayerTreeFrameSink could have synchronously created an output // surface, so check again before returning. if (layer_tree_frame_sink_lost_) return; } viz::BeginFrameArgs begin_frame_args(viz::BeginFrameArgs::Create( BEGINFRAME_FROM_HERE, viz::BeginFrameArgs::kManualSourceId, 1, frame_begin_time, base::TimeTicks(), viz::BeginFrameArgs::DefaultInterval(), viz::BeginFrameArgs::NORMAL)); // Start the impl frame. { DebugScopedSetImplThread impl(task_runner_provider_); WillBeginImplFrame(begin_frame_args); } // Run the "main thread" and get it to commit. { #if DCHECK_IS_ON() DCHECK(inside_impl_frame_); #endif animate_requested_ = false; needs_impl_frame_ = false; // Prevent new commits from being requested inside DoBeginMainFrame. // Note: We do not want to prevent SetNeedsAnimate from requesting // a commit here. commit_requested_ = true; DoBeginMainFrame(begin_frame_args); commit_requested_ = false; DoPainting(); DoCommit(); DCHECK_EQ( 0u, layer_tree_host_->GetSwapPromiseManager()->num_queued_swap_promises()) << "Commit should always succeed and transfer promises."; } // Finish the impl frame. { DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->ActivateSyncTree(); if (raster) { host_impl_->PrepareTiles(); host_impl_->SynchronouslyInitializeAllTiles(); } // TODO(danakj): Don't do this last... we prepared the wrong things. D: host_impl_->Animate(); if (raster) { LayerTreeHostImpl::FrameData frame; frame.begin_frame_ack = viz::BeginFrameAck(begin_frame_args, true); DoComposite(&frame); } // DoComposite could abort, but because this is a synchronous composite // another draw will never be scheduled, so break remaining promises. host_impl_->active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); DidFinishImplFrame(); } } bool SingleThreadProxy::SupportsImplScrolling() const { return false; } bool SingleThreadProxy::ShouldComposite() const { DCHECK(task_runner_provider_->IsImplThread()); return host_impl_->visible() && host_impl_->CanDraw(); } void SingleThreadProxy::ScheduleRequestNewLayerTreeFrameSink() { if (layer_tree_frame_sink_creation_callback_.IsCancelled() && !layer_tree_frame_sink_creation_requested_) { layer_tree_frame_sink_creation_callback_.Reset( base::BindOnce(&SingleThreadProxy::RequestNewLayerTreeFrameSink, weak_factory_.GetWeakPtr())); task_runner_provider_->MainThreadTaskRunner()->PostTask( FROM_HERE, layer_tree_frame_sink_creation_callback_.callback()); } } DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); DrawResult draw_result; bool draw_frame; { DebugScopedSetImplThread impl(task_runner_provider_); base::AutoReset<bool> mark_inside(&inside_draw_, true); // We guard PrepareToDraw() with CanDraw() because it always returns a valid // frame, so can only be used when such a frame is possible. Since // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on // CanDraw() as well. if (!ShouldComposite()) { return DRAW_ABORTED_CANT_DRAW; } // This CapturePostTasks should be destroyed before // DidCommitAndDrawFrame() is called since that goes out to the // embedder, and we want the embedder to receive its callbacks before that. // NOTE: This maintains consistent ordering with the ThreadProxy since // the DidCommitAndDrawFrame() must be post-tasked from the impl thread // there as the main thread is not blocked, so any posted tasks inside // the swap buffers will execute first. DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); draw_result = host_impl_->PrepareToDraw(frame); draw_frame = draw_result == DRAW_SUCCESS; if (draw_frame) { if (host_impl_->DrawLayers(frame)) { if (scheduler_on_impl_thread_) // Drawing implies we submitted a frame to the LayerTreeFrameSink. scheduler_on_impl_thread_->DidSubmitCompositorFrame(); single_thread_client_->DidSubmitCompositorFrame(); } } host_impl_->DidDrawAllLayers(*frame); bool start_ready_animations = draw_frame; host_impl_->UpdateAnimationState(start_ready_animations); } DidCommitAndDrawFrame(); return draw_result; } void SingleThreadProxy::DidCommitAndDrawFrame() { if (next_frame_is_newly_committed_frame_) { DebugScopedSetMainThread main(task_runner_provider_); next_frame_is_newly_committed_frame_ = false; layer_tree_host_->DidCommitAndDrawFrame(); } } bool SingleThreadProxy::MainFrameWillHappenForTesting() { if (!scheduler_on_impl_thread_) return false; return scheduler_on_impl_thread_->MainFrameForTestingWillHappen(); } void SingleThreadProxy::ClearHistory() { DCHECK(task_runner_provider_->IsImplThread()); if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->ClearHistory(); } void SingleThreadProxy::SetRenderFrameObserver( std::unique_ptr<RenderFrameMetadataObserver> observer) { host_impl_->SetRenderFrameObserver(std::move(observer)); } void SingleThreadProxy::UpdateBrowserControlsState( BrowserControlsState constraints, BrowserControlsState current, bool animate) { host_impl_->browser_controls_manager()->UpdateBrowserControlsState( constraints, current, animate); } bool SingleThreadProxy::WillBeginImplFrame(const viz::BeginFrameArgs& args) { DebugScopedSetImplThread impl(task_runner_provider_); #if DCHECK_IS_ON() DCHECK(!inside_impl_frame_) << "WillBeginImplFrame called while already inside an impl frame!"; inside_impl_frame_ = true; #endif return host_impl_->WillBeginImplFrame(args); } void SingleThreadProxy::ScheduledActionSendBeginMainFrame( const viz::BeginFrameArgs& begin_frame_args) { TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); #if DCHECK_IS_ON() // Although this proxy is single-threaded, it's problematic to synchronously // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This // could cause a commit to occur in between a series of SetNeedsCommit calls // (i.e. property modifications) causing some to fall on one frame and some to // fall on the next. Doing it asynchronously instead matches the semantics of // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a // synchronous commit. DCHECK(inside_impl_frame_) << "BeginMainFrame should only be sent inside a BeginImplFrame"; #endif host_impl_->WillSendBeginMainFrame(); task_runner_provider_->MainThreadTaskRunner()->PostTask( FROM_HERE, base::BindOnce(&SingleThreadProxy::BeginMainFrame, weak_factory_.GetWeakPtr(), begin_frame_args)); host_impl_->DidSendBeginMainFrame(); } void SingleThreadProxy::FrameIntervalUpdated(base::TimeDelta interval) { DebugScopedSetMainThread main(task_runner_provider_); single_thread_client_->FrameIntervalUpdated(interval); } void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { layer_tree_host_->BeginMainFrameNotExpectedSoon(); } void SingleThreadProxy::ScheduledActionBeginMainFrameNotExpectedUntil( base::TimeTicks time) { layer_tree_host_->BeginMainFrameNotExpectedUntil(time); } void SingleThreadProxy::BeginMainFrame( const viz::BeginFrameArgs& begin_frame_args) { // This checker assumes NotifyReadyToCommit in this stack causes a synchronous // commit. ScopedAbortRemainingSwapPromises swap_promise_checker( layer_tree_host_->GetSwapPromiseManager()); if (scheduler_on_impl_thread_) { scheduler_on_impl_thread_->NotifyBeginMainFrameStarted( base::TimeTicks::Now()); } commit_requested_ = false; needs_impl_frame_ = false; animate_requested_ = false; if (defer_main_frame_update_) { TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferBeginMainFrame", TRACE_EVENT_SCOPE_THREAD); BeginMainFrameAbortedOnImplThread( CommitEarlyOutReason::ABORTED_DEFERRED_MAIN_FRAME_UPDATE); return; } if (!layer_tree_host_->IsVisible()) { TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); BeginMainFrameAbortedOnImplThread( CommitEarlyOutReason::ABORTED_NOT_VISIBLE); return; } // Prevent new commits from being requested inside DoBeginMainFrame. // Note: We do not want to prevent SetNeedsAnimate from requesting // a commit here. commit_requested_ = true; DoBeginMainFrame(begin_frame_args); // New commits requested inside UpdateLayers should be respected. commit_requested_ = false; // Check now if we should stop deferring commits if (defer_commits_ && base::TimeTicks::Now() > commits_restart_time_) { StopDeferringCommits(PaintHoldingCommitTrigger::kTimeout); } // At this point the main frame may have deferred commits to avoid committing // right now. if (defer_main_frame_update_ || defer_commits_ || begin_frame_args.animate_only) { TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit_InsideBeginMainFrame", TRACE_EVENT_SCOPE_THREAD); BeginMainFrameAbortedOnImplThread( CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); layer_tree_host_->DidBeginMainFrame(); return; } // Queue the LATENCY_BEGIN_FRAME_UI_MAIN_COMPONENT swap promise only once we // know we will commit since QueueSwapPromise itself requests a commit. ui::LatencyInfo new_latency_info(ui::SourceEventType::FRAME); new_latency_info.AddLatencyNumberWithTimestamp( ui::LATENCY_BEGIN_FRAME_UI_MAIN_COMPONENT, begin_frame_args.frame_time, 1); layer_tree_host_->QueueSwapPromise( std::make_unique<LatencyInfoSwapPromise>(new_latency_info)); DoPainting(); } void SingleThreadProxy::DoBeginMainFrame( const viz::BeginFrameArgs& begin_frame_args) { // The impl-side scroll deltas may be manipulated directly via the // InputHandler on the UI thread and the scale deltas may change when they are // clamped on the impl thread. std::unique_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); layer_tree_host_->ApplyScrollAndScale(scroll_info.get()); layer_tree_host_->WillBeginMainFrame(); layer_tree_host_->BeginMainFrame(begin_frame_args); layer_tree_host_->AnimateLayers(begin_frame_args.frame_time); layer_tree_host_->RequestMainFrameUpdate(); } void SingleThreadProxy::DoPainting() { layer_tree_host_->UpdateLayers(); // TODO(enne): SingleThreadProxy does not support cancelling commits yet, // search for CommitEarlyOutReason::FINISHED_NO_UPDATES inside // thread_proxy.cc if (scheduler_on_impl_thread_) scheduler_on_impl_thread_->NotifyReadyToCommit(); } void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( CommitEarlyOutReason reason) { DebugScopedSetImplThread impl(task_runner_provider_); DCHECK(scheduler_on_impl_thread_->CommitPending()); DCHECK(!host_impl_->pending_tree()); std::vector<std::unique_ptr<SwapPromise>> empty_swap_promises; host_impl_->BeginMainFrameAborted(reason, std::move(empty_swap_promises)); scheduler_on_impl_thread_->BeginMainFrameAborted(reason); } DrawResult SingleThreadProxy::ScheduledActionDrawIfPossible() { DebugScopedSetImplThread impl(task_runner_provider_); LayerTreeHostImpl::FrameData frame; frame.begin_frame_ack = scheduler_on_impl_thread_->CurrentBeginFrameAckForActiveTree(); return DoComposite(&frame); } DrawResult SingleThreadProxy::ScheduledActionDrawForced() { NOTREACHED(); return INVALID_RESULT; } void SingleThreadProxy::ScheduledActionCommit() { DebugScopedSetMainThread main(task_runner_provider_); DoCommit(); } void SingleThreadProxy::ScheduledActionActivateSyncTree() { DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->ActivateSyncTree(); } void SingleThreadProxy::ScheduledActionBeginLayerTreeFrameSinkCreation() { DebugScopedSetMainThread main(task_runner_provider_); DCHECK(scheduler_on_impl_thread_); // If possible, create the output surface in a post task. Synchronously // creating the output surface makes tests more awkward since this differs // from the ThreadProxy behavior. However, sometimes there is no // task runner. if (task_runner_provider_->MainThreadTaskRunner()) { ScheduleRequestNewLayerTreeFrameSink(); } else { RequestNewLayerTreeFrameSink(); } } void SingleThreadProxy::ScheduledActionPrepareTiles() { TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles"); DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->PrepareTiles(); } void SingleThreadProxy::ScheduledActionInvalidateLayerTreeFrameSink( bool needs_redraw) { // This is an Android WebView codepath, which only uses multi-thread // compositor. So this should not occur in single-thread mode. NOTREACHED() << "Android Webview use-case, so multi-thread only"; } void SingleThreadProxy::ScheduledActionPerformImplSideInvalidation() { DCHECK(scheduler_on_impl_thread_); DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->InvalidateContentOnImplSide(); // Invalidations go directly to the active tree, so we synchronously call // NotifyReadyToActivate to update the scheduler and LTHI state correctly. // Since in single-threaded mode the scheduler will wait for a ready to draw // signal from LTHI, the draw will remain blocked till the invalidated tiles // are ready. NotifyReadyToActivate(); } void SingleThreadProxy::DidFinishImplFrame() { host_impl_->DidFinishImplFrame(); #if DCHECK_IS_ON() DCHECK(inside_impl_frame_) << "DidFinishImplFrame called while not inside an impl frame!"; inside_impl_frame_ = false; #endif } void SingleThreadProxy::DidNotProduceFrame(const viz::BeginFrameAck& ack) { DebugScopedSetImplThread impl(task_runner_provider_); host_impl_->DidNotProduceFrame(ack); } void SingleThreadProxy::WillNotReceiveBeginFrame() { host_impl_->DidNotNeedBeginFrame(); } void SingleThreadProxy::DidReceiveCompositorFrameAck() { layer_tree_host_->DidReceiveCompositorFrameAck(); } } // namespace cc
61ca6506293dedec41dd303f84173da8ea9d80f6
6a7edbce87563000a3b9b29d6c4e8299cefe9dfa
/reactor/s05/Eventloop.h
37c1f286ef32bd6c7983a6dae21d4301fc718d69
[]
no_license
myclass242/snippet
f031e0d89188519bc68ad620dba855cea57dbce3
52f38ee5f80d0d802475a727c8765c09bfb31c17
refs/heads/master
2021-06-19T14:00:11.947907
2021-03-08T09:12:07
2021-03-08T09:12:07
177,366,069
0
0
null
null
null
null
UTF-8
C++
false
false
1,824
h
// // Created by zy on 5/26/19. // #ifndef EVENTLOOP_H_ #define EVENTLOOP_H_ #include <atomic> #include <memory> #include <vector> #include <sys/types.h> #include "base/noncopyable.h" #include "base/CurrentThread.h" #include "base/Mutex.h" #include "TimerId.h" namespace muduo { class Poller; class Channel; class TimerQueue; class Eventloop : public noncopyable { using WakeupCallback = std::function<void()>; public: Eventloop(); ~Eventloop(); void loop(); void runInLoop(WakeupCallback&& wakeupCallback); Timestamp pollReturnTimer() const noexcept { return pollReturnTime_; } TimerId runAt(TimerCallback&& callBack, Timestamp when); TimerId runAfter(TimerCallback&& callBack, double delay); TimerId runEvery(TimerCallback&& callBack, double interval); void assertInLoopThread() { if (!isInLoopThread()) { abortNotInLoopThread(); } } bool isInLoopThread() const { return threadId_ == CurrentThread::tid(); } void quit(); void updateChannel(Channel* channel); static Eventloop* getEventloopOfCurrentThread(); private: void abortNotInLoopThread(); void handleWakeup(); void doPendingTasks(); void wakeup(); void addPendingTask(WakeupCallback&& wakeupCallback); private: using ChannelLIst = std::vector<Channel*>; std::atomic_bool looping_; const pid_t threadId_; std::atomic_bool quit_; std::unique_ptr<Poller> poller_; ChannelLIst activeChannels_; std::unique_ptr<TimerQueue> timerQueue_; int wakeupFd_; std::unique_ptr<Channel> wakeupChannel_; std::vector<WakeupCallback> pendingTasks_; MutexLock mutex_; std::atomic_bool callingPendingTasks_; Timestamp pollReturnTime_; }; } #endif //EVENTLOOP_H_
9de12f87dc1964471a67251daf6d077605adc6b9
bfb53276ce917b6bcca9462def24afc21b828a00
/Triangle.h
772cae69f206902de25500cab5dfbef3a5f4848e
[]
no_license
nachob97/Ray-Tracer
a2ce9ade09c87ec46f529d62636a4fd1e559d25a
5443cf173c2d553337e26ee1e14b9577a2117adc
refs/heads/master
2022-12-30T03:56:24.297546
2020-08-01T20:07:05
2020-08-01T20:07:05
280,751,799
0
0
null
null
null
null
UTF-8
C++
false
false
3,044
h
#ifndef _TRIANGLE_H #define _TRIANGLE_H #include "math.h" #include "Object.h" #include "Vect.h" #include "Color.h" class Triangle : public Object { Vect A; Vect B; Vect C; Color* color; double coef; public: Triangle (Vect, Vect,Vect, Color*,double); Vect getP1(){return A;} Vect getP2(){return B;} Vect getP3(){return C;} Color* getColor(){return color;} double getCoef(){return coef;} Vect getNormal(); double getTriangleDistance(); virtual Vect getNormalAt(Vect point) {return getNormal();} virtual double findIntersection(Ray* ray) { Vect ray_direction = ray->getRayDirection(); Vect ray_o = ray->getRayOrigin(); Vect normal = getNormal(); double distance = getTriangleDistance(); double a = ray_direction.dotProduct(normal); if (a == 0) { // Rayo paralelo al triangulo return -1; } else { double b = normal.dotProduct(ray->getRayOrigin().vectAdd(normal.vectMult(distance).negative())); double distancePlane = -1*b/a; double Qx = ray_direction.vectMult(distancePlane).getVectX() + ray_o.getVectX(); double Qy = ray_direction.vectMult(distancePlane).getVectY() + ray_o.getVectY(); double Qz = ray_direction.vectMult(distancePlane).getVectZ() + ray_o.getVectZ(); Vect Q = Vect(Qx,Qy,Qz); //punto interseccion //[CAxQA]*n >= 0 Vect CA = Vect(C.getVectX() - A.getVectX(),C.getVectY() - A.getVectY(),C.getVectZ() - A.getVectZ()); Vect QA = Vect (Q.getVectX() - A.getVectX(),Q.getVectY() - A.getVectY(),Q.getVectZ() - A.getVectZ()); double cond1 = (CA.crossProduct(QA).dotProduct(normal)); //[BCxQC]*n >= 0 Vect BC = Vect (B.getVectX() - C.getVectX(),B.getVectY() - C.getVectY(),B.getVectZ() - C.getVectZ()); Vect QC = Vect (Q.getVectX() - C.getVectX(),Q.getVectY() - C.getVectY(),Q.getVectZ() - C.getVectZ()); double cond2 = (BC.crossProduct(QC).dotProduct(normal)); //[ABxQB]*n >= 0 Vect AB = Vect (A.getVectX() - B.getVectX(),A.getVectY() - B.getVectY(),A.getVectZ() - B.getVectZ()); Vect QB = Vect (Q.getVectX() - B.getVectX(),Q.getVectY() - B.getVectY(),Q.getVectZ() - B.getVectZ()); double cond3 = (AB.crossProduct(QB).dotProduct(normal)); if( (cond1 >= 0)&&(cond2>=0)&&(cond3>=0) ){ //dentro del triangulo return -1*b/a; //(b > 0.00001 ? -1*b/a : -1); }else return -1; } } }; Triangle::Triangle (Vect p1, Vect p2,Vect p3, Color* colorValue,double c) { this->A = p1; this->B = p2; this->C = p3; this->color = colorValue; this->coef = c; } Vect Triangle::getNormal(){ Vect CA = Vect (C.getVectX() - A.getVectX(),C.getVectY() - A.getVectY(),C.getVectZ() - A.getVectZ()); Vect BA = Vect (B.getVectX() - A.getVectX(),B.getVectY() - A.getVectY(),B.getVectZ() - A.getVectZ()); return CA.crossProduct(BA).normalize(); } double Triangle::getTriangleDistance (){ return (getNormal().dotProduct(A)); } #endif
ae9ea722331baaaec05fdad1e0789a87310c6587
7d81e3a3cc4d22c335eca10b2b4f44820ae30158
/Codes/Source/GradientCalculation.cpp
a0da2152fc301618d62ad9141cb4c75982538b20
[]
no_license
eantonini/CFD-based-WFLO
a4652e09af5447010c3e38be7245b883f040ef96
cd5a314bc16793fc5e970c9201255e8f40b6297c
refs/heads/master
2021-07-16T05:14:20.245154
2020-10-06T19:43:21
2020-10-06T19:43:21
217,121,174
8
7
null
null
null
null
UTF-8
C++
false
false
11,460
cpp
#include <math.h> #include <cmath> #include <vector> #include <sys/stat.h> #include <sys/types.h> #include <sstream> #include <iostream> #include <fstream> #include <string> #include <algorithm> #include "ReadInputs.h" #include "DiffusionProperties.h" #include "Simulation.h" #include "BCvelocity.h" #include "BCpressure.h" #include "BCk.h" #include "BCepsilon.h" #include "BComega.h" #include "ReadResults.h" #define pi 3.1416 int main() { ReadInputs inputs; DiffusionProperties diffusion; Simulation simulation; BCvelocity velocity; BCpressure pressure; BCk k; BCepsilon epsilon; BComega omega; ReadResults results; int nt; // Number of wind turbines int nwd; // Number of wind directions double d; // Turbine diameter double h; // Hub height double h0; // Turbine base height double z0; // Surface roughness double lx; // Streamwise lenght double ly; // Lateral length double lz; // Domain height double delta; // Mesh resolution int turb; // Diffusion type int dim; // Problem dimensions int np; // Number of processor int terrain; // Terrain type double height; // Height of Gaussian hill double spread; // Spread of Gaussian hill inputs.setup(d,h,h0,z0,lx,ly,lz,delta,turb,dim,np,terrain,height,spread); int wsbinmax = 30; // Maximum wind speed bin std::vector<double> Ct(wsbinmax); // Thrust coefficient std::vector< std::vector<double> > positions; // Turbine positions std::vector<double> windDir; // Wind directions std::vector< std::vector<double> > windRose; // Wind rose frequency inputs.thrustCoeff(Ct); inputs.positions(nt,positions); inputs.windRose(wsbinmax,nwd,windDir,windRose); double totFreq = 0; for (int i=0; i<nwd; i++) { for (int j=0; j<wsbinmax; j++) { totFreq = totFreq+windRose[j][i]; } } if (std::abs(totFreq-1)>0.01) { std::cout << "Warning: Total frequency is off from 1 by "<<totFreq-1<<"\n"; } double rho = 1.2; // Air density double nu = 1.5e-05; // Air kinetic viscosity double A = pi*pow(d,2)/4.0; // Rotor spanned area double kappa = 0.41; // Von-Karman constant double Cmu = 0.0333; // Turbulent constant double variation; // Variation of the design variables if (dim == 2) { variation = delta; } else if (dim == 3) { variation = delta/4; } std::vector<double> windSpeed(wsbinmax); std::vector<double> T(wsbinmax); // Thrust for (int i=0; i<wsbinmax; i++) { windSpeed[i] = i+0.5; if (dim == 2) { T[i] = 0.5*rho*d*pow(windSpeed[i],2)*Ct[i]; } else if (dim == 3) { T[i] = 0.5*rho*A*pow(windSpeed[i],2)*Ct[i]; } } double dt = 1; int nIter = 10000; int finalIter = 0; if (turb == 0) { for (int i=0; i<wsbinmax; i++) { T[i] = 0.1*T[i]; } } std::vector< std::vector< std::vector<double> > > adjointVel(wsbinmax,std::vector< std::vector<double> >(nwd,std::vector<double>(nt*8))); std::vector< std::vector< std::vector<double> > > adjointVol(wsbinmax,std::vector< std::vector<double> >(nwd,std::vector<double>(nt*8))); std::vector< std::vector< std::vector<double> > > dummyVel(wsbinmax,std::vector< std::vector<double> >(nwd,std::vector<double>(nt*4))); std::vector< std::vector< std::vector<double> > > dummyVol(wsbinmax,std::vector< std::vector<double> >(nwd,std::vector<double>(nt*4))); std::vector< std::vector< std::vector<double> > > rotorVol(wsbinmax,std::vector< std::vector<double> >(nwd,std::vector<double>(nt))); std::vector< std::vector< std::vector<double> > > rotorVel(wsbinmax,std::vector< std::vector<double> >(nwd,std::vector<double>(nt))); std::vector<double> Gradient(nt*2); std::ofstream resultFile; for (int i=0; i<nwd; i++) { std::vector< std::vector<double> > relPositions(nt,std::vector<double>(2)); for (int z=0; z<nt; z++) { relPositions[z][0] = positions[z][0]*cos(windDir[i]*pi/180)-positions[z][1]*sin(windDir[i]*pi/180); relPositions[z][1] = positions[z][0]*sin(windDir[i]*pi/180)+positions[z][1]*cos(windDir[i]*pi/180); } for (int j=0; j<wsbinmax; j++) { if (windRose[j][i] > 1e-5) { double check = 0; std::vector<double> tempGradient(nt*2); std::ostringstream directorySS; while (check < 1 || isnan(check) || isinf(check) || finalIter == 0) { directorySS.str(""); directorySS << "./wd-" << windDir[i] << "-ws-" << windSpeed[j]-0.5 << "_5"; std::string command = "cd " + directorySS.str() + "; ls -d *Output | xargs -I {} rm {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 1* | xargs -I {} rm -r {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 2* | xargs -I {} rm -r {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 3* | xargs -I {} rm -r {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 4* | xargs -I {} rm -r {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 5* | xargs -I {} rm -r {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 6* | xargs -I {} rm -r {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 7* | xargs -I {} rm -r {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 8* | xargs -I {} rm -r {}"; system(command.c_str()); command = "cd " + directorySS.str() + "; ls -d 9* | xargs -I {} rm -r {}"; system(command.c_str()); std::string directoryS = directorySS.str()+"/0"; command = "rm -r " + directoryS; system(command.c_str()); mkdir(directoryS.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); directoryS = directorySS.str()+"/constant"; command = "rm -r " + directoryS; system(command.c_str()); mkdir(directoryS.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); directoryS = directorySS.str()+"/system"; command = "rm -r " + directoryS; system(command.c_str()); mkdir(directoryS.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if (dim == 2) { pressure.a_twodLayout(directorySS.str()); velocity.a_twodLayout(directorySS.str()); k.a_twodLayout(directorySS.str()); epsilon.a_twodLayout(directorySS.str()); omega.a_twodLayout(directorySS.str()); } else if (dim == 3) { pressure.a_threedLayout(directorySS.str()); velocity.a_threedLayout(directorySS.str()); k.a_threedLayout(directorySS.str()); epsilon.a_threedLayout(directorySS.str()); omega.a_threedLayout(directorySS.str()); } simulation.a_schemes(directorySS.str()); simulation.a_solvers(turb,directorySS.str()); simulation.a_options(nt,T[j],directorySS.str()); if (terrain == 0) { simulation.topoSet(relPositions,d,h,variation,dim,directorySS.str()); simulation.a_topoSet(relPositions,lx,ly,lz,d,h,variation,dim,directorySS.str()); } else { simulation.topoSetComplexTerrain(d,h,variation,directorySS.str()); simulation.a_topoSetCompleTerrain(lx,ly,lz,d,h,variation,dim,directorySS.str()); } simulation.a_control(nIter,turb,directorySS.str()); simulation.a_run(np,turb,dim,directorySS.str()); results.a_finalIter(finalIter,turb,directorySS.str()); results.adjointVelocities(adjointVel[j][i],finalIter,directorySS.str()); results.adjointVolumes(adjointVol[j][i],finalIter,directorySS.str()); results.dummyRotorVelocities(dummyVel[j][i],finalIter,directorySS.str()); results.dummyRotorVolumes(dummyVol[j][i],finalIter,directorySS.str()); results.rotorVolumes(rotorVol[j][i],finalIter,directorySS.str()); results.rotorVelocities(rotorVel[j][i],finalIter,directorySS.str()); check = 0; for (int k=0; k<nt*2; k++) { tempGradient[k] = 0; } for (int k=0; k<nt; k++) { tempGradient[k*2+0] = tempGradient[k*2+0] + 8760*T[j]/rotorVol[j][i][k]*dummyVel[j][i][k*4+0]*dummyVol[j][i][k*4+0]/(2*variation); tempGradient[k*2+0] = tempGradient[k*2+0] - 8760*T[j]/rotorVol[j][i][k]*dummyVel[j][i][k*4+1]*dummyVol[j][i][k*4+1]/(2*variation); tempGradient[k*2+1] = tempGradient[k*2+1] + 8760*T[j]/rotorVol[j][i][k]*dummyVel[j][i][k*4+2]*dummyVol[j][i][k*4+2]/(2*variation); tempGradient[k*2+1] = tempGradient[k*2+1] - 8760*T[j]/rotorVol[j][i][k]*dummyVel[j][i][k*4+3]*dummyVol[j][i][k*4+3]/(2*variation); tempGradient[k*2+0] = tempGradient[k*2+0] + 8760*T[j]/rotorVol[j][i][k]*adjointVel[j][i][k*8+0]*adjointVol[j][i][k*8+0]/(2*variation); tempGradient[k*2+0] = tempGradient[k*2+0] - 8760*T[j]/rotorVol[j][i][k]*adjointVel[j][i][k*8+1]*adjointVol[j][i][k*8+1]/(2*variation); tempGradient[k*2+0] = tempGradient[k*2+0] + 8760*T[j]/rotorVol[j][i][k]*adjointVel[j][i][k*8+2]*adjointVol[j][i][k*8+2]/(2*variation); tempGradient[k*2+0] = tempGradient[k*2+0] - 8760*T[j]/rotorVol[j][i][k]*adjointVel[j][i][k*8+3]*adjointVol[j][i][k*8+3]/(2*variation); tempGradient[k*2+1] = tempGradient[k*2+1] + 8760*T[j]/rotorVol[j][i][k]*adjointVel[j][i][k*8+4]*adjointVol[j][i][k*8+4]/(2*variation); tempGradient[k*2+1] = tempGradient[k*2+1] - 8760*T[j]/rotorVol[j][i][k]*adjointVel[j][i][k*8+5]*adjointVol[j][i][k*8+5]/(2*variation); tempGradient[k*2+1] = tempGradient[k*2+1] + 8760*T[j]/rotorVol[j][i][k]*adjointVel[j][i][k*8+6]*adjointVol[j][i][k*8+6]/(2*variation); tempGradient[k*2+1] = tempGradient[k*2+1] - 8760*T[j]/rotorVol[j][i][k]*adjointVel[j][i][k*8+7]*adjointVol[j][i][k*8+7]/(2*variation); check = check + abs(tempGradient[k*2+0]) + abs(tempGradient[k*2+1]); } } std::vector<double> absGradient(nt*2); for (int k=0; k<nt; k++) { //if (rotorVel[j][i][k] > 0.95*(*std::max_element(rotorVel[j][i].begin(), rotorVel[j][i].end()))) { // tempGradient[k*2+1] = 0; //} absGradient[k*2+0] = tempGradient[k*2+0]*cos(-windDir[i]*pi/180)-tempGradient[k*2+1]*sin(-windDir[i]*pi/180); absGradient[k*2+1] = tempGradient[k*2+0]*sin(-windDir[i]*pi/180)+tempGradient[k*2+1]*cos(-windDir[i]*pi/180); Gradient[k*2+0] = Gradient[k*2+0] + windRose[j][i]*absGradient[k*2+0]; Gradient[k*2+1] = Gradient[k*2+1] + windRose[j][i]*absGradient[k*2+1]; } simulation.cleanAdjoint(directorySS.str()); directorySS.str(""); resultFile.open("Results-Gradient.txt",std::ofstream::app); resultFile << "Wind direction " << windDir[i] << " deg, wind speed " << windSpeed[j] << " m/s\n\n"; resultFile << "Finished after " << finalIter << " iterations\n"; resultFile << "The gradient is\n"; for (int k=0; k<nt; k++) { resultFile << tempGradient[k*2+0]/1000 << " " << tempGradient[k*2+1]/1000 << "\n"; } resultFile << "kWh/m\nor\n"; for (int k=0; k<nt; k++) { resultFile << sqrt(pow(tempGradient[k*2+0]/1000,2) + pow(tempGradient[k*2+1]/1000,2)) << " kWh/m, " << atan2(tempGradient[k*2+1]/1000,tempGradient[k*2+0]/1000)*180/pi << " deg\n"; } resultFile << "\n"; resultFile.close(); } } } resultFile.open("Results-Gradient.txt",std::ofstream::app); resultFile << "The total gradient is\n"; for (int k=0; k<nt; k++) { resultFile << Gradient[k*2+0]/1000 << " " << Gradient[k*2+1]/1000 << "\n"; } resultFile << "kWh/m\nor\n"; for (int k=0; k<nt; k++) { resultFile << sqrt(pow(Gradient[k*2+0]/1000,2) + pow(Gradient[k*2+1]/1000,2)) << " kWh/m, " << atan2(Gradient[k*2+1]/1000,Gradient[k*2+0]/1000)*180/pi << " deg\n"; } resultFile.close(); return 0; }
c4ce5088181e9d8b2e30071832d00e1ebad36ff7
1809b5bda803fbbf51dcbc4e2d464c762f3563c1
/sparse_grid_laguerre_dataset/sparse_grid_laguerre_dataset.cpp
8ed594c260d5081b7e526e3f4684c7b0453899f0
[]
no_license
tnakaicode/jburkardt
42c5ef74ab88d17afbd188e4ff2b4ecb8a30bb25
74eebcbda61423178b96cfdec5d8bb30d6494a33
refs/heads/master
2020-12-24T02:23:01.855912
2020-02-05T02:10:32
2020-02-05T02:10:32
237,349,784
0
0
null
null
null
null
UTF-8
C++
false
false
79,741
cpp
# include <cstdlib> # include <cmath> # include <iostream> # include <fstream> # include <iomanip> # include <ctime> using namespace std; int main ( int argc, char *argv[] ); int choose ( int n, int k ); void comp_next ( int n, int k, int a[], bool *more, int *h, int *t ); int i4_log_2 ( int i ); int i4_max ( int i1, int i2 ); int i4_min ( int i1, int i2 ); int i4_modp ( int i, int j ); int i4_power ( int i, int j ); string i4_to_string ( int i4, string format ); int i4vec_product ( int n, int a[] ); void laguerre_abscissa ( int dim_num, int point_num, int grid_index[], int grid_base[], double grid_point[] ); void laguerre_weights ( int order, double weight[] ); void level_to_order_open ( int dim_num, int level[], int order[] ); int *multigrid_index_one ( int dim_num, int order_1d[], int order_nd ); double *product_weight_laguerre ( int dim_num, int order_1d[], int order_nd ); double r8_epsilon ( ); double r8_huge ( ); void r8mat_transpose_print_some ( int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, string title ); void r8mat_write ( string output_filename, int m, int n, double table[] ); void r8vec_direct_product2 ( int factor_index, int factor_order, double factor_value[], int factor_num, int point_num, double w[] ); void r8vec_print_some ( int n, double a[], int i_lo, int i_hi, string title ); int s_len_trim ( string s ); void sparse_grid_laguerre ( int dim_num, int level_max, int point_num, double grid_weight[], double grid_point[] ); void sparse_grid_laguerre_index ( int dim_num, int level_max, int point_num, int grid_index [], int grid_base[] ); int sparse_grid_laguerre_size ( int dim_num, int level_max ); void timestamp ( ); void vec_colex_next2 ( int dim_num, int base[], int a[], bool *more ); //****************************************************************************80 int main ( int argc, char *argv[] ) //****************************************************************************80 // // Purpose: // // MAIN is the main program for SPARSE_GRID_LAGUERRE_DATASET. // // Discussion: // // This program computes a sparse grid quadrature rule based on a 1D // Gauss-Laguerre rule and writes it to a file.. // // The user specifies: // * the spatial dimension of the quadrature region, // * the level that defines the Smolyak grid. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 10 July 2009 // // Author: // // John Burkardt // // Reference: // // Fabio Nobile, Raul Tempone, Clayton Webster, // A Sparse Grid Stochastic Collocation Method for Partial Differential // Equations with Random Input Data, // SIAM Journal on Numerical Analysis, // Volume 46, Number 5, 2008, pages 2309-2345. // { int dim; int dim_num; int level_max; int level_min; int point; int point_num; double *r; string r_filename; double *w; string w_filename; double weight_sum; double *x; string x_filename; timestamp ( ); cout << "\n"; cout << "SPARSE_GRID_LAGUERRE_DATASET\n"; cout << " C++ version\n"; cout << "\n"; cout << " Compiled on " << __DATE__ << " at " << __TIME__ << ".\n"; cout << "\n"; cout << " Compute the abscissas and weights of a quadrature rule\n"; cout << " associated with a sparse grid derived from a Smolyak\n"; cout << " construction based on a 1D Gauss-Laguerre rule.\n"; cout << "\n"; cout << " Inputs to the program include:\n"; cout << "\n"; cout << " DIM_NUM, the spatial dimension.\n"; cout << " (typically in the range of 2 to 10)\n"; cout << "\n"; cout << " LEVEL_MAX, the level of the sparse grid.\n"; cout << " (typically in the range of 0, 1, 2, 3, ...\n"; cout << "\n"; cout << " Output from the program includes:\n"; cout << "\n"; cout << " * A printed table of the abscissas and weights.\n"; cout << "\n"; cout << " * A set of 3 files that define the quadrature rule.\n"; cout << "\n"; cout << " (1) lag_d?_level?_r.txt, the ranges;\n"; cout << " (2) lag_d?_level?_w.txt, the weights;\n"; cout << " (3) lag_d?_level?_x.txt, the abscissas.\n"; // // Get the spatial dimension. // if ( 1 < argc ) { dim_num = atoi ( argv[1] ); } else { cout << "\n"; cout << " Enter the value of DIM_NUM (1 or greater)\n"; cin >> dim_num; } cout << "\n"; cout << " Spatial dimension requested is = " << dim_num << "\n"; // // Get the level. // if ( 2 < argc ) { level_max = atoi ( argv[2] ); } else { cout << "\n"; cout << " Enter the value of LEVEL_MAX (0 or greater).\n"; cin >> level_max; } level_min = i4_max ( 0, level_max + 1 - dim_num ); cout << "\n"; cout << " LEVEL_MIN is = " << level_min << "\n"; cout << " LEVEL_MAX is = " << level_max << "\n"; // // How many distinct points will there be? // point_num = sparse_grid_laguerre_size ( dim_num, level_max ); cout << "\n"; cout << " The number of distinct abscissas in the\n"; cout << " quadrature rule is determined from the spatial\n"; cout << " dimension DIM_NUM and the level LEVEL_MAX.\n"; cout << " For the given input, this value will be = " << point_num << "\n"; // // Allocate memory. // r = new double[dim_num*2]; w = new double[point_num]; x = new double[dim_num*point_num]; // // Compute the weights and points. // for ( dim = 0; dim < dim_num; dim++ ) { r[dim+0*dim_num] = 0.0E+00; r[dim+1*dim_num] = + r8_huge ( ); } sparse_grid_laguerre ( dim_num, level_max, point_num, w, x ); r8mat_transpose_print_some ( dim_num, point_num, x, 1, 1, dim_num, 10, " First 10 grid points:" ); r8vec_print_some ( point_num, w, 1, 10, " First 10 grid weights:" ); weight_sum = 0.0; for ( point = 0; point < point_num; point++ ) { weight_sum = weight_sum + w[point]; } cout << "\n"; cout << " Weights sum to " << weight_sum << "\n"; cout << " Correct value is " << 1.0 << "\n"; // // Construct appropriate file names. // r_filename = "lag_d" + i4_to_string ( dim_num, "%d" ) + "_level" + i4_to_string ( level_max, "%d" ) + "_r.txt"; w_filename = "lag_d" + i4_to_string ( dim_num, "%d" ) + "_level" + i4_to_string ( level_max, "%d" ) + "_w.txt"; x_filename = "lag_d" + i4_to_string ( dim_num, "%d" ) + "_level" + i4_to_string ( level_max, "%d" ) + "_x.txt"; // // Write the rule to files. // cout << "\n"; cout << " Creating R file = \"" << r_filename << "\".\n"; r8mat_write ( r_filename, dim_num, 2, r ); cout << " Creating W file = \"" << w_filename << "\".\n"; r8mat_write ( w_filename, 1, point_num, w ); cout << " Creating X file = \"" << x_filename << "\".\n"; r8mat_write ( x_filename, dim_num, point_num, x ); delete [] r; delete [] w; delete [] x; cout << "\n"; cout << "SPARSE_GRID_LAGUERRE_DATASET\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 int choose ( int n, int k ) //****************************************************************************80 // // Purpose: // // CHOOSE computes the binomial coefficient C(N,K). // // Discussion: // // The value is calculated in such a way as to avoid overflow and // roundoff. The calculation is done in integer arithmetic. // // The formula used is: // // C(N,K) = N! / ( K! * (N-K)! ) // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 22 May 2007 // // Author: // // John Burkardt // // Reference: // // ML Wolfson, HV Wright, // Algorithm 160: // Combinatorial of M Things Taken N at a Time, // Communications of the ACM, // Volume 6, Number 4, April 1963, page 161. // // Parameters: // // Input, int N, K, are the values of N and K. // // Output, int CHOOSE, the number of combinations of N // things taken K at a time. // { int i; int mn; int mx; int value; mn = i4_min ( k, n - k ); if ( mn < 0 ) { value = 0; } else if ( mn == 0 ) { value = 1; } else { mx = i4_max ( k, n - k ); value = mx + 1; for ( i = 2; i <= mn; i++ ) { value = ( value * ( mx + i ) ) / i; } } return value; } //****************************************************************************80 void comp_next ( int n, int k, int a[], bool *more, int *h, int *t ) //****************************************************************************80 // // Purpose: // // COMP_NEXT computes the compositions of the integer N into K parts. // // Discussion: // // A composition of the integer N into K parts is an ordered sequence // of K nonnegative integers which sum to N. The compositions (1,2,1) // and (1,1,2) are considered to be distinct. // // The routine computes one composition on each call until there are no more. // For instance, one composition of 6 into 3 parts is // 3+2+1, another would be 6+0+0. // // On the first call to this routine, set MORE = FALSE. The routine // will compute the first element in the sequence of compositions, and // return it, as well as setting MORE = TRUE. If more compositions // are desired, call again, and again. Each time, the routine will // return with a new composition. // // However, when the LAST composition in the sequence is computed // and returned, the routine will reset MORE to FALSE, signaling that // the end of the sequence has been reached. // // This routine originally used a SAVE statement to maintain the // variables H and T. I have decided that it is safer // to pass these variables as arguments, even though the user should // never alter them. This allows this routine to safely shuffle // between several ongoing calculations. // // // There are 28 compositions of 6 into three parts. This routine will // produce those compositions in the following order: // // I A // - --------- // 1 6 0 0 // 2 5 1 0 // 3 4 2 0 // 4 3 3 0 // 5 2 4 0 // 6 1 5 0 // 7 0 6 0 // 8 5 0 1 // 9 4 1 1 // 10 3 2 1 // 11 2 3 1 // 12 1 4 1 // 13 0 5 1 // 14 4 0 2 // 15 3 1 2 // 16 2 2 2 // 17 1 3 2 // 18 0 4 2 // 19 3 0 3 // 20 2 1 3 // 21 1 2 3 // 22 0 3 3 // 23 2 0 4 // 24 1 1 4 // 25 0 2 4 // 26 1 0 5 // 27 0 1 5 // 28 0 0 6 // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 02 July 2008 // // Author: // // Original FORTRAN77 version by Albert Nijenhuis, Herbert Wilf. // C++ version by John Burkardt. // // Reference: // // Albert Nijenhuis, Herbert Wilf, // Combinatorial Algorithms for Computers and Calculators, // Second Edition, // Academic Press, 1978, // ISBN: 0-12-519260-6, // LC: QA164.N54. // // Parameters: // // Input, int N, the integer whose compositions are desired. // // Input, int K, the number of parts in the composition. // // Input/output, int A[K], the parts of the composition. // // Input/output, bool *MORE. // Set MORE = FALSE on first call. It will be reset to TRUE on return // with a new composition. Each new call returns another composition until // MORE is set to FALSE when the last composition has been computed // and returned. // // Input/output, int *H, *T, two internal parameters needed for the // computation. The user should allocate space for these in the calling // program, include them in the calling sequence, but never alter them! // { int i; if ( !( *more ) ) { *t = n; *h = 0; a[0] = n; for ( i = 1; i < k; i++ ) { a[i] = 0; } } else { if ( 1 < *t ) { *h = 0; } *h = *h + 1; *t = a[*h-1]; a[*h-1] = 0; a[0] = *t - 1; a[*h] = a[*h] + 1; } *more = ( a[k-1] != n ); return; } //****************************************************************************80 int i4_log_2 ( int i ) //****************************************************************************80 // // Purpose: // // I4_LOG_2 returns the integer part of the logarithm base 2 of an I4. // // Example: // // I I4_LOG_10 // ----- -------- // 0 0 // 1 0 // 2 1 // 3 1 // 4 2 // 5 2 // 7 2 // 8 3 // 9 3 // 1000 9 // 1024 10 // // Discussion: // // I4_LOG_2 ( I ) + 1 is the number of binary digits in I. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 04 January 2004 // // Author: // // John Burkardt // // Parameters: // // Input, int I, the number whose logarithm base 2 is desired. // // Output, int I4_LOG_2, the integer part of the logarithm base 2 of // the absolute value of X. // { int i_abs; int two_pow; int value; if ( i == 0 ) { value = 0; } else { value = 0; two_pow = 2; i_abs = abs ( i ); while ( two_pow <= i_abs ) { value = value + 1; two_pow = two_pow * 2; } } return value; } //****************************************************************************80 int i4_max ( int i1, int i2 ) //****************************************************************************80 // // Purpose: // // I4_MAX returns the maximum of two I4's. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 May 2003 // // Author: // // John Burkardt // // Parameters: // // Input, int I1, I2, two integers to be compared. // // Output, int I4_MAX, the larger of i1 and i2. // { int value; if ( i2 < i1 ) { value = i1; } else { value = i2; } return value; } //****************************************************************************80 int i4_min ( int i1, int i2 ) //****************************************************************************80 // // Purpose: // // I4_MIN returns the smaller of two I4's. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 May 2003 // // Author: // // John Burkardt // // Parameters: // // Input, int I1, I2, two integers to be compared. // // Output, int I4_MIN, the smaller of i1 and i2. // { int value; if ( i1 < i2 ) { value = i1; } else { value = i2; } return value; } //****************************************************************************80 int i4_modp ( int i, int j ) //****************************************************************************80 // // Purpose: // // I4_MODP returns the nonnegative remainder of I4 division. // // Formula: // // If // NREM = I4_MODP ( I, J ) // NMULT = ( I - NREM ) / J // then // I = J * NMULT + NREM // where NREM is always nonnegative. // // Comments: // // The MOD function computes a result with the same sign as the // quantity being divided. Thus, suppose you had an angle A, // and you wanted to ensure that it was between 0 and 360. // Then mod(A,360) would do, if A was positive, but if A // was negative, your result would be between -360 and 0. // // On the other hand, I4_MODP(A,360) is between 0 and 360, always. // // Examples: // // I J MOD I4_MODP I4_MODP Factorization // // 107 50 7 7 107 = 2 * 50 + 7 // 107 -50 7 7 107 = -2 * -50 + 7 // -107 50 -7 43 -107 = -3 * 50 + 43 // -107 -50 -7 43 -107 = 3 * -50 + 43 // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 26 May 1999 // // Author: // // John Burkardt // // Parameters: // // Input, int I, the number to be divided. // // Input, int J, the number that divides I. // // Output, int I4_MODP, the nonnegative remainder when I is // divided by J. // { int value; if ( j == 0 ) { cout << "\n"; cout << "I4_MODP - Fatal error!\n"; cout << " I4_MODP ( I, J ) called with J = " << j << "\n"; exit ( 1 ); } value = i % j; if ( value < 0 ) { value = value + abs ( j ); } return value; } //****************************************************************************80 int i4_power ( int i, int j ) //****************************************************************************80 // // Purpose: // // I4_POWER returns the value of I^J. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 17 August 2007 // // Author: // // John Burkardt // // Parameters: // // Input, int I, J, the base and the power. J should be nonnegative. // // Output, int I4_POWER, the value of I^J. // { int k; int value; if ( j < 0 ) { if ( i == 1 ) { value = 1; } else if ( i == 0 ) { cout << "\n"; cout << "I4_POWER - Fatal error!\n"; cout << " I^J requested, with I = 0 and J negative.\n"; exit ( 1 ); } else { value = 0; } } else if ( j == 0 ) { if ( i == 0 ) { cout << "\n"; cout << "I4_POWER - Fatal error!\n"; cout << " I^J requested, with I = 0 and J = 0.\n"; exit ( 1 ); } else { value = 1; } } else if ( j == 1 ) { value = i; } else { value = 1; for ( k = 1; k <= j; k++ ) { value = value * i; } } return value; } //****************************************************************************80 string i4_to_string ( int i4, string format ) //****************************************************************************80 // // Purpose: // // I4_TO_STRING converts an I4 to a C++ string. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 09 July 2009 // // Author: // // John Burkardt // // Parameters: // // Input, int I4, an integer. // // Input, string FORMAT, the format string. // // Output, string I4_TO_STRING, the string. // { char i4_char[80]; string i4_string; sprintf ( i4_char, format.c_str ( ), i4 ); i4_string = string ( i4_char ); return i4_string; } //****************************************************************************80 int i4vec_product ( int n, int a[] ) //****************************************************************************80 // // Purpose: // // I4VEC_PRODUCT multiplies the entries of an I4VEC. // // Example: // // A = ( 1, 2, 3, 4 ) // // I4VEC_PRODUCT = 24 // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 17 August 2007 // // Author: // // John Burkardt // // Parameters: // // Input, int N, the number of entries in the vector. // // Input, int A[N], the vector // // Output, int I4VEC_PRODUCT, the product of the entries of A. // { int i; int product; product = 1; for ( i = 0; i < n; i++ ) { product = product * a[i]; } return product; } //****************************************************************************80 void laguerre_abscissa ( int dim_num, int point_num, int grid_index[], int grid_base[], double grid_point[] ) //****************************************************************************80 // // Purpose: // // LAGUERRE_ABSCISSA sets abscissas for multidimensional Gauss-Laguerre quadrature. // // Discussion: // // The "nesting" as it occurs for Gauss-Laguerre sparse grids simply // involves the use of a specified set of permissible orders for the // rule. // // The X array lists the (complete) Gauss-Legendre abscissas for rules // of order 1, 3, 7, 15, 31, 63 or 127, in order. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 10 October 2007 // // Author: // // John Burkardt // // Parameters: // // Input, int DIM_NUM, the spatial dimension. // // Input, int POINT_NUM, the number of points. // // Input, int GRID_INDEX[DIM_NUM*POINT_NUM], the index of the abscissa // from the rule, for each dimension and point. // // Input, int GRID_BASE[DIM_NUM], the number of points used in the // rule for a given dimension. // // Output, double GRID_POINT[DIM_NUM], the grid points of abscissas. // { int dim; int level; int point; int pointer; int skip[8] = { 0, 1, 4, 11, 26, 57, 120, 247 }; double x[247] = { 1.0E+00, 0.415774556783479083311533873128E+00, 0.229428036027904171982205036136E+01, 0.628994508293747919686641576551E+01, 0.193043676560362413838247885004E+00, 0.102666489533919195034519944317E+01, 0.256787674495074620690778622666E+01, 0.490035308452648456810171437810E+01, 0.818215344456286079108182755123E+01, 0.127341802917978137580126424582E+02, 0.193957278622625403117125820576E+02, 0.933078120172818047629030383672E-01, 0.492691740301883908960101791412E+00, 0.121559541207094946372992716488E+01, 0.226994952620374320247421741375E+01, 0.366762272175143727724905959436E+01, 0.542533662741355316534358132596E+01, 0.756591622661306786049739555812E+01, 0.101202285680191127347927394568E+02, 0.131302824821757235640991204176E+02, 0.166544077083299578225202408430E+02, 0.207764788994487667729157175676E+02, 0.256238942267287801445868285977E+02, 0.314075191697539385152432196202E+02, 0.385306833064860094162515167595E+02, 0.480260855726857943465734308508E+02, 0.45901947621108290743496080275224E-01, 0.24198016382477204890408974151714E+00, 0.59525389422235073707330165005414E+00, 1.1066894995329987162111308789792E+00, 1.7775956928747727211593727482675E+00, 2.6097034152566806503893375925315E+00, 3.6051968023400442698805817554243E+00, 4.7667470844717611313629127271123E+00, 6.0975545671817409269925429328463E+00, 7.6014009492331374229360106942867E+00, 9.2827143134708894182536695297710E+00, 11.146649755619291358993815629587E+00, 13.199189576244998522464925028637E+00, 15.447268315549310075809325891801E+00, 17.898929826644757646725793817752E+00, 20.563526336715822170743048968779E+00, 23.451973482011858591050255575933E+00, 26.577081352118260459975876986478E+00, 29.953990872346445506951917840024E+00, 33.600759532902202735410313885784E+00, 37.539164407330440882887902558001E+00, 41.795830870182219981347945853330E+00, 46.403866806411123136029227604386E+00, 51.405314476797755161861461088395E+00, 56.854992868715843620511922055660E+00, 62.826855908786321453677523304806E+00, 69.425277191080345623322251656443E+00, 76.807047763862732837609972285484E+00, 85.230358607545669169387065607043E+00, 95.188939891525629981308606853957E+00, 107.95224382757871475002440117666E+00, 0.22768893732576153785994330248562E-01, 0.11998325242727824715771416426383E+00, 0.29494185444770149577427738517405E+00, 0.54779087896237725363865073775856E+00, 0.87869061179931901673895567052285E+00, 1.2878464335919706302309207788611E+00, 1.7755123815388553763979463268728E+00, 2.3419925567085989256055628337716E+00, 2.9876423223246473939976731053629E+00, 3.7128695992018000346299637413422E+00, 4.5181363349503584391105568561550E+00, 5.4039601781825946286902599782736E+00, 6.3709163787865330220392250891777E+00, 7.4196399339311711154888493199004E+00, 8.5508280008403328312589048722235E+00, 9.7652425999245366807004592977996E+00, 11.063713635140661736220550410604E+00, 12.447142262356492749798687569289E+00, 13.916504641057818562912967008183E+00, 15.472856110036296424777143607779E+00, 17.117335833863588753116900303886E+00, 18.851171974154856850873483787506E+00, 20.675687448056515660377265667433E+00, 22.592306346311528381292277759986E+00, 24.602561094972638883700642760037E+00, 26.708100458737343969779087998829E+00, 28.910698500451382640177718103234E+00, 31.212264631175912885477773820802E+00, 33.614854909101154836598842888345E+00, 36.120684774484823056306328740825E+00, 38.732143442933582145626041607663E+00, 41.451810222318741191114726181363E+00, 44.282473071479233839358857134636E+00, 47.227149784295686898935095231536E+00, 50.289112264240695761749021839419E+00, 53.471914456788652808348280619542E+00, 56.779424636342062213099781057119E+00, 60.215862909019862886417550114424E+00, 63.785845004235974631701139601836E+00, 67.494433702293885830374325695045E+00, 71.347199604295266286654803376075E+00, 75.350293425653234254290504744279E+00, 79.510532629986309149555391354778E+00, 83.835506080872257843339817658508E+00, 88.333701570354369086112766326498E+00, 93.014662728558547405303399037100E+00, 97.889184147578140043386727677112E+00, 102.96955690741381650783952746778E+00, 108.26988161961595392226350967206E+00, 113.80647350287462738934485955901E+00, 119.59839538830458666962452963285E+00, 125.66817255856119431291196303280E+00, 132.04277272091165746585590583045E+00, 138.75498418103789078167590567526E+00, 145.84541318313540358283994248439E+00, 153.36548459497863623710815962660E+00, 161.38215194813761243562172669592E+00, 169.98570600665839438795175301156E+00, 179.30366247401580910251827858515E+00, 189.52789596532475473668721332981E+00, 200.97521159924656741628671841018E+00, 214.25368536638788642698056296400E+00, 230.93465747089703971246562985079E+00, 0.11339635298518611691893169631306E-01, 0.59749753435726620281348237057387E-01, 0.14685098690746167612388223687431E+00, 0.27267590735859553131378008278900E+00, 0.43724600644192665554577035869932E+00, 0.64058688222566929533576416399983E+00, 0.88272968639058364481487653650042E+00, 1.1637114160166537661560584700951E+00, 1.4835750152834613891313584861012E+00, 1.8423694351613565380686320809853E+00, 2.2401496839579024244513315656522E+00, 2.6769768780141303692167869961238E+00, 3.1529182957082825565771508308846E+00, 3.6680474360304752540226339926515E+00, 4.2224440823301888455977876667425E+00, 4.8161943715870502475665535087286E+00, 5.4493908694559416755862178908416E+00, 6.1221326512997254193944584763155E+00, 6.8345253894122668112237994973336E+00, 7.5866814466367472174205986836847E+00, 8.3787199765932725254842120659452E+00, 9.2107670307426558777922506102445E+00, 10.082955672528643809166439353647E+00, 10.995426098858125429803147358780E+00, 11.948325769197725997610605127857E+00, 12.941809542585531053723381098192E+00, 13.976039822878506520014405668679E+00, 15.051186712579523631574796365435E+00, 16.167428175612852922977395051768E+00, 17.324950209443673446561163712616E+00, 18.523947026965688560811711309349E+00, 19.764621248611504104071669386884E+00, 21.047184105173183606877044020054E+00, 22.371855651855542817648123918101E+00, 23.738864994122497183652313788712E+00, 25.148450525937368234077278385644E+00, 26.600860181041749607253384279755E+00, 28.096351697964619201753961292129E+00, 29.635192899504178910610227138642E+00, 31.217661987479759144214467152615E+00, 32.844047853610430460522951341338E+00, 34.514650407441149149105635947422E+00, 36.229780922306804019615388508885E+00, 37.989762400399956435968780140278E+00, 39.794929958089961778396437141707E+00, 41.645631232730180705153990897484E+00, 43.542226812286859549950892993822E+00, 45.485090689228791137996151336673E+00, 47.474610740231964719468766599146E+00, 49.511189233379087716728884584381E+00, 51.595243364671244443182771266934E+00, 53.727205825819316758288140069145E+00, 55.907525405447553305830605991732E+00, 58.136667626022439197077526025660E+00, 60.415115419018590295707192053805E+00, 62.743369841051809700207126742685E+00, 65.121950833949996311956025417139E+00, 67.551398031997886314411872443149E+00, 70.032271619884584511229871192030E+00, 72.565153245206849090888669416801E+00, 75.150646989739935299354362325096E+00, 77.789380404085816000647405462136E+00, 80.482005610750729205803962926758E+00, 83.229200481195914886796120019048E+00, 86.031669892953582966798238732643E+00, 88.890147073512051099652518544282E+00, 91.805395038358177994971250170499E+00, 94.778208131331583205387031034825E+00, 97.809413676305116411054110115424E+00, 100.89987375017285940371939762172E+00, 104.05048708821598934704076845022E+00, 107.26219113414600428423116401414E+00, 110.53596424851500530602771351277E+00, 113.87282809075839485348376187652E+00, 117.27385019192517774095477886379E+00, 120.74014673718880106173978002719E+00, 124.27288557955698354259506446928E+00, 127.87328950885942645093841745425E+00, 131.54263980314366921809377742137E+00, 135.28228009311836970132738106369E+00, 139.09362057432970013964422086977E+00, 142.97814260643601776808227753574E+00, 146.93740374437366549441080969072E+00, 150.97304325252187127492511437460E+00, 155.08678816034612572229641420609E+00, 159.28045992663288235401956989889E+00, 163.55598178957571104015967182053E+00, 167.91538689194360134245547184721E+00, 172.36082728473812536838156191681E+00, 176.89458392960192176311674993508E+00, 181.51907784036813069227528834025E+00, 186.23688252828112373861202530357E+00, 191.05073794450929196790836610789E+00, 195.96356614879879837839002542988E+00, 200.97848897600025153696475526130E+00, 206.09884802468871112127283042753E+00, 211.32822735671655260572377256981E+00, 216.67047937658230323477089465777E+00, 222.12975445929687246267304963754E+00, 227.71053502072232419089132431317E+00, 233.41767488282602453367775322563E+00, 239.25644498830308620018749667089E+00, 245.23258677871567172531254018984E+00, 251.35237488718128030005500991754E+00, 257.62269123792061413076191882313E+00, 264.05111322908240551754377241831E+00, 270.64601945722796749299111718606E+00, 277.41671750163651071798388218104E+00, 284.37359974220870326674402873120E+00, 291.52833521346495719581282021650E+00, 298.89410837028248600878895615414E+00, 306.48591978262611320418112423947E+00, 314.32096986471177487400007507615E+00, 322.41915589128679683349440361344E+00, 330.80372663802405651933847334878E+00, 339.50216127832433747735367595958E+00, 348.54737559472697355480761787441E+00, 357.97942028029845454049007443090E+00, 367.84794520076004578858341422871E+00, 378.21590623135532818332979188889E+00, 389.16539141251004101579475325153E+00, 400.80729331451702589996361286427E+00, 413.29853681779384418008260081859E+00, 426.87579153663675538288509017051E+00, 441.93085485310841412460309271842E+00, 459.21804639888429981971267313224E+00, 480.69378263388373859704269229304E+00 }; for ( dim = 0; dim < dim_num; dim++ ) { if ( grid_base[dim] < 1 ) { cout << "\n"; cout << "LAGUERRE_ABSCISSA - Fatal error!\n"; cout << " Some base values are less than 1.\n"; exit ( 1 ); } } for ( dim = 0; dim < dim_num; dim++ ) { if ( 127 < grid_base[dim] ) { cout << "\n"; cout << "LAGUERRE_ABSCISSA - Fatal error!\n"; cout << " Some base values are greater than 127.\n"; exit ( 1 ); } } for ( point = 0; point < point_num; point++ ) { for ( dim = 0; dim < dim_num; dim++ ) { level = i4_log_2 ( grid_base[dim] + 1 ) - 1; pointer = skip[level] + grid_index[dim+point*dim_num]; if ( pointer < 1 || 247 < pointer ) { cout << "\n"; cout << "LAGUERRE_ABSCISSA - Fatal error!\n"; cout << " POINTER out of bounds.\n"; cout << " POINTER = " << pointer << "\n"; cout << " POINT = " << point << "\n"; cout << " DIM = " << dim << "\n"; cout << " GRID_BASE = " << grid_base[dim] << "\n"; cout << " LEVEL = " << level << "\n"; cout << " GRID_INDEX = " << grid_index[dim+point*dim_num] << "\n"; exit ( 1 ); } grid_point[dim+point*dim_num] = x[pointer-1]; } } return; } //****************************************************************************80 void laguerre_weights ( int order, double weight[] ) //****************************************************************************80 // // Purpose: // // LAGUERRE_WEIGHTS returns weights for certain Gauss-Laguerre quadrature rules. // // Discussion: // // The allowed orders are 1, 3, 7, 15, 31, 63 and 127. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 10 October 2007 // // Author: // // John Burkardt // // Reference: // // Milton Abramowitz, Irene Stegun, // Handbook of Mathematical Functions, // National Bureau of Standards, 1964, // ISBN: 0-486-61272-4, // LC: QA47.A34. // // Arthur Stroud, Don Secrest, // Gaussian Quadrature Formulas, // Prentice Hall, 1966, // LC: QA299.4G3S7. // // Parameters: // // Input, int ORDER, the order of the rule. // ORDER must be 1, 3, 7, 15, 31, 63 or 127. // // Output, double WEIGHT[ORDER], the weights. // The weights are positive, symmetric and should sum to 1. // { if ( order == 1 ) { weight[1-1] = 1.0E+00; } else if ( order == 3 ) { weight[1-1] = 0.711093009929173015449590191143E+00; weight[2-1] = 0.278517733569240848801444888457E+00; weight[3-1] = 0.103892565015861357489649204007E-01; } else if ( order == 7 ) { weight[1-1] = 0.409318951701273902130432880018E+00; weight[2-1] = 0.421831277861719779929281005417E+00; weight[3-1] = 0.147126348657505278395374184637E+00; weight[4-1] = 0.206335144687169398657056149642E-01; weight[5-1] = 0.107401014328074552213195962843E-02; weight[6-1] = 0.158654643485642012687326223234E-04; weight[7-1] = 0.317031547899558056227132215385E-07; } else if ( order == 15 ) { weight[1-1] = 0.218234885940086889856413236448E+00; weight[2-1] = 0.342210177922883329638948956807E+00; weight[3-1] = 0.263027577941680097414812275022E+00; weight[4-1] = 0.126425818105930535843030549378E+00; weight[5-1] = 0.402068649210009148415854789871E-01; weight[6-1] = 0.856387780361183836391575987649E-02; weight[7-1] = 0.121243614721425207621920522467E-02; weight[8-1] = 0.111674392344251941992578595518E-03; weight[9-1] = 0.645992676202290092465319025312E-05; weight[10-1] = 0.222631690709627263033182809179E-06; weight[11-1] = 0.422743038497936500735127949331E-08; weight[12-1] = 0.392189726704108929038460981949E-10; weight[13-1] = 0.145651526407312640633273963455E-12; weight[14-1] = 0.148302705111330133546164737187E-15; weight[15-1] = 0.160059490621113323104997812370E-19; } else if ( order == 31 ) { weight[ 1-1] = 0.11252789550372583820847728082801E+00; weight[ 2-1] = 0.21552760818089123795222505285045E+00; weight[ 3-1] = 0.23830825164569654731905788089234E+00; weight[ 4-1] = 0.19538830929790229249915303390711E+00; weight[ 5-1] = 0.12698283289306190143635272904602E+00; weight[ 6-1] = 0.67186168923899300670929441993508E-01; weight[ 7-1] = 0.29303224993879487404888669311974E-01; weight[ 8-1] = 0.10597569915295736089529380314433E-01; weight[ 9-1] = 0.31851272582386980320974842433019E-02; weight[ 10-1] = 0.79549548307940382922092149012477E-03; weight[ 11-1] = 0.16480052126636687317862967116412E-03; weight[ 12-1] = 0.28229237864310816393860971468993E-04; weight[ 13-1] = 0.39802902551008580387116174900106E-05; weight[ 14-1] = 0.45931839841801061673729694510289E-06; weight[ 15-1] = 0.43075545187731100930131457465897E-07; weight[ 16-1] = 0.32551249938271570855175749257884E-08; weight[ 17-1] = 0.19620246675410594996247151593142E-09; weight[ 18-1] = 0.93190499086617587129534716431331E-11; weight[ 19-1] = 0.34377541819411620520312597898311E-12; weight[ 20-1] = 0.96795247130446716997405035776206E-14; weight[ 21-1] = 0.20368066110115247398010624219291E-15; weight[ 22-1] = 0.31212687280713526831765358632585E-17; weight[ 23-1] = 0.33729581704161052453395678308350E-19; weight[ 24-1] = 0.24672796386616696011038363242541E-21; weight[ 25-1] = 0.11582201904525643634834564576593E-23; weight[ 26-1] = 0.32472922591425422434798022809020E-26; weight[ 27-1] = 0.49143017308057432740820076259666E-29; weight[ 28-1] = 0.34500071104808394132223135953806E-32; weight[ 29-1] = 0.87663710117162041472932760732881E-36; weight[ 30-1] = 0.50363643921161490411297172316582E-40; weight[ 31-1] = 0.19909984582531456482439549080330E-45; } else if ( order == 63 ) { weight[ 1-1] = 0.57118633213868979811587283390476E-01; weight[ 2-1] = 0.12067476090640395283319932036351E+00; weight[ 3-1] = 0.15925001096581873723870561096472E+00; weight[ 4-1] = 0.16875178327560799234596192963585E+00; weight[ 5-1] = 0.15366641977668956696193711310131E+00; weight[ 6-1] = 0.12368770614716481641086652261948E+00; weight[ 7-1] = 0.89275098854848671545279150057422E-01; weight[ 8-1] = 0.58258485446105944957571825725160E-01; weight[ 9-1] = 0.34546657545992580874717085812508E-01; weight[ 10-1] = 0.18675685985714656798286552591203E-01; weight[ 11-1] = 0.92233449044093536528490075241649E-02; weight[ 12-1] = 0.41671250684839592762582663470209E-02; weight[ 13-1] = 0.17238120299900582715386728541955E-02; weight[ 14-1] = 0.65320845029716311169340559359043E-03; weight[ 15-1] = 0.22677644670909586952405173207471E-03; weight[ 16-1] = 0.72127674154810668410750270234861E-04; weight[ 17-1] = 0.21011261180466484598811536851241E-04; weight[ 18-1] = 0.56035500893357212749181536071292E-05; weight[ 19-1] = 0.13673642785604888017836641282292E-05; weight[ 20-1] = 0.30507263930195817240736097189550E-06; weight[ 21-1] = 0.62180061839309763559981775409241E-07; weight[ 22-1] = 0.11566529551931711260022448996296E-07; weight[ 23-1] = 0.19614588267565478081534781863335E-08; weight[ 24-1] = 0.30286171195709411244334756404054E-09; weight[ 25-1] = 0.42521344539400686769012963452599E-10; weight[ 26-1] = 0.54202220578073819334698791381873E-11; weight[ 27-1] = 0.62627306838597672554166850420603E-12; weight[ 28-1] = 0.65474443156573322992307089591924E-13; weight[ 29-1] = 0.61815575808729181846302500000047E-14; weight[ 30-1] = 0.52592721363507381404263991342633E-15; weight[ 31-1] = 0.40230920092646484015391506025408E-16; weight[ 32-1] = 0.27600740511819536505013824207729E-17; weight[ 33-1] = 0.16936946756968296053322009855265E-18; weight[ 34-1] = 0.92689146872177087314963772462726E-20; weight[ 35-1] = 0.45093739060365632939780140603959E-21; weight[ 36-1] = 0.19435162876132376573629962695374E-22; weight[ 37-1] = 0.73926270895169207037999639194513E-24; weight[ 38-1] = 0.24714364154434632615980126000066E-25; weight[ 39-1] = 0.72288649446741597655145390616476E-27; weight[ 40-1] = 0.18407617292614039362985209905608E-28; weight[ 41-1] = 0.40583498566841960105759537058880E-30; weight[ 42-1] = 0.77000496416438368114463925286343E-32; weight[ 43-1] = 0.12488505764999334328843314866038E-33; weight[ 44-1] = 0.17185000226767010697663950619912E-35; weight[ 45-1] = 0.19896372636672396938013975755522E-37; weight[ 46-1] = 0.19199671378804058267713164416870E-39; weight[ 47-1] = 0.15278588285522166920459714708240E-41; weight[ 48-1] = 0.99054752688842142955854138884590E-44; weight[ 49-1] = 0.51597523673029211884228858692990E-46; weight[ 50-1] = 0.21249846664084111245693912887783E-48; weight[ 51-1] = 0.67903852766852910591172042494884E-51; weight[ 52-1] = 0.16466654148296177467908300517887E-53; weight[ 53-1] = 0.29509065402691055027053659375033E-56; weight[ 54-1] = 0.37838420647571051984882241014675E-59; weight[ 55-1] = 0.33358130068542431878174667995217E-62; weight[ 56-1] = 0.19223461022273880981363303073329E-65; weight[ 57-1] = 0.67812696961083016872779388922288E-69; weight[ 58-1] = 0.13404752802440604607620468935693E-72; weight[ 59-1] = 0.13109745101805029757648048223928E-76; weight[ 60-1] = 0.52624863881401787388694579143866E-81; weight[ 61-1] = 0.63780013856587414257760666006511E-86; weight[ 62-1] = 0.12997078942372924566347473916943E-91; weight[ 63-1] = 0.10008511496968754063443740168421E-98; } else if ( order == 127 ) { weight[ 1-1] = 0.28773246692000124355770010301506E-01; weight[ 2-1] = 0.63817468175134649363480949265236E-01; weight[ 3-1] = 0.91919669721570571389864194652717E-01; weight[ 4-1] = 0.11054167914413766381245463002967E+00; weight[ 5-1] = 0.11879771633375850188328329422643E+00; weight[ 6-1] = 0.11737818530052695148804451630074E+00; weight[ 7-1] = 0.10819305984180551488335145581193E+00; weight[ 8-1] = 0.93827075290489628080377261401107E-01; weight[ 9-1] = 0.76966450960588843995822485928431E-01; weight[ 10-1] = 0.59934903912939714332570730063476E-01; weight[ 11-1] = 0.44417742073889001371708316272923E-01; weight[ 12-1] = 0.31385080966252320983009372215062E-01; weight[ 13-1] = 0.21172316041924506411370709025015E-01; weight[ 14-1] = 0.13650145364230541652171185564626E-01; weight[ 15-1] = 0.84172852710599172279366657385445E-02; weight[ 16-1] = 0.49674990059882760515912858620175E-02; weight[ 17-1] = 0.28069903895001884631961957446400E-02; weight[ 18-1] = 0.15192951003941952460445341057817E-02; weight[ 19-1] = 0.78789028751796084086217287140548E-03; weight[ 20-1] = 0.39156751064868450584507324648999E-03; weight[ 21-1] = 0.18652434268825860550093566260060E-03; weight[ 22-1] = 0.85173160415576621908809828160247E-04; weight[ 23-1] = 0.37285639197853037712145321577724E-04; weight[ 24-1] = 0.15648416791712993947447805296768E-04; weight[ 25-1] = 0.62964340695224829035692735524979E-05; weight[ 26-1] = 0.24288929711328724574541379938222E-05; weight[ 27-1] = 0.89824607890051007201922871545035E-06; weight[ 28-1] = 0.31844174740760353710742966328091E-06; weight[ 29-1] = 0.10821272905566839211861807542741E-06; weight[ 30-1] = 0.35245076750635536015902779085340E-07; weight[ 31-1] = 0.11001224365719347407063839761738E-07; weight[ 32-1] = 0.32904079616717932125329343003261E-08; weight[ 33-1] = 0.94289145237889976419772700772988E-09; weight[ 34-1] = 0.25882578904668318184050195309296E-09; weight[ 35-1] = 0.68047437103370762630942259017560E-10; weight[ 36-1] = 0.17131398805120837835399564475632E-10; weight[ 37-1] = 0.41291744524052865469443922304935E-11; weight[ 38-1] = 0.95264189718807273220707664873469E-12; weight[ 39-1] = 0.21032604432442425932962942047474E-12; weight[ 40-1] = 0.44427151938729352860940434285789E-13; weight[ 41-1] = 0.89760500362833703323319846405449E-14; weight[ 42-1] = 0.17341511407769287074627948346848E-14; weight[ 43-1] = 0.32028099548988356631494379835210E-15; weight[ 44-1] = 0.56531388950793682022660742095189E-16; weight[ 45-1] = 0.95329672799026591234588044025896E-17; weight[ 46-1] = 0.15353453477310142565288509437552E-17; weight[ 47-1] = 0.23608962179467365686057842132176E-18; weight[ 48-1] = 0.34648742794456611332193876653230E-19; weight[ 49-1] = 0.48515241897086461320126957663545E-20; weight[ 50-1] = 0.64786228633519813428137373790678E-21; weight[ 51-1] = 0.82476020965403242936448553126316E-22; weight[ 52-1] = 0.10005361880214719793491658282977E-22; weight[ 53-1] = 0.11561395116207304954233181263632E-23; weight[ 54-1] = 0.12719342731167922655612134264961E-24; weight[ 55-1] = 0.13316584714165372967340004160814E-25; weight[ 56-1] = 0.13261218454678944033646108509198E-26; weight[ 57-1] = 0.12554995447643949807286074138324E-27; weight[ 58-1] = 0.11294412178579462703240913107219E-28; weight[ 59-1] = 0.96491020279562119228500608131696E-30; weight[ 60-1] = 0.78241846768302099396733076955632E-31; weight[ 61-1] = 0.60181503542219626658249939076636E-32; weight[ 62-1] = 0.43882482704961741551510518054138E-33; weight[ 63-1] = 0.30314137647517256304035802501863E-34; weight[ 64-1] = 0.19826016543944539545224676057020E-35; weight[ 65-1] = 0.12267623373665926559013654872402E-36; weight[ 66-1] = 0.71763931692508888943812834967620E-38; weight[ 67-1] = 0.39659378833836963584113716149270E-39; weight[ 68-1] = 0.20688970553868040099581951696677E-40; weight[ 69-1] = 0.10179587017979517245268418427523E-41; weight[ 70-1] = 0.47200827745986374625714293679649E-43; weight[ 71-1] = 0.20606828985553374825744353490744E-44; weight[ 72-1] = 0.84627575907305987245899032156188E-46; weight[ 73-1] = 0.32661123687088798658026998931647E-47; weight[ 74-1] = 0.11833939207883162380564134612682E-48; weight[ 75-1] = 0.40211209123895013807243250164050E-50; weight[ 76-1] = 0.12799824394111125389430292847476E-51; weight[ 77-1] = 0.38123877747548846504399051365162E-53; weight[ 78-1] = 0.10612057542701156767898551949650E-54; weight[ 79-1] = 0.27571446947200403594113572720812E-56; weight[ 80-1] = 0.66772544240928492881306904862856E-58; weight[ 81-1] = 0.15052438383868234954068178600268E-59; weight[ 82-1] = 0.31538986800113758526689068500772E-61; weight[ 83-1] = 0.61326614299483180785237418887960E-63; weight[ 84-1] = 0.11048510030324810567549119229368E-64; weight[ 85-1] = 0.18410563538091348076979665543900E-66; weight[ 86-1] = 0.28323926570052832195543883237652E-68; weight[ 87-1] = 0.40154409843763655508670978777418E-70; weight[ 88-1] = 0.52351530215683708779772201956106E-72; weight[ 89-1] = 0.62634476665005100555787696642851E-74; weight[ 90-1] = 0.68612210535666530365348093803922E-76; weight[ 91-1] = 0.68651298840956019297134099761855E-78; weight[ 92-1] = 0.62581388433728084867318704240915E-80; weight[ 93-1] = 0.51833271237514904046803469968027E-82; weight[ 94-1] = 0.38893621571918443533108973497673E-84; weight[ 95-1] = 0.26357711379476932781525533730623E-86; weight[ 96-1] = 0.16078851293917979699005509638883E-88; weight[ 97-1] = 0.87978042070968939637972577886624E-91; weight[ 98-1] = 0.43013405077495109903408697802188E-93; weight[ 99-1] = 0.18713435881342838527144321803729E-95; weight[100-1] = 0.72125744708060471675805761366523E-98; weight[101-1] = 0.24508746062177874383231742333023E-100; weight[102-1] = 0.73042094619470875777647865078327E-103; weight[103-1] = 0.18983290818383463537886818579820E-105; weight[104-1] = 0.42757400244246684123093264825902E-108; weight[105-1] = 0.82894681420515755691423485228897E-111; weight[106-1] = 0.13729432219324400013067050156048E-113; weight[107-1] = 0.19265464126404973222043166489406E-116; weight[108-1] = 0.22693344503301354826140809941334E-119; weight[109-1] = 0.22209290603717355061909071271535E-122; weight[110-1] = 0.17851087685544512662856555121755E-125; weight[111-1] = 0.11630931990387164467431190485525E-128; weight[112-1] = 0.60524443584652392290952805077893E-132; weight[113-1] = 0.24729569115063528647628375096400E-135; weight[114-1] = 0.77789065006489410364997205809045E-139; weight[115-1] = 0.18409738662712607039570678274636E-142; weight[116-1] = 0.31900921131079114970179071968597E-146; weight[117-1] = 0.39179487139174199737617666077555E-150; weight[118-1] = 0.32782158394188697053774429820559E-154; weight[119-1] = 0.17793590713138888062819640128739E-158; weight[120-1] = 0.58882353408932623157467835381214E-163; weight[121-1] = 0.10957236509071169877747203273886E-167; weight[122-1] = 0.10281621114867000898285076975760E-172; weight[123-1] = 0.41704725557697758145816510853967E-178; weight[124-1] = 0.58002877720316101774638319601971E-184; weight[125-1] = 0.18873507745825517106171619101120E-190; weight[126-1] = 0.69106601826730911682786705950895E-198; weight[127-1] = 0.43506813201105855628383313334402E-207; } else { cout << "\n"; cout << "LAGUERRE_WEIGHTS - Fatal error!\n"; cout << " Illegal value of ORDER = " << order << "\n"; cout << " Legal values are 1, 3, 7, 15, 31, 63 and 127.\n"; exit ( 1 ); } return; } //****************************************************************************80 void level_to_order_open ( int dim_num, int level[], int order[] ) //****************************************************************************80 // // Purpose: // // LEVEL_TO_ORDER_OPEN converts a level to an order for open rules. // // Discussion: // // Sparse grids can naturally be nested. A natural scheme is to use // a series of one-dimensional rules arranged in a series of "levels" // whose order roughly doubles with each step. // // The arrangement described here works naturally for the Fejer Type 1, // Fejer Type 2, Newton Cotes Open, Newton Cotes Half Open, // and Gauss-Patterson rules. It also can be used, partially, to describe // the growth of Gauss-Legendre and Gauss-Hermite rules. // // The idea is that we start with LEVEL = 0, ORDER = 1 indicating the single // point at the center, and for all values afterwards, we use the // relationship // // ORDER = 2**(LEVEL+1) - 1. // // The following table shows how the growth will occur: // // Level Order // // 0 1 // 1 3 = 4 - 1 // 2 7 = 8 - 1 // 3 15 = 16 - 1 // 4 31 = 32 - 1 // 5 63 = 64 - 1 // // For the Fejer Type 1, Fejer Type 2, Newton Cotes Open, // Newton Cotes Open Half, and Gauss-Patterson rules, the point growth is // nested. If we have ORDER points on a particular LEVEL, the next level // includes all these old points, plus ORDER+1 new points, formed in the // gaps between successive pairs of old points plus an extra point at each // end. // // Level Order = New + Old // // 0 1 = 1 + 0 // 1 3 = 2 + 1 // 2 7 = 4 + 3 // 3 15 = 8 + 7 // 4 31 = 16 + 15 // 5 63 = 32 + 31 // // If we use a series of Gauss-Legendre or Gauss-Hermite rules, then there // is almost no nesting, except that the central point is shared. If we // insist on producing a comparable series of such points, then the // "nesting" behavior is as follows: // // Level Order = New + Old // // 0 1 = 1 + 0 // 1 3 = 2 + 1 // 2 7 = 6 + 1 // 3 15 = 14 + 1 // 4 31 = 30 + 1 // 5 63 = 62 + 1 // // Moreover, if we consider ALL the points used in such a set of "nested" // Gauss-Legendre or Gauss-Hermite rules, then we must sum the "NEW" column, // and we see that we get roughly twice as many points as for the truly // nested rules. // // In this routine, we assume that a vector of levels is given, // and the corresponding orders are desired. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 19 April 2007 // // Author: // // John Burkardt // // Reference: // // Fabio Nobile, Raul Tempone, Clayton Webster, // A Sparse Grid Stochastic Collocation Method for Partial Differential // Equations with Random Input Data, // SIAM Journal on Numerical Analysis, // Volume 46, Number 5, 2008, pages 2309-2345. // // Parameters: // // Input, int DIM_NUM, the spatial dimension. // // Input, int LEVEL[DIM_NUM], the nesting level. // // Output, int ORDER[DIM_NUM], the order (number of points) // of the rule. // { int dim; for ( dim = 0; dim < dim_num; dim++ ) { if ( level[dim] < 0 ) { order[dim] = -1; } else if ( level[dim] == 0 ) { order[dim] = 1; } else { order[dim] = i4_power ( 2, level[dim] + 1 ) - 1 ; } } return; } //****************************************************************************80 int *multigrid_index_one ( int dim_num, int order_1d[], int order_nd ) //****************************************************************************80 // // Purpose: // // MULTIGRID_INDEX_ONE returns an indexed multidimensional grid. // // Discussion: // // For dimension DIM, the number of points is M (the order of the 1D rule). // // We index the points as: // 1, 2, 3, ..., M. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 10 October 2007 // // Author: // // John Burkardt // // Reference: // // Fabio Nobile, Raul Tempone, Clayton Webster, // A Sparse Grid Stochastic Collocation Method for Partial Differential // Equations with Random Input Data, // SIAM Journal on Numerical Analysis, // Volume 46, Number 5, 2008, pages 2309-2345. // // Parameters: // // Input, int DIM_NUM, the spatial dimension of the points. // // Input, int ORDER_1D[DIM_NUM], the order of the // rule in each dimension. // // Input, int ORDER_ND, the product of the entries of ORDER_1D. // // Output, int INDX[DIM_NUM*ORDER_ND], the indices of the points in // the grid. The second dimension of this array is equal to the // product of the entries of ORDER_1D. // { int *a; int dim; bool more; int p; int *indx; indx = new int[dim_num*order_nd]; a = new int[dim_num]; more = false; p = 0; for ( ; ; ) { vec_colex_next2 ( dim_num, order_1d, a, &more ); if ( !more ) { break; } // // The values of A(DIM) are between 0 and ORDER_1D(DIM)-1 = N - 1 = 2 * M. // Subtracting M sets the range to -M to +M, as we wish. // for ( dim = 0; dim < dim_num; dim++ ) { indx[dim+p*dim_num] = a[dim] + 1; } p = p + 1; } delete [] a; return indx; } //****************************************************************************80 double *product_weight_laguerre ( int dim_num, int order_1d[], int order_nd ) //****************************************************************************80 // // Purpose: // // PRODUCT_WEIGHT_LAGUERRE: weights for a product Gauss-Laguerre rule. // // Discussion: // // This routine computes the weights for a quadrature rule which is // a product of 1D Gauss-Laguerre rules of varying order. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 10 October 2007 // // Author: // // John Burkardt // // Parameters: // // Input, int DIM_NUM, the spatial dimension. // // Input, int ORDER_1D[DIM_NUM], the order of the 1D rules. // // Input, int ORDER_ND, the order of the product rule. // // Output, double PRODUCT_WEIGHT_HERM[ORDER_ND], the product rule weights. // { int dim; int order; double *w_1d; double *w_nd; w_nd = new double[order_nd]; for ( order = 0; order < order_nd; order++ ) { w_nd[order] = 1.0; } for ( dim = 0; dim < dim_num; dim++ ) { w_1d = new double[order_1d[dim]]; laguerre_weights ( order_1d[dim], w_1d ); r8vec_direct_product2 ( dim, order_1d[dim], w_1d, dim_num, order_nd, w_nd ); delete [] w_1d; } return w_nd; } //****************************************************************************80 double r8_epsilon ( ) //****************************************************************************80 // // Purpose: // // R8_EPSILON returns the R8 roundoff unit. // // Discussion: // // The roundoff unit is a number R which is a power of 2 with the // property that, to the precision of the computer's arithmetic, // 1 < 1 + R // but // 1 = ( 1 + R / 2 ) // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 01 September 2012 // // Author: // // John Burkardt // // Parameters: // // Output, double R8_EPSILON, the R8 round-off unit. // { const double value = 2.220446049250313E-016; return value; } //****************************************************************************80 double r8_huge ( ) //****************************************************************************80 // // Purpose: // // R8_HUGE returns a "huge" R8. // // Discussion: // // The value returned by this function is NOT required to be the // maximum representable R8. This value varies from machine to machine, // from compiler to compiler, and may cause problems when being printed. // We simply want a "very large" but non-infinite number. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 06 October 2007 // // Author: // // John Burkardt // // Parameters: // // Output, double R8_HUGE, a "huge" R8 value. // { double value; value = 1.0E+30; return value; } //****************************************************************************80 void r8mat_transpose_print_some ( int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, string title ) //****************************************************************************80 // // Purpose: // // R8MAT_TRANSPOSE_PRINT_SOME prints some of an R8MAT, transposed. // // Discussion: // // An R8MAT is a doubly dimensioned array of R8 values, stored as a vector // in column-major order. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 11 August 2004 // // Author: // // John Burkardt // // Parameters: // // Input, int M, N, the number of rows and columns. // // Input, double A[M*N], an M by N matrix to be printed. // // Input, int ILO, JLO, the first row and column to print. // // Input, int IHI, JHI, the last row and column to print. // // Input, string TITLE, an optional title. // { # define INCX 5 int i; int i2; int i2hi; int i2lo; int inc; int j; int j2hi; int j2lo; if ( 0 < s_len_trim ( title ) ) { cout << "\n"; cout << title << "\n"; } for ( i2lo = i4_max ( ilo, 1 ); i2lo <= i4_min ( ihi, m ); i2lo = i2lo + INCX ) { i2hi = i2lo + INCX - 1; i2hi = i4_min ( i2hi, m ); i2hi = i4_min ( i2hi, ihi ); inc = i2hi + 1 - i2lo; cout << "\n"; cout << " Row: "; for ( i = i2lo; i <= i2hi; i++ ) { cout << setw(7) << i << " "; } cout << "\n"; cout << " Col\n"; cout << "\n"; j2lo = i4_max ( jlo, 1 ); j2hi = i4_min ( jhi, n ); for ( j = j2lo; j <= j2hi; j++ ) { cout << setw(5) << j << " "; for ( i2 = 1; i2 <= inc; i2++ ) { i = i2lo - 1 + i2; cout << setw(14) << a[(i-1)+(j-1)*m]; } cout << "\n"; } } return; # undef INCX } //****************************************************************************80 void r8mat_write ( string output_filename, int m, int n, double table[] ) //****************************************************************************80 // // Purpose: // // R8MAT_WRITE writes an R8MAT file. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 29 June 2009 // // Author: // // John Burkardt // // Parameters: // // Input, string OUTPUT_FILENAME, the output filename. // // Input, int M, the spatial dimension. // // Input, int N, the number of points. // // Input, double TABLE[M*N], the table data. // { int i; int j; ofstream output; // // Open the file. // output.open ( output_filename.c_str ( ) ); if ( !output ) { cerr << "\n"; cerr << "R8MAT_WRITE - Fatal error!\n"; cerr << " Could not open the output file.\n"; return; } // // Write the data. // for ( j = 0; j < n; j++ ) { for ( i = 0; i < m; i++ ) { output << " " << setw(24) << setprecision(16) << table[i+j*m]; } output << "\n"; } // // Close the file. // output.close ( ); return; } //****************************************************************************80 void r8vec_direct_product2 ( int factor_index, int factor_order, double factor_value[], int factor_num, int point_num, double w[] ) //****************************************************************************80 // // Purpose: // // R8VEC_DIRECT_PRODUCT2 creates a direct product of R8VEC's. // // Discussion: // // An R8VEC is a vector of R8's. // // To explain what is going on here, suppose we had to construct // a multidimensional quadrature rule as the product of K rules // for 1D quadrature. // // The product rule will be represented as a list of points and weights. // // The J-th item in the product rule will be associated with // item J1 of 1D rule 1, // item J2 of 1D rule 2, // ..., // item JK of 1D rule K. // // In particular, // X(J) = ( X(1,J1), X(2,J2), ..., X(K,JK)) // and // W(J) = W(1,J1) * W(2,J2) * ... * W(K,JK) // // So we can construct the quadrature rule if we can properly // distribute the information in the 1D quadrature rules. // // This routine carries out that task for the weights W. // // Another way to do this would be to compute, one by one, the // set of all possible indices (J1,J2,...,JK), and then index // the appropriate information. An advantage of the method shown // here is that you can process the K-th set of information and // then discard it. // // Example: // // Rule 1: // Order = 4 // W(1:4) = ( 2, 3, 5, 7 ) // // Rule 2: // Order = 3 // W(1:3) = ( 11, 13, 17 ) // // Rule 3: // Order = 2 // W(1:2) = ( 19, 23 ) // // Product Rule: // Order = 24 // W(1:24) = // ( 2 * 11 * 19 ) // ( 3 * 11 * 19 ) // ( 4 * 11 * 19 ) // ( 7 * 11 * 19 ) // ( 2 * 13 * 19 ) // ( 3 * 13 * 19 ) // ( 5 * 13 * 19 ) // ( 7 * 13 * 19 ) // ( 2 * 17 * 19 ) // ( 3 * 17 * 19 ) // ( 5 * 17 * 19 ) // ( 7 * 17 * 19 ) // ( 2 * 11 * 23 ) // ( 3 * 11 * 23 ) // ( 5 * 11 * 23 ) // ( 7 * 11 * 23 ) // ( 2 * 13 * 23 ) // ( 3 * 13 * 23 ) // ( 5 * 13 * 23 ) // ( 7 * 13 * 23 ) // ( 2 * 17 * 23 ) // ( 3 * 17 * 23 ) // ( 5 * 17 * 23 ) // ( 7 * 17 * 23 ) // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 24 April 2009 // // Author: // // John Burkardt // // Parameters: // // Input, int FACTOR_INDEX, the index of the factor being processed. // The first factor processed must be factor 0. // // Input, int FACTOR_ORDER, the order of the factor. // // Input, double FACTOR_VALUE[FACTOR_ORDER], the factor values for // factor FACTOR_INDEX. // // Input, int FACTOR_NUM, the number of factors. // // Input, int POINT_NUM, the number of elements in the direct product. // // Input/output, double W[POINT_NUM], the elements of the // direct product, which are built up gradually. // // Local Parameters: // // Local, integer START, the first location of a block of values to set. // // Local, integer CONTIG, the number of consecutive values to set. // // Local, integer SKIP, the distance from the current value of START // to the next location of a block of values to set. // // Local, integer REP, the number of blocks of values to set. // { static int contig = 0; int i; int j; int k; static int rep = 0; static int skip = 0; int start; if ( factor_index == 0 ) { contig = 1; skip = 1; rep = point_num; for ( i = 0; i < point_num; i++ ) { w[i] = 1.0; } } rep = rep / factor_order; skip = skip * factor_order; for ( j = 0; j < factor_order; j++ ) { start = 0 + j * contig; for ( k = 1; k <= rep; k++ ) { for ( i = start; i < start + contig; i++ ) { w[i] = w[i] * factor_value[j]; } start = start + skip; } } contig = contig * factor_order; return; } //****************************************************************************80 void r8vec_print_some ( int n, double a[], int i_lo, int i_hi, string title ) //****************************************************************************80 // // Purpose: // // R8VEC_PRINT_SOME prints "some" of an R8VEC. // // Discussion: // // An R8VEC is a vector of R8's. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 16 October 2006 // // Author: // // John Burkardt // // Parameters: // // Input, int N, the number of entries of the vector. // // Input, double A[N], the vector to be printed. // // Input, integer I_LO, I_HI, the first and last indices to print. // The routine expects 1 <= I_LO <= I_HI <= N. // // Input, string TITLE, an optional title. // { int i; if ( 0 < s_len_trim ( title ) ) { cout << "\n"; cout << title << "\n"; } cout << "\n"; for ( i = i4_max ( 1, i_lo ); i <= i4_min ( n, i_hi ); i++ ) { cout << " " << setw(8) << i << " " << setw(14) << a[i-1] << "\n"; } return; } //****************************************************************************80 int s_len_trim ( string s ) //****************************************************************************80 // // Purpose: // // S_LEN_TRIM returns the length of a string to the last nonblank. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 July 2009 // // Author: // // John Burkardt // // Parameters: // // Input, string S, a string. // // Output, int S_LEN_TRIM, the length of the string to the last nonblank. // If S_LEN_TRIM is 0, then the string is entirely blank. // { int n; n = s.length ( ); while ( 0 < n ) { if ( s[n-1] != ' ' ) { return n; } n = n - 1; } return n; } //****************************************************************************80 void sparse_grid_laguerre ( int dim_num, int level_max, int point_num, double grid_weight[], double grid_point[] ) //****************************************************************************80 // // Purpose: // // SPARSE_GRID_LAGUERRE computes a sparse grid of Gauss-Laguerre points. // // Discussion: // // The quadrature rule is associated with a sparse grid derived from // a Smolyak construction using a 1D Gauss-Laguerre quadrature rule. // // The user specifies: // * the spatial dimension of the quadrature region, // * the level that defines the Smolyak grid. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 July 2008 // // Author: // // John Burkardt // // Reference: // // Fabio Nobile, Raul Tempone, Clayton Webster, // A Sparse Grid Stochastic Collocation Method for Partial Differential // Equations with Random Input Data, // SIAM Journal on Numerical Analysis, // Volume 46, Number 5, 2008, pages 2309-2345. // // Parameters: // // Input, int DIM_NUM, the spatial dimension. // // Input, int LEVEL_MAX, controls the size of the final sparse grid. // // Input, int POINT_NUM, the number of points in the grid, as determined // by SPARSE_GRID_LAGUERRE_SIZE. // // Output, double GRID_WEIGHT[POINT_NUM], the weights. // // Output, double GRID_POINT[DIM_NUM*POINT_NUM], the points. // { int coeff; int dim; int *grid_base2; int *grid_index2; double *grid_weight2; int h; int level; int *level_1d; int level_min; bool more; int *order_1d; int order_nd; int order_max; int point; int point_num2; int t; for ( point = 0; point < point_num; point++ ) { grid_weight[point] = 0.0; } // // The outer loop generates LEVELs from LEVEL_MIN to LEVEL_MAX. // point_num2 = 0; level_min = i4_max ( 0, level_max + 1 - dim_num ); grid_base2 = new int[dim_num]; level_1d = new int[dim_num]; order_1d = new int[dim_num]; for ( level = level_min; level <= level_max; level++ ) { // // The middle loop generates the next partition LEVEL_1D(1:DIM_NUM) // that adds up to LEVEL. // more = false; h = 0; t = 0; for ( ; ; ) { comp_next ( level, dim_num, level_1d, &more, &h, &t ); // // Transform each 1D level to a corresponding 1D order. // The relationship is the same as for other OPEN rules. // level_to_order_open ( dim_num, level_1d, order_1d ); for ( dim = 0; dim < dim_num; dim++ ) { grid_base2[dim] = order_1d[dim]; } // // The product of the 1D orders gives us the number of points in this grid. // order_nd = i4vec_product ( dim_num, order_1d ); // // Compute the weights for this product grid. // grid_weight2 = product_weight_laguerre ( dim_num, order_1d, order_nd ); // // Now determine the coefficient of the weight. // coeff = i4_power ( -1, level_max - level ) * choose ( dim_num - 1, level_max - level ); // // The inner (hidden) loop generates all points corresponding to given grid. // The grid indices will be between -M to +M, where 2*M + 1 = ORDER_1D(DIM). // grid_index2 = multigrid_index_one ( dim_num, order_1d, order_nd ); for ( point = 0; point < order_nd; point++ ) { laguerre_abscissa ( dim_num, 1, grid_index2+point*dim_num, grid_base2, grid_point+point_num2*dim_num ); grid_weight[point_num2] = ( double ) ( coeff ) * grid_weight2[point]; point_num2 = point_num2 + 1; } delete [] grid_index2; delete [] grid_weight2; if ( !more ) { break; } } } delete [] grid_base2; delete [] level_1d; delete [] order_1d; return; } //****************************************************************************80 void sparse_grid_laguerre_index ( int dim_num, int level_max, int point_num, int grid_index [], int grid_base[] ) //****************************************************************************80 // // Purpose: // // SPARSE_GRID_LAGUERRE_INDEX indexes points in a Gauss-Laguerre sparse grid. // // Discussion: // // The sparse grid is assumed to be formed from 1D Gauss-Laguerre rules. // // The necessary dimensions of GRID_INDEX can be determined by // calling SPARSE_GRID_LAGUERRE_SIZE first. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 July 2008 // // Author: // // John Burkardt // // Reference: // // Fabio Nobile, Raul Tempone, Clayton Webster, // A Sparse Grid Stochastic Collocation Method for Partial Differential // Equations with Random Input Data, // SIAM Journal on Numerical Analysis, // Volume 46, Number 5, 2008, pages 2309-2345. // // Parameters: // // Input, int DIM_NUM, the spatial dimension. // // Input, int LEVEL_MAX, the maximum value of LEVEL. // // Input, int POINT_NUM, the total number of points in the grids. // // Output, int GRID_INDEX[DIM_NUM*POINT_NUM], a list of // point indices, representing a subset of the product grid of level // LEVEL_MAX, representing (exactly once) each point that will show up in a // sparse grid of level LEVEL_MAX. // // Output, int GRID_BASE[DIM_NUM*POINT_NUM], a list of // the orders of the Gauss-Laguerre rules associated with each point // and dimension. // { int dim; int factor; int *grid_base2; int *grid_index2; int h; int j; int level; int *level_1d; int level_min; bool more; int *order_1d; int order_nd; int point; int point_num2; int t; // // The outer loop generates LEVELs from LEVEL_MIN to LEVEL_MAX. // point_num2 = 0; level_min = i4_max ( 0, level_max + 1 - dim_num ); grid_base2 = new int[dim_num]; level_1d = new int[dim_num]; order_1d = new int[dim_num]; for ( level = level_min; level <= level_max; level++ ) { // // The middle loop generates the next partition LEVEL_1D(1:DIM_NUM) // that adds up to LEVEL. // more = false; h = 0; t = 0; for ( ; ; ) { comp_next ( level, dim_num, level_1d, &more, &h, &t ); // // Transform each 1D level to a corresponding 1D order. // level_to_order_open ( dim_num, level_1d, order_1d ); for ( dim = 0; dim < dim_num; dim++ ) { grid_base2[dim] = order_1d[dim]; } // // The product of the 1D orders gives us the number of points in this grid. // order_nd = i4vec_product ( dim_num, order_1d ); // // The inner (hidden) loop generates all points corresponding to given grid. // grid_index2 = multigrid_index_one ( dim_num, order_1d, order_nd ); // // Only keep those points which first appear on this level. // for ( point = 0; point < order_nd; point++ ) { for ( dim = 0; dim < dim_num; dim++ ) { grid_index[dim+point_num2*dim_num] = grid_index2[dim+point*dim_num]; grid_base[dim+point_num2*dim_num] = grid_base2[dim]; } point_num2 = point_num2 + 1; } delete [] grid_index2; if ( !more ) { break; } } } delete [] grid_base2; delete [] level_1d; delete [] order_1d; return; } //****************************************************************************80 int sparse_grid_laguerre_size ( int dim_num, int level_max ) //****************************************************************************80 // // Purpose: // // SPARSE_GRID_LAGUERRE_SIZE sizes a sparse grid of Gauss-Laguerre points. // // Discussion: // // The grid is defined as the sum of the product rules whose LEVEL // satisfies: // // LEVEL_MIN <= LEVEL <= LEVEL_MAX. // // where LEVEL_MAX is user specified, and // // LEVEL_MIN = max ( 0, LEVEL_MAX + 1 - DIM_NUM ). // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 July 2008 // // Author: // // John Burkardt // // Reference: // // Fabio Nobile, Raul Tempone, Clayton Webster, // A Sparse Grid Stochastic Collocation Method for Partial Differential // Equations with Random Input Data, // SIAM Journal on Numerical Analysis, // Volume 46, Number 5, 2008, pages 2309-2345. // // Parameters: // // Input, int DIM_NUM, the spatial dimension. // // Input, int LEVEL_MAX, the maximum value of LEVEL. // // Output, int SPARSE_GRID_LAGUERRE_SIZE, the number of points in the grid. // { int dim; int h; int level; int *level_1d; int level_min; bool more; int num; int *order_1d; int order_nd; int point_num; int t; // // Special case. // if ( level_max == 0 ) { point_num = 1; return point_num; } // // The outer loop generates LEVELs from 0 to LEVEL_MAX. // point_num = 0; level_min = i4_max ( 0, level_max + 1 - dim_num ); level_1d = new int[dim_num]; order_1d = new int[dim_num]; for ( level = level_min; level <= level_max; level++ ) { // // The middle loop generates the next partition that adds up to LEVEL. // more = false; h = 0; t = 0; for ( ; ; ) { comp_next ( level, dim_num, level_1d, &more, &h, &t ); // // Transform each 1D level to a corresponding 1D order. // level_to_order_open ( dim_num, level_1d, order_1d ); point_num = point_num + i4vec_product ( dim_num, order_1d ); if ( !more ) { break; } } } delete [] level_1d; delete [] order_1d; return point_num; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // TIMESTAMP prints the current YMDHMS date as a time stamp. // // Example: // // 31 May 2001 09:45:54 AM // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 08 July 2009 // // Author: // // John Burkardt // // Parameters: // // None // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; size_t len; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); len = std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE } //****************************************************************************80 void vec_colex_next2 ( int dim_num, int base[], int a[], bool *more ) //****************************************************************************80 // // Purpose: // // VEC_COLEX_NEXT2 generates vectors in colex order. // // Discussion: // // The vectors are produced in colexical order, starting with // // (0, 0, ...,0), // (1, 0, ...,0), // ... // (BASE(1)-1,0, ...,0) // // (0, 1, ...,0) // (1, 1, ...,0) // ... // (BASE(1)-1,1, ...,0) // // (0, 2, ...,0) // (1, 2, ...,0) // ... // (BASE(1)-1,BASE(2)-1,...,BASE(DIM_NUM)-1). // // Examples: // // DIM_NUM = 2, // BASE = { 3, 3 } // // 0 0 // 1 0 // 2 0 // 0 1 // 1 1 // 2 1 // 0 2 // 1 2 // 2 2 // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 25 May 2007 // // Author: // // John Burkardt // // Parameters: // // Input, int DIM_NUM, the spatial dimension. // // Input, int BASE[DIM_NUM], the bases to be used in each dimension. // In dimension I, entries will range from 0 to BASE[I]-1. // // Output, int A[DIM_NUM], the next vector. // // Input/output, bool *MORE. Set this variable false before // the first call. On return, MORE is TRUE if another vector has // been computed. If MORE is returned FALSE, ignore the output // vector and stop calling the routine. // { int i; if ( !( *more ) ) { for ( i = 0; i < dim_num; i++ ) { a[i] = 0; } *more = true; } else { for ( i = 0; i < dim_num; i++ ) { a[i] = a[i] + 1; if ( a[i] < base[i] ) { return; } a[i] = 0; } *more = false; } return; }
12198d5665a178aaead5cd95d54cb1d27e1f4a36
334d1e0a807ef7b235436937a02353b192e891c8
/Module/Motor_Controller/motorTreiber_V0_1/motorTreiber_V0_1.ino
8f0fba3190c2dcbf56112fc22742e117570f8547
[]
no_license
mechPrak/mechpraktikum
1ca5f12e74cef4b5ae9b381052f4792c7a87aba6
67d837b748241df974e9667696654ef63394ef43
refs/heads/master
2020-03-18T09:12:12.008421
2018-07-06T01:35:42
2018-07-06T01:35:42
134,550,297
0
0
null
null
null
null
UTF-8
C++
false
false
614
ino
#include <MultiStepper.h> #include <AccelStepper.h> #define PIN_A_M0 A0 #define PIN_A_M1 A1 #define PIN_B_M0 A2 #define PIN_B_M1 A3 #define PIN_A_STEP 2 #define PIN_A_DIR 4 #define PIN_B_STEP 7 #define PIN_B_DIR 8 #define PIN_V_meas_1 0 #define PIN_V_meas_2 0 void setup(){ pinMode(PIN_A_M0, OUTPUT); pinMode(PIN_B_M1, OUTPUT); pinMode(PIN_A_M0, OUTPUT); pinMode(PIN_B_M1, OUTPUT); pinMode(PIN_A_STEP, OUTPUT); pinMode(PIN_A_DIR, OUTPUT); pinMode(PIN_B_STEP, OUTPUT); pinMode(PIN_B_DIR, OUTPUT); pinMode(PIN_V_meas_1, INPUT; pinMode(PIN_V_meas_2, INPUT); } void loop(){ }
ea3f47799724986f4e9acf7c3f195f401353aaf7
5f88b923a10c1786ae94206f18e362436028c2d4
/src/catk/syntax.hpp
f8d9c6607e0ec2b4fa06bb4bb0a3b14896eb6e4d
[ "MIT" ]
permissive
CHChang810716/CAsterisk
664d1d4d06477b72e83a594553e6f5671fc28015
410d2afaae6cd01402a35c1889466f97e4c208bf
refs/heads/master
2023-07-23T22:54:48.794575
2021-09-05T04:58:00
2021-09-05T04:58:00
304,879,246
0
0
null
null
null
null
UTF-8
C++
false
false
65
hpp
#pragma once #include "syntax/ast.hpp" #include "syntax/expr.hpp"
c0baeb21c05395860afe9f341a9a959a8311d926
119c1dd2b61764210064511d8ab5be252b8b7c8f
/InterivewBit/02 Maths/3PalindromeNum.cpp
b9da5a9a9fb8ccec06b809d9d4f79045bef9562a
[]
no_license
jasveen18/CP-krle-placement-lag-jayegi
2557309a9dfc4feb01dbdc867a67f1ccc4f10868
8db92e5c3a7d08edfc34d8223af6c080aa3e4721
refs/heads/main
2023-07-29T09:39:36.270193
2021-09-03T15:19:22
2021-09-03T15:19:22
430,816,168
1
1
null
2021-11-22T18:10:13
2021-11-22T18:10:13
null
UTF-8
C++
false
false
654
cpp
int Solution::isPalindrome(int A) { if (A < 0) return 0; long long int dummy = A; long long int n = A; long long int start = 1; long long int end = 10; int i = 0, j = 0; // Count the power of 10 required while (dummy) { j++; start *= 10; dummy /= 10; } start /= 10; long long int startKeLie = n; long long int endKeLie = n; while (i < j) { // Last dig nikal kr /10 krdo for the next last dig. int lastDig = endKeLie % 10; endKeLie /= 10; // First dig nikal kr usko udaa do int firstDig = startKeLie / start; startKeLie %= start; start /= 10; if (firstDig != lastDig) return 0; i++; j--; } return 1; }
fb2bd3b7e68d404915b6d72394a3c71c9e67b452
70d190cf5a3296e4430c862df2a4a3b299c079fe
/RubberBrush.cpp
25a2ceea7c03a7860231091bbfafc1c09a5c4feb
[]
no_license
qixuchen/Impressionist
675874752037098979becc832789ea1d3f370bd4
199da491312a1bd02f37f45a0870d4131669f86d
refs/heads/master
2020-04-22T13:44:05.835629
2019-02-28T07:01:56
2019-02-28T07:01:56
170,419,682
1
0
null
2019-02-28T07:01:57
2019-02-13T01:34:19
C
UTF-8
C++
false
false
1,324
cpp
// // PointBrush.cpp // // The implementation of Point Brush. It is a kind of ImpBrush. All your brush implementations // will look like the file with the different GL primitive calls. // #include "impressionistDoc.h" #include "impressionistUI.h" #include "RubberBrush.h" extern float frand(); RubberBrush::RubberBrush(ImpressionistDoc* pDoc, char* name) : ImpBrush(pDoc, name) { } void RubberBrush::BrushBegin(const Point source, const Point target) { ImpressionistDoc* pDoc = GetDocument(); ImpressionistUI* dlg = pDoc->m_pUI; BrushMove(source, target); } void RubberBrush::BrushMove(const Point source, const Point target) { ImpressionistDoc* pDoc = GetDocument(); ImpressionistUI* dlg = pDoc->m_pUI; if (pDoc == NULL) { printf("PointBrush::BrushMove document is NULL\n"); return; } int size = pDoc->getSize(); //glPointSize((float)size); glBegin(GL_POINTS); SetColor(source); glVertex2d(target.x, target.y); glEnd(); } void RubberBrush::BrushEnd(const Point source, const Point target) { // do nothing so far } void RubberBrush::SetColorPixel(const Point source) { ImpressionistDoc* pDoc = GetDocument(); GLubyte color[3]; memcpy(color, pDoc->GetPaintingPixel(source), 3); glColor4f((GLfloat)color[0] / 255, (GLfloat)color[1] / 255, (GLfloat)color[2] / 255, pDoc->getAlpha()); }
ece7d77653812f9d6ca0d83dbff7aa4ae5dc4fa0
92bbe8c09f5960839ca495c0d4d9a3dce454a300
/Source/World_Constants.h
d0692a78ab836fe72df1de1844d0a0689cee91cb
[ "MIT" ]
permissive
houcy/Flappy-Bee
4ce1dcd5860bf140d2cf707eb0f33c500ab739f0
4385b426213475cc864c07674b36fa199748e65e
refs/heads/master
2021-06-14T23:10:41.410377
2017-01-26T18:04:25
2017-01-26T18:04:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
410
h
#ifndef WORLD_CONSTANTS_H_INCLUDED #define WORLD_CONSTANTS_H_INCLUDED #include "Display.h" namespace World_Constants { constexpr int GRAVITY = 100, PLAYER_X = 200, GROUND_HEIGHT = Display::HEIGHT - 100; namespace Pipe { constexpr int Y_GAP = 175; constexpr int SPEED = 800; } } #endif // WORLD_CONSTANTS_H_INCLUDED
6184ce4e5b38040275f95762b568361152493ded
4800158b187c087da93b3aecdc71daeec39d055f
/Cook.cpp
34f2039661c0cf7d3e8588a4de259e67893b1a50
[]
no_license
jihee102/restaurant-system-Cpp
9439b4ac96ac4da8a8e85d88ce5b732d7c7827b5
7f059ee66eea5f1b31c08c7c73912771a00823fd
refs/heads/master
2023-03-01T12:14:48.395057
2021-02-03T13:22:41
2021-02-03T13:22:41
335,630,145
0
0
null
null
null
null
UTF-8
C++
false
false
1,455
cpp
// // Created by jihee on 1/26/2021. // #include "Cook.h" Cook::Cook(const std::string &name, int salary) : Employee(name, salary) {} Cook::~Cook() { } void Cook::print_employee(std::ostream &out) const { Employee::print_employee(out); out << " Can prepare the following: "; out << std::endl; for(auto dish : dish_list){ dish->print_dish(out, "\t"); out <<std::endl; } } std::shared_ptr<Dish> Cook::get_dish_with_name(const std::string &name) const { for(auto dish : dish_list){ if(dish->get_name() == name){ return dish; } } return nullptr; } void Cook::add_dish(const std::string &name, double price, const std::string &category) { if(name.empty() || category.empty()|| price ==0){ throw std::runtime_error("Dish name / category / price can not be empty or 0!"); } auto existing = get_dish_with_name(name); if(existing){ throw std::runtime_error("Dish with the name "+ name +" is already existing!"); } auto dish = std::make_shared<Dish>(name, price, category); dish_list.push_back(dish); } std::shared_ptr<Dish> Cook::get_most_expensive_dish() const { double price = 0; std::shared_ptr<Dish> expensive; for( auto dish : dish_list){ if(dish->get_price() > price){ price = dish->get_price(); expensive = dish; } } return price >0 ? expensive : nullptr; }
b1cecfa0bb91636216dbdf8a42e384db8a21f066
56d6d08854b73ece0c7d69f1ab838e7a9e2801b8
/refs/bcif/main.cpp
560e0f2274134054dbab7e2e4a2d3f4ea4ecd71b
[ "BSD-3-Clause" ]
permissive
catid/gcif
f7d653ec2cab29322ecb9c130f61278197c9a1c7
75a35b28e8d1cae4606aa409a745005335295a8c
refs/heads/master
2021-01-14T14:07:39.718825
2020-01-22T23:10:38
2020-01-22T23:10:38
18,389,223
6
0
null
null
null
null
UTF-8
C++
false
false
5,159
cpp
/* * main.cpp * * Created by Stefano Brocchi and Gabriele Nencini * Version 1.0 beta * License: GPL * Website: http://www.researchandtechnology.net/bcif/ */ #include <stdlib.h> #include <string.h> #include <iostream> #include <fstream> #include <string> #include <math.h> #include <vector> #include <sstream> using namespace std; #ifdef WIN32 #include <stdio.h> #include <sys/time.h> #else #ifdef UNIX #include <unistd.h> #include <sys/time.h> #include <sys/times.h> #include <sys/types.h> #endif #endif #include <dirent.h> #include "newBitReader.h" #include "bmpWriter.h" #include "fileBmpWriter.h" #include "binaryWrite.h" #include "HTree.h" #include "huffmanReader.h" #include "zeroHuffmanReader.h" #include "oneValHuffmanReader.h" #include "standardHuffmanReader.h" #include "HTreeReaderGestor.h" #include "newFilterGestor.h" #include "HTreeWriterGestor.h" #include "readHeader.h" #include "bitMatrix.h" #include "byteMatrix.h" #include "costEvaluator.h" #include "BmpImage.h" #include "bcif.h" static void printBcifIntro(bcif *b) { printf("\n"); printf(" BCIF lossless image compression algorithm version %d.%d", b->version, b->subVersion); if (b->beta == 0) { printf("\n"); } if (b->beta == 1) { printf(" beta.\n"); } if (b->beta == 2) { printf(" alpha.\n"); } if (b->beta > 2) { printf(" unstable pre-alpha, level %d. \n", b->beta); } printf(" By Stefano Brocchi ([email protected]) \n"); printf(" Website: www.researchandtechnology.net/bcif/ \n\n"); } void displayBcifHelp() { printf("BCIF syntax: \n \n"); printf(" bcif inputfile [-c|-d] [outputfile] [-h]\n\n"); printf("Parameters: \n\n"); printf("-c : Compress (BMP -> BCIF)\n"); printf("-d : Decompress (BCIF -> BMP)\n"); printf("-h : Print help information\n"); printf("inputfile : The file to be compressed or decompressed\n"); printf("outputfile : The destination file. If not specified, default is the same \n"); printf(" filename of inputfile with an appropriate extension. If already \n"); printf(" existing, the outputfile is overwritten without prompting.\n\n"); } int exeParams(int argc, char **args, bcif *encoder) { char *sourceFile = NULL; char *destFile = NULL; string errString = ""; bool ok = true; bool help = false; bool compress = false; bool actionDef = false; bool decompress = false; bool hashCode = false; for (int i = 1; i < argc; i++) { char *cur = args[i]; if (cur[0] != '-') { if (sourceFile == NULL) { sourceFile = cur; } else if (destFile == NULL) { destFile = cur; } else { ok = false; errString.append("Unrecognized parameter, or extra filename: "); errString.append(cur); errString.append(" \n"); } } else { cur++; if (cur[0] == 'c' && cur[1] == (char)0) { if (actionDef) { ok = false; errString.append("Select only one of the options -c (compress) or -d (decompress).\n"); } compress = true; actionDef = true; } else if (cur[0] == 'd' && cur[1] == (char)0) { if (actionDef) { ok = false; errString.append("Select only one of the options -c (compress) or -d (decompress).\n"); } decompress = true; actionDef = true; } else if (cur[0] == 'h' && cur[1] == 'c' && cur[2] == (char)0) { // Not implemented hashCode = true; } else if (cur[0] == 'h' && cur[1] == (char)0) { help = true; } else if (cur[0] == 'v' && cur[1] == (char)0) { encoder->setVerbose(1); } else { ok = false; errString.append("Unrecognized option: "); errString.append(cur); errString.append(" \n"); printf("None\n"); } } } if (sourceFile == NULL && help == false) { ok = false; errString.append("No source file specified ! Use -h for help \n"); } if (actionDef == false && help == false) { ok = false; errString.append("No action specified ! \n"); errString.append("Specify -c (compress, BMP -> BCIF) \n"); errString.append(" or -d (decompress, BCIF -> BMP)\n"); errString.append(" or -h for help \n"); } if (! ok) { printf("%s", errString.c_str()); return 1; } else { if (help) { displayBcifHelp(); return 0; } else { if (compress) { if (destFile != NULL) { encoder->compress(*(new string(sourceFile)), *(new string(destFile))); } else { encoder->compress(*(new string(sourceFile))); } } else if (decompress) { if (destFile != NULL) { encoder->decompress(*(new string(sourceFile)), *(new string(destFile))); } else { encoder->decompress(*(new string(sourceFile))); } } return 0; } } } int main (int argc, char **argv) { bcif encoder; printBcifIntro(&encoder); return exeParams(argc, argv, &encoder); }
be9b0b871c434f7f6518619a00c3305cc4dfb811
f671f091b5614e61fe8835592b94b50b619c46d5
/Source/Core/SVTPageEncoding.cpp
cec2599ffe9959adabf1a044cf5bb08b2b2ab784
[]
no_license
jaschmid/HAGE
2c5b77b54a7cffb720f54cf762a85deb6fe2da3a
18f0552975ad05646398d54dc8e00b8f2ff04f4e
refs/heads/master
2020-05-26T01:36:29.676111
2011-05-29T21:44:01
2011-05-29T21:44:01
525,847
1
0
null
null
null
null
UTF-8
C++
false
false
13,145
cpp
#include <HAGE.h> #include <stdio.h> #include "SVTPageEncoding.h" namespace HAGE { ISVTDataLayer* ISVTDataLayer::CreateLayer(u32 encodingId) { switch(encodingId) { case LAYER_ENCODING_UNCOMPRESSED_RAW: return new SVTDataLayer_Raw; case LAYER_ENCODING_PNGISH_RAW: return new SVTDataLayer_PNGish; case LAYER_ENCODING_JPEG_XR_RAW: return new SVTDataLayer_JpegXR; case LAYER_ENCODING_COMPOSITE: case LAYER_ENCODING_BLENDED: default: assert(!"non supported encoding"); return nullptr; } } bool SVTDataLayer_Raw::GetImageData(const Vector2<u32>& offset,u32 LayerId,ImageRect<R8G8B8A8>& dataOut) const { assert( offset.x + dataOut.XSize() <= _size.x); assert( offset.y + dataOut.YSize() <= _size.y); if(_imageData) dataOut.CopyFrom(_imageData->GetRect(Vector4<u32>(offset.x,offset.y,offset.x + dataOut.XSize(),offset.y + dataOut.YSize()))); else for(u32 y = 0; y < dataOut.YSize(); ++y) for(u32 x = 0; x < dataOut.XSize(); ++x) dataOut( x, y ).SetData(0); return true; } void SVTDataLayer_Raw::GenerateMipmap(const Vector2<u32>& size,const std::array<const ISVTDataLayer*,16>& parents,u32 borderSize) { reset(); u32 outerPageSize = size.x; assert(size.x == size.y); _size = size; ImageData<R8G8B8A8> largeData(outerPageSize*2, outerPageSize*2); const u32 r[4] = {outerPageSize - 3*borderSize, borderSize, borderSize, borderSize}; const u32 s[4] = {2*borderSize, outerPageSize - 2*borderSize, outerPageSize -2*borderSize, 2*borderSize}; const u32 w[4] = {0, 2*borderSize, outerPageSize, 2*outerPageSize-2*borderSize}; for(int y= 0; y<4;++y) for(int x= 0; x<4;++x) if(parents[y*4+x]) parents[y*4+x]->GetImageData(Vector2<u32>(r[x],r[y]),0xffffffff,largeData.GetRect(Vector4<u32>(w[x],w[y],w[x]+s[x],w[y]+s[y]))); _imageData = new ImageData<R8G8B8A8>(outerPageSize,outerPageSize); for(int y = 0; y<_size.y;++y) for(int x = 0; x<_size.x;++x) (*_imageData)(x,y) = ColorAverage( largeData(x*2+0,y*2+0), largeData(x*2+1,y*2+0), largeData(x*2+0,y*2+1), largeData(x*2+1,y*2+1)); } u32 SVTDataLayer_Raw::Deserialize(const Vector2<u32>& size,u32 numBytes,const u8* pInBytes,const ISVTSharedDataStorage* pShared) { reset(); _size = size; _imageData = new ImageData<R8G8B8A8>(_size.x,_size.y,(const Pixel<R8G8B8A8>*)pInBytes); return _imageData->GetDataSize(); } ISVTDataLayer* SVTDataLayer_Raw::WriteRect(Vector2<i32> offset,u32 layer,const ISVTDataLayer* data) { if(!_imageData) _imageData = new ImageData<R8G8B8A8>(_size.x,_size.y); Vector2<u32> sourceOffset ( (u32)std::max<i32>(-offset.x,0) , (u32)std::max<i32>(-offset.y,0) ); Vector2<u32> targetSize = data->GetSize(); data->GetImageData(sourceOffset,layer,_imageData->GetRect( Vector4<u32>( (u32)std::max<i32>(offset.x,0) , (u32)std::max<i32>(offset.y,0) ,std::min<u32>(targetSize.x+offset.x,_size.x) , std::min<u32>(targetSize.y+offset.y,_size.y))) ); return this; } Pixel<R8G8B8A8> SVTDataLayer_Raw::ColorAverage(const Pixel<R8G8B8A8>& _1,const Pixel<R8G8B8A8>& _2, const Pixel<R8G8B8A8>& _3, const Pixel<R8G8B8A8>& _4) { Pixel<R8G8B8A8> result; result.SetRed((u8)(((u32)_1.Red() + (u32)_2.Red() + (u32)_3.Red() + (u32)_4.Red() + 2)/4)); result.SetGreen((u8)(((u32)_1.Green() + (u32)_2.Green() + (u32)_3.Green() + (u32)_4.Green() + 2)/4)); result.SetBlue((u8)(((u32)_1.Blue() + (u32)_2.Blue() + (u32)_3.Blue() + (u32)_4.Blue() + 2)/4)); result.SetAlpha((u8)(((u32)_1.Alpha() + (u32)_2.Alpha() + (u32)_3.Alpha() + (u32)_4.Alpha() + 2)/4)); return result; } u32 SVTDataLayer_PNGish::Serialize(u32 maxBytes,u8* pOutBytes) const { static const Pixel<R8G8B8A8> border(0x00000000); if(!_imageData) return 0; u32 pos = 0; /* SumType redSum; memset(&redSum,0,sizeof(redSum)); SumType greenSum; memset(&greenSum,0,sizeof(greenSum)); SumType blueSum; memset(&blueSum,0,sizeof(blueSum)); */ //first row {/* filterColorSum(redSum,greenSum,blueSum,(*_imageData)(0,0),border,border,border); for(u32 x=1;x<_imageData->XSize();++x) filterColorSum(redSum,greenSum,blueSum,(*_imageData)(x,0),(*_imageData)(x-1,0),border,border); */ u8 RedFilter = 4;//getBestFilter(redSum); u8 GreenFilter = 4;//getBestFilter(greenSum); u8 BlueFilter = 4;//getBestFilter(blueSum); //pOutBytes[pos++] = 0; //pOutBytes[pos++] = RedFilter; //pOutBytes[pos++] = GreenFilter; //pOutBytes[pos++] = BlueFilter; //writePaethXFilteredPixel(pOutBytes,pos,(*_imageData)(0,0),border,border,border); writeFilteredPixel(RedFilter,GreenFilter,BlueFilter,pOutBytes,pos,(*_imageData)(0,0),border,border,border); for(u32 x=1;x<_imageData->XSize();++x) //writePaethXFilteredPixel(pOutBytes,pos,(*_imageData)(x,0),(*_imageData)(x-1,0),border,border); writeFilteredPixel(RedFilter,GreenFilter,BlueFilter,pOutBytes,pos,(*_imageData)(x,0),(*_imageData)(x-1,0),border,border); } for(u32 y=1;y<_imageData->YSize();++y) {/* memset(&redSum,0,sizeof(redSum)); memset(&greenSum,0,sizeof(greenSum)); memset(&blueSum,0,sizeof(blueSum)); filterColorSum(redSum,greenSum,blueSum,(*_imageData)(0,y),border,(*_imageData)(0,y-1),border); for(u32 x=1;x<_imageData->XSize();++x) filterColorSum(redSum,greenSum,blueSum,(*_imageData)(x,y),(*_imageData)(x-1,y),(*_imageData)(x,y-1),(*_imageData)(x-1,y-1)); */ u8 RedFilter = 4;//getBestFilter(redSum); u8 GreenFilter = 4;//getBestFilter(greenSum); u8 BlueFilter = 4;//getBestFilter(blueSum); //pOutBytes[pos++] = 0; //pOutBytes[pos++] = RedFilter; //pOutBytes[pos++] = GreenFilter; //pOutBytes[pos++] = BlueFilter; //writePaethXFilteredPixel(pOutBytes,pos,(*_imageData)(0,y),border,(*_imageData)(0,y-1),border); writeFilteredPixel(RedFilter,GreenFilter,BlueFilter,pOutBytes,pos,(*_imageData)(0,y),border,(*_imageData)(0,y-1),border); for(u32 x=1;x<_imageData->XSize();++x) //writePaethXFilteredPixel(pOutBytes,pos,(*_imageData)(x,y),(*_imageData)(x-1,y),(*_imageData)(x,y-1),(*_imageData)(x-1,y-1)); writeFilteredPixel(RedFilter,GreenFilter,BlueFilter,pOutBytes,pos,(*_imageData)(x,y),(*_imageData)(x-1,y),(*_imageData)(x,y-1),(*_imageData)(x-1,y-1)); } //debug /* { assert(pos == 3*(_size.x+1)*_size.y); u32 t_pos = 0; { u8 RedFilter = pOutBytes[t_pos++]; u8 GreenFilter = pOutBytes[t_pos++]; u8 BlueFilter = pOutBytes[t_pos++]; assert( (*_imageData)(0,0) == readFilteredPixel(RedFilter,GreenFilter,BlueFilter,pOutBytes,t_pos,border,border,border) ); for(u32 x=1;x<_imageData->XSize();++x) assert( (*_imageData)(x,0) == readFilteredPixel(RedFilter,GreenFilter,BlueFilter,pOutBytes,t_pos,(*_imageData)(x-1,0),border,border) ); } for(u32 y=1;y<_imageData->YSize();++y) { u8 RedFilter = pOutBytes[t_pos++]; u8 GreenFilter = pOutBytes[t_pos++]; u8 BlueFilter = pOutBytes[t_pos++]; assert( (*_imageData)(0,y) == readFilteredPixel(RedFilter,GreenFilter,BlueFilter,pOutBytes,t_pos,border,(*_imageData)(0,y-1),border) ); for(u32 x=1;x<_imageData->XSize();++x) assert( (*_imageData)(x,y) == readFilteredPixel(RedFilter,GreenFilter,BlueFilter,pOutBytes,t_pos,(*_imageData)(x-1,y),(*_imageData)(x,y-1),(*_imageData)(x-1,y-1)) ); } assert(pos == t_pos); }*/ return pos; } u32 SVTDataLayer_PNGish::Deserialize(const Vector2<u32>& size,u32 numBytes,const u8* pInBytes,const ISVTSharedDataStorage* pShared) { static const Pixel<R8G8B8A8> border(0x00000000); reset(); _size = size; _imageData = new ImageData<R8G8B8A8>(_size.x,_size.y); assert(numBytes == 3*(_size.x)*_size.y); u32 pos = 0; { //pos++; u8 RedFilter = 4;//pInBytes[pos++]; u8 GreenFilter = 4;//pInBytes[pos++]; u8 BlueFilter = 4;//pInBytes[pos++]; (*_imageData)(0,0) = readFilteredPixel(RedFilter,GreenFilter,BlueFilter,pInBytes,pos,border,border,border); for(u32 x=1;x<_imageData->XSize();++x) (*_imageData)(x,0) = readFilteredPixel(RedFilter,GreenFilter,BlueFilter,pInBytes,pos,(*_imageData)(x-1,0),border,border); } for(u32 y=1;y<_imageData->YSize();++y) { //pos++; u8 RedFilter = 4;//pInBytes[pos++]; u8 GreenFilter = 4;//pInBytes[pos++]; u8 BlueFilter = 4;//pInBytes[pos++]; (*_imageData)(0,y) = readFilteredPixel(RedFilter,GreenFilter,BlueFilter,pInBytes,pos,border,(*_imageData)(0,y-1),border); for(u32 x=1;x<_imageData->XSize();++x) (*_imageData)(x,y) = readFilteredPixel(RedFilter,GreenFilter,BlueFilter,pInBytes,pos,(*_imageData)(x-1,y),(*_imageData)(x,y-1),(*_imageData)(x-1,y-1)); } assert(pos == numBytes); return pos; } void SVTDataLayer_PNGish::filterColorSum(SumType& red,SumType& green,SumType& blue,const Pixel<R8G8B8A8>& current,const Pixel<R8G8B8A8>& left,const Pixel<R8G8B8A8>& top,const Pixel<R8G8B8A8>& topleft) { filterSum(red,current.Red(),left.Red(),top.Red(),topleft.Red()); filterSum(green,current.Green(),left.Green(),top.Green(),topleft.Green()); filterSum(blue,current.Blue(),left.Blue(),top.Blue(),topleft.Blue()); } void SVTDataLayer_PNGish::writeFilteredPixel(u8 redFilter,u8 greenFilter,u8 blueFilter,u8* pOut,u32& pos,const Pixel<R8G8B8A8>& current,const Pixel<R8G8B8A8>& left,const Pixel<R8G8B8A8>& top,const Pixel<R8G8B8A8>& topleft) { //pOut[pos++] = 0; pOut[pos++] = filterByte(redFilter,current.Red(),left.Red(),top.Red(),topleft.Red()); pOut[pos++] = filterByte(greenFilter,current.Green(),left.Green(),top.Green(),topleft.Green()); pOut[pos++] = filterByte(blueFilter,current.Blue(),left.Blue(),top.Blue(),topleft.Blue()); /* assert( unfilterByte(redFilter,pOut[pos-3],left.Red(),top.Red(),topleft.Red()) == current.Red() ); assert( unfilterByte(greenFilter,pOut[pos-2],left.Green(),top.Green(),topleft.Green()) == current.Green() ); assert( unfilterByte(blueFilter,pOut[pos-1],left.Blue(),top.Blue(),topleft.Blue()) == current.Blue() );*/ } Pixel<R8G8B8A8> SVTDataLayer_PNGish::readFilteredPixel(u8 redFilter,u8 greenFilter,u8 blueFilter,const u8* pIn,u32& pos,const Pixel<R8G8B8A8>& left,const Pixel<R8G8B8A8>& top,const Pixel<R8G8B8A8>& topleft) { Pixel<R8G8B8A8> result; result.SetAlpha(0xff); //pos++; result.SetRed(unfilterByte(redFilter,pIn[pos++],left.Red(),top.Red(),topleft.Red())); result.SetGreen(unfilterByte(greenFilter,pIn[pos++],left.Green(),top.Green(),topleft.Green())); result.SetBlue(unfilterByte(blueFilter,pIn[pos++],left.Blue(),top.Blue(),topleft.Blue())); return result; } void SVTDataLayer_PNGish::filterSum(SumType& sum,u8 current,u8 left,u8 top,u8 top_left) { for(int i = 0; i < numFilterMethods; ++i) sum[i] += predDiff(i,current,left,top,top_left); } u8 SVTDataLayer_PNGish::getBestFilter(const SumType& sums) {/* static std::array<u32,numFilterMethods> bestFilters = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0}; static u32 count = 0; */ u32 min = sums[0]; u8 best = 0; for(int i = 1; i < numFilterMethods; ++i) if(sums[i] < min) { min = sums[i]; best = i; }/* bestFilters[best] ++; ++count; if(count%10000 == 0) { printf("Filter statistics:\n"); for(int i = 0; i < numFilterMethods; ++i) printf("\tFilter %i - %u uses\n",i,bestFilters[i]); }*/ return best; } u8 SVTDataLayer_PNGish::getPaeth(u8 left,u8 top,u8 top_left) { i32 p = (i32)left + (i32) top - (i32) top_left; u32 d_l = std::abs((i32)left - p); u32 d_t = std::abs((i32)top - p); u32 d_tl = std::abs((i32)top_left - p); if( d_l < d_t && d_l < d_tl ) return left; else if( d_t < d_tl ) return top; else return top_left; } u8 SVTDataLayer_PNGish::getPaethX(i32 left,i32 top,i32 top_left) { if(top_left > std::max(top,left)) return std::min(top,left); else if(top_left < std::min(top,left)) return std::max(top,left); else return top+left-top_left; } u8 SVTDataLayer_PNGish::predict(u8 method,u8 left,u8 top,u8 top_left) { i32 avg = (((i32)top + (i32)left) /2); i32 grad = ((i32)top + (i32)left - (i32)top_left); switch(method) {/* case 0: return 0x00; case 1: return left; case 2: return top; case 3: return getPaeth(left,top,top_left);*/ case 4: return getPaethX(left,top,top_left); /*case 5: return avg; case 6: return ((grad>>2) + ((avg*3)>>2)); case 7: return ((grad>>1) + (avg>>1)); case 8: return ((avg>>2) + ((grad*3)>>2)); case 9: return grad;*/ default: assert(!"Unknown filter method for PNGish layer"); return 0xff; } } u8 SVTDataLayer_PNGish::filterByte(u8 method,u8 current,u8 left,u8 top,u8 top_left) { return current - predict(method,left,top,top_left); } u8 SVTDataLayer_PNGish::unfilterByte(u8 method,u8 current,u8 left,u8 top,u8 top_left) { return current + predict(method,left,top,top_left); } u32 SVTDataLayer_PNGish::predDiff(u8 method,u8 current,u8 left,u8 top,u8 top_left) { u8 pred = predict(method,left,top,top_left); u8 diff = current - pred; if( diff > 128 ) return 255 - diff; else return diff; //return (u32)std::abs((i32)current - (i32)predict(method,left,top,top_left)); } }
56035a39f287720544101756e4d9a54631e195fe
798b409c2262078dfe770960586160fc47434fae
/sandbox/sb_lua_io.cpp
d92841fa35729f4727f267cd1ac35d743049acd9
[]
no_license
andryblack/sandbox
b53fe7b148901442d24d2bcfc411ddce531b7664
6fcffae0e00ecf31052c98d2437dbed242509438
refs/heads/master
2021-01-25T15:52:16.330633
2019-08-26T09:24:00
2019-08-26T09:24:00
2,220,342
5
8
null
2018-06-18T15:41:44
2011-08-17T07:10:54
C++
UTF-8
C++
false
false
10,423
cpp
/* * sb_lua_io.cpp * Copyright 2016 andryblack. All rights reserved. * */ #include "sb_lua.h" extern "C" { #include <lua/lua.h> #include <lua/lauxlib.h> #include <lua/lualib.h> } #include <ghl_types.h> #include <ghl_data_stream.h> #include "sb_file_provider.h" namespace Sandbox { struct FileHandle { GHL::DataStream* ds; }; static int lua_io_readline (lua_State *L); static void lua_aux_lines (lua_State *L, int toclose) { int i; int n = lua_gettop(L) - 1; /* number of arguments to read */ /* ensure that arguments will fit here and into 'io_readline' stack */ luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options"); lua_pushvalue(L, 1); /* file handle */ lua_pushinteger(L, n); /* number of arguments to read */ lua_pushboolean(L, toclose); /* close/not close file when finished */ for (i = 1; i <= n; i++) lua_pushvalue(L, i + 1); /* copy arguments */ lua_pushcclosure(L, lua_io_readline, 3 + n); } static FileHandle* lua_io_openfile(lua_State*L) { const char *filename = luaL_checkstring(L, 1); //const char *mode = luaL_optstring(L, 2, "r"); FileProvider* provider = reinterpret_cast<FileProvider*>(lua_touserdata(L, lua_upvalueindex(1))); GHL::DataStream* ds = provider->OpenFile(filename); if (!ds) { return 0; } FileHandle* handle = (FileHandle*)lua_newuserdata(L, sizeof(FileHandle)); handle->ds = ds; luaL_setmetatable(L, LUA_FILEHANDLE); return handle; } static int lua_io_open(lua_State* L) { FileHandle* handle = lua_io_openfile(L); if (!handle) { lua_pushboolean(L, 0); lua_pushstring(L, luaL_checkstring(L, 1)); return 2; } return 1; } static int lua_io_f_lines (lua_State *L) { (luaL_checkudata(L, 1, LUA_FILEHANDLE)); /* check that it's a valid file handle */ lua_aux_lines(L, 0); return 1; } static int lua_io_lines (lua_State *L) { int toclose = 0; if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */ if (lua_isnil(L, 1)) { /* no file name? */ luaL_argerror(L, 1, "need file"); } else { /* open a new file */ if (!lua_io_openfile(L)) { luaL_argerror(L, 1, luaL_checkstring(L, 1)); } lua_replace(L, 1); /* put file at index 1 */ toclose = 1; /* close it after iteration */ } lua_aux_lines(L, toclose); return 1; } static int lua_io_close(lua_State* L) { FileHandle* handle = ((FileHandle *)luaL_checkudata(L, 1, LUA_FILEHANDLE)); if (handle->ds) { handle->ds->Release(); handle->ds = 0; } return 0; } #define MAX_SIZE_T (~(size_t)0) static void read_all (lua_State *L, GHL::DataStream *f) { size_t rlen = LUAL_BUFFERSIZE; /* how much to read in each cycle */ luaL_Buffer b; luaL_buffinit(L, &b); for (;;) { char *p = luaL_prepbuffsize(&b, rlen); size_t nr = f->Read(reinterpret_cast<GHL::Byte*>(p), static_cast<GHL::UInt32>(rlen)); luaL_addsize(&b, nr); if (nr < rlen) break; /* eof? */ else if (rlen <= (MAX_SIZE_T / 4)) /* avoid buffers too large */ rlen *= 2; /* double buffer size at each iteration */ } luaL_pushresult(&b); /* close buffer */ } static int read_chars (lua_State *L, GHL::DataStream *f, size_t n) { size_t nr; /* number of chars actually read */ char *p; luaL_Buffer b; luaL_buffinit(L, &b); p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */ nr = f->Read(reinterpret_cast<GHL::Byte*>(p), static_cast<GHL::UInt32>(n)); /* try to read 'n' chars */ luaL_addsize(&b, nr); luaL_pushresult(&b); /* close buffer */ return (nr > 0); /* true iff read something */ } static bool get_string(GHL::DataStream *f,void* p,size_t max_size) { bool res = false; GHL::Byte* buf = static_cast<GHL::Byte*>(p); --max_size; while (!f->Eof() && max_size) { if (f->Read(buf, 1)!=1) { *buf = 0; return res; } res = true; if (*buf == '\n') { ++buf; break; } ++buf; --max_size; } *buf = 0; return res; } static int lua_io_read_line (lua_State *L, GHL::DataStream *f, int chop) { luaL_Buffer b; luaL_buffinit(L, &b); for (;;) { size_t l; char *p = luaL_prepbuffer(&b); if (!get_string(f, p, LUAL_BUFFERSIZE)) { /* eof? */ luaL_pushresult(&b); /* close buffer */ return (lua_rawlen(L, -1) > 0); /* check whether read something */ } l = strlen(p); if (l == 0 || p[l-1] != '\n') luaL_addsize(&b, l); else { luaL_addsize(&b, l - chop); /* chop 'eol' if needed */ luaL_pushresult(&b); /* close buffer */ return 1; /* read at least an `eol' */ } } } static int lua_io_g_read (lua_State *L, GHL::DataStream *f, int first) { int nargs = lua_gettop(L) - 1; int success; int n; if (nargs == 0) { /* no arguments? */ success = lua_io_read_line(L, f, 1); n = first+1; /* to return 1 result */ } else { /* ensure stack space for all results and for auxlib's buffer */ luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); success = 1; for (n = first; nargs-- && success; n++) { if (lua_type(L, n) == LUA_TNUMBER) { size_t l = (size_t)lua_tointeger(L, n); success = (l == 0) ? (f->Eof()) : read_chars(L, f, l); } else { const char *p = lua_tostring(L, n); luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); switch (p[1]) { case 'n': /* number */ luaL_argerror(L, n, "unsupported read numbe"); break; case 'l': /* line */ success = lua_io_read_line(L, f, 1); break; case 'L': /* line with end-of-line */ success = lua_io_read_line(L, f, 0); break; case 'a': /* file */ read_all(L, f); /* read entire file */ success = 1; /* always success */ break; default: return luaL_argerror(L, n, "invalid format"); } } } } if (!success) { lua_pop(L, 1); /* remove last result */ lua_pushnil(L); /* push nil instead */ } return n - first; } static GHL::DataStream *tofile (lua_State *L) { FileHandle* handle = ((FileHandle *)luaL_checkudata(L, 1, LUA_FILEHANDLE)); if (!handle->ds) luaL_error(L, "attempt to use a closed file"); return handle->ds; } static int lua_io_f_read (lua_State *L) { return lua_io_g_read(L, tofile(L), 2); } static int lua_io_readline (lua_State *L) { FileHandle* handle = ((FileHandle *)lua_touserdata(L, lua_upvalueindex(1))); int i; int n = (int)lua_tointeger(L, lua_upvalueindex(2)); if (!handle->ds) /* file is already closed? */ return luaL_error(L, "file is already closed"); lua_settop(L , 1); for (i = 1; i <= n; i++) /* push arguments to 'g_read' */ lua_pushvalue(L, lua_upvalueindex(3 + i)); n = lua_io_g_read(L, handle->ds, 2); /* 'n' is number of results */ lua_assert(n > 0); /* should return at least a nil */ if (!lua_isnil(L, -n)) /* read at least one value? */ return n; /* return them */ else { /* first result is nil: EOF or error */ if (n > 1) { /* is there error information? */ /* 2nd result is error message */ return luaL_error(L, "%s", lua_tostring(L, -n + 1)); } if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ lua_settop(L, 0); lua_pushvalue(L, lua_upvalueindex(1)); lua_io_close(L); /* close it */ } return 0; } } /* ** methods for file handles */ static const luaL_Reg flib[] = { {"close", lua_io_close}, //{"flush", f_flush}, {"lines", lua_io_f_lines}, {"read", lua_io_f_read}, //{"seek", f_seek}, //{"setvbuf", f_setvbuf}, //{"write", f_write}, {"__gc", lua_io_close}, //{"__tostring", f_tostring}, {NULL, NULL} }; static void createmeta (lua_State *L) { luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ lua_pushvalue(L, -1); /* push metatable */ lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ lua_pop(L, 1); /* pop new metatable */ } void lua_io_register( lua_State* L, FileProvider* provider ) { createmeta(L); lua_createtable(L, 0, 2); static const luaL_Reg io_funcs_impl[] = { {"open", lua_io_open}, {"close", lua_io_close}, {"lines", lua_io_lines}, {NULL, NULL} }; lua_pushlightuserdata(L, provider); luaL_setfuncs(L, io_funcs_impl,1); lua_setglobal(L, "io"); } }
3cc021de1fdc66032506e930b32c8ad5789ddd2f
6c78dd5a05517738c41babe14c662881fee241f4
/framework/statistic.h
fd652c1d49d6556dbd389c58f440aff6cca82a48
[]
no_license
Tocknicsu/EwnFramework
151cd4f7055b0d20371df1ba9eb194845a54ca44
437fc3b458b3bc061830bac5582c60e69d493a3f
refs/heads/master
2020-07-02T18:59:41.752687
2017-03-08T01:25:11
2017-03-08T01:25:11
74,287,957
0
1
null
2017-03-08T00:58:47
2016-11-20T16:37:40
C++
UTF-8
C++
false
false
414
h
#ifndef _STATISTIC_H_ #define _STATISTIC_H_ #include <cstdio> #include <ctime> class Statistic{ private: int GameCount; int WinPlayer[2]; int MoveCount[2]; long long MoveCost[2]; clock_t lasttime; public: Statistic(); void reset(); void print(); void increaseOneGame(); void increaseOneMove(int player, int cost); void setWinner(int player); int tick(); }; #endif
03415b2fe589aa3725fdddfd93ee5a1a300f4f64
466c29c94071c5c23b6474c9436e5e1804704c00
/covidm_for_fitting/model_v2/changes.cpp
49d1759444ac94b6e553d2156d1406b170d2605f
[]
no_license
deano1351/newcovid
cb3d284163e999a16fb3f002edbfc4f2ed4ff86b
913f97e08d5f295316887f6150d9085dc31f3bd8
refs/heads/master
2023-02-06T06:08:27.864439
2020-12-28T14:48:04
2020-12-28T14:48:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,354
cpp
// changes.cpp #include "changes.h" #include "parameters.h" #include "helper.h" #include <stdexcept> #define PVector(x) x #define PDiscrete(x) x.weights #define ParamCapture(param, get_vec) \ else if (param_name == #param) { \ if (pops.empty()) { \ for (auto& pp : P.pop) { \ param_ptr.push_back(&get_vec(pp.param)); \ param_orig.push_back(get_vec(pp.param)); \ } \ } else { \ for (auto& pi : pops) { \ if (pi >= P.pop.size()) \ throw logic_error("Referring to nonexistent population in Change::Capture."); \ param_ptr.push_back(&get_vec(P.pop[pi].param)); \ param_orig.push_back(get_vec(P.pop[pi].param)); \ } \ } \ } // Construct a change impacting parameter pname in populations po of parameters P; // apply value v with mode m at times t Change::Change(Parameters& P, vector<unsigned int>& po, vector<unsigned int>& ru, string pname, Mode m, vector<double>& t, vector<vector<double>>& v) : mode(m), times(t), values(v), param_name(pname), current(-1), pops(po), runs(ru) { if (times.size() != values.size()) throw logic_error("Change: times and values must be same length."); } // Capture parameters to change void Change::Capture(Parameters& P) { current = -1; if (false) {} ParamCapture(dE, PDiscrete) ParamCapture(dIp, PDiscrete) ParamCapture(dIa, PDiscrete) ParamCapture(dIs, PDiscrete) ParamCapture(dE2, PDiscrete) ParamCapture(contact, PVector) ParamCapture(contact_mult, PVector) ParamCapture(contact_lowerto, PVector) ParamCapture(u, PVector) ParamCapture(u2, PVector) ParamCapture(fIp, PVector) ParamCapture(fIa, PVector) ParamCapture(fIs, PVector) ParamCapture(y, PVector) ParamCapture(y2, PVector) ParamCapture(omega, PVector) ParamCapture(tau, PVector) ParamCapture(pi_r, PVector) ParamCapture(pi_r2, PVector) ParamCapture(pi2_r, PVector) ParamCapture(pi2_r2, PVector) ParamCapture(wn, PVector) ParamCapture(wn2, PVector) ParamCapture(v, PVector) ParamCapture(wv, PVector) ParamCapture(ei_v, PVector) ParamCapture(ei2_v, PVector) ParamCapture(ed_vi, PVector) ParamCapture(ed_vi2, PVector) ParamCapture(A, PVector) ParamCapture(B, PVector) ParamCapture(D, PVector) ParamCapture(season_A, PVector) ParamCapture(season_T, PVector) ParamCapture(season_phi, PVector) else if (param_name == "travel") { param_ptr.push_back(&P.travel.x); param_orig.push_back(P.travel.x); } else throw logic_error("Unsupported parameter change for " + param_name); } // Return true if parameters will change at time t bool Change::Update(double t) { bool refresh = false; while (current + 1 < (int)times.size() && t >= times[current + 1]) { ++current; refresh = true; } return refresh; } // Apply parameter changes void Change::Apply(double t) { auto op = [&](vector<double>* ptr) { if (ptr->size() == values[current].size() || values[current].empty()) { if (!values[current].empty()) { for (unsigned int j = 0; j < ptr->size(); ++j) { if (values[current][j] == -999) continue; switch (mode) { case Assign: (*ptr)[j] = values[current][j]; break; case Add: (*ptr)[j] += values[current][j]; break; case Multiply: (*ptr)[j] *= values[current][j]; break; case LowerTo: (*ptr)[j] = min((*ptr)[j], values[current][j]); break; case RaiseTo: (*ptr)[j] = max((*ptr)[j], values[current][j]); break; case Bypass: break; } } } } else { cout << current << "\n"; cout << ptr->size() << "\n"; cout << values[current].size() << "\n"; throw logic_error("Change::Apply: change value has different size from parameter."); } }; if (current >= 0) for (auto ptr : param_ptr) op(ptr); } // Reset all linked parameters to their original values void Change::Reset() { for (unsigned int i = 0; i < param_ptr.size(); ++i) *param_ptr[i] = param_orig[i]; } // Capture parameters to change void ChangeSet::Capture(Parameters& P) { for (auto& c : ch) c.Capture(P); } // Apply any needed changes void ChangeSet::Apply(Parameters& P, double t) { bool refresh = false; for (auto& c : ch) { if (c.Update(t)) { c.Reset(); refresh = true; } } if (refresh) { for (auto& c : ch) c.Apply(t); for (auto& pp : P.pop) { // TODO -- slightly wasteful; Change could keep track if linked parameter sets need refreshing; then again in most cases probably needed pp.needs_recalc = true; pp.Recalculate(); } } }
2af9c6f637a7c41aed9d5c26800fc55eab4baa93
fbfe377b5bb905ccb3373f425d109b5ed533c44b
/GeneSplicer.hpp
bedad8f54dfda1f0562b642daad326e127104966
[]
no_license
Stav-Nof/-pandemic-a
b66204aec38c85270c7cc8821fc713f739d6bf8d
3d38111a8cb7bdab27809b195b88ac70670d9847
refs/heads/master
2023-04-16T18:28:44.935884
2021-05-05T16:59:23
2021-05-05T16:59:23
364,639,097
0
0
null
null
null
null
UTF-8
C++
false
false
190
hpp
#include "Board.hpp" #include "Player.hpp" namespace pandemic{ class GeneSplicer : public Player{ public: GeneSplicer(Board& b, City city): Player(b, city){}; }; }
da0f355301e7e7249fd296f691cfda98ffd020f0
8f0024332ed057fa818c75245c93d6d5bdbd4054
/01.GameObject/05.UI/00.BasicUI/01.QuickSlot/QuickSlot.h
6f4c36dee2e8c57a47adcbad8e0dae44b95fafbf
[]
no_license
js7217/DX9_2D_TalesWeaver
44b81ddb80bf5a6b84f9afc839ab60e81817b7fe
670a7da3e384689e6e21033cc23b51f88d107120
refs/heads/master
2021-05-19T07:14:13.082978
2020-03-31T11:23:11
2020-03-31T11:23:11
251,580,782
0
0
null
null
null
null
UHC
C++
false
false
544
h
#pragma once #include "GameObject.h" class CQuickSlot : public CGameObject { public: CQuickSlot(); virtual ~CQuickSlot(); public: // CGameObject을(를) 통해 상속됨 virtual int Update() override; virtual void LateUpdate() override; virtual void Render() override; virtual void LineRender() override; private: virtual HRESULT Initialize() override; virtual void Release() override; private: void KeyCheck(); public: static HRESULT Create(); private: int m_iFrame; CKeyMgr* m_pKeyMgr; };
b25eea6e6d3c65b820bfa6a48de880783cc8aab9
d8faa77436c6620e1e66ef2a43ab9100168467de
/rts/game_CF/ai.cc
ecf753480fc563cc4f6c543f1d31f8360cf904af
[ "BSD-3-Clause" ]
permissive
zeyuan1987/ELF
7f805dedd99b6614431eb0f646d07dd920f56814
dc3eff02c240cab8312830602c6ae2f7b61b03b3
refs/heads/master
2020-12-02T07:47:48.317686
2019-12-31T01:51:38
2019-12-31T01:51:38
96,727,570
0
0
null
2017-07-10T02:26:02
2017-07-10T02:26:02
null
UTF-8
C++
false
false
1,517
cc
/** * Copyright (c) 2017-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ #include "ai.h" bool FlagTrainedAI::on_act(const GameEnv &env) { _state.resize(NUM_FLAGSTATE); std::fill (_state.begin(), _state.end(), 0); // if (_receiver == nullptr) return false; if (! NeedStructuredState(_receiver->GetTick())) { // We just use the backup AI. // cout << "Use the backup AI, tick = " << _receiver->GetTick() << endl; send_comment("BackupAI"); return _backup_ai->Act(env); } // Get the current action from the queue. int h = 0; const Reply& reply = _ai_comm->newest().reply; if (reply.global_action >= 0) { // action h = reply.global_action; } _state[h] = 1; return gather_decide(env, [&](const GameEnv &e, string*, AssignedCmds *assigned_cmds) { return _cf_rule_actor.FlagActByState(e, _state, assigned_cmds); }); } bool FlagSimpleAI::on_act(const GameEnv &env) { _state.resize(NUM_FLAGSTATE, 0); std::fill (_state.begin(), _state.end(), 0); return gather_decide(env, [&](const GameEnv &e, string*, AssignedCmds *assigned_cmds) { _cf_rule_actor.GetFlagActSimpleState(e, &_state); return _cf_rule_actor.FlagActByState(e, _state, assigned_cmds); }); }
784db19d63b70b1b83e759c51be7efa3c89a45c9
17ab783d4d0acdb43f8b4417ab79a113c604d28c
/test/enumclassobject.cpp
8e9d0371a4dc2af5de585cb2ddc9860aae791de0
[ "MIT" ]
permissive
kragmag/ponder
f95cfe3e3c7e82f02c0db3361a8fb8cdbb880e10
baa08370ed0630eb295850a653312a9fb0e1195b
refs/heads/master
2021-01-17T21:53:54.664811
2017-02-16T17:32:45
2017-02-16T17:32:45
67,532,065
0
0
null
2016-09-06T17:41:02
2016-09-06T17:41:02
null
UTF-8
C++
false
false
4,896
cpp
/**************************************************************************** ** ** This file is part of the Ponder library, formerly CAMP. ** ** The MIT License (MIT) ** ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. ** Copyright (C) 2015-2016 Billy Quith. ** ** Permission is hereby granted, free of charge, to any person obtaining a copy ** of this software and associated documentation files (the "Software"), to deal ** in the Software without restriction, including without limitation the rights ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ** copies of the Software, and to permit persons to whom the Software is ** furnished to do so, subject to the following conditions: ** ** The above copyright notice and this permission notice shall be included in ** all copies or substantial portions of the Software. ** ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ** THE SOFTWARE. ** ****************************************************************************/ #include <ponder/errors.hpp> #include <ponder/enumget.hpp> #include <ponder/enumobject.hpp> #include <ponder/enum.hpp> #include "test.hpp" namespace EnumClassObjectTest { enum class MyUndeclaredEnum { Undeclared }; enum class MyEnum { Zero = 0, One = 1, Two = 2 }; enum class MyEnum2 { Zero2 = 0, One2 = 1, Two2 = 2 }; void declare() { ponder::Enum::declare<MyEnum>("EnumClassObjectTest::MyEnum") .value("Zero", MyEnum::Zero) .value("One", MyEnum::One) .value("Two", MyEnum::Two); // same names as MyEnum ponder::Enum::declare<MyEnum2>("EnumClassObjectTest::MyEnum2") .value("Zero", MyEnum2::Zero2) .value("One", MyEnum2::One2) .value("Two", MyEnum2::Two2); } } PONDER_TYPE(EnumClassObjectTest::MyUndeclaredEnum) PONDER_AUTO_TYPE(EnumClassObjectTest::MyEnum, &EnumClassObjectTest::declare) PONDER_AUTO_TYPE(EnumClassObjectTest::MyEnum2, &EnumClassObjectTest::declare) using namespace EnumClassObjectTest; //----------------------------------------------------------------------------- // Tests for ponder::EnumObject for enum class //----------------------------------------------------------------------------- TEST_CASE("Enum class objects") { ponder::EnumObject zero(MyEnum::Zero); ponder::EnumObject one(MyEnum::One); ponder::EnumObject two(MyEnum::Two); SECTION("has names") { REQUIRE(zero.name() == "Zero"); REQUIRE(one.name() == "One"); REQUIRE(two.name() == "Two"); } SECTION("has values") { REQUIRE(zero.value<MyEnum>() == MyEnum::Zero); REQUIRE(one.value<MyEnum>() == MyEnum::One); REQUIRE(two.value<MyEnum>() == MyEnum::Two); } SECTION("wraps an Enum class type") { IS_TRUE(zero.getEnum() == ponder::enumByType<MyEnum>()); IS_TRUE(one.getEnum() == ponder::enumByType<MyEnum>()); IS_TRUE(two.getEnum() == ponder::enumByType<MyEnum>()); } SECTION("can be compared ==") { ponder::EnumObject zero2(MyEnum2::Zero2); ponder::EnumObject one2(MyEnum2::One2); ponder::EnumObject two2(MyEnum2::Two2); REQUIRE(zero == ponder::EnumObject(MyEnum::Zero)); REQUIRE(one == ponder::EnumObject(MyEnum::One)); REQUIRE(two == ponder::EnumObject(MyEnum::Two)); REQUIRE((zero == one) == false); REQUIRE((one == two) == false); REQUIRE((two == zero) == false); REQUIRE((zero == zero2) == false); // same value and name, different metaenum REQUIRE((one == one2) == false); REQUIRE((two == two2) == false); } SECTION("can be compared <") { REQUIRE((zero < zero) == false); REQUIRE(zero < one); REQUIRE(zero < two); REQUIRE((one < zero) == false); REQUIRE((one < one) == false); REQUIRE(one < two); REQUIRE((two < zero) == false); REQUIRE((two < one) == false); REQUIRE((two < two) == false); } SECTION("must be declared") { // The meta-enum of MyUndeclaredEnum is *not* declared REQUIRE_THROWS_AS(ponder::EnumObject obj(MyUndeclaredEnum::Undeclared), ponder::EnumNotFound); } }
c51c1c6a0357573f220782cbad4675f4cb3630b0
f47a5f76a5445e23b32430620f71b331d8c0c568
/lib/Navio/Common/sockets.cpp
9876f9c6f335ed566d50d2f8de6d64a86763c8dd
[ "MIT" ]
permissive
torressantiago/PINISAT
ca56f45a6597f7009c5611f98f5ef443fd175e59
21809d7a96ffd44d48d43b5ed1cfb866dcc97be5
refs/heads/main
2023-05-07T22:43:40.422609
2021-05-22T21:24:18
2021-05-22T21:24:18
344,392,275
2
0
null
null
null
null
UTF-8
C++
false
false
1,308
cpp
/** @file gps.cpp * * @brief Socket library implementation of * sockets.h * * @author Santiago Torres Borda * * @version 1.0 * */ #ifndef SOCKETS_H #include"sockets.h" #endif #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<string.h> #include<sys/types.h> #include<sys/socket.h> #include<arpa/inet.h> #include<netinet/in.h> int create(){ int sockfd; // Creating socket file descriptor if ( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) { printf("socket creation failed\n"); exit(EXIT_FAILURE); } return sockfd; } void send_float(int sock, float msg, char numTAG ,char Data, int port, char* addr){ char buffer[MAXLINE]; char message[MAXLINE]; sprintf(&message[0],"%c%c%f",numTAG,Data,msg); struct sockaddr_in servaddr; memset(&servaddr, 0, sizeof(servaddr)); // Filling server information servaddr.sin_family = AF_INET; servaddr.sin_port = htons(port); servaddr.sin_addr.s_addr = inet_addr(addr); unsigned int n, len; // Connect to server //connect(sock, (struct sockaddr*)&servaddr, sizeof(servaddr)); sendto(sock, (const char *)message, strlen(message),MSG_CONFIRM, (const struct sockaddr *) &servaddr, sizeof(servaddr)); //printf("Hello message sent.\n"); }
14245e16789646025a2bec4c22e694d6092c76ae
dd80a584130ef1a0333429ba76c1cee0eb40df73
/external/chromium_org/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc
5cbd22d53fc16aa376dd5d632b0576993cc2aa52
[ "MIT", "BSD-3-Clause" ]
permissive
karunmatharu/Android-4.4-Pay-by-Data
466f4e169ede13c5835424c78e8c30ce58f885c1
fcb778e92d4aad525ef7a995660580f948d40bc9
refs/heads/master
2021-03-24T13:33:01.721868
2017-02-18T17:48:49
2017-02-18T17:48:49
81,847,777
0
2
MIT
2020-03-09T00:02:12
2017-02-13T16:47:00
null
UTF-8
C++
false
false
10,383
cc
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/basictypes.h" #include "base/command_line.h" #if defined(OS_MACOSX) #include "base/mac/mac_util.h" #endif #include "base/strings/stringprintf.h" #include "base/test/trace_event_analyzer.h" #include "base/win/windows_version.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/extensions/features/base_feature_provider.h" #include "chrome/common/extensions/features/complex_feature.h" #include "chrome/common/extensions/features/simple_feature.h" #include "chrome/test/base/test_launcher_utils.h" #include "chrome/test/base/test_switches.h" #include "chrome/test/base/tracing.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/common/content_switches.h" #include "extensions/common/feature_switch.h" #include "extensions/common/features/feature.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/perf/perf_test.h" #include "ui/compositor/compositor_switches.h" #include "ui/gl/gl_switches.h" namespace { const char kExtensionId[] = "ddchlicdkolnonkihahngkmmmjnjlkkf"; enum TestFlags { kUseGpu = 1 << 0, // Only execute test if --enable-gpu was given // on the command line. This is required for // tests that run on GPU. kForceGpuComposited = 1 << 1, // Force the test to use the compositor. kDisableVsync = 1 << 2, // Do not limit framerate to vertical refresh. // when on GPU, nor to 60hz when not on GPU. kTestThroughWebRTC = 1 << 3, // Send captured frames through webrtc kSmallWindow = 1 << 4, // 1 = 800x600, 0 = 2000x1000 kScaleQualityMask = 3 << 5, // two bits select which scaling quality kScaleQualityDefault = 0 << 5, // to use on aura. kScaleQualityFast = 1 << 5, kScaleQualityGood = 2 << 5, kScaleQualityBest = 3 << 5, }; class TabCapturePerformanceTest : public ExtensionApiTest, public testing::WithParamInterface<int> { public: TabCapturePerformanceTest() {} bool HasFlag(TestFlags flag) const { return (GetParam() & flag) == flag; } bool IsGpuAvailable() const { return CommandLine::ForCurrentProcess()->HasSwitch("enable-gpu"); } std::string ScalingMethod() const { switch (GetParam() & kScaleQualityMask) { case kScaleQualityFast: return "fast"; case kScaleQualityGood: return "good"; case kScaleQualityBest: return "best"; default: return ""; } } std::string GetSuffixForTestFlags() { std::string suffix; if (HasFlag(kForceGpuComposited)) suffix += "_comp"; if (HasFlag(kUseGpu)) suffix += "_gpu"; if (HasFlag(kDisableVsync)) suffix += "_novsync"; if (HasFlag(kTestThroughWebRTC)) suffix += "_webrtc"; if (!ScalingMethod().empty()) suffix += "_scale" + ScalingMethod(); if (HasFlag(kSmallWindow)) suffix += "_small"; return suffix; } virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { if (!ScalingMethod().empty()) { command_line->AppendSwitchASCII(switches::kTabCaptureUpscaleQuality, ScalingMethod()); command_line->AppendSwitchASCII(switches::kTabCaptureDownscaleQuality, ScalingMethod()); } // UI tests boot up render views starting from about:blank. This causes // the renderer to start up thinking it cannot use the GPU. To work // around that, and allow the frame rate test to use the GPU, we must // pass kAllowWebUICompositing. command_line->AppendSwitch(switches::kAllowWebUICompositing); // Some of the tests may launch http requests through JSON or AJAX // which causes a security error (cross domain request) when the page // is loaded from the local file system ( file:// ). The following switch // fixes that error. command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); if (HasFlag(kSmallWindow)) { command_line->AppendSwitchASCII(switches::kWindowSize, "800,600"); } else { command_line->AppendSwitchASCII(switches::kWindowSize, "2000,1500"); } UseRealGLContexts(); if (!HasFlag(kUseGpu)) { command_line->AppendSwitch(switches::kDisableGpu); } else { command_line->AppendSwitch(switches::kForceCompositingMode); } if (HasFlag(kDisableVsync)) command_line->AppendSwitch(switches::kDisableGpuVsync); command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID, kExtensionId); ExtensionApiTest::SetUpCommandLine(command_line); } bool PrintResults(trace_analyzer::TraceAnalyzer *analyzer, const std::string& test_name, const std::string& event_name, const std::string& unit) { trace_analyzer::TraceEventVector events; trace_analyzer::Query query = trace_analyzer::Query::EventNameIs(event_name) && (trace_analyzer::Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN) || trace_analyzer::Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN) || trace_analyzer::Query::EventPhaseIs(TRACE_EVENT_PHASE_FLOW_BEGIN) || trace_analyzer::Query::EventPhaseIs(TRACE_EVENT_PHASE_INSTANT)); analyzer->FindEvents(query, &events); if (events.size() < 20) { LOG(INFO) << "Not enough events of type " << event_name << " found."; return false; } // Ignore some events for startup/setup/caching. trace_analyzer::TraceEventVector rate_events(events.begin() + 3, events.end() - 3); trace_analyzer::RateStats stats; if (!GetRateStats(rate_events, &stats, NULL)) { LOG(INFO) << "GetRateStats failed"; return false; } double mean_ms = stats.mean_us / 1000.0; double std_dev_ms = stats.standard_deviation_us / 1000.0; std::string mean_and_error = base::StringPrintf("%f,%f", mean_ms, std_dev_ms); perf_test::PrintResultMeanAndError(test_name, GetSuffixForTestFlags(), event_name, mean_and_error, unit, true); return true; } void RunTest(const std::string& test_name) { if (HasFlag(kUseGpu) && !IsGpuAvailable()) { LOG(WARNING) << "Test skipped: requires gpu. Pass --enable-gpu on the command " "line if use of GPU is desired."; return; } std::string json_events; ASSERT_TRUE(tracing::BeginTracing("test_fps,mirroring")); std::string page = "performance.html"; page += HasFlag(kTestThroughWebRTC) ? "?WebRTC=1" : "?WebRTC=0"; // Ideally we'd like to run a higher capture rate when vsync is disabled, // but libjingle currently doesn't allow that. // page += HasFlag(kDisableVsync) ? "&fps=300" : "&fps=30"; page += "&fps=30"; ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", page)) << message_; ASSERT_TRUE(tracing::EndTracing(&json_events)); scoped_ptr<trace_analyzer::TraceAnalyzer> analyzer; analyzer.reset(trace_analyzer::TraceAnalyzer::Create(json_events)); // Only one of these PrintResults should actually print something. // The printed result will be the average time between frames in the // browser window. bool sw_frames = PrintResults(analyzer.get(), test_name, "TestFrameTickSW", "frame_time"); bool gpu_frames = PrintResults(analyzer.get(), test_name, "TestFrameTickGPU", "frame_time"); EXPECT_TRUE(sw_frames || gpu_frames); EXPECT_NE(sw_frames, gpu_frames); // This prints out the average time between capture events. // As the capture frame rate is capped at 30fps, this score // cannot get any better than 33.33 ms. EXPECT_TRUE(PrintResults(analyzer.get(), test_name, "Capture", "capture_time")); } }; } // namespace IN_PROC_BROWSER_TEST_P(TabCapturePerformanceTest, Performance) { RunTest("TabCapturePerformance"); } // Note: First argument is optional and intentionally left blank. // (it's a prefix for the generated test cases) INSTANTIATE_TEST_CASE_P( , TabCapturePerformanceTest, testing::Values( 0, kUseGpu | kForceGpuComposited, kDisableVsync, kDisableVsync | kUseGpu | kForceGpuComposited, kTestThroughWebRTC, kTestThroughWebRTC | kUseGpu | kForceGpuComposited, kTestThroughWebRTC | kDisableVsync, kTestThroughWebRTC | kDisableVsync | kUseGpu | kForceGpuComposited)); #if defined(USE_AURA) // TODO(hubbe): // These are temporary tests for the purpose of determining what the // appropriate scaling quality is. Once that has been determined, // these tests will be removed. const int kScalingTestBase = kTestThroughWebRTC | kDisableVsync | kUseGpu | kForceGpuComposited; INSTANTIATE_TEST_CASE_P( ScalingTests, TabCapturePerformanceTest, testing::Values( kScalingTestBase | kScaleQualityFast, kScalingTestBase | kScaleQualityGood, kScalingTestBase | kScaleQualityBest, kScalingTestBase | kScaleQualityFast | kSmallWindow, kScalingTestBase | kScaleQualityGood | kSmallWindow, kScalingTestBase | kScaleQualityBest | kSmallWindow)); #endif // USE_AURA
b5ef9287d8dd92551900e03eee4027bbd49795ec
46f2e7a10fca9f7e7b80b342240302c311c31914
/lid_driven_flow/cavity/0.0384/phi
6a411fc7afd5debd3f701c32ba0a4037f2487947
[]
no_license
patricksinclair/openfoam_warmups
696cb1950d40b967b8b455164134bde03e9179a1
03c982f7d46b4858e3b6bfdde7b8e8c3c4275df9
refs/heads/master
2020-12-26T12:50:00.615357
2020-02-04T20:22:35
2020-02-04T20:22:35
237,510,814
0
0
null
null
null
null
UTF-8
C++
false
false
62,624
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class surfaceScalarField; location "0.0384"; object phi; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 3 -1 0 0 0 0]; internalField nonuniform List<scalar> 4900 ( 9.7569e-10 -9.72004e-10 1.88632e-09 -9.10608e-10 1.77295e-09 1.13345e-10 3.2558e-10 1.44738e-09 -2.49894e-09 2.82454e-09 -6.61349e-09 4.11452e-09 -1.18629e-08 5.24943e-09 -1.80658e-08 6.20289e-09 -2.50331e-08 6.96733e-09 -3.25773e-08 7.54411e-09 -4.05167e-08 7.93946e-09 -4.86791e-08 8.16238e-09 -5.69025e-08 8.22338e-09 -6.50364e-08 8.13388e-09 -7.29421e-08 7.9057e-09 -8.04929e-08 7.55082e-09 -8.75741e-08 7.08118e-09 -9.40827e-08 6.50859e-09 -9.99274e-08 5.84471e-09 -1.05028e-07 5.10098e-09 -1.09317e-07 4.28873e-09 -1.12736e-07 3.41917e-09 -1.1524e-07 2.50351e-09 -1.16793e-07 1.55302e-09 -1.17372e-07 5.79119e-10 -1.16965e-07 -4.06501e-10 -1.15574e-07 -1.39184e-09 -1.13209e-07 -2.3645e-09 -1.09897e-07 -3.31164e-09 -1.05677e-07 -4.22e-09 -1.00602e-07 -5.07584e-09 -9.47365e-08 -5.86508e-09 -8.81632e-08 -6.57331e-09 -8.09772e-08 -7.18598e-09 -7.32886e-08 -7.68854e-09 -6.5222e-08 -8.0666e-09 -5.69158e-08 -8.30627e-09 -4.85214e-08 -8.39436e-09 -4.02027e-08 -8.31873e-09 -3.2134e-08 -8.0687e-09 -2.44984e-08 -7.63555e-09 -1.74852e-08 -7.01324e-09 -1.12856e-08 -6.19952e-09 -6.08765e-09 -5.198e-09 -2.06548e-09 -4.02217e-09 6.39166e-10 -2.70465e-09 1.95447e-09 -1.31531e-09 1.95908e-09 -4.60522e-12 9.78574e-10 9.80506e-10 9.78576e-10 9.26218e-10 -1.8982e-09 7.80252e-10 -7.64685e-10 -1.79861e-09 2.6922e-09 -7.43544e-09 7.08424e-09 -1.62832e-08 1.16723e-08 -2.82063e-08 1.60377e-08 -4.2905e-08 1.99482e-08 -5.99863e-08 2.32841e-08 -7.90102e-08 2.59913e-08 -9.95194e-08 2.80533e-08 -1.21057e-07 2.94773e-08 -1.43179e-07 3.02845e-08 -1.65461e-07 3.05054e-08 -1.87503e-07 3.0176e-08 -2.08933e-07 2.93356e-08 -2.29408e-07 2.80258e-08 -2.48616e-07 2.62889e-08 -2.66275e-07 2.41675e-08 -2.82134e-07 2.17043e-08 -2.95975e-07 1.8942e-08 -3.07609e-07 1.59227e-08 -3.16879e-07 1.26888e-08 -3.23658e-07 9.28265e-09 -3.27852e-07 5.7469e-09 -3.29398e-07 2.1249e-09 -3.28265e-07 -1.53912e-09 -3.24457e-07 -5.19983e-09 -3.18011e-07 -8.81055e-09 -3.09e-07 -1.23232e-08 -2.97531e-07 -1.56882e-08 -2.83753e-07 -1.88547e-08 -2.67847e-07 -2.17707e-08 -2.50037e-07 -2.43835e-08 -2.30583e-07 -2.66401e-08 -2.09783e-07 -2.8488e-08 -1.87974e-07 -2.9876e-08 -1.65525e-07 -3.07553e-08 -1.42839e-07 -3.10806e-08 -1.20346e-07 -3.08115e-08 -9.84998e-08 -2.99146e-08 -7.77695e-08 -2.83659e-08 -5.86288e-08 -2.61539e-08 -4.15433e-08 -2.3285e-08 -2.69495e-08 -1.97917e-08 -1.52251e-08 -1.57466e-08 -6.64127e-09 -1.12884e-08 -1.28939e-09 -6.66718e-09 1.02577e-09 -2.31977e-09 9.88534e-10 1.01774e-09 1.96711e-09 -6.3321e-11 -1.83489e-09 -2.5921e-09 1.7641e-09 -8.8986e-09 8.99871e-09 -1.95982e-08 1.77839e-08 -3.48434e-08 2.69174e-08 -5.44579e-08 3.56522e-08 -7.80449e-08 4.35352e-08 -1.05069e-07 5.03081e-08 -1.34914e-07 5.58364e-08 -1.66925e-07 6.00646e-08 -2.00437e-07 6.29887e-08 -2.34791e-07 6.46385e-08 -2.69352e-07 6.50667e-08 -3.03517e-07 6.43406e-08 -3.36718e-07 6.25372e-08 -3.68432e-07 5.97397e-08 -3.98178e-07 5.60349e-08 -4.25522e-07 5.15113e-08 -4.50076e-07 4.62588e-08 -4.71501e-07 4.03672e-08 -4.89506e-07 3.39268e-08 -5.03845e-07 2.7028e-08 -5.14324e-07 1.97617e-08 -5.20797e-07 1.22198e-08 -5.23167e-07 4.49536e-09 -5.2139e-07 -3.31641e-09 -5.15471e-07 -1.11182e-08 -5.05472e-07 -1.88101e-08 -4.91506e-07 -2.62893e-08 -4.73744e-07 -3.34503e-08 -4.52413e-07 -4.01853e-08 -4.278e-07 -4.63842e-08 -4.00247e-07 -5.19362e-08 -3.70157e-07 -5.67305e-08 -3.37987e-07 -6.06579e-08 -3.0425e-07 -6.36129e-08 -2.69509e-07 -6.54959e-08 -2.34374e-07 -6.6216e-08 -1.99491e-07 -6.56947e-08 -1.65536e-07 -6.38697e-08 -1.332e-07 -6.07012e-08 -1.03176e-07 -5.61786e-08 -7.61284e-08 -5.03323e-08 -5.26709e-08 -4.32492e-08 -3.33181e-08 -3.50994e-08 -1.84292e-08 -2.61773e-08 -8.12655e-09 -1.69698e-08 -2.19484e-09 -8.25147e-09 5.81196e-11 -1.23522e-09 2.02523e-09 -1.35029e-09 -4.84606e-10 -6.90883e-09 7.32268e-09 -1.76091e-08 1.9699e-08 -3.38946e-08 3.40694e-08 -5.58132e-08 4.8836e-08 -8.3099e-08 6.2938e-08 -1.15256e-07 7.56924e-08 -1.51631e-07 8.66833e-08 -1.91471e-07 9.56764e-08 -2.33967e-07 1.02561e-07 -2.78289e-07 1.07311e-07 -3.2361e-07 1.09959e-07 -3.69125e-07 1.10581e-07 -4.14062e-07 1.09277e-07 -4.57694e-07 1.06169e-07 -4.99345e-07 1.01391e-07 -5.38393e-07 9.50833e-08 -5.74275e-07 8.73934e-08 -6.06487e-07 7.84706e-08 -6.34586e-07 6.84662e-08 -6.58192e-07 5.75323e-08 -6.76986e-07 4.58222e-08 -6.90715e-07 3.34902e-08 -6.99187e-07 2.06926e-08 -7.0228e-07 7.58807e-09 -6.99935e-07 -5.66175e-09 -6.92162e-07 -1.88914e-08 -6.7904e-07 -3.19313e-08 -6.60722e-07 -4.46074e-08 -6.37431e-07 -5.67416e-08 -6.09464e-07 -6.8152e-08 -5.77194e-07 -7.86541e-08 -5.41068e-07 -8.80624e-08 -5.01607e-07 -9.61921e-08 -4.59402e-07 -1.02862e-07 -4.15115e-07 -1.079e-07 -3.6947e-07 -1.11142e-07 -3.23244e-07 -1.12442e-07 -2.77261e-07 -1.11677e-07 -2.32378e-07 -1.08753e-07 -1.89462e-07 -1.03617e-07 -1.49377e-07 -9.62643e-08 -1.12945e-07 -8.67636e-08 -8.09195e-08 -7.5275e-08 -5.39306e-08 -6.20882e-08 -3.24319e-08 -4.7676e-08 -1.66273e-08 -3.27745e-08 -6.39184e-09 -1.8487e-08 -1.19395e-09 -6.43311e-09 8.31279e-10 -2.71057e-09 2.22596e-09 -1.15338e-08 1.61459e-08 -2.69352e-08 3.51005e-08 -4.90786e-08 5.62128e-08 -7.78247e-08 7.75821e-08 -1.12769e-07 9.78825e-08 -1.53297e-07 1.1622e-07 -1.98636e-07 1.32023e-07 -2.47912e-07 1.44952e-07 -3.00185e-07 1.54834e-07 -3.5449e-07 1.61615e-07 -4.0986e-07 1.65329e-07 -4.65349e-07 1.6607e-07 -5.20048e-07 1.63977e-07 -5.73098e-07 1.59219e-07 -6.23693e-07 1.51986e-07 -6.71094e-07 1.42485e-07 -7.14628e-07 1.30928e-07 -7.53693e-07 1.17535e-07 -7.87759e-07 1.02532e-07 -8.16368e-07 8.61422e-08 -8.39142e-07 6.85956e-08 -8.55774e-07 5.01223e-08 -8.66037e-07 3.0956e-08 -8.69783e-07 1.13339e-08 -8.66943e-07 -8.50223e-09 -8.57529e-07 -2.83051e-08 -8.41639e-07 -4.78216e-08 -8.19453e-07 -6.67925e-08 -7.91242e-07 -8.49527e-08 -7.57362e-07 -1.02032e-07 -7.18258e-07 -1.17758e-07 -6.74465e-07 -1.31856e-07 -6.26603e-07 -1.44054e-07 -5.75377e-07 -1.54088e-07 -5.21573e-07 -1.61704e-07 -4.66047e-07 -1.66667e-07 -4.0972e-07 -1.68769e-07 -3.53561e-07 -1.67836e-07 -2.98574e-07 -1.6374e-07 -2.45778e-07 -1.56413e-07 -1.96175e-07 -1.45867e-07 -1.50726e-07 -1.32213e-07 -1.10308e-07 -1.15693e-07 -7.56705e-08 -9.67257e-08 -4.73837e-08 -7.59628e-08 -2.57834e-08 -5.43747e-08 -1.09199e-08 -3.33505e-08 -2.52252e-09 -1.48305e-08 -1.69124e-09 -4.0354e-09 6.26138e-09 -1.61508e-08 2.82612e-08 -3.63405e-08 5.52902e-08 -6.44384e-08 8.43107e-08 -1.00068e-07 1.13211e-07 -1.42645e-07 1.4046e-07 -1.9141e-07 1.64985e-07 -2.45463e-07 1.86076e-07 -3.03805e-07 2.03294e-07 -3.65378e-07 2.16407e-07 -4.29094e-07 2.25332e-07 -4.93867e-07 2.30102e-07 -5.58632e-07 2.30835e-07 -6.22362e-07 2.27707e-07 -6.84084e-07 2.20941e-07 -7.42887e-07 2.1079e-07 -7.97932e-07 1.97529e-07 -8.48453e-07 1.81449e-07 -8.93764e-07 1.62847e-07 -9.33262e-07 1.42029e-07 -9.66426e-07 1.19307e-07 -9.92823e-07 9.49918e-08 -1.0121e-06 6.94026e-08 -1.02401e-06 4.28607e-08 -1.02837e-06 1.5693e-08 -1.0251e-06 -1.17672e-08 -1.01423e-06 -3.91794e-08 -9.95854e-07 -6.61954e-08 -9.70187e-07 -9.24586e-08 -9.37535e-07 -1.17605e-07 -8.98302e-07 -1.41265e-07 -8.52994e-07 -1.63065e-07 -8.0222e-07 -1.8263e-07 -7.46684e-07 -1.99591e-07 -6.87185e-07 -2.13586e-07 -6.24614e-07 -2.24275e-07 -5.5994e-07 -2.31341e-07 -4.94204e-07 -2.34505e-07 -4.28502e-07 -2.33539e-07 -3.63965e-07 -2.28277e-07 -3.0174e-07 -2.18638e-07 -2.42962e-07 -2.04646e-07 -1.88716e-07 -1.86458e-07 -1.40009e-07 -1.644e-07 -9.77198e-08 -1.39015e-07 -6.2564e-08 -1.11119e-07 -3.50504e-08 -8.18883e-08 -1.54552e-08 -5.29456e-08 -3.81936e-09 -2.64664e-08 -5.5106e-09 -5.28857e-09 1.15499e-08 -2.06251e-08 4.35978e-08 -4.55688e-08 8.02339e-08 -7.96133e-08 1.18355e-07 -1.22118e-07 1.55716e-07 -1.72291e-07 1.90634e-07 -2.29205e-07 2.21898e-07 -2.91814e-07 2.48685e-07 -3.58991e-07 2.70471e-07 -4.29557e-07 2.86973e-07 -5.02311e-07 2.98085e-07 -5.76054e-07 3.03846e-07 -6.49615e-07 3.04396e-07 -7.21866e-07 2.99958e-07 -7.91736e-07 2.9081e-07 -8.58222e-07 2.77276e-07 -9.20399e-07 2.59707e-07 -9.77425e-07 2.38474e-07 -1.02854e-06 2.13963e-07 -1.07308e-06 1.86571e-07 -1.11048e-06 1.56699e-07 -1.14024e-06 1.24756e-07 -1.16199e-06 9.11525e-08 -1.17544e-06 5.63092e-08 -1.1804e-06 2.06516e-08 -1.17678e-06 -1.53866e-08 -1.16459e-06 -5.1362e-08 -1.14397e-06 -8.68213e-08 -1.11513e-06 -1.21301e-07 -1.0784e-06 -1.54329e-07 -1.03424e-06 -1.85424e-07 -9.83206e-07 -2.14102e-07 -9.25958e-07 -2.39879e-07 -8.63274e-07 -2.62274e-07 -7.96036e-07 -2.80825e-07 -7.25221e-07 -2.9509e-07 -6.51898e-07 -3.04664e-07 -5.77213e-07 -3.09191e-07 -5.02372e-07 -3.08379e-07 -4.28625e-07 -3.02023e-07 -3.57241e-07 -2.90022e-07 -2.89477e-07 -2.7241e-07 -2.2655e-07 -2.49385e-07 -1.69602e-07 -2.21348e-07 -1.19662e-07 -1.88954e-07 -7.76147e-08 -1.53166e-07 -4.41712e-08 -1.15332e-07 -1.98611e-08 -7.72557e-08 -5.04796e-09 -4.12795e-08 -1.05586e-08 -6.46806e-09 1.8018e-08 -2.4922e-08 6.20517e-08 -5.45349e-08 1.09847e-07 -9.44701e-08 1.5829e-07 -1.43813e-07 2.05059e-07 -2.01548e-07 2.48368e-07 -2.66557e-07 2.86907e-07 -3.37636e-07 3.19764e-07 -4.1352e-07 3.46355e-07 -4.92902e-07 3.66355e-07 -5.74468e-07 3.79651e-07 -6.56912e-07 3.8629e-07 -7.38964e-07 3.86448e-07 -8.19402e-07 3.80396e-07 -8.97068e-07 3.68477e-07 -9.70881e-07 3.51089e-07 -1.03984e-06 3.28666e-07 -1.10304e-06 3.0167e-07 -1.15965e-06 2.7058e-07 -1.20897e-06 2.35889e-07 -1.25037e-06 1.98098e-07 -1.28333e-06 1.57716e-07 -1.30744e-06 1.15258e-07 -1.32238e-06 7.12483e-08 -1.32794e-06 2.62186e-08 -1.32404e-06 -1.92891e-08 -1.31068e-06 -6.4721e-08 -1.28799e-06 -1.09511e-07 -1.25621e-06 -1.53081e-07 -1.2157e-06 -1.94839e-07 -1.16694e-06 -2.34188e-07 -1.11052e-06 -2.70523e-07 -1.04716e-06 -3.03238e-07 -9.77696e-07 -3.31737e-07 -9.03079e-07 -3.55442e-07 -8.24363e-07 -3.73805e-07 -7.42706e-07 -3.86322e-07 -6.59347e-07 -3.9255e-07 -5.75597e-07 -3.92129e-07 -4.92819e-07 -3.84801e-07 -4.12399e-07 -3.70442e-07 -3.35723e-07 -3.49086e-07 -2.64146e-07 -3.20962e-07 -1.98959e-07 -2.86536e-07 -1.41357e-07 -2.46556e-07 -9.24148e-08 -2.02108e-07 -5.30663e-08 -1.5468e-07 -2.41047e-08 -1.06217e-07 -6.20606e-09 -5.91782e-08 -1.67646e-08 -7.58585e-09 2.56039e-08 -2.90578e-08 8.35237e-08 -6.32494e-08 1.44038e-07 -1.09012e-07 2.04053e-07 -1.65157e-07 2.61204e-07 -2.30434e-07 3.13645e-07 -3.03523e-07 3.59996e-07 -3.83047e-07 3.99288e-07 -4.67588e-07 4.30896e-07 -5.5571e-07 4.54477e-07 -6.45978e-07 4.69919e-07 -7.36981e-07 4.77293e-07 -8.27351e-07 4.76818e-07 -9.1578e-07 4.68825e-07 -1.00103e-06 4.53728e-07 -1.08195e-06 4.32007e-07 -1.15747e-06 4.04186e-07 -1.22662e-06 3.70824e-07 -1.28854e-06 3.32501e-07 -1.34247e-06 2.89811e-07 -1.38773e-06 2.43362e-07 -1.42378e-06 1.9377e-07 -1.45018e-06 1.41659e-07 -1.4666e-06 8.76618e-08 -1.4728e-06 3.24233e-08 -1.46869e-06 -2.34005e-08 -1.45427e-06 -7.91393e-08 -1.42968e-06 -1.34108e-07 -1.39515e-06 -1.87606e-07 -1.35107e-06 -2.38918e-07 -1.29794e-06 -2.8732e-07 -1.23639e-06 -3.32076e-07 -1.16717e-06 -3.72456e-07 -1.09117e-06 -4.07734e-07 -1.0094e-06 -4.3721e-07 -9.22992e-07 -4.60217e-07 -8.3317e-07 -4.76143e-07 -7.41271e-07 -4.8445e-07 -6.48704e-07 -4.84695e-07 -5.56944e-07 -4.76562e-07 -4.67499e-07 -4.59887e-07 -3.8189e-07 -4.34694e-07 -3.0162e-07 -4.01232e-07 -2.28144e-07 -3.60013e-07 -1.62839e-07 -3.1186e-07 -1.06988e-07 -2.5796e-07 -6.1758e-08 -1.9991e-07 -2.82071e-08 -1.39768e-07 -7.30671e-09 -8.00786e-08 -2.40713e-08 -8.65886e-09 3.42627e-08 -3.30729e-08 1.07938e-07 -7.17741e-08 1.8274e-07 -1.2332e-07 2.55599e-07 -1.86254e-07 3.24138e-07 -2.59083e-07 3.86474e-07 -3.40276e-07 4.41189e-07 -4.28272e-07 4.87284e-07 -5.21491e-07 5.24115e-07 -6.18354e-07 5.51341e-07 -7.17305e-07 5.68869e-07 -8.16823e-07 5.76811e-07 -9.15444e-07 5.7544e-07 -1.01177e-06 5.65155e-07 -1.1045e-06 5.46456e-07 -1.19241e-06 5.19911e-07 -1.27436e-06 4.86144e-07 -1.34936e-06 4.45816e-07 -1.41647e-06 3.99614e-07 -1.4749e-06 3.48243e-07 -1.52396e-06 2.92419e-07 -1.56306e-06 2.32871e-07 -1.59174e-06 1.70337e-07 -1.60964e-06 1.05564e-07 -1.61653e-06 3.93131e-08 -1.61229e-06 -2.76415e-08 -1.59692e-06 -9.45082e-08 -1.57055e-06 -1.60478e-07 -1.53343e-06 -2.24722e-07 -1.48595e-06 -2.86397e-07 -1.42863e-06 -3.44641e-07 -1.36212e-06 -3.98587e-07 -1.28721e-06 -4.47365e-07 -1.20483e-06 -4.90115e-07 -1.11604e-06 -5.26002e-07 -1.02203e-06 -5.5423e-07 -9.24102e-07 -5.74068e-07 -8.23685e-07 -5.84868e-07 -7.22285e-07 -5.86094e-07 -6.2149e-07 -5.77356e-07 -5.22939e-07 -5.58439e-07 -4.28294e-07 -5.29339e-07 -3.39218e-07 -4.90307e-07 -2.57346e-07 -4.41885e-07 -1.84255e-07 -3.84952e-07 -1.21444e-07 -3.20771e-07 -7.03243e-08 -2.5103e-07 -3.22165e-08 -1.77876e-07 -8.36884e-09 -1.03926e-07 -3.24402e-08 -9.70513e-09 4.39679e-08 -3.70179e-08 1.35251e-07 -8.0196e-08 2.25918e-07 -1.37519e-07 3.12922e-07 -2.07264e-07 3.93883e-07 -2.87696e-07 4.66905e-07 -3.77062e-07 5.30556e-07 -4.73607e-07 5.83829e-07 -5.7558e-07 6.26088e-07 -6.81253e-07 6.57014e-07 -7.88937e-07 6.76554e-07 -8.97002e-07 6.84875e-07 -1.00388e-06 6.82322e-07 -1.10811e-06 6.69377e-07 -1.20828e-06 6.46633e-07 -1.30313e-06 6.14761e-07 -1.39148e-06 5.74491e-07 -1.47226e-06 5.26595e-07 -1.54452e-06 4.71873e-07 -1.60742e-06 4.11146e-07 -1.66025e-06 3.45245e-07 -1.70239e-06 2.75014e-07 -1.73336e-06 2.01309e-07 -1.75279e-06 1.24995e-07 -1.76043e-06 4.69509e-08 -1.75615e-06 -3.19267e-08 -1.73993e-06 -1.10722e-07 -1.71191e-06 -1.88499e-07 -1.67234e-06 -2.64298e-07 -1.6216e-06 -3.37137e-07 -1.56022e-06 -4.06018e-07 -1.48888e-06 -4.6993e-07 -1.40838e-06 -5.27858e-07 -1.3197e-06 -5.78796e-07 -1.22394e-06 -6.21764e-07 -1.12235e-06 -6.55826e-07 -1.0163e-06 -6.80117e-07 -9.07299e-07 -6.93865e-07 -7.96966e-07 -6.96427e-07 -6.87003e-07 -6.87319e-07 -5.79184e-07 -6.66259e-07 -4.75326e-07 -6.33197e-07 -3.77267e-07 -5.88366e-07 -2.86832e-07 -5.32319e-07 -2.05812e-07 -4.65972e-07 -1.35939e-07 -3.90644e-07 -7.88725e-08 -3.08097e-07 -3.6193e-08 -2.20555e-07 -9.41319e-09 -1.30706e-07 -4.18534e-08 -1.07423e-08 5.47102e-08 -4.09465e-08 1.65455e-07 -8.86122e-08 2.73583e-07 -1.51751e-07 3.76061e-07 -2.28376e-07 4.70509e-07 -3.16506e-07 5.55034e-07 -4.14161e-07 6.28211e-07 -5.19381e-07 6.89049e-07 -6.30235e-07 7.36942e-07 -7.44836e-07 7.71615e-07 -8.61361e-07 7.93078e-07 -9.78059e-07 8.01573e-07 -1.09327e-06 7.97532e-07 -1.20543e-06 7.81538e-07 -1.31309e-06 7.54289e-07 -1.4149e-06 7.16571e-07 -1.50964e-06 6.6923e-07 -1.5962e-06 6.13159e-07 -1.6736e-06 5.49276e-07 -1.74098e-06 4.78523e-07 -1.79759e-06 4.01851e-07 -1.8428e-06 3.20225e-07 -1.87611e-06 2.34617e-07 -1.89712e-06 1.46013e-07 -1.90559e-06 5.54138e-08 -1.90135e-06 -3.61628e-08 -1.8844e-06 -1.27675e-07 -1.85484e-06 -2.18055e-07 -1.81293e-06 -3.0621e-07 -1.75905e-06 -3.91019e-07 -1.69373e-06 -4.71339e-07 -1.61765e-06 -5.46009e-07 -1.53164e-06 -6.13861e-07 -1.4367e-06 -6.73734e-07 -1.33398e-06 -7.2449e-07 -1.22476e-06 -7.6504e-07 -1.11051e-06 -7.94369e-07 -9.92813e-07 -8.11565e-07 -8.73383e-07 -8.15856e-07 -7.54053e-07 -8.0665e-07 -6.36739e-07 -7.83572e-07 -5.23427e-07 -7.46509e-07 -4.16139e-07 -6.95654e-07 -3.1691e-07 -6.31549e-07 -2.27757e-07 -5.55125e-07 -1.50656e-07 -4.67744e-07 -8.75231e-08 -3.7123e-07 -4.02016e-08 -2.67877e-07 -1.04605e-08 -1.60447e-07 -5.23138e-08 -1.17868e-08 6.6497e-08 -4.49112e-08 1.98579e-07 -9.71217e-08 3.25794e-07 -1.66164e-07 4.45103e-07 -2.49789e-07 5.54134e-07 -3.4576e-07 6.51005e-07 -4.51866e-07 7.34316e-07 -5.65931e-07 8.03114e-07 -6.85836e-07 8.56846e-07 -8.09528e-07 8.95307e-07 -9.35039e-07 9.1859e-07 -1.0605e-06 9.27033e-07 -1.18414e-06 9.21177e-07 -1.30433e-06 9.01722e-07 -1.41953e-06 8.69488e-07 -1.52834e-06 8.25388e-07 -1.62951e-06 7.70396e-07 -1.72188e-06 7.05533e-07 -1.80445e-06 6.31846e-07 -1.87633e-06 5.50401e-07 -1.93675e-06 4.62273e-07 -1.98507e-06 3.68547e-07 -2.02078e-06 2.70319e-07 -2.04346e-06 1.68693e-07 -2.05283e-06 6.47898e-08 -2.04875e-06 -4.02475e-08 -2.03117e-06 -1.45252e-07 -2.0002e-06 -2.49025e-07 -1.95607e-06 -3.50338e-07 -1.89916e-06 -4.47927e-07 -1.83e-06 -5.40501e-07 -1.74927e-06 -6.26742e-07 -1.65781e-06 -7.0532e-07 -1.55664e-06 -7.74909e-07 -1.44692e-06 -8.34202e-07 -1.33003e-06 -8.81939e-07 -1.20746e-06 -9.16939e-07 -1.08089e-06 -9.3813e-07 -9.52155e-07 -9.44592e-07 -8.23207e-07 -9.35598e-07 -6.96118e-07 -9.10661e-07 -5.73051e-07 -8.69577e-07 -4.56228e-07 -8.12477e-07 -3.47907e-07 -7.3987e-07 -2.50348e-07 -6.52684e-07 -1.65785e-07 -5.52307e-07 -9.64012e-08 -4.40613e-07 -4.43076e-08 -3.19971e-07 -1.15307e-08 -1.93224e-07 -6.38446e-08 -1.28537e-08 7.93507e-08 -4.8962e-08 2.34687e-07 -1.0582e-07 3.82652e-07 -1.80905e-07 5.20188e-07 -2.71698e-07 6.44927e-07 -3.75704e-07 7.55011e-07 -4.90465e-07 8.49078e-07 -6.13586e-07 9.26235e-07 -7.42747e-07 9.86007e-07 -8.75723e-07 1.02828e-06 -1.01039e-06 1.05326e-06 -1.14477e-06 1.0614e-06 -1.27697e-06 1.05338e-06 -1.40528e-06 1.03003e-06 -1.5281e-06 9.92308e-07 -1.64398e-06 9.41271e-07 -1.75162e-06 8.78034e-07 -1.84984e-06 8.03755e-07 -1.93761e-06 7.19616e-07 -2.01402e-06 6.26813e-07 -2.0783e-06 5.26549e-07 -2.12979e-06 4.20033e-07 -2.16795e-06 3.0848e-07 -2.19237e-06 1.93114e-07 -2.20275e-06 7.51764e-08 -2.19893e-06 -4.4069e-08 -2.18085e-06 -1.6333e-07 -2.1486e-06 -2.81279e-07 -2.10239e-06 -3.96549e-07 -2.04258e-06 -5.07735e-07 -1.96969e-06 -6.13389e-07 -1.8844e-06 -7.12036e-07 -1.78755e-06 -8.02174e-07 -1.68015e-06 -8.82299e-07 -1.56343e-06 -9.50922e-07 -1.43878e-06 -1.0066e-06 -1.30776e-06 -1.04796e-06 -1.17214e-06 -1.07375e-06 -1.03386e-06 -1.08287e-06 -8.95013e-07 -1.07445e-06 -7.57825e-07 -1.04785e-06 -6.2465e-07 -1.00275e-06 -4.97927e-07 -9.39199e-07 -3.80153e-07 -8.57643e-07 -2.73848e-07 -7.5899e-07 -1.81519e-07 -6.44636e-07 -1.05631e-07 -5.16501e-07 -4.85747e-08 -3.77027e-07 -1.26428e-08 -2.29156e-07 -7.64874e-08 -1.39568e-08 9.33074e-08 -5.31451e-08 2.73876e-07 -1.14797e-07 4.44304e-07 -1.96112e-07 6.01503e-07 -2.94291e-07 7.43106e-07 -4.06568e-07 8.67288e-07 -5.30232e-07 9.72742e-07 -6.62652e-07 1.05866e-06 -8.01302e-07 1.12466e-06 -9.43773e-07 1.17075e-06 -1.08779e-06 1.19728e-06 -1.23124e-06 1.20485e-06 -1.37213e-06 1.19428e-06 -1.50866e-06 1.16656e-06 -1.63918e-06 1.12282e-06 -1.76218e-06 1.06427e-06 -1.87633e-06 9.9218e-07 -1.98042e-06 9.0785e-07 -2.07341e-06 8.12608e-07 -2.15439e-06 7.07785e-07 -2.22255e-06 5.94715e-07 -2.27725e-06 4.7473e-07 -2.31793e-06 3.49164e-07 -2.34418e-06 2.19361e-07 -2.35568e-06 8.66768e-08 -2.35224e-06 -4.75058e-08 -2.3338e-06 -1.81773e-07 -2.30041e-06 -3.14669e-07 -2.25227e-06 -4.44692e-07 -2.18971e-06 -5.70293e-07 -2.11323e-06 -6.89869e-07 -2.02349e-06 -8.01777e-07 -1.92133e-06 -9.04339e-07 -1.80776e-06 -9.95861e-07 -1.68403e-06 -1.07466e-06 -1.55155e-06 -1.13908e-06 -1.41196e-06 -1.18754e-06 -1.26711e-06 -1.2186e-06 -1.11904e-06 -1.23094e-06 -9.69977e-07 -1.22351e-06 -8.22333e-07 -1.19549e-06 -6.78658e-07 -1.14643e-06 -5.4162e-07 -1.07624e-06 -4.13973e-07 -9.85291e-07 -2.98513e-07 -8.74449e-07 -1.98045e-07 -7.45105e-07 -1.15332e-07 -5.99214e-07 -5.3064e-08 -4.39295e-07 -1.38146e-08 -2.68405e-07 -9.0302e-08 -1.51083e-08 1.08416e-07 -5.75028e-08 3.1627e-07 -1.24136e-07 5.10937e-07 -2.11912e-07 6.89279e-07 -3.1774e-07 8.48934e-07 -4.38566e-07 9.88114e-07 -5.71412e-07 1.10559e-06 -7.13402e-07 1.20065e-06 -8.61789e-07 1.27304e-06 -1.01398e-06 1.32294e-06 -1.16753e-06 1.35084e-06 -1.3202e-06 1.35751e-06 -1.46989e-06 1.34397e-06 -1.61473e-06 1.3114e-06 -1.75299e-06 1.26108e-06 -1.88313e-06 1.19442e-06 -2.00379e-06 1.11284e-06 -2.11376e-06 1.01782e-06 -2.21197e-06 9.10818e-07 -2.2975e-06 7.9332e-07 -2.36957e-06 6.66785e-07 -2.42751e-06 5.3267e-07 -2.47078e-06 3.92427e-07 -2.49893e-06 2.47513e-07 -2.51165e-06 9.93969e-08 -2.50873e-06 -5.04265e-08 -2.49007e-06 -2.00426e-07 -2.45572e-06 -3.49024e-07 -2.40583e-06 -4.94586e-07 -2.3407e-06 -6.35418e-07 -2.26081e-06 -7.69763e-07 -2.16678e-06 -8.95807e-07 -2.05943e-06 -1.01169e-06 -1.93978e-06 -1.11551e-06 -1.80907e-06 -1.20537e-06 -1.66874e-06 -1.2794e-06 -1.52049e-06 -1.3358e-06 -1.36623e-06 -1.37285e-06 -1.20813e-06 -1.38905e-06 -1.04855e-06 -1.38309e-06 -8.90078e-07 -1.35396e-06 -7.35479e-07 -1.30103e-06 -5.87667e-07 -1.22405e-06 -4.49672e-07 -1.12329e-06 -3.2459e-07 -9.9953e-07 -2.15543e-07 -8.54152e-07 -1.25621e-07 -6.89136e-07 -5.78337e-08 -5.07082e-07 -1.5063e-08 -3.11176e-07 -1.05365e-07 -1.63196e-08 1.24735e-07 -6.20739e-08 3.62024e-07 -1.33912e-07 5.82775e-07 -2.28424e-07 7.83791e-07 -3.42202e-07 9.62712e-07 -4.71889e-07 1.1178e-06 -6.14223e-07 1.24792e-06 -7.66068e-07 1.35249e-06 -9.24447e-07 1.43142e-06 -1.08657e-06 1.48506e-06 -1.24983e-06 1.5141e-06 -1.41183e-06 1.51952e-06 -1.57041e-06 1.50255e-06 -1.72359e-06 1.46457e-06 -1.8696e-06 1.40709e-06 -2.00686e-06 1.33168e-06 -2.13399e-06 1.23997e-06 -2.24978e-06 1.1336e-06 -2.35315e-06 1.01419e-06 -2.44321e-06 8.83374e-07 -2.51916e-06 7.42735e-07 -2.58034e-06 5.93855e-07 -2.62622e-06 4.38302e-07 -2.65634e-06 2.77639e-07 -2.67039e-06 1.13441e-07 -2.66812e-06 -5.26915e-08 -2.64943e-06 -2.19118e-07 -2.61431e-06 -3.84144e-07 -2.56289e-06 -5.46009e-07 -2.49543e-06 -7.02879e-07 -2.41235e-06 -8.52841e-07 -2.31425e-06 -9.93909e-07 -2.20191e-06 -1.12403e-06 -2.07633e-06 -1.24109e-06 -1.93873e-06 -1.34297e-06 -1.79059e-06 -1.42755e-06 -1.63363e-06 -1.49275e-06 -1.46984e-06 -1.53664e-06 -1.3015e-06 -1.5574e-06 -1.1311e-06 -1.55348e-06 -9.61434e-07 -1.52363e-06 -7.95473e-07 -1.46699e-06 -6.36399e-07 -1.38312e-06 -4.87537e-07 -1.27215e-06 -3.52311e-07 -1.13476e-06 -2.34185e-07 -9.72278e-07 -1.36607e-07 -7.86715e-07 -6.29393e-08 -5.80749e-07 -1.6404e-08 -3.57711e-07 -1.21769e-07 -1.76009e-08 1.42336e-07 -6.68935e-08 4.11317e-07 -1.44195e-07 6.60076e-07 -2.45751e-07 8.85347e-07 -3.67815e-07 1.08478e-06 -5.06703e-07 1.25669e-06 -6.58848e-07 1.40007e-06 -8.20837e-07 1.51448e-06 -9.89454e-07 1.60004e-06 -1.1617e-06 1.6573e-06 -1.33479e-06 1.6872e-06 -1.50623e-06 1.69095e-06 -1.67371e-06 1.67003e-06 -1.8352e-06 1.62606e-06 -1.98888e-06 1.56078e-06 -2.13317e-06 1.47597e-06 -2.26666e-06 1.37346e-06 -2.38814e-06 1.25508e-06 -2.49657e-06 1.12262e-06 -2.59104e-06 9.77848e-07 -2.6708e-06 8.2249e-07 -2.73519e-06 6.58246e-07 -2.78368e-06 4.8679e-07 -2.81582e-06 3.09786e-07 -2.83129e-06 1.28906e-07 -2.82983e-06 -5.41543e-08 -2.81129e-06 -2.37655e-07 -2.77564e-06 -4.19795e-07 -2.72295e-06 -5.98695e-07 -2.65344e-06 -7.72386e-07 -2.56748e-06 -9.38804e-07 -2.4656e-06 -1.09579e-06 -2.34855e-06 -1.24108e-06 -2.21727e-06 -1.37237e-06 -2.07298e-06 -1.48726e-06 -1.91714e-06 -1.58339e-06 -1.75151e-06 -1.65839e-06 -1.57814e-06 -1.71e-06 -1.39939e-06 -1.73614e-06 -1.21793e-06 -1.73494e-06 -1.03671e-06 -1.70485e-06 -8.58954e-07 -1.64475e-06 -6.88112e-07 -1.55397e-06 -5.27831e-07 -1.43243e-06 -3.8189e-07 -1.2807e-06 -2.54131e-07 -1.10004e-06 -1.48393e-07 -8.92453e-07 -6.84334e-08 -6.60709e-07 -1.78527e-08 -4.08292e-07 -1.39622e-07 -1.89615e-08 1.61298e-07 -7.1994e-08 4.64349e-07 -1.55046e-07 7.43129e-07 -2.63989e-07 9.94289e-07 -3.94702e-07 1.21549e-06 -5.43149e-07 1.40514e-06 -7.05433e-07 1.56235e-06 -8.7785e-07 1.6869e-06 -1.05692e-06 1.77911e-06 -1.23944e-06 1.83982e-06 -1.42246e-06 1.87021e-06 -1.60332e-06 1.87181e-06 -1.77965e-06 1.84636e-06 -1.94934e-06 1.79575e-06 -2.11054e-06 1.72198e-06 -2.26166e-06 1.62708e-06 -2.40129e-06 1.5131e-06 -2.52825e-06 1.38204e-06 -2.64153e-06 1.23589e-06 -2.74024e-06 1.07656e-06 -2.82365e-06 9.05905e-07 -2.89115e-06 7.25743e-07 -2.94221e-06 5.37848e-07 -2.9764e-06 3.43974e-07 -2.99337e-06 1.45877e-07 -2.99286e-06 -5.46644e-08 -2.97469e-06 -2.55824e-07 -2.93878e-06 -4.55704e-07 -2.88515e-06 -6.52321e-07 -2.81396e-06 -8.43578e-07 -2.7255e-06 -1.02727e-06 -2.62024e-06 -1.20105e-06 -2.49885e-06 -1.36247e-06 -2.36223e-06 -1.50899e-06 -2.21154e-06 -1.63795e-06 -2.04823e-06 -1.74669e-06 -1.87407e-06 -1.83255e-06 -1.69116e-06 -1.89292e-06 -1.50194e-06 -1.92536e-06 -1.30922e-06 -1.92766e-06 -1.11615e-06 -1.89793e-06 -9.26173e-07 -1.83472e-06 -7.43057e-07 -1.73708e-06 -5.70786e-07 -1.6047e-06 -4.13524e-07 -1.43796e-06 -2.7553e-07 -1.23803e-06 -1.61078e-07 -1.0069e-06 -7.43666e-08 -7.4742e-07 -1.94239e-08 -4.63235e-07 -1.59046e-07 -2.04105e-08 1.81708e-07 -7.74057e-08 5.21345e-07 -1.66525e-07 8.32248e-07 -2.83222e-07 1.11099e-06 -4.22969e-07 1.35524e-06 -5.81343e-07 1.56351e-06 -7.5409e-07 1.7351e-06 -9.37192e-07 1.87e-06 -1.1269e-06 1.96883e-06 -1.31979e-06 2.0327e-06 -1.51272e-06 2.06315e-06 -1.70293e-06 2.06202e-06 -1.88794e-06 2.03137e-06 -2.0656e-06 1.97341e-06 -2.23404e-06 1.89042e-06 -2.39167e-06 1.78471e-06 -2.53711e-06 1.65854e-06 -2.66922e-06 1.51415e-06 -2.78701e-06 1.35369e-06 -2.88968e-06 1.17922e-06 -2.97652e-06 9.92745e-07 -3.04695e-06 7.96175e-07 -3.10048e-06 5.91376e-07 -3.13669e-06 3.80182e-07 -3.15523e-06 1.64418e-07 -3.15582e-06 -5.40709e-08 -3.13826e-06 -2.73388e-07 -3.1024e-06 -4.91558e-07 -3.04822e-06 -7.06501e-07 -2.97579e-06 -9.16011e-07 -2.88532e-06 -1.11774e-06 -2.77718e-06 -1.30918e-06 -2.65197e-06 -1.48769e-06 -2.5105e-06 -1.65046e-06 -2.35386e-06 -1.79459e-06 -2.18346e-06 -1.91709e-06 -2.00105e-06 -2.01495e-06 -1.80876e-06 -2.0852e-06 -1.60912e-06 -2.125e-06 -1.40504e-06 -2.13173e-06 -1.19987e-06 -2.10311e-06 -9.97316e-07 -2.03728e-06 -8.01441e-07 -1.93296e-06 -6.16606e-07 -1.78953e-06 -4.47392e-07 -1.60717e-06 -2.98523e-07 -1.3869e-06 -1.74757e-07 -1.13067e-06 -8.07875e-08 -8.4139e-07 -2.11319e-08 -5.2289e-07 -1.80177e-07 -2.19564e-08 2.03665e-07 -8.31577e-08 5.82546e-07 -1.78685e-07 9.27776e-07 -3.03528e-07 1.23583e-06 -4.52708e-07 1.50442e-06 -6.21376e-07 1.73218e-06 -8.04892e-07 1.91861e-06 -9.98898e-07 2.064e-06 -1.19936e-06 2.16929e-06 -1.40262e-06 2.23596e-06 -1.60537e-06 2.26591e-06 -1.80472e-06 2.26137e-06 -1.99811e-06 2.22477e-06 -2.18336e-06 2.15867e-06 -2.35861e-06 2.06567e-06 -2.52227e-06 1.94837e-06 -2.67304e-06 1.80931e-06 -2.80981e-06 1.65092e-06 -2.93167e-06 1.47556e-06 -3.03788e-06 1.28543e-06 -3.1278e-06 1.08267e-06 -3.2009e-06 8.69275e-07 -3.25673e-06 6.47201e-07 -3.29488e-06 4.18338e-07 -3.31503e-06 1.84564e-07 -3.31687e-06 -5.22277e-08 -3.30017e-06 -2.90092e-07 -3.26473e-06 -5.26994e-07 -3.21045e-06 -7.6078e-07 -3.13732e-06 -9.89148e-07 -3.04543e-06 -1.20962e-06 -2.93507e-06 -1.41954e-06 -2.80671e-06 -1.61606e-06 -2.66104e-06 -1.79613e-06 -2.49907e-06 -1.95656e-06 -2.32213e-06 -2.09403e-06 -2.13194e-06 -2.20515e-06 -1.93061e-06 -2.28653e-06 -1.72073e-06 -2.33489e-06 -1.50533e-06 -2.34713e-06 -1.28793e-06 -2.32051e-06 -1.07249e-06 -2.25271e-06 -8.63419e-07 -2.14203e-06 -6.65458e-07 -1.9875e-06 -4.83654e-07 -1.78898e-06 -3.23239e-07 -1.54732e-06 -1.89518e-07 -1.26439e-06 -8.77437e-08 -9.43164e-07 -2.29909e-08 -5.87643e-07 -2.03168e-07 -2.36082e-08 2.27273e-07 -8.92793e-08 6.48217e-07 -1.9158e-07 1.03008e-06 -3.24981e-07 1.36923e-06 -4.84001e-07 1.66344e-06 -6.6332e-07 1.9115e-06 -8.57877e-07 2.11317e-06 -1.06295e-06 2.26907e-06 -1.2742e-06 2.38054e-06 -1.48772e-06 2.44948e-06 -1.70006e-06 2.47824e-06 -1.90818e-06 2.46949e-06 -2.10949e-06 2.42607e-06 -2.30178e-06 2.35095e-06 -2.4832e-06 2.2471e-06 -2.65225e-06 2.11741e-06 -2.80766e-06 1.96472e-06 -2.94844e-06 1.7917e-06 -3.07376e-06 1.60087e-06 -3.18295e-06 1.39463e-06 -3.27548e-06 1.17519e-06 -3.35087e-06 9.44666e-07 -3.40873e-06 7.05059e-07 -3.4487e-06 4.58306e-07 -3.47045e-06 2.06314e-07 -3.47368e-06 -4.89991e-08 -3.45811e-06 -3.05662e-07 -3.42349e-06 -5.61606e-07 -3.36965e-06 -8.14626e-07 -3.29645e-06 -1.06234e-06 -3.20389e-06 -1.30218e-06 -3.09211e-06 -1.53132e-06 -2.96143e-06 -1.74674e-06 -2.81242e-06 -1.94513e-06 -2.64596e-06 -2.12303e-06 -2.46325e-06 -2.27673e-06 -2.26594e-06 -2.40246e-06 -2.05611e-06 -2.49636e-06 -1.83637e-06 -2.55463e-06 -1.60985e-06 -2.57365e-06 -1.38023e-06 -2.55013e-06 -1.15173e-06 -2.48121e-06 -9.29087e-07 -2.36467e-06 -7.17478e-07 -2.1991e-06 -5.2245e-07 -1.98401e-06 -3.49801e-07 -1.71996e-06 -2.05448e-07 -1.40874e-06 -9.52826e-08 -1.05333e-06 -2.50155e-08 -6.5791e-07 -2.28184e-07 -2.53754e-08 2.52648e-07 -9.58016e-08 7.18643e-07 -2.05266e-07 1.13954e-06 -3.47654e-07 1.51162e-06 -5.16923e-07 1.83271e-06 -7.0723e-07 2.1018e-06 -9.1305e-07 2.31899e-06 -1.12927e-06 2.48529e-06 -1.35122e-06 2.6025e-06 -1.57477e-06 2.67303e-06 -1.79629e-06 2.69975e-06 -2.01264e-06 2.68584e-06 -2.22118e-06 2.63462e-06 -2.41974e-06 2.54951e-06 -2.60651e-06 2.43387e-06 -2.78005e-06 2.29096e-06 -2.93923e-06 2.1239e-06 -3.08315e-06 1.93562e-06 -3.21111e-06 1.72883e-06 -3.32256e-06 1.50608e-06 -3.41706e-06 1.26969e-06 -3.49423e-06 1.02184e-06 -3.55376e-06 7.64584e-07 -3.59532e-06 4.99871e-07 -3.61862e-06 2.29616e-07 -3.62336e-06 -4.42675e-08 -3.60921e-06 -3.19811e-07 -3.57587e-06 -5.94939e-07 -3.52307e-06 -8.67426e-07 -3.45057e-06 -1.13484e-06 -3.35822e-06 -1.39453e-06 -3.246e-06 -1.64355e-06 -3.11406e-06 -1.87868e-06 -2.96279e-06 -2.0964e-06 -2.7929e-06 -2.29292e-06 -2.60545e-06 -2.46419e-06 -2.40195e-06 -2.60596e-06 -2.18442e-06 -2.71388e-06 -1.95545e-06 -2.7836e-06 -1.71822e-06 -2.81088e-06 -1.47656e-06 -2.79178e-06 -1.23496e-06 -2.72281e-06 -9.98479e-07 -2.60115e-06 -7.72762e-07 -2.42482e-06 -5.63901e-07 -2.19287e-06 -3.78322e-07 -1.90554e-06 -2.22634e-07 -1.56443e-06 -1.03453e-07 -1.17251e-06 -2.72207e-08 -7.34142e-07 -2.55404e-07 -2.72688e-08 2.79917e-07 -1.02759e-07 7.94134e-07 -2.19803e-07 1.25658e-06 -3.71624e-07 1.66344e-06 -5.51547e-07 2.01263e-06 -7.53146e-07 2.3034e-06 -9.70387e-07 2.53623e-06 -1.19772e-06 2.71262e-06 -1.43017e-06 2.83494e-06 -1.66332e-06 2.90619e-06 -1.8934e-06 2.92983e-06 -2.1172e-06 2.90964e-06 -2.33207e-06 2.84949e-06 -2.53586e-06 2.7533e-06 -2.72687e-06 2.62487e-06 -2.90378e-06 2.46787e-06 -3.06558e-06 2.28571e-06 -3.21155e-06 2.08158e-06 -3.34111e-06 1.8584e-06 -3.45388e-06 1.61885e-06 -3.54955e-06 1.36535e-06 -3.62785e-06 1.10014e-06 -3.68855e-06 8.25283e-07 -3.7314e-06 5.42726e-07 -3.75614e-06 2.54358e-07 -3.76247e-06 -3.79419e-08 -3.75004e-06 -3.32241e-07 -3.71848e-06 -6.26495e-07 -3.66742e-06 -9.18486e-07 -3.5965e-06 -1.20577e-06 -3.50539e-06 -1.48563e-06 -3.3939e-06 -1.75504e-06 -3.26197e-06 -2.0106e-06 -3.10979e-06 -2.24858e-06 -2.93783e-06 -2.46488e-06 -2.74696e-06 -2.65506e-06 -2.53851e-06 -2.81441e-06 -2.31438e-06 -2.93802e-06 -2.07708e-06 -3.0209e-06 -1.82982e-06 -3.05814e-06 -1.57656e-06 -3.04504e-06 -1.32199e-06 -2.97738e-06 -1.07156e-06 -2.85159e-06 -8.31367e-07 -2.66501e-06 -6.0811e-07 -2.41612e-06 -4.08913e-07 -2.10474e-06 -2.41163e-07 -1.73218e-06 -1.12304e-07 -1.30137e-06 -2.96227e-08 -8.16823e-07 -2.85027e-07 -2.93016e-08 3.09219e-07 -1.10194e-07 8.75026e-07 -2.35262e-07 1.38165e-06 -3.96979e-07 1.82516e-06 -5.87952e-07 2.2036e-06 -8.01103e-07 2.51655e-06 -1.02983e-06 2.76496e-06 -1.26814e-06 2.95093e-06 -1.51067e-06 3.07747e-06 -1.7528e-06 3.14832e-06 -1.99059e-06 3.16763e-06 -2.22079e-06 3.13984e-06 -2.44077e-06 3.06947e-06 -2.64846e-06 2.96099e-06 -2.8423e-06 2.81871e-06 -3.02113e-06 2.6467e-06 -3.18414e-06 2.44871e-06 -3.33077e-06 2.22821e-06 -3.46066e-06 1.98829e-06 -3.57359e-06 1.73178e-06 -3.66941e-06 1.46117e-06 -3.74801e-06 1.17873e-06 -3.80925e-06 8.86526e-07 -3.85298e-06 5.86457e-07 -3.87898e-06 2.80356e-07 -3.88695e-06 -2.99674e-08 -3.87654e-06 -3.42656e-07 -3.8473e-06 -6.5573e-07 -3.79876e-06 -9.67026e-07 -3.73041e-06 -1.27412e-06 -3.64176e-06 -1.57429e-06 -3.53239e-06 -1.86441e-06 -3.402e-06 -2.14099e-06 -3.25053e-06 -2.40006e-06 -3.07818e-06 -2.63723e-06 -2.88555e-06 -2.84768e-06 -2.67375e-06 -3.02621e-06 -2.44447e-06 -3.1673e-06 -2.20011e-06 -3.26527e-06 -1.94383e-06 -3.31441e-06 -1.67968e-06 -3.3092e-06 -1.41254e-06 -3.24451e-06 -1.14821e-06 -3.11591e-06 -8.93308e-07 -2.91992e-06 -6.55162e-07 -2.65427e-06 -4.41678e-07 -2.31822e-06 -2.61124e-07 -1.91274e-06 -1.21892e-07 -1.4406e-06 -3.22395e-08 -9.06475e-07 -3.17267e-07 -3.149e-08 3.40709e-07 -1.18157e-07 9.61693e-07 -2.51731e-07 1.51523e-06 -4.23826e-07 1.99725e-06 -6.26231e-07 2.40601e-06 -8.51136e-07 2.74146e-06 -1.09132e-06 3.00514e-06 -1.34026e-06 3.19988e-06 -1.59228e-06 3.32949e-06 -1.84248e-06 3.39852e-06 -2.08683e-06 3.41197e-06 -2.32205e-06 3.37505e-06 -2.54558e-06 3.293e-06 -2.75549e-06 3.17091e-06 -2.95041e-06 3.01363e-06 -3.12939e-06 2.82568e-06 -3.29185e-06 2.61117e-06 -3.43748e-06 2.37383e-06 -3.56613e-06 2.11695e-06 -3.67781e-06 1.84346e-06 -3.77256e-06 1.55592e-06 -3.85042e-06 1.2566e-06 -3.91142e-06 9.47524e-07 -3.95549e-06 6.30526e-07 -3.98247e-06 3.0734e-07 -3.99211e-06 -2.03365e-08 -3.984e-06 -3.50762e-07 -3.95766e-06 -6.82069e-07 -3.9125e-06 -1.01219e-06 -3.84785e-06 -1.33877e-06 -3.76304e-06 -1.6591e-06 -3.65739e-06 -1.97006e-06 -3.53035e-06 -2.26803e-06 -3.38153e-06 -2.54888e-06 -3.21081e-06 -2.80795e-06 -3.01848e-06 -3.04001e-06 -2.80533e-06 -3.23936e-06 -2.57279e-06 -3.39984e-06 -2.32304e-06 -3.51502e-06 -2.05915e-06 -3.5783e-06 -1.78517e-06 -3.58319e-06 -1.50616e-06 -3.52353e-06 -1.22824e-06 -3.39383e-06 -9.58556e-07 -3.1896e-06 -7.05129e-07 -2.9077e-06 -4.76728e-07 -2.54662e-06 -2.82618e-07 -2.10685e-06 -1.32277e-07 -1.59094e-06 -3.50917e-08 -1.00366e-06 -3.52358e-07 -3.38551e-08 3.74564e-07 -1.26715e-07 1.05455e-06 -2.69323e-07 1.65783e-06 -4.52301e-07 2.18023e-06 -6.66502e-07 2.62021e-06 -9.03285e-07 2.97824e-06 -1.15473e-06 3.25659e-06 -1.41381e-06 3.45895e-06 -1.67442e-06 3.59011e-06 -1.93149e-06 3.65559e-06 -2.18088e-06 3.66136e-06 -2.41935e-06 3.61352e-06 -2.64448e-06 3.51812e-06 -2.85453e-06 3.38097e-06 -3.04838e-06 3.20748e-06 -3.22535e-06 3.00265e-06 -3.38516e-06 2.77098e-06 -3.52776e-06 2.51643e-06 -3.65331e-06 2.2425e-06 -3.76205e-06 1.9522e-06 -3.85426e-06 1.64813e-06 -3.93018e-06 1.33252e-06 -3.98997e-06 1.00732e-06 -4.03371e-06 6.74265e-07 -4.06131e-06 3.34944e-07 -4.07255e-06 -9.09951e-09 -4.06703e-06 -3.56285e-07 -4.04419e-06 -7.04907e-07 -4.00334e-06 -1.05304e-06 -3.94365e-06 -1.39846e-06 -3.86423e-06 -1.73852e-06 -3.76415e-06 -2.07014e-06 -3.64253e-06 -2.38965e-06 -3.49864e-06 -2.69278e-06 -3.33198e-06 -2.97461e-06 -3.14244e-06 -3.22955e-06 -2.93041e-06 -3.45138e-06 -2.69696e-06 -3.63329e-06 -2.44399e-06 -3.76799e-06 -2.17437e-06 -3.84793e-06 -1.89206e-06 -3.8655e-06 -1.60224e-06 -3.81334e-06 -1.31135e-06 -3.68472e-06 -1.02703e-06 -3.47392e-06 -7.58068e-07 -3.17666e-06 -5.14178e-07 -2.79051e-06 -3.05755e-07 -2.31527e-06 -1.43532e-07 -1.75317e-06 -3.82037e-08 -1.10899e-06 -3.90562e-07 -3.64246e-08 4.10989e-07 -1.35953e-07 1.15408e-06 -2.88182e-07 1.81006e-06 -4.82578e-07 2.37463e-06 -7.08915e-07 2.84654e-06 -9.57607e-07 3.22693e-06 -1.21997e-06 3.51895e-06 -1.48839e-06 3.72737e-06 -1.75641e-06 3.85813e-06 -2.01875e-06 3.91793e-06 -2.27124e-06 3.91385e-06 -2.51076e-06 3.85304e-06 -2.73507e-06 3.74243e-06 -2.94272e-06 3.58862e-06 -3.1329e-06 3.39766e-06 -3.30528e-06 3.17504e-06 -3.45993e-06 2.92562e-06 -3.59714e-06 2.65365e-06 -3.7174e-06 2.36276e-06 -3.82123e-06 2.05603e-06 -3.90918e-06 1.73607e-06 -3.9817e-06 1.40504e-06 -4.03916e-06 1.06478e-06 -4.08175e-06 7.16857e-07 -4.1095e-06 3.62693e-07 -4.12222e-06 3.62391e-09 -4.11953e-06 -3.58981e-07 -4.10081e-06 -7.23627e-07 -4.06526e-06 -1.08859e-06 -4.01189e-06 -1.45182e-06 -3.93959e-06 -1.81083e-06 -3.84714e-06 -2.16259e-06 -3.73332e-06 -2.50347e-06 -3.59699e-06 -2.8291e-06 -3.43723e-06 -3.13437e-06 -3.25343e-06 -3.41335e-06 -3.04552e-06 -3.6593e-06 -2.81409e-06 -3.86471e-06 -2.56063e-06 -4.02145e-06 -2.28769e-06 -4.12086e-06 -1.99908e-06 -4.15411e-06 -1.7e-06 -4.11242e-06 -1.39712e-06 -3.9876e-06 -1.0986e-06 -3.77244e-06 -8.14025e-07 -3.46124e-06 -5.54155e-07 -3.05038e-06 -3.30668e-07 -2.53876e-06 -1.55743e-07 -1.92809e-06 -4.16053e-08 -1.22313e-06 -4.32167e-07 -3.92353e-08 4.50224e-07 -1.45987e-07 1.26083e-06 -3.08502e-07 1.97258e-06 -5.14891e-07 2.58102e-06 -7.53671e-07 3.08532e-06 -1.01418e-06 3.48744e-06 -1.28688e-06 3.79165e-06 -1.56355e-06 4.00404e-06 -1.83739e-06 4.13196e-06 -2.10294e-06 4.18349e-06 -2.35611e-06 4.16702e-06 -2.59393e-06 4.09086e-06 -2.81447e-06 3.96298e-06 -3.01666e-06 3.79081e-06 -3.20009e-06 3.58108e-06 -3.36485e-06 3.3398e-06 -3.51141e-06 3.07219e-06 -3.64049e-06 2.78273e-06 -3.75293e-06 2.47519e-06 -3.84958e-06 2.15269e-06 -3.93129e-06 1.81777e-06 -3.99876e-06 1.47251e-06 -4.05255e-06 1.11857e-06 -4.09303e-06 7.57341e-07 -4.12034e-06 3.89998e-07 -4.13435e-06 1.76344e-08 -4.13469e-06 -3.58644e-07 -4.1207e-06 -7.37611e-07 -4.09149e-06 -1.1178e-06 -4.04591e-06 -1.4974e-06 -3.98261e-06 -1.87413e-06 -3.90007e-06 -2.24513e-06 -3.79671e-06 -2.60682e-06 -3.67095e-06 -2.95486e-06 -3.52135e-06 -3.28397e-06 -3.34677e-06 -3.58793e-06 -3.14653e-06 -3.85953e-06 -2.92066e-06 -4.09059e-06 -2.67009e-06 -4.27202e-06 -2.39693e-06 -4.39403e-06 -2.10466e-06 -4.44637e-06 -1.7984e-06 -4.41868e-06 -1.48499e-06 -4.30101e-06 -1.17308e-06 -4.08435e-06 -8.73037e-07 -3.76128e-06 -5.96808e-07 -3.32661e-06 -3.57516e-07 -2.77805e-06 -1.69017e-07 -2.11659e-06 -4.5334e-08 -1.34681e-06 -4.77501e-07 -4.23367e-08 4.92561e-07 -1.5697e-07 1.37547e-06 -3.30538e-07 2.14615e-06 -5.49543e-07 2.80002e-06 -8.0103e-07 3.33681e-06 -1.0731e-06 3.75952e-06 -1.35529e-06 4.07384e-06 -1.63874e-06 4.28749e-06 -1.9163e-06 4.40952e-06 -2.18247e-06 4.44966e-06 -2.43327e-06 4.41782e-06 -2.66606e-06 4.32364e-06 -2.8793e-06 4.17623e-06 -3.0724e-06 3.98391e-06 -3.24544e-06 3.75413e-06 -3.39905e-06 3.49341e-06 -3.53418e-06 3.20732e-06 -3.65199e-06 2.90054e-06 -3.75373e-06 2.57693e-06 -3.84064e-06 2.2396e-06 -3.91388e-06 1.891e-06 -3.97442e-06 1.53305e-06 -4.02305e-06 1.1672e-06 -4.06031e-06 7.94603e-07 -4.08646e-06 4.16152e-07 -4.10147e-06 3.26443e-08 -4.10499e-06 -3.55129e-07 -4.09634e-06 -7.46262e-07 -4.07453e-06 -1.13961e-06 -4.03826e-06 -1.53367e-06 -3.98596e-06 -1.92643e-06 -3.91582e-06 -2.31527e-06 -3.82585e-06 -2.69679e-06 -3.714e-06 -3.0667e-06 -3.57829e-06 -3.41969e-06 -3.41692e-06 -3.7493e-06 -3.22853e-06 -4.04792e-06 -3.01244e-06 -4.30668e-06 -2.76888e-06 -4.51558e-06 -2.49932e-06 -4.66358e-06 -2.2068e-06 -4.73889e-06 -1.89615e-06 -4.72934e-06 -1.57425e-06 -4.62291e-06 -1.25017e-06 -4.40843e-06 -9.35135e-07 -4.07632e-06 -6.42318e-07 -3.61943e-06 -3.865e-07 -3.03387e-06 -1.83491e-07 -2.3196e-06 -4.94377e-08 -1.48086e-06 -5.26939e-07 -4.57955e-08 5.38356e-07 -1.69105e-07 1.49877e-06 -3.54629e-07 2.33167e-06 -5.86933e-07 3.03233e-06 -8.5133e-07 3.60121e-06 -1.13451e-06 4.0427e-06 -1.42497e-06 4.36429e-06 -1.71321e-06 4.57574e-06 -1.99183e-06 4.68814e-06 -2.25535e-06 4.71318e-06 -2.50006e-06 4.66253e-06 -2.72376e-06 4.54734e-06 -2.92549e-06 4.37795e-06 -3.10523e-06 4.16365e-06 -3.26371e-06 3.9126e-06 -3.40213e-06 3.63182e-06 -3.52201e-06 3.3272e-06 -3.62502e-06 3.00356e-06 -3.71288e-06 2.66479e-06 -3.78722e-06 2.31394e-06 -3.84952e-06 1.9533e-06 -3.90106e-06 1.58459e-06 -3.94286e-06 1.20901e-06 -3.97565e-06 8.27392e-07 -3.99983e-06 4.40332e-07 -4.01546e-06 4.82726e-08 -4.02223e-06 -3.48358e-07 -4.01947e-06 -7.49028e-07 -4.00611e-06 -1.15297e-06 -3.98072e-06 -1.55905e-06 -3.94152e-06 -1.96563e-06 -3.8864e-06 -2.37039e-06 -3.81299e-06 -2.77021e-06 -3.71873e-06 -3.16096e-06 -3.60104e-06 -3.53738e-06 -3.45741e-06 -3.89293e-06 -3.2857e-06 -4.21963e-06 -3.08436e-06 -4.50803e-06 -2.85274e-06 -4.74719e-06 -2.59151e-06 -4.92481e-06 -2.30299e-06 -5.02741e-06 -1.99155e-06 -5.04078e-06 -1.66394e-06 -4.95052e-06 -1.32953e-06 -4.74284e-06 -1.00034e-06 -4.40551e-06 -6.90904e-07 -3.92886e-06 -4.17876e-07 -3.30689e-06 -1.99341e-07 -2.53814e-06 -5.39792e-08 -1.62622e-06 -5.80918e-07 -4.97018e-08 5.88058e-07 -1.82666e-07 1.63174e-06 -3.81219e-07 2.53022e-06 -6.27577e-07 3.27868e-06 -9.04993e-07 3.87862e-06 -1.19853e-06 4.33624e-06 -1.49557e-06 4.66133e-06 -1.78602e-06 4.86618e-06 -2.06227e-06 4.96439e-06 -2.31906e-06 4.96997e-06 -2.55314e-06 4.89661e-06 -2.76293e-06 4.75713e-06 -2.94817e-06 4.5632e-06 -3.10963e-06 4.32511e-06 -3.24875e-06 4.05172e-06 -3.36743e-06 3.75051e-06 -3.46783e-06 3.4276e-06 -3.55218e-06 3.08791e-06 -3.62267e-06 2.73529e-06 -3.68136e-06 2.37263e-06 -3.73008e-06 2.00202e-06 -3.77039e-06 1.6249e-06 -3.80356e-06 1.24218e-06 -3.83051e-06 8.54341e-07 -3.85179e-06 4.6161e-07 -3.86756e-06 6.40437e-08 -3.87758e-06 -3.38337e-07 -3.88119e-06 -7.45421e-07 -3.87728e-06 -1.15688e-06 -3.86433e-06 -1.57201e-06 -3.84035e-06 -1.9896e-06 -3.80298e-06 -2.40776e-06 -3.74946e-06 -2.82373e-06 -3.67674e-06 -3.23368e-06 -3.58159e-06 -3.63253e-06 -3.46076e-06 -4.01376e-06 -3.31121e-06 -4.36918e-06 -3.13037e-06 -4.68887e-06 -2.91654e-06 -4.96102e-06 -2.66933e-06 -5.17202e-06 -2.3901e-06 -5.30665e-06 -2.08247e-06 -5.3484e-06 -1.75282e-06 -5.28017e-06 -1.41062e-06 -5.08504e-06 -1.06864e-06 -4.74749e-06 -7.42843e-07 -4.25466e-06 -4.51973e-07 -3.59776e-06 -2.168e-07 -2.77331e-06 -5.90416e-08 -1.78398e-06 -6.3996e-07 -5.41781e-08 6.42236e-07 -1.98021e-07 1.77558e-06 -4.10896e-07 2.7431e-06 -6.72136e-07 3.53993e-06 -9.62529e-07 4.16901e-06 -1.26528e-06 4.63899e-06 -1.5666e-06 4.96265e-06 -1.85583e-06 5.15542e-06 -2.1254e-06 5.23396e-06 -2.37043e-06 5.215e-06 -2.58837e-06 5.11454e-06 -2.77849e-06 4.94726e-06 -2.94149e-06 4.72619e-06 -3.07901e-06 4.46263e-06 -3.19339e-06 4.1661e-06 -3.28731e-06 3.84442e-06 -3.36361e-06 3.5039e-06 -3.42512e-06 3.14942e-06 -3.47454e-06 2.7847e-06 -3.51433e-06 2.41242e-06 -3.54667e-06 2.03436e-06 -3.57343e-06 1.65166e-06 -3.59608e-06 1.26483e-06 -3.61573e-06 8.73998e-07 -3.6331e-06 4.78974e-07 -3.64845e-06 7.93936e-08 -3.66162e-06 -3.25165e-07 -3.67199e-06 -7.35051e-07 -3.67845e-06 -1.15041e-06 -3.67941e-06 -1.57105e-06 -3.67274e-06 -1.99626e-06 -3.65586e-06 -2.42465e-06 -3.62565e-06 -2.85394e-06 -3.5786e-06 -3.28073e-06 -3.51084e-06 -3.70029e-06 -3.41832e-06 -4.10627e-06 -3.29702e-06 -4.49048e-06 -3.14324e-06 -4.84265e-06 -2.95403e-06 -5.15023e-06 -2.72764e-06 -5.39841e-06 -2.46417e-06 -5.57012e-06 -2.16615e-06 -5.64642e-06 -1.83924e-06 -5.60708e-06 -1.49275e-06 -5.43153e-06 -1.14002e-06 -5.10022e-06 -7.98474e-07 -4.59621e-06 -4.89221e-07 -3.90702e-06 -2.36176e-07 -3.02635e-06 -6.47369e-08 -1.95542e-06 -7.04697e-07 -5.9392e-08 7.01628e-07 -2.15659e-07 1.93185e-06 -4.44427e-07 2.97187e-06 -7.21441e-07 3.81694e-06 -1.02453e-06 4.4721e-06 -1.33479e-06 4.94926e-06 -1.63723e-06 5.26509e-06 -1.92081e-06 5.439e-06 -2.17821e-06 5.49136e-06 -2.40529e-06 5.44208e-06 -2.60048e-06 5.30974e-06 -2.76421e-06 5.11099e-06 -2.89832e-06 4.86029e-06 -3.00556e-06 4.56987e-06 -3.08925e-06 4.24979e-06 -3.15294e-06 3.90812e-06 -3.20022e-06 3.55117e-06 -3.23451e-06 3.18372e-06 -3.25901e-06 2.80921e-06 -3.27659e-06 2.42999e-06 -3.28974e-06 2.04751e-06 -3.30057e-06 1.66249e-06 -3.31079e-06 1.27505e-06 -3.32167e-06 8.84879e-07 -3.33406e-06 4.91362e-07 -3.34835e-06 9.36837e-08 -3.36447e-06 -3.09041e-07 -3.38187e-06 -7.17651e-07 -3.39948e-06 -1.13281e-06 -3.41567e-06 -1.55486e-06 -3.42827e-06 -1.98366e-06 -3.43451e-06 -2.41842e-06 -3.431e-06 -2.85744e-06 -3.41381e-06 -3.29792e-06 -3.37847e-06 -3.73562e-06 -3.32014e-06 -4.16461e-06 -3.23376e-06 -4.57686e-06 -3.11439e-06 -4.96202e-06 -2.9576e-06 -5.30702e-06 -2.76005e-06 -5.59596e-06 -2.52017e-06 -5.81e-06 -2.23899e-06 -5.9276e-06 -1.92098e-06 -5.92509e-06 -1.57488e-06 -5.77763e-06 -1.21435e-06 -5.46075e-06 -8.58215e-07 -4.95235e-06 -5.30183e-07 -4.23505e-06 -2.57885e-07 -3.29865e-06 -7.12182e-08 -2.14209e-06 -7.75915e-07 -6.55749e-08 7.67203e-07 -2.36244e-07 2.10252e-06 -4.82812e-07 3.21843e-06 -7.76512e-07 4.11064e-06 -1.09161e-06 4.7872e-06 -1.40687e-06 5.26451e-06 -1.70614e-06 5.56436e-06 -1.97829e-06 5.71115e-06 -2.21663e-06 5.7297e-06 -2.41817e-06 5.64362e-06 -2.58275e-06 5.47432e-06 -2.71227e-06 5.24051e-06 -2.80997e-06 4.95799e-06 -2.8799e-06 4.6398e-06 -2.92647e-06 4.29636e-06 -2.95417e-06 3.93582e-06 -2.96733e-06 3.56433e-06 -2.96995e-06 3.18635e-06 -2.96571e-06 2.80496e-06 -2.95781e-06 2.42209e-06 -2.94902e-06 2.03873e-06 -2.94166e-06 1.65514e-06 -2.93761e-06 1.27099e-06 -2.93827e-06 8.85541e-07 -2.94462e-06 4.97708e-07 -2.95716e-06 1.06225e-07 -2.97593e-06 -2.90268e-07 -3.00047e-06 -6.93107e-07 -3.0298e-06 -1.10349e-06 -3.06234e-06 -1.52232e-06 -3.09591e-06 -1.95009e-06 -3.12766e-06 -2.38666e-06 -3.15405e-06 -2.83105e-06 -3.1708e-06 -3.28117e-06 -3.17294e-06 -3.73349e-06 -3.15486e-06 -4.18268e-06 -3.11049e-06 -4.62123e-06 -3.03356e-06 -5.03895e-06 -2.918e-06 -5.42258e-06 -2.75859e-06 -5.75538e-06 -2.55168e-06 -6.0169e-06 -2.29625e-06 -6.18302e-06 -1.99501e-06 -6.22633e-06 -1.65555e-06 -6.11709e-06 -1.29138e-06 -5.82492e-06 -9.22555e-07 -5.32117e-06 -5.75591e-07 -4.58201e-06 -2.82487e-07 -3.59176e-06 -7.86971e-08 -2.34588e-06 -8.54612e-07 -7.30501e-08 8.40253e-07 -2.60673e-07 2.29014e-06 -5.27347e-07 3.48511e-06 -8.38573e-07 4.42186e-06 -1.16435e-06 5.11298e-06 -1.4809e-06 5.58107e-06 -1.77116e-06 5.85462e-06 -2.02434e-06 5.96432e-06 -2.23497e-06 5.94033e-06 -2.40178e-06 5.81042e-06 -2.52649e-06 5.59903e-06 -2.61285e-06 5.32687e-06 -2.66579e-06 5.01094e-06 -2.69081e-06 4.66482e-06 -2.69352e-06 4.29907e-06 -2.67932e-06 3.92163e-06 -2.65327e-06 3.53827e-06 -2.61991e-06 3.15299e-06 -2.58329e-06 2.76834e-06 -2.54689e-06 2.38568e-06 -2.51366e-06 2.0055e-06 -2.48607e-06 1.62754e-06 -2.46608e-06 1.25101e-06 -2.45521e-06 8.74668e-07 -2.45451e-06 4.9701e-07 -2.46459e-06 1.16312e-07 -2.48562e-06 -2.69246e-07 -2.51724e-06 -6.61484e-07 -2.5586e-06 -1.06212e-06 -2.60826e-06 -1.47266e-06 -2.66413e-06 -1.89422e-06 -2.72341e-06 -2.32739e-06 -2.78249e-06 -2.77197e-06 -2.83693e-06 -3.22673e-06 -2.88137e-06 -3.68905e-06 -2.90957e-06 -4.15448e-06 -2.91451e-06 -4.61629e-06 -2.88858e-06 -5.06488e-06 -2.82397e-06 -5.48719e-06 -2.71328e-06 -5.86607e-06 -2.55038e-06 -6.1798e-06 -2.33159e-06 -6.40181e-06 -2.05709e-06 -6.50083e-06 -1.73252e-06 -6.44166e-06 -1.37055e-06 -6.1869e-06 -9.92033e-07 -5.69969e-06 -6.26397e-07 -4.94765e-06 -3.10753e-07 -3.9074e-06 -8.74723e-08 -2.56916e-06 -9.42084e-07 -8.22772e-08 9.2253e-07 -2.9017e-07 2.49803e-06 -5.79694e-07 3.77463e-06 -9.09009e-07 4.75118e-06 -1.24305e-06 5.44702e-06 -1.55547e-06 5.89348e-06 -1.82873e-06 6.12788e-06 -2.05315e-06 6.18874e-06 -2.22529e-06 6.11247e-06 -2.3463e-06 5.93143e-06 -2.42039e-06 5.67312e-06 -2.45356e-06 5.36004e-06 -2.45269e-06 5.01007e-06 -2.42484e-06 4.63697e-06 -2.37684e-06 4.25106e-06 -2.31498e-06 3.85977e-06 -2.24493e-06 3.46823e-06 -2.17168e-06 3.07974e-06 -2.09949e-06 2.69615e-06 -2.03202e-06 2.31821e-06 -1.9723e-06 1.94578e-06 -1.92281e-06 1.57806e-06 -1.88556e-06 1.21375e-06 -1.86207e-06 8.51184e-07 -1.85347e-06 4.88403e-07 -1.86043e-06 1.23271e-07 -1.88322e-06 -2.46455e-07 -1.92165e-06 -6.23048e-07 -1.97506e-06 -1.00872e-06 -2.04219e-06 -1.40553e-06 -2.12116e-06 -1.81524e-06 -2.20937e-06 -2.23919e-06 -2.30332e-06 -2.67802e-06 -2.39857e-06 -3.13148e-06 -2.48959e-06 -3.59802e-06 -2.56972e-06 -4.07435e-06 -2.63114e-06 -4.55487e-06 -2.665e-06 -5.03102e-06 -2.66173e-06 -5.49046e-06 -2.61157e-06 -5.91623e-06 -2.50549e-06 -6.28588e-06 -2.33647e-06 -6.57083e-06 -2.10125e-06 -6.73605e-06 -1.80243e-06 -6.74048e-06 -1.45076e-06 -6.53856e-06 -1.06716e-06 -6.08329e-06 -6.83824e-07 -5.33099e-06 -3.43742e-07 -4.24748e-06 -9.79729e-08 -2.81493e-06 -1.04006e-06 -9.39238e-08 1.01645e-06 -3.26414e-07 2.73052e-06 -6.41954e-07 4.09017e-06 -9.89261e-07 5.09849e-06 -1.32741e-06 5.78517e-06 -1.62771e-06 6.19379e-06 -1.87309e-06 6.37326e-06 -2.05609e-06 6.37174e-06 -2.17639e-06 6.23277e-06 -2.23849e-06 5.99353e-06 -2.24972e-06 5.68434e-06 -2.21874e-06 5.32907e-06 -2.15458e-06 4.9459e-06 -2.06589e-06 4.54828e-06 -1.96063e-06 4.1458e-06 -1.84586e-06 3.745e-06 -1.7277e-06 3.35007e-06 -1.61135e-06 2.96339e-06 -1.50119e-06 2.58599e-06 -1.40083e-06 2.21784e-06 -1.31322e-06 1.85817e-06 -1.24078e-06 1.50561e-06 -1.18541e-06 1.15838e-06 -1.1486e-06 8.14376e-07 -1.13146e-06 4.71256e-07 -1.1347e-06 1.26521e-07 -1.15872e-06 -2.22438e-07 -1.20349e-06 -5.7828e-07 -1.26856e-06 -9.43651e-07 -1.35298e-06 -1.32111e-06 -1.45519e-06 -1.71303e-06 -1.57292e-06 -2.12146e-06 -1.70299e-06 -2.54794e-06 -1.84122e-06 -2.99325e-06 -1.98218e-06 -3.45707e-06 -2.11905e-06 -3.93748e-06 -2.24352e-06 -4.4304e-06 -2.34574e-06 -4.9288e-06 -2.41451e-06 -5.4217e-06 -2.43765e-06 -5.89308e-06 -2.40291e-06 -6.32063e-06 -2.29924e-06 -6.6745e-06 -2.11888e-06 -6.91641e-06 -1.86002e-06 -6.99934e-06 -1.52994e-06 -6.86864e-06 -1.14827e-06 -6.46496e-06 -7.49405e-07 -5.72986e-06 -3.82931e-07 -4.61396e-06 -1.10831e-07 -3.08703e-06 -1.15089e-06 -1.08987e-07 1.12544e-06 -3.71739e-07 2.99328e-06 -7.16719e-07 4.43515e-06 -1.08053e-06 5.4623e-06 -1.41578e-06 6.12041e-06 -1.69228e-06 6.47029e-06 -1.89496e-06 6.57595e-06 -2.02027e-06 6.49705e-06 -2.07247e-06 6.28497e-06 -2.06044e-06 5.98151e-06 -1.99529e-06 5.61919e-06 -1.88867e-06 5.22245e-06 -1.75178e-06 4.80901e-06 -1.59479e-06 4.39129e-06 -1.42657e-06 3.97758e-06 -1.25469e-06 3.57311e-06 -1.08543e-06 3.18081e-06 -9.23984e-07 2.80195e-06 -7.74546e-07 2.43655e-06 -6.40506e-07 2.0838e-06 -5.24578e-07 1.74224e-06 -4.28924e-07 1.40996e-06 -3.55259e-07 1.08472e-06 -3.04923e-07 7.6404e-07 -2.78942e-07 4.45276e-07 -2.78056e-07 1.25635e-07 -3.02727e-07 -1.97767e-07 -3.5312e-07 -5.27887e-07 -4.29059e-07 -8.67712e-07 -5.29954e-07 -1.22022e-06 -6.54692e-07 -1.58829e-06 -8.01498e-07 -1.97466e-06 -9.67752e-07 -2.38169e-06 -1.14978e-06 -2.81123e-06 -1.34259e-06 -3.26426e-06 -1.53962e-06 -3.74044e-06 -1.73249e-06 -4.23754e-06 -1.91076e-06 -4.75052e-06 -2.06193e-06 -5.27053e-06 -2.1716e-06 -5.78341e-06 -2.22413e-06 -6.2681e-06 -2.20392e-06 -6.69471e-06 -2.09757e-06 -7.02275e-06 -1.89711e-06 -7.1998e-06 -1.60421e-06 -7.16154e-06 -1.2351e-06 -6.83407e-06 -8.24984e-07 -6.13997e-06 -4.30389e-07 -5.00855e-06 -1.27005e-07 -3.39041e-06 -1.27789e-06 -1.29007e-07 1.25445e-06 -4.29393e-07 3.29366e-06 -8.07006e-07 4.81276e-06 -1.18314e-06 5.83843e-06 -1.5039e-06 6.44118e-06 -1.73955e-06 6.70594e-06 -1.87956e-06 6.71595e-06 -1.92661e-06 6.5441e-06 -1.89132e-06 6.24968e-06 -1.78807e-06 5.87825e-06 -1.63227e-06 5.46339e-06 -1.43866e-06 5.02884e-06 -1.22047e-06 4.59082e-06 -9.89023e-07 4.15984e-06 -7.53727e-07 3.74228e-06 -5.22227e-07 3.34161e-06 -3.00622e-07 2.95921e-06 -9.37157e-08 2.59504e-06 9.47406e-08 2.2481e-06 2.61832e-07 1.91671e-06 4.05297e-07 1.59878e-06 5.23372e-07 1.29189e-06 6.1467e-07 9.93419e-07 6.78093e-07 7.00618e-07 7.12761e-07 4.10607e-07 7.17979e-07 1.20418e-07 6.93217e-07 -1.73005e-07 6.38127e-07 -4.72798e-07 5.52582e-07 -7.82167e-07 4.36744e-07 -1.10438e-06 2.91176e-07 -1.44272e-06 1.16988e-07 -1.80047e-06 -8.39655e-08 -2.18073e-06 -3.08832e-07 -2.58636e-06 -5.53452e-07 -3.01964e-06 -8.11998e-07 -3.4819e-06 -1.07657e-06 -3.97297e-06 -1.33677e-06 -4.49032e-06 -1.57943e-06 -5.02787e-06 -1.78841e-06 -5.57443e-06 -1.94493e-06 -6.11158e-06 -2.02853e-06 -6.61111e-06 -2.01918e-06 -7.03211e-06 -1.90078e-06 -7.31821e-06 -1.66657e-06 -7.39575e-06 -1.32606e-06 -7.17458e-06 -9.12574e-07 -6.55346e-06 -4.89026e-07 -5.4321e-06 -1.47994e-07 -3.73144e-06 -1.42589e-06 -1.56437e-07 1.41089e-06 -5.0389e-07 3.64112e-06 -9.15906e-07 5.22478e-06 -1.29509e-06 6.21762e-06 -1.5826e-06 6.72869e-06 -1.7528e-06 6.87614e-06 -1.80359e-06 6.76673e-06 -1.74701e-06 6.48753e-06 -1.60196e-06 6.10463e-06 -1.38927e-06 5.66557e-06 -1.12885e-06 5.20297e-06 -8.38259e-07 4.73825e-06 -5.32194e-07 4.28476e-06 -2.22525e-07 3.85017e-06 8.14298e-08 3.43833e-06 3.72509e-07 3.05053e-06 6.45306e-07 2.68641e-06 8.95796e-07 2.34455e-06 1.12101e-06 2.02288e-06 1.31877e-06 1.71895e-06 1.48748e-06 1.43007e-06 1.62592e-06 1.15344e-06 1.73317e-06 8.86171e-07 1.80846e-06 6.25328e-07 1.85113e-06 3.67937e-07 1.86058e-06 1.1097e-07 1.83624e-06 -1.48665e-07 1.77759e-06 -4.14149e-07 1.68419e-06 -6.88765e-07 1.55572e-06 -9.75917e-07 1.39213e-06 -1.27913e-06 1.19372e-06 -1.60206e-06 9.61376e-07 -1.94839e-06 6.96829e-07 -2.32182e-06 4.03005e-07 -2.72581e-06 8.44585e-08 -3.16335e-06 -2.52087e-07 -3.63642e-06 -5.97127e-07 -4.14528e-06 -9.37732e-07 -4.68726e-06 -1.25699e-06 -5.25518e-06 -1.53372e-06 -5.83485e-06 -1.7429e-06 -6.40192e-06 -1.85723e-06 -6.91778e-06 -1.85063e-06 -7.32481e-06 -1.70442e-06 -7.54196e-06 -1.41664e-06 -7.46236e-06 -1.01386e-06 -6.95623e-06 -5.62885e-07 -5.88308e-06 -1.76217e-07 -4.11811e-06 -1.6021e-06 -1.95305e-07 1.60619e-06 -6.01339e-07 4.04715e-06 -1.04543e-06 5.66887e-06 -1.40927e-06 6.58146e-06 -1.63363e-06 6.95305e-06 -1.70352e-06 6.94602e-06 -1.63083e-06 6.69405e-06 -1.44059e-06 6.29729e-06 -1.16174e-06 5.82577e-06 -8.21906e-07 5.32574e-06 -4.45032e-07 4.82609e-06 -5.05838e-08 4.3438e-06 3.46273e-07 3.8879e-06 7.34117e-07 3.46232e-06 1.10459e-06 3.06786e-06 1.45173e-06 2.70339e-06 1.77139e-06 2.36675e-06 2.06078e-06 2.05516e-06 2.31805e-06 1.76562e-06 2.54201e-06 1.49499e-06 2.7319e-06 1.24019e-06 2.88721e-06 9.98128e-07 3.00757e-06 7.6581e-07 3.09263e-06 5.40268e-07 3.142e-06 3.18563e-07 3.15522e-06 9.77475e-08 3.13173e-06 -1.25172e-07 3.07085e-06 -3.5327e-07 2.97183e-06 -5.89748e-07 2.83389e-06 -8.37974e-07 2.65628e-06 -1.10152e-06 2.43841e-06 -1.38419e-06 2.18006e-06 -1.69004e-06 1.88159e-06 -2.02335e-06 1.54431e-06 -2.38853e-06 1.17096e-06 -2.79e-06 7.66315e-07 -3.23178e-06 3.37995e-07 -3.71696e-06 -1.02591e-07 -4.24668e-06 -5.39197e-07 -4.81857e-06 -9.49759e-07 -5.42429e-06 -1.30585e-06 -6.04583e-06 -1.57324e-06 -6.65039e-06 -1.71455e-06 -7.1835e-06 -1.69551e-06 -7.561e-06 -1.49633e-06 -7.66154e-06 -1.12883e-06 -7.32373e-06 -6.57366e-07 -6.35454e-06 -2.15676e-07 -4.5598e-06 -1.81778e-06 -2.52325e-07 1.85851e-06 -7.29331e-07 4.52416e-06 -1.19343e-06 6.13297e-06 -1.5075e-06 6.89553e-06 -1.6224e-06 7.06795e-06 -1.54418e-06 6.86781e-06 -1.30588e-06 6.45574e-06 -9.48936e-07 5.94035e-06 -5.13072e-07 5.38991e-06 -3.18865e-08 4.84455e-06 4.68253e-07 4.32595e-06 9.67712e-07 3.84435e-06 1.45247e-06 3.40314e-06 1.91292e-06 3.00188e-06 2.34271e-06 2.63806e-06 2.7379e-06 2.3082e-06 3.09621e-06 2.00844e-06 3.41647e-06 1.7349e-06 3.69827e-06 1.48382e-06 3.94159e-06 1.25167e-06 4.14668e-06 1.0351e-06 4.3138e-06 8.31003e-07 4.44321e-06 6.36403e-07 4.53501e-06 4.48467e-07 4.58914e-06 2.64437e-07 4.6053e-06 8.15853e-08 4.58296e-06 -1.02837e-07 4.52135e-06 -2.91655e-07 4.41943e-06 -4.87828e-07 4.27596e-06 -6.94506e-07 4.08954e-06 -9.15096e-07 3.85868e-06 -1.15333e-06 3.58195e-06 -1.41332e-06 3.25821e-06 -1.6996e-06 2.88687e-06 -2.01719e-06 2.46838e-06 -2.37151e-06 2.00485e-06 -2.76824e-06 1.50092e-06 -3.21303e-06 9.64988e-07 -3.71075e-06 4.10661e-07 -4.26424e-06 -1.41457e-07 -4.87217e-06 -6.62009e-07 -5.52528e-06 -1.11175e-06 -6.20065e-06 -1.4423e-06 -6.85295e-06 -1.60095e-06 -7.40235e-06 -1.54262e-06 -7.71987e-06 -1.2523e-06 -7.61405e-06 -7.78879e-07 -6.82796e-06 -2.7305e-07 -5.06563e-06 -2.09083e-06 -3.38576e-07 2.19709e-06 -8.95038e-07 5.08062e-06 -1.34592e-06 6.58386e-06 -1.54903e-06 7.09863e-06 -1.4855e-06 7.00442e-06 -1.19726e-06 6.57956e-06 -7.45796e-07 6.00428e-06 -1.90585e-07 5.38514e-06 4.19516e-07 4.77981e-06 1.04791e-06 4.21615e-06 1.66892e-06 3.70495e-06 2.26547e-06 3.2478e-06 2.82687e-06 2.84174e-06 3.3469e-06 2.48185e-06 3.82241e-06 2.16255e-06 4.25223e-06 1.87838e-06 4.63643e-06 1.62423e-06 4.97583e-06 1.3955e-06 5.27159e-06 1.18806e-06 5.525e-06 9.98253e-07 5.73732e-06 8.22785e-07 5.90964e-06 6.58685e-07 6.04282e-06 5.03223e-07 6.13744e-06 3.53849e-07 6.19374e-06 2.0813e-07 6.21164e-06 6.36877e-08 6.19066e-06 -8.18568e-08 6.12995e-06 -2.30947e-07 6.02828e-06 -3.86152e-07 5.88401e-06 -5.50239e-07 5.69516e-06 -7.2625e-07 5.45942e-06 -9.17589e-07 5.17423e-06 -1.12812e-06 4.83689e-06 -1.36227e-06 4.44485e-06 -1.62515e-06 3.99597e-06 -1.92263e-06 3.48915e-06 -2.26142e-06 2.92512e-06 -2.649e-06 2.30769e-06 -3.09332e-06 1.64556e-06 -3.60211e-06 9.54701e-07 -4.18131e-06 2.61421e-07 -4.832e-06 -3.94315e-07 -5.54491e-06 -9.56458e-07 -6.29081e-06 -1.35384e-06 -7.00496e-06 -1.50951e-06 -7.5642e-06 -1.36572e-06 -7.75784e-06 -9.3241e-07 -7.26128e-06 -3.59257e-07 -5.63878e-06 -2.45009e-06 -4.70734e-07 2.66782e-06 -1.09711e-06 5.707e-06 -1.45883e-06 6.94558e-06 -1.44819e-06 7.08799e-06 -1.11029e-06 6.66652e-06 -5.39796e-07 6.00907e-06 1.69632e-07 5.29486e-06 9.43885e-07 4.61088e-06 1.73086e-06 3.99284e-06 2.49684e-06 3.45017e-06 3.22164e-06 2.98014e-06 3.89434e-06 2.5751e-06 4.50999e-06 2.22609e-06 5.06739e-06 1.92445e-06 5.5675e-06 1.66244e-06 6.01248e-06 1.43341e-06 6.40502e-06 1.23169e-06 6.74799e-06 1.05253e-06 7.04414e-06 8.91911e-07 7.296e-06 7.46392e-07 7.50577e-06 6.13017e-07 7.67526e-06 4.89192e-07 7.80589e-06 3.72596e-07 7.89863e-06 2.61108e-07 7.95403e-06 1.52735e-07 7.97216e-06 4.55549e-08 7.95265e-06 -6.23441e-08 7.89462e-06 -1.72922e-07 7.79672e-06 -2.88249e-07 7.65705e-06 -4.10574e-07 7.4732e-06 -5.42402e-07 7.24221e-06 -6.86591e-07 6.96055e-06 -8.46465e-07 6.62423e-06 -1.02595e-06 6.22882e-06 -1.22974e-06 5.76968e-06 -1.46349e-06 5.24229e-06 -1.73404e-06 4.64291e-06 -2.04962e-06 3.96958e-06 -2.42e-06 3.2239e-06 -2.85643e-06 2.41364e-06 -3.37104e-06 1.55674e-06 -3.9751e-06 6.86805e-07 -4.67498e-06 -1.40424e-07 -5.46358e-06 -8.41502e-07 -6.30389e-06 -1.3064e-06 -7.0993e-06 -1.41857e-06 -7.64567e-06 -1.11236e-06 -7.56749e-06 -4.90172e-07 -6.26097e-06 -2.94026e-06 -6.65741e-07 3.33356e-06 -1.29822e-06 6.33948e-06 -1.41624e-06 7.0636e-06 -1.03366e-06 6.70541e-06 -3.04115e-07 5.93697e-06 6.15309e-07 5.08965e-06 1.60651e-06 4.30366e-06 2.59344e-06 3.62395e-06 3.53251e-06 3.05376e-06 4.40177e-06 2.58091e-06 5.19248e-06 2.18943e-06 5.9035e-06 1.86408e-06 6.5377e-06 1.59189e-06 7.09988e-06 1.36227e-06 7.59552e-06 1.16681e-06 8.03011e-06 9.9881e-07 8.40883e-06 8.52971e-07 8.73633e-06 7.2503e-07 9.0167e-06 6.1154e-07 9.25343e-06 5.09662e-07 9.44943e-06 4.17022e-07 9.60703e-06 3.31591e-07 9.72803e-06 2.51597e-07 9.81369e-06 1.75445e-07 9.86476e-06 1.01662e-07 9.88148e-06 2.88418e-08 9.86354e-06 -4.44085e-08 9.81013e-06 -1.19512e-07 9.71986e-06 -1.97976e-07 9.59074e-06 -2.81451e-07 9.42013e-06 -3.71798e-07 9.20471e-06 -4.71172e-07 8.94038e-06 -5.8213e-07 8.6222e-06 -7.07769e-07 8.24436e-06 -8.51901e-07 7.80016e-06 -1.01929e-06 7.28209e-06 -1.21597e-06 6.68207e-06 -1.44959e-06 5.99204e-06 -1.72997e-06 5.20516e-06 -2.06955e-06 4.31803e-06 -2.48391e-06 3.33461e-06 -2.99168e-06 2.27281e-06 -3.61318e-06 1.17462e-06 -4.36538e-06 1.19736e-07 -5.24901e-06 -7.61201e-07 -6.21836e-06 -1.28752e-06 -7.11934e-06 -1.27345e-06 -7.58156e-06 -6.79738e-07 -6.85468e-06 -3.62e-06 -9.1472e-07 4.24829e-06 -1.34518e-06 6.76993e-06 -9.40546e-07 6.65897e-06 2.07175e-08 5.74415e-06 1.24573e-06 4.71196e-06 2.5356e-06 3.79978e-06 3.77775e-06 3.0615e-06 4.91939e-06 2.48231e-06 5.94236e-06 2.03079e-06 6.84631e-06 1.67697e-06 7.63901e-06 1.39672e-06 8.33125e-06 1.17185e-06 8.93424e-06 9.88902e-07 9.45847e-06 8.38034e-07 9.91331e-06 7.11971e-07 1.03068e-05 6.05285e-07 1.06459e-05 5.13866e-07 1.09364e-05 4.3455e-07 1.11831e-05 3.64859e-07 1.139e-05 3.02809e-07 1.15602e-05 2.46781e-07 1.16964e-05 1.95419e-07 1.18004e-05 1.47562e-07 1.18737e-05 1.0218e-07 1.1917e-05 5.83339e-08 1.19307e-05 1.51339e-08 1.19146e-05 -2.82946e-08 1.18679e-05 -7.28453e-08 1.17894e-05 -1.19466e-07 1.16772e-05 -1.69201e-07 1.15286e-05 -2.23238e-07 1.13404e-05 -2.82972e-07 1.11084e-05 -3.50084e-07 1.08272e-05 -4.26652e-07 1.04906e-05 -5.15294e-07 1.00907e-05 -6.1938e-07 9.61808e-06 -7.43323e-07 9.06148e-06 -8.92993e-07 8.40782e-06 -1.07632e-06 7.64238e-06 -1.30412e-06 6.74976e-06 -1.59129e-06 5.71632e-06 -1.95825e-06 4.53559e-06 -2.43245e-06 3.21891e-06 -3.0487e-06 1.81474e-06 -3.84484e-06 4.38687e-07 -4.84231e-06 -6.92443e-07 -5.98821e-06 -1.25097e-06 -7.02304e-06 -9.12064e-07 -7.19359e-06 -4.53206e-06 -1.0845e-06 5.33278e-06 -7.59216e-07 6.44465e-06 5.82268e-07 5.31748e-06 2.29483e-06 4.03159e-06 4.00971e-06 2.99707e-06 5.56883e-06 2.24066e-06 6.92519e-06 1.70515e-06 8.08231e-06 1.3252e-06 9.06247e-06 1.05063e-06 9.892e-06 8.47435e-07 1.05954e-05 6.93331e-07 1.11935e-05 5.73698e-07 1.17036e-05 4.78835e-07 1.21395e-05 4.02167e-07 1.25123e-05 3.39135e-07 1.28311e-05 2.86497e-07 1.31031e-05 2.41891e-07 1.33341e-05 2.03554e-07 1.35288e-05 1.70141e-07 1.3691e-05 1.40596e-07 1.38237e-05 1.14078e-07 1.39292e-05 8.98891e-08 1.40094e-05 6.7443e-08 1.40653e-05 4.62253e-08 1.40979e-05 2.57712e-08 1.41074e-05 5.64384e-09 1.40937e-05 -1.45843e-08 1.40562e-05 -3.53497e-08 1.39938e-05 -5.71157e-08 1.3905e-05 -8.03951e-08 1.37875e-05 -1.05776e-07 1.36385e-05 -1.33955e-07 1.34542e-05 -1.65785e-07 1.32299e-05 -2.02331e-07 1.29596e-05 -2.44967e-07 1.26357e-05 -2.95495e-07 1.22487e-05 -3.56344e-07 1.17866e-05 -4.30857e-07 1.1234e-05 -5.23747e-07 1.05717e-05 -6.41831e-07 9.77565e-06 -7.95212e-07 8.81662e-06 -9.99211e-07 7.66162e-06 -1.27745e-06 6.27939e-06 -1.66648e-06 4.65588e-06 -2.22132e-06 2.82944e-06 -3.01587e-06 9.59491e-07 -4.11827e-06 -5.61187e-07 -5.50236e-06 -1.03583e-06 -6.71894e-06 -5.56789e-06 -1.21128e-07 5.45391e-06 1.82684e-06 4.49669e-06 4.40548e-06 2.73883e-06 6.72019e-06 1.71688e-06 8.60145e-06 1.11582e-06 1.00882e-05 7.53946e-07 1.12602e-05 5.33109e-07 1.21916e-05 3.93779e-07 1.29407e-05 3.01573e-07 1.35506e-05 2.37509e-07 1.40529e-05 1.91035e-07 1.44705e-05 1.56077e-07 1.48204e-05 1.28983e-07 1.51151e-05 1.07457e-07 1.53642e-05 8.99953e-08 1.55751e-05 7.55709e-08 1.57536e-05 6.34582e-08 1.5904e-05 5.31284e-08 1.603e-05 4.41851e-08 1.61342e-05 3.6323e-08 1.6219e-05 2.93007e-08 1.6286e-05 2.29217e-08 1.63364e-05 1.70215e-08 1.63712e-05 1.14575e-08 1.63908e-05 6.10177e-09 1.63956e-05 8.35083e-10 1.63855e-05 -4.46071e-09 1.63601e-05 -9.90289e-09 1.63186e-05 -1.56189e-08 1.62599e-05 -2.17491e-08 1.61826e-05 -2.84556e-08 1.60846e-05 -3.59319e-08 1.59632e-05 -4.44168e-08 1.58151e-05 -5.42128e-08 1.56358e-05 -6.5714e-08 1.54198e-05 -7.94472e-08 1.51596e-05 -9.61356e-08 1.48455e-05 -1.16802e-07 1.44647e-05 -1.42938e-07 1.39997e-05 -1.76813e-07 1.34265e-05 -2.22021e-07 1.27118e-05 -2.84542e-07 1.18092e-05 -3.74828e-07 1.06547e-05 -5.11942e-07 9.1646e-06 -7.31234e-07 7.24496e-06 -1.09622e-06 4.8423e-06 -1.71561e-06 2.12505e-06 -2.78511e-06 1.12964e-08 -4.60519e-06 -5.5566e-06 5.45391e-06 9.9506e-06 1.26894e-05 1.44063e-05 1.55221e-05 1.62761e-05 1.68092e-05 1.7203e-05 1.75045e-05 1.7742e-05 1.79331e-05 1.80892e-05 1.82181e-05 1.83256e-05 1.84156e-05 1.84912e-05 1.85546e-05 1.86078e-05 1.86519e-05 1.86883e-05 1.87176e-05 1.87405e-05 1.87575e-05 1.8769e-05 1.87751e-05 1.87759e-05 1.87714e-05 1.87615e-05 1.87459e-05 1.87242e-05 1.86957e-05 1.86598e-05 1.86154e-05 1.85612e-05 1.84954e-05 1.8416e-05 1.83199e-05 1.82031e-05 1.80601e-05 1.78833e-05 1.76613e-05 1.73767e-05 1.70019e-05 1.649e-05 1.57587e-05 1.46625e-05 1.29469e-05 1.01618e-05 5.5566e-06 ) ; boundaryField { movingWall { type calculated; value uniform 0; } fixedWalls { type calculated; value uniform 0; } frontAndBack { type empty; value nonuniform 0(); } } // ************************************************************************* //
c72eae53da30ede1e06ea22b2ade91467e86a2d6
41c46297d9303f54fb390050f550379649313979
/20190508/Maximal Continuous Rest.cpp
26d238d1896c04bb24f49e5145f9a0325a778b37
[]
no_license
SketchAlgorithm/17_Jo-Wonbin
f48d6c51026d08bd4eeb13448e35d8566660ad40
75231bf4a0fb62518f687c62c752f5efb7c49478
refs/heads/master
2020-04-23T00:30:30.618376
2020-02-18T09:02:46
2020-02-18T09:02:46
170,782,242
1
0
null
null
null
null
UTF-8
C++
false
false
355
cpp
//https://codeforces.com/contest/1141/problem/B #include<iostream> #include<algorithm> using namespace std; int n, a[200001], temp = 0; int main() { int ans = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < 2 * n; i++) { if (a[i % n]) temp++; else temp = 0; ans = max(ans, temp); } cout << ans; }
47dbf03e53ca1021961d306e2d9998c1997ccd91
5b58f72c67e33b4a8422156c470b97e91c24730c
/Randomized Quick Sort(3 que).cpp
5218e31dc1d9cceecc71fa99d79cff199d667095
[]
no_license
Riya500/DAA-PRACTICAL-FILE
ea279c60a5ecd0e6998fc5eca20d38e53326f39a
420b9d599e3235268270688cab5c34906c850d99
refs/heads/main
2023-04-28T06:51:30.236944
2021-05-18T08:48:45
2021-05-18T08:48:45
363,147,036
0
1
null
null
null
null
UTF-8
C++
false
false
1,468
cpp
#include <cstdlib> #include <iostream> #include <time.h> using namespace std; int comp =0; int partition(int arr[], int low, int high) { int pivot = arr[high]; int i = (low - 1); for (int j = low; j <= high - 1; j++) { if (arr[j] <= pivot) { i++; swap(arr[i], arr[j]); } comp++; } swap(arr[i + 1], arr[high]); return (i + 1); } int partition_r(int arr[], int low, int high) { srand(time(NULL)); int random = low + rand() % (high - low); swap(arr[random], arr[high]); return partition(arr, low, high); } void quickSort(int arr[], int low, int high) { if (low < high) { int pi = partition_r(arr, low, high); quickSort(arr, low, pi - 1); quickSort(arr, pi + 1, high); } } void printArray(int arr[], int n) { for (int i = 0; i < n; ++i) cout << arr[i] << " "; cout << "\n"; } int main() { int size,ext; begin: comp=0; cout<<"Enter the size of array : "; cin>>size; int arr[size]; cout<<"\n\n"; for(int i=0;i<size;i++) { cout<<"Enter element "<<i+1<<" in an array : "; cin>>arr[i]; } cout << "\n\nGiven array is : "; printArray(arr, size); quickSort(arr, 0, size - 1); cout<<"\n\nSorted array is: "; printArray(arr, size); cout<<"\nNo of comparisons are : "<<comp; cout<<"\n\nPress 1 to start again / any other key to exit : "; cin>>ext; if(ext == 1) goto begin; return 0; }
431c37ccc5198b3eccdfd923ae4fa098307fbeb9
59a2f81c36686a40e03bb2557e08dc31bd6f1ec9
/Dynamic-Programming/Numeric_Keypad.cpp
4ca48e927dca7798ab0d8b818d4421b1ee690ad6
[]
no_license
mkltaneja/Interview-Prep-Questions
8f77bd7b332380ebd30a99c0426f87464b3bcb13
1ef818175ae2c6beca766625b41de850f8a8eb5b
refs/heads/master
2023-02-16T09:01:35.495108
2021-01-10T12:50:48
2021-01-10T12:50:48
288,815,697
0
0
null
null
null
null
UTF-8
C++
false
false
1,263
cpp
#include <iostream> #include <vector> using namespace std; vector<vector<int>> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {0, 0}}; int numeric_keypad(int n, vector<vector<int>> &keypad) { for (int i = 0; i < 4; i++) for (int j = 0; j < 3; j++) keypad[i][j] = ((i == 3 && j == 0) || (i == 3 && j == 2)) ? 0 : 1; while (--n) { vector<vector<int>> nkeypad(4, vector<int>(3, 0)); for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { if ((i == 3 && j == 0) || (i == 3 && j == 2)) continue; for (int d = 0; d < 5; d++) { int r = i + dir[d][0]; int c = j + dir[d][1]; if (r < 4 && c < 3 && r >= 0 && c >= 0 && (r != 3 || c != 0) && (r != 3 || c != 2)) nkeypad[i][j] += keypad[r][c]; } } } keypad = nkeypad; } int count = 0; for (int i = 0; i < 4; i++) for (int j = 0; j < 3; j++) count += keypad[i][j]; return count; } int main() { int n; cin >> n; vector<vector<int>> keypad(4, vector<int>(3, 0)); cout << numeric_keypad(n, keypad); }
c3d3e51b2624e5c8dafb6c977f12262fe4ea8da2
f13da091809dc2af0eee7eb01d82e4e27021442e
/updateServer/content/client.cpp
0934122d6f4ff093669ea8251e6e01f3e9015973
[]
no_license
fU9ANg/hacks
c3e58039e374459c029b2922f962862d74d79528
b259e3394a560dfde2bc22884f3df991b9667f2b
refs/heads/master
2021-01-15T19:28:16.194698
2015-01-12T13:51:30
2015-01-12T13:51:30
3,471,273
0
1
null
null
null
null
UTF-8
C++
false
false
681
cpp
/* * client.cpp */ #include "client.h" CClient::CClient () { } CClient::~CClient () { } void CClient::setOnLine (bool b) { m_onLine = b; } bool CClient::getOnLine (void) { return (m_onLine); } void CClient::setId (int id) { m_Id = id; } int CClient::getId () { return (m_Id); } void CClient::setSocket (int sock) { m_Socket = sock; } int CClient::getSocket () { return (m_Socket); } void CClient::setVersion (const string& ver) { m_version = ver; } string CClient::getVersion (void) { return (m_version); } void CClient::setIpAddr (const string& ip) { m_IpAddr = ip; } string CClient::getIpAddr (void) { return (m_IpAddr); }
82d917e74ac42df0d7e8a13c1d61e21de8907093
93697624e5bff8c25fec6c8e7ffad73da03e396e
/src/router/history.cpp
bfee04d87311915642f62306803b6bd6dccaf6df
[]
no_license
alfanick/xbee868-routing
6b836af82f4334b29e1f467d6951ccfefc0310dd
0bee55e8a5775502daf6c46c08f168e1aee907fd
refs/heads/master
2021-01-19T11:35:52.839758
2015-02-03T20:31:47
2015-02-03T20:31:47
28,773,036
1
0
null
null
null
null
UTF-8
C++
false
false
2,735
cpp
#include "history.h" namespace PUT { namespace CS { namespace XbeeRouting { Metadata::~Metadata() { // packet should be deleted manually because of case in Dispatcher::tick(), when metadata have to be deleted, but pointer to packet should be valid //delete packet; } void History::erase(Packet* packet) { auto it = packets_history.find(packet->id()); Metadata* tmp = it->second; packets_history.erase(it); if (packet == tmp->packet) { delete tmp->packet; packet = nullptr; } else delete tmp->packet; delete tmp; } void History::erase(Frame* frame) { LOG(WARNING)<<"erase"; frames_history.erase(frame->data.status.id); } void History::erase_frame(uint8_t frameId) { LOG(WARNING)<<"erase_frame"; frames_history.erase(frameId); } Metadata* History::meta(Packet* packet) { auto it = packets_history.find(packet->id()); return it != packets_history.end() ? it->second : nullptr; } Metadata* History::meta(Frame* frame) const { auto it = frames_history.find(frame->data.status.id); return it != frames_history.end() ? it->second : nullptr; } void History::add(Metadata* meta) { packets_history[meta->packet->id()] = meta; frames_history[meta->frame_id] = meta; } uint8_t History::watch(Packet* packet, Path path) { lock(); Metadata* meta = this->meta(packet); if (meta == nullptr) meta = new Metadata(); DLOG(INFO) << "Watching packet, visited size: " << packet->visited.size(); meta->packet = packet; meta->path_history.push_back(path); meta->frame_id = reserve_id(); if (packet->packet_id == 0) { packet->packet_id = meta->frame_id; DLOG(INFO) << "New frame id set to " << (int) packet->packet_id; } meta->packet_id = packet->id(); add(meta); meta->send_time = std::chrono::steady_clock::now(); unlock(); return meta->frame_id; } uint8_t History::reserve_id() { uint8_t id; id_occupation_lock.lock(); for (id = 0; id < bit_set_size; id++) if (!id_occupation.test(id)) break; if (id == bit_set_size) id = rand() % bit_set_size; id_occupation.set(id); id_occupation_lock.unlock(); return id + 1; } void History::release_id(Frame* frame) { id_occupation_lock.lock(); id_occupation.reset(frame->data.status.id - 1); id_occupation_lock.unlock(); } } } }
0b09bf99fdb492719f5c83a9204abb284e864101
b22588340d7925b614a735bbbde1b351ad657ffc
/athena/Event/FourMom/FourMom/P5Jacobiand0z0PhiThetaqOverP2d0z0PhiEtaP.h
d21002f10f23c5a8c188c10f9247e37a4d8cd49f
[]
no_license
rushioda/PIXELVALID_athena
90befe12042c1249cbb3655dde1428bb9b9a42ce
22df23187ef85e9c3120122c8375ea0e7d8ea440
refs/heads/master
2020-12-14T22:01:15.365949
2020-01-19T03:59:35
2020-01-19T03:59:35
234,836,993
1
0
null
null
null
null
UTF-8
C++
false
false
872
h
/* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef FOURMOM_P5JACOBIAND0Z0PHITHETAQOVERP2D0Z0PHIETAP_H #define FOURMOM_P5JACOBIAND0Z0PHITHETAQOVERP2D0Z0PHIETAP_H /******************************************************************** NAME: P5Jacobiand0z0PhiThetaqOverP2d0z0PhiEtaP.h PACKAGE: offline/Event/FourMom AUTHORS: T. Cuhadar Donszelmann CREATED: May 2009 PURPOSE: Jacobian to transfrom trk perigee parameters (d0,z0,phi,theta,E) to (d0,z0,phi,eta,p) UPDATED: ********************************************************************/ #include "CLHEP/Matrix/Matrix.h" class P5Jacobiand0z0PhiThetaqOverP2d0z0PhiEtaP : public CLHEP::HepMatrix { public: P5Jacobiand0z0PhiThetaqOverP2d0z0PhiEtaP(const double phi, const int charge, const double momentum); ~P5Jacobiand0z0PhiThetaqOverP2d0z0PhiEtaP(){} }; #endif
3d6ba24fa42760ff4f764c0d9b44746aa1330b43
da85324835c8c418ab22f85a9b1ac2ee0cc686a9
/bluetooth.ino
cfe55c37e53130bdfd6464f2448aaf9769101491
[]
no_license
chrisMbuff/AllNetscapes
2efe84fb6b394b6a08a286a0a132e230312336af
54e7fcaf188065c6dea2e9f36d55ef437fed7a16
refs/heads/master
2021-09-05T01:28:36.200237
2018-01-23T12:01:50
2018-01-23T12:01:50
113,847,363
0
1
null
2017-12-11T11:03:10
2017-12-11T10:50:15
JavaScript
UTF-8
C++
false
false
1,304
ino
/* made by Steph and Chris */ //13 = red 12= green 11 = blue char dump; String ledControlColourchar=""; void setup() // runs once { Serial.begin(9600); // sets the baud 9600 pinMode(13, OUTPUT); } void loop() { if(Serial.available()){ while(Serial.available()) { char inChar = (char)Serial.read(); //reads the cahracter input ledControlColourchar += inChar; // } Serial.println(ledControlColourchar); while (Serial.available() > 0) { dump = Serial.read() ; } // clears the buffer if(ledControlColourchar == "a"){ //if its "a" turn on RED digitalWrite(13, HIGH); digitalWrite(10, HIGH); } else if(ledControlColourchar == "b"){ //if its "b" turn on green digitalWrite(12, HIGH); digitalWrite(9, HIGH); } else if(ledControlColourchar == "c"){ //if its "c" turn on blue digitalWrite(11, HIGH); digitalWrite(8, HIGH); }else if(ledControlColourchar == "d"){ //if 'd' turn the LED off digitalWrite(13, LOW); digitalWrite(12, LOW); digitalWrite(11, LOW); digitalWrite(10, LOW); digitalWrite(9, LOW); digitalWrite(8, LOW); } ledControlColourchar = ""; } }
40cce36a74552dc2ff99737d7cbe27869dae6b4d
14a08ebe60e3f80c3a773d83af67bbc1b2231c63
/mainwindow.cpp
828317c75a83e60841603719c60f9cbfefac7c6e
[]
no_license
DiegoRibeiro/CaterBot
7c09b1a41418951fce512c20696b7cef5ff74b5e
e62838723dc221c8dbbf0ee827136463e5ec90ab
refs/heads/master
2022-06-22T23:30:40.617886
2020-05-11T05:05:17
2020-05-11T05:05:17
262,943,250
1
0
null
null
null
null
UTF-8
C++
false
false
1,359
cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QMessageBox> #include <iostream> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , process("SimpleClient.exe") , remoteThread() , caterModule("MyDll.dll") , thread() , client() { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_attachBtn_clicked() { QMessageBox box; if(!process.open()) { box.setText(process.getLastError()); box.exec(); return; } if(!remoteThread.inject(process, caterModule)) { box.setText(remoteThread.getLastError()); box.exec(); return; } } void MainWindow::on_detachBtn_clicked() { this->remoteThread.shutdown(); this->process.free(); this->process.close(); } void MainWindow::on_startServerBtn_clicked() { QMessageBox box; if(!thread.start()) { box.setText(thread.getLastError()); box.exec(); } } void MainWindow::on_stopServerBtn_clicked() { QMessageBox box; if(!client.connect()) { box.setText(client.getLastError()); box.exec(); } LPCTSTR str = TEXT("bye"); std::wcout << "send " << str << std::endl; if(!client.sendMessage(str)) { box.setText(client.getLastError()); box.exec(); } }
bd244c4c31b529df85dfcc5c28e6a30b4729c044
11053154af00a3a4c57c09ab4cfd64d30d0f8ebd
/2주차/붕어빵 판매하기.cpp
b899415ced969cbcbe556b679c4602f3a920ad29
[]
no_license
c3coding100/koi_im
e8de166919e335f3a5e8fc9c423bfe15ae74b973
687ec734c325ec40d107b932c660e98bed3c4b2f
refs/heads/master
2020-04-27T06:04:04.141480
2019-05-24T08:55:30
2019-05-24T08:55:30
174,097,678
0
1
null
null
null
null
UTF-8
C++
false
false
387
cpp
#include <stdio.h> int a[1001]; int d[1001]; int main() { int n; scanf("%d",&n); for (int i=1; i<=n; i++) { scanf("%d",&a[i]); } for (int i=1; i<=n; i++) { for (int j=1; j<=i; j++) { if (d[i] < d[i-j] + a[j]) { d[i] = d[i-j] + a[j]; } } } printf("%d\n",d[n]); return 0; }
8fb27b1efcbfd26299133fd324e71c879795def8
2cbe5a3c876b2dfc1e3d3cfe94c986616f133639
/Test/PayloadCRCouncilMemberClaimNodeTest.cpp
78dc11ee56d1ad51c878d120c8f37792f1085e90
[ "MIT" ]
permissive
chenyukaola/Elastos.ELA.SPV.Cpp
803d028d311ba2193a5b5ccd684bb0112c676bfd
57b5264d4eb259439dd85aefc0455389551ee3cf
refs/heads/master
2021-06-27T22:42:18.211020
2021-02-19T03:41:44
2021-02-19T03:41:44
222,857,687
1
0
MIT
2019-11-20T05:26:13
2019-11-20T05:26:12
null
UTF-8
C++
false
false
2,721
cpp
/* * Copyright (c) 2020 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #define CATCH_CONFIG_MAIN #include <catch.hpp> #include <Plugin/Transaction/Payload/CRCouncilMemberClaimNode.h> #include <Common/Log.h> #include <WalletCore/HDKeychain.h> #include <WalletCore/BIP39.h> #include <WalletCore/Mnemonic.h> #include <WalletCore/Key.h> static uint8_t version = CRCouncilMemberClaimNodeVersion; using namespace Elastos::ElaWallet; static void initPayload(CRCouncilMemberClaimNode &payload) { std::string mnemonic = Mnemonic(boost::filesystem::path("Data")).Create("English", Mnemonic::WORDS_12); uint512 seed = BIP39::DeriveSeed(mnemonic, ""); HDSeed hdseed(seed.bytes()); HDKeychain rootkey(hdseed.getExtendedKey(true)); HDKeychain masterKey = rootkey.getChild("44'/0'/0'"); HDKeychain nodePublicKey = masterKey.getChild("0/0"); HDKeychain councilMemberKey = masterKey.getChild("0/1"); payload.SetNodePublicKey(nodePublicKey.pubkey()); payload.SetCRCouncilMemberDID(Address(PrefixIDChain, councilMemberKey.pubkey(), true)); Key key; const uint256 &digest = payload.DigestUnsigned(version); key = councilMemberKey; bytes_t signature = key.Sign(digest); payload.SetCRCouncilMemberSignature(signature); } TEST_CASE("RechargeToSideChain test", "[RechargeToSideChain]") { Log::registerMultiLogger(); CRCouncilMemberClaimNode p1, p2; ByteStream stream; initPayload(p1); REQUIRE(p1.IsValid(version)); p1.Serialize(stream, version); REQUIRE(p2.Deserialize(stream, version)); REQUIRE(p1 == p2); initPayload(p1); REQUIRE(p1.IsValid(version)); nlohmann::json j = p1.ToJson(version); REQUIRE_NOTHROW(p2.FromJson(j, version)); REQUIRE(p1 == p2); }
1e469dce9f4b0eb38b815ce255a410afae878a59
8fcc488d9df0094885e2b32b67672d65b11b30a7
/include/caffe/cc/core/cc.h
a1798834dd09d20ee03476069dddd91b8085f55e
[]
no_license
zgsxwsdxg/CC4.0
3a3678dfb90d8da47ab9ca114518ea60944346dc
7fe1ad3a96f9fa32fc2b4f55b488da052702a18c
refs/heads/master
2020-03-19T13:43:24.907711
2018-05-26T12:04:09
2018-05-26T12:04:09
null
0
0
null
null
null
null
GB18030
C++
false
false
14,582
h
/* CC深度学习库(Caffe)V4.0 */ #ifndef CC_H #define CC_H #include <opencv2/opencv.hpp> #include <vector> #include <map> //#define USE_PROTOBUF #ifdef USE_PROTOBUF #include <caffe/proto/caffe.pb.h> #endif using namespace std; #ifdef EXPORT_CC_DLL #define CCAPI __declspec(dllexport) #else #define CCAPI __declspec(dllimport) #endif #define CCCALL __stdcall namespace cc{ using cv::Mat; static const int PhaseTrain = 0; static const int PhaseTest = 1; class CCAPI CCString{ private: char* buffer; int capacity_size; int length; public: operator char*(){ return get(); } operator const char*(){ return get(); } CCString& operator=(const char* str){ set(str); return *this; } CCString& operator=(char* str){ set(str); return *this; } CCString& operator=(const CCString& str){ set(str.get(), str.len()); return *this; } CCString& operator+=(const CCString& str); CCString& operator+=(const char* str); CCString operator+(const CCString& str); CCString operator+(const char* str); CCString(const char* other); CCString(const CCString& other); CCString(); virtual ~CCString(); void set(const char* str, int len = -1); char* get() const; const char* c_str() const{ return get(); }; int len() const{ return length; } void release(); void append(const char* str, int len = -1); }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////// enum ValueType{ ValueType_Null, ValueType_Int32, ValueType_Int64, ValueType_String, ValueType_Float, ValueType_Double, ValueType_Bool, ValueType_Uint32, ValueType_Uint64, ValueType_Enum, ValueType_Message }; struct CCAPI MessageProperty{ cc::CCString name; ValueType type; int count; }; struct CCAPI MessagePropertyList{ MessageProperty* list; int count, capacity_count; void init(); MessagePropertyList(); MessagePropertyList(const MessagePropertyList& other); MessagePropertyList& operator=(const MessagePropertyList& other); void resize(int size); void copyFrom(const MessagePropertyList& other); void release(); virtual ~MessagePropertyList(); }; typedef const void* MessageHandle; typedef int cint32; typedef __int64 cint64; typedef unsigned int cuint32; typedef unsigned __int64 cuint64; struct CCAPI Value{ union { cint32 int32Val; cint64 int64Val; cc::CCString* stringVal; float floatVal; double doubleVal; cuint32 uint32Val; cuint64 uint64Val; bool boolVal; cc::CCString* enumVal; MessageHandle messageVal; //repeated float* floatRepVal; cint32* cint32RepVal; cuint32* cuint32RepVal; cint64* cint64RepVal; cuint64* cuint64RepVal; double* doubleRepVal; bool* boolRepVal; cc::CCString* stringRepVal; cc::CCString* enumRepVal; MessageHandle* messageRepVal; }; //for enum type int enumIndex; int* enumRepIndex; ValueType type; bool repeated; //对于基本元素,是否为重复的,如果是,则推广为指针 int numElements; void init(); Value(cc::CCString* repeatedValue, int length); Value(cc::CCString* repeatedValue, int* enumIndex, int length); Value(MessageHandle* repeatedValue, int length); Value(float* repeatedValue, int length); Value(cint32* repeatedValue, int length); Value(cuint32* repeatedValue, int length); Value(cint64* repeatedValue, int length); Value(cuint64* repeatedValue, int length); Value(double* repeatedValue, int length); Value(bool* repeatedValue, int length); Value(int val); Value(cuint32 val); Value(cint64 val); Value(cuint64 val); Value(float val); Value(double val); Value(bool val); Value(const char* stringVal); Value(const char* enumName, int enumIndex); Value(MessageHandle message); Value(); cint32 getInt(int index = 0); cuint32 getUint(int index = 0); cint64 getInt64(int index = 0); cuint64 getUint64(int index = 0); float getFloat(int index = 0); double getDouble(int index = 0); cc::CCString getString(int index = 0); cc::CCString toString(); void release(); void copyFrom(const Value& other); Value& operator=(const Value& other); Value(const Value& other); virtual ~Value(); }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// class CCAPI Blob{ public: void setNative(void* native); void* getNative(); int shape(int index) const; int num_axes() const; int count() const; int count(int start_axis) const; int height() const; int width() const; int channel() const; int num() const; int offset(int n) const;; void set_cpu_data(float* data); const float* cpu_data() const; const float* gpu_data() const; float* mutable_cpu_data(); float* mutable_gpu_data(); const float* cpu_diff(); const float* gpu_diff(); float* mutable_cpu_diff(); float* mutable_gpu_diff(); void Reshape(int num = 1, int channels = 1, int height = 1, int width = 1); void Reshape(int numShape, int* shapeDims); void ReshapeLike(const Blob& other); void copyFrom(const Blob& other, bool copyDiff = false, bool reshape = false); void setDataRGB(int numIndex, const Mat& data); CCString shapeString(); private: void* _native; }; class CCAPI Layer{ public: void setNative(void* native); void setupLossWeights(int num, float* weights); float lossWeights(int index); void setLossWeights(int index, float weights); const char* type() const; CCString paramString(); bool getParam(const char* path, Value& val); bool hasParam(const char* path); CCString name(); MessageHandle* param(); #ifdef USE_PROTOBUF caffe::LayerParameter& layer_param(); #endif private: void* _native; }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// class CCAPI Net{ public: void setNative(void* native); void* getNative(); Blob* blob(const char* name); Blob* blob(int index); void Forward(float* loss = 0); void Reshape(); void copyTrainedParamFromFile(const char* file); void copyTrainedParamFromData(const void* data, int length); void ShareTrainedLayersWith(const Net* other); bool has_blob(const char* name); bool has_layer(const char* name); int num_input_blobs(); int num_output_blobs(); int num_blobs(); CCString blob_name(int index); CCString layer_name(int index); Blob* input_blob(int index); Blob* output_blob(int index); int num_layers(); Layer* layer(const char* name); Layer* layer(int index); size_t memory_used(); private: void* _native; }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// class CCAPI Solver{ public: Solver(); virtual ~Solver(); void setNative(void* native); void step(int iters); Net* net(); int num_test_net(); Net* test_net(int index = 0); void* getNative(); int iter(); float smooth_loss(); void Restore(const char* resume_file); void Snapshot(); int max_iter(); void Solve(); void installActionSignalOperator(); void setBaseLearningRate(float rate); float getBaseLearningRate(); void postSnapshotSignal(); void TestAll(); bool getParam(const char* path, Value& val); MessageHandle param(); #ifdef USE_PROTOBUF caffe::SolverParameter& solver_param(); #endif private: void* signalHandler_; void* _native; }; CCAPI Blob* CCCALL newBlob(); CCAPI Blob* CCCALL newBlobByShape(int num = 1, int channels = 1, int height = 1, int width = 1); CCAPI Blob* CCCALL newBlobByShapes(int numShape, int* shapes); CCAPI void CCCALL releaseBlob(Blob* blob); CCAPI void CCCALL releaseSolver(Solver* solver); CCAPI void CCCALL releaseNet(Net* net); CCAPI Solver* CCCALL loadSolverFromPrototxt(const char* solver_prototxt); CCAPI Solver* CCCALL loadSolverFromPrototxtString(const char* solver_prototxt_string); #ifdef USE_PROTOBUF CCAPI Solver* CCCALL newSolverFromProto(const caffe::SolverParameter* solver_param); #endif CCAPI Net* CCCALL loadNetFromPrototxt(const char* net_prototxt, int phase = PhaseTest); CCAPI Net* CCCALL loadNetFromPrototxtString(const char* net_prototxt, int length = -1, int phase = PhaseTest); #ifdef USE_PROTOBUF CCAPI Net* CCCALL newNetFromParam(const caffe::NetParameter& param); #endif CCAPI void CCCALL setGPU(int id); #ifdef USE_PROTOBUF CCAPI bool CCCALL ReadProtoFromTextString(const char* str, google::protobuf::Message* proto); CCAPI bool CCCALL ReadProtoFromData(const void* data, int length, google::protobuf::Message* proto); CCAPI bool CCCALL ReadProtoFromTextFile(const char* filename, google::protobuf::Message* proto); CCAPI bool CCCALL ReadProtoFromBinaryFile(const char* binaryfilename, google::protobuf::Message* proto); CCAPI void CCCALL WriteProtoToTextFile(const google::protobuf::Message& proto, const char* filename); CCAPI void CCCALL WriteProtoToBinaryFile(const google::protobuf::Message& proto, const char* filename); #endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////// class CCAPI AbstractCustomLayer{ public: virtual void setup(const char* name, const char* type, const char* param_str, int phase, Blob** bottom, int numBottom, Blob** top, int numTop) = 0; virtual void forward(Blob** bottom, int numBottom, Blob** top, int numTop) = 0; virtual void backward(Blob** bottom, int numBottom, Blob** top, int numTop, const bool* propagate_down){}; virtual void reshape(Blob** bottom, int numBottom, Blob** top, int numTop) = 0; virtual const char* type() = 0; virtual ~AbstractCustomLayer(){} void* getNative(); void setNative(void* ptr); Layer* ccLayer(); private: void* native_; }; class CCAPI AbstractCustomLayerCPP{ public: virtual void setup(const char* name, const char* type, const char* param_str, int phase, vector<Blob*>& bottom, vector<Blob*>& top) = 0; virtual void forward(vector<Blob*>& bottom, vector<Blob*>& top) = 0; virtual void backward(vector<Blob*>& bottom, const vector<bool>& propagate_down, vector<Blob*>& top) = 0; virtual void reshape(vector<Blob*>& bottom, vector<Blob*>& top) = 0; virtual const char* type() = 0; virtual ~AbstractCustomLayerCPP(){} }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// typedef void* CustomLayerInstance; typedef AbstractCustomLayer* (*createLayerFunc)(); typedef void(*releaseLayerFunc)(AbstractCustomLayer* layer); typedef CustomLayerInstance(CCCALL *newLayerFunction)(const char* name, const char* type, const char* param_str, int phase, Blob** bottom, int numBottom, Blob** top, int numTop, void* native); typedef void(CCCALL *customLayerForward)(CustomLayerInstance instance, Blob** bottom, int numBottom, Blob** top, int numTop); typedef void(CCCALL *customLayerBackward)(CustomLayerInstance instance, Blob** bottom, int numBottom, Blob** top, int numTop, const bool* propagate_down); typedef void(CCCALL *customLayerReshape)(CustomLayerInstance instance, Blob** bottom, int numBottom, Blob** top, int numTop); typedef void(CCCALL *customLayerRelease)(CustomLayerInstance instance); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// CCAPI void CCCALL registerLayerFunction(newLayerFunction newlayerFunc); CCAPI void CCCALL registerLayerForwardFunction(customLayerForward forward); CCAPI void CCCALL registerLayerBackwardFunction(customLayerBackward backward); CCAPI void CCCALL registerLayerReshapeFunction(customLayerReshape reshape); CCAPI void CCCALL registerLayerReleaseFunction(customLayerRelease release); CCAPI void CCCALL installRegister(); CCAPI void CCCALL installLayer(const char* type, createLayerFunc func, releaseLayerFunc release); #define INSTALL_LAYER(classes) {installLayer(#classes, classes::creater, classes::release);}; #define SETUP_LAYERFUNC(classes) static AbstractCustomLayer* creater(){return new classes();} static void release(AbstractCustomLayer* layer){if (layer) delete layer; }; virtual const char* type(){return #classes;} class CCAPI DataLayer : public AbstractCustomLayer{ public: DataLayer(); virtual ~DataLayer(); virtual int getBatchCacheSize(); virtual void loadBatch(Blob** top, int numTop) = 0; virtual void setup(const char* name, const char* type, const char* param_str, int phase, Blob** bottom, int numBottom, Blob** top, int numTop); virtual void forward(Blob** bottom, int numBottom, Blob** top, int numTop); virtual void reshape(Blob** bottom, int numBottom, Blob** top, int numTop){} void stopBatchLoader(); virtual int waitForDataTime(); private: void setupBatch(Blob** top, int numTop); static void watcher(DataLayer* ptr); void startWatcher(); void stopWatcher(); void pullBatch(Blob** top, int numTop); private: volatile bool keep_run_watcher_; void* hsem_; bool* batch_flags_; Blob*** batch_; int numTop_; int cacheBatchSize_; }; class CCAPI SSDDataLayer : public DataLayer{ public: SSDDataLayer(); virtual ~SSDDataLayer(); virtual int getBatchCacheSize(); virtual void loadBatch(Blob** top, int numTop); virtual void setup(const char* name, const char* type, const char* param_str, int phase, Blob** bottom, int numBottom, Blob** top, int numTop); virtual void* getAnnDatum() = 0; virtual void releaseAnnDatum(void* datum) = 0; private: bool has_anno_type_; int anno_type_; void* batch_samplers_; char label_map_file_[500]; void* transform_param_; void* data_transformer_; Blob* transformed_data_; }; CCAPI void* CCCALL createAnnDatum(); CCAPI bool CCCALL loadAnnDatum( const char* filename, const char* xml, int resize_width, int resize_height, int min_dim, int max_dim, int is_color, const char* encode_type, const char* label_type, void* label_map, void* inplace_anndatum); CCAPI void* CCCALL loadLabelMap(const char* prototxt); CCAPI void CCCALL releaseLabelMap(void* labelmap); CCAPI void CCCALL releaseAnnDatum(void* datum); ///////////////////////////////////////////////////////////////////////////// CCAPI MessageHandle CCCALL loadMessageNetCaffemodel(const char* filename); CCAPI MessageHandle CCCALL loadMessageNetFromPrototxt(const char* filename); CCAPI MessageHandle CCCALL loadMessageSolverFromPrototxt(const char* filename); CCAPI bool CCCALL getMessageValue(MessageHandle message, const char* pathOfGet, Value& val); CCAPI MessagePropertyList CCCALL listProperty(MessageHandle message_); }; #endif //CC_H
43504de51233ef559934347e18fc23fb99397430
0ff0c44885ccf687d8d00d407bff180f89f45a2a
/T1021甲流疫情死亡率.cpp
a268a728b3c4d4716a20114c471284b1baa93c19
[]
no_license
shareone2/JiSuanKeOj
dc3e06134b58a679d515aef343d7cbe48ee887d1
4771e5a50bea48cab278245fb979bffe9b4c5da6
refs/heads/master
2022-12-16T13:47:38.853626
2020-09-09T08:57:38
2020-09-09T08:57:38
294,057,513
0
0
null
null
null
null
UTF-8
C++
false
false
443
cpp
/************************************************************************* > File Name: T1021甲流疫情死亡率.cpp > Author: > Mail: > Created Time: 2019年04月04日 星期四 20时24分53秒 ************************************************************************/ #include <iostream> #include <cstdio> using namespace std; int main () { double a, b; cin >> a >> b; printf("%.3lf%\n", b / a * 100); return 0; }
47ec99595d1823a218a43c9f127cba4da5eb8afa
5456502f97627278cbd6e16d002d50f1de3da7bb
/ppapi/host/resource_host.h
8adb9eaf2902537e4d17559e603f8a8fcde31b98
[ "BSD-3-Clause", "LicenseRef-scancode-khronos" ]
permissive
TrellixVulnTeam/Chromium_7C66
72d108a413909eb3bd36c73a6c2f98de1573b6e5
c8649ab2a0f5a747369ed50351209a42f59672ee
refs/heads/master
2023-03-16T12:51:40.231959
2017-12-20T10:38:26
2017-12-20T10:38:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,493
h
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_HOST_RESOURCE_HOST_H_ #define PPAPI_HOST_RESOURCE_HOST_H_ #include <vector> #include "base/macros.h" #include "base/memory/ref_counted.h" #include "ppapi/c/pp_resource.h" #include "ppapi/host/ppapi_host_export.h" #include "ppapi/host/resource_message_handler.h" #include "ppapi/shared_impl/host_resource.h" namespace IPC { class Message; } namespace ppapi { namespace host { struct HostMessageContext; class PpapiHost; class ResourceMessageFilter; // Some (but not all) resources have a corresponding object in the host side // that is kept alive as long as the resource in the plugin is alive. This is // the base class for such objects. class PPAPI_HOST_EXPORT ResourceHost : public ResourceMessageHandler { public: ResourceHost(PpapiHost* host, PP_Instance instance, PP_Resource resource); ~ResourceHost() override; PpapiHost* host() { return host_; } PP_Instance pp_instance() const { return pp_instance_; } PP_Resource pp_resource() const { return pp_resource_; } // This runs any message filters in |message_filters_|. If the message is not // handled by these filters then the host's own message handler is run. True // is always returned (the message will always be handled in some way). bool HandleMessage(const IPC::Message& msg, HostMessageContext* context) override; // Sets the PP_Resource ID when the plugin attaches to a pending resource // host. This will notify subclasses by calling // DidConnectPendingHostToResource. // // The current PP_Resource for all pending hosts should be 0. See // PpapiHostMsg_AttachToPendingHost. void SetPPResourceForPendingHost(PP_Resource pp_resource); void SendReply(const ReplyMessageContext& context, const IPC::Message& msg) override; // Simple RTTI. A subclass that is a host for one of these APIs will override // the appropriate function and return true. virtual bool IsCompositorHost(); virtual bool IsFileRefHost(); virtual bool IsFileSystemHost(); virtual bool IsGraphics2DHost(); virtual bool IsMediaStreamVideoTrackHost(); protected: // Adds a ResourceMessageFilter to handle resource messages. Incoming // messages will be passed to the handlers of these filters before being // handled by the resource host's own message handler. This allows // ResourceHosts to easily handle messages on other threads. void AddFilter(scoped_refptr<ResourceMessageFilter> filter); // Called when this resource host is pending and the corresponding plugin has // just connected to it. The host resource subclass can implement this // function if it wants to do processing (typically sending queued data). // // The PP_Resource will be valid for this call but not before. virtual void DidConnectPendingHostToResource() {} private: // The host that owns this object. PpapiHost* host_; PP_Instance pp_instance_; PP_Resource pp_resource_; // A vector of message filters which the host will forward incoming resource // messages to. std::vector<scoped_refptr<ResourceMessageFilter> > message_filters_; DISALLOW_COPY_AND_ASSIGN(ResourceHost); }; } // namespace host } // namespace ppapi #endif // PPAPI_HOST_RESOURCE_HOST_H_
f3ec6bb3b9502b224fd27eecd83d0980fb340607
ad5f6aab3066c280c80494a233e78179d4a5319e
/src/CandidateIdentifiersGrabber.cpp
2364cc4c56bdd0578e0deafb53901d03660b4b58
[]
no_license
dakeryas/CandidateMapMaker
da9b069827c132c0d12a9864f300dbec830be899
53a3259ed6284a63de6d98fdf73f7679bd50db9a
refs/heads/master
2021-01-10T12:42:25.818152
2016-04-19T08:40:16
2016-04-19T08:40:16
48,567,504
0
0
null
null
null
null
UTF-8
C++
false
false
2,068
cpp
#include "CandidateIdentifiersGrabber.hpp" namespace CandidateMapMaker{ CandidateIdentifiersGrabber::CandidateIdentifiersGrabber(std::string production, std::string dataType, CosmogenicHunter::Bounds<double> candidateEnergyBounds) :production(std::move(production)),dataType(std::move(dataType)),candidateEnergyBounds(std::move(candidateEnergyBounds)){ } void CandidateIdentifiersGrabber::UpdateCandidateIdentifiers(const EnDep& currentEnergyDeposit, std::vector<unsigned>& candidateIdentifiers){ auto globalInfo = currentEnergyDeposit.GetGlobalInfo(); auto recoBAMAInfo = currentEnergyDeposit.GetRecoBAMAInfo(); CosmogenicHunter::Point<double> position(recoBAMAInfo->GetRecoX()[0], recoBAMAInfo->GetRecoX()[1], recoBAMAInfo->GetRecoX()[2]); auto numberOfPhotoElectrons = globalInfo->GetCaloPEID(DC::kCaloPEDefaultDC); auto energy = Calib::GetME(currentEnergyDeposit.GetVldContext())->EvisID(numberOfPhotoElectrons, globalInfo->GetNGoodChID(), position.getR(), position.getZ(), DCSimFlag::kDATA, DC::kESv10); if(candidateEnergyBounds.contains(energy)) candidateIdentifiers.emplace_back(globalInfo->GetTriggerID()); } std::vector<unsigned> CandidateIdentifiersGrabber::getCandidateIdentifiers(unsigned runNumber){ EnDep::AddFileDBINFO(production, std::to_string(runNumber),""); EnDep::SetLabelINPUT(dataType); EnDep currentEnergyDeposit; currentEnergyDeposit.CancelAllInfoCapsule_Tree(); currentEnergyDeposit.UncancelInfoCapsule_Tree(DC::kGlobalIT); currentEnergyDeposit.UncancelInfoCapsule_Tree(DC::kRunIT); currentEnergyDeposit.UncancelInfoCapsule_Tree(DC::kRecoBAMAIT); currentEnergyDeposit.RetrieveME(); std::vector<unsigned> candidateIdentifiers; while(currentEnergyDeposit.Next()) if(currentEnergyDeposit.GetN() % 2) UpdateCandidateIdentifiers(currentEnergyDeposit, candidateIdentifiers); //GetN() starts at 1 and we want prompts only so the rest of division by 2 should be 1 (hence 'true') return candidateIdentifiers; } }
1ecbfafb997f460e38160a21eb42d05cd052e023
ae966c81c2de5af22680d4c9ec15d0b84499d260
/my/onecpu.h
0f8b0b2b2078fd33b48d27fc3f1c64543c399f79
[]
no_license
kkHAIKE/codestore
f4a8020200a8071c3b53610a388a1b1776cfb375
593e3e27ca01237112021bee4d50f47033a79d59
refs/heads/master
2022-11-09T07:05:18.681248
2020-06-28T06:19:42
2020-06-28T06:19:42
275,519,887
0
0
null
null
null
null
UTF-8
C++
false
false
1,781
h
#pragma once #ifndef ONECPU_NAME #define ONECPU_NAME "one_cpu" #endif #pragma data_seg(ONECPU_NAME) DWORD_PTR g_cpu1=0,g_cpu2=0; #pragma data_seg() #pragma comment(linker,"/SECTION:"ONECPU_NAME",RWS") class COneCpu { public: static COneCpu& Instance() { static COneCpu instance; return instance; } ~COneCpu() { if(m_mutex) { unsetcpu(); CloseHandle(m_mutex); } } protected: COneCpu():m_id(-1) { m_mutex=CreateMutex(NULL,FALSE,_T("Global\\"ONECPU_NAME)); if(m_mutex==NULL) return; m_ncpu=getcpus(); m_mask[0]=1; for(int i=1;i<sizeof(DWORD_PTR);++i) { m_mask[i]=m_mask[i-1]*2; } setcpu(); } void setcpu() { lock(); for(int i=0;i<m_ncpu;++i) { if((g_cpu1 & m_mask[i])==0) { m_id=i; SetProcessAffinityMask(GetCurrentProcess(),m_mask[i]); g_cpu1|=m_mask[i]; break; } } if(m_id==-1) { for(int i=0;i<m_ncpu;++i) { if((g_cpu2 & m_mask[i])==0) { m_id=i+sizeof(DWORD_PTR); SetProcessAffinityMask(GetCurrentProcess(),m_mask[i]); g_cpu2|=m_mask[i]; break; } } } unlock(); } void unsetcpu() { if(m_id!=-1) { lock(); if(m_id>=sizeof(DWORD_PTR)) { g_cpu2&=~m_mask[m_id-sizeof(DWORD_PTR)]; } else { g_cpu1&=~m_mask[m_id]; } unlock(); } } void lock() { WaitForSingleObject(m_mutex,INFINITE); } void unlock() { ReleaseMutex(m_mutex); } int getcpus() { SYSTEM_INFO info; GetSystemInfo(&info); return info.dwNumberOfProcessors; } protected: HANDLE m_mutex; int m_id,m_ncpu; DWORD_PTR m_mask[sizeof(DWORD_PTR)]; private: COneCpu(const COneCpu&); void operator=(const COneCpu&); };
ec2ab7ea890f4032e8144623a1fd6ac957f49a09
f96fc6c0274edf6d0f8b407a391f02f6a1151885
/Noctis/src/Noctis/Renderer/RenderCommand.cpp
09edd86a65507e8b69c2b2464c285a29fff71133
[ "Apache-2.0" ]
permissive
Imoali/Noctis
b4bc014b1e3a57ce1864d304e20c16d0d42a4ece
7a0233f2765ae0949a0f3724cd21e6cad78eb3da
refs/heads/master
2020-05-31T10:35:33.901550
2019-08-05T21:26:46
2019-08-05T21:26:46
190,242,915
2
0
null
null
null
null
UTF-8
C++
false
false
185
cpp
#include "ntpch.h" #include "RenderCommand.h" #include "Platform/OpenGL/OpenGLRendererAPI.h" namespace Noctis { RendererAPI* RenderCommand::s_RendererAPI = new OpenGLRendererAPI; }
c0828d2bd4e06372ecfca4b7410466951c67d1f6
13e0dd63138eb68a19b3a8c7db52d12af78b2c2a
/Trees/BinaryTreeLevelOrderTraversal.cpp
8111bb9ccea7d77978077be0ddeda8355e0a5848
[]
no_license
AmelHelez/Data-structures
14931e620dc85d2324a623d1ec3b6cd3c4bd64ee
85237a264327652a422a4453b12b0d5928ede6c6
refs/heads/master
2020-12-31T09:53:01.796129
2020-02-07T17:23:22
2020-02-07T17:23:22
238,984,284
0
0
null
null
null
null
UTF-8
C++
false
false
1,454
cpp
#include <iostream> #include <algorithm> #include <vector> #include <queue> using namespace std; struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL),right(NULL) {} }; vector<vector<int> > levelOrderBottom(TreeNode* root) { vector<vector<int> > ret; if(!root) return ret; queue<TreeNode*> cur_que,next_que; vector<int> tem; cur_que.push(root); while(!cur_que.empty()) { TreeNode* top = cur_que.front(); tem.push_back(top->val); cur_que.pop(); if(top->left) {next_que.push(top->left);} if(top->right) {next_que.push(top->right);} if(cur_que.empty()) { ret.push_back(tem); tem.clear(); cur_que = next_que; next_que = queue<TreeNode*>(); } } reverse(ret.begin(),ret.end()); return ret; } int main() { vector<vector<int> > vec; TreeNode *root = new TreeNode(3); root->left = new TreeNode(9); root->right = new TreeNode(20); root->right->left = new TreeNode(15); root->right->right = new TreeNode(7); vec = levelOrderBottom(root); for(int i = 0; i < vec.size(); i++) { for(int j = 0; j < vec[i].size(); j++) cout << "[" << vec[i][j] << "," << "]\n"; } }
5dcb3197789b50e8891096478a6d0d939172f179
8a92aa7d9f97269de27489f494e5249505e7645d
/Programa moléculas/Programa moléculas/MoleculaAgua.h
dbf5eaa779c770916de91f337ed93e91644a6a18
[ "MIT" ]
permissive
AlbertoTrapiello/SII-ADOO
0f5fb098407ad821394d1d73ded1c7490934dab5
9a7ba5dcd450c6b6b3e0932f5a62d0be28733bbf
refs/heads/master
2021-07-23T02:16:32.216387
2019-01-23T17:48:22
2019-01-23T17:48:22
147,925,200
0
0
null
null
null
null
UTF-8
C++
false
false
496
h
#ifndef _MOL_AGUA #define _MOL_AGUA // #include "Atomo.h" class MoleculaAgua { protected: Atomo oxigeno, hidrogeno1, hidrogeno2; public: MoleculaAgua(): oxigeno(16), hidrogeno1(1), hidrogeno2(1) { hidrogeno1.Enlaza(&oxigeno); hidrogeno2.Enlaza(&oxigeno); } void CalcularPosicion() { oxigeno.CalcularPosicion(); hidrogeno1.CalcularPosicion(); hidrogeno2.CalcularPosicion(); } void Dibuja() { oxigeno.Dibuja(); hidrogeno1.Dibuja(); hidrogeno2.Dibuja(); } }; #endif
2af5fa7dcad0c237e522a1fafb8427abb9e451f8
78918391a7809832dc486f68b90455c72e95cdda
/boost_lib/boost/mpl/aux_/preprocessed/no_ttp/equal_to.hpp
e74b7d4bea26150ac1e15b12d31b828d2a9457d8
[ "MIT" ]
permissive
kyx0r/FA_Patcher
50681e3e8bb04745bba44a71b5fd04e1004c3845
3f539686955249004b4483001a9e49e63c4856ff
refs/heads/master
2022-03-28T10:03:28.419352
2020-01-02T09:16:30
2020-01-02T09:16:30
141,066,396
2
0
null
null
null
null
UTF-8
C++
false
false
2,079
hpp
// Copyright Aleksey Gurtovoy 2000-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Preprocessed version of "boost/mpl/equal_to.hpp" header // -- DO NOT modify by hand! namespace boost { namespace mpl { template< typename Tag1 , typename Tag2 > struct equal_to_impl : if_c< ( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1) > BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2) ) , aux::cast2nd_impl< equal_to_impl< Tag1,Tag1 >,Tag1, Tag2 > , aux::cast1st_impl< equal_to_impl< Tag2,Tag2 >,Tag1, Tag2 > >::type { }; /// for Digital Mars C++/compilers with no CTPS/TTP support template<> struct equal_to_impl< na,na > { template< typename U1, typename U2 > struct apply { typedef apply type; BOOST_STATIC_CONSTANT(int, value = 0); }; }; template< typename Tag > struct equal_to_impl< na,Tag > { template< typename U1, typename U2 > struct apply { typedef apply type; BOOST_STATIC_CONSTANT(int, value = 0); }; }; template< typename Tag > struct equal_to_impl< Tag,na > { template< typename U1, typename U2 > struct apply { typedef apply type; BOOST_STATIC_CONSTANT(int, value = 0); }; }; template< typename T > struct equal_to_tag { typedef typename T::tag type; }; template< typename BOOST_MPL_AUX_NA_PARAM(N1) , typename BOOST_MPL_AUX_NA_PARAM(N2) > struct equal_to : equal_to_impl< typename equal_to_tag<N1>::type , typename equal_to_tag<N2>::type >::template apply< N1,N2 >::type { BOOST_MPL_AUX_LAMBDA_SUPPORT(2, equal_to, (N1, N2)) }; BOOST_MPL_AUX_NA_SPEC2(2, 2, equal_to) } } namespace boost { namespace mpl { template<> struct equal_to_impl< integral_c_tag,integral_c_tag > { template< typename N1, typename N2 > struct apply { BOOST_STATIC_CONSTANT(bool, value = ( BOOST_MPL_AUX_VALUE_WKND(N1)::value == BOOST_MPL_AUX_VALUE_WKND(N2)::value ) ); typedef bool_<value> type; }; }; } }