blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
13cd5bdecb4ec57996b1d5434696acb785d6b3b1
754a4e2d287898ae93bd572bf2edfbe465c6951a
/arduino_code/ros_libraries/kinetic/ros_lib/human_awareness_msgs/AnalyzedSocsigPerson.h
c4ab1d2090ec1b7527593c1bb49e8e98f634dba5
[]
no_license
vislab-tecnico-lisboa/vizzy_tactile_drivers
c183723daea5fd3acb1a9460719a81fb1db546a7
c2068ebf0abb3b60bc52f364a923544e435df935
refs/heads/master
2022-05-13T20:52:03.065784
2022-05-03T17:22:24
2022-05-03T17:22:24
90,271,857
1
0
null
null
null
null
UTF-8
C++
false
false
6,667
h
AnalyzedSocsigPerson.h
#ifndef _ROS_human_awareness_msgs_AnalyzedSocsigPerson_h #define _ROS_human_awareness_msgs_AnalyzedSocsigPerson_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" #include "std_msgs/Header.h" #include "human_awareness_msgs/BodyPart.h" #include "human_awareness_msgs/OpenFaceFeatures.h" #include "human_awareness_msgs/BoundingBox.h" #include "geometry_msgs/Pose.h" #include "geometry_msgs/Twist.h" namespace human_awareness_msgs { class AnalyzedSocsigPerson : public ros::Msg { public: typedef std_msgs::Header _header_type; _header_type header; typedef const char* _id_type; _id_type id; typedef const char* _face_id_type; _face_id_type face_id; uint32_t body_parts_length; typedef human_awareness_msgs::BodyPart _body_parts_type; _body_parts_type st_body_parts; _body_parts_type * body_parts; uint32_t openface_features_length; typedef human_awareness_msgs::OpenFaceFeatures _openface_features_type; _openface_features_type st_openface_features; _openface_features_type * openface_features; typedef human_awareness_msgs::BoundingBox _body_type; _body_type body; typedef geometry_msgs::Pose _body_pose_type; _body_pose_type body_pose; typedef geometry_msgs::Pose _head_pose_type; _head_pose_type head_pose; typedef geometry_msgs::Twist _velocity_type; _velocity_type velocity; AnalyzedSocsigPerson(): header(), id(""), face_id(""), body_parts_length(0), body_parts(NULL), openface_features_length(0), openface_features(NULL), body(), body_pose(), head_pose(), velocity() { } virtual int serialize(unsigned char *outbuffer) const { int offset = 0; offset += this->header.serialize(outbuffer + offset); uint32_t length_id = strlen(this->id); varToArr(outbuffer + offset, length_id); offset += 4; memcpy(outbuffer + offset, this->id, length_id); offset += length_id; uint32_t length_face_id = strlen(this->face_id); varToArr(outbuffer + offset, length_face_id); offset += 4; memcpy(outbuffer + offset, this->face_id, length_face_id); offset += length_face_id; *(outbuffer + offset + 0) = (this->body_parts_length >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (this->body_parts_length >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (this->body_parts_length >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (this->body_parts_length >> (8 * 3)) & 0xFF; offset += sizeof(this->body_parts_length); for( uint32_t i = 0; i < body_parts_length; i++){ offset += this->body_parts[i].serialize(outbuffer + offset); } *(outbuffer + offset + 0) = (this->openface_features_length >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (this->openface_features_length >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (this->openface_features_length >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (this->openface_features_length >> (8 * 3)) & 0xFF; offset += sizeof(this->openface_features_length); for( uint32_t i = 0; i < openface_features_length; i++){ offset += this->openface_features[i].serialize(outbuffer + offset); } offset += this->body.serialize(outbuffer + offset); offset += this->body_pose.serialize(outbuffer + offset); offset += this->head_pose.serialize(outbuffer + offset); offset += this->velocity.serialize(outbuffer + offset); return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; offset += this->header.deserialize(inbuffer + offset); uint32_t length_id; arrToVar(length_id, (inbuffer + offset)); offset += 4; for(unsigned int k= offset; k< offset+length_id; ++k){ inbuffer[k-1]=inbuffer[k]; } inbuffer[offset+length_id-1]=0; this->id = (char *)(inbuffer + offset-1); offset += length_id; uint32_t length_face_id; arrToVar(length_face_id, (inbuffer + offset)); offset += 4; for(unsigned int k= offset; k< offset+length_face_id; ++k){ inbuffer[k-1]=inbuffer[k]; } inbuffer[offset+length_face_id-1]=0; this->face_id = (char *)(inbuffer + offset-1); offset += length_face_id; uint32_t body_parts_lengthT = ((uint32_t) (*(inbuffer + offset))); body_parts_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); body_parts_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); body_parts_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); offset += sizeof(this->body_parts_length); if(body_parts_lengthT > body_parts_length) this->body_parts = (human_awareness_msgs::BodyPart*)realloc(this->body_parts, body_parts_lengthT * sizeof(human_awareness_msgs::BodyPart)); body_parts_length = body_parts_lengthT; for( uint32_t i = 0; i < body_parts_length; i++){ offset += this->st_body_parts.deserialize(inbuffer + offset); memcpy( &(this->body_parts[i]), &(this->st_body_parts), sizeof(human_awareness_msgs::BodyPart)); } uint32_t openface_features_lengthT = ((uint32_t) (*(inbuffer + offset))); openface_features_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); openface_features_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); openface_features_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); offset += sizeof(this->openface_features_length); if(openface_features_lengthT > openface_features_length) this->openface_features = (human_awareness_msgs::OpenFaceFeatures*)realloc(this->openface_features, openface_features_lengthT * sizeof(human_awareness_msgs::OpenFaceFeatures)); openface_features_length = openface_features_lengthT; for( uint32_t i = 0; i < openface_features_length; i++){ offset += this->st_openface_features.deserialize(inbuffer + offset); memcpy( &(this->openface_features[i]), &(this->st_openface_features), sizeof(human_awareness_msgs::OpenFaceFeatures)); } offset += this->body.deserialize(inbuffer + offset); offset += this->body_pose.deserialize(inbuffer + offset); offset += this->head_pose.deserialize(inbuffer + offset); offset += this->velocity.deserialize(inbuffer + offset); return offset; } const char * getType(){ return "human_awareness_msgs/AnalyzedSocsigPerson"; }; const char * getMD5(){ return "a5acdf48e5b58c2c2cebba48389d54aa"; }; }; } #endif
8dc4de0c790488ffcfb7815462245be0ef810a94
8e3e9d528488eed9b08d9c6fca4bc8d911077805
/Sieve_of_Eratosthenes.cpp
53adf029eb8b0a9ceab7734f3db4da53fe13f17f
[]
no_license
Sam071100/CPlusPlus-OOPS
9856de4ebc4ce2846a4eddb374c8ea304589a245
b4fb82f8b16f1445919f5032a6a0f4f8eb32fe49
refs/heads/main
2023-08-15T16:44:02.574165
2021-09-06T08:57:04
2021-09-06T08:57:04
370,747,855
0
1
null
2021-10-02T11:31:39
2021-05-25T15:48:51
C++
UTF-8
C++
false
false
624
cpp
Sieve_of_Eratosthenes.cpp
#include <bits/stdc++.h> using namespace std; void sieveOfEratosthenes(int n) { bool prime[n + 1]; memset(prime, true, sizeof(prime)); for (int p = 2; p * p <= n; p++) { if (prime[p] == true) { for (int i = p * p; i <= n; i += p) { prime[i] = false; } } } for (int p = 2; p <= n; p++) { if (prime[p]) { cout <<p<<" "; } } } int main() { int n; cout <<"Enter the Number till you want to print the Prime number\n"; cin >>n; sieveOfEratosthenes(n); return 0; }
3966b619e55fe7f2a63eecf54fff5a3a24e63951
1d6cf2919e1cadb8dcf5cc8bbb69c5e19e1946ec
/class_training/0918-6.cpp
8e930264e6d72419288703a5eeec80dac6701085
[]
no_license
joey-z/autonomic
f4d9a3a684fdef3db202f63166bdbdbe003b1757
8b3bd656c5be15d5aff357e16810454cd233b0be
refs/heads/master
2020-03-28T08:06:20.774650
2018-12-27T11:48:36
2018-12-27T11:48:36
147,944,818
0
0
null
null
null
null
UTF-8
C++
false
false
444
cpp
0918-6.cpp
/************************************************************************* > File Name: 0918-6.cpp > Author: zoe > Mail: > Created Time: 2018年09月18日 星期二 20时50分46秒 ************************************************************************/ //使用while 循环实现程序 输出1-100 // #include <stdio.h> int main() { int n = 1; while (n < 100) { n++; printf("%d\n", n); } return 0; }
350dccbbb3b8ce03051fa7e1e2abd08aeee2bf24
6d49421a68d84b0cd0e8400e10619982a1472158
/Torre.cpp
1db1658f18f36626a5386949aaa6c51367acee96
[]
no_license
kech37/tp-poo
51f82e8d7db9541dae36a38c0250ce6be961ac0a
955470a40dc4dcc02008a7eb41dea80dd4c44b61
refs/heads/master
2021-01-11T21:20:17.012153
2017-01-20T23:42:56
2017-01-20T23:42:56
78,765,231
0
1
null
2017-01-14T01:11:42
2017-01-12T16:38:29
C++
UTF-8
C++
false
false
710
cpp
Torre.cpp
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: Torre.cpp * Author: carlo * * Created on 12 de Janeiro de 2017, 18:49 */ #include "Torre.h" Torre::Torre(int linha, int coluna, int equipa) : Edificios("T", 30, 20, 10, linha, coluna, equipa) { this->ataque = 3; this->tipo = this->TORRE; } Torre::Torre(const Torre& t) : Torre(t.getLinha(), t.getColuna(), t.getEquipa()) { } int Torre::getAtaque() const { return ataque; } int Torre::getTipo() const { return this->tipo; } Torre::~Torre() { }
8eb277e7bf3de452540cbc3df0b3023feb0bb092
8590b7928fdcff351a6e347c4b04a085f29b7895
/VIC_CropSyst/crop/calibration/calibrate_season_engine.cpp
5aa1978089effaf16bcf78d2155a2594a9f29bc5
[]
no_license
liao007/VIC-CropSyst-Package
07fd0f29634cf28b96a299dc07156e4f98a63878
63a626250ccbf9020717b7e69b6c70e40a264bc2
refs/heads/master
2023-05-23T07:15:29.023973
2021-05-29T02:17:32
2021-05-29T02:17:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,169
cpp
calibrate_season_engine.cpp
#include "calibrate_season_engine.h" #include "crop/crop_param_V5.h" #include "corn/format/binary/binary_file_fstream.h" #include "corn/file_sys/filename.h" #include "corn/math/compare.hpp" //ofstream test_GDD_out("GDD.dat"); //______________________________________________________________________________ Season_calibrator::Season_calibrator(VIC_crop::Crop_parameters &_crop_parameter) :sowing_DOY_stats() ,maturity_deg_days_stats() ,perennial_bud_or_restart_deg_days_stats() ,days_to_maturity(0) ,curr_inducement_duration(0) ,curr_accum_deg_day(0) ,in_season(false) ,found_inducible_period(false) ,crop_parameter(_crop_parameter) ,finished_season_year(0) {} //______________________________________________________________________________ const char *Season_calibrator::get_key() const { return crop_parameter.get_key();} //______________________________________________________________________________ bool Season_calibrator::process(const CORN::Date &date, float64 Tmax, float64 Tmin) { bool processed = crop_parameter.is_perennial() ? process_perennial_crop (date, Tmax, Tmin) : process_annual_crop (date, Tmax, Tmin); test_accum_output(date, Tmax, Tmin); //110908 return processed; } //______________________________________________________________________________ bool Season_calibrator::process_perennial_crop (const CORN::Date &date, float64 Tmax, float64 Tmin) { float64 Tavg = (Tmax+Tmin)/2.0; bool maturity_found = false; CORN::DOY doy = date.get_DOY(); CORN::Year year = date.get_year(); if ((year != finished_season_year)) { if (doy == 1) { // begin accumulating deg days until day the earliest start DOY (I.e. day 90) // for the region (WA,ID,OR). curr_accum_deg_day = 0; test_curr_accum_deg_day = 0; //110907 } else if (doy == crop_parameter.season_correction.earliest_start_DOY) { // earliest_start_DOY represents budbreak for trees, start of season for perennials perennial_bud_or_restart_deg_days_stats.append(curr_accum_deg_day); // Now begin accumulating deg das until maturity curr_accum_deg_day = 0; test_curr_accum_deg_day = 0; //110907 in_season = true; days_to_maturity = 0; } float64 deg_day_base_temp = crop_parameter.thermal_time.base_temperature; float64 deg_day_cutoff_temp = crop_parameter.thermal_time.cutoff_temperature; float64 avg_plant_temp = Tavg; avg_plant_temp = (avg_plant_temp > deg_day_cutoff_temp) ? deg_day_cutoff_temp : avg_plant_temp; if (Tavg > deg_day_base_temp) { float64 growing_degree_day = avg_plant_temp - deg_day_base_temp; curr_accum_deg_day += growing_degree_day; } if (in_season) { if (days_to_maturity < crop_parameter.season_correction.duration) days_to_maturity++; else { //We've reach the target days to maturity. maturity_deg_days_stats.append(curr_accum_deg_day); maturity_DOY_stats.append(doy); maturity_found = true; in_season = false; finished_season_year = year; } } } return maturity_found; } //______________________________________________________________________________ bool Season_calibrator::process_annual_crop (const CORN::Date &date, float64 Tmax, float64 Tmin) { float64 Tavg = (Tmax+Tmin)/2.0; bool maturity_found = false; CORN::DOY doy = date.get_DOY(); CORN::Year year = date.get_year(); bool winter_crop = (crop_parameter.season_correction.earliest_start_DOY>182); if ((year != finished_season_year) || winter_crop) { if (doy == 1) { curr_inducement_duration = 0; found_inducible_period = false; test_curr_accum_deg_day = 0; //110907 } else { if (in_season) { window_avg_temperatures.clear(); if (days_to_maturity < crop_parameter.season_correction.duration) { float64 deg_day_base_temp = crop_parameter.thermal_time.base_temperature; float64 deg_day_cutoff_temp = crop_parameter.thermal_time.cutoff_temperature; float64 Tavg = (Tmax + Tmin) / 2.0; float64 avg_plant_temp = Tavg; avg_plant_temp = (avg_plant_temp > deg_day_cutoff_temp) ? deg_day_cutoff_temp : avg_plant_temp; if (Tavg > deg_day_base_temp) { float64 growing_degree_day = avg_plant_temp - deg_day_base_temp; curr_accum_deg_day += growing_degree_day; } days_to_maturity++; } else { //We've reach the target days to maturity. maturity_deg_days_stats.append(curr_accum_deg_day); maturity_DOY_stats.append(doy); maturity_found = true; in_season = false; finished_season_year = year; } } else // still looking for the start of the season. { if (winter_crop) { // Winter crop if (doy > crop_parameter.season_correction.earliest_start_DOY) in_season = true; } else { //Spring/summer crop window_avg_temperatures.append(Tavg); if (window_avg_temperatures.get_count() == 7 /*110911 crop_parameter.inactive_period.consider_inactive_days*/ ) { float64 mean_window_avg_temp = window_avg_temperatures.get_mean(); if (mean_window_avg_temp > crop_parameter.thermal_time.base_temperature) //110911 found_inducible_period = true; else window_avg_temperatures.remove(0); } if (found_inducible_period && (doy >= crop_parameter .season_correction.earliest_start_DOY)) { in_season = true; sowing_doy = doy; DOY_crossed_found = false; test_curr_accum_deg_day = 0; //110908 } } if (in_season ) { sowing_DOY_stats.append(doy); days_to_maturity = 0; curr_accum_deg_day = 0.0; } } } } return maturity_found; } //______________________________________________________________________________ bool Season_calibrator::test_accum_output (const CORN::Date &date, float64 Tmax, float64 Tmin) { float64 Tavg = (Tmax+Tmin)/2.0; bool maturity_found = false; CORN::DOY doy = date.get_DOY(); CORN::Year year = date.get_year(); float64 deg_day_base_temp = crop_parameter.thermal_time.base_temperature; float64 deg_day_cutoff_temp = crop_parameter.thermal_time.cutoff_temperature; float64 avg_plant_temp = Tavg; avg_plant_temp = (avg_plant_temp > deg_day_cutoff_temp) ? deg_day_cutoff_temp : avg_plant_temp; if (Tavg > deg_day_base_temp) { float64 growing_degree_day = avg_plant_temp - deg_day_base_temp; test_curr_accum_deg_day += growing_degree_day; } if ((test_curr_accum_deg_day > 2241) && !DOY_crossed_found) {DOY_crossed_found = true; DOY_crossed.append(doy - sowing_doy); } return maturity_found; } //______________________________________________________________________________ float64 Season_calibrator ::get_phenology_adjustment_given_historical_maturity_deg_days(float64 historical_maturity_deg_days) { float64 adjust = maturity_deg_days_stats.get_mean() / historical_maturity_deg_days; //110902 if (adjust > 1.0) adjust = 1.0; //110519 We decided to only adjust to shorten the season return adjust; } //______________________________________________________________________________ float64 Season_calibrator::get_phenology_adjustment() { return get_phenology_adjustment_given_historical_maturity_deg_days(crop_parameter.phenology.begin_maturity_deg_day); } //______________________________________________________________________________ float64 Season_calibrator::get_start_season_adjustment() { float64 restart_degday_mean = perennial_bud_or_restart_deg_days_stats.get_mean(); float64 param_restart_degday = crop_parameter.phenology.emergence_deg_day; bool perennial = crop_parameter.is_perennial(); return (perennial && (param_restart_degday > 0.00001)) ? restart_degday_mean / param_restart_degday : 1.0 ; } //_2011-03-14___________________________________________________________________ float32 Season_calibrations::Calibration::set_adjustments( float64 at_latitude,float64 at_longitude ,float32 new_phenology_adjustment ,float32 new_season_start_adjustment) { FIND_FOR_EACH_IN(found_adjustment,adjustment,Season_calibrations::Calibration::Adjustment,adjustments,true,each_adj) { if (CORN::is_approximately(adjustment->latitude,at_latitude,0.00001) && CORN::is_approximately(adjustment->longitude,at_longitude,0.00001)) found_adjustment = adjustment; } FOR_EACH_END(each_adj); if (!found_adjustment) { found_adjustment = new Season_calibrations::Calibration::Adjustment; found_adjustment->latitude = at_latitude; found_adjustment->longitude = at_longitude; adjustments.append(found_adjustment); } found_adjustment->phenology_adjustment = new_phenology_adjustment; found_adjustment->season_start_adjustment = new_season_start_adjustment; return new_phenology_adjustment; } //_2011-03-14___________________________________________________________________ float32 Season_calibrations::set_adjustments (const char *crop_ID ,float64 at_latitude,float64 at_longitude ,float32 phenology_adjustment ,float32 season_start_adjustment) { Calibration *calibration = dynamic_cast<Calibration *>(find(crop_ID)); if (!calibration) { calibration = new Calibration(crop_ID); append(calibration); } calibration->set_adjustments (at_latitude,at_longitude ,phenology_adjustment ,season_start_adjustment ); return phenology_adjustment; } //______________________________________________________________________________ Season_calibrations::Season_calibrations(const CORN::Directory_name &season_calibrations_directory_name) : calibration_directory_name(season_calibrations_directory_name) {} Season_calibrations::Season_calibrations(const char *season_calibrations_directory_name) : calibration_directory_name(season_calibrations_directory_name) {} //______________________________________________________________________________ nat32 Season_calibrations::read_calibration_files() { nat32 files_read = 0; CORN::Association_list calibration_files; calibration_directory_name.list_contents_by_type (calibration_files ,false // not recursive ,true // quality ,true // with ext ,true // show path ,true //show extension ,CORN::Directory_entry_name::file_entry ,"CS_crop"); FOR_EACH_IN(calibration_filename,CORN::File_name,calibration_files,each_calib_file) { Calibration *calibration = new Calibration(calibration_filename->get_name(false)); calibration->read(*calibration_filename); append(calibration); files_read ++; } FOR_EACH_END(each_calib_file); return files_read; //NYI } //______________________________________________________________________________ nat32 Season_calibrations::write_calibration_files() { nat32 written = 0; std::cout << "Writing crop calibrations" << std::endl; FOR_EACH(calibration,Calibration,each_calib) { calibration->write(calibration_directory_name); std::cout << calibration->get_key() << std::endl; written++; } FOR_EACH_END(each_calib); return written; } //______________________________________________________________________________ bool Season_calibrations::Calibration::Adjustment::read(CORN::Binary_file_fstream &binfstream) { latitude = binfstream.read_float64(); longitude = binfstream.read_float64(); phenology_adjustment = binfstream.read_float32(); season_start_adjustment = binfstream.read_float32(); return true; } //______________________________________________________________________________ nat32 Season_calibrations::Calibration::read(const CORN::File_name &calibration_filename) { CORN::Binary_file_fstream calib_file(calibration_filename.c_str(),false); bool at_eof = !calib_file.good(); int cell_count = 0; while (!at_eof) { Season_calibrations::Calibration::Adjustment *adjustment = new Season_calibrations::Calibration::Adjustment; adjustment->read(calib_file); adjustments.append(adjustment); } return 0; // NYI } //______________________________________________________________________________ nat32 Season_calibrations::Calibration::write(const CORN::Directory_name &calibration_directory_name) { nat32 written = 0; CORN::File_name crop_adjustment_file_name(crop_ID.c_str(),VIC_crop_adjust_ext); crop_adjustment_file_name.set_path(calibration_directory_name); std::ofstream calibration_file(crop_adjustment_file_name.c_str(),std::ofstream::binary); adjustments.sort(); FOR_EACH_IN(adjustment,Season_calibrations::Calibration::Adjustment,adjustments,each_adj) { calibration_file.write((char *)(&adjustment->latitude),sizeof(float64)); calibration_file.write((char *)(&adjustment->longitude),sizeof(float64)); calibration_file.write((char *)(&adjustment->phenology_adjustment),sizeof(float32)); calibration_file.write((char *)(&adjustment->season_start_adjustment),sizeof(float32)); //110314 written ++; } FOR_EACH_END(each_adj); return written; } //______________________________________________________________________________
244fd8b5f7b87499ff2e5e2c6dd4c92674b2be86
613fa33cba109498a4e7f27d01238c1f7795ce3d
/project/Constructor.h
7379e122e3eb52c3ae65a006dce05300e382a959
[]
no_license
SiyingJIANG/Compilateur
5c496904a4575ad8248caebfd8358fa0da648355
67d18a9e475d806d568070700619a2b68cabce37
refs/heads/master
2020-03-31T19:07:10.337660
2018-10-10T20:27:41
2018-10-10T20:27:41
152,485,565
0
0
null
null
null
null
UTF-8
C++
false
false
4,063
h
Constructor.h
// // Created by Gheorghe on 12-Mar-18. // #ifndef PROJECT_CONSTRUCTOR_H #define PROJECT_CONSTRUCTOR_H #include <antlr/subCBaseVisitor.h> class Constructor: public subCBaseVisitor { public: antlrcpp::Any visitProg(subCParser::ProgContext *ctx) override; antlrcpp::Any visitFunctionDef(subCParser::FunctionDefContext *ctx) override; antlrcpp::Any visitVariableDec(subCParser::VariableDecContext *ctx) override; antlrcpp::Any visitChar(subCParser::CharContext *ctx) override; antlrcpp::Any visitInt32(subCParser::Int32Context *ctx) override; antlrcpp::Any visitInt64(subCParser::Int64Context *ctx) override; antlrcpp::Any visitVoid(subCParser::VoidContext *ctx) override; antlrcpp::Any visitConst_expr(subCParser::Const_exprContext *ctx) override; antlrcpp::Any visitDecVariable(subCParser::DecVariableContext *ctx) override; antlrcpp::Any visitVar_simple(subCParser::Var_simpleContext *ctx) override; antlrcpp::Any visitVar_table_size(subCParser::Var_table_sizeContext *ctx) override; antlrcpp::Any visitVar_table(subCParser::Var_tableContext *ctx) override; antlrcpp::Any visitVarInit1(subCParser::VarInit1Context *ctx) override; antlrcpp::Any visitVarInit2(subCParser::VarInit2Context *ctx) override; antlrcpp::Any visitScalarInit(subCParser::ScalarInitContext *ctx) override; antlrcpp::Any visitDefFun_param(subCParser::DefFun_paramContext *ctx) override; antlrcpp::Any visitDefFun_no_param(subCParser::DefFun_no_paramContext *ctx) override; antlrcpp::Any visitListeparam(subCParser::ListeparamContext *ctx) override; antlrcpp::Any visitParam(subCParser::ParamContext *ctx) override; antlrcpp::Any visitBloc(subCParser::BlocContext *ctx) override; antlrcpp::Any visitStatement(subCParser::StatementContext *ctx) override; antlrcpp::Any visitStmtCompound(subCParser::StmtCompoundContext *ctx) override; antlrcpp::Any visitStmtExpression(subCParser::StmtExpressionContext *ctx) override; antlrcpp::Any visitStmtWhile(subCParser::StmtWhileContext *ctx) override; antlrcpp::Any visitStmtIf(subCParser::StmtIfContext *ctx) override; antlrcpp::Any visitStmtElse(subCParser::StmtElseContext *ctx) override; antlrcpp::Any visitStmtReturn(subCParser::StmtReturnContext *ctx) override; // antlrcpp::Any visitStmtGetchar(subCParser::StmtGetcharContext *ctx) override; antlrcpp::Any visitStmtPutchar(subCParser::StmtPutcharContext *ctx) override; antlrcpp::Any visitStmtBreak(subCParser::StmtBreakContext *ctx) override; antlrcpp::Any visitStmtContinue(subCParser::StmtContinueContext *ctx) override; antlrcpp::Any visitIdentifier(subCParser::IdentifierContext *ctx) override; antlrcpp::Any visitNumericValue(subCParser::NumericValueContext *ctx) override; antlrcpp::Any visitCharValue(subCParser::CharValueContext *ctx) override; antlrcpp::Any visitParantheses(subCParser::ParanthesesContext *ctx) override; antlrcpp::Any visitSubscript(subCParser::SubscriptContext *ctx) override; antlrcpp::Any visitPrimaryE(subCParser::PrimaryEContext *ctx) override; antlrcpp::Any visitCallFunction(subCParser::CallFunctionContext *ctx) override; antlrcpp::Any visitPostunary(subCParser::PostunaryContext *ctx) override; antlrcpp::Any visitFunctionCall(subCParser::FunctionCallContext *ctx) override; antlrcpp::Any visitArguments(subCParser::ArgumentsContext *ctx) override; antlrcpp::Any visitPostfixE(subCParser::PostfixEContext *ctx) override; antlrcpp::Any visitPreunary(subCParser::PreunaryContext *ctx) override; antlrcpp::Any visitBinaryE(subCParser::BinaryEContext *ctx) override; antlrcpp::Any visitAssignment(subCParser::AssignmentContext *ctx) override; antlrcpp::Any visitAffectation(subCParser::AffectationContext *ctx) override; antlrcpp::Any visitExpression(subCParser::ExpressionContext *ctx) override; antlrcpp::Any visitBinaryExpression(subCParser::BinaryExpressionContext *ctx) override; }; #endif //PROJECT_CONSTRUCTOR_H
c6f9d43aca89ab2e58807d719b8c930b641c41cd
006f035d65012b7c5af15d54716407a276a096a8
/src/Core/src/sbt-core.cpp
671ec196803b72e29d879167067252474740871e
[]
no_license
rosecodym/space-boundary-tool
4ce5b67fd96ec9b66f45aca60e0e69f4f8936e93
300db4084cd19b092bdf2e8432da065daeaa7c55
refs/heads/master
2020-12-24T06:51:32.828579
2016-08-12T16:13:51
2016-08-12T16:13:51
65,566,229
7
0
null
null
null
null
UTF-8
C++
false
false
4,341
cpp
sbt-core.cpp
#include "precompiled.h" #include "assign_openings.h" #include "build_blocks.h" #include "convert_to_space_boundaries.h" #include "equality_context.h" #include "exceptions.h" #include "geometry_common.h" #include "guid_filter.h" #include "identify_transmission.h" #include "load_elements.h" #include "load_spaces.h" #include "report.h" #include "space.h" #include "surface.h" #include "transmission_information.h" #include "sbt-core.h" sb_calculation_options g_opts; char g_msgbuf[256]; sbt_return_t calculate_space_boundaries_( size_t element_count, element_info ** element_infos, size_t space_count, space_info ** space_infos, size_t * space_boundary_count, space_boundary *** space_boundaries, sb_calculation_options opts); using namespace reporting; namespace { void do_nothing(char * /*msg*/) { } void exception_translator(unsigned int code, struct _EXCEPTION_POINTERS *) { if (code == EXCEPTION_STACK_OVERFLOW) { // don't call _resetskoflow() here yet - the stack isn't unwound. or something. throw stack_overflow_exception(); } else { throw sbt_exception(); } } class translator_setter { public: typedef void (*translator_t)(unsigned int, struct _EXCEPTION_POINTERS *); translator_setter(translator_t translator) : old_(_set_se_translator(translator)) { } ~translator_setter() { _set_se_translator(old_); } private: translator_t old_; }; } // namespace sbt_return_t calculate_space_boundaries( size_t element_count, element_info ** element_infos, size_t space_count, space_info ** space_infos, size_t * space_boundary_count, space_boundary *** space_boundaries, sb_calculation_options opts) { typedef boost::format fmt; g_opts = opts; if (g_opts.notify_func == NULL) { g_opts.notify_func = &do_nothing; } if (g_opts.warn_func == NULL) { g_opts.warn_func = &do_nothing; } if (g_opts.error_func == NULL) { g_opts.error_func = &do_nothing; } guid_filter element_filter = create_guid_filter( g_opts.element_filter, g_opts.element_filter_count); guid_filter space_filter = create_guid_filter( g_opts.space_filter, g_opts.space_filter_count); sbt_return_t retval; translator_setter translate(&exception_translator); try { report_progress( fmt("Beginning processing for %u building elements.\n") % element_count); equality_context ctxt(g_opts.tolernace_in_meters); double height_cutoff = g_opts.max_pair_distance_in_meters * g_opts.length_units_per_meter; std::vector<element> elements = load_elements( element_infos, element_count, &ctxt, element_filter); std::vector<space> spaces = load_spaces( space_infos, space_count, &ctxt, space_filter); std::vector<block> blocks = blocking::build_blocks( elements, &ctxt, height_cutoff); std::vector<transmission_information> t_info = traversal::identify_transmission( blocks, spaces, height_cutoff, &ctxt); std::vector<std::unique_ptr<surface>> surfaces; boost::for_each(t_info, [&](const transmission_information & ti) { ti.to_surfaces(std::back_inserter(surfaces)); }); auto opening_blocks = blocks | boost::adaptors::filtered([](const block & b) { return b.is_fenestration(); }); opening_assignment::assign_openings( &surfaces, opening_blocks, g_opts.length_units_per_meter / 3); report_progress( "Converting internal structures to interface structures"); retval = interface_conversion::convert_to_space_boundaries( surfaces, space_boundaries, space_boundary_count, opts.length_units_per_meter * opts.tolernace_in_meters); report_progress("done.\n"); } catch (sbt_exception & ex) { retval = ex.code(); } if (retval == SBT_STACK_OVERFLOW) { _resetstkoflw(); } return retval; } void release_space_boundaries(space_boundary ** sbs, size_t count) { for (size_t i = 0; i < count; ++i) { free(sbs[i]->geometry.vertices); free(sbs[i]); } free(sbs); } sb_calculation_options create_default_options() { sb_calculation_options opts; opts.flags = SBT_NONE; opts.length_units_per_meter = 1.0; opts.max_pair_distance_in_meters = 0.5; opts.space_filter = nullptr; opts.space_filter_count = 0; opts.element_filter = nullptr; opts.element_filter_count = 0; opts.notify_func = nullptr; opts.warn_func = nullptr; opts.error_func = nullptr; return opts; }
49a747300dab9ab2feddab8a5e7e6911195d597e
e70b8c9a6f71492db211d6ac8bf90860ca30a76e
/Segment Tree/2268번_수들의 합.cpp
e9e6577bf8aea76e14b2ba3219cdbf473aee963d
[]
no_license
orihehe/BOJ
b289031abf5736c7f9d933fa52a889d73de39614
6c78d53f8ec1a9251f252f913d5f8e3a6fdb14fc
refs/heads/master
2020-04-04T09:56:25.511131
2019-11-04T13:19:17
2019-11-04T13:19:17
155,836,795
3
1
null
null
null
null
UTF-8
C++
false
false
906
cpp
2268번_수들의 합.cpp
/* BOJ 2268 - 수들의 합 https://www.acmicpc.net/problem/2268 */ #include <cstdio> #include <algorithm> #define ll long long using namespace std; /* 🐣🐥 */ ll tree[2097152]; void update(int idx, int s, int e, int k, int val) { if (k<s || k>e) return; if (s == e) { tree[idx] = val; return; } update(idx * 2, s, (s + e) / 2, k, val); update(idx * 2 + 1, (s + e) / 2 + 1, e, k, val); tree[idx] = tree[idx * 2] + tree[idx * 2 + 1]; } ll hap(int idx, int s, int e, int l, int r) { if (e < l || r < s) return 0; if (l <= s && e <= r) return tree[idx]; return hap(idx * 2, s, (s + e) / 2, l, r) + hap(idx * 2 + 1, (s + e) / 2 + 1, e, l, r); } int main() { int n, m, a, b, c; scanf("%d %d", &n, &m); while (m--) { scanf("%d %d %d", &a, &b, &c); if (a == 0) { if (b > c) swap(b, c); printf("%lld\n", hap(1, 1, n, b, c)); } else update(1, 1, n, b, c); } return 0; }
884c3f62ebc6f83dfe712dcccd1250585d2d8439
cb517177a1a2fc008285c84c6ab105c29967cfcc
/Competition/UVa11503.cpp
6fd9154965ac1fe4c8acbb545577d5a2dd44c69f
[]
no_license
cshung/Competition
8b4219593bfe28372ba82fbf923437988d862e2c
f534f37b34a0ef2351f4af3926ac864fed6dafc5
refs/heads/main
2023-08-29T03:25:35.042880
2023-08-16T15:32:45
2023-08-16T15:32:45
23,745,091
0
0
null
null
null
null
UTF-8
C++
false
false
2,964
cpp
UVa11503.cpp
#include "stdafx.h" // http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2498 #include "UVa11503.h" #include <iostream> #include <string> #include <map> #include <cstdlib> #include <stdio.h> #include <vector> #include <list> using namespace std; int find(vector<int>& social_network, int id) { if (social_network[id] < 0) { return id; } else { list<int> path; while (social_network[id] >= 0) { path.push_back(id); id = social_network[id]; } for (list<int>::iterator pi = path.begin(); pi != path.end(); pi++) { social_network[*pi] = id; } return id; } } int UVa11503() { int number_of_cases; cin >> number_of_cases; for (int c = 0; c < number_of_cases; c++) { int number_of_friendship; cin >> number_of_friendship; map<string, int> names; vector<int> social_network; for (int f = 0; f < number_of_friendship; f++) { char name1Buffer[20]; char name2Buffer[20]; scanf("%s %s", name1Buffer, name2Buffer); string name1(name1Buffer); string name2(name2Buffer); int id1; int id2; map<string, int>::iterator probe1 = names.find(name1); if (probe1 == names.end()) { names.insert(pair<string, int>(name1, id1 = social_network.size())); social_network.push_back(-1); /* a new person is a network of size 1 */ } else { id1 = probe1->second; } map<string, int>::iterator probe2 = names.find(name2); if (probe2 == names.end()) { names.insert(pair<string, int>(name2, id2 = social_network.size())); social_network.push_back(-1); /* a new person is a network of size 1 */ } else { id2 = probe2->second; } int root1 = find(social_network, id1); int root2 = find(social_network, id2); if (root1 != root2) { // Union by size if (social_network[root1] < social_network[root2]) { social_network[root1] = social_network[root1] + social_network[root2]; social_network[root2] = root1; printf("%d\n", -social_network[root1]); } else { social_network[root2] = social_network[root1] + social_network[root2]; social_network[root1] = root2; printf("%d\n", -social_network[root2]); } } else { printf("%d\n", -social_network[root1]); } } } return 0; }
546a8563866d2257724a0dba449171e1a2770278
3519dfe8e536508168d751fab6111ae21e8cf0a9
/MenuLlamarFunciones.cpp
5e9a9cc3e9017e8181b31b34e4ca5d935f25456e
[]
no_license
villa97/codigos
464d648cd6f4a504cbff161d080b3b4f984e01df
178c741f815441ed008728391b783708d3b2fac6
refs/heads/master
2021-01-18T18:45:56.751839
2017-11-23T19:28:46
2017-11-23T19:28:46
100,521,079
0
0
null
null
null
null
UTF-8
C++
false
false
2,152
cpp
MenuLlamarFunciones.cpp
#include<iostream> #include <ctime> using namespace std; void Menu(); void llenar(int vec[], int tam); void mostrar(int vec[], int tam); void MostrarInverso(int vec[], int tam); void girarArriba(int vec[], int tam); void girarAbajo(int vec[], int tam); void Invertir(int vec[], int tam); int main() { int vec[10],menu,tam=10; for(int ciclo=0;ciclo<10;ciclo++) vec[ciclo]=0; do{system("cls"); Menu(); cout<<"ingresa tu seleccion: "; cin>>menu; switch(menu) { case 1: llenar(vec,tam); system("PAUSE"); break; case 2: mostrar(vec,tam); system("PAUSE"); break; case 3: MostrarInverso(vec,tam); system("PAUSE"); break; case 4: girarArriba(vec,tam); system("PAUSE"); break; case 5: girarAbajo(vec,tam); system("PAUSE"); break; case 6: Invertir(vec,tam); system("PAUSE"); break; case 0: break; default: cout<<"Seleccion erronea"; } }while(menu!=0); return 0; } void Menu() { cout<<"--------Menu--------"<<endl <<"1-Llenar Vector"<<endl <<"2-Mostrar Vector."<<endl <<"3-Mostrar vector Inversamente"<<endl <<"4-Girar Arriba"<<endl <<"5-Girar Abajo"<<endl <<"6-Invertir"<<endl <<"0-Salir"<<endl; } void llenar(int vec[], int tam) { for(int ciclo=0;ciclo<tam;ciclo++) vec[ciclo]=ciclo+1;; } void mostrar(int vec[], int tam) { for(int ciclo=0;ciclo<tam;ciclo++) cout<<vec[ciclo]<<endl; } void MostrarInverso(int vec[], int tam) { for(int ciclo=tam-1;ciclo>=0;ciclo--) cout<<vec[ciclo]<<endl; } void girarArriba(int vec[], int tam) { int temporal=vec[0]; for(int ciclo=0;ciclo<tam;ciclo++) { if(ciclo+1==tam) vec[ciclo] = temporal; else vec[ciclo]=vec[ciclo+1]; } } void girarAbajo(int vec[], int tam) { int temporal=vec[9]; for(int ciclo=tam;ciclo>=0;ciclo--) { if(ciclo-1<0) vec[ciclo] = temporal; else vec[ciclo]=vec[ciclo-1]; } } void Invertir(int vec[], int tam) { int temporal=0,cambio=tam; for(int ciclo=0;ciclo<tam/2;ciclo++) { temporal = vec[ciclo]; vec[ciclo]=vec[cambio-1]; vec[cambio-1]=temporal; cambio--; } }
eb2add8b30008b57cc2598b899c2f5bdaa1066a1
4a00a94923d938cd6c5a1bd4a9077f8f4a3c992b
/openFoam2/processor1/31/p
4f5ad2a2a7731fc146095389d07950d129136470
[]
no_license
mars2020/my_openfoam_2
c79813522ab0bb74fca9f3c6f4f4169a56d883b4
fda619bae0230cfb459aac15056ebea7e2d79b0e
refs/heads/master
2020-05-04T04:35:20.905005
2019-04-05T04:33:47
2019-04-05T04:33:47
178,968,612
1
0
null
null
null
null
UTF-8
C++
false
false
43,709
p
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6.0 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "31"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 4000 ( -0.25265 -0.253594 -0.254215 -0.254665 -0.25504 -0.255355 -0.255622 -0.255854 -0.256059 -0.256245 -0.256415 -0.256575 -0.256729 -0.256881 -0.257034 -0.2572 -0.257379 -0.257518 -0.257591 -0.258152 -0.252744 -0.253687 -0.254305 -0.254751 -0.255122 -0.255431 -0.255692 -0.255917 -0.256116 -0.256294 -0.256457 -0.256609 -0.256754 -0.256897 -0.257042 -0.257199 -0.257369 -0.2575 -0.257564 -0.258119 -0.252945 -0.253884 -0.254497 -0.254936 -0.255296 -0.255594 -0.255843 -0.256055 -0.25624 -0.256403 -0.25655 -0.256686 -0.256815 -0.256941 -0.25707 -0.25721 -0.257365 -0.257481 -0.257529 -0.258073 -0.253255 -0.254188 -0.254791 -0.255218 -0.255564 -0.255845 -0.256075 -0.256267 -0.25643 -0.25657 -0.256694 -0.256806 -0.256909 -0.25701 -0.257113 -0.257228 -0.25736 -0.257453 -0.257476 -0.258005 -0.253674 -0.254599 -0.25519 -0.2556 -0.255925 -0.256183 -0.256387 -0.256551 -0.256685 -0.256794 -0.256885 -0.256963 -0.257032 -0.257097 -0.257164 -0.257245 -0.257343 -0.257406 -0.257396 -0.257904 -0.254204 -0.255118 -0.255693 -0.256081 -0.256381 -0.256608 -0.256779 -0.256908 -0.257004 -0.257073 -0.257122 -0.257155 -0.257178 -0.257196 -0.257216 -0.25725 -0.257305 -0.257326 -0.257272 -0.257755 -0.254848 -0.255748 -0.256303 -0.256665 -0.256931 -0.257122 -0.257253 -0.257337 -0.257386 -0.257406 -0.257402 -0.25738 -0.257344 -0.257302 -0.257261 -0.257235 -0.257232 -0.257199 -0.25709 -0.25754 -0.255609 -0.256493 -0.257023 -0.257352 -0.257579 -0.257726 -0.257808 -0.257841 -0.257833 -0.257793 -0.257726 -0.257635 -0.257529 -0.257412 -0.257293 -0.257191 -0.257114 -0.25701 -0.25683 -0.25724 -0.256494 -0.257356 -0.257855 -0.258145 -0.258327 -0.258422 -0.258447 -0.25842 -0.258348 -0.258238 -0.258096 -0.257925 -0.257733 -0.257524 -0.257311 -0.257112 -0.256941 -0.256745 -0.256474 -0.256834 -0.257508 -0.258343 -0.258805 -0.259049 -0.259177 -0.259212 -0.259174 -0.259078 -0.258934 -0.258746 -0.258518 -0.258255 -0.257962 -0.257646 -0.257317 -0.256998 -0.256707 -0.256392 -0.256004 -0.256299 -0.25866 -0.259459 -0.259876 -0.260066 -0.260132 -0.260101 -0.259992 -0.259821 -0.259596 -0.259322 -0.259002 -0.258636 -0.258229 -0.257786 -0.25732 -0.256855 -0.256413 -0.255945 -0.255402 -0.25561 -0.259957 -0.26071 -0.261073 -0.2612 -0.261196 -0.26109 -0.260904 -0.260651 -0.260342 -0.259976 -0.259556 -0.259079 -0.258547 -0.257963 -0.257338 -0.256697 -0.256067 -0.255401 -0.254652 -0.254737 -0.26141 -0.262105 -0.262402 -0.262455 -0.262371 -0.262182 -0.261911 -0.261572 -0.261173 -0.260713 -0.26019 -0.259598 -0.258933 -0.258196 -0.257392 -0.256546 -0.255688 -0.254768 -0.253742 -0.253649 -0.263028 -0.26365 -0.263869 -0.263836 -0.26366 -0.263378 -0.263014 -0.262583 -0.262091 -0.261536 -0.260909 -0.2602 -0.259401 -0.258504 -0.257507 -0.256429 -0.2553 -0.254062 -0.252663 -0.252307 -0.264823 -0.265355 -0.265478 -0.265344 -0.265064 -0.264677 -0.26421 -0.26368 -0.263091 -0.262438 -0.261708 -0.260887 -0.259956 -0.258897 -0.2577 -0.256371 -0.254931 -0.253305 -0.251416 -0.250664 -0.266805 -0.267228 -0.267239 -0.266986 -0.266583 -0.266075 -0.265493 -0.264854 -0.264161 -0.263407 -0.262575 -0.261644 -0.260587 -0.259374 -0.257978 -0.25639 -0.254612 -0.252536 -0.250025 -0.248693 -0.268988 -0.269281 -0.269159 -0.268767 -0.26822 -0.267572 -0.266857 -0.266094 -0.265286 -0.264424 -0.263488 -0.26245 -0.261274 -0.25992 -0.25834 -0.256504 -0.254389 -0.251842 -0.248603 -0.24645 -0.27139 -0.27153 -0.271251 -0.270694 -0.26998 -0.269168 -0.268298 -0.267392 -0.266452 -0.26547 -0.264423 -0.263278 -0.261994 -0.260517 -0.258781 -0.256726 -0.254296 -0.251283 -0.247211 -0.243846 -0.274033 -0.273995 -0.273531 -0.272783 -0.271872 -0.270869 -0.269818 -0.268745 -0.267655 -0.266538 -0.265374 -0.264129 -0.262759 -0.261203 -0.25938 -0.257191 -0.254515 -0.251001 -0.245768 -0.240402 -0.276944 -0.2767 -0.276022 -0.275051 -0.273914 -0.272689 -0.271431 -0.270166 -0.268905 -0.267642 -0.266362 -0.265042 -0.26365 -0.26215 -0.260493 -0.258613 -0.256399 -0.253392 -0.248352 -0.242413 -0.280161 -0.279679 -0.278754 -0.277528 -0.276131 -0.274656 -0.273162 -0.271683 -0.270233 -0.268816 -0.267426 -0.266061 -0.264726 -0.263447 -0.262292 -0.26141 -0.26108 -0.261753 -0.265048 -0.277987 -0.283729 -0.28297 -0.281762 -0.280248 -0.278562 -0.276808 -0.275054 -0.273341 -0.271689 -0.270111 -0.268613 -0.267214 -0.26595 -0.264894 -0.264181 -0.264045 -0.264872 -0.26723 -0.27235 -0.284968 -0.287698 -0.286618 -0.285091 -0.283255 -0.28125 -0.279193 -0.277161 -0.275201 -0.273339 -0.271596 -0.269993 -0.268562 -0.267363 -0.266495 -0.266116 -0.266464 -0.267883 -0.270812 -0.275868 -0.285687 -0.292126 -0.290675 -0.288788 -0.2866 -0.284251 -0.281871 -0.279547 -0.27733 -0.275254 -0.273345 -0.271631 -0.270155 -0.268987 -0.268228 -0.268024 -0.26857 -0.270111 -0.272909 -0.277232 -0.284273 -0.297074 -0.295193 -0.292906 -0.290336 -0.28762 -0.284903 -0.282277 -0.279797 -0.2775 -0.275415 -0.273572 -0.272015 -0.270807 -0.270036 -0.269814 -0.270273 -0.271551 -0.273762 -0.276997 -0.281504 -0.3026 -0.300227 -0.297498 -0.294519 -0.291417 -0.28835 -0.285413 -0.282662 -0.280131 -0.277846 -0.275834 -0.27413 -0.272782 -0.271854 -0.271416 -0.271542 -0.272288 -0.273672 -0.275715 -0.278166 -0.308758 -0.305825 -0.302615 -0.299203 -0.295699 -0.29227 -0.289011 -0.285972 -0.28318 -0.280653 -0.278405 -0.276461 -0.274848 -0.273604 -0.272765 -0.272361 -0.272399 -0.272854 -0.273717 -0.274559 -0.315595 -0.312033 -0.308303 -0.304436 -0.300517 -0.296712 -0.293112 -0.289756 -0.286657 -0.283818 -0.281242 -0.278938 -0.276917 -0.275197 -0.273792 -0.272709 -0.271936 -0.271438 -0.271199 -0.270805 -0.323144 -0.318886 -0.314601 -0.310262 -0.305911 -0.301711 -0.29774 -0.294017 -0.290539 -0.287292 -0.284268 -0.281464 -0.278883 -0.276534 -0.274424 -0.272555 -0.270915 -0.269481 -0.268233 -0.266854 -0.331424 -0.326407 -0.321538 -0.316711 -0.311911 -0.307286 -0.302894 -0.29873 -0.294771 -0.290991 -0.287376 -0.283919 -0.280628 -0.277514 -0.27459 -0.271864 -0.269334 -0.266994 -0.264824 -0.262614 -0.340434 -0.334603 -0.329127 -0.323797 -0.318522 -0.313427 -0.30854 -0.303831 -0.299261 -0.294799 -0.290434 -0.286172 -0.282032 -0.278041 -0.274224 -0.2706 -0.26718 -0.26397 -0.26095 -0.257996 -0.35015 -0.343461 -0.337362 -0.331512 -0.325726 -0.320093 -0.314609 -0.30922 -0.30388 -0.298569 -0.293294 -0.288083 -0.28298 -0.278029 -0.273271 -0.268736 -0.264442 -0.260402 -0.25659 -0.252941 -0.360521 -0.352943 -0.34621 -0.339821 -0.33347 -0.327203 -0.320988 -0.314755 -0.30847 -0.302138 -0.295801 -0.289521 -0.283368 -0.277406 -0.271689 -0.266251 -0.261114 -0.256286 -0.251732 -0.247426 -0.371462 -0.362982 -0.35561 -0.348651 -0.341659 -0.334635 -0.327523 -0.320262 -0.312847 -0.305331 -0.297802 -0.290361 -0.283105 -0.276115 -0.269446 -0.263133 -0.257191 -0.251621 -0.246374 -0.241448 -0.382855 -0.373475 -0.365463 -0.357889 -0.350156 -0.342219 -0.334022 -0.325536 -0.316813 -0.307971 -0.299151 -0.290494 -0.282116 -0.274105 -0.266514 -0.259367 -0.252669 -0.246408 -0.240516 -0.235015 -0.394541 -0.384284 -0.375628 -0.367379 -0.358775 -0.349744 -0.340258 -0.330353 -0.320165 -0.309886 -0.299714 -0.289821 -0.280333 -0.271335 -0.262867 -0.254939 -0.24754 -0.240642 -0.234156 -0.22813 -0.406323 -0.395227 -0.385923 -0.376916 -0.367285 -0.356961 -0.345981 -0.334482 -0.322702 -0.310916 -0.29937 -0.288255 -0.277696 -0.267763 -0.258477 -0.249827 -0.241787 -0.234309 -0.227284 -0.22079 -0.417962 -0.406083 -0.396117 -0.386249 -0.375416 -0.363591 -0.350925 -0.337688 -0.324234 -0.310914 -0.29801 -0.285717 -0.274147 -0.263345 -0.253308 -0.244004 -0.235386 -0.227391 -0.219882 -0.212984 -0.429181 -0.41659 -0.40594 -0.395088 -0.382865 -0.369339 -0.354824 -0.339748 -0.324584 -0.309745 -0.295534 -0.282132 -0.269628 -0.258035 -0.247323 -0.237436 -0.228308 -0.219858 -0.211928 -0.20469 -0.43967 -0.426448 -0.415084 -0.403109 -0.389307 -0.373903 -0.357417 -0.340451 -0.323588 -0.307287 -0.291849 -0.27743 -0.264081 -0.251785 -0.240479 -0.230084 -0.220518 -0.211679 -0.20339 -0.195883 -0.439875 -0.42665 -0.415285 -0.403308 -0.389505 -0.3741 -0.357611 -0.340643 -0.323778 -0.307475 -0.292035 -0.277615 -0.264266 -0.251968 -0.240662 -0.230266 -0.220701 -0.211862 -0.203574 -0.196067 -0.429379 -0.416785 -0.406134 -0.39528 -0.383056 -0.36953 -0.355013 -0.339935 -0.32477 -0.30993 -0.295717 -0.282315 -0.26981 -0.258217 -0.247505 -0.237618 -0.228491 -0.220041 -0.212112 -0.204875 -0.418152 -0.406271 -0.396303 -0.386434 -0.375601 -0.363775 -0.351108 -0.33787 -0.324416 -0.311095 -0.29819 -0.285897 -0.274326 -0.263524 -0.253488 -0.244185 -0.235567 -0.227573 -0.220066 -0.213169 -0.406506 -0.395408 -0.386102 -0.377095 -0.367464 -0.357139 -0.346158 -0.334659 -0.322879 -0.311093 -0.299547 -0.288431 -0.277873 -0.267939 -0.258654 -0.250006 -0.241966 -0.23449 -0.227466 -0.220974 -0.394717 -0.384458 -0.375801 -0.367552 -0.358947 -0.349916 -0.34043 -0.330525 -0.320337 -0.310058 -0.299886 -0.289993 -0.280506 -0.271509 -0.263042 -0.255115 -0.247717 -0.240821 -0.234337 -0.228313 -0.383024 -0.373643 -0.36563 -0.358055 -0.350321 -0.342385 -0.334188 -0.325702 -0.31698 -0.308138 -0.299318 -0.290662 -0.282285 -0.274275 -0.266685 -0.25954 -0.252844 -0.246586 -0.240695 -0.235197 -0.371625 -0.363144 -0.355771 -0.34881 -0.341819 -0.334795 -0.327683 -0.320423 -0.313008 -0.305493 -0.297964 -0.290525 -0.28327 -0.276281 -0.269613 -0.263302 -0.257363 -0.251796 -0.246551 -0.241628 -0.360678 -0.353099 -0.346365 -0.339975 -0.333623 -0.327357 -0.321141 -0.31491 -0.308625 -0.302294 -0.295958 -0.289679 -0.283528 -0.277568 -0.271852 -0.266417 -0.261282 -0.256456 -0.251905 -0.247603 -0.350302 -0.343612 -0.337511 -0.331661 -0.325874 -0.32024 -0.314757 -0.309368 -0.304029 -0.298719 -0.293445 -0.288236 -0.283135 -0.278186 -0.273429 -0.268897 -0.264606 -0.260569 -0.25676 -0.253114 -0.34058 -0.334748 -0.329271 -0.32394 -0.318665 -0.313569 -0.308682 -0.303974 -0.299404 -0.294943 -0.290579 -0.286319 -0.282181 -0.278192 -0.274377 -0.270756 -0.267339 -0.264132 -0.261115 -0.258164 -0.331565 -0.326548 -0.321678 -0.31685 -0.312048 -0.307423 -0.303031 -0.298867 -0.294908 -0.291129 -0.287515 -0.28406 -0.280771 -0.277659 -0.274737 -0.272014 -0.269487 -0.26715 -0.264984 -0.262778 -0.32328 -0.319022 -0.314736 -0.310396 -0.306045 -0.301843 -0.297871 -0.294148 -0.290669 -0.287423 -0.284401 -0.281597 -0.279018 -0.276672 -0.274565 -0.272698 -0.271061 -0.26963 -0.268386 -0.26701 -0.315727 -0.312165 -0.308434 -0.304566 -0.300646 -0.296839 -0.293238 -0.289881 -0.286781 -0.283943 -0.281368 -0.279065 -0.277046 -0.275328 -0.273926 -0.272845 -0.272075 -0.27158 -0.271344 -0.270953 -0.308887 -0.305954 -0.302743 -0.299329 -0.295824 -0.292392 -0.289131 -0.286091 -0.283299 -0.280771 -0.278524 -0.276581 -0.27497 -0.273728 -0.272892 -0.27249 -0.27253 -0.272988 -0.273853 -0.274698 -0.302725 -0.300353 -0.297624 -0.294643 -0.291539 -0.288468 -0.285529 -0.282776 -0.280244 -0.277958 -0.275946 -0.274243 -0.272897 -0.271971 -0.271535 -0.271663 -0.272411 -0.273798 -0.275842 -0.278295 -0.297198 -0.295318 -0.29303 -0.290457 -0.287738 -0.285017 -0.282388 -0.279906 -0.277608 -0.275521 -0.273677 -0.272121 -0.270915 -0.270146 -0.269926 -0.270387 -0.271666 -0.273879 -0.277115 -0.281622 -0.292249 -0.290798 -0.28891 -0.28672 -0.284366 -0.281983 -0.279655 -0.277435 -0.275356 -0.273445 -0.271731 -0.270256 -0.269089 -0.268332 -0.268129 -0.268677 -0.270219 -0.273018 -0.277341 -0.284381 -0.287821 -0.286742 -0.285213 -0.283374 -0.281364 -0.279303 -0.277266 -0.275302 -0.273437 -0.271693 -0.270088 -0.268658 -0.26746 -0.266594 -0.266216 -0.266565 -0.267985 -0.270913 -0.275967 -0.285783 -0.283854 -0.283095 -0.281885 -0.280367 -0.278675 -0.276916 -0.275157 -0.27344 -0.271785 -0.270204 -0.268705 -0.267306 -0.266043 -0.264989 -0.264277 -0.264142 -0.264968 -0.267324 -0.272439 -0.285052 -0.280291 -0.279807 -0.278879 -0.277648 -0.276246 -0.274765 -0.273265 -0.271781 -0.270328 -0.268907 -0.267516 -0.266151 -0.264817 -0.263539 -0.262384 -0.261503 -0.261171 -0.261839 -0.265125 -0.278052 -0.277079 -0.276832 -0.27615 -0.275174 -0.274031 -0.2728 -0.271535 -0.270265 -0.268999 -0.267734 -0.266452 -0.265131 -0.26374 -0.262241 -0.260584 -0.258704 -0.256487 -0.253473 -0.248422 -0.242467 -0.274174 -0.274132 -0.273663 -0.272909 -0.271992 -0.270982 -0.269925 -0.268846 -0.267751 -0.266631 -0.265465 -0.264219 -0.262849 -0.261294 -0.259472 -0.257282 -0.254604 -0.251084 -0.245843 -0.240465 -0.271539 -0.271673 -0.271388 -0.270825 -0.270104 -0.269286 -0.268409 -0.267497 -0.266552 -0.265566 -0.264517 -0.263371 -0.262087 -0.26061 -0.258876 -0.256821 -0.254391 -0.251377 -0.247303 -0.243935 -0.269145 -0.26943 -0.269301 -0.268903 -0.26835 -0.267695 -0.266973 -0.266204 -0.265391 -0.264525 -0.263587 -0.262547 -0.261372 -0.260019 -0.258442 -0.256608 -0.254495 -0.251952 -0.248719 -0.246574 -0.266969 -0.267383 -0.267387 -0.267128 -0.266718 -0.266203 -0.265614 -0.26497 -0.264272 -0.263514 -0.262681 -0.261749 -0.260692 -0.259481 -0.258089 -0.256505 -0.254733 -0.252666 -0.250168 -0.248851 -0.264995 -0.265516 -0.265632 -0.265491 -0.265203 -0.264809 -0.264337 -0.263802 -0.263208 -0.262552 -0.261821 -0.261 -0.26007 -0.259015 -0.257822 -0.2565 -0.25507 -0.253457 -0.251587 -0.250854 -0.263206 -0.263816 -0.264026 -0.263986 -0.263804 -0.263515 -0.263146 -0.26271 -0.262215 -0.261657 -0.261029 -0.260322 -0.259525 -0.258632 -0.257642 -0.256574 -0.255457 -0.254235 -0.252858 -0.252524 -0.261593 -0.262274 -0.262562 -0.262608 -0.262518 -0.262323 -0.262047 -0.261704 -0.261302 -0.260841 -0.260318 -0.259727 -0.259067 -0.258335 -0.25754 -0.256705 -0.255861 -0.25496 -0.253957 -0.253889 -0.260142 -0.260881 -0.261234 -0.261354 -0.261344 -0.261233 -0.261042 -0.260786 -0.260475 -0.260109 -0.259689 -0.259216 -0.258688 -0.258112 -0.257496 -0.256868 -0.256254 -0.255608 -0.254883 -0.254994 -0.258844 -0.259628 -0.260035 -0.260218 -0.260279 -0.260243 -0.26013 -0.259957 -0.259731 -0.259458 -0.259139 -0.258777 -0.258376 -0.257942 -0.257486 -0.257034 -0.256609 -0.256161 -0.255644 -0.255876 -0.257688 -0.258508 -0.25896 -0.259198 -0.25932 -0.259352 -0.259311 -0.259213 -0.259068 -0.258881 -0.258657 -0.258398 -0.258112 -0.257804 -0.257487 -0.257181 -0.256907 -0.256614 -0.25625 -0.256569 -0.256667 -0.257514 -0.258004 -0.258288 -0.258465 -0.258556 -0.25858 -0.258551 -0.258479 -0.258371 -0.258232 -0.258067 -0.257881 -0.257682 -0.25748 -0.257294 -0.25714 -0.256965 -0.256718 -0.257101 -0.255772 -0.256641 -0.257162 -0.257486 -0.257709 -0.257852 -0.257933 -0.257965 -0.257958 -0.25792 -0.257856 -0.257771 -0.257672 -0.257564 -0.257457 -0.257367 -0.257307 -0.257222 -0.257064 -0.257497 -0.254996 -0.255883 -0.25643 -0.256787 -0.25705 -0.257238 -0.257367 -0.257452 -0.257502 -0.257524 -0.257524 -0.257507 -0.257478 -0.257445 -0.257414 -0.257401 -0.257413 -0.257397 -0.257309 -0.25778 -0.254335 -0.255238 -0.255806 -0.25619 -0.256486 -0.256711 -0.256882 -0.25701 -0.257107 -0.257179 -0.257231 -0.25727 -0.257299 -0.257325 -0.257354 -0.2574 -0.257468 -0.257505 -0.25747 -0.257971 -0.253786 -0.2547 -0.255285 -0.255692 -0.256015 -0.256271 -0.256474 -0.256639 -0.256774 -0.256885 -0.25698 -0.257062 -0.257136 -0.257208 -0.257283 -0.257374 -0.257484 -0.25756 -0.257566 -0.25809 -0.253345 -0.254269 -0.254868 -0.255292 -0.255636 -0.255916 -0.256145 -0.256337 -0.256501 -0.256644 -0.25677 -0.256885 -0.256994 -0.2571 -0.25721 -0.257333 -0.257474 -0.257579 -0.257614 -0.258156 -0.253011 -0.253944 -0.254553 -0.25499 -0.255349 -0.255646 -0.255895 -0.256107 -0.256292 -0.256457 -0.256606 -0.256745 -0.256877 -0.257008 -0.257141 -0.257288 -0.25745 -0.257574 -0.25763 -0.258184 -0.252784 -0.253723 -0.254339 -0.254784 -0.255154 -0.255463 -0.255723 -0.255949 -0.256148 -0.256327 -0.256491 -0.256645 -0.256792 -0.256938 -0.257086 -0.257246 -0.257421 -0.257557 -0.257627 -0.258187 -0.252664 -0.253607 -0.254226 -0.254676 -0.255051 -0.255365 -0.255632 -0.255864 -0.25607 -0.256256 -0.256427 -0.256587 -0.256742 -0.256894 -0.257049 -0.257216 -0.257396 -0.257537 -0.257612 -0.258175 -0.277705 -0.262602 -0.319659 -0.299733 -0.227318 -0.161894 -0.0993289 -0.055878 -0.026848 -0.00479679 0.00436346 0.0115687 0.0130028 0.0139971 0.0129362 0.0119175 0.00976668 0.00800536 0.00483977 0.00282502 -0.277762 -0.262412 -0.319599 -0.300212 -0.228143 -0.162627 -0.0997449 -0.0559131 -0.0266833 -0.00456941 0.00451653 0.0116287 0.0129707 0.013906 0.0128334 0.0118129 0.00970152 0.00796179 0.00482893 0.0028357 -0.277914 -0.262278 -0.319742 -0.301022 -0.229218 -0.163532 -0.100302 -0.0560477 -0.0266068 -0.00440432 0.00462273 0.0116543 0.0129139 0.0137972 0.0127176 0.0116995 0.00962892 0.00791214 0.00481372 0.00284184 -0.278148 -0.262188 -0.320051 -0.302122 -0.230516 -0.164594 -0.100995 -0.056282 -0.0266205 -0.00430622 0.00467898 0.0116432 0.0128316 0.013671 0.0125895 0.0115782 0.00954957 0.00785693 0.00479439 0.00284328 -0.27844 -0.262124 -0.320476 -0.303462 -0.23201 -0.1658 -0.101814 -0.0566161 -0.0267255 -0.00427959 0.00468253 0.0115932 0.0127234 0.0135278 0.0124497 0.0114498 0.0094641 0.00779657 0.00477119 0.00283991 -0.278767 -0.262064 -0.320956 -0.304981 -0.233665 -0.167135 -0.102754 -0.0570497 -0.0269222 -0.00432834 0.00463112 0.0115022 0.0125886 0.0133675 0.0122988 0.0113149 0.00937302 0.00773141 0.00474434 0.00283163 -0.279099 -0.261984 -0.321428 -0.306616 -0.235451 -0.168584 -0.103808 -0.0575821 -0.0272103 -0.0044556 0.00452311 0.0113685 0.0124268 0.01319 0.0121372 0.011174 0.00927674 0.0076617 0.00471406 0.00281836 -0.279409 -0.261862 -0.321826 -0.308304 -0.237334 -0.170134 -0.10497 -0.0582122 -0.0275884 -0.00466352 0.00435758 0.0111907 0.0122376 0.0129954 0.0119651 0.0110274 0.00917554 0.00758761 0.00468049 0.00280008 -0.279673 -0.261675 -0.322089 -0.309986 -0.239286 -0.171773 -0.106236 -0.0589382 -0.0280544 -0.00495317 0.00413433 0.0109679 0.0120212 0.0127835 0.0117829 0.0108753 0.00906965 0.00750925 0.00464378 0.00277679 -0.27987 -0.261408 -0.322166 -0.311614 -0.241284 -0.17349 -0.107601 -0.0597577 -0.0286055 -0.00532444 0.00385389 0.0106998 0.0117774 0.0125543 0.0115906 0.0107176 0.00895917 0.00742664 0.00460402 0.00274851 -0.279982 -0.261049 -0.322015 -0.313146 -0.243307 -0.175276 -0.109059 -0.0606675 -0.0292379 -0.0057761 0.00351748 0.0103866 0.0115068 0.0123077 0.0113885 0.0105545 0.00884417 0.0073398 0.0045613 0.00271534 -0.280002 -0.260592 -0.321603 -0.314552 -0.245344 -0.177123 -0.110608 -0.0616637 -0.0299473 -0.00630582 0.00312691 0.0100292 0.01121 0.012044 0.0111767 0.0103857 0.00872465 0.00724868 0.00451567 0.0026774 -0.279924 -0.260034 -0.320907 -0.315811 -0.247387 -0.179028 -0.112243 -0.062743 -0.0307295 -0.00691062 0.00268441 0.00962872 0.0108875 0.0117634 0.0109553 0.0102112 0.00860064 0.00715328 0.00446718 0.00263482 -0.279748 -0.259381 -0.319911 -0.316906 -0.249438 -0.180989 -0.113964 -0.0639021 -0.0315797 -0.00758681 0.00219255 0.00918685 0.0105404 0.0114661 0.0107245 0.0100309 0.00847212 0.00705357 0.0044159 0.00258781 -0.279467 -0.258634 -0.318597 -0.317811 -0.251488 -0.182998 -0.115759 -0.0651315 -0.0324884 -0.00832796 0.00165529 0.00870579 0.0101697 0.0111526 0.0104845 0.00984468 0.00833906 0.00694946 0.00436183 0.00253653 -0.279064 -0.257798 -0.316956 -0.318488 -0.253505 -0.185017 -0.117594 -0.0664068 -0.0334373 -0.00912241 0.00107903 0.00818918 0.00977704 0.0108234 0.0102354 0.00965241 0.00820138 0.00684089 0.00430495 0.00248118 -0.278564 -0.256902 -0.31501 -0.318967 -0.255499 -0.187047 -0.119469 -0.0677274 -0.0344294 -0.00996707 0.000465645 0.00764091 0.00936473 0.0104807 0.00997839 0.00945496 0.00805947 0.00672842 0.00424547 0.00242219 -0.278041 -0.256024 -0.312775 -0.319449 -0.257754 -0.189353 -0.121608 -0.0692385 -0.0355651 -0.0109084 -0.000206982 0.00705645 0.00893313 0.0101278 0.00971598 0.009255 0.00791491 0.00661411 0.0041845 0.00236054 -0.27689 -0.255011 -0.30993 -0.319757 -0.260563 -0.19228 -0.124294 -0.0711114 -0.0369246 -0.0119986 -0.000961174 0.00641722 0.00847304 0.0097571 0.00944507 0.00905022 0.00776773 0.00649714 0.00412282 0.00229592 -0.272745 -0.253035 -0.305818 -0.317919 -0.262242 -0.194372 -0.126262 -0.0724839 -0.0378367 -0.0129188 -0.00163256 0.00574894 0.0079759 0.00933514 0.00914196 0.00881441 0.00760529 0.00635868 0.00405294 0.00222063 -0.233203 -0.234894 -0.277088 -0.29376 -0.259879 -0.196227 -0.128875 -0.0743574 -0.0383742 -0.0158757 -0.00429299 0.00204449 0.00498045 0.00656588 0.00715212 0.00720053 0.00653777 0.00538484 0.00356627 0.00171188 -0.192497 -0.217362 -0.238885 -0.251217 -0.233842 -0.183689 -0.124634 -0.0746188 -0.0408255 -0.0210473 -0.0102159 -0.00434839 -0.000795966 0.00155421 0.00317 0.00408665 0.0042009 0.00358571 0.00236885 0.000830628 -0.172491 -0.1936 -0.205354 -0.209439 -0.196212 -0.160993 -0.115509 -0.0741082 -0.0443295 -0.0262013 -0.0158074 -0.0097894 -0.005824 -0.00288821 -0.00057907 0.00105284 0.0018485 0.00186857 0.00127692 0.000360413 -0.143415 -0.165777 -0.173476 -0.172397 -0.161548 -0.138265 -0.106006 -0.0736219 -0.0480755 -0.0311155 -0.0207278 -0.0143178 -0.0099653 -0.00663707 -0.00386882 -0.00169922 -0.000289976 0.000375433 0.000462061 0.000192317 -0.119056 -0.139325 -0.14592 -0.143807 -0.13551 -0.120056 -0.0976185 -0.0728918 -0.0513699 -0.0355553 -0.0249671 -0.0179814 -0.01316 -0.0095252 -0.00649953 -0.00400549 -0.00213191 -0.000892764 -0.000220748 -7.31685e-05 -0.0988516 -0.116802 -0.123481 -0.122471 -0.116527 -0.105743 -0.0898389 -0.0710644 -0.0531317 -0.0385494 -0.0278613 -0.0204154 -0.015264 -0.0115225 -0.00848191 -0.00587892 -0.00369823 -0.00199973 -0.000842603 -0.000256725 -0.0832016 -0.0987069 -0.105638 -0.106066 -0.102047 -0.0942117 -0.0825567 -0.0681111 -0.0531738 -0.0399812 -0.0296264 -0.0221197 -0.0168788 -0.013161 -0.010184 -0.007532 -0.00511743 -0.0030427 -0.00147597 -0.000485992 -0.0711239 -0.0844732 -0.0913638 -0.0928858 -0.090409 -0.0846273 -0.0757414 -0.0643385 -0.0519166 -0.0403304 -0.0307686 -0.0235508 -0.0183587 -0.0146553 -0.0116711 -0.00892826 -0.00631097 -0.00394891 -0.00203283 -0.000634788 -0.0617823 -0.0732591 -0.0798193 -0.0820307 -0.080732 -0.0764316 -0.0694422 -0.0602911 -0.0500488 -0.0401378 -0.0315862 -0.0248233 -0.0197298 -0.015968 -0.0128684 -0.00998193 -0.00721054 -0.00466596 -0.00248207 -0.000754217 -0.0544548 -0.0643305 -0.0704113 -0.0729844 -0.0725169 -0.0693367 -0.0638026 -0.0564445 -0.0480543 -0.0396797 -0.032135 -0.0258733 -0.0208884 -0.0169997 -0.0137232 -0.0107002 -0.00786271 -0.00523971 -0.00288322 -0.000902328 -0.0486044 -0.0571337 -0.062691 -0.0654001 -0.0655174 -0.06325 -0.05892 -0.0530153 -0.0461335 -0.0390545 -0.0324076 -0.026622 -0.0217354 -0.0177149 -0.0142985 -0.0112206 -0.00839491 -0.00574911 -0.00326456 -0.00104765 -0.0438464 -0.0512583 -0.0563164 -0.0590555 -0.0596156 -0.0581065 -0.05477 -0.0500277 -0.044341 -0.0383047 -0.0324069 -0.027035 -0.0222659 -0.0181996 -0.0147507 -0.0116915 -0.0088774 -0.00619157 -0.00357548 -0.00114463 -0.0398917 -0.0464039 -0.0510427 -0.0537923 -0.0547008 -0.0538033 -0.0512672 -0.0474393 -0.0426794 -0.0374595 -0.0321707 -0.027169 -0.0225863 -0.0185934 -0.0151886 -0.0121381 -0.00927314 -0.00650973 -0.00378188 -0.00120839 -0.0365318 -0.042358 -0.0466925 -0.0494657 -0.050647 -0.0502314 -0.0483244 -0.0451983 -0.0411469 -0.0365681 -0.0317882 -0.0271499 -0.0228224 -0.0189656 -0.0155924 -0.0124902 -0.00953464 -0.00670263 -0.00392474 -0.00127627 -0.0335921 -0.0389673 -0.0431229 -0.0459406 -0.0473374 -0.0472917 -0.0458629 -0.04327 -0.03977 -0.0357071 -0.0313689 -0.0270869 -0.0230238 -0.0192815 -0.015885 -0.0127109 -0.00969383 -0.00684038 -0.00405516 -0.00134606 -0.0309686 -0.0361272 -0.0402283 -0.0431134 -0.0446778 -0.044902 -0.0438297 -0.0416522 -0.0385939 -0.0349538 -0.0309968 -0.0270225 -0.0231637 -0.019483 -0.0160526 -0.0128527 -0.0098266 -0.00697171 -0.00416798 -0.00139333 -0.0285644 -0.0337762 -0.037937 -0.0409023 -0.0425874 -0.0430027 -0.0422021 -0.040352 -0.0376455 -0.0343506 -0.0307021 -0.0269472 -0.0232127 -0.0195767 -0.0161581 -0.0129826 -0.00995985 -0.00707744 -0.00423399 -0.00141475 -0.0264188 -0.0319129 -0.0362169 -0.0392552 -0.0410174 -0.04157 -0.0409778 -0.0393753 -0.0369349 -0.0339025 -0.0304731 -0.0268538 -0.023202 -0.0196286 -0.0162539 -0.0131028 -0.0100622 -0.0071341 -0.00426302 -0.00143064 -0.0246516 -0.0305859 -0.0350548 -0.0381425 -0.0399503 -0.0405969 -0.0401494 -0.0387196 -0.0364619 -0.0335945 -0.0302917 -0.0267615 -0.0231908 -0.0196832 -0.0163301 -0.0131718 -0.0101081 -0.0071583 -0.00428567 -0.00144804 -0.0235406 -0.0298786 -0.0344579 -0.0375682 -0.0393993 -0.0400937 -0.0397206 -0.038385 -0.0362235 -0.0334281 -0.0301777 -0.0267022 -0.0231951 -0.0197257 -0.0163653 -0.0131873 -0.010115 -0.00717007 -0.00430454 -0.00145725 -0.15609 -0.166122 -0.176283 -0.186667 -0.197376 -0.208528 -0.220248 -0.232669 -0.245921 -0.260116 -0.275308 -0.291464 -0.308336 -0.325448 -0.341809 -0.356259 -0.366815 -0.372708 -0.371796 -0.368769 -0.0966389 -0.10004 -0.103126 -0.105881 -0.108282 -0.110306 -0.111925 -0.113115 -0.113849 -0.114113 -0.113903 -0.11325 -0.112223 -0.110995 -0.109795 -0.109083 -0.109256 -0.111206 -0.115247 -0.123456 -0.0726986 -0.0769837 -0.0813036 -0.0856689 -0.0900908 -0.0945813 -0.0991529 -0.103818 -0.108589 -0.113476 -0.118485 -0.123613 -0.128844 -0.134141 -0.139424 -0.144587 -0.149441 -0.153799 -0.157345 -0.159863 -0.0595926 -0.0625069 -0.0653787 -0.0682085 -0.0709967 -0.0737432 -0.0764478 -0.0791099 -0.0817287 -0.0843034 -0.0868339 -0.0893213 -0.0917695 -0.0941878 -0.0965938 -0.0990177 -0.101511 -0.104149 -0.107084 -0.110534 -0.049781 -0.0521505 -0.0545227 -0.0568998 -0.0592843 -0.0616784 -0.0640847 -0.0665055 -0.0689432 -0.0714002 -0.0738786 -0.0763802 -0.0789061 -0.0814557 -0.0840275 -0.086614 -0.0892108 -0.091793 -0.0943723 -0.0968919 -0.0437925 -0.0456576 -0.0475196 -0.0493793 -0.051237 -0.0530934 -0.0549492 -0.056805 -0.0586615 -0.0605195 -0.0623799 -0.0642434 -0.0661114 -0.0679849 -0.0698668 -0.0717579 -0.0736676 -0.0755942 -0.0775815 -0.0796237 -0.0390201 -0.040519 -0.0420185 -0.0435193 -0.0450218 -0.0465265 -0.048034 -0.0495447 -0.0510594 -0.0525785 -0.0541026 -0.0556322 -0.0571679 -0.0587098 -0.060259 -0.0618142 -0.0633795 -0.0649479 -0.0665455 -0.068146 -0.0354925 -0.0367149 -0.0379374 -0.0391601 -0.0403832 -0.0416068 -0.0428311 -0.0440565 -0.0452831 -0.0465112 -0.047741 -0.0489729 -0.0502072 -0.051444 -0.0526842 -0.053927 -0.0551761 -0.0564265 -0.0577 -0.0589753 -0.0326647 -0.0336722 -0.0346797 -0.0356872 -0.0366949 -0.0377029 -0.0387112 -0.0397201 -0.0407297 -0.0417401 -0.0427514 -0.0437637 -0.0447773 -0.0457921 -0.0468085 -0.0478259 -0.0488466 -0.0498666 -0.0509017 -0.0519338 -0.0304284 -0.0312664 -0.0321042 -0.0329419 -0.0337794 -0.034617 -0.0354545 -0.0362921 -0.0371298 -0.0379677 -0.0388058 -0.0396442 -0.0404829 -0.0413218 -0.0421613 -0.0430008 -0.0438419 -0.0446817 -0.045532 -0.0463791 -0.0285995 -0.0292986 -0.0299978 -0.030697 -0.0313963 -0.0320957 -0.0327952 -0.0334949 -0.0341948 -0.0348948 -0.0355951 -0.0362954 -0.0369959 -0.0376965 -0.0383973 -0.0390978 -0.0397992 -0.0404992 -0.0412067 -0.0419118 -0.0270737 -0.0276575 -0.0282419 -0.0288269 -0.0294124 -0.0299986 -0.0305854 -0.0311728 -0.0317607 -0.0323491 -0.0329379 -0.0335271 -0.0341166 -0.0347063 -0.0352962 -0.0358858 -0.036476 -0.0370652 -0.0376598 -0.0382534 -0.0257005 -0.0261864 -0.0266739 -0.0271631 -0.0276537 -0.0281459 -0.0286396 -0.0291347 -0.0296312 -0.0301288 -0.0306277 -0.0311275 -0.0316283 -0.0321297 -0.0326318 -0.0331342 -0.0336373 -0.03414 -0.0346469 -0.0351545 -0.0243984 -0.0248023 -0.0252092 -0.0256191 -0.0260319 -0.0264476 -0.026866 -0.0272869 -0.0277102 -0.0281358 -0.0285633 -0.0289926 -0.0294235 -0.0298557 -0.030289 -0.0307232 -0.0311582 -0.0315934 -0.0320319 -0.0324726 -0.0229264 -0.0232613 -0.0236018 -0.0239476 -0.0242986 -0.0246545 -0.025015 -0.0253799 -0.0257489 -0.0261215 -0.0264976 -0.0268768 -0.0272586 -0.0276428 -0.028029 -0.0284169 -0.0288063 -0.0291967 -0.0295901 -0.0299871 -0.0212589 -0.0215433 -0.0218367 -0.0221384 -0.0224479 -0.0227648 -0.0230885 -0.0234183 -0.0237538 -0.0240945 -0.0244396 -0.0247888 -0.0251415 -0.0254971 -0.0258552 -0.0262153 -0.0265771 -0.0269401 -0.0273054 -0.0276748 -0.0187328 -0.01901 -0.0193001 -0.0196018 -0.0199142 -0.0202361 -0.0205666 -0.0209046 -0.0212493 -0.0215998 -0.0219552 -0.0223149 -0.0226781 -0.023044 -0.0234122 -0.0237819 -0.0241527 -0.0245243 -0.024897 -0.0252732 -0.0154535 -0.0157944 -0.016148 -0.0165126 -0.0168867 -0.0172691 -0.0176583 -0.0180532 -0.0184529 -0.0188562 -0.0192623 -0.0196704 -0.0200798 -0.0204898 -0.0208997 -0.0213091 -0.0217175 -0.0221246 -0.0225301 -0.0229371 -0.010438 -0.0110423 -0.0116408 -0.012233 -0.0128186 -0.0133972 -0.0139687 -0.0145327 -0.0150893 -0.0156381 -0.0161791 -0.0167123 -0.0172375 -0.0177548 -0.0182642 -0.0187656 -0.0192591 -0.0197449 -0.0202228 -0.0206959 -0.0049363 -0.00590082 -0.00683107 -0.00772896 -0.00859629 -0.00943474 -0.0102459 -0.0110313 -0.0117923 -0.0125302 -0.0132462 -0.0139415 -0.0146172 -0.0152742 -0.0159135 -0.016536 -0.0171424 -0.0177338 -0.0183103 -0.0188752 -0.00496889 -0.00593294 -0.00686272 -0.00776013 -0.00862698 -0.00946494 -0.0102756 -0.0110605 -0.011821 -0.0125584 -0.0132739 -0.0139688 -0.0146439 -0.0153004 -0.0159392 -0.0165612 -0.017167 -0.0177579 -0.0183339 -0.0188983 -0.010471 -0.0110749 -0.0116729 -0.0122646 -0.0128497 -0.0134278 -0.0139988 -0.0145624 -0.0151184 -0.0156667 -0.0162072 -0.0167399 -0.0172646 -0.0177814 -0.0182902 -0.0187911 -0.0192841 -0.0197694 -0.0202468 -0.0207194 -0.0154874 -0.0158278 -0.0161809 -0.0165451 -0.0169187 -0.0173005 -0.0176892 -0.0180837 -0.0184828 -0.0188856 -0.0192912 -0.0196988 -0.0201077 -0.0205171 -0.0209266 -0.0213354 -0.0217432 -0.0221498 -0.0225548 -0.0229612 -0.0187682 -0.0190449 -0.0193345 -0.0196358 -0.0199476 -0.020269 -0.0205989 -0.0209364 -0.0212806 -0.0216305 -0.0219855 -0.0223446 -0.0227072 -0.0230726 -0.0234402 -0.0238094 -0.0241797 -0.0245507 -0.0249228 -0.0252985 -0.0212965 -0.0215804 -0.0218732 -0.0221744 -0.0224834 -0.0227997 -0.0231228 -0.0234521 -0.0237871 -0.0241272 -0.0244718 -0.0248204 -0.0251725 -0.0255275 -0.025885 -0.0262446 -0.0266058 -0.0269682 -0.0273329 -0.0277018 -0.0229669 -0.0233012 -0.0236412 -0.0239864 -0.0243368 -0.0246922 -0.0250521 -0.0254164 -0.0257848 -0.0261569 -0.0265324 -0.0269109 -0.0272921 -0.0276757 -0.0280613 -0.0284486 -0.0288374 -0.0292272 -0.02962 -0.0300163 -0.0244428 -0.0248461 -0.0252524 -0.0256617 -0.026074 -0.026489 -0.0269068 -0.0273271 -0.0277498 -0.0281747 -0.0286016 -0.0290303 -0.0294605 -0.0298921 -0.0303247 -0.0307582 -0.0311926 -0.0316271 -0.0320649 -0.032505 -0.02575 -0.0262353 -0.0267222 -0.0272107 -0.0277008 -0.0281923 -0.0286854 -0.0291799 -0.0296757 -0.0301727 -0.0306709 -0.0311701 -0.0316701 -0.0321709 -0.0326723 -0.033174 -0.0336764 -0.0341784 -0.0346846 -0.0351916 -0.0271298 -0.027713 -0.0282968 -0.0288812 -0.0294662 -0.0300517 -0.0306379 -0.0312246 -0.0318119 -0.0323997 -0.0329879 -0.0335764 -0.0341652 -0.0347543 -0.0353434 -0.0359325 -0.036522 -0.0371105 -0.0377044 -0.0382974 -0.0286641 -0.0293627 -0.0300613 -0.0307599 -0.0314586 -0.0321574 -0.0328564 -0.0335555 -0.0342548 -0.0349542 -0.0356538 -0.0363536 -0.0370535 -0.0377535 -0.0384536 -0.0391535 -0.0398543 -0.0405537 -0.0412605 -0.0419652 -0.0305037 -0.0313412 -0.0321785 -0.0330157 -0.0338528 -0.0346898 -0.0355268 -0.0363639 -0.0372011 -0.0380385 -0.038876 -0.0397139 -0.040552 -0.0413904 -0.0422293 -0.0430682 -0.0439088 -0.044748 -0.0455978 -0.0464445 -0.0327536 -0.0337608 -0.0347679 -0.0357752 -0.0367825 -0.0377902 -0.0387982 -0.0398068 -0.0408161 -0.0418261 -0.0428371 -0.0438492 -0.0448624 -0.0458769 -0.046893 -0.0479101 -0.0489305 -0.0499502 -0.0509851 -0.0520174 -0.0355985 -0.036821 -0.0380436 -0.0392664 -0.0404896 -0.0417133 -0.0429378 -0.0441634 -0.0453902 -0.0466185 -0.0478486 -0.0490807 -0.0503154 -0.0515525 -0.0527931 -0.0540365 -0.0552861 -0.0565372 -0.0578114 -0.059088 -0.0391465 -0.0406461 -0.0421463 -0.0436479 -0.0451511 -0.0466566 -0.048165 -0.0496767 -0.0511924 -0.0527126 -0.0542378 -0.0557686 -0.0573056 -0.0588489 -0.0603996 -0.0619564 -0.0635235 -0.0650938 -0.0666935 -0.0682967 -0.0439415 -0.0458079 -0.0476715 -0.0495326 -0.0513919 -0.0532499 -0.0551074 -0.056965 -0.0588234 -0.0606833 -0.0625457 -0.0644113 -0.0662815 -0.0681574 -0.0700416 -0.0719352 -0.0738475 -0.0757768 -0.0777668 -0.0798123 -0.0499529 -0.0523246 -0.0546989 -0.0570782 -0.0594649 -0.0618614 -0.06427 -0.0666932 -0.0691334 -0.071593 -0.074074 -0.0765782 -0.0791069 -0.0816593 -0.084234 -0.0868235 -0.0894235 -0.0920091 -0.0945921 -0.0971163 -0.059793 -0.0627112 -0.065587 -0.068421 -0.0712135 -0.0739646 -0.0766739 -0.0793409 -0.0819648 -0.0845449 -0.0870809 -0.0895741 -0.0920284 -0.094453 -0.0968656 -0.0992963 -0.101797 -0.104443 -0.107386 -0.110846 -0.0729198 -0.0772101 -0.0815355 -0.0859064 -0.0903343 -0.094831 -0.0994091 -0.104081 -0.10886 -0.113754 -0.118771 -0.123909 -0.12915 -0.134458 -0.139753 -0.14493 -0.149799 -0.154175 -0.15774 -0.160283 -0.096897 -0.100309 -0.103407 -0.106174 -0.108588 -0.110626 -0.112261 -0.113467 -0.114219 -0.114501 -0.11431 -0.113677 -0.112672 -0.111466 -0.110288 -0.1096 -0.109795 -0.111769 -0.11583 -0.124054 -0.156278 -0.166312 -0.176476 -0.186861 -0.197572 -0.208725 -0.220445 -0.232865 -0.246115 -0.260306 -0.275494 -0.291644 -0.308506 -0.325609 -0.341956 -0.35639 -0.366928 -0.372799 -0.371863 -0.368808 -0.0235591 -0.0298882 -0.0344591 -0.0375624 -0.0393887 -0.0400811 -0.0397094 -0.0383773 -0.0362203 -0.0334303 -0.030185 -0.026711 -0.0232018 -0.0197282 -0.0163632 -0.0131814 -0.0101082 -0.00716519 -0.00430122 -0.00145553 -0.0246704 -0.0305955 -0.0350556 -0.0381354 -0.0399379 -0.0405826 -0.0401365 -0.0387105 -0.0364592 -0.0335993 -0.0303013 -0.0267707 -0.0231971 -0.0196862 -0.0163288 -0.0131657 -0.0101004 -0.00715277 -0.00428208 -0.00144631 -0.0264382 -0.0319225 -0.0362167 -0.0392459 -0.0410013 -0.0415516 -0.0409616 -0.0393649 -0.0369339 -0.0339116 -0.0304863 -0.0268642 -0.0232085 -0.0196326 -0.0162532 -0.0130957 -0.0100528 -0.00712727 -0.00425865 -0.00142837 -0.0285847 -0.0337855 -0.0379351 -0.0408898 -0.0425666 -0.0429783 -0.0421808 -0.0403403 -0.0376484 -0.0343662 -0.0307199 -0.0269589 -0.0232201 -0.0195823 -0.0161575 -0.0129731 -0.00994734 -0.00706834 -0.00422827 -0.0014117 -0.0309903 -0.0361364 -0.0402237 -0.0430957 -0.0446508 -0.0448711 -0.0438019 -0.041637 -0.0386005 -0.0349785 -0.0310215 -0.0270364 -0.023172 -0.0194901 -0.0160515 -0.0128396 -0.00981003 -0.0069594 -0.00416018 -0.00138926 -0.0336157 -0.0389768 -0.043116 -0.0459159 -0.0473001 -0.0472516 -0.0458281 -0.0432511 -0.0397798 -0.0357416 -0.0314034 -0.0271065 -0.0230352 -0.0192898 -0.0158816 -0.012693 -0.00967264 -0.00682407 -0.00404392 -0.00134012 -0.0365581 -0.0423678 -0.0466833 -0.0494344 -0.0505964 -0.0501737 -0.0482755 -0.0451768 -0.0411663 -0.0366162 -0.0318328 -0.0271776 -0.0228418 -0.0189772 -0.015584 -0.0124633 -0.0095064 -0.00668096 -0.00390887 -0.0012679 -0.0399226 -0.0464142 -0.0510283 -0.0537524 -0.0546384 -0.0537226 -0.0511895 -0.0474087 -0.0427198 -0.0375359 -0.0322298 -0.0272031 -0.0226139 -0.0186098 -0.015174 -0.0120992 -0.0092345 -0.00647969 -0.00375956 -0.00119717 -0.0438847 -0.0512729 -0.0562951 -0.0589973 -0.0595339 -0.0580016 -0.0546586 -0.0499798 -0.0444039 -0.0384223 -0.032494 -0.0270818 -0.0223009 -0.018216 -0.0147252 -0.0116383 -0.00882682 -0.00615037 -0.00354357 -0.00112919 -0.0486526 -0.0571566 -0.0626696 -0.0653205 -0.0653929 -0.0630957 -0.0587742 -0.0529673 -0.0462279 -0.0392108 -0.0325261 -0.0266971 -0.0217902 -0.0177289 -0.0142511 -0.011144 -0.0083276 -0.00569397 -0.00322123 -0.00102686 -0.0545158 -0.0643599 -0.0703933 -0.0729007 -0.0723422 -0.0690767 -0.0635789 -0.0564199 -0.0482307 -0.0398928 -0.0322764 -0.0259752 -0.0209727 -0.0170173 -0.0136495 -0.0105908 -0.00776856 -0.00516233 -0.00282482 -0.000876207 -0.0618654 -0.0732946 -0.0797885 -0.0819451 -0.0805258 -0.0760379 -0.0690702 -0.0602616 -0.0503508 -0.0404698 -0.0317833 -0.0249524 -0.0198291 -0.0159748 -0.0127612 -0.00983674 -0.00708452 -0.0045591 -0.00240249 -0.000720087 -0.071246 -0.084538 -0.0913187 -0.0927509 -0.0901167 -0.0840879 -0.0752318 -0.0642931 -0.0523247 -0.040801 -0.031084 -0.0237615 -0.01848 -0.0146227 -0.0114979 -0.00872706 -0.00614158 -0.00380787 -0.00193193 -0.000591952 -0.0833726 -0.0988377 -0.105659 -0.105883 -0.101482 -0.0933431 -0.0819404 -0.068191 -0.0537449 -0.0405618 -0.0300513 -0.0224477 -0.0170563 -0.0130937 -0.00992626 -0.00724648 -0.00487642 -0.00284857 -0.00134706 -0.000436717 -0.0990641 -0.11699 -0.123677 -0.122394 -0.115572 -0.104182 -0.0889131 -0.071387 -0.0540944 -0.0393777 -0.0284171 -0.0208201 -0.0154502 -0.0113898 -0.00812798 -0.00550156 -0.00337448 -0.00174596 -0.000678792 -0.000194114 -0.119321 -0.139541 -0.146279 -0.143898 -0.134189 -0.117654 -0.0961173 -0.0732862 -0.0528003 -0.036888 -0.0258898 -0.0185429 -0.0133036 -0.00922738 -0.00596262 -0.00347731 -0.0016961 -0.000580247 -3.87564e-05 -8.82157e-06 -0.143813 -0.166212 -0.17402 -0.172203 -0.159403 -0.135057 -0.104157 -0.0740907 -0.0498482 -0.0329665 -0.0221727 -0.0151913 -0.0101442 -0.00616919 -0.00309751 -0.000939797 0.000322562 0.000784336 0.000680467 0.000243294 -0.173082 -0.194852 -0.206792 -0.208456 -0.191885 -0.156246 -0.113584 -0.0752807 -0.0468895 -0.0287416 -0.0177133 -0.0108228 -0.00589805 -0.00216045 0.000459595 0.00206006 0.0026119 0.00232572 0.00150278 0.000402396 -0.193035 -0.220086 -0.242651 -0.250033 -0.226356 -0.175881 -0.1216 -0.0764434 -0.0449044 -0.0251663 -0.0131013 -0.0056678 -0.00062761 0.00280032 0.00472697 0.0055689 0.00521784 0.00410632 0.00253148 0.000748345 -0.23304 -0.239003 -0.283598 -0.293519 -0.250637 -0.185835 -0.12387 -0.0757014 -0.0434238 -0.0215459 -0.0083643 0.0001676 0.00518207 0.00817232 0.00916296 0.00916121 0.00782423 0.00604422 0.00368609 0.00147773 -0.272532 -0.257637 -0.312874 -0.317834 -0.252826 -0.183897 -0.12092 -0.073539 -0.0429588 -0.0187503 -0.00576 0.00384646 0.00826254 0.01099 0.011181 0.0108321 0.00883239 0.00704706 0.00410698 0.00191292 -0.27673 -0.259736 -0.31698 -0.319507 -0.251011 -0.181852 -0.119032 -0.0722226 -0.0420699 -0.0178126 -0.0050514 0.00454343 0.0087778 0.0114102 0.0114723 0.0110602 0.00898051 0.0071869 0.00417226 0.00198271 -0.27799 -0.260859 -0.319701 -0.318896 -0.24804 -0.179022 -0.116513 -0.0704636 -0.0407255 -0.0166664 -0.00422703 0.00522977 0.00925286 0.0117684 0.011718 0.0112439 0.00911079 0.00730242 0.0042344 0.00204703 -0.278619 -0.261783 -0.321775 -0.318194 -0.245719 -0.176815 -0.114485 -0.0690082 -0.0395621 -0.0156525 -0.00348351 0.00585432 0.0096881 0.0120988 0.0119468 0.0114165 0.00923605 0.00741355 0.0042971 0.00211018 -0.279219 -0.262675 -0.323531 -0.317546 -0.24373 -0.174909 -0.112705 -0.0677066 -0.0385074 -0.0147163 -0.00279228 0.00644158 0.0100972 0.0124105 0.0121618 0.0115794 0.00935479 0.00752031 0.00435874 0.00217226 -0.279717 -0.263465 -0.324946 -0.316714 -0.241775 -0.173057 -0.110978 -0.0664356 -0.0374659 -0.0138053 -0.00212388 0.00700142 0.0104819 0.0127001 0.0123596 0.0117282 0.00946465 0.00761999 0.00441825 0.00223274 -0.280082 -0.264124 -0.325999 -0.315669 -0.239847 -0.171266 -0.109309 -0.0651965 -0.036433 -0.0129193 -0.00147781 0.00753123 0.0108399 0.0129648 0.0125381 0.011861 0.00956473 0.00771152 0.00447529 0.00229135 -0.280331 -0.264647 -0.326702 -0.314458 -0.23799 -0.169577 -0.107733 -0.064011 -0.0354245 -0.012068 -0.000859185 0.00802808 0.0111698 0.0132036 0.0126967 0.0119772 0.00965457 0.00779451 0.00452957 0.00234798 -0.280465 -0.265033 -0.327073 -0.313113 -0.236218 -0.168004 -0.106263 -0.0628881 -0.0344485 -0.0112553 -0.000270147 0.008491 0.0114712 0.013416 0.0128351 0.0120763 0.00973364 0.00786854 0.00458073 0.00240247 -0.280485 -0.265279 -0.327131 -0.311654 -0.234536 -0.166556 -0.104906 -0.0618324 -0.0335091 -0.0104826 0.000288779 0.00891985 0.011744 0.0136017 0.0129527 0.0121576 0.0098014 0.00793317 0.00462835 0.00245464 -0.280394 -0.265387 -0.326901 -0.310104 -0.232954 -0.165243 -0.103668 -0.0608487 -0.0326106 -0.00975083 0.000817337 0.00931486 0.0119884 0.0137604 0.0130493 0.0122208 0.00985741 0.00798807 0.00467204 0.00250432 -0.280201 -0.265363 -0.326415 -0.308496 -0.231489 -0.164077 -0.102559 -0.0599426 -0.0317575 -0.00906073 0.00131537 0.0096766 0.0122048 0.0138924 0.013125 0.0122656 0.00990135 0.00803298 0.00471145 0.00255132 -0.279923 -0.265221 -0.325716 -0.306871 -0.230162 -0.163072 -0.101587 -0.0591191 -0.0309546 -0.0084126 0.00178285 0.0100059 0.0123939 0.013998 0.0131798 0.0122921 0.00993299 0.00806776 0.00474623 0.00259547 -0.279582 -0.26498 -0.324859 -0.305279 -0.228998 -0.16224 -0.100759 -0.0583826 -0.0302063 -0.00780652 0.00221979 0.0103038 0.0125563 0.0140779 0.013214 0.0123005 0.00995229 0.00809242 0.00477613 0.00263659 -0.279204 -0.264662 -0.323905 -0.303777 -0.228022 -0.161592 -0.100081 -0.0577366 -0.0295169 -0.00724249 0.00262607 0.0105715 0.012693 0.0141329 0.0132282 0.0122913 0.00995931 0.00810706 0.00480092 0.0026745 -0.278818 -0.264294 -0.322921 -0.302425 -0.22726 -0.161138 -0.099558 -0.0571841 -0.0288906 -0.00672078 0.00300129 0.0108098 0.0128046 0.0141639 0.0132229 0.0122652 0.0099543 0.00811194 0.00482046 0.00270904 -0.278454 -0.263905 -0.321973 -0.301281 -0.226736 -0.160884 -0.0991941 -0.0567271 -0.0283316 -0.00624208 0.00334461 0.0110194 0.0128918 0.0141721 0.0131991 0.0122231 0.00993764 0.00810741 0.00483468 0.00274002 -0.27814 -0.26352 -0.321126 -0.300403 -0.22647 -0.160835 -0.0989905 -0.0563673 -0.027844 -0.00580777 0.00365466 0.0112006 0.0129551 0.0141584 0.0131576 0.012166 0.00990988 0.00809393 0.00484361 0.00276728 -0.2779 -0.263164 -0.320435 -0.299833 -0.226475 -0.160989 -0.0989469 -0.0561055 -0.0274317 -0.00542 0.00392952 0.0113531 0.0129947 0.0141241 0.0130992 0.0120952 0.00987164 0.00807203 0.00484733 0.00279065 -0.277751 -0.262854 -0.319938 -0.299605 -0.226758 -0.161345 -0.0990611 -0.0559423 -0.0270985 -0.00508176 0.00416675 0.0114763 0.0130107 0.01407 0.0130251 0.012012 0.00982364 0.00804231 0.00484598 0.00280995 ) ; boundaryField { inlet { type zeroGradient; } outlet { type fixedValue; value uniform 0; } cylinder { type zeroGradient; } top { type symmetryPlane; } bottom { type symmetryPlane; } defaultFaces { type empty; } procBoundary1to0 { type processor; value nonuniform List<scalar> 80 ( -0.449091 -0.435328 -0.42321 -0.409966 -0.394409 -0.376987 -0.358459 -0.339606 -0.321103 -0.303431 -0.28687 -0.27154 -0.257449 -0.244542 -0.232728 -0.221905 -0.211976 -0.202817 -0.194236 -0.18653 -0.449303 -0.435537 -0.423417 -0.410172 -0.394613 -0.377189 -0.358658 -0.339802 -0.321296 -0.303622 -0.287059 -0.271727 -0.257635 -0.244727 -0.232912 -0.222089 -0.212159 -0.203001 -0.19442 -0.186714 -0.146106 -0.0929387 -0.0684385 -0.056635 -0.0474116 -0.041924 -0.0375214 -0.0342699 -0.0316571 -0.0295902 -0.0279003 -0.0264904 -0.0252161 -0.0239976 -0.0225971 -0.0209838 -0.0184696 -0.015127 -0.00982835 -0.0039355 -0.00396853 -0.00986181 -0.0151614 -0.0185055 -0.0210219 -0.0226381 -0.0240425 -0.0252661 -0.0265471 -0.0279654 -0.0296659 -0.0317462 -0.0343758 -0.0376472 -0.0420716 -0.0475815 -0.0568317 -0.0686546 -0.0931868 -0.146292 ) ; } } // ************************************************************************* //
8497c84230d44be71b0078885c233389fe031457
bad189cd654d186b6f80d53c8cbddf7f455d9a7b
/game/src/SideItemBar.cpp
3a6a384149c0bc6bd0cb570e15c6e39392f63231
[ "MIT" ]
permissive
unbgames/StandYourGround
dbc6302de71a354cf49a6190939438d2537b1f8a
87099fe6f08d0396655a711537401bb7526d3e43
refs/heads/master
2020-03-27T14:37:59.309405
2018-09-25T23:42:34
2018-09-25T23:42:34
146,673,328
0
0
null
2018-08-30T00:16:35
2018-08-30T00:16:35
null
UTF-8
C++
false
false
4,230
cpp
SideItemBar.cpp
#include "SideItemBar.h" #include "Game.h" #include "Sprite.h" #include "Bag.h" #include "InputManager.h" #include "config.h" SideItemBar::SideItemBar(GameObject& associated) : Component(associated), backToNormal(false) { GameObject* berryObj = new GameObject(); berryAmount = new Text(*berryObj, ASSETS_PATH("/font/pixel.ttf"), 80, TextStyle::SOLID, "0x", {0, 0, 0, 255}); textItemList.push_back(berryAmount); berryObj->AddComponent(berryAmount); berryObj->layer = associated.layer; berryObj->box.SetOrigin(SCREEN_WIDTH-100, 100); Sprite* berrySprite = new Sprite(*berryObj, ASSETS_PATH("/img/items/Berriest x4.png")); spriteItemList.push_back(berrySprite); berrySprite->SetOffset({50, 10}); berrySprite->SetScale({1, 1}); berryObj->AddComponent(berrySprite); itemList.push_back(berryObj); GameObject* cipoObj = new GameObject(); cipoAmount = new Text(*cipoObj, ASSETS_PATH("/font/pixel.ttf"), 80, TextStyle::SOLID, "0x", {0, 0, 0, 255}); textItemList.push_back(cipoAmount); cipoObj->AddComponent(cipoAmount); cipoObj->layer = associated.layer; cipoObj->box.SetOrigin(SCREEN_WIDTH-100, 150); Sprite* cipoSprite = new Sprite(*cipoObj, ASSETS_PATH("/img/items/cipo.png")); spriteItemList.push_back(cipoSprite); cipoSprite->SetOffset({50, 15}); cipoSprite->SetScale(0.5, 0.5); cipoObj->AddComponent(cipoSprite); itemList.push_back(cipoObj); GameObject* galhoObj = new GameObject(); galhoAmount = new Text(*galhoObj, ASSETS_PATH("/font/pixel.ttf"), 80, TextStyle::SOLID, "0x", {0, 0, 0, 255}); textItemList.push_back(galhoAmount); galhoObj->AddComponent(galhoAmount); galhoObj->layer = associated.layer; galhoObj->box.SetOrigin(SCREEN_WIDTH-100, 200); Sprite* galhoSprite = new Sprite(*galhoObj, ASSETS_PATH("/img/items/galho.png")); spriteItemList.push_back(galhoSprite); galhoSprite->SetOffset({50, 15}); galhoSprite->SetScale(0.5, 0.5); galhoObj->AddComponent(galhoSprite); itemList.push_back(galhoObj); } void SideItemBar::Update(float dt) { if(berry != Bag::GetAmountItem(ItemType::berry)) { berry = Bag::GetAmountItem(ItemType::berry); berryAmount->SetText(std::to_string(berry) + "x"); } if(cipo != Bag::GetAmountItem(ItemType::cipo)) { cipo = Bag::GetAmountItem(ItemType::cipo); cipoAmount->SetText(std::to_string(cipo) + "x"); } if(galho != Bag::GetAmountItem(ItemType::galho)) { galho = Bag::GetAmountItem(ItemType::galho); galhoAmount->SetText(std::to_string(galho) + "x"); } InputManager &inp = InputManager::GetInstance(); if(inp.KeyPress(SDLK_k)) { blinkItem("Bomb"); } else if(inp.KeyPress(SDLK_j)) { blinkItem("Hole"); } if(blinking) { backToNormal.Update(dt); if(backToNormal.Get() > 0.7) { backToNormal.Restart(); blinking = false; cipoAmount->SetColor({0, 0, 0, 255}); berryAmount->SetColor({0, 0, 0, 255}); galhoAmount->SetColor({0, 0, 0, 255}); } } } void SideItemBar::Render() { for(int i = 0; i < itemList.size(); i++) { textItemList[i]->RenderNoCam(); spriteItemList[i]->RenderNoCam(); } } bool SideItemBar::Is(std::string type) { } std::string SideItemBar::Type() { } void SideItemBar::NotifyCollision(GameObject &other) { } bool SideItemBar::blinkItem(std::string trap) { if(trap == "Hole") { // 3 gravetos e 2 cipos if(Bag::GetAmountItem(ItemType::cipo) < 2) { cipoAmount->SetColor({255, 0, 0, 1}); blinking = true; } if(Bag::GetAmountItem(ItemType::galho) < 3) { galhoAmount->SetColor({255, 0, 0, 1}); blinking = true; } } else if(trap == "Bomb") { if(Bag::GetAmountItem(ItemType::cipo) < 2) { cipoAmount->SetColor({255, 0, 0, 1}); blinking = true; } if(Bag::GetAmountItem(ItemType::berry) < 4) { berryAmount->SetColor({255, 0, 0, 1}); blinking = true; } } else if(trap == "Cipo") { } bool canUseItem = !blinking; return canUseItem; }
d80d36053f46bb479347dd1ffba8a2182bb00385
5e16bdc8da61393ac4548aa8ffd6bdbfdb466495
/chapter03/BinarySearch.cpp
a5a37415cb3eb8e49ce6824dbae1842007daf50c
[]
no_license
TolicWang/C-Plus-Plus-Primer-Edition-5
38610bd03dfb7800cc965c5d8f325552f7d50e60
b897381d407f7278431397c54a080b39fdc95f9c
refs/heads/master
2021-01-19T09:54:50.836805
2017-06-13T10:29:00
2017-06-13T10:29:00
87,797,677
1
1
null
null
null
null
UTF-8
C++
false
false
1,061
cpp
BinarySearch.cpp
/************************************************************************* > File Name: BinarySearch.cpp > Author: > Mail: > Created Time: Sun 09 Apr 2017 07:47:55 PM CST ************************************************************************/ #include<iostream> #include<vector> using namespace std; int main() { vector<int> ivec; int n; cin>>n; for(int i = 0; i < n; ++i) { ivec.push_back(2 * i + 3); cout<<2 * i + 3<<" "; } cout<<endl<<"Pleasae type the number you wanna search: "; int sought; cin>>sought; auto beg = ivec.cbegin(); auto end = ivec.cend(); auto mid = beg + (end - beg) / 2; while(mid != end && *mid != sought) { if(sought < *mid) end = mid; else beg = mid + 1; mid = beg + (end - beg) / 2; //mid = (end + beg) / 2; } if(*mid == sought) cout<<"the index of "<<sought<<" is "<<int(mid - ivec.cbegin())<<".(begin as 0)"<<endl; else cout<<"not found."<<endl; return 0; }
f027980c273b605532c988ef7dd0dee20a4e608f
8d3dd89ded7ba45c2a20d633e1321639c5f76368
/source/3D/CubeGrid/CubeGrid.cpp
a2a6f065de811f169d038db1f63d9c1e59cededf
[]
no_license
OzW1234/huji-rich
a7d54fa269cf14f40e8d6c4af3eb344d826ceddf
2bc92f37c2e7d234f8759af34fb77bb87dafd03b
refs/heads/master
2020-03-24T23:37:27.184296
2018-07-26T16:14:56
2018-07-26T16:14:56
143,145,490
0
0
null
2018-08-01T11:13:31
2018-08-01T11:13:31
null
UTF-8
C++
false
false
8,530
cpp
CubeGrid.cpp
#include "CubeGrid.hpp" #include <limits> using std::min; namespace { /*void ConvertIndexToSubindex(size_t index,size_t &i,size_t &j,size_t &k, size_t ny_,size_t nz_) { k=index%(nz_); i=index/(nz_*ny_); j=(index-i*nz_*ny_)/nz_; } */ size_t ConvertSubindexToIndex(size_t i,size_t j,size_t k, size_t ny_,size_t nz_) { return i*ny_*nz_+j*nz_+k; } } CubeGrid::CubeGrid(size_t nx, size_t ny, size_t nz, Vector3D const& backlowerleft, Vector3D const& frontupperright):nx_(nx),ny_(ny),nz_(nz), maxsize_(std::numeric_limits<std::size_t>::max()), dx_((frontupperright.x-backlowerleft.x)/static_cast<double>(nx)), dy_((frontupperright.y-backlowerleft.y)/static_cast<double>(ny)), dz_((frontupperright.z-backlowerleft.z)/static_cast<double>(nz)), obc_(0),backlowerleft_(backlowerleft),frontupperright_(frontupperright), cor_(vector<Vector3D> ()),faces_(vector<Face> ()),cellfaces_(vector<vector<size_t> > ()), temp_(vector<vector<size_t> > ()) { // Create the faces size_t nfaces=(nx_+1)*ny_*nz_+(ny_+1)*nx_*nz_+(nz_+1)*ny_*nx_; faces_.resize(nfaces); cellfaces_.resize(nx_*ny_*nz_); // Do the z direction vector<Vector3D> side(4); side[0]=backlowerleft_; side[1]=backlowerleft_+Vector3D(dx_,0,0); side[2]=backlowerleft_+Vector3D(dx_,dy_,0); side[3]=backlowerleft_+Vector3D(0,dy_,0); for(size_t k=0;k<nz_+1;++k) { for(size_t i=0;i<ny_;++i) { for(size_t j=0;j<nx_;++j) { faces_[i*nx_+j+k*ny_*nx_].vertices=side+Vector3D(dx_*static_cast<double>(j),0,dz_*static_cast<double>(k)) +Vector3D(0,dy_*static_cast<double>(i),0); if(k==0) faces_[i*nx_+j+k*ny_*nx_].neighbors.first=maxsize_; else faces_[i*nx_+j+k*ny_*nx_].neighbors.first=ConvertSubindexToIndex(j,i,k-1,ny_,nz_); if(k==nz_) faces_[i*nx_+j+k*ny_*nx_].neighbors.second=maxsize_; else faces_[i*nx_+j+k*ny_*nx_].neighbors.second=ConvertSubindexToIndex(j,i,k,ny_,nz_); } } } // Do the y direction side[0]=backlowerleft_; side[1]=backlowerleft_+Vector3D(dx_,0,0); side[2]=backlowerleft_+Vector3D(dx_,0,dz_); side[3]=backlowerleft_+Vector3D(0,0,dz_); for(size_t k=0;k<nz_;++k) { for(size_t i=0;i<ny_+1;++i) { for(size_t j=0;j<nx_;++j) { faces_[i*nx_*nz_+k+j*nz_+nx_*(nz_+1)*ny_].vertices=side+Vector3D(dx_*static_cast<double>(j),dy_*static_cast<double>(i),0) +Vector3D(0,0,dz_*static_cast<double>(k)); if(i==0) faces_[i*nx_*nz_+k+j*nz_+nx_*(nz_+1)*ny_].neighbors.first=maxsize_; else faces_[i*nx_*nz_+k+j*nz_+nx_*(nz_+1)*ny_].neighbors.first=ConvertSubindexToIndex(j,i-1,k,ny_,nz_); if(i==ny_) faces_[i*nx_*nz_+k+j*nz_+nx_*(nz_+1)*ny_].neighbors.second=maxsize_; else faces_[i*nx_*nz_+k+j*nz_+nx_*(nz_+1)*ny_].neighbors.second=ConvertSubindexToIndex(j,i,k,ny_,nz_); } } } // Do the x direction side[0]=backlowerleft_; side[1]=backlowerleft_+Vector3D(0,dy_,0); side[2]=backlowerleft_+Vector3D(0,dy_,dz_); side[3]=backlowerleft_+Vector3D(0,0,dz_); for(size_t k=0;k<nz_;++k) { for(size_t i=0;i<ny_;++i) { for(size_t j=0;j<nx_+1;++j) { faces_[i*nz_+j*ny_*nz_+k+nx_*(nz_+1)*ny_+nx_*(ny_+1)*nz_].vertices=side +Vector3D(0,dy_*static_cast<double>(i),0)+Vector3D(dx_*static_cast<double>(j),0,dz_*static_cast<double>(k)); if(j==0) faces_[i*nz_+j*ny_*nz_+k+nx_*(nz_+1)*ny_+nx_*(ny_+1)*nz_].neighbors.first=maxsize_; else faces_[i*nz_+j*ny_*nz_+k+nx_*(nz_+1)*ny_+nx_*(ny_+1)*nz_].neighbors.first=ConvertSubindexToIndex(j-1,i,k,ny_,nz_); if(j==nx_) faces_[i*nz_+j*ny_*nz_+k+nx_*(nz_+1)*ny_+nx_*(ny_+1)*nz_].neighbors.second=maxsize_; else faces_[i*nz_+j*ny_*nz_+k+nx_*(nz_+1)*ny_+nx_*(ny_+1)*nz_].neighbors.second=ConvertSubindexToIndex(j,i,k,ny_,nz_); } } } // Add the faces for the points for(size_t i=0;i<cellfaces_.size();++i) cellfaces_[i].reserve(6); for(size_t i=0;i<faces_.size();++i) { if(faces_[i].neighbors.first<maxsize_) cellfaces_[faces_[i].neighbors.first].push_back(i); if(faces_[i].neighbors.second<maxsize_) cellfaces_[faces_[i].neighbors.second].push_back(i); } /* for(size_t k=0;k<nz_;++k) { for(size_t i=0;i<ny_;++i) { for(size_t j=0;j<nx_;++j) { size_t index=ConvertSubindexToIndex(j,i,k,ny_,nz_); cellfaces_[index].push_back(i*nx_*nz_+k+j*nz_+nx_*(nz_+1)*ny_+nx_*(nz_+1)*ny_); cellfaces_[index].push_back((i+1)*nx_*nz_+k+j*nz_+nx_*(nz_+1)*ny_+nx_*(nz_+1)*ny_); cellfaces_[index].push_back(i*nz_+j*ny_*nz_+k+nx_*(nz_+1)*ny_+nx_*(ny_+1)*nz_); cellfaces_[index].push_back(i*nz_+(j+1)*ny_*nz_+k+nx_*(nz_+1)*ny_+nx_*(ny_+1)*nz_); cellfaces_[index].push_back(i*nx_+j+k*ny_*nx_); cellfaces_[index].push_back(i*nx_+j+(k+1)*ny_*nx_); } } }*/ // Create the points cor_.resize(nx_*ny_*nz_); for(size_t i=0;i<nx_;++i) { for(size_t j=0;j<ny_;++j) { for(size_t k=0;k<nz_;++k) { cor_[ConvertSubindexToIndex(i,j,k,ny_,nz_)]=backlowerleft+ Vector3D(static_cast<double>(i)*dx_+0.5*dx_,static_cast<double>(j)*dy_+0.5*dy_,static_cast<double>(k)*dz_+0.5*dz_); } } } } CubeGrid::CubeGrid(CubeGrid const& other):nx_(other.nx_),ny_(other.ny_),nz_(other.nz_), maxsize_(other.maxsize_),dx_(other.dx_),dy_(other.dy_),dz_(other.dz_),obc_(other.obc_), backlowerleft_(other.backlowerleft_),frontupperright_(other.frontupperright_), cor_(other.cor_),faces_(other.faces_),cellfaces_(other.cellfaces_), temp_(other.temp_){} void CubeGrid::Initialise(vector<Vector3D> const& /*points*/, OuterBoundary3D const* bc) { obc_=bc; } void CubeGrid::Update(vector<Vector3D> const& /*points*/) {} size_t CubeGrid::GetPointNo(void) const { return nz_*nx_*ny_; } Vector3D CubeGrid::GetMeshPoint(size_t index) const { return cor_[index]; } Vector3D const& CubeGrid::GetCellCM(size_t index) const { return cor_[index]; } size_t CubeGrid::GetTotalFacesNumber(void) const { return faces_.size(); } Face const& CubeGrid::GetFace(size_t index) const { return faces_[index]; } double CubeGrid::GetWidth(size_t /*index*/) const { return min(min(dx_,dy_),dz_); } double CubeGrid::GetVolume(size_t /*index*/) const { return dx_*dy_*dz_; } vector<size_t>const& CubeGrid::GetCellFaces(size_t index) const { return cellfaces_[index]; } vector<Vector3D>& CubeGrid::GetMeshPoints(void) { return cor_; } vector<size_t> CubeGrid::GetNeighbors(size_t index)const { vector<size_t> res(6); for(size_t i=0;i<6;++i) { res[i]=(faces_[cellfaces_[index][i]].neighbors.first==index) ? faces_[cellfaces_[index][i]].neighbors.second : faces_[cellfaces_[index][i]].neighbors.first; } return res; } Tessellation3D* CubeGrid::clone(void) const { return new CubeGrid(*this); } CubeGrid::~CubeGrid(void) {} bool CubeGrid::NearBoundary(size_t index) const { for(size_t i=0;i<6;++i) { if(faces_[cellfaces_[index][i]].neighbors.first==maxsize_) return true; if(faces_[cellfaces_[index][i]].neighbors.second==maxsize_) return true; } return false; } vector<vector<size_t> >& CubeGrid::GetDuplicatedPoints(void) { return temp_; } vector<vector<size_t> >const& CubeGrid::GetDuplicatedPoints(void)const { return temp_; } size_t CubeGrid::GetTotalPointNumber(void)const { return cor_.size(); } vector<Vector3D>& CubeGrid::GetAllCM(void) { return cor_; } void CubeGrid::GetNeighborNeighbors(vector<size_t> &result, size_t point)const { result.clear(); vector<size_t> neigh=GetNeighbors(point); for(size_t i=0;i<neigh.size();++i) { if(neigh[i]==maxsize_) continue; vector<size_t> temp=GetNeighbors(neigh[i]); result.insert(result.end(),temp.begin(),temp.end()); } sort(result.begin(),result.end()); result=unique(result); } Vector3D CubeGrid::Normal(size_t faceindex)const { if(faceindex<(nx_*ny_*(nz_+1))) return Vector3D(0,0,dz_); if(faceindex<(nx_*ny_*(nz_+1)+nx_*(ny_+1)*nz_)) return Vector3D(0,dy_,0); else return Vector3D(dx_,0,0); } bool CubeGrid::IsGhostPoint(size_t index)const { if(index<nz_*ny_*nx_) return false; else return true; } Vector3D CubeGrid::CalcFaceVelocity(size_t /*p0*/,size_t /*p1*/,Vector3D const& /*v0*/, Vector3D const& /*v1*/)const { return Vector3D(); } bool CubeGrid::BoundaryFace(size_t index) const { if(faces_[index].neighbors.first==maxsize_||faces_[index].neighbors.second==maxsize_) return true; else return false; }
677a007c9d6efc0fe0c800211e8ab03b14fed828
b6d1df49c1ec621a02204b1100312ecbb3e76ad3
/src/mains/raven/estimate_f.cc
991ae60b4156572fd90e0bf6f4e4314424191454
[]
no_license
flylong0204/projects
5271acde325cf3947fac7433077353b52fa07bc4
b1e5c918d4aeb34c36576dababc5509dbb89afd1
refs/heads/master
2017-12-06T06:35:20.926786
2017-01-24T23:53:13
2017-01-24T23:53:13
79,988,197
1
2
null
2017-01-25T06:11:23
2017-01-25T06:11:23
null
UTF-8
C++
false
false
12,217
cc
estimate_f.cc
// ========================================================================== // Program ESTIMATE_F implements a modified version of the constrained // "checkerboard" calibration algorithm described in I. Shimizu, // Z. Zhang, S. Akamatsu and K. Deguchi, "Head pose determination from // one image using a generic mode camera calibration", IEEE 3rd Intl // Conf on Automatic Face and Gesture Recognition, pp 100-105, 1998. // It first reads in a set of image-plane UV and corresponding // world-plane XY tiepoints from some number of photos (preferably 4 // or more). For each photo, a least-squares homography relating the // image and world planes is next calculated. We assume the internal // matrix K is constrained so that it depends upon a SINGLE unknown // focal parameter (i.e. f=fu=fv; skew=0; u0=0.5*aspect_ratio and // v0=0.5). ESTIMATE_F computes and returns the average of all // reasonable image f values. // As of 1/21/12, we believe "checkerboard" calibration is only // quasi-robust for (highly constrained) f parameter estimation and // NOT for finding any other internal or external camera parameters... // estimate_f // Important note: As of 1/21/12, we believe the following // relationship holds between our dimensionless focal parameter f, the // physical focal length F (measured in mm) and d = VERTICAL physical // size of the CCD chip: f_peter = - F/d. Digital camera chip sizes // are commonly expressed in terms of 35 mm equivalents. A "35 mm" // chip has horizontal dimension = 36 mm and vertical dimension = 24 // mm. So f_peter = - F_equivalent / 24 mm . // For Powershot SX1501S, 35 mm film equivalent is 28 mm (wide) and // 336 mm (telephoto). So at its default zoom setting, f_peter = // -28mm/24mm=-1.16 . // For Fujifilm Finepix S800fd, F = 27 mm (wide) to 488 mm // (telephoto). So f_peter = - 27mm / 24mm = -1.13 for default zoom // setting. // ========================================================================== // Last updated on 1/19/12; 1/20/12; 1/21/12; 5/30/15 // ========================================================================== #include <iostream> #include <iomanip> #include <string> #include <vector> #include "video/camerafuncs.h" #include "general/filefuncs.h" #include "geometry/homography.h" #include "astro_geo/latlong2utmfuncs.h" #include "general/outputfuncs.h" #include "general/stringfuncs.h" #include "general/sysfuncs.h" #include "video/texture_rectangle.h" #include "math/twovector.h" using std::cin; using std::cout; using std::endl; using std::ios; using std::ofstream; using std::ostream; using std::string; using std::vector; // ========================================================================== int main(int argc, char *argv[]) // ========================================================================== { std::set_new_handler(sysfunc::out_of_memory); const int PRECISION=12; cout.precision(PRECISION); // Read in imageplane-worldplane tiepoint pairs: vector<string> feature_filenames; string features_subdir="./calib/Fuji/"; feature_filenames.push_back(features_subdir+"features_2D_DSCF9083.txt"); feature_filenames.push_back(features_subdir+"features_2D_DSCF9084.txt"); feature_filenames.push_back(features_subdir+"features_2D_DSCF9085.txt"); feature_filenames.push_back(features_subdir+"features_2D_DSCF9086.txt"); double aspect_ratio=3264.0/2448.0; // DSCF9083-6.JPG unsigned int n_tiepoints=9; // const double f_actual=-1.13; // const double f_calculated=-1.12; /* string features_subdir="./data/calib/"; feature_filenames.push_back(features_subdir+"features_2D_IMG_0133.txt"); feature_filenames.push_back(features_subdir+"features_2D_IMG_0134.txt"); feature_filenames.push_back(features_subdir+"features_2D_IMG_0135.txt"); feature_filenames.push_back(features_subdir+"features_2D_IMG_0136.txt"); int n_tiepoints=9; double aspect_ratio=4000.0/3000.0; // IMG_0133-0136.JPG const double f_actual=-1.16; const double f_calculated=-1.27; */ /* string features_subdir="./calib/simul_camera/"; feature_filenames.push_back(features_subdir+"features_2D_vs1.txt"); feature_filenames.push_back(features_subdir+"features_2D_vs2.txt"); feature_filenames.push_back(features_subdir+"features_2D_vs3.txt"); feature_filenames.push_back(features_subdir+"features_2D_vs4.txt"); int n_tiepoints=8; // double aspect_ratio=1067.0/800.0; // Simulated image double aspect_ratio=1.33375; // Simulated image (calculated value) const double FOV_u_actual=40; // degs const double FOV_v_actual=30; // degs const double f_actual=-1.866; const double f_calculated=-1.71; */ /* string features_subdir="./calib/calib_front_camera/grid/cropped_frames/"; feature_filenames.push_back(features_subdir+"features_2D_frame0007.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0021.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0035.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0055.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0088.txt"); int n_tiepoints=9; double aspect_ratio=647.0/480.0; // Cropped Raven front video frame */ /* string features_subdir="./calib/calib_side_camera/grid/"; feature_filenames.push_back(features_subdir+"features_2D_frame0006.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0110.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0173.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0203.txt"); int n_tiepoints=9; double aspect_ratio=720.0/480.0; // Uncropped Raven video frame */ /* string features_subdir="./calib/calib_front_camera/grid/"; feature_filenames.push_back(features_subdir+"features_2D_frame0007.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0021.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0035.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0055.txt"); feature_filenames.push_back(features_subdir+"features_2D_frame0088.txt"); int n_tiepoints=9; double aspect_ratio=720.0/480.0; // Uncropped Raven video frame */ int n_images=feature_filenames.size(); double FOV_u,FOV_v; vector<double> f_values; for (int imagenumber=0; imagenumber<n_images; imagenumber++) { cout << "imagenumber = " << imagenumber << endl; filefunc::ReadInfile(feature_filenames[imagenumber]); vector<twovector> XY,UV; for (unsigned int i=0; i<filefunc::text_line.size(); i++) { vector<string> substring=stringfunc::decompose_string_into_substrings( filefunc::text_line[i]); if (i < n_tiepoints) { double U=stringfunc::string_to_number(substring[3]); double V=stringfunc::string_to_number(substring[4]); // Need to recenter u0,v0 to lie at (0,0): double Uprime=U-0.5*aspect_ratio; double Vprime=V-0.5; UV.push_back(twovector(Uprime,Vprime)); } else { double X=stringfunc::string_to_number(substring[0]); double Y=stringfunc::string_to_number(substring[1]); XY.push_back(twovector(X,Y)); } } // for (int i=0; i<XY.size(); i++) // { // cout << "i = " << i // << " X = " << XY[i].get(0) // << " Y = " << XY[i].get(1) // << " U = " << UV[i].get(0) // << " V = " << UV[i].get(1) // << endl; // } // Calculate homography relating image and world planes: homography H; H.parse_homography_inputs(XY,UV); H.compute_homography_matrix(); H.compute_homography_inverse(); double RMS_residual=H.check_homography_matrix(XY,UV); cout << "RMS_residual = " << RMS_residual << endl; cout << "H = " << H << endl; genmatrix* H_ptr=H.get_H_ptr(); // cout << "*H_ptr = " << *H_ptr << endl; // Calculate average value for proportionality constant lambda defined by // (U,V,1) = lambda H (X,Y,1) // Then rescale H by 1/lambda s.t. lambda -> 1: vector<double> lambda_values; for (unsigned int t=0; t<XY.size(); t++) { threevector XYZ(XY[t].get(0),XY[t].get(1),1); // cout << "XYZ = " << XYZ << endl; threevector HXYZ=*H_ptr * XYZ; // cout << "H*XYZ = " << HXYZ << endl; lambda_values.push_back(HXYZ.get(2)); // cout << "lambda = " << lambda << endl; } // loop over index t labeling tiepoint pairs double lambda=mathfunc::mean(lambda_values); cout << "Average proportionality constant value lambda = " << lambda << endl; *H_ptr = *H_ptr/lambda; /* for (int t=0; t<XY.size(); t++) { threevector XYZ(XY[t].get(0),XY[t].get(1),1); cout << "t = " << t << " XYZ = " << XYZ << endl; threevector HXYZ=*H_ptr * XYZ; threevector UVW(UV[t].get(0),UV[t].get(1),1); cout << " H*XYZ = " << HXYZ << " UVW = " << UVW << endl; } */ double h11=H_ptr->get(0,0); double h12=H_ptr->get(0,1); // double h13=H_ptr->get(0,2); double h21=H_ptr->get(1,0); double h22=H_ptr->get(1,1); // double h23=H_ptr->get(1,2); double h31=H_ptr->get(2,0); double h32=H_ptr->get(2,1); // double h33=H_ptr->get(2,2); // cout << "h11 = " << h11 << " h12 = " << h12 << " h13 = " << h13 << endl; // cout << "h21 = " << h21 << " h22 = " << h22 << " h23 = " << h23 << endl; // cout << "h31 = " << h31 << " h32 = " << h32 << " h33 = " << h33 << endl; /* genmatrix M(2,2),Minv(2,2); M.put(0,0,h11*h22); M.put(0,1,h21*h22); M.put(1,0,sqr(h11)-sqr(h12)); M.put(1,1,sqr(h21)-sqr(h22)); M.inverse(Minv); twovector X,Y; Y.put(0,-h31*h32); Y.put(1,sqr(h32)-sqr(h31)); X=Minv*Y; cout << "X = " << X << endl; */ // Solve Eqn 32 for 1/fu**2 = 1/fv**2 where fu and fv are forced to be // equal: double numer=h11*h12+h21*h22; double denom=h31*h32; double fsq=-numer/denom; cout << "fsq = " << fsq << endl; // As of 1/21/12, we do NOT understand why we cannot get eqns 33 and // 34 to even remotely work! But at least eqn 32 does yield // reasonable estimates for f**2 in most cases... /* numer=sqr(h11)+sqr(h21); denom=1-sqr(h31); double fsq2=numer/denom; numer=sqr(h12)+sqr(h22); denom=1-sqr(h32); double fsq3=numer/denom; cout << "fsq2 = " << fsq2 << endl; cout << "fsq3 = " << fsq3 << endl; */ double f=POSITIVEINFINITY; if (fsq > 0) { f=-sqrt(fsq); cout << "f = " << f << endl; f_values.push_back(f); camerafunc::horiz_vert_FOVs_from_f_and_aspect_ratio( f,aspect_ratio,FOV_u,FOV_v); cout << "FOV_u = " << FOV_u*180/PI << endl; cout << "FOV_v = " << FOV_v*180/PI << endl; /* double Eqn33=sqr(h11/f)+sqr(h21/f)+sqr(h31); double Eqn34=sqr(h12/f)+sqr(h22/f)+sqr(h32); cout << "Eqn 33 = " << Eqn33 << endl; cout << "Eqn 34 = " << Eqn34 << endl; */ } // outputfunc::enter_continue_char(); cout << endl; } // loop over imagenumber index double numer=0; double denom=0; double f_median=mathfunc::median_value(f_values); for (unsigned int i=0; i<f_values.size(); i++) { double curr_f=f_values[i]; if (fabs(curr_f-f_median) > 0.5) continue; numer += curr_f; denom += 1; } double f_avg=numer/denom; camerafunc::horiz_vert_FOVs_from_f_and_aspect_ratio( f_avg,aspect_ratio,FOV_u,FOV_v); cout << "======================================================" << endl; cout << "Best average estimate for f=fu=fv=" << f_avg << endl; cout << "FOV_u = " << FOV_u*180/PI << endl; cout << "FOV_v = " << FOV_v*180/PI << endl; cout << "Aspect ratio = width/height = " << aspect_ratio << endl; cout << "======================================================" << endl; cout << endl; }
be1564e76b0b9b31c61312e4a1f421aa8b2abae5
49dedcacc3d929052850fc896c37a7a5262d2976
/src/btwxt.h
ab7cc91bcaf1e6d26895abde4331b3e25ddf541a
[ "BSD-2-Clause" ]
permissive
hc27080401/btwxt
847809d09538067824422e1bd3c86dc05cee4506
d30871e30fc222a663ea0ad1e0c0344d983e0f51
refs/heads/master
2020-04-04T15:50:52.832881
2018-08-03T22:25:04
2018-08-03T22:25:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,549
h
btwxt.h
/* Copyright (c) 2018 Big Ladder Software LLC. All rights reserved. * See the LICENSE file for additional terms and conditions. */ #ifndef GRIDINTERP_H_ #define GRIDINTERP_H_ // Standard #include<vector> #include "Eigen/Dense" // btwxt #include "griddeddata.h" #include "gridpoint.h" #include "hypercube.h" namespace Btwxt { // this will be the public-facing class. class RegularGridInterpolator { public: // GridSpace, GridAxis, AllValueTables, ValueTable are instantiated in RGI constructor. RegularGridInterpolator(); explicit RegularGridInterpolator(GriddedData &the_blob); RegularGridInterpolator( const std::vector<std::vector<double> > &grid, const std::vector<std::vector<double> > &values ); // Add value table to GriddedData std::size_t add_value_table(std::vector<double>& value_vector) { return the_blob.add_value_table(value_vector); } // GridPoint gets instantiated inside calculate_value_at_target double calculate_value_at_target(std::vector<double> target, std::size_t table_index); double operator()(std::vector<double> target, std::size_t table_index) { return calculate_value_at_target(std::move(target), table_index); } double calculate_value_at_target(std::size_t table_index); double operator()(std::size_t table_index) { return calculate_value_at_target(table_index); } std::vector<double> calculate_all_values_at_target(std::vector<double> target); std::vector<double> operator()(std::vector<double> target) { return calculate_all_values_at_target(std::move(target)); } std::vector<double> calculate_all_values_at_target(); std::vector<double> operator()() { return calculate_all_values_at_target(); } void set_new_grid_point(const std::vector<double> &target); std::vector<double> get_current_grid_point(); void clear_current_grid_point(); std::size_t get_ndims(); private: GriddedData the_blob; bool cgp_exists; GridPoint current_grid_point; WhereInTheGridIsThisPoint the_locator; Hypercube hypercube; void check_target_dimensions(const std::vector<double> &target); std::vector<double> interpolation_wrapper(); }; // free functions std::size_t pow(const std::size_t &base, const std::size_t &power); } #endif // GRIDINTERP_H_
ddbdd0fcd1d2e6c5c308621bece249a91aa3d603
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/textproc/zorba/files/patch-src-util_string_util.cpp
315c9958bd7aa94872d9dd118bf07c61323c3c79
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C++
false
false
1,191
cpp
patch-src-util_string_util.cpp
--- src/util/string_util.cpp.orig 2012-10-04 00:35:16.000000000 +0200 +++ src/util/string_util.cpp 2014-09-12 11:43:08.000000000 +0200 @@ -18,6 +18,9 @@ #include <cerrno> #include <cstdlib> +#include <stdlib.h> +#include <limits.h> + #include "ascii_util.h" #include "cxx_util.h" #include "string_util.h" @@ -92,7 +95,11 @@ float atof( char const *s ) { char *end; errno = 0; +#ifdef WIN32 float result = std::strtof( s, &end ); +#else + float result = strtof( s, &end ); +#endif check_parse_number( s, end, &result ); return result; } @@ -100,7 +107,11 @@ long long atoll( char const *s ) { char *end; errno = 0; +#ifdef WIN32 long long const result = std::strtoll( s, &end, 10 ); +#else + long long const result = strtoll( s, &end, 10 ); +#endif check_parse_number( s, end, static_cast<long long*>( nullptr ) ); return result; } @@ -114,7 +125,11 @@ char *end; errno = 0; +#ifdef WIN32 unsigned long long const result = std::strtoull( s, &end, 10 ); +#else + unsigned long long const result = strtoull( s, &end, 10 ); +#endif check_parse_number( s, end, static_cast<unsigned long long*>( nullptr ) ); if ( minus && result ) {
c6ef804051440e48ff6711b0d6d6549bff9e493a
3062c8b8c05793b33b699c6800334c7ec07779d1
/tv/tuner/aidl/vts/functional/DvrTests.h
6662637d548a7ca688206706f2845ac2efb435ba
[ "Apache-2.0" ]
permissive
crdroidandroid/android_hardware_interfaces
d195f4fbd01ff8db36428667f73faff79a17b6e9
3ecf0495de1b1d20d42a0486ac3f742fc2758c5b
refs/heads/13.0
2023-08-18T19:30:51.587761
2023-08-12T18:01:14
2023-08-12T18:01:14
103,736,402
3
31
null
2023-07-29T14:54:17
2017-09-16T08:08:52
C++
UTF-8
C++
false
false
6,447
h
DvrTests.h
/* * Copyright 2021 The Android Open Source Project * * 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. */ #pragma once #include <fcntl.h> #include <fmq/AidlMessageQueue.h> #include <gtest/gtest.h> #include <log/log.h> #include <utils/Condition.h> #include <utils/Mutex.h> #include <atomic> #include <fstream> #include <iostream> #include <map> #include <thread> #include <aidl/android/hardware/tv/tuner/BnDvrCallback.h> #include <aidl/android/hardware/tv/tuner/IDvr.h> #include <aidl/android/hardware/tv/tuner/ITuner.h> #include "FilterTests.h" using ::aidl::android::hardware::common::fmq::MQDescriptor; using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite; using ::android::AidlMessageQueue; using ::android::Condition; using ::android::Mutex; using ::android::hardware::EventFlag; using namespace aidl::android::hardware::tv::tuner; using namespace std; #define WAIT_TIMEOUT 3000000000 class DvrCallback : public BnDvrCallback { public: virtual ::ndk::ScopedAStatus onRecordStatus(RecordStatus status) override { ALOGD("[vts] record status %hhu", status); switch (status) { case RecordStatus::DATA_READY: break; case RecordStatus::LOW_WATER: break; case RecordStatus::HIGH_WATER: case RecordStatus::OVERFLOW: ALOGD("[vts] record overflow. Flushing."); EXPECT_TRUE(mDvr) << "Dvr callback is not set with an IDvr"; if (mDvr) { ndk::ScopedAStatus result = mDvr->flush(); ALOGD("[vts] Flushing result %s.", result.getMessage()); } break; } return ndk::ScopedAStatus::ok(); } virtual ::ndk::ScopedAStatus onPlaybackStatus(PlaybackStatus status) override { // android::Mutex::Autolock autoLock(mMsgLock); ALOGD("[vts] playback status %d", status); switch (status) { case PlaybackStatus::SPACE_EMPTY: case PlaybackStatus::SPACE_ALMOST_EMPTY: ALOGD("[vts] keep playback inputing %d", status); mKeepWritingPlaybackFMQ = true; break; case PlaybackStatus::SPACE_ALMOST_FULL: case PlaybackStatus::SPACE_FULL: ALOGD("[vts] stop playback inputing %d", status); mKeepWritingPlaybackFMQ = false; break; } return ndk::ScopedAStatus::ok(); } void stopPlaybackThread(); void testRecordOutput(); void stopRecordThread(); void startPlaybackInputThread(string& dataInputFile, PlaybackSettings& settings, MQDesc& playbackMQDescriptor); void startRecordOutputThread(RecordSettings recordSettings, MQDesc& recordMQDescriptor); static void* __threadLoopPlayback(void* user); static void* __threadLoopRecord(void* threadArgs); void playbackThreadLoop(); void recordThreadLoop(); bool readRecordFMQ(); void setDvr(std::shared_ptr<IDvr> dvr) { mDvr = dvr; } private: struct RecordThreadArgs { DvrCallback* user; RecordSettings* recordSettings; bool* keepReadingRecordFMQ; }; // uint16_t mDataLength = 0; std::vector<int8_t> mDataOutputBuffer; std::map<uint32_t, std::unique_ptr<FilterMQ>> mFilterMQ; std::unique_ptr<FilterMQ> mPlaybackMQ; std::unique_ptr<FilterMQ> mRecordMQ; std::map<uint32_t, EventFlag*> mFilterMQEventFlag; android::Mutex mMsgLock; android::Condition mMsgCondition; std::atomic<bool> mKeepWritingPlaybackFMQ = true; std::atomic<bool> mKeepReadingRecordFMQ = true; std::atomic<bool> mPlaybackThreadRunning; std::atomic<bool> mRecordThreadRunning; std::thread mPlaybackThread; std::thread mRecordThread; string mInputDataFile; PlaybackSettings mPlaybackSettings; std::shared_ptr<IDvr> mDvr = nullptr; // int mPidFilterOutputCount = 0; }; class DvrTests { public: void setService(std::shared_ptr<ITuner> tuner) { mService = tuner; } void setDemux(std::shared_ptr<IDemux> demux) { mDemux = demux; } void startPlaybackInputThread(string& dataInputFile, PlaybackSettings& settings) { mDvrPlaybackCallback->startPlaybackInputThread(dataInputFile, settings, mDvrPlaybackMQDescriptor); }; void startRecordOutputThread(RecordSettings settings) { mDvrRecordCallback->startRecordOutputThread(settings, mDvrRecordMQDescriptor); }; void stopPlaybackThread() { mDvrPlaybackCallback->stopPlaybackThread(); } void testRecordOutput() { mDvrRecordCallback->testRecordOutput(); } void stopRecordThread() { mDvrRecordCallback->stopRecordThread(); } AssertionResult openDvrInDemux(DvrType type, int32_t bufferSize); AssertionResult configDvrPlayback(DvrSettings setting); AssertionResult configDvrRecord(DvrSettings setting); AssertionResult getDvrPlaybackMQDescriptor(); AssertionResult getDvrRecordMQDescriptor(); AssertionResult attachFilterToDvr(std::shared_ptr<IFilter> filter); AssertionResult detachFilterToDvr(std::shared_ptr<IFilter> filter); AssertionResult stopDvrPlayback(); AssertionResult startDvrPlayback(); AssertionResult stopDvrRecord(); AssertionResult startDvrRecord(); void closeDvrPlayback(); void closeDvrRecord(); protected: static AssertionResult failure() { return ::testing::AssertionFailure(); } static AssertionResult success() { return ::testing::AssertionSuccess(); } std::shared_ptr<ITuner> mService; std::shared_ptr<IDvr> mDvrPlayback; std::shared_ptr<IDvr> mDvrRecord; std::shared_ptr<IDemux> mDemux; std::shared_ptr<DvrCallback> mDvrPlaybackCallback; std::shared_ptr<DvrCallback> mDvrRecordCallback; MQDesc mDvrPlaybackMQDescriptor; MQDesc mDvrRecordMQDescriptor; };
da85144a267d4f8fd70cdfe1823da9feab9dd16a
eac0a13fea8acd3ee5d8c6bd72b97f39102c6337
/CPPPool/cpp_d13_2019/ex05/Toy.cpp
ff11acb7106e80753269c59de4bfa077b028be2e
[]
no_license
Jean-MichelGRONDIN/EPITECH_Tek2_Projects
ddb022cc6dafd9c3d8d1e8b17bad8de108a0cd2c
eb4621bb747b1f2cca3edfe993fefef4b564835f
refs/heads/master
2023-01-04T13:12:21.670186
2020-10-23T06:16:50
2020-10-23T06:16:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,189
cpp
Toy.cpp
/* ** EPITECH PROJECT, 2020 ** cpp_d13_2019 ** File description: ** Toy */ #include "Toy.hpp" Toy::Toy() { this->_type = BASIC_TOY; this->_name = "toy"; this->_picture = Picture(); this->_error = Error(); this->_error.type = Toy::Error::ErrorType::UNKNOWN; } Toy::Toy(int type, std::string name, const std::string file) { this->_type = type; this->_name = name; this->_picture = Picture(file); this->_error = Error(); this->_error.type = Toy::Error::ErrorType::UNKNOWN; } Toy::Toy(const Toy &obj) { this->_type = obj._type; this->_name = obj._name; this->_picture = Picture(obj._picture); this->_error = *new Toy::Error; this->_error.type = Toy::Error::ErrorType::UNKNOWN; } Toy::~Toy() { } int Toy::getType() const { return (this->_type); } std::string Toy::getName() const { return (this->_name); } void Toy::setName(std::string name) { this->_name = name; } bool Toy::setAscii(const std::string file) { bool res = this->_picture.getPictureFromFile(file); if (res == false) this->_error.type = Toy::Error::ErrorType::PICTURE; return (res); } std::string Toy::getAscii() const { return (this->_picture.data); } void Toy::speak(std::string statement) { std::cout << this->_name << " \"" << statement << "\"" << std::endl; } Toy &Toy::operator<<(std::string str) { this->_picture.data = str; return (*this); } bool Toy::speak_es(std::string statement) { (void)statement; this->_error.type = Toy::Error::ErrorType::SPEAK; return (false); } Toy::Error::Error() { } Toy::Error::~Error() { } std::string Toy::Error::what() { if (this->type == PICTURE) return ("bad new illustration"); if (this->type == SPEAK) return ("wrong mode"); return (""); } std::string Toy::Error::where() { if (this->type == PICTURE) return ("setAscii"); if (this->type == SPEAK) return ("speak_es"); return (""); } Toy::Error Toy::getLastError() { return (this->_error); } std::ostream &operator<<(std::ostream &s, const Toy &obj) { s << obj.getName() << std::endl << obj.getAscii() << std::endl; return (s); }
37c4ebc2fb56bed661fd2bc3576366d6c66c17c7
973e6b6952070cc2923d117aaa7772d9d010439b
/src/state/src/actor/bot_states/bot_blast_state.cpp
8f66969fabbb8f2bb2f40389f4360e873dc4b9b5
[]
no_license
delta/codecharacter-simulator-2020
af4169dc79e709341ec61a0ad0263bdb0077ecbb
1f1224aee3a15a8adaa7e68ee05dd35e053f2470
refs/heads/master
2023-03-25T22:17:03.967380
2021-03-19T15:30:08
2021-03-19T15:30:08
190,995,166
2
0
null
2021-03-22T10:58:31
2019-06-09T10:54:15
C++
UTF-8
C++
false
false
692
cpp
bot_blast_state.cpp
/** * @file bot_blast_state.cpp * Definition of bot blast state */ #include "state/actor/bot_states/bot_blast_state.h" #include "state/actor/bot.h" #include "state/actor/bot_states/bot_dead_state.h" namespace state { BotBlastState::BotBlastState(Bot *bot) : BotState(BotStateName::BLAST, bot) {} void BotBlastState::enter() { // kill self and damage others by blasting bot->damageEnemyActors(bot->getPlayerId(), bot->getActorId(), bot->getPosition()); bot->damage(bot->getHp()); } std::unique_ptr<IActorState> BotBlastState::update() const { return std::make_unique<BotDeadState>(bot); } void BotBlastState::exit() {} } // namespace state
d82e85913b1840d3dbd0c1b2721de644cf486598
a33aac97878b2cb15677be26e308cbc46e2862d2
/program_data/PKU_raw/9/554.c
40a294bf7184e07d172777de64240b969999e770
[]
no_license
GabeOchieng/ggnn.tensorflow
f5d7d0bca52258336fc12c9de6ae38223f28f786
7c62c0e8427bea6c8bec2cebf157b6f1ea70a213
refs/heads/master
2022-05-30T11:17:42.278048
2020-05-02T11:33:31
2020-05-02T11:33:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,291
c
554.c
main() { char senior[100][10]; char junior[100][10]; char temp[10]; int list[100]={0}; int se[100]; int ju[100]; int n,i,j,k,nums,numj,year; scanf("%d",&n); nums=-1; numj=-1; for (i=1;i<=n;i++) { scanf("%s",temp); scanf("%d",&year); if (year>=60) { nums++; strcpy(senior[nums],temp); se[nums]=year; list[nums]=nums; } else { numj++; strcpy(junior[numj],temp); ju[numj]=year; } } for (i=0;i<nums;i++) for (j=i+1;j<=nums;j++) if ((se[i]<se[j]) || (se[i]==se[j] && list[i]>list[j])) { year=se[i]; se[i]=se[j]; se[j]=year; year=list[i]; list[i]=list[j]; list[j]=year; strcpy(temp,senior[i]); strcpy(senior[i],senior[j]); strcpy(senior[j],temp); } for (i=0;i<=nums;i++) { puts(senior[i]); } for (i=0;i<=numj;i++) puts(junior[i]); return 0; }
6c68cef4e24af9589de3d3e92a977696953429ad
3a42bab0688ea0a61cc8aa87b5c97143035dc269
/SnakeFML/SnakingState.hpp
4b74d139781ffe8f996d197a1f5728073f58146e
[]
no_license
JonnyPtn/SnakeFML
71a5c3dadce710f35a8f294dcc455ca1127552c2
7bbd16169e0f46a357276a6973e253933b1f2b0d
refs/heads/master
2021-01-18T22:33:25.255820
2017-11-22T01:38:39
2017-11-22T01:38:39
50,194,946
6
12
null
null
null
null
UTF-8
C++
false
false
629
hpp
SnakingState.hpp
// // SnakingState.hpp // SnakeFML // // Created by Jonny Paton on 21/11/2017. // #ifndef SnakingState_hpp #define SnakingState_hpp #include <xyginext/core/State.hpp> #include <xyginext/ecs/Scene.hpp> class SnakingState : public xy::State { public: SnakingState(xy::StateStack& ss, xy::State::Context& context); bool handleEvent(const sf::Event &evt) override; void handleMessage(const xy::Message &) override; bool update(float dt) override; void draw() override; xy::StateID stateID() const override; private: xy::Scene m_scene; }; #endif /* SnakingState_hpp */
a1fad7bbfc43dc22a39ebb529912dd0e78170851
58a0ba5ee99ec7a0bba36748ba96a557eb798023
/GeeksForGeeks/Algorithms/9. Dynamic Programming/10.longest-palindromic-subsequence.cpp
90eb0b815193fe0efc56828c2985d1997958a363
[ "MIT" ]
permissive
adityanjr/code-DS-ALGO
5bdd503fb5f70d459c8e9b8e58690f9da159dd53
1c104c33d2f56fe671d586b702528a559925f875
refs/heads/master
2022-10-22T21:22:09.640237
2022-10-18T15:38:46
2022-10-18T15:38:46
217,567,198
40
54
MIT
2022-10-18T15:38:47
2019-10-25T15:50:28
C++
UTF-8
C++
false
false
810
cpp
10.longest-palindromic-subsequence.cpp
// http://www.geeksforgeeks.org/dynamic-programming-set-12-longest-palindromic-subsequence #include <iostream> #include <cstring> using namespace std; int lps(char *str){ int len = strlen(str); int L[len][len]; for(int i=0; i<len; i++){ L[i][i] = 1; } int j; for(int cl=2; cl<=len; cl++){ for(int i=0; i<len-cl+1; i++){ j = i+cl-1; if(str[i] == str[j] && cl==2) L[i][j] = 2; else if(str[i] == str[j]) L[i][j] = L[i+1][j-1] + 2; else { L[i][j] = max(L[i][j-1], L[i+1][j]); } } } return L[0][len-1]; } int main() { char seq[] = "GEEKS FOR GEEKS"; int n = strlen(seq); printf ("The lnegth of the LPS is %d", lps(seq)); return 0; }
1d2f107b2e65dd2454813eb44d4f4b3ee92a16a0
9ff779813c7f4d0bdf01c097bcd696a20303ca8a
/20170713_MyVector/cVector3.h
4fecb45501c378b63b70f49ab934a4c057f78dd7
[]
no_license
jaejunlee0538/3DGameAssignments
f27c361eb1966aea9fc8dad90fdccfe28506f4c1
1946d481f467eb4740c58a0575060cd9ec088b3f
refs/heads/master
2021-01-01T20:39:30.179428
2017-09-11T13:19:25
2017-09-11T13:19:25
98,905,507
0
0
null
null
null
null
UTF-8
C++
false
false
762
h
cVector3.h
#pragma once class cVector3 { public: cVector3(); cVector3(float x, float y, float z); ~cVector3(); float Length() const; float LengthSq() const; cVector3 Normalize() const; void Print(); float& X(); const float& X() const; float& Y(); const float& Y() const; float& Z(); const float& Z() const; float& operator[](size_t idx); const float& operator[](size_t idx)const; bool operator==(const cVector3& vec) const; bool operator!=(const cVector3& vec) const; cVector3 operator+(const cVector3& vec) const; cVector3 operator-(const cVector3& vec) const; cVector3 operator*(float s) const; static float Dot(const cVector3& v1, const cVector3& v2); static cVector3 Cross(const cVector3& v1, const cVector3& v2); private: float _xyz[3]; };
181bb6e9581216e99cdd976d9a9cfe02bdcfbad7
792958a048162488c502aac80ec9d6e1b11afaeb
/백준/20_1_21/2419.cpp
a2ff87e0c50204352f1003daa84818a1840c94ad
[]
no_license
Kim-DongGeun/Probelm-Solving
ca1d285033f49bf818c8c8796a1c66433555fc16
ee9412e574adbe209504d415d4a60fa6b4c2ed5f
refs/heads/master
2023-02-15T17:50:25.315424
2021-01-06T01:10:32
2021-01-06T01:10:32
323,862,898
0
0
null
null
null
null
UTF-8
C++
false
false
235
cpp
2419.cpp
#include <iostream> using namespace std; int arr[301]; pair<int, int> dp[1000001][2]; void dfs(int cur) { dp[cur][0] = } int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> arr[i]; dfs(0); return 0; }
1b0b2b132bf7570be7e19749ddf14b151e5ed2d2
ca38e7094429cb01d0430e0f724be5a104347865
/WristWatch1.4/Interrupts.ino
13a478496d995162717a98ae45b70dcd98f7fafd
[]
no_license
Jo-Dill/watch
0678fcecfc238132f8217264999eaf8762afa9f3
cf03ade3090ea903c23274622b5bb8d44f7e75a8
refs/heads/main
2023-04-21T02:44:49.667573
2021-05-11T18:43:35
2021-05-11T18:43:35
366,440,735
1
0
null
2021-05-11T16:27:09
2021-05-11T16:02:31
null
UTF-8
C++
false
false
505
ino
Interrupts.ino
volatile byte alarmflag =0; volatile byte downbuttonflag =0; volatile byte upbuttonflag =0; void interruptSetup(){ LowPower.attachInterruptWakeup(RTC_ALARM_WAKEUP, wokeUpbyAlarm, CHANGE); LowPower.attachInterruptWakeup(upbuttonPin, wokeUpbyUpbutton, FALLING); LowPower.attachInterruptWakeup(downbuttonPin, wokeUpbyDownbutton, FALLING); } void wokeUpbyAlarm (){ alarmflag=1; } void wokeUpbyDownbutton (){ downbuttonflag =1; } void wokeUpbyUpbutton (){ upbuttonflag =1; }
f11bec9d7d083d75b03aaa4ded5dec87c6970cf5
521685507e5b26ec9be38b39a249bdc1ee638138
/Servers/ServerManager/vtkSMComparativeViewProxy.cxx
85ebd825b1ceb8c3894ee8976987ab2b05514b32
[ "LicenseRef-scancode-paraview-1.2" ]
permissive
matthb2/ParaView-beforekitwareswtichedtogit
6ad4662a1ad8c3d35d2c41df209fc4d78b7ba298
392519e17af37f66f6465722930b3705c1c5ca6c
refs/heads/master
2020-04-05T05:11:15.181579
2009-05-26T20:50:10
2009-05-26T20:50:10
211,087
1
2
null
null
null
null
UTF-8
C++
false
false
27,601
cxx
vtkSMComparativeViewProxy.cxx
/*========================================================================= Program: ParaView Module: $RCSfile$ Copyright (c) Kitware, Inc. All rights reserved. See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkSMComparativeViewProxy.h" #include "vtkCollection.h" #include "vtkMemberFunctionCommand.h" #include "vtkObjectFactory.h" #include "vtkSMAnimationSceneProxy.h" #include "vtkSmartPointer.h" #include "vtkSMCameraLink.h" #include "vtkSMDoubleVectorProperty.h" #include "vtkSMIntVectorProperty.h" #include "vtkSMPropertyIterator.h" #include "vtkSMProxyLink.h" #include "vtkSMProxyManager.h" #include "vtkSMPropertyHelper.h" #include "vtkSMRepresentationProxy.h" #include "vtkSMProxyProperty.h" #include <vtkstd/vector> #include <vtkstd/map> #include <vtkstd/set> #include <vtkstd/string> #include <vtksys/ios/sstream> class vtkSMComparativeViewProxy::vtkInternal { public: struct RepresentationData { typedef vtkstd::map<vtkSMViewProxy*, vtkSmartPointer<vtkSMRepresentationProxy> > MapOfViewToRepr; MapOfViewToRepr Clones; // The clone representations created for the representations (with key // being the view in which that representation clone // exists. vtkSmartPointer<vtkSMProxyLink> Link; }; typedef vtkstd::vector<vtkSmartPointer<vtkSMViewProxy> > VectorOfViews; VectorOfViews Views; typedef vtkstd::map<vtkSMRepresentationProxy*, RepresentationData> MapOfReprClones; MapOfReprClones RepresentationClones; vtkSmartPointer<vtkSMProxyLink> ViewLink; vtkSmartPointer<vtkSMCameraLink> ViewCameraLink; vtkInternal() { this->ViewLink = vtkSmartPointer<vtkSMProxyLink>::New(); this->ViewCameraLink = vtkSmartPointer<vtkSMCameraLink>::New(); this->ViewCameraLink->SynchronizeInteractiveRendersOff(); } unsigned int ActiveIndexX; unsigned int ActiveIndexY; vtkstd::string SuggestedViewType; }; //---------------------------------------------------------------------------- vtkStandardNewMacro(vtkSMComparativeViewProxy); vtkCxxRevisionMacro(vtkSMComparativeViewProxy, "$Revision$"); //---------------------------------------------------------------------------- vtkSMComparativeViewProxy::vtkSMComparativeViewProxy() { this->Internal = new vtkInternal(); this->Mode = FILM_STRIP; this->Dimensions[0] = 0; this->Dimensions[1] = 0; this->ViewSize[0] = 400; this->ViewSize[1] = 400; this->TimeRange[0] = 0.0; this->TimeRange[1] = 1.0; this->Spacing[0] = this->Spacing[1] = 1; this->AnimationSceneX = 0; this->AnimationSceneY = 0; this->ShowTimeSteps = 1; this->ViewUpdateMode = UPDATE_MODE_ROOT; this->SceneOutdated = true; vtkMemberFunctionCommand<vtkSMComparativeViewProxy>* fsO = vtkMemberFunctionCommand<vtkSMComparativeViewProxy>::New(); fsO->SetCallback(*this, &vtkSMComparativeViewProxy::MarkSceneOutdated); this->SceneObserver = fsO; } //---------------------------------------------------------------------------- vtkSMComparativeViewProxy::~vtkSMComparativeViewProxy() { if (this->AnimationSceneX) { this->AnimationSceneX->RemoveObserver(this->SceneObserver); } if (this->AnimationSceneY) { this->AnimationSceneY->RemoveObserver(this->SceneObserver); } delete this->Internal; this->SceneObserver->Delete(); } //---------------------------------------------------------------------------- bool vtkSMComparativeViewProxy::BeginCreateVTKObjects() { vtkSMViewProxy* rootView = vtkSMViewProxy::SafeDownCast( this->GetSubProxy("RootView")); if (!rootView) { vtkErrorMacro("Subproxy \"Root\" must be defined in the xml configuration."); return false; } this->Dimensions[0] = 1; this->Dimensions[1] = 1; // Root view is the first view in the views list. this->Internal->Views.push_back(rootView); this->Internal->ViewCameraLink->AddLinkedProxy(rootView, vtkSMLink::INPUT); this->Internal->ViewCameraLink->AddLinkedProxy(rootView, vtkSMLink::OUTPUT); this->Internal->ViewLink->AddLinkedProxy(rootView, vtkSMLink::INPUT); // Every view keeps their own representations. this->Internal->ViewLink->AddException("Representations"); // This view computes view size/view position for each view based on the // layout. this->Internal->ViewLink->AddException("ViewSize"); this->Internal->ViewLink->AddException("ViewTime"); this->Internal->ViewLink->AddException("ViewPosition"); this->Internal->ViewLink->AddException("CameraPositionInfo"); this->Internal->ViewLink->AddException("CameraPosition"); this->Internal->ViewLink->AddException("CameraFocalPointInfo"); this->Internal->ViewLink->AddException("CameraFocalPoint"); this->Internal->ViewLink->AddException("CameraViewUpInfo"); this->Internal->ViewLink->AddException("CameraViewUp"); this->Internal->ViewLink->AddException("CameraClippingRangeInfo"); this->Internal->ViewLink->AddException("CameraClippingRange"); this->Internal->ViewLink->AddException("CameraViewAngleInfo"); this->Internal->ViewLink->AddException("CameraViewAngle"); this->AnimationSceneX = vtkSMAnimationSceneProxy::SafeDownCast( this->GetSubProxy("AnimationSceneX")); this->AnimationSceneY = vtkSMAnimationSceneProxy::SafeDownCast( this->GetSubProxy("AnimationSceneY")); this->AnimationSceneX->AddObserver(vtkCommand::ModifiedEvent, this->SceneObserver); this->AnimationSceneY->AddObserver(vtkCommand::ModifiedEvent, this->SceneObserver); return this->Superclass::BeginCreateVTKObjects(); } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::Build(int dx, int dy) { // Ensure objects are created before building. this->CreateVTKObjects(); if (dx == 0 || dy == 0) { vtkErrorMacro("Dimensions cannot be 0."); return; } int numViews = dx * dy; int cc; // Remove extra view modules. for (cc=this->Internal->Views.size()-1; cc >= numViews; cc--) { this->RemoveView(this->Internal->Views[cc]); this->SceneOutdated = true; } // Add view modules, if not enough. for (cc=this->Internal->Views.size(); cc < numViews; cc++) { this->AddNewView(); this->SceneOutdated = true; } this->Dimensions[0] = dx; this->Dimensions[1] = dy; this->UpdateViewLayout(); // Whenever the layout changes we'll fire the ConfigureEvent. this->InvokeEvent(vtkCommand::ConfigureEvent); } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::UpdateViewLayout() { int width = (this->ViewSize[0] - (this->Dimensions[0]-1)*this->Spacing[0])/this->Dimensions[0]; int height = (this->ViewSize[1] - (this->Dimensions[1]-1)*this->Spacing[1])/this->Dimensions[1]; int view_index = 0; for (int y=0; y < this->Dimensions[1]; ++y) { for (int x=0; x < this->Dimensions[0]; ++x, view_index++) { vtkSMViewProxy* view = this->Internal->Views[view_index]; int view_pos[2]; view_pos[0] = this->ViewPosition[0] + width * x; view_pos[1] = this->ViewPosition[1] + height * y; vtkSMIntVectorProperty* ivp = vtkSMIntVectorProperty::SafeDownCast( view->GetProperty("ViewPosition")); ivp->SetElements(view_pos); ivp = vtkSMIntVectorProperty::SafeDownCast( view->GetProperty("ViewSize")); if (ivp) // Not all view classes have a ViewSize property { ivp->SetElement(0, width); ivp->SetElement(1, height); } ivp = vtkSMIntVectorProperty::SafeDownCast( view->GetProperty("GUISize")); ivp->SetElements(this->GUISize); view->UpdateVTKObjects(); } } } //---------------------------------------------------------------------------- vtkSMViewProxy* vtkSMComparativeViewProxy::GetRootView() { if (this->Internal->Views.size()) { return this->Internal->Views[0]; } else { return 0; } } //---------------------------------------------------------------------------- static void vtkCopyClone(vtkSMProxy* source, vtkSMProxy* clone, vtkstd::set<vtkstd::string> *exceptions=0) { vtkSmartPointer<vtkSMPropertyIterator> iterSource; vtkSmartPointer<vtkSMPropertyIterator> iterDest; iterSource.TakeReference(source->NewPropertyIterator()); iterDest.TakeReference(clone->NewPropertyIterator()); // Since source/clone are exact copies, the following is safe. for (; !iterSource->IsAtEnd() && !iterDest->IsAtEnd(); iterSource->Next(), iterDest->Next()) { // Skip the property if it is in the exceptions list. if (exceptions && exceptions->find(iterSource->GetKey()) != exceptions->end()) { continue; } vtkSMProperty* destProp = iterDest->GetProperty(); // Skip the property if it is information only or is internal. if (destProp->GetInformationOnly() || destProp->GetIsInternal()) { continue; } // Copy the property from source to dest destProp->Copy(iterSource->GetProperty()); } } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::AddNewView() { vtkSMViewProxy* rootView = this->GetRootView(); vtkSMProxyManager* pxm = vtkSMProxyManager::GetProxyManager(); vtkSMViewProxy* newView = vtkSMViewProxy::SafeDownCast( pxm->NewProxy(rootView->GetXMLGroup(), rootView->GetXMLName())); if (!newView) { vtkErrorMacro("Failed to create internal view proxy. Comparative visualization " "view cannot work."); return; } newView->SetConnectionID(this->ConnectionID); newView->UpdateVTKObjects(); // Copy current view properties over to this newly created view. vtkstd::set<vtkstd::string> exceptions; exceptions.insert("Representations"); exceptions.insert("ViewSize"); exceptions.insert("ViewPosition"); vtkCopyClone(rootView, newView, &exceptions); this->Internal->Views.push_back(newView); this->Internal->ViewCameraLink->AddLinkedProxy(newView, vtkSMLink::INPUT); this->Internal->ViewCameraLink->AddLinkedProxy(newView, vtkSMLink::OUTPUT); this->Internal->ViewLink->AddLinkedProxy(newView, vtkSMLink::OUTPUT); newView->Delete(); // Create clones for all currently added representation for the new view. vtkInternal::MapOfReprClones::iterator reprIter; for (reprIter = this->Internal->RepresentationClones.begin(); reprIter != this->Internal->RepresentationClones.end(); ++reprIter) { vtkSMRepresentationProxy* repr = reprIter->first; vtkInternal::RepresentationData& data = reprIter->second; vtkSMRepresentationProxy* newRepr = vtkSMRepresentationProxy::SafeDownCast( pxm->NewProxy(repr->GetXMLGroup(), repr->GetXMLName())); vtkCopyClone(repr, newRepr); // create a clone newRepr->UpdateVTKObjects(); // create objects data.Link->AddLinkedProxy(newRepr, vtkSMLink::OUTPUT); // link properties newView->AddRepresentation(newRepr); // add representation to view // Now update data structure to include this view/repr clone. data.Clones[newView] = newRepr; newRepr->Delete(); } } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::RemoveView(vtkSMViewProxy* view) { if (view == this->GetRootView()) { vtkErrorMacro("Root view cannot be removed."); return; } // Remove all representations in this view. vtkInternal::MapOfReprClones::iterator reprIter; for (reprIter = this->Internal->RepresentationClones.begin(); reprIter != this->Internal->RepresentationClones.end(); ++reprIter) { vtkInternal::RepresentationData& data = reprIter->second; vtkInternal::RepresentationData::MapOfViewToRepr::iterator cloneIter = data.Clones.find(view); if (cloneIter != data.Clones.end()) { vtkSMRepresentationProxy* clone = cloneIter->second.GetPointer(); view->RemoveRepresentation(clone); data.Link->RemoveLinkedProxy(clone); data.Clones.erase(cloneIter); } } this->Internal->ViewLink->RemoveLinkedProxy(view); this->Internal->ViewCameraLink->RemoveLinkedProxy(view); this->Internal->ViewCameraLink->RemoveLinkedProxy(view); vtkInternal::VectorOfViews::iterator iter; for (iter = this->Internal->Views.begin(); iter != this->Internal->Views.end(); ++iter) { if (iter->GetPointer() == view) { this->Internal->Views.erase(iter); break; } } } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::AddRepresentation(vtkSMRepresentationProxy* repr) { if (!repr) { return; } // Add representation to the root view vtkSMViewProxy* rootView = this->GetRootView(); rootView->AddRepresentation(repr); // Create clones of representation and add them to all other views. // We will save information about the clones we create // so that we can clean them up later. vtkInternal::RepresentationData data; // We'll link the clones' properties to the original // representation using a proxy link. The "UpdateTime" // property will not be linked however. vtkSMProxyLink* reprLink = vtkSMProxyLink::New(); data.Link.TakeReference(reprLink); reprLink->AddLinkedProxy(repr, vtkSMLink::INPUT); reprLink->AddException("UpdateTime"); // Need the proxy manager to create new representations vtkSMProxyManager* pxm = vtkSMProxyManager::GetProxyManager(); // For each view vtkInternal::VectorOfViews::iterator iter = this->Internal->Views.begin(); iter++; // skip root view. for (; iter != this->Internal->Views.end(); ++iter) { // Create a new representation vtkSMRepresentationProxy* newRepr = vtkSMRepresentationProxy::SafeDownCast( pxm->NewProxy(repr->GetXMLGroup(), repr->GetXMLName())); // Made the new representation a clone vtkCopyClone(repr, newRepr); newRepr->UpdateVTKObjects(); reprLink->AddLinkedProxy(newRepr, vtkSMLink::OUTPUT); // Add the cloned representation to this view iter->GetPointer()->AddRepresentation(newRepr); // Add the cloned representation to the RepresentationData struct // The clone is added to a map where its view is the key. data.Clones[iter->GetPointer()] = newRepr; // Clean up this reference newRepr->Delete(); } // Add the RepresentationData struct to a map // with the original representation as the key this->Internal->RepresentationClones[repr] = data; // Signal that representations have changed this->InvokeEvent(vtkCommand::UserEvent); // Override superclass' AddRepresentation since repr has already been added // to the rootView. } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::RemoveRepresentation(vtkSMRepresentationProxy* repr) { vtkInternal::MapOfReprClones::iterator reprDataIter = this->Internal->RepresentationClones.find(repr); if (!repr || reprDataIter == this->Internal->RepresentationClones.end()) { // Nothing to do. return; } vtkInternal::RepresentationData& data = reprDataIter->second; // Remove all clones of this representation. vtkInternal::RepresentationData::MapOfViewToRepr::iterator viewReprIter; for (viewReprIter = data.Clones.begin(); viewReprIter != data.Clones.end(); ++viewReprIter) { vtkSMViewProxy* view = viewReprIter->first; vtkSMRepresentationProxy* clone = viewReprIter->second.GetPointer(); if (view && clone) { view->RemoveRepresentation(clone); // No need to clean the clone from the proxy link since the link object // will be destroyed anyways. } } // This will destroy the repr proxy link as well. this->Internal->RepresentationClones.erase(reprDataIter); // Remove repr from RootView. vtkSMViewProxy* rootView = this->GetRootView(); rootView->RemoveRepresentation(repr); // Signal that representations have changed this->InvokeEvent(vtkCommand::UserEvent); // Override superclass' RemoveRepresentation since repr was not added to this // view at all, we added it to (and removed from) the root view. } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::RemoveAllRepresentations() { vtkInternal::MapOfReprClones::iterator iter = this->Internal->RepresentationClones.begin(); while (iter != this->Internal->RepresentationClones.end()) { vtkSMRepresentationProxy* repr = iter->first; this->RemoveRepresentation(repr); iter = this->Internal->RepresentationClones.begin(); } } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::StillRender() { static bool in_still_render = false; if (in_still_render) { return; } in_still_render = true; // Generate the CV if required. // For starters, we wont update the vis automatically, let the user call // UpdateComparativeVisualization explicitly. this->UpdateVisualization(); this->GetRootView()->StillRender(); // The StillRender will propagate through the ViewCameraLink to all the other // views. in_still_render = false; //this->Internal->ViewCameraLink->SetEnabled(true); } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::InteractiveRender() { // The InteractiveRender will propagate through the ViewCameraLink to all the // other views. this->GetRootView()->InteractiveRender(); } //---------------------------------------------------------------------------- vtkSMRepresentationProxy* vtkSMComparativeViewProxy::CreateDefaultRepresentation( vtkSMProxy* src, int outputport) { return this->GetRootView()->CreateDefaultRepresentation(src, outputport); } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::UpdateVisualization(int force) { if (!this->AnimationSceneX && !this->AnimationSceneY) { // no comparative vis. return; } if (!this->SceneOutdated && !force && this->ViewUpdateMode != UPDATE_MODE_ALL) { if (this->ViewUpdateMode == UPDATE_MODE_ROOT) { this->UpdateRootView(); } // no need to rebuild. return; } vtkInternal::VectorOfViews::iterator iter; for (iter = this->Internal->Views.begin(); iter != this->Internal->Views.end(); ++iter) { iter->GetPointer()->SetUseCache(false); iter->GetPointer()->UpdateAllRepresentations(); iter->GetPointer()->SetUseCache(true); } // Are we in generating a film-strip or a comparative vis? if (this->AnimationSceneX && this->AnimationSceneY && this->Mode == COMPARATIVE) { this->UpdateComparativeVisualization( this->AnimationSceneX, this->AnimationSceneY); } else if (this->Mode == FILM_STRIP && this->AnimationSceneX) { this->UpdateFilmStripVisualization(this->AnimationSceneX); } /* // I'm not sure why this block of code was needed? // It called SetUseCache(false) which caused bad behavior. for (iter = this->Internal->Views.begin(); iter != this->Internal->Views.end(); ++iter) { // Mark all representations as updated; this won't cause any real updation // since use cache is on. iter->GetPointer()->UpdateAllRepresentations(); iter->GetPointer()->SetUseCache(false); } */ this->SceneOutdated = false; } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::UpdateRootView() { this->AnimationSceneX->SetAnimationTime(0); vtkSMViewProxy* view = this->Internal->Views[0]; if (this->GetShowTimeSteps()) { view->SetViewUpdateTime(this->TimeRange[0]); } else { view->SetViewUpdateTime(this->GetViewUpdateTime()); } view->SetCacheTime(view->GetCacheTime()+1.0); view->StillRender(); } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::UpdateFilmStripVisualization( vtkSMAnimationSceneProxy* scene) { // Set EndTime to the number of views in comparative view. // Think of this as the number of key frames in the animation. // Next, for each frame in the CV, set that frame's time to an // intermediate value between this->TimeRange[0] and this->TimeRange[1]. vtkSMDoubleVectorProperty* dvp = vtkSMDoubleVectorProperty::SafeDownCast( scene->GetProperty("EndTime")); dvp->SetElement(0, this->Dimensions[0]*this->Dimensions[1]-1); scene->UpdateVTKObjects(); this->Internal->ActiveIndexX = 0; this->Internal->ActiveIndexY = 0; double increment = (this->TimeRange[1] - this->TimeRange[0])/ (this->Dimensions[0]*this->Dimensions[1]-1); for (int view_index=0; view_index < this->Dimensions[0]*this->Dimensions[1]; ++view_index) { scene->SetAnimationTime(view_index); vtkSMViewProxy* view = this->Internal->Views[view_index]; if (this->GetShowTimeSteps()) { double time = this->TimeRange[0] + view_index*increment; view->SetViewUpdateTime(time); } else { view->SetViewUpdateTime(this->GetViewUpdateTime()); } // HACK: This ensure that obsolete cache is never used when the CV is being // generated. view->SetCacheTime(view->GetCacheTime()+1.0); // Make the view cache the current setup. // We do interactive render so that both the full-res as well as low-res cache // is updated. view->InteractiveRender(); } } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::UpdateComparativeVisualization( vtkSMAnimationSceneProxy* sceneX, vtkSMAnimationSceneProxy* sceneY) { vtkSMDoubleVectorProperty* dvp = vtkSMDoubleVectorProperty::SafeDownCast( sceneX->GetProperty("EndTime")); dvp->SetElement(0, this->Dimensions[0]-1); sceneX->UpdateVTKObjects(); dvp = vtkSMDoubleVectorProperty::SafeDownCast( sceneY->GetProperty("EndTime")); dvp->SetElement(0, this->Dimensions[1]-1); sceneY->UpdateVTKObjects(); double increment = (this->TimeRange[1] - this->TimeRange[0])/ (this->Dimensions[0]*this->Dimensions[1]-1); int view_index=0; for (int y=0; y < this->Dimensions[1]; y++) { sceneY->SetAnimationTime(y); for (int x=0; x < this->Dimensions[0]; x++) { sceneX->SetAnimationTime(x); vtkSMViewProxy* view = this->Internal->Views[view_index]; if (this->GetShowTimeSteps()) { double time = this->TimeRange[0] + view_index*increment; view->SetViewUpdateTime(time); } else { view->SetViewUpdateTime(this->GetViewUpdateTime()); } // HACK: This ensure that obsolete cache is never used when the CV is being // generated. view->SetCacheTime(view->GetCacheTime()+1.0); // Make the view cache the current setup. // We do interactive render so that both the full-res as well as low-res cache // is updated. view->InteractiveRender(); view_index++; } } } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::GetViews(vtkCollection* collection) { if (!collection) { return; } vtkInternal::VectorOfViews::iterator iter; for (iter = this->Internal->Views.begin(); iter != this->Internal->Views.end(); ++iter) { collection->AddItem(iter->GetPointer()); } } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::GetRepresentationsForView(vtkSMViewProxy* view, vtkCollection *collection) { if (!collection) { return; } // Find all representations in this view. // For each representation vtkInternal::MapOfReprClones::iterator reprIter; for (reprIter = this->Internal->RepresentationClones.begin(); reprIter != this->Internal->RepresentationClones.end(); ++reprIter) { if (view == this->GetRootView()) { // If the view is the root view, then its representations // are the keys of map we are iterating over collection->AddItem(reprIter->first); continue; } // The view is not the root view, so it could be one of the cloned views. // Search the RepresentationData struct for a representation // belonging to the cloned view. vtkInternal::RepresentationData& data = reprIter->second; vtkInternal::RepresentationData::MapOfViewToRepr::iterator cloneIter = data.Clones.find(view); if (cloneIter != data.Clones.end()) { // A representation was found, so add it to the collection. vtkSMRepresentationProxy* repr = cloneIter->second.GetPointer(); collection->AddItem(repr); } } } //----------------------------------------------------------------------------- bool vtkSMComparativeViewProxy::GetXPropertyAndElement(vtkSMProperty *& prop, int & element) { vtkSMProxyProperty* pp = vtkSMProxyProperty::SafeDownCast(this->GetProperty("XCues")); for (unsigned int i=0; i < pp->GetNumberOfProxies(); ++i) { vtkSMAnimationCueProxy* cue = vtkSMAnimationCueProxy::SafeDownCast(pp->GetProxy(i)); if (cue && vtkSMPropertyHelper(cue, "Enabled").GetAsInt()) { element = cue->GetAnimatedElement(); prop = cue->GetAnimatedProperty(); return true; } } return false; } //----------------------------------------------------------------------------- bool vtkSMComparativeViewProxy::GetYPropertyAndElement(vtkSMProperty *& prop, int & element) { vtkSMProxyProperty* pp = vtkSMProxyProperty::SafeDownCast(this->GetProperty("YCues")); for (unsigned int i=0; i < pp->GetNumberOfProxies(); ++i) { vtkSMAnimationCueProxy* cue = vtkSMAnimationCueProxy::SafeDownCast(pp->GetProxy(i)); if (cue && vtkSMPropertyHelper(cue, "Enabled").GetAsInt()) { element = cue->GetAnimatedElement(); prop = cue->GetAnimatedProperty(); return true; } } return false; } //---------------------------------------------------------------------------- const char* vtkSMComparativeViewProxy::GetSuggestedViewType(vtkIdType connectionID) { vtkSMViewProxy* rootView = vtkSMViewProxy::SafeDownCast(this->GetSubProxy("RootView")); if (rootView) { vtksys_ios::ostringstream stream; stream << "Comparative" << rootView->GetSuggestedViewType(connectionID); this->Internal->SuggestedViewType = stream.str(); return this->Internal->SuggestedViewType.c_str(); } return this->Superclass::GetSuggestedViewType(connectionID); } //---------------------------------------------------------------------------- void vtkSMComparativeViewProxy::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "Dimensions: " << this->Dimensions[0] << ", " << this->Dimensions[1] << endl; os << indent << "Mode: " << this->Mode << endl; os << indent << "TimeRange: " << this->TimeRange[0] <<", " << this->TimeRange[1] << endl; os << indent << "Spacing: " << this->Spacing[0] << ", " << this->Spacing[1] << endl; }
819a21f0368454cc7cef682cf94b2cf3d15987df
dd80a584130ef1a0333429ba76c1cee0eb40df73
/dalvik/vm/mterp/c/OP_ADD_LONG.cpp
25d1f47df7c400cb0507a9ff86b2c2977b4ac1ee
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "MIT" ]
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
50
cpp
OP_ADD_LONG.cpp
HANDLE_OP_X_LONG(OP_ADD_LONG, "add", +, 0) OP_END
4ab2ca0874065ad77c84a637065d798c518232aa
7175e88e90aa739fa6da8805e83d9d435f567e86
/Source/indra/newview/llweb.cpp
1747d4b929e1a2573bae0fdd06c14064e080fd20
[]
no_license
JohnMcCaffery/Armadillo-Phoenix
06af55f05848defb399605c986f905adf6ad2b70
f49cc3b45dd1039e6bc5254d30145bc1c6b95d0a
refs/heads/master
2020-06-04T03:35:24.354381
2014-05-20T16:14:58
2014-05-20T16:14:58
8,097,679
0
1
null
null
null
null
UTF-8
C++
false
false
6,407
cpp
llweb.cpp
/** * @file llweb.cpp * @brief Functions dealing with web browsers * @author James Cook * * $LicenseInfo:firstyear=2006&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #include "llviewerprecompiledheaders.h" #include "llweb.h" // Library includes #include "llwindow.h" // spawnWebBrowser() #include "llagent.h" #include "llappviewer.h" #include "llfloaterwebcontent.h" #include "llfloaterreg.h" #include "lllogininstance.h" #include "llparcel.h" #include "llsd.h" #include "lltoastalertpanel.h" #include "llui.h" #include "lluri.h" #include "llversioninfo.h" #include "llviewercontrol.h" #include "llviewernetwork.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" #include "llviewerwindow.h" #include "llnotificationsutil.h" bool on_load_url_external_response(const LLSD& notification, const LLSD& response, bool async ); class URLLoader : public LLToastAlertPanel::URLLoader { virtual void load(const std::string& url , bool force_open_externally) { if (force_open_externally) { LLWeb::loadURLExternal(url); } else { LLWeb::loadURL(url); } } }; static URLLoader sAlertURLLoader; // static void LLWeb::initClass() { LLToastAlertPanel::setURLLoader(&sAlertURLLoader); } // static void LLWeb::loadURL(const std::string& url, const std::string& target, const std::string& uuid) { if(target == "_internal") { // Force load in the internal browser, as if with a blank target. loadURLInternal(url, "", uuid); } else if (gSavedSettings.getBOOL("UseExternalBrowser") || (target == "_external")) { loadURLExternal(url); } else { loadURLInternal(url, target, uuid); } } // static // Explicitly open a Web URL using the Web content floater void LLWeb::loadURLInternal(const std::string &url, const std::string& target, const std::string& uuid) { LLFloaterWebContent::Params p; p.url(url).target(target).id(uuid); LLFloaterReg::showInstance("web_content", p); } // static void LLWeb::loadURLExternal(const std::string& url, const std::string& uuid) { loadURLExternal(url, true, uuid); } // static void LLWeb::loadURLExternal(const std::string& url, bool async, const std::string& uuid) { // Act like the proxy window was closed, since we won't be able to track targeted windows in the external browser. LLViewerMedia::proxyWindowClosed(uuid); if(gSavedSettings.getBOOL("DisableExternalBrowser")) { // Don't open an external browser under any circumstances. llwarns << "Blocked attempt to open external browser." << llendl; return; } LLSD payload; payload["url"] = url; LLNotificationsUtil::add( "WebLaunchExternalTarget", LLSD(), payload, boost::bind(on_load_url_external_response, _1, _2, async)); } // static bool on_load_url_external_response(const LLSD& notification, const LLSD& response, bool async ) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if ( 0 == option ) { LLSD payload = notification["payload"]; std::string url = payload["url"].asString(); std::string escaped_url = LLWeb::escapeURL(url); if (gViewerWindow) { gViewerWindow->getWindow()->spawnWebBrowser(escaped_url, async); } } return false; } // static std::string LLWeb::escapeURL(const std::string& url) { // The CURL curl_escape() function escapes colons, slashes, // and all characters but A-Z and 0-9. Do a cheesy mini-escape. std::string escaped_url; S32 len = url.length(); for (S32 i = 0; i < len; i++) { char c = url[i]; if (c == ' ') { escaped_url += "%20"; } else if (c == '\\') { escaped_url += "%5C"; } else { escaped_url += c; } } return escaped_url; } //static std::string LLWeb::expandURLSubstitutions(const std::string &url, const LLSD &default_subs) { LLSD substitution = default_subs; substitution["VERSION"] = LLVersionInfo::getVersion(); substitution["VERSION_MAJOR"] = LLVersionInfo::getMajor(); substitution["VERSION_MINOR"] = LLVersionInfo::getMinor(); substitution["VERSION_PATCH"] = LLVersionInfo::getPatch(); substitution["VERSION_BUILD"] = LLVersionInfo::getBuild(); substitution["CHANNEL"] = LLVersionInfo::getChannel(); substitution["GRID"] = LLGridManager::getInstance()->getGridId(); substitution["GRID_LOWERCASE"] = utf8str_tolower(LLGridManager::getInstance()->getGridId()); substitution["OS"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple(); substitution["SESSION_ID"] = gAgent.getSessionID(); substitution["FIRST_LOGIN"] = gAgent.isFirstLogin(); // work out the current language std::string lang = LLUI::getLanguage(); if (lang == "en-us") { // *HACK: the correct fix is to change English.lproj/language.txt, // but we're late in the release cycle and this is a less risky fix lang = "en"; } substitution["LANGUAGE"] = lang; // find the region ID LLUUID region_id; LLViewerRegion *region = gAgent.getRegion(); if (region) { region_id = region->getRegionID(); } substitution["REGION_ID"] = region_id; // find the parcel local ID S32 parcel_id = 0; LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); if (parcel) { parcel_id = parcel->getLocalID(); } substitution["PARCEL_ID"] = llformat("%d", parcel_id); #ifdef OPENSIM // <FS:AW optional opensim support> substitution["SLURL_TYPE"] = "hop"; // <FS:AW provide SLURL_TYPE url substitution> #endif // </FS:AW optional opensim support> // expand all of the substitution strings and escape the url std::string expanded_url = url; LLStringUtil::format(expanded_url, substitution); return LLWeb::escapeURL(expanded_url); }
9637dcfc69a74f1faaeb28cbc5e5d6d04c887b26
a02399c5c66d43d56599ca0b303da4ffddbcd94a
/CppTry3_Algorithm/MaxSumSubsequence.h
1abfb62ab4e6df9c578ad4f110f0b96c39d2031f
[]
no_license
jayjihunlegacy/CppTry
2dbe7c422b5a98770778202dbf18870f5537fe19
dfd617e90c09dd44ce7bd57e567cc2d34305b7c0
refs/heads/master
2020-03-27T23:07:58.089581
2015-12-27T09:10:39
2015-12-27T09:10:39
147,293,633
0
0
null
null
null
null
UTF-8
C++
false
false
2,396
h
MaxSumSubsequence.h
#pragma once #include <ctime> int maxSum_BruteForce(int* arr, int length) { int maxsum = 0; for (int i = 0; i < length; i++) { for (int j = i; j < length; j++) { int thissum = 0; for (int k = i; k <= j; k++) thissum += arr[k]; if (thissum > maxsum) maxsum = thissum; } } return maxsum; } int maxSum_Better(int* arr, int length) { int maxsum = 0; for (int i = 0; i < length; i++) { int thissum = 0; for (int j = i; j < length; j++) { thissum += arr[j]; if (thissum > maxsum) maxsum = thissum; } } return maxsum; } int maxSum_DivideConquer(int* arr, int s, int e) { //printf("Divide Conquer called. Left : %d, right : %d\n", s, e); if (e == s + 1) return arr[s] > 0 ? arr[s] : 0; if(s==e+2) { int p1 = maxSum_DivideConquer(arr, s, s+1); int p2 = maxSum_DivideConquer(arr, s+1, s+2); return p1 > p2 ? p1 : p2; } int middle = (e + s) / 2;//first : [s, middle), second : [middle,e) int p1, p2, p3; p1 = maxSum_DivideConquer(arr, s, middle); p2 = maxSum_DivideConquer(arr, middle, e); p3 = 0; int leftmax = 0; int rightmax = 0; //probe left half int leftsum = 0; for (int i = middle - 1; i >= s; i--) { leftsum += arr[i]; if (leftsum > leftmax) leftmax = leftsum; } //probe right half int rightsum = 0; for (int i = middle; i < e; i++) { rightsum += arr[i]; if (rightsum > rightmax) rightmax = rightsum; } p3 = leftmax + rightmax; int t = (p1 > p2 ? p1 : p2); return t > p3 ? t : p3; } int maxSum_Linear(int * arr, int length) { int maxsum, thissum; maxsum = thissum = 0; for (int i = 0; i < length; i++) { thissum += arr[i]; if (thissum > maxsum) maxsum = thissum; if (thissum < 0) thissum = 0; } return maxsum; } void maxSum_Test(int T) { srand(time(NULL)); int * arr = new int[T]; for (int i = 0; i < T; i++) { int val = rand() % 1000; val = val % 3 == 0 ? -val : val; arr[i] = val; //printf("%d ", arr[i] = val); } printf("\n"); //printf("Calc using bruteFroce : "); //std::cout.flush(); //printf("%d\n", maxSum_BruteForce(arr, T)); printf("Calc using better : "); std::cout.flush(); //printf("%d\n", maxSum_Better(arr, T)); printf("Calc using even better : "); std::cout.flush(); printf("%d\n", maxSum_DivideConquer(arr, 0,T)); printf("Calc using the best : "); std::cout.flush(); printf("%d\n", maxSum_Linear(arr, T)); delete[]arr; }
340c13a29ad7c2f0dabbbd53742456a34bc7ffc2
c99925e94c583f0d5f4d433cdb374e3f29b98d50
/MyGAME/GameTemplate/Game/Guzai.h
7274d9911d098ec84d4f82aecb12b1260df1de3d
[]
no_license
kw11SL/BurgerPicker
eda2804bfd3c257af3494ef3dc05c2c4d0c60192
992b20202f618143c148ea29b5e30350c0ad01bb
refs/heads/master
2023-03-16T12:32:17.195348
2021-03-10T00:48:59
2021-03-10T00:48:59
346,202,830
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
760
h
Guzai.h
#pragma once #include <vector> class Guzai : public IGameObject { private: Model model; ModelInitData modeldata; Skeleton m_skeleton; CharacterController m_charaCon; public: bool Start(); void Update(); Vector3 GetPosition(); void SetPosition(Vector3 pos); void Render(RenderContext& rc) { model.Draw(rc); } //Update()でインクリメントする。 int time = 0; //1ならば持たれている。 int state = 0; //1ならばもうキッチンに置かれている。 int put = 0; //何段積んでるか int stack = 0; //Xボタン長押しで積み上げている具材を全部削除する。そのためのタイマー。 int DeleteTimer = 0; //具材の種類番号 //ToDo...変更可能にする。 int TypeNo = 1; };
72b47fc65c56d1e6b9995df768574a03dc915333
d9cfe7700cf37bf04dbc15836adf1c59fdb2e0d1
/uri1248.cpp
6de71d9d7afb64410f2904b145c311aef7f337fa
[]
no_license
helfo2/URI-Online-Judge-CP-Training
b270fb250276651aaac80b78f1e4e12a692d4546
f79faf3b6a5a692314b4ba054704c5fc3aa7613a
refs/heads/master
2021-05-11T19:42:54.736358
2018-01-17T20:09:55
2018-01-17T20:09:55
117,887,011
0
0
null
null
null
null
UTF-8
C++
false
false
1,184
cpp
uri1248.cpp
#include <iostream> #include <string> #include <set> #include <vector> #include <algorithm> using namespace std; int main(void) { int n; cin >> n; cin.ignore(); while(n--) { string dieta, cafe, almoco, jantar; getline(cin, dieta); getline(cin, cafe); getline(cin, almoco); // cout << "dieta = "<< dieta << endl; // cout << "cafe = "<< cafe << endl; // cout << "almoco = "<< almoco << endl; bool cheater = false; set<char> comido; vector<bool> visto(dieta.size()); for(int i = 0; i < cafe.size(); i++) { if(dieta.find(cafe[i]) == -1 || comido.count(cafe[i])) cheater = true; else visto[dieta.find(cafe[i])] = true; comido.insert(cafe[i]); } for(int i = 0; i < almoco.size(); i++) { if(dieta.find(almoco[i]) == -1 || comido.count(almoco[i])) cheater = true; else visto[dieta.find(almoco[i])] = true; comido.insert(almoco[i]); } if(cheater) cout << "CHEATER\n"; else { vector<char> jantar; for(int i = 0; i < dieta.size(); i++) if(!visto[i]) jantar.push_back(dieta[i]); sort(jantar.begin(), jantar.end()); for(auto i : jantar) cout << i; cout << endl; } } return 0; }
311106784927ea831e48dee426669b8ef7fd666f
d8c6bb667289c272191210788f91fe534dae84e9
/customqtui.cpp
48ad33634ff6532fcc266db50b3a762b45ee5e3f
[]
no_license
whitebeard234/sume-borrower-app
139fd0be5f490031a8369f5f1ea5832c578aac63
052092318fc7ead2363ace557baea1ef675f2ecb
refs/heads/master
2023-09-05T00:28:53.199439
2018-09-11T10:35:29
2018-09-11T10:35:29
144,999,425
1
0
null
2018-08-16T14:29:47
2018-08-16T14:29:46
null
UTF-8
C++
false
false
2,601
cpp
customqtui.cpp
#include "customqtui.h" CustomQtUI::CustomQtUI() { } /** * Helper function. Removes all layout items within the given @a layout * which either span the given @a row or @a column. If @a deleteWidgets * is true, all concerned child widgets become not only removed from the * layout, but also deleted. */ void CustomQtUI::remove(QGridLayout *layout, int row, int column, bool deleteWidgets) { // We avoid usage of QGridLayout::itemAtPosition() here to improve performance. for (int i = layout->count() - 1; i >= 0; i--) { int r, c, rs, cs; layout->getItemPosition(i, &r, &c, &rs, &cs); if ((r <= row && r + rs - 1 >= row) || (c <= column && c + cs - 1 >= column)) { // This layout item is subject to deletion. QLayoutItem *item = layout->takeAt(i); if (deleteWidgets) { deleteChildWidgets(item); } delete item; } } } /** * Helper function. Deletes all child widgets of the given layout @a item. */ void CustomQtUI::deleteChildWidgets(QLayoutItem *item) { if (item->layout()) { // Process all child items recursively. for (int i = 0; i < item->layout()->count(); i++) { deleteChildWidgets(item->layout()->itemAt(i)); } } delete item->widget(); } /** * Removes all layout items on the given @a row from the given grid * @a layout. If @a deleteWidgets is true, all concerned child widgets * become not only removed from the layout, but also deleted. Note that * this function doesn't actually remove the row itself from the grid * layout, as this isn't possible (i.e. the rowCount() and row indices * will stay the same after this function has been called). */ void CustomQtUI::removeRow(QGridLayout *&layout, int row, bool deleteWidgets){ remove(layout, row, -1, deleteWidgets); layout->setRowMinimumHeight(row, 0); layout->setRowStretch(row, 0); } /** * Removes all layout items on the given @a column from the given grid * @a layout. If @a deleteWidgets is true, all concerned child widgets * become not only removed from the layout, but also deleted. Note that * this function doesn't actually remove the column itself from the grid * layout, as this isn't possible (i.e. the columnCount() and column * indices will stay the same after this function has been called). */ void CustomQtUI::removeColumn(QGridLayout *&layout, int column, bool deleteWidgets) { remove(layout, -1, column, deleteWidgets); layout->setColumnMinimumWidth(column, 0); layout->setColumnStretch(column, 0); }
e8d5ae4bc28bb3111a74c041c36fccbf6fb4ad8d
9b727ccbf91d12bbe10adb050784c04b4753758c
/archived/2014-JAG-Spring/E.cc
08054e98fdd7bb03f3f6fa6e999bb46f6ebac00e
[]
no_license
codeAligned/acm-icpc-1
b57ab179228f2acebaef01082fe6b67b0cae6403
090acaeb3705b6cf48790b977514965b22f6d43f
refs/heads/master
2020-09-19T19:39:30.929711
2015-10-06T15:13:12
2015-10-06T15:13:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,077
cc
E.cc
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; const int MAXN = 100 + 10; PII a[MAXN]; char s[MAXN]; #define x first #define y second int type(const PII &a) { if (a.x > a.y) return -1; else return (a.x < a.y); } bool cmp(const PII &a, const PII &b) { if (type(a) != type(b)) return type(a) < type(b); if (type(a) == -1) return a.y < b.y; else if (type(a) == 1) return a.x > b.x; return false; } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++ i) { scanf("%s", s); vector<char> v; int x(0), y(0); for (char *p = s; *p; ++ p) { if (*p == '(') v.push_back('('), ++ x; else { if (v.size() && v.back() == '(') { v.pop_back(); -- x; } else v.push_back(')'), ++ y; } } a[i] = PII(x, y); } sort(a, a + n, cmp); int left = 0, flag = true; for (int i = 0; i < n; ++ i) { if (a[i].y > left) {flag = false; break;} left += a[i].x - a[i].y; } if (left == 0 && flag) puts("Yes"); else puts("No"); return 0; }
58322085fc7f4c92193234b22be6f9c974a430a9
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/xgboost/xgboost-gumtree/dmlc_xgboost_old_hunk_649.cpp
3b77a0ce59a3f93e2c74dc26651faf30281f39ad
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
159
cpp
dmlc_xgboost_old_hunk_649.cpp
utils::Error("unknown objective function type"); return NULL; } >>>>>>> 9eabb5c7f912a326005aca53a76c2e53a1661842 }; }; #endif
a79e6466c98f4c7b10e6dd8e4b148c127fd075cb
f703bebbc497e6c91b8da9c19d26cbcc98a897fb
/camps/winter_school_Kremenchuk_2016/DAY_4_SQRT_DECOMPOSITION/C.cpp
4ec595da1a50f40210e5599bd9d9fe643c825773
[ "MIT" ]
permissive
mstrechen/competitive-programming
1dc48163fc2960c54099077b7bfc0ed84912d2c2
ffac439840a71f70580a0ef197e47479e167a0eb
refs/heads/master
2021-09-22T21:09:24.340863
2018-09-16T13:48:51
2018-09-16T13:48:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,304
cpp
C.cpp
#include<iostream> #include<vector> using namespace std; const int sizeOfBlock = 1000; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<vector<int> > blocks((n-1)/sizeOfBlock + 1, vector<int>((n-1)/sizeOfBlock + 1)); vector<int> bombsH(n),bombsV(n); for(int i = 0; i<n; i++) { int x, y; cin >> x >> y; bombsH[x]=y; bombsV[y]=x; blocks[x/sizeOfBlock][y/sizeOfBlock]++; } for(int i = 0; i<(int)blocks.size(); i++) for(int j = 0; j<(int)blocks[0].size(); j++) { if(j>0) blocks[i][j]+=blocks[i][j-1]; if(i>0) blocks[i][j]+=blocks[i-1][j]; if(i>0&&j>0) blocks[i][j]-=blocks[i-1][j-1]; } int q; cin >> q; while(q--) { int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; int ans = y2-y1+1; int x_1,x_2,y_1,y_2; for(x_1 = x1-1; (x_1+1)%sizeOfBlock; x_1--) { ans-=y1<=bombsH[x_1] && bombsH[x_1]<=y2; } for(x_2 = x2+1; x_2%sizeOfBlock && x_2<n; x_2++) { ans-=y1<=bombsH[x_2] && bombsH[x_2]<=y2; } for(y_1 = y1; y_1%sizeOfBlock && y_1<=y2; y_1++) { ans-= bombsV[y_1] < x_1 || x_2 < bombsV[y_1]; } for(y_2 = y2-1; (y_2+1)%sizeOfBlock && y_2 >= y_1; y_2--) { ans-= bombsV[y_2] < x_1 || x_2 < bombsV[y_2]; } y_1/=sizeOfBlock; y_2 = (y_2 + 1)/sizeOfBlock - 1; if(y_1<=y_2) { if(x_1>=0) { ans-=blocks[x_1/sizeOfBlock][y_2]; if(y_1>0) ans+=blocks[x_1/sizeOfBlock][y_1-1]; } if(x_2<n) { ans-=blocks[blocks.size()-1][y_2]; ans+=blocks[x_2/sizeOfBlock - 1][y_2]; if(y_1>0) { ans+=blocks[blocks.size()-1][y_1-1]; ans-=blocks[x_2/sizeOfBlock - 1][y_1-1]; } } } cout << ans << endl; } return 0; }
c3891bd3c4401cd8fe09604855e7a2bd924ca95a
e969da11a508f2bf1c93e76b46d742c2f02a21b3
/ActionGame/ActionGame/Effect.h
0ab8a896c861773d7ad70f03c8b9b00ab6d41b96
[]
no_license
sansanshi/repo_test
0c116c52a271ff66ee53de1a68c8d62515d01db6
5b85726237a7339b114a6837ebcc1d2a38d19275
refs/heads/master
2021-01-17T17:21:03.469488
2016-08-05T08:30:10
2016-08-05T08:30:10
62,817,116
0
0
null
null
null
null
UTF-8
C++
false
false
492
h
Effect.h
#pragma once #include"Geometry.h" class Camera; class Effect { private: int _handle; Vector2 _pos; int _timer; Camera& _cameraRef; bool _isAvailable; public: Effect(Vector2 pos,int handle,Camera& camera); ~Effect(); void Update(); void Draw(); void DrawCameraGraph(int x, int y, int srcX, int srcY, int width, int height, int cx, int cy, double extRate, double angle, int handle, int transFlag, int turnFlag); bool IsAvailable(){ return _isAvailable; } };
87b4b483ca38427bcd3b0bb5aa974e1ffe9a678a
959d9efe680b50f04f0e303677ff6067d66bc36a
/src/coin.cpp
6c8eaf9e38290565ad41017582dc0316c49a978f
[]
no_license
ShellCode33/Runner
2716ef47de5ffab24cfdf3c9dfdaff9a9939b555
88405d2c153fa12f737c7be0940938c3034b9bca
refs/heads/master
2021-03-16T06:16:58.537955
2017-12-31T19:54:37
2017-12-31T19:54:37
51,835,577
1
0
null
null
null
null
UTF-8
C++
false
false
345
cpp
coin.cpp
#include "coin.h" Coin::Coin(int relat_x, int relat_y, int width, int height) : model(relat_x, relat_y, width, height), view(model) {} Coin::~Coin() { } CoinModel *Coin::getModel() { return &this->model; } CoinView *Coin::getView() { return &this->view; } void Coin::update() { this->model.update(); this->view.update(); }
324c999cf4b451cb470ac8263923f3c049404ba2
3b9738955cfdbae250492be7649b8b724637ffff
/C&C++/一下/0617/2.cpp
ac95134495c5abebf93f25a1df69a652d396bd3e
[]
no_license
NickLuGithub/school_homework
c38a9ef58a1d346e8469489ad025a58c8bf1b701
3570a2b30c53ac151b62f380855e86fe11ffd29a
refs/heads/main
2023-04-07T11:40:10.943690
2021-04-16T08:57:09
2021-04-16T08:57:09
358,534,527
1
0
null
null
null
null
UTF-8
C++
false
false
2,133
cpp
2.cpp
#include<iostream> #include<sstream> #include<cmath> using namespace std; typedef struct{ double x, y; } Point; class Line { private: double a, b, c; public: Line(double _a = 0, double _b = 0, double _c = 0) { setLine(_a, _b, _c); } void setLine(double _a = 0, double _b = 0, double _c = 0) { a = _a; b = _b; c = _c; } double getA() { return a; } double getB() { return b; } double getC() { return c; } string str(){ ostringstream out; out << a << "x + " << b << "y = " << c; return out.str(); } }; void line_two(Line l1, Line l2){ if( l1.getA() / l2.getA() == l1.getB() / l2.getB() && l1.getB() / l2.getB() == l1.getC() / l2.getC()){ cout << "The intersection of " << l1.str() << " and " << l2.str() << " is (inf, inf)" << endl; }else if(l1.getA() / l2.getA() != l1.getB() / l2.getB() && l1.getB() / l2.getB() != l1.getC() / l2.getC() && l2.getB()){ cout << "The intersection of " << l1.str() << " and " << l2.str() << " is (-inf, -inf)" << endl; }else{ cout << "The intersection of " << l1.str() << " and " << l2.str() << " is (" << ((l1.getC() * l2.getB())- (l1.getB() * l2.getC())) / ((l1.getA() * l2.getB()) - (l1.getB() * l2.getA())) << ", " << ((l1.getA() * l2.getC()) - (l1.getC() * l2.getA())) / ((l1.getA() * l2.getB()) - (l1.getB() * l2.getA())) << ")" << endl; } } string operator * (Line a, Point k){ ostringstream out; if (a.getA() * a.getB() > 0) out << "The line perpendicular to " << a.getA() << "x + " << a.getB() << "y = " << a.getC() << " and passing(" << k.x << ", " << k.y << ") is " << a.getB() << "x - " << a.getA() << "y = " << (a.getB() * k.x - a.getA() * k.y) << endl; else out << "The no line perpendicular to " << a.getA() << "x + " << a.getB() << "y = " << a.getC() << " and passing is (" << k.x << ", " << k.y << ")"<< endl; return out.str(); } int main ( void ){ double a, b, c, d, e, f, x, y; Point p; cout << "Enter ax + by = c, dx + ey = f, and Point(x, y):"; cin >> a >> b >> c >> d >> e >> f >> p.x >> p.y; Line l1(a, b, c), l2(d, e, f); cout << l1 * p << l2 * p; line_two(l1, l2); }
728caebb79f253cd37429e5ba691059dcb471954
3f708fd1ccc43671b913354682aeb00d05626ec3
/Source/MpBase/Private/GeoEllipsoid.cpp
8e5b050f8b36529e95db05727e3da4b0575bfe6f
[]
no_license
yangjs6/MagicPolaris
2d175b55bd87d943abd23c8866ed6fff693c098d
fd21289ed215f0c6859844b0d7109f9ab789e26c
refs/heads/master
2023-06-04T05:27:07.179044
2021-06-17T05:43:22
2021-06-17T05:43:22
365,452,653
3
0
null
null
null
null
UTF-8
C++
false
false
4,345
cpp
GeoEllipsoid.cpp
#include "GeoEllipsoid.h" const FGeoEllipsoid FGeoEllipsoid::WGS84(6378137.0, 6378137.0, 6356752.3142451793); FGeoCartesian FGeoEllipsoid::GetSurfaceNormal(const FGeoCartesian& position) const noexcept { return (position * this->_oneOverRadiiSquared).Normalized(); } FVector3d FGeoEllipsoid::GetSurfaceNormal( const FGeoPosition& cartographic) const noexcept { double longitude = cartographic.Longitude; double latitude = cartographic.Latitude; double cosLatitude = FMathd::Cos(latitude); return FVector3d( cosLatitude * FMathd::Cos(longitude), cosLatitude * FMathd::Sin(longitude), FMathd::Sin(latitude)).Normalized(); } FVector3d FGeoEllipsoid::PositionToCartesian( const FGeoPosition& cartographic) const noexcept { FVector3d n = this->GetSurfaceNormal(cartographic); FVector3d k = this->_radiiSquared * n; double gamma = sqrt(n.Dot(k)); k /= gamma; n *= cartographic.Height; return k + n; } FGeoPosition FGeoEllipsoid::CartesianToPosition(const FGeoCartesian& cartesian) const noexcept { FGeoCartesian p = this->ScaleToGeodeticSurface(cartesian); FVector3d n = this->GetSurfaceNormal(p); FVector3d h = cartesian - p; double longitude = FMathd::Atan2(n.Y, n.X); double latitude = asin(n.Z); double height = FMathd::Sign(h.Dot(cartesian)) * h.Length(); return FGeoPosition(longitude, latitude, height); } FVector3d FGeoEllipsoid::ScaleToGeodeticSurface(const FVector3d& cartesian) const noexcept { double positionX = cartesian.X; double positionY = cartesian.Y; double positionZ = cartesian.Z; double oneOverRadiiX = this->_oneOverRadii.X; double oneOverRadiiY = this->_oneOverRadii.Y; double oneOverRadiiZ = this->_oneOverRadii.Z; double x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX; double y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY; double z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ; // Compute the squared FGeoEllipsoid norm. double squaredNorm = x2 + y2 + z2; double ratio = sqrt(1.0 / squaredNorm); // As an initial approximation, assume that the radial intersection is the // projection point. FVector3d intersection = cartesian * ratio; // If the position is near the center, the iteration will not converge. //if (squaredNorm < this->_centerToleranceSquared) { // return !std::isfinite(ratio) ? std::optional<FVector3d>() : intersection; //} double oneOverRadiiSquaredX = this->_oneOverRadiiSquared.X; double oneOverRadiiSquaredY = this->_oneOverRadiiSquared.Y; double oneOverRadiiSquaredZ = this->_oneOverRadiiSquared.Z; // Use the gradient at the intersection point in place of the true unit // normal. The difference in magnitude will be absorbed in the multiplier. FVector3d gradient( intersection.X * oneOverRadiiSquaredX * 2.0, intersection.Y * oneOverRadiiSquaredY * 2.0, intersection.Z * oneOverRadiiSquaredZ * 2.0); // Compute the initial guess at the normal vector multiplier, lambda. double lambda = ((1.0 - ratio) * cartesian.Length()) / (0.5 * gradient.Length()); double correction = 0.0; double func; double denominator; double xMultiplier; double yMultiplier; double zMultiplier; double xMultiplier2; double yMultiplier2; double zMultiplier2; double xMultiplier3; double yMultiplier3; double zMultiplier3; do { lambda -= correction; xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX); yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY); zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ); xMultiplier2 = xMultiplier * xMultiplier; yMultiplier2 = yMultiplier * yMultiplier; zMultiplier2 = zMultiplier * zMultiplier; xMultiplier3 = xMultiplier2 * xMultiplier; yMultiplier3 = yMultiplier2 * yMultiplier; zMultiplier3 = zMultiplier2 * zMultiplier; func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0; // "denominator" here refers to the use of this expression in the velocity // and acceleration computations in the sections to follow. denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ; double derivative = -2.0 * denominator; correction = func / derivative; } while (abs(func) > 0.000000000001); return FVector3d( positionX * xMultiplier, positionY * yMultiplier, positionZ * zMultiplier); }
9257901cd92edc0e73c0b45e6e20a38c4af71327
0766dfbd1aa5ac39badb9b2c05a5492c76652864
/occ_projects/Robotics Arduino Proj/Arduino_4_Button_YRLight_5s_each/Arduino_4_Button_YRLight_5s_each.ino
044f2d883ee60f78b5daec77f27daeac1362c3db
[]
no_license
AyeshaAhmed/iit_projects
35ba333d4d6dbefaf1e4010e290959187ddd6175
9b27ffbd1bf65378b78e4fe82b9ffcc3abb3c80c
refs/heads/master
2021-09-03T14:48:35.476924
2018-01-09T22:03:46
2018-01-09T22:03:46
103,581,421
0
0
null
null
null
null
UTF-8
C++
false
false
455
ino
Arduino_4_Button_YRLight_5s_each.ino
const int buttonPin = 3; const int ledPinY = 2; const int ledPinR = 4; int buttonState = 0; void setup() { pinMode(ledPinR, OUTPUT); pinMode(ledPinY, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { buttonState = digitalRead(buttonPin); if(buttonState == LOW){ digitalWrite(ledPinY, HIGH); delay(5000); digitalWrite(ledPinR, HIGH); delay(5000); } digitalWrite(ledPinY, LOW); digitalWrite(ledPinR, LOW); }
de7b63a0ab22601aba9561dcfb4ce10850fea18e
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive/2b6092ad8d1ff23c229c54b8f6b0d2e0/main.cpp
1a2c6b6dcd46ac0bd8478e7d3771a67198a68803
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
243
cpp
main.cpp
#include <iostream> struct A { int a = 10; int b = 20; friend std::ostream& operator<<(std::ostream& out, const A& a) { out << a.a << '\n' << a.b; return out; } }; int main() { A aa; std::cout << aa; }
d25325405877393831412e5126cbb106bacd05a3
9c670b45996436e16310276f4b2a9bfd0cb4f8f5
/eric/finish_bounds.cpp
edb814e1ad0508efdfbadd9a8fbb2e80e8c6adb9
[]
no_license
errorcodexero/fiddle
30d6b1a4733704bdde81bca5d1227cc61f17e459
cebaf9afde8ac2789dea91e450227be1b92b749a
refs/heads/master
2020-04-04T02:30:40.606178
2018-08-09T01:11:09
2018-08-09T01:11:09
37,697,361
4
2
null
null
null
null
UTF-8
C++
false
false
13,709
cpp
finish_bounds.cpp
#include<iostream> #include<set> #include<vector> #include<map> #include<typeinfo> #include<cassert> #include<algorithm> #include<unordered_map> using namespace std; #define nyi { cout<<"nyi "<<__LINE__<<"\n"; exit(44); } #define PRINT(X) { cout<<""#X<<":"<<X<<"\n"; } template<typename T> set<T> operator|(set<T> a,set<T> b){ for(auto x:b) a.insert(x); return a; } template<typename K,typename V> ostream& operator<<(ostream& o,map<K,V> const& a){ o<<"{ "; for(auto x:a) o<<x<<" "; return o<<"}"; } template<typename K,typename V> ostream& operator<<(ostream& o,unordered_map<K,V> const& a){ o<<"{ "; for(auto x:a) o<<x<<" "; return o<<"}"; } template<typename T> ostream& operator<<(ostream& o,set<T> const& a){ o<<"{ "; for(auto x:a) o<<x<<" "; return o<<"}"; } template<typename A,typename B> ostream& operator<<(ostream& o,pair<A,B> const& p){ return o<<"("<<p.first<<","<<p.second<<")"; } template<typename T> ostream& operator<<(ostream& o,vector<T> const& a){ o<<"[ "; for(auto x:a) o<<x<<" "; return o<<"]"; } template<typename T,size_t LEN> ostream& operator<<(ostream& o,array<T,LEN> const& a){ o<<"[ "; for(auto elem:a) o<<elem<<" "; return o<<"]"; } template<typename T> vector<T> operator|(vector<T> a,vector<T> b){ nyi } template<typename T> vector<T> operator|(vector<T>,T){ nyi } template<typename T> vector<T>& operator|=(vector<T>& a,T t){ a.push_back(t); return a; } vector<size_t> range(size_t lim){ vector<size_t> r; for(size_t i=0;i<lim;i++) r|=i; return r; } template<size_t LEN> array<size_t,LEN> range_st(){ array<size_t,LEN> r; for(size_t i=0;i<LEN;i++) r[i]=i; return r; } template<typename Func,typename T> auto mapf(Func f,vector<T> const& v)->vector<decltype(f(v[0]))>{ vector<decltype(f(v[0]))> r; r.reserve(v.size()); for(auto const& a:v) r|=f(a); return r; } #define MAP(FUNC,ARRAY) mapf([&](auto a){ return FUNC(a); },ARRAY) template<typename T> vector<T> tail(vector<T> const& v){ vector<T> r; for(size_t i=1;i<v.size();i++) r|=v[i]; return r; } template<typename T> vector<T>& operator|=(vector<T>& a,vector<T> const& t){ for(auto x:t) a.push_back(x); return a; } template<typename K,typename V> vector<K> keys(map<K,V> const& a){ vector<K> r; for(auto p:a) r|=p.first; return r; } template<typename K,typename V> vector<K> keys(unordered_map<K,V> const& a){ vector<K> r; for(auto p:a) r|=p.first; return r; } template<typename T> vector<T> flatten(vector<vector<T>> const& a){ vector<T> r; for(auto elem:a) r|=elem; return r; } template<typename T> set<T> flatten(vector<set<T>> a){ set<T> r; for(auto elem:a) r|=elem; return r; } template<typename T> set<T>& operator|=(set<T>& a,T b){ a.insert(b); return a; } template<typename T> set<T> to_set(vector<T> a){ set<T> r; for(auto x:a) r|=x; return r; } template<typename T> vector<T> sorted(vector<T> a){ sort(begin(a),end(a)); return a; } template<typename T> T min(vector<T> const& a){ assert(a.size()); T r=a[0]; for(auto x:a) r=min(r,x); return r; } template<typename T> T max(vector<T> const& a){ /*assert(a.size()); return sorted(a)[a.size()-1];*/ T r=a[0]; for(auto elem:a) r=max(r,elem); return r; } template<typename T> T median(vector<T> v){ assert(v.size()); //return sorted(v)[v.size()/2]; auto n=v.size()/2; nth_element(v.begin(),v.begin()+n,v.end()); return v[n]; } template<typename A,typename B> pair<B,A> reverse(pair<A,B> p){ nyi } template<typename T> vector<pair<size_t,T>> enumerate_from(size_t start,vector<T> v){ vector<pair<size_t,T>> r; for(size_t i=0;i<v.size();i++){ r|=make_pair(start+i,v[i]); } return r; } template<typename T> vector<T> to_vec(set<T> a){ vector<T> r; for(auto elem:a) r|=elem; return r; } template<typename T> vector<T> to_vec(initializer_list<T> const& a){ vector<T> r; for(auto x:a) r|=x; return r; } template<typename Collection> auto enumerate_from(size_t start,Collection c){ return enumerate_from(start,to_vec(c)); } template<typename T> auto enumerate(T t){ return enumerate_from(0,t); } template<typename T> set<T>& operator|=(set<T> &a,set<T> b){ for(auto elem:b) a|=elem; return a; } template<typename Func,typename T,size_t LEN> auto mapf(Func f,array<T,LEN> a){ array<decltype(f(a[0])),LEN> r; for(auto i:range_st<LEN>()){ r[i]=f(a[i]); } return r; } template<typename Func,typename Collection> auto mapv(Func f,Collection c){ for(auto a:c) f(a); } template<typename T,size_t LEN1,size_t LEN2> array<T,LEN1+LEN2> operator|(array<T,LEN1> a,array<T,LEN2> b){ array<T,LEN1+LEN2> r; size_t i=0; auto add=[&](auto x){ r[i++]=x; }; mapv(add,a); mapv(add,b); return r; } template<typename T,size_t LEN> vector<T>& operator|=(vector<T> &a,array<T,LEN> b){ for(auto elem:b) a|=elem; return a; } template<typename T,size_t LEN> vector<T> flatten(vector<array<T,LEN>> a){ vector<T> r; for(auto x:a) r|=x; return r; } template<typename T,size_t LEN> set<T> to_set(array<T,LEN> a){ nyi } //program-specific stuff is below here. using Team=int; Team rand(Team*){ return rand()%64; } //using Alliance=set<Team>; struct Alliance{ //set<Team> data; array<Team,3> data; //todo:make these explicit explicit Alliance(set<Team> s){ //:data(s){} assert(s.size()==3); for(auto p:enumerate(s)) data[p.first]=p.second; } //Alliance(initializer_list<Team> a):data(a){} explicit Alliance(initializer_list<Team> a){ assert(a.size()==3); for(auto p:enumerate(a)) data[p.first]=p.second; } explicit Alliance(array<Team,3> a):data(a){} auto begin()const{ return data.begin(); } auto end()const{ return data.end(); } }; template<typename Func> auto mapf(Func f,Alliance a){ return mapf(f,a.data); } auto operator|(Alliance a,Alliance b){ return a.data|b.data; } Alliance rand(Alliance*){ Team *t; return Alliance{rand(t),rand(t),rand(t)}; } Alliance to_alliance(vector<Team> v){ return Alliance{to_set(v)}; } Alliance to_alliance(array<Team,3> a){ return Alliance{a}; } using Match=pair<Alliance,Alliance>; Match rand(Match*){ return make_pair(rand((Alliance*)0),rand((Alliance*)0)); } using Schedule=vector<Match>; Schedule rand(Schedule*){ return mapf([](int){ return rand((Match*)0); },range(12)); } using Ranking_points=int; //using Current_standings=map<Team,Ranking_points>; struct Current_standings{ //map<Team,Ranking_points> r; unordered_map<Team,Ranking_points> r; auto& operator[](auto a){ return r[a]; } auto find(auto a){ return r.find(a); } auto find(auto a)const{ return r.find(a); } auto begin(){ return r.begin(); } auto begin()const{ return r.begin(); } auto end(){ return r.end(); } auto end()const{ return r.end(); } auto size()const{ return r.size(); } auto inc(Team team,Ranking_points amount){ auto f=r.find(team); if(f==r.end()){ r[team]=2; }else{ f->second+=2; } } }; ostream& operator<<(ostream& o,Current_standings const& a){ return o<<a.r; } vector<Team> keys(Current_standings const& a){ return keys(a.r); } Current_standings rand(Current_standings*){ Current_standings r; for(auto i:range_st<10>()){ r[rand((Team*)0)]=rand((Ranking_points*)0); } return r; } Current_standings update(Current_standings in,Alliance const& win){ for(auto team:win){ in.inc(team,2); } return in; } Current_standings tied(Current_standings standings,Alliance a,Alliance b){ for(auto team:a|b){ standings.inc(team,1); } return standings; } /*vector<Current_standings> play_match(Current_standings standings,Match match){ auto a=match.first; auto b=match.second; vector<Current_standings> r; r|=update(standings,a); r|=update(standings,b); r|=tied(standings,a,b); return r; }*/ array<Current_standings,3> play_match(Current_standings standings,Match match){ auto a=match.first; auto b=match.second; return { update(standings,a), update(standings,b), tied(standings,a,b) }; } vector<Current_standings> remaining(Current_standings standings,vector<Match> matches){ if(matches.empty()) return {standings}; vector<Current_standings> r; for(auto x:play_match(standings,matches[0])){ r|=remaining(x,tail(matches)); } return r; } auto appearing_teams(Match match){ return match.first|match.second; } set<Team> appearing_teams(Schedule sched){ return to_set(flatten(MAP(appearing_teams,sched))); } using Outcome=vector<Ranking_points>; using Rank=size_t; Outcome win(Outcome out,Alliance a){ for(auto team:a) out[team]+=2; return out; } auto teams(Match m){ return m.first|m.second; } Outcome tie(Outcome out,Match m){ for(auto team:teams(m)) out[team]++; return out; } array<Outcome,3> play(Outcome current,Match match){ return { win(current,match.first), win(current,match.second), tie(current,match) }; } //assuming that matches has already been changed to the dense team numbers vector<Outcome> update_rankings(Outcome current,Schedule matches){ if(matches.empty()) return {current}; vector<Outcome> r; for(auto out:play(current,matches[0])){ r|=update_rankings(out,tail(matches)); } return r; } template<typename Func,typename A,typename B> auto mapf(Func f,pair<A,B> p)->pair<decltype(f(p.first)),decltype(f(p.second))>{ return make_pair(f(p.first),f(p.second)); } template<typename Func,typename T> vector<T> mapf(Func f,set<T> s){ vector<T> r; for(auto a:s) r|=f(a); return r; } template<typename Func> void visit_result(Func f,Outcome const& current,Schedule::const_iterator matches_start,Schedule::const_iterator matches_end){ if(matches_start==matches_end){ f(current); return; } for(auto out:play(current,*matches_start)){ visit_result(f,out,matches_start+1,matches_end); } } template<typename A,typename B> vector<pair<B,A>> swap_pairs(vector<pair<A,B>> v){ vector<pair<B,A>> r; r.reserve(v.size()); for(auto p:v) r|=make_pair(p.second,p.first); return r; } template<typename T> vector<pair<T,size_t>> enumerate_back(vector<T> const& a){ vector<pair<T,size_t>> r; for(size_t i=0;i<a.size();i++) r|=make_pair(a[i],i); return r; } vector<Current_standings> possible(Current_standings standings,Schedule matches){ //first, convert the team numbers to aliases that are densely in the range 0-(num teams-1) auto teams=to_vec(to_set(keys(standings))|appearing_teams(matches)); PRINT(teams.size()); //indexed by the team's location in 'teams' Outcome r; for(auto team:teams){ r|=[&](){ auto f=standings.find(team); if(f==standings.end()){ return 0; } return f->second; }(); } auto to_ind2=[&](Team t)->Team{ for(auto p:enumerate(teams)){ if(p.second==t) return p.first; } nyi }; auto to_ind1=[&](Alliance a)->Alliance{ return to_alliance(MAP(to_ind2,a)); }; auto to_ind=[&](Match a)->Match{ return MAP(to_ind1,a); }; Schedule matches_ind=MAP(to_ind,matches); //vector<Outcome> possible_by_index=update_rankings(r,matches_ind); //vector<Outcome> possible_by_index; //visit_result([&](Outcome a){ possible_by_index|=a; },r,matches_ind); //could decide to do more of the processing in this mode. /*vector<vector<Rank>> rankings; for(auto team:teams) rankings|={}; for(auto outcome:possible_by_index){ auto p=swap_pairs(enumerate(outcome)); nyi }*/ auto from_ind=[&](Outcome a)->Current_standings{ Current_standings r; for(auto p:enumerate(a)){ auto team=teams[p.first]; auto rp=p.second; r[team]=rp; } return r; }; { vector<vector<Rank>> ranks;//by team list of the rankings that have got for(auto team:teams) ranks|=vector<Rank>{}; visit_result( [&](Outcome a){ auto s=enumerate_from(//rank,(rp,team ind) 1, sorted(//(rp,team ind) in the right order swap_pairs(//(rp,team ind) enumerate(a) //(team ind,rp) ) //enumerate_back(a) ) ); for(auto p:s){ auto rank=p.first; auto team=p.second.second; assert(team>=0 && team<teams.size()); ranks[team]|=rank; } return 0; }, r, begin(matches_ind), end(matches_ind) ); for(auto p:enumerate(teams)){ auto i=p.first; auto team=p.second; cout<<"Team "<<team<<":"<<min(ranks[i])<<" "<<median(ranks[i])<<" "<<max(ranks[i])<<"\n"; } exit(0); } /*{ vector<Current_standings> out; visit_result([&](Outcome a){ out|=from_ind(a); },r,matches_ind); return out; }*/ //return mapf(from_ind,possible_by_index); /*vector<Current_standings> r; for(auto outcome:possible_by_index){ Current_standings st; r|=st; }*/ //team index->list of rankings /*vector<vector<Result>> r; for(auto out:possible_by_index){ }*/ /*PRINT(x) for(auto a:x){ nyi }*/ nyi } int main(){ auto current=rand((Current_standings*)0); auto remaining1=rand((Schedule*)nullptr); PRINT(current); //PRINT(remaining); //PRINT(play_match(current,remaining1[0])); //auto x=remaining(current,remaining1); auto x=possible(current,remaining1); PRINT(x.size()) //PRINT(x) //PRINT(typeid(MAP(keys,x)).name()); auto teams=to_set(flatten(MAP(keys,x))); //PRINT(teams); map<Team,vector<Rank>> finishes; for(auto result:x){ //sort the results and then assign that number to each team vector<pair<Ranking_points,Team>> r; for(auto p:result){ r|=make_pair(p.second,p.first);//reverse(p); } auto s=sorted(r); for(auto p:enumerate_from(1,s)){ auto rank=p.first; auto team=p.second.second; finishes[team]|=rank; } } for(auto team:teams){ //PRINT(team); auto places=finishes[team];/*mapf( [team](auto const& a)->int{ auto f=a.find(team); if(f==a.end()) return a.size();//if not found then say lower than everyone else return f->second; }, x );*/ cout<<"Team "<<team<<": "<<min(places)<<" "<<median(places)<<" "<<max(places)<<"\n"; //PRINT(sorted(places)) } }
9f89680c59f6eaa3938fa9b76f42826968a4e4d8
b83a7556f75904614a245b74607a08ae76717b49
/src/cmdstan/write_stan_flags.hpp
9a7a259f304d08ed0e266e09c52e38a8fd5179a8
[ "BSD-3-Clause", "GPL-2.0-only", "Apache-2.0" ]
permissive
stan-dev/cmdstan
35fae63a7d7dce3d81a19e17272f06a677d03f72
fa4a4b8149a200a4f8c70dfede090601dc9b19c5
refs/heads/develop
2023-09-02T17:52:15.909803
2023-09-02T03:01:56
2023-09-02T03:01:56
16,967,338
181
126
BSD-3-Clause
2023-09-13T19:09:52
2014-02-18T23:12:16
C++
UTF-8
C++
false
false
741
hpp
write_stan_flags.hpp
#ifndef CMDSTAN_WRITE_STAN_FLAGS_HPP #define CMDSTAN_WRITE_STAN_FLAGS_HPP #include <stan/callbacks/writer.hpp> #include <string> namespace cmdstan { void write_stan_flags(stan::callbacks::writer &writer) { #ifdef STAN_THREADS writer("STAN_THREADS=true"); #else writer("STAN_THREADS=false"); #endif #ifdef STAN_MPI writer("STAN_MPI=true"); #else writer("STAN_MPI=false"); #endif #ifdef STAN_OPENCL writer("STAN_OPENCL=true"); #else writer("STAN_OPENCL=false"); #endif #ifdef STAN_NO_RANGE_CHECKS writer("STAN_NO_RANGE_CHECKS=true"); #else writer("STAN_NO_RANGE_CHECKS=false"); #endif #ifdef STAN_CPP_OPTIMS writer("STAN_CPP_OPTIMS=true"); #else writer("STAN_CPP_OPTIMS=false"); #endif } } // namespace cmdstan #endif
9654e0f68bde6955ea4ed563679d3461f13c25b0
c75e00a4569cf9eb5392f48f81623f6d7991ce3e
/Jungding/Snowboard/Terrain/GdsTerrain.cpp
7d9c63e0e9ee011093c757afa0147303ceac3e5f
[]
no_license
rodrigobmg/choding
b90dd63ff3916d969ca625134553e1ff034e1de8
7b559066e0c0989720a507c011bbfd0168c7de8f
refs/heads/master
2021-01-01T03:41:36.274647
2012-04-02T07:03:21
2012-04-02T07:03:21
57,394,584
0
0
null
null
null
null
UHC
C++
false
false
10,271
cpp
GdsTerrain.cpp
#include "stdafx.h" GdsTerrain::GdsTerrain() : m_iVertexPerNode( 33 ) , m_ixheight( 0 ) , m_izheight( 0 ) , m_iMaxLOD( 0 ) , m_pRootTile(NULL) , m_iLodRate( 50 ) , m_ilod(0) , m_idir(0) { //set renderstate GdsRenderStateGroupPtr renderstate = GdsRenderStateGroupPtr( new GdsRenderStateGroup ); renderstate->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); /// 0번 텍스처 스테이지의 확대 필터 renderstate->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 ); /// 0번 텍스처 : 0번 텍스처 인덱스 사용 renderstate->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE); renderstate->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); renderstate->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); renderstate->SetRenderState( D3DRS_ZENABLE, TRUE ); renderstate->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); renderstate->SetRenderState( D3DRS_LIGHTING, FALSE ); RENDERER.GetRenderer9()->GetRenderFrame()->AddRenderStateGroup( renderstate , 0 ); } GdsTerrain::~GdsTerrain() { vClear(); } void GdsTerrain::vClear() { m_LODIBTemplet.clear(); SAFE_DELETE( m_pRootTile ); } void GdsTerrain::build( TILE* tile , GDSVERTEX* pVB ) { tile->m_cenPos = ( tile->m_minPos + tile->m_maxPos ) * 0.5; tile->m_fRadius = D3DXVec3Length( &(tile->m_cenPos - tile->m_minPos) ); float fDist = tile->m_maxPos.x - tile->m_minPos.x; if ( abs( fDist ) > m_iVertexPerNode ) { tile->m_pChild[0] = new TILE; tile->m_pChild[0]->m_pParent = tile; tile->m_pChild[0]->m_minPos = tile->m_minPos; tile->m_pChild[0]->m_maxPos = tile->m_cenPos; tile->m_pChild[1] = new TILE; tile->m_pChild[1]->m_pParent = tile; tile->m_pChild[1]->m_minPos = D3DXVECTOR3( tile->m_cenPos.x , 0 , tile->m_minPos.z ); tile->m_pChild[1]->m_maxPos = D3DXVECTOR3( tile->m_maxPos.x , 0 , tile->m_cenPos.z ); tile->m_pChild[2] = new TILE; tile->m_pChild[2]->m_pParent = tile; tile->m_pChild[2]->m_minPos = tile->m_cenPos; tile->m_pChild[2]->m_maxPos = tile->m_maxPos; tile->m_pChild[3] = new TILE; tile->m_pChild[3]->m_pParent = tile; tile->m_pChild[3]->m_minPos = D3DXVECTOR3( tile->m_minPos.x , 0 , tile->m_cenPos.z ); tile->m_pChild[3]->m_maxPos = D3DXVECTOR3( tile->m_cenPos.x , 0 , tile->m_maxPos.z ); build( tile->m_pChild[0] , (GDSVERTEX*)pVB ); build( tile->m_pChild[1] , (GDSVERTEX*)pVB ); build( tile->m_pChild[2] , (GDSVERTEX*)pVB ); build( tile->m_pChild[3] , (GDSVERTEX*)pVB ); } else { tile->m_pVB = GdsVertexBufferPtr( new GdsVertexBuffer ); float minY = 0; float maxY = 0; int istartx = static_cast<int>(tile->m_minPos.x); int istartz = static_cast<int>(tile->m_minPos.z); for ( int z = istartz ; z < istartz + m_iVertexPerNode ; z++ ) { for ( int x = istartx ; x < istartx + m_iVertexPerNode ; x++ ) { tile->m_pVB->AddVertex( pVB[ z*m_ixheight + x] ); if ( pVB[ z*m_ixheight + x].p.y > maxY ) maxY = pVB[ z*m_ixheight + x].p.y; if ( pVB[ z*m_ixheight + x].p.y < minY ) minY = pVB[ z*m_ixheight + x].p.y; } } tile->m_minPos.y = minY; tile->m_maxPos.y = maxY; tile->m_pVB->Alloc(); } } bool GdsTerrain::MakeHeightMap() { if ( m_pRootTile != NULL ) { ASSERT( 0 && "중복 로딩" ); return false; } GdsResTexturePtr texheight = boost::shared_dynamic_cast< GdsResTexture >( RESMGR.Get( L"map.bmp") ); GdsResTexturePtr texcolor = boost::shared_dynamic_cast< GdsResTexture >( RESMGR.Get( L"tile2.tga") ); D3DSURFACE_DESC ddsd; D3DLOCKED_RECT d3drc; int cxHeight , czHeight; texheight->Get()->GetLevelDesc( 0, &ddsd ); /// 텍스처의 정보 cxHeight = ddsd.Width; /// 텍스처의 가로크기 czHeight = ddsd.Height; /// 텍스처의 세로크기 int icheckx = cxHeight % (m_iVertexPerNode-1); int icheckz = czHeight % (m_iVertexPerNode-1); if ( icheckx != 0 || icheckz != 0 || cxHeight < (m_iVertexPerNode-1) || czHeight < (m_iVertexPerNode-1) ) { //LOG_ERROR_F( "Texture Size Error:[%d,%d]", cxHeight, czHeight ); return false; } icheckx = cxHeight / (m_iVertexPerNode-1); icheckz = czHeight / (m_iVertexPerNode-1); if ( icheckx > 0 && icheckz > 0 ) { m_ixheight = cxHeight+1; m_izheight = czHeight+1; } else { ASSERT( 0 ); return false; } //maxlod 계산 for ( int i= (m_iVertexPerNode-1) ; i > 0 ; i /= 2 ) { m_iMaxLOD++; } LOG_INFO_F( "Texture Size:[%d,%d]", cxHeight, czHeight ); /// 텍스처 메모리 락! texheight->Get()->LockRect( 0, &d3drc, NULL, D3DLOCK_READONLY ); D3DXVECTOR3 minPos( 0.f , 0.f, 0.f ); D3DXVECTOR3 maxPos( 0.f, 0.f , 0.f ); GDSVERTEX vertex; GDSVERTEX* v = new GDSVERTEX[m_ixheight*m_izheight]; for( int z = 0 ; z < czHeight+1 ; z++ ) { for( int x = 0 ; x < cxHeight+1 ; x++ ) { if ( z == czHeight ) { vertex = v[(z-1)*m_ixheight+x]; vertex.p.z += 1; if ( minPos.x > vertex.p.x ) minPos.x = vertex.p.x; if ( minPos.y > vertex.p.y ) minPos.y = vertex.p.y; if ( minPos.z > vertex.p.z ) minPos.z = vertex.p.z; if ( maxPos.x < vertex.p.x ) maxPos.x = vertex.p.x; if ( maxPos.y < vertex.p.y ) maxPos.y = vertex.p.y; if ( maxPos.z < vertex.p.z ) maxPos.z = vertex.p.z; v[z*m_ixheight+x] = vertex; } else if ( x == cxHeight ) { vertex = v[z*m_ixheight+(x-1)]; vertex.p.x += 1; if ( minPos.x > vertex.p.x ) minPos.x = vertex.p.x; if ( minPos.y > vertex.p.y ) minPos.y = vertex.p.y; if ( minPos.z > vertex.p.z ) minPos.z = vertex.p.z; if ( maxPos.x < vertex.p.x ) maxPos.x = vertex.p.x; if ( maxPos.y < vertex.p.y ) maxPos.y = vertex.p.y; if ( maxPos.z < vertex.p.z ) maxPos.z = vertex.p.z; v[z*m_ixheight+x] = vertex; } else { vertex.p.x = (float)x; vertex.p.z = (float)z;//-( (float)(z-1) - ( cxHeight - 1) ); vertex.p.y = ((float)(*( (LPDWORD)d3drc.pBits+x+( czHeight - z)*(d3drc.Pitch/4) )&0x000000ff) ) / 10.0f; /// DWORD이므로 pitch/4 D3DXVec3Normalize( &vertex.n, &vertex.p ); vertex.t.x = (float)x / (cxHeight-1); vertex.t.y = (float)z / (czHeight-1); if ( minPos.x > vertex.p.x ) minPos.x = vertex.p.x; if ( minPos.y > vertex.p.y ) minPos.y = vertex.p.y; if ( minPos.z > vertex.p.z ) minPos.z = vertex.p.z; if ( maxPos.x < vertex.p.x ) maxPos.x = vertex.p.x; if ( maxPos.y < vertex.p.y ) maxPos.y = vertex.p.y; if ( maxPos.z < vertex.p.z ) maxPos.z = vertex.p.z; v[z*m_ixheight+x] = vertex; } } } texheight->Get()->UnlockRect( 0 ); m_pRootTile = new TILE; m_pRootTile->m_minPos = minPos; m_pRootTile->m_maxPos = maxPos; build( m_pRootTile , (GDSVERTEX*)v ); SAFE_DELETE( v ); createTempletIB(); return true; } void GdsTerrain::genIndex( TILE* tile ) { if ( tile == NULL ) return; if ( CAMMGR.GetCurCam()->GetFrustum().SphereIsInFrustum( tile->m_cenPos , tile->m_fRadius ) == false ) return; if ( tile->m_pChild[0] ) genIndex( tile->m_pChild[0] ); if ( tile->m_pChild[1] ) genIndex( tile->m_pChild[1] ); if ( tile->m_pChild[2] ) genIndex( tile->m_pChild[2] ); if ( tile->m_pChild[3] ) genIndex( tile->m_pChild[3] ); if ( tile->m_pVB == NULL ) return; D3DXVECTOR3 eyepos = CAMMGR.GetCurCam()->GetEye(); D3DXVECTOR3 dir = eyepos - tile->m_cenPos; float fdist = D3DXVec3Length( &dir ); int iLodlv = 0; for (int i=0; i<m_iMaxLOD; i++) { iLodlv++; if ( i*m_iLodRate > fdist ) { break; } } GdsRenderObject* p = RENDERER.GetRenderer9()->GetRenderFrame()->AllocRenderObject( 0 ); GdsResTexturePtr texcolor = boost::shared_dynamic_cast< GdsResTexture >( RESMGR.Get( L"tile2.tga") ); p->SetTexture( texcolor->Get() ); p->SetFVF( GDSVERTEX::FVF ); p->SetVertexBuffer( tile->m_pVB->Get() ); p->SetEndVertexIndex( tile->m_pVB->GetEndVertexIndex() ); p->SetVertexSize( tile->m_pVB->GetVertexSize() ); p->SetVertexMaxCount( tile->m_pVB->GetVertexMaxCount() ); INDEX_CONTAINER lodindex = m_LODIBTemplet.at(m_ilod); p->SetIndexMaxCount( lodindex.at(m_idir)->GetIndexMaxCount() ); p->SetIndexBuffer( lodindex.at(m_idir)->Get() ); p->SetEndIndex( lodindex.at(m_idir)->GetIndexMaxCount() ); p->SetStartVertexIndex( 0 ); p->SetStartIndex( 0 ); } void GdsTerrain::Update( float fElapsedtime ) { if ( INPUTSYSTEM.GetKeyIsDown( VK_B ) ) { m_ilod = rand()%m_LODIBTemplet.size(); INDEX_CONTAINER lodindex = m_LODIBTemplet.at(m_ilod); m_idir = rand()%lodindex.size(); } if( m_pRootTile ) genIndex( m_pRootTile ); } bool GdsTerrain::createTempletIB() { TRIANGLE* pRootTri1 = new TRIANGLE; D3DXVECTOR3 minPos( 0,0,0 ); D3DXVECTOR3 maxPos( (float)m_iVertexPerNode-1 , 0 , (float)m_iVertexPerNode-1 ); pRootTri1->m_pLeft = new TRIANGLE; pRootTri1->m_pLeft->p1 = minPos; pRootTri1->m_pLeft->corner = D3DXVECTOR3( (float)m_iVertexPerNode-1 ,0, 0 ); pRootTri1->m_pLeft->p2 = maxPos; pRootTri1->m_pRight = new TRIANGLE; pRootTri1->m_pRight->p1 = maxPos; pRootTri1->m_pRight->corner = D3DXVECTOR3( 0, 0, (float)m_iVertexPerNode-1 ); pRootTri1->m_pRight->p2 = minPos; pRootTri1->split( pRootTri1->m_pLeft , pRootTri1->m_iLodlv , m_iMaxLOD ); pRootTri1->split( pRootTri1->m_pRight , pRootTri1->m_iLodlv , m_iMaxLOD ); for ( int lvlod=0; lvlod < m_iMaxLOD ; lvlod++ ) { INDEX_CONTAINER lod; //홀수일때 if( lvlod % 2 == 1 ) { for ( size_t dir=0 ; dir < TRIANGLE::MAX ; dir++ ) { GdsIndexBufferPtr pIndexBuffer = GdsIndexBufferPtr( new GdsIndexBuffer ); pRootTri1->genIndexTemplet( pIndexBuffer , lvlod , dir ); pIndexBuffer->Alloc(); lod.push_back( pIndexBuffer ); } } else { GdsIndexBufferPtr pIndexBuffer = GdsIndexBufferPtr( new GdsIndexBuffer ); pRootTri1->genIndexTemplet( pIndexBuffer , lvlod , TRIANGLE::NONE ); pIndexBuffer->Alloc(); lod.push_back( pIndexBuffer ); } m_LODIBTemplet.push_back(lod); } SAFE_DELETE( pRootTri1 ); return true; }
e25d6e60a9c412a6569be4e961d859d4648b3849
c0e370117a9d0af01886b5dff187504887919e3c
/esp8266-mcu/water_control.ino
2e6244ea418af730443247c3d9c3e2fca9d4df6c
[]
no_license
EPQSky/soil-system
aeb5df9b9755bf9ba89132ef1eaa1fff24eccbe7
de7b7a4b996ee80c271c719c36d82c2b6cb30220
refs/heads/main
2023-04-15T06:46:13.365877
2021-04-28T11:21:23
2021-04-28T11:21:23
361,743,591
0
0
null
null
null
null
UTF-8
C++
false
false
2,423
ino
water_control.ino
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino // 实现网页配置WiFi需要引入的依赖包 #include <DNSServer.h> #include <ESP8266WebServer.h> #include <WiFiManager.h> //https://github.com/tzapu/WiFiManager // 用于MQTT连接EMQ X Cloud #include <PubSubClient.h> //https://github.com/knolleary/pubsubclient // MQTT Broker const char *mqtt_broker = "racf312b.cn.emqx.cloud"; const char *topic = "esp8266/control"; const char *mqtt_username = "water"; const char *mqtt_password = "123"; const int mqtt_port = 12672; #define FIRST_DEVICE 12 #define SECOND_DEVICE 14 // 创建客户端 WiFiClient espClient; PubSubClient client(espClient); void setup() { pinMode(FIRST_DEVICE, OUTPUT); pinMode(SECOND_DEVICE, OUTPUT); digitalWrite(FIRST_DEVICE, HIGH); digitalWrite(SECOND_DEVICE, HIGH); // 设置串口波特率 Serial.begin(115200); WiFiManager wifiManager; // 配置 ESP8266 热点 SSID 和 PassWord,启动网页配置 WiFi wifiManager.autoConnect("ESPwater0", "qwertyuiop"); // WiFi 配置连接成功,串口打印 Serial.println("connected...yeey :)"); // 设置服务端接口 client.setServer(mqtt_broker, mqtt_port); // 设置回调 client.setCallback(callback); while(!client.connected()){ String client_id = "esp8266-client-"; // 设置客户端ID为 ESP8266 的 MAC 地址 client_id += String(WiFi.macAddress()); Serial.println("Connecting to public emqx mqtt broker....."); if (client.connect(client_id.c_str(), mqtt_username, mqtt_password)) { // MQTT连接完成,串口打印 Serial.println("Public emqx mqtt broker connected"); } else { // MQTT连接失败,打印错误信息 Serial.print("failed with state "); Serial.println(client.state()); delay(2000); } } client.subscribe(topic); } // 接收消息,控制水启动 void callback(char *topic, byte *payload, unsigned int length) { String msg = ""; for (int i = 0; i < length; i++) { msg += (char) payload[i]; } if (msg == "1:10") { digitalWrite(FIRST_DEVICE, HIGH); } else if (msg == "1:11") { digitalWrite(FIRST_DEVICE, LOW); } else if (msg == "2:20") { digitalWrite(SECOND_DEVICE, HIGH); } else if (msg == "2:21") { digitalWrite(SECOND_DEVICE, LOW); } } // the loop function runs over and over again forever void loop() { client.loop(); }
6bd8cb2d5d24d264e5a319de2764d884251645a2
5969f0d18f38e0401bd007a9a17908424444f1c0
/Projects/_8Interrupts/_1ISRandQueue/_1ISRandQueue.ino
e284ee91fff9c35dd9dbc1fbfe3f969eabb63e1c
[]
no_license
mustafaylmz1995/Arduino_FreeRTOS_Basics
884d28c4e1ff78fee82c0fa4e57980afd3531876
06d6eb0492987bda6bb17f7badae0494d7fb521c
refs/heads/main
2023-02-01T11:22:53.805662
2020-12-20T14:23:33
2020-12-20T14:23:33
323,088,376
3
0
null
null
null
null
UTF-8
C++
false
false
993
ino
_1ISRandQueue.ino
#include <Arduino_FreeRTOS.h> #include "queue.h" QueueHandle_t que_hand; int timer1_cnt; void setup(){ Serial.begin(9600); xTaskCreate(vStringPrinter, "vStringPrinter", 128, NULL, 1, NULL); que_hand = xQueueCreate(5, sizeof(char *)); InterruptInit(); } void vStringPrinter(void *pvParameters){ char *pcString; while(1){ xQueueReceive(que_hand, &pcString, portMAX_DELAY); Serial.println(pcString); } } ISR(TIMER1_OVF_vect){ TCNT1 = timer1_cnt; uint32_t receivedNumber; static int i =0; i = (i+1)%5; static const char *pcString[]={ "Hello\r\n", "Hi\r\n", "I\r\n", "am\r\n", "here\r\n" }; xQueueSendToBackFromISR(que_hand, &pcString[i], pdFALSE); } void loop(){ } void InterruptInit(){ noInterrupts(); TCCR1A = 0; TCCR1B = 0; timer1_cnt = 32768; TCNT1 = timer1_cnt; TCCR1B |= (1 << CS12); TIMSK1 |= (1 << TOIE1); interrupts(); }
10ec5daf99e033cf9824c4222f91229edbdd0fc6
f6f2e3a103440b24ed37f3f46417ecb0c04b6ef6
/ACM-old/Strings/LexicographicallySmallestRotationOfString.cpp
f60569d4a1fd4ed595381928251cde9dad3c6dbe
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
lopatovsky/Algorithms
ef84d870782327903d10af13963336af702e5994
c5f4d2376fa86be37bcc4b4ff8aa08a683ff05b4
refs/heads/master
2022-02-10T09:47:24.489290
2022-01-01T16:54:30
2022-01-01T16:54:30
78,099,172
0
0
null
null
null
null
UTF-8
C++
false
false
337
cpp
LexicographicallySmallestRotationOfString.cpp
memcpy( str+len, str, len ); int i = 0; int j = 1; int k = 0; // len = strlen(str); while (i < len && j < len && k < len) { if (str[i+k] == str[j+k]) ++k; if (str[i+k] > str[j+k]) { i = max(i+k+1, j+1); k = 0; } else if (str[i+k] < str[j+k]) { j = max(j+k+1, i+1); k = 0; } } printf("%d\n", min(i,j)+1);
9538ae79d109f65ff115388454b4ae053d65c910
fa8e41eea4e30a407e5a73b7524050f0fe15b40b
/ogsr_engine/xrGame/physics_game.cpp
61c718a2a384c60ba1dab73e1d1db8234dccc674
[ "Apache-2.0" ]
permissive
dsh2dsh/OGSR-Engine
70c29d81fba88cece52a3150a57c24a00b1e121a
43ac8298b9a264e23c40d05beb20d7ca64a4a589
refs/heads/master
2023-08-15T23:32:56.804065
2023-07-25T15:16:22
2023-07-25T15:16:22
250,016,513
7
4
null
null
null
null
UTF-8
C++
false
false
9,671
cpp
physics_game.cpp
#include "stdafx.h" #include "ParticlesObject.h" #include "../xr_3da/gamemtllib.h" #include "level.h" #include "gamepersistent.h" #include "Extendedgeom.h" #include "PhysicsGamePars.h" #include "PhysicsCommon.h" #include "PhSoundPlayer.h" #include "PhysicsShellHolder.h" #include "PHCommander.h" #include "PHReqComparer.h" #include "MathUtils.h" #include "PHWorld.h" ///////////////////////////////////////////////////////////// bool ContactShotMarkGetEffectPars(dContactGeom* c, dxGeomUserData*& data, float& vel_cret, bool& b_invert_normal); static constexpr float PARTICLE_EFFECT_DIST = 70.f; static constexpr float SOUND_EFFECT_DIST = 70.f; static constexpr float SQUARE_PARTICLE_EFFECT_DIST = PARTICLE_EFFECT_DIST * PARTICLE_EFFECT_DIST; static constexpr float SQUARE_SOUND_EFFECT_DIST = SOUND_EFFECT_DIST * SOUND_EFFECT_DIST; static constexpr float minimal_plane_distance_between_liquid_particles = 0.2f; ///////////////////////////////////////////////////////////// class CPHParticlesPlayCall : public CPHAction { const char* ps_name; protected: dContactGeom c; int psLifeTime; public: CPHParticlesPlayCall(const dContactGeom& contact, bool invert_n, const char* psn) { ps_name = psn; c = contact; if (invert_n) { c.normal[0] = -c.normal[0]; c.normal[1] = -c.normal[1]; c.normal[2] = -c.normal[2]; } psLifeTime = 0; } virtual void run() { CParticlesObject* ps = CParticlesObject::Create(ps_name, TRUE); psLifeTime = ps->LifeTime(); Fmatrix pos; Fvector zero_vel = {0.f, 0.f, 0.f}; pos.k.set(*((Fvector*)c.normal)); Fvector::generate_orthonormal_basis(pos.k, pos.j, pos.i); pos.c.set(*((Fvector*)c.pos)); ps->UpdateParent(pos, zero_vel); GamePersistent().ps_needtoplay.push_back(ps); } virtual bool obsolete() const noexcept { return false; } }; class CPHLiquidParticlesPlayCall : public CPHParticlesPlayCall, public CPHReqComparerV { u32 remove_time; bool b_called; const CPhysicsShellHolder* m_object; public: CPHLiquidParticlesPlayCall(const dContactGeom& contact, bool invert_n, const char* psn, const CPhysicsShellHolder* object = nullptr) : CPHParticlesPlayCall(contact, invert_n, psn), b_called(false) { m_object = object; static constexpr u32 time_to_call_remove = 3000; remove_time = Device.dwTimeGlobal + time_to_call_remove; } const Fvector& position() const noexcept { return cast_fv(c.pos); } const CPhysicsShellHolder* object() const noexcept { return m_object; } private: virtual bool compare(const CPHReqComparerV* v) const { return v->compare(this); } virtual void run() { if (b_called) return; b_called = true; CPHParticlesPlayCall::run(); if (m_object && psLifeTime > 0) remove_time = Device.dwTimeGlobal + iFloor(psLifeTime / 2.f); } virtual bool obsolete() const noexcept { return Device.dwTimeGlobal > remove_time; } }; class CPHLiquidParticlesCondition : public CPHCondition, public CPHReqComparerV { private: virtual bool compare(const CPHReqComparerV* v) const noexcept { return v->compare(this); } virtual bool is_true() noexcept override { return true; } virtual bool obsolete() const noexcept { return false; } }; class CPHFindLiquidParticlesComparer : public CPHReqComparerV { Fvector m_position; const CPhysicsShellHolder* m_object; public: CPHFindLiquidParticlesComparer(const Fvector& position, const CPhysicsShellHolder* object = nullptr) : m_object(object), m_position(position) {} private: virtual bool compare(const CPHReqComparerV* v) const { return v->compare(this); } virtual bool compare(const CPHLiquidParticlesCondition* v) const { return true; } virtual bool compare(const CPHLiquidParticlesPlayCall* v) const { VERIFY(v); if (m_object) return m_object == v->object(); Fvector disp = Fvector().sub(m_position, v->position()); return disp.x * disp.x + disp.z * disp.z < (minimal_plane_distance_between_liquid_particles * minimal_plane_distance_between_liquid_particles); } }; class CPHWallMarksCall : public CPHAction { wm_shader pWallmarkShader; Fvector pos; CDB::TRI* T; public: CPHWallMarksCall(const Fvector& p, CDB::TRI* Tri, const wm_shader& s) : pWallmarkShader(s), T(Tri) { pos.set(p); } virtual void run() noexcept { //добавить отметку на материале ::Render->add_StaticWallmark(pWallmarkShader, pos, 0.09f, T, Level().ObjectSpace.GetStaticVerts()); }; virtual bool obsolete() const noexcept { return false; } }; static CPHSoundPlayer* object_snd_player(dxGeomUserData* data) noexcept { return data->ph_ref_object ? data->ph_ref_object->ObjectPhSoundPlayer() : nullptr; } static void play_object(dxGeomUserData* data, SGameMtlPair* mtl_pair, const dContactGeom* c, bool check_vel = true, float* vol = nullptr) noexcept { if (auto sp = object_snd_player(data); sp) sp->Play(mtl_pair, *(Fvector*)c->pos, check_vel, vol); } template <class Pars> inline bool play_liquid_particle_criteria(dxGeomUserData& data, float vel_cret) noexcept { if (vel_cret > Pars::vel_cret_particles) return true; bool controller = !!data.ph_object && data.ph_object->CastType() == CPHObject::tpCharacter; return !controller && vel_cret > Pars::vel_cret_particles / 4.f; } template <class Pars> void play_particles(float vel_cret, dxGeomUserData* data, const dContactGeom* c, bool b_invert_normal, const SGameMtl* static_mtl, const char* ps_name) { VERIFY(c); VERIFY(static_mtl); bool liquid = !!static_mtl->Flags.test(SGameMtl::flLiquid); const bool play_liquid = liquid && play_liquid_particle_criteria<Pars>(*data, vel_cret); const bool play_not_liquid = !liquid && vel_cret > Pars::vel_cret_particles; if (play_not_liquid) { CPHFindLiquidParticlesComparer find(cast_fv(c->pos), data->ph_ref_object); if (!Level().ph_commander().has_call(&find, &find)) Level().ph_commander().add_call(xr_new<CPHLiquidParticlesCondition>(), xr_new<CPHLiquidParticlesPlayCall>(*c, b_invert_normal, ps_name, data->ph_ref_object)); } else if (play_liquid) { CPHFindLiquidParticlesComparer find(cast_fv(c->pos)); if (!Level().ph_commander().has_call(&find, &find)) Level().ph_commander().add_call(xr_new<CPHLiquidParticlesCondition>(), xr_new<CPHLiquidParticlesPlayCall>(*c, b_invert_normal, ps_name)); } } template <class Pars> void TContactShotMark(CDB::TRI* T, dContactGeom* c) { dxGeomUserData* data = nullptr; float vel_cret = 0; bool b_invert_normal = false; if (!ContactShotMarkGetEffectPars(c, data, vel_cret, b_invert_normal)) return; Fvector to_camera; to_camera.sub(cast_fv(c->pos), Device.vCameraPosition); float square_cam_dist = to_camera.square_magnitude(); if (data) { SGameMtlPair* mtl_pair = GMLib.GetMaterialPair(T->material, data->material); if (mtl_pair) { if (vel_cret > Pars::vel_cret_wallmark && !mtl_pair->m_pCollideMarks->empty()) { wm_shader WallmarkShader = mtl_pair->m_pCollideMarks->GenerateWallmark(); Level().ph_commander().add_call( xr_new<CPHOnesCondition>(), xr_new<CPHWallMarksCall>(*((Fvector*)c->pos), T, WallmarkShader)); } if (square_cam_dist < SQUARE_SOUND_EFFECT_DIST && !mtl_pair->CollideSounds.empty()) { SGameMtl* static_mtl = GMLib.GetMaterialByIdx(T->material); VERIFY(static_mtl); if (!static_mtl->Flags.test(SGameMtl::flPassable) && vel_cret > Pars::vel_cret_sound) { float volume = collide_volume_min + vel_cret * (collide_volume_max - collide_volume_min) / (_sqrt(mass_limit) * default_l_limit - Pars::vel_cret_sound); if (auto sp = object_snd_player(data); sp) sp->PlayNext(mtl_pair, ((Fvector*)c->pos), true, &volume); else GET_RANDOM(mtl_pair->CollideSounds) .play_no_feedback(nullptr, 0, 0, ((Fvector*)c->pos), &volume); } else { play_object(data, mtl_pair, c); } } if (square_cam_dist < SQUARE_PARTICLE_EFFECT_DIST && !mtl_pair->CollideParticles.empty()) { SGameMtl* static_mtl = GMLib.GetMaterialByIdx(T->material); VERIFY(static_mtl); const char* ps_name = *mtl_pair->CollideParticles[::Random.randI( 0, mtl_pair->CollideParticles.size())]; play_particles<Pars>(vel_cret, data, c, b_invert_normal, static_mtl, ps_name); } } } } ContactCallbackFun* ContactShotMark = &TContactShotMark<EffectPars>; ContactCallbackFun* CharacterContactShotMark = &TContactShotMark<CharacterEffectPars>;
59f0e225051bbfd01113bead0bd7c916b619b8a3
7ebe68b9a889dc8b25a4b263d0f3aae436175649
/数字转换为字符.cpp
f1f1a6d43996751e712661c051e032b5ddf34ba4
[]
no_license
bystc/SomeExercisesAboutC
fecd57333ce9a197335ce7f91ce5ed30e4cefae9
6d89e375944e6b7b30c564bf94fd78f721607959
refs/heads/master
2016-09-12T17:43:58.995549
2016-05-24T12:13:17
2016-05-24T12:13:17
59,569,829
0
0
null
null
null
null
UTF-8
C++
false
false
95
cpp
数字转换为字符.cpp
#include<stdio.h> int main() { char a; scanf("%d",&a); printf("%c",a); return 0; }
02d33fd38070c692145ac2f2b09b46c9532edf82
cd4df921819d75c4c0ceff8a1b91d605ab11a995
/PAT02.cpp
a9bca3e86e0a48e7b8fc0f90ef2f7598de17dcdc
[]
no_license
flowerdrops/PAT_yi
a7ee15461355bc5755b18e62a7175ca3dc3ca0e1
b1bb0d8758cbdecb10587216a996934ea8a17fe8
refs/heads/master
2021-08-24T01:08:08.591827
2017-12-07T11:07:36
2017-12-07T11:07:36
111,670,645
1
0
null
null
null
null
UTF-8
C++
false
false
1,360
cpp
PAT02.cpp
/*#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int len = s.length(); int *a = new int [len]; int sum = 0; string str[10] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"}; for (int i = 0; i < len; i++) { a[i] = s[i] - '0'; sum = sum + a[i]; } int *b = new int [len]; int j = 0; if (sum == 0) { cout << "ling"; } else { while (sum != 0) { b[j++] = sum % 10; sum = sum / 10; } } for (int i = j - 1;i >= 1; i--) { cout << str[b[i]] << " "; } cout << str[b[0]]; delete [] a; delete [] b; return 0; }*/ #include <iostream> #include <string> using namespace std; int main(){ string num="1234567894440"; // cin>>num; int len=num.length(); // int *a=new int [len]; int sum=0; string pinyin[10]={"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"}; for (int i=0;i<len;i++) { sum=sum+(int)(num[i]-(int)'0'); } if (sum==0){ cout<<pinyin[0]; } else{int *b=new int [3]; int j=0; while (sum!=0) { b[j++]=sum%10; sum=sum/10; } for (int i=j-1;i>0;i--){ cout<<pinyin[b[i]]<<" "; } cout<<pinyin[b[0]]; } }
13db03d298e088f4d94125e5db3d8a2690908f63
84ee4284374c790accab2fa8821d1f8a1b2fa9e6
/tr2cpp/include/tr2cpp/joint.h
dfd92450c696b143d80dab04d9c1f3929a9dc5e7
[ "MIT" ]
permissive
SlateRobotics/tr2_essentials
05f3db2365fcd71fab4dae2bd836aa5502a7748f
91948213107779b78a30e177344e3de4ef8d3de5
refs/heads/master
2020-04-05T06:09:13.651052
2020-01-14T18:06:06
2020-01-14T18:06:06
156,627,344
0
0
MIT
2022-06-24T10:16:53
2018-11-08T00:35:41
Python
UTF-8
C++
false
false
462
h
joint.h
#ifndef TR2CPP__JOINT_H #define TR2CPP__JOINT_H #include <sstream> #include <tr2cpp/msgs.h> namespace tr2cpp { class Joint { private: double _previousEffort = 0; public: Joint(); ~Joint(); Msgs *_msgs; std::string name = "x0"; double pos = 0; void setMode(int mode); void actuate(double effort, int duration); void setPosition(double pos, double speed); double getPosition(); double getPreviousEffort(); }; } #endif
d5c8ad92822be3afde922241556473b3ce11753c
03c85882d07a9fdee15a0ee055112839cdfb6a3f
/nist-2/hsntg/if-mngmt.cc
7131658e90fc58f10669fbb7117faa3c87bbe6e0
[]
no_license
mello92/sip-nemo
dc560a3272288bb7e2db9eb4fc169b54aadade07
a8c04b77237343c276e2e70dc842e42c141bddcd
refs/heads/master
2020-06-04T08:38:15.377211
2009-06-01T15:42:11
2009-06-01T15:42:11
33,480,603
0
0
null
null
null
null
UTF-8
C++
false
false
7,506
cc
if-mngmt.cc
/* * Implementation of interface management protocol * * This software was developed at the National Institute of Standards and * Technology by employees of the Federal Government in the course of * their official duties. Pursuant to title 17 Section 105 of the United * States Code this software is not subject to copyright protection and * is in the public domain. * NIST assumes no responsibility whatsoever for its use by other parties, * and makes no guarantees, expressed or implied, about its quality, * reliability, or any other characteristic. * <BR> * We would appreciate acknowledgement if the software is used. * <BR> * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING * FROM THE USE OF THIS SOFTWARE. * </PRE></P> * @author rouil * @version 1.0 * <P><PRE> * VERSION CONTROL<BR> * -------------------------------------------------------------------------<BR> * Name - YYYY/MM/DD - VERSION - ACTION<BR> * rouil - 2005/05/01 - 1.0 - Source created<BR> * <BR> * <BR> * </PRE><P> */ #include "if-mngmt.h" #include "nd.h" #include "handover.h" #define MYNUM Address::instance().print_nodeaddr(addr()) /* * Static constructor for TCL */ static class IFMNGMTAgentClass : public TclClass { public: IFMNGMTAgentClass() : TclClass("Agent/MIHUser/IFMNGMT") {} TclObject* create(int, const char*const*) { return (new IFMNGMTAgent()); } } class_ifmngmtagent; /* * Creates a neighbor discovery agent */ IFMNGMTAgent::IFMNGMTAgent() : MIHUserAgent() { LIST_INIT(&fList_head_); LIST_INIT(&nd_mac_); //bind tcl attributes bind("default_port_", &default_port_); } /* * Interface with TCL interpreter * @param argc The number of elements in argv * @param argv The list of arguments * @return TCL_OK if everything went well else TCL_ERROR */ int IFMNGMTAgent::command(int argc, const char*const* argv) { if (argc == 3) { if (strcmp(argv[1], "connect-mih") == 0) { mih_ = (MIHAgent *) TclObject::lookup(argv[2]); if (mih_) return TCL_OK; return TCL_ERROR; } } if (argc == 4) { if (strcmp(argv[1], "nd_mac") == 0) { NDAgent *nd = (NDAgent *) TclObject::lookup(argv[2]); Mac *mac = (Mac *) TclObject::lookup(argv[3]); if (nd == NULL || mac == NULL) return TCL_ERROR; Nd_Mac *h = new Nd_Mac (nd, mac); h->insert_entry(&nd_mac_); return TCL_OK; } } //----------------sem start------------------// if (argc == 5) { if (strcmp(argv[1], "nd_mac") == 0) { NDAgent *nd = (NDAgent *) TclObject::lookup(argv[2]); Mac *mac = (Mac *) TclObject::lookup(argv[3]); int type = atoi(argv[4]); if (nd == NULL || mac == NULL) return TCL_ERROR; Nd_Mac *h = new Nd_Mac (nd, mac, type); h->insert_entry(&nd_mac_); return TCL_OK; } } //----------------sem end------------------// if (argc == 6) { // add-flow $local_agent $remote_agent $interface $priority if (strcmp(argv[1], "add-flow") == 0) { Agent *local = (Agent *) TclObject::lookup(argv[2]); Agent *remote = (Agent *) TclObject::lookup(argv[3]); Node * iface = (Node *) TclObject::lookup(argv[4]); int priority = atoi(argv[5]); add_flow (local, remote, iface, priority, 0); return TCL_OK; } } if (argc == 7) { // add-flow $local_agent $remote_agent $interface $priority $minBw if (strcmp(argv[1], "add-flow") == 0) { Agent *local = (Agent *) TclObject::lookup(argv[2]); Agent *remote = (Agent *) TclObject::lookup(argv[3]); Node * iface = (Node *) TclObject::lookup(argv[4]); int priority = atoi(argv[5]); float minBw = atof (argv[6]); add_flow (local, remote, iface, priority, minBw); return TCL_OK; } } return (MIHUserAgent::command(argc, argv)); } /* * Get the flow connecting the given agents * @param local The agent running locally * @param remote The remote agent * @return The flow information connecting the agent of null */ FlowEntry* IFMNGMTAgent:: get_flow (Agent *local, Agent *remote) { FlowEntry *n = head(fList_head_); for ( ; n ; n=n->next_entry()) { if(n->local()==local && n->remote()==remote) return n; } return NULL; } /* * Get the flow connecting the given agents * @param local The agent running locally * @param remote The remote agent * @return The flow information connecting the agent of null */ vector <FlowEntry*> IFMNGMTAgent:: get_flows () { FlowEntry *n = head(fList_head_); vector <FlowEntry *> res; for ( ; n ; n=n->next_entry()) { res.push_back (n); } return res; } /* * Connect both agent and create a flow information * @param local The local agent * @param remote The remote agent * @param iface The interface to use * @param priority The flow priority */ void IFMNGMTAgent:: add_flow (Agent *local, Agent *remote, Node *iface, int priority, float minBw) { Tcl& tcl = Tcl::instance(); if (!get_flow (local, remote)) { tcl.evalf ("[Simulator instance] simplex-connect %s %s", local->name(), remote->name()); tcl.evalf ("%s set dst_addr_ [AddrParams addr2id [%s node-addr]]", remote->name(), iface->name()); tcl.evalf ("%s set dst_port_ [%s set agent_port_]",remote->name(), local->name()); //add entry FlowEntry *new_entry = new FlowEntry(local, remote, priority, minBw, iface); new_entry->insert_entry(&fList_head_); debug ("At %f in %s Interface Manager : Flow added\n", NOW, MYNUM); } else { debug ("At %f in %s Interface Manager : Warning..a flow already exists between %s and %s\n",\ NOW, MYNUM, local->name(), remote->name()); } } /* * Remove the flow information connecting the 2 agents * @param local The local agent * @param remote The remote agent * @TODO if add_flow connects the agents, delete_flow should disconnects them?? */ void IFMNGMTAgent:: delete_flow (Agent *local, Agent *remote) { FlowEntry *n = get_flow (local, remote); if (n) n->remove_entry (); } /* * Process received packet * @param p The received packet * @param h Packet handler */ void IFMNGMTAgent::recv(Packet* p, Handler *h) { debug ("At %f in %s Interface Manager received packet\n", NOW, MYNUM); Packet::free (p); } /* * Process an event received from the ND module. * This method must be overwritten by subclasses * @param type The event type * @param data The data associated with the event */ void IFMNGMTAgent::process_nd_event (int type, void* data) { debug ("At %f in %s Interface Manager received ND event\n",NOW, MYNUM); free (data); } //----------------sem start------------------// void IFMNGMTAgent::set_mr_bs_prefix(new_prefix* data, double lifetime) { debug ("At %f in %s Interface Manager received MR_BS prefix\n",NOW, MYNUM); free (data); } //----------------sem end------------------// /* * Find the ND module in the node where the mac is * @param mac The MAC module * @return The ND module in the node if it exists or NULL */ NDAgent * IFMNGMTAgent::get_nd_by_mac (Mac *mac) { Nd_Mac *h = nd_mac_.lh_first; for ( ; h ; h=h->next_entry()) { if (h->mac() == mac) { return h->nd(); } } return NULL; } /* Return a Packet * @return A newly allocated packet */ Packet* IFMNGMTAgent::getPacket() { Packet *p = allocpkt(); hdr_ip *iph = HDR_IP(p); iph->dport() = port(); return p; }
f29a4c2435f359d4a8ad38c89963f5434d776ecd
f8b1dfccaef5a8f75567b527fc7c2f0a34e3877b
/swjtu/e20150122/p2.cpp
5575c5fe715b261983ffeb72451e6cdc7e92832c
[]
no_license
bamboohiko/problemSolve
e7e2a2c6e46a4d10ccfa54cffff3c9895b3ddb1b
cd3e9e5986325f5def4efe01975a950f6eaa6015
refs/heads/master
2021-01-17T06:39:42.502176
2017-09-13T14:30:08
2017-09-13T14:30:08
47,928,189
0
0
null
null
null
null
UTF-8
C++
false
false
886
cpp
p2.cpp
#include<iostream> #include<cstdio> #include<map> #include<set> #include<vector> #include<stack> #include<queue> #include<string> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int f[100000 + 10]; set<int> use; int add(int x) { if (!use.count(x)) { use.insert(x); return 1; } return 0; } int main() { int x,y,t = 0; while (scanf("%d%d",&x,&y) != EOF && x >= 0 && y >= 0) { printf("Case %d is ",++t); if (!x || !y) { printf("not a tree.\n"); continue; } use.clear(); int cou = 1,n = add(x) + add(y),ans = 1; memset(f,0,sizeof(f)); if (x == y) ans = 0; while (scanf("%d%d",&x,&y) != EOF && x && y) { cou++; n += add(x) + add(y); f[y]++; if (f[y] > 1) ans = 0; } if (cou != n-1) ans = 0; if (!ans) printf("not "); printf("a tree.\n"); } return 0; }
e41f6bee3d886bf0de24951d0acd7432e0857ef0
7cbb2ff867cbde5551161b4456c904d3e1f3a4ff
/stream.h
7a7335b1b468ca7164303a371f147a189311313a
[ "BSD-2-Clause" ]
permissive
agobi/cppstream
c8e1dc599903d76524fab8a9a4ab3fd052c5b63d
eaef6d3b5b15d06a253de71ebc1342df6d375d3b
refs/heads/master
2020-04-17T02:58:21.202088
2014-10-28T17:41:05
2014-10-28T17:41:05
25,881,664
0
0
null
null
null
null
UTF-8
C++
false
false
9,994
h
stream.h
/* * Copyright (c) 2011-2012, Attila Gobi and Zalan Szugyi * All rights reserved. * * This software was developed by Attila Gobi and Zalan Szugyi. * The project was supported by the European Union and co-financed by the * European Social Fund (grant agreement no. TAMOP 4.2.1./B-09/1/KMR-2010-0003) * * 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 AUTHORS 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 __stream_h__ #define __stream_h__ #include <iostream> #include <utility> #include <ctime> #include <cassert> #if __GNUC__ > 4 || \ (__GNUC__ == 4 && (__GNUC_MINOR__ >= 7)) #define HAVE_LITERALS #endif template<typename T> struct storage_type { typedef typename std::conditional< std::is_lvalue_reference<typename std::remove_const<T>::type>::value, typename std::remove_const<T>::type, typename std::remove_reference<typename std::remove_const<T>::type>::type >::type type; }; template<typename T> struct stream { protected: struct impl; public: typedef T value_type; stream(const stream<T> &o) : impl_(o.impl_->clone()) { } stream(stream<T> &&o) : impl_(0) { std::swap(impl_, o.impl_); } stream<T> & operator = (stream<T> &&o) { if(this != &o) { std::swap(impl_, o.impl_); return *this; } } ~stream() { delete impl_; } struct iterator { iterator& operator ++() { (*impl_)->next(*this); return *this; } const T& operator *() const { return (*impl_)->get(*this); } friend struct stream<T>; protected: iterator(impl ** impl) :impl_(impl) { } impl **impl_; }; iterator begin() const { return iterator(&impl_); } protected: struct impl { virtual ~impl() {} virtual const T &get(const iterator &) = 0; virtual void next(iterator &) = 0; virtual impl* clone() = 0; }; mutable impl * impl_; stream(impl *i) :impl_(i) { } template<typename ST> struct addimpl: public impl { addimpl(const T &a, ST &&s) : a_(a), s_(std::forward<ST>(s)) { } const T &get(const iterator &) { return a_; } void next(iterator &it) { it.impl_ = const_cast<impl**>(&s_.impl_); } impl *clone() { return new addimpl<ST>(a_, std::forward<ST>(s_)); } private: const T a_; typename storage_type<ST>::type s_; }; template<typename Op, typename ST> struct mapimpl2: public impl { mapimpl2(Op op, ST &&s) :s_(std::forward<ST>(s)), it1(s_.begin()), op_(op) { } const T &get(const iterator &it) { *(it.impl_)=new addimpl<stream<T>&&>(op_(*it1), stream<T>(this)); ++it1; return *it; } void next(iterator &it) { *(it.impl_)=new addimpl<stream<T>&&>(op_(*it1), stream<T>(this)); ++it1; ++it; } impl *clone() { return new mapimpl2<Op, ST>(op_, std::forward<ST>(s_)); } private: typename storage_type<ST>::type s_; iterator it1; Op op_; }; template<typename Op, typename ST> struct mapimpl: public impl { mapimpl(Op op, ST &&s) : s_(std::forward<ST>(s)), op_(op) { } const T &get(const iterator &it) { impl *x = new mapimpl2<Op, ST>(op_, std::forward<ST>(s_)); *(it.impl_) = x; delete this; return *it; } void next(iterator &it) { impl *x = new mapimpl2<Op, ST>(op_, std::forward<ST>(s_)); *(it.impl_) = x; delete this; ++it; } impl *clone() { return new mapimpl<Op, ST>(op_, std::forward<ST>(s_)); } private: typename storage_type<ST>::type s_; Op op_; }; template<typename Op, typename ST1, typename ST2> struct zipimpl: public impl { zipimpl(Op op, ST1 &&s1, ST2 &&s2) :s1_(std::forward<ST1>(s1)), s2_(std::forward<ST2>(s2)), op_(op) { } const T &get(const iterator &it) { impl *x = new zipimpl2<Op, ST1, ST2>(op_, std::forward<ST1>(s1_), std::forward<ST2>(s2_)); *(it.impl_) = x; delete this; return *it; } void next(iterator &it) { impl *x = new zipimpl2<Op, ST1, ST2>(op_, std::forward<ST1>(s1_), std::forward<ST2>(s2_)); *(it.impl_) = x; delete this; ++it; } impl *clone() { return new zipimpl<Op, ST1, ST2>(op_, std::forward<ST1>(s1_), std::forward<ST2>(s2_)); } private: typename storage_type<ST1>::type s1_; typename storage_type<ST2>::type s2_; Op op_; }; template<typename Op, typename ST1, typename ST2> struct zipimpl2: public impl { zipimpl2(Op op, ST1 &&s1, ST2 &&s2) :s1_(std::forward<ST1>(s1)),s2_(std::forward<ST2>(s2)), it1(s1_.begin()), it2(s2_.begin()), op_(op) { } const T &get(const iterator &it) { *(it.impl_)=new addimpl<stream<T>&&>(op_(*it1, *it2), stream<T>(this)); ++it1; ++it2; return *it; } void next(iterator &it) { *(it.impl_)=new addimpl<stream<T>&&>(op_(*it1, *it2), stream<T>(this)); ++it1; ++it2; ++it; } impl *clone() { return new zipimpl2<Op, ST1, ST2>(op_, std::forward<ST1>(s1_), std::forward<ST2>(s2_)); } private: typename storage_type<ST1>::type s1_; typename storage_type<ST2>::type s2_; iterator it1, it2; Op op_; }; public: template <typename S, typename U> friend stream<U> operator <<= (const U& a, S && s); template <typename Op, typename ST1, typename ST2> static stream<T> zipwith(Op op, ST1 &&s1, ST2 &&s2) { return stream(new zipimpl<Op, decltype(s1), decltype(s2)>(op, std::forward<ST1>(s1), std::forward<ST2>(s2))); } template <typename ST1, typename Op> static stream<T> map(Op op, ST1 &&s1) { return stream(new mapimpl<Op, decltype(s1)>(op, std::forward<ST1>(s1))); } static stream<T> pure(const T& v) { stream<T> s = v<<=s; return s; } }; template<typename ST> struct stream_value_type { typedef typename std::remove_reference<ST>::type::value_type type; }; template <typename S, typename U=typename stream_value_type<S>::type> stream<U> operator <<= (const U& a, S && s) { return stream<U>(new typename stream<U>::template addimpl<decltype(s)>(a, std::forward<S>(s))); } template<typename ST1, typename ST2, typename T=typename stream_value_type<ST1>::type> stream<T> operator +(ST1 &&s1, ST2 &&s2) { return stream<T>::zipwith(std::plus<T>(), std::forward<ST1>(s1), std::forward<ST2>(s2)); } template<typename ST1, typename ST2, typename T=typename stream_value_type<ST1>::type> stream<T> operator -(ST1 &&s1, ST2 &&s2) { return stream<T>::zipwith(std::minus<T>(), std::forward<ST1>(s1), std::forward<ST2>(s2)); } template<typename ST1, typename ST2, typename T=typename stream_value_type<ST1>::type> stream<T> operator *(ST1 &&s1, ST2 &&s2) { return stream<T>::zipwith(std::multiplies<T>(), std::forward<ST1>(s1), std::forward<ST2>(s2)); } template<typename ST1, typename ST2, typename T=typename stream_value_type<ST1>::type> stream<T> operator /(ST1 &&s1, ST2 &&s2) { return stream<T>::zipwith(std::divides<T>(), std::forward<ST1>(s1), std::forward<ST2>(s2)); } template<typename ST1, typename ST2, typename T=typename stream_value_type<ST1>::type> stream<T> operator %(ST1 &&s1, ST2 &&s2) { return stream<T>::zipwith(std::modulus<T>(), std::forward<ST1>(s1), std::forward<ST2>(s2)); } template<typename ST, typename T=typename stream_value_type<ST>::type> stream<T> operator -(ST &&s) { return stream<T>::map(std::negate<T>(), std::forward<ST>(s)); } #ifdef HAVE_LITERALS struct stream_proxy { stream_proxy(unsigned long long i): x(i) {} template <typename T> operator stream<T> () { stream<T> a = static_cast<T>(x)<<=a; return a; } unsigned long long x; }; stream_proxy operator "" _s (unsigned long long i) { return stream_proxy(i); } #endif//HAVE_LITERALS #endif//__stream_h__
df7cb65924c4cf365c9cb387a07def36469dbc3d
35d67bf16427d421c986602bc50b98b94b3328be
/Desgin/Command/LightOnCommand.cc
599343387ad542580dc92380dfd8b2aa1c5a5638
[]
no_license
xiaoy/Exercise
74eefe6458d202ea6310d958374cbb761d4a7ad5
c89b7beac3ae7508cd00d81e215b7e00e4306d85
refs/heads/master
2021-06-12T04:40:54.555509
2021-05-16T09:03:22
2021-05-16T09:03:22
5,648,724
1
0
null
null
null
null
UTF-8
C++
false
false
427
cc
LightOnCommand.cc
/* * LightCommad.cc * * Created on: 2012-5-22 * Author: lfwu */ #include "LightOnCommand.h" #include "base.h" LightOnCommand::LightOnCommand() { // TODO Auto-generated constructor stub } LightOnCommand::~LightOnCommand() { // TODO Auto-generated destructor stub } void LightOnCommand::SetLight(Light* light) { light_ = light; } void LightOnCommand::Excute() { if(light_ != NULL) { light_->LightOn(); } }
f0813c9498008d7cc39d0dd7ea80d2421a42c329
da3a2d867984a41270c9e92b38f26967673959c0
/src/MainWindow.h
ead78ed4289de311b655bcd94f9c69b203c05176
[]
no_license
andrewrk/motrs
713c1bf05e5fc284da4e23f9a8e53ce60a447c11
f4f0494cf4c76c30b6aeff78bfc89925fb61b541
refs/heads/master
2023-03-13T06:59:08.515898
2012-12-08T19:49:23
2012-12-08T19:49:23
7,071,350
0
1
null
null
null
null
UTF-8
C++
false
false
1,251
h
MainWindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <SFML/Graphics.hpp> class Gameplay; // Main window is responsible for setting up the graphics framework, // Gameplay, and handling window events. // MainWindow has the main loop, which calls the necessary Gameplay methods // to make Gameplay work class MainWindow { public: MainWindow(); ~MainWindow(); // main loop and window processing int exec(); // switch between full screen and windowed mode void toggleFullscreen(); // return the rendering window inline sf::RenderWindow * renderWindow(); // number of logic frames per second inline int fps(); // close window and end gameplay void close(); private: //variables static const int c_fps; static const int c_width; static const int c_height; static const char * c_caption; static const int c_colorDepth; bool m_fullscreen; sf::VideoMode m_videoModeFlags; int m_windowStyle; sf::RenderWindow * m_window; Gameplay * m_gameplay; private: //methods void setFullscreenFlags(bool fullscreen); }; inline sf::RenderWindow * MainWindow::renderWindow() { return m_window; } inline int MainWindow::fps() { return c_fps; } #endif // MAINWINDOW_H
a5130110ee12b837615c0fb50b8ec78f74a3ed7f
d19ad17b3d9a8bf9cf837b79b94f199f3b1e723f
/mainwindow.cpp
eb22cf5dc4825028fa348dcbe1729feef1f25e34
[]
no_license
745184533/Elevator
c730954f61f92c2e652f89910b0b1a221cb85b9c
fbfb6f199012a6b9f5cd9666f56b64e98c6b0f92
refs/heads/master
2022-07-17T12:34:03.324600
2020-05-17T16:05:21
2020-05-17T16:05:21
264,703,287
1
0
null
null
null
null
UTF-8
C++
false
false
8,350
cpp
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include<QDebug> #include<QString> #include<QLCDNumber> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); myt=new mythread(this); myt->lifts=this->lifts; //让全局子线程拥有电梯和楼梯间的信息 //myt->Building=this->Building; //选择电梯并且整个调度写道其他子线程里面。 myt->mytestEleself=&(lifts[1].Elevatorself); singlet=new singleT[TotalFloor + 1]; for (int i=1;i<=TotalElevator;++i) { singlet[i].setParent(this); singlet[i].lifts=&(this->lifts[i]); //对于子线程我们只要拥有对应的电梯信息即可 singlet[i].Building=this->Building; //也可放到主窗口操作。 connect(&singlet[i],&singleT::isOver, [=]() { singlet[i].stopImmediately(); });//直接调用,安全退出 } //主窗口的构造函数里布局,并且确定基本的功能 //初始化电梯所有按钮。 for(int j=1;j<=TotalElevator;j++) { //电梯内部按钮设计。 lifts[j].setParent(this); lifts[j].Groupmy.setParent(this);//必须! lifts[j].Groupmy.move(150*j-100,560); lifts[j].warning.setParent(&lifts[j].Groupmy); lifts[j].warning2.setParent(&lifts[j].Groupmy); lifts[j].liftswitch.setParent(&lifts[j].Groupmy); lifts[j].liftswitch2.setParent(&lifts[j].Groupmy); //出发按钮和计时器 lifts[j].Elevatorself.setParent(this); lifts[j].number1.setParent(this); if(j==1){lifts[j].Elevatorself.setText("电梯1");} if(j==2){lifts[j].Elevatorself.setText("电梯2");} if(j==3){lifts[j].Elevatorself.setText("电梯3");} if(j==4){lifts[j].Elevatorself.setText("电梯4");} if(j==5){lifts[j].Elevatorself.setText("电梯5");} lifts[j].Elevatorself.setGeometry(115*j-110,500,110,25); //lifts[j].Elevatorself.move(115*j-110,500); lifts[j].number1.move(115*j-110,530); //楼层按钮. for (int i=1;i<=TotalFloor;i++) { lifts[j].inButtons[i].setParent(&lifts[j].Groupmy); QString tempfloor=QString::number(i); lifts[j].inButtons[i].setText(tempfloor); //lifts[j].inButtons[i].setFixedSize(80,40); if(i<=10) { lifts[j].inButtons[i].move(40,42*i-40); } else { lifts[j].inButtons[i].move(120,42*(i-10)-40); } } lifts[j].Groupmy.hide();//避免一开始同时多个电梯界面重合。 } //楼梯间设置。 Building->setParent(this); // for (int i=1;i<=TotalFloor;i++) { Building->outButton[i].setParent(this); Building->outButton[i].Lup.setParent(this); Building->outButton[i].Ldown.setParent(this); Building->outButton[i].floors.setParent(this); Building->outButton[i].move(600-30,500-23*i); Building->outButton[i].Lup.move(610-30,500-23*i); Building->outButton[i].Ldown.move(680-30,500-23*i); Building->outButton[i].floors.move(740-30,500-23*i); //如果不需要Building和Elevator之间的信息传递,connect函数全部写到构造函数中 connect(&Building->outButton[i].Lup,&QPushButton::clicked, [=]() { Building->outButton[i].Lup.setStyleSheet("background-color: rgb(175,238,238)"); //在内部绑定更新楼层队列 //在主窗口调用全局线程改变各个电梯的目标队列。 myt->dealSelect(i);//启动主线程的搜索分配。 QThread::msleep(1000);//等待搜索结果 //若结果未等到则tempid的值未知,无法进行下去。 //全局线程的等待事件设为100ms,子线程的事件最多等待500ms //所以留给算法的时间约为400ms. //每次按钮触发的调度时间则远比这个时间要长。 tempid=myt->liftid; qDebug()<<tempid<<"选出电梯号:"<<endl; }); connect(&Building->outButton[i].Ldown,&QPushButton::clicked, [=]() { Building->outButton[i].Ldown.setStyleSheet("background-color: rgb(175,238,238)"); myt->dealSelect(i); QThread::msleep(600); tempid=myt->liftid; qDebug()<<tempid<<"选出电梯号:"<<endl; }); Building->outButton[i].show(); } //完成初始化以后开启线程myt,运行run函数. connect(myt,&mythread::isOver,this,&MainWindow::dealisOver); //在楼梯层的按钮被按下后交给全局线程去选择一个合适接收者。 for (int i=1;i<=TotalElevator;++i) { connect(&singlet[i],&singleT::vary,this,&MainWindow::dealvary); //将按钮改变交给主窗口处理? } myt->start(); //主线程只改变子线程内部run()函数的运行情况而不会直接调用run函数。 //局部子线程即改变整个按钮移动响应,全程不停止扫描更新。 for (int i=1;i<=TotalElevator;++i) { singlet[i].start(); } //connect(ui->Test,&QPushButton::clicked,this,&MainWindow::test); } MainWindow::~MainWindow() { qDebug() << "start destroy widget"; //调试信息确保线程安全退出。 //在主窗口被删除前结束子线程。 for (int i=1;i<=TotalElevator;++i) { singlet[i].stopImmediately(); singlet[i].wait(); } myt->stopImmediately(); myt->wait(); delete ui; qDebug() << "end destroy widget"; } void MainWindow::dealisOver() { myt->stopImmediately(); //这个是线程的非run函数,他运行在主线程上,所以主线程可以立马对其操作通过bool变量来结束子线程。 } void MainWindow::dealvary(int floor) { //电梯内部按钮的响应,检测其非空所以触发信号vary,此时参数floor。 qDebug()<<"主线程处理按钮移动"; tempfloor=floor; //qDebug()<<"目标楼层:"<<tempfloor<<endl;全部无误。 if(tempfloor<=0||tempfloor>TotalFloor||tempid==0)//证明是电梯内部请求 { for (int i=1;i<=TotalElevator;++i) { qDebug()<<"检测电梯"<<i; if(lifts[i].nextDes.count()) { //因为是有线程检测到队列不空,所以我们只要找到有有值的那一个, tempid=i;break; } } } qDebug()<<"目标电梯:"<<tempid<<endl; while(lifts[tempid].now_floor<tempfloor) { QThread::msleep(1000); qDebug()<<"+1"; lifts[tempid].gradual_vary(tempfloor); } while(lifts[tempid].now_floor>tempfloor) { QThread::msleep(1000); qDebug()<<"-1"; lifts[tempid].gradual_vary(tempfloor); } if(!Building->TotalDes.empty()) { for(QVector<int>::iterator it = Building->TotalDes.begin(); it != Building->TotalDes.end(); ++it) { if(tempfloor==*it) { Building->TotalDes.erase(it); qDebug()<<"Yes"; break; } } } lifts[tempid].inButtons[tempfloor].setStyleSheet("background-color: #f5f5f5"); Building->outButton[tempfloor].setStyleSheet("background-color: #f5f5f5"); qDebug()<<tempfloor<<"--------"; qDebug()<<tempid<<"-------"; if(lifts[tempid].nextDes.count()) { lifts[tempid].nextDes.pop_front(); qDebug()<<lifts[tempid].nextDes.count()<<"队列中的剩余个数"<<endl; } } void MainWindow::test() { /*int i=1; qDebug()<<"动不了!!"; lifts[1].gradual_vary(20); while(i<20) { QThread::sleep(1); QPoint temp=lifts[1].Elevatorself.pos();//将电梯自身按钮上下移动。 lifts[1].Elevatorself.move(temp.x(),temp.y()-24); ++i; }*/ }
851fec8baffce2ca2916922ad40f8ef77416d702
5329d78e893225368bfc953c47d8e93a043867d9
/src/UniformLookupTableGenerator.cpp
642548c86d9ddd8a51e88f13962b5bb2c2d41d48
[]
no_license
wbbssr/func
8b68b9fde04c22727cc657af041333c266157cb9
5459cc80b7f95da81d8101f80e6bd62118dc28b3
refs/heads/master
2020-08-21T06:29:18.053049
2018-12-11T15:52:29
2018-12-11T15:52:29
216,106,993
0
0
null
2019-10-18T21:07:44
2019-10-18T21:07:43
null
UTF-8
C++
false
false
10,222
cpp
UniformLookupTableGenerator.cpp
/* Implementation of UniformLookupTableGenerator */ #include "UniformLookupTableGenerator.hpp" // #include "UniformTables.hpp" #include <boost/math/tools/minima.hpp> #include <boost/math/tools/roots.hpp> #include <boost/multiprecision/float128.hpp> #include <boost/math/special_functions/next.hpp> #include <limits> #include <iostream> using namespace boost::multiprecision; /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /* Nested Functor used for computing error in a given lookup table */ struct UniformLookupTableGenerator::LookupTableErrorFunctor { LookupTableErrorFunctor(UniformLookupTable* impl) : m_impl(impl) {} /* operator() always returns a negative value */ float128 operator()(float128 const& x) { float128 f_value = float128((*(m_impl->function()))(double(x))); float128 lut_value = float128((*m_impl)(double(x))); return -float128(2.0) * fabs( (f_value - lut_value) ) / (fabs(f_value)+fabs(lut_value)); } private: UniformLookupTable *m_impl; }; /* Nested Functor used for finding optimal stepsize that satisfies TOL */ struct UniformLookupTableGenerator::OptimalStepSizeFunctor { OptimalStepSizeFunctor(UniformLookupTableGenerator &parent, std::string tableKey, double tol) : m_parent(parent), m_tableKey(tableKey) , m_tol(tol) { } double operator()(double const& stepSize) { using namespace boost::math::tools; UniformLookupTableParameters par; par.minArg = m_parent.m_min; par.maxArg = m_parent.m_max; par.stepSize = stepSize; auto impl = UniformLookupTableFactory::Create(m_tableKey, m_parent.mp_func, par); boost::uintmax_t max_it = 20; float128 max_err = 0; float128 xstar, err; /* get number of binary bits in mantissa */ int bits = std::numeric_limits<float128>::digits; double eps = std::numeric_limits<double>::epsilon(); /* for each interval in the uniform table, compute the maximum error - be careful about the top most interval, it may reach beyond the table range due to rounding errors */ unsigned index = 0; for(unsigned ii=0; ii<impl->num_intervals()-1; ii++){ std::pair<double,double> intEndPoints = impl->arg_bounds_of_interval(ii); float128 x = float128(boost::math::float_next(intEndPoints.first)); float128 xtop = float128(boost::math::float_prior(intEndPoints.second)); if ( double(xtop) > m_parent.m_max ) break; std::pair<float128, float128> r = brent_find_minima(LookupTableErrorFunctor(impl.get()),x,xtop,bits,max_it); xstar = r.first; err = r.second; if( err < max_err ) { index = ii+1; max_err = err; } } /* want return to be 0 if the same, +/- on either side */ max_err = -max_err; // std::cout << "stepSize: " << stepSize << " max_err: " << max_err << std::endl; return double(max_err-m_tol); } private: UniformLookupTableGenerator &m_parent; std::string m_tableKey; double m_tol; }; /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /* UniformLookupTableGenerator functions */ UniformLookupTableGenerator::UniformLookupTableGenerator(EvaluationFunctor<double,double> *func, double minArg, double maxArg) : mp_func(func), m_min(minArg), m_max(maxArg) {} UniformLookupTableGenerator::~UniformLookupTableGenerator() { } std::unique_ptr<UniformLookupTable> UniformLookupTableGenerator::generate_by_step(std::string tableKey, double stepSize) { UniformLookupTableParameters par; par.minArg = m_min; par.maxArg = m_max; par.stepSize = stepSize; return UniformLookupTableFactory::Create(tableKey, mp_func, par); } std::unique_ptr<UniformLookupTable> UniformLookupTableGenerator::generate_by_impl_size(std::string tableKey, unsigned long desiredSize) { /* Use 2 query points to get relationship */ const double step1 = 0.5; const unsigned long N1 = 2; const double step2 = 0.1; const unsigned long N2 = 10; UniformLookupTableParameters par1; par1.minArg = m_min; par1.maxArg = m_max; par1.stepSize = step1; UniformLookupTableParameters par2; par2.minArg = m_min; par2.maxArg = m_max; par2.stepSize = step1; std::unique_ptr<EvaluationImplementation> impl1 = UniformLookupTableFactory::Create(tableKey, mp_func, par1); std::unique_ptr<EvaluationImplementation> impl2 = UniformLookupTableFactory::Create(tableKey, mp_func, par2); unsigned long size1 = impl1->size(); unsigned long size2 = impl2->size(); if (size2 == size1) { throw "Query tables have same size."; } /* approximate step size for for desired impl size (assuming linear relationship of num_intervals to size */ par1.stepSize = 1.0/((double)((N2-N1)*(desiredSize-size1)/(size2-size1) + N1)); return UniformLookupTableFactory::Create(tableKey, mp_func, par1); } std::unique_ptr<UniformLookupTable> UniformLookupTableGenerator::generate_by_tol(std::string tableKey, double desiredTolerance) { UniformLookupTableParameters par; par.minArg = m_min; par.maxArg = m_max; par.stepSize = (m_max-m_min)/1000.0; /* generate a first approximation for the implementation */ auto impl = UniformLookupTableFactory::Create(tableKey, mp_func, par); /* And initialize the functor used for refinement */ OptimalStepSizeFunctor f(*this,tableKey,0); double stepSize = impl->step_size(); const int order = impl->order(); const double logTol = log(desiredTolerance); /* APPLY NEWTON'S METHOD IN log-log SPACE ('known' slope = order) Approximate the solution that satisfies tolerance based on the order of the implementation - assumes that the initial guess is in the asymptotic regime of the table's convergence - even if not in asymptotic regime, this thing has some pretty robust convergence! */ const int N_NEWTON_MAX_IT = 0; // max log-Newton-iterations const double NEWTON_IT_RTOL = 1e-5; const double NEWTON_IT_ATOL = 1e-10; int NEWTON_SUCCESS_FLAG = 0; std::vector<std::pair<double,double>> iterates; for (int iNewton = 0; iNewton < N_NEWTON_MAX_IT; iNewton++) { double err = f(stepSize); if ( fabs(err-desiredTolerance) < fabs(desiredTolerance)*NEWTON_IT_RTOL+NEWTON_IT_ATOL ) { std::cout << "Newton iter: " << iNewton << "\n"; NEWTON_SUCCESS_FLAG = 1; break; } double logStepSize = log(stepSize); double logError = log(err); logStepSize += (logTol-logError)/order; stepSize = exp(logStepSize); iterates.push_back(std::make_pair(stepSize,err)); } /* Output Newton iterates: */ // double err = f(stepSize); // std::cout << "Iterates (normal space): step, error" << std::endl; // for (auto it : iterates) { // std::cout << " " << it.first << ", " << it.second << std::endl; // } /* APPLY A BRACKETING ALGORITHM IN log-log SPACE If a suitable bracket is found, this guarantees a solution below desiredTolerance. If not, bracket_and_solve throws. */ const boost::uintmax_t BRACKET_MAX_IT = 50; // Limit to maximum iterations. boost::uintmax_t it = BRACKET_MAX_IT; // Initally our chosen max iterations, but updated with actual. /* Throw when the log-Newton method did not converge AND there are no bracketing iterations performed. */ if ( !NEWTON_SUCCESS_FLAG && !BRACKET_MAX_IT) { std::cerr << "WARNING: No bracketing iterations specified." << std::endl; std::stringstream throwMessage; throwMessage << "log-Newton method did not converge in " << N_NEWTON_MAX_IT << " steps."; throw throwMessage; } /* Use the guess step size as an initialization to bracket_and_solve */ using namespace boost::math::tools; double factor = 2; // Mult/divide factor for bracket expansion when searching. bool is_rising = 1; // The error curve should always be rising int digits = std::numeric_limits<double>::digits; // Maximum possible binary digits accuracy for type T. // Some fraction of digits is used to control how accurate to try to make the result. int get_digits = digits-30; // We have to have a non-zero interval at each step, so // doesn't have to be so accurate // maximum accuracy is digits - 1. But we also have to // allow for inaccuracy in f(x), otherwise the last few iterations // just thrash around. eps_tolerance<double> tol(get_digits); // Set the tolerance. OptimalStepSizeFunctor g(*this,tableKey,desiredTolerance); // functor for solving log(E(h)/TOL)-1 = 0 /* Run the bracket and solve algorithm - answer is taken to be the lower point of the bracketing interval - this guarantees a tolerance lower than desired */ std::pair<double, double> r = bracket_and_solve_root(g, stepSize, factor, is_rising, tol, it); /* Finally, return the implementation with the desired stepSize*/ par.stepSize = r.first; return UniformLookupTableFactory::Create(tableKey,mp_func,par); } double UniformLookupTableGenerator::error_at_step_size(std::string tableKey, double stepSize) { /* Can be implemented in terms of the Functor used in solving for a specific tolerance, so that is reused. */ OptimalStepSizeFunctor f(*this,tableKey,0); double err = f(stepSize); return err; } void UniformLookupTableGenerator::plot_implementation_at_step_size(std::string tableKey, double stepSize) { /* Can be implemented in terms of the Functor used in solving for a specific tolerance, so that is reused. */ UniformLookupTableParameters par; par.minArg = m_min; par.maxArg = m_max; par.stepSize = stepSize; auto impl = UniformLookupTableFactory::Create(tableKey, mp_func, par); std::cout << "# x func impl" << std::endl; for (double x=impl->min_arg(); x < impl->max_arg(); x+=impl->step_size()/10 ) { std::cout << x << " " << (*(impl->function()))(x) << " " << (*impl)(x) << std::endl; } }
ede97667fdde958acaf2a7fee4c431e006434ca0
40725e823c713d68536980c9a6ed6f66294c8e4d
/PSU_zappy_2018/Map/mappe.cpp
875fd555f2ec6c9655b326a8baa6ceffbadd6d97
[]
no_license
predatorsfr/PSU-tek-2
aa3ce310cf6c6c6296e061dcb0d9ed64341b0316
c6935b3c1191224d1218e85f779d51d8849b153d
refs/heads/master
2020-07-31T17:17:50.565535
2019-09-24T20:29:26
2019-09-24T20:29:26
210,689,825
0
0
null
null
null
null
UTF-8
C++
false
false
2,519
cpp
mappe.cpp
#include "graphe.hpp" #include <vector> #include <string.h> #include <string> #include <cstring> // int ten(char **av) // { // sf::RenderWindow window(sf::VideoMode(1920, 1080), "SFML window"); // sf::Texture texture; // if (!texture.loadFromFile("download.jpeg")) // return EXIT_FAILURE; // sf::Sprite sprite(texture); // std::vector <sf::Sprite> enemies; // std::unique_ptr<Graphe> graphe(new Graphe); // graphe->set_data(std::atoi(av[1]), std::atoi(av[2])); // graphe->map->display(); // // sprite.scale(4,4); // // sprite.setPosition(40, 50); // while (window.isOpen()) // { // sf::Event event; // while (window.pollEvent(event)) // { // if ((sf::Keyboard::isKeyPressed(sf::Keyboard::Escape) == true)) // window.close(); // if (event.type == sf::Event::Closed) // window.close(); // } // window.clear(); // for (int i = 0; i < graphe->map->getY(); i++) { // for (int j = 0; j < graphe->map->getX(); j++) { // if (graphe->map->getChar(i, j) == 'X') { // enemies.push_back(sprite); // if (!enemies.empty()) { // enemies.back().setPosition(i, j); // window.draw(enemies,sprite); // } // } // } // } // // window.draw(sprite); // window.display(); // } // return EXIT_SUCCESS; // } // int main(int ac, char **av) // { // if (ac == 3) // ten(av); // } Map::~Map() { } Map::Map(std::vector<std::string> ptr) : _x(ptr.back().size()), _y(ptr.size() - 1) { map = new char*[_y + 1]; map[_y] = NULL; for (int y = 0 ; y < _y ; y++) { map[y] = new char[_x + 1]; std::strcpy(map[y], ptr.at(y+1).c_str()); } } void Map::create_map() { this->map = new char*[_y + 1]; map[_y] = NULL; for (int i = 0; i < _y; i++) { map[i] = new char[_x + 1]; map[i][_x] = '\0'; } for (int i = 0; i < _x; i++) map[0][i] = 'X'; for (int i = 1; i < _y; i++) { map[i][0] = 'X'; for (int c = 1; c < _x; c++) map[i][c] = 'X'; map[i][_x - 1] = 'X'; } for (int i = 0; i < _x; i++) map[_y - 1][i] = 'X'; } void Map::gen_map() { create_map(); } void Map::display() { for (int i = 0; map[i] != NULL; i++) std::cout << map[i] << std::endl; }
ee6eeb3bd759349a1aa5e8b6bba4537bb5619e73
446a749d41af0008ba557dca6a62c0fbf8fed3ad
/COJ/pumpk.cpp
0f6978c51acf62f263e8266871004dd78b016429
[]
no_license
Sirivasv/ProgrammingChallenges
b8910f869548491a81e5352f72295a6886cc150e
5d9039725b2947f392a179f75896b8a57b4537cb
refs/heads/master
2021-01-12T09:08:15.814557
2020-05-15T21:40:14
2020-05-15T21:40:14
76,768,160
0
0
null
2018-10-13T17:18:12
2016-12-18T07:02:21
C++
UTF-8
C++
false
false
1,531
cpp
pumpk.cpp
#include <bits/stdc++.h> using namespace std; typedef pair<int, int>pii; const int MAXA = 25; const int MAXN = 1300; const pii MU = pii(-1, -1); int A, M; int MN[MAXN], C[MAXA][MAXN], ANS[MAXA]; pii memo[MAXA][MAXN]; pii DP(int ida, int llevas) { if (ida == A) return pii(0, -llevas); if (memo[ida][llevas] != MU) return memo[ida][llevas]; pii res = pii(0, -llevas); int acum = 0; for (int tkn = 0; tkn <= MN[ida]; ++tkn) { if (tkn) acum += C[ida][tkn - 1]; if ((tkn + llevas) > M) break; pii ndp = DP(ida + 1, llevas + tkn); ndp.first += (10 * tkn) - acum; res = max(res, ndp); } return memo[ida][llevas] = res; } void RECON(int ida, int llevas) { if (ida == A) return; if (memo[ida][llevas] == pii(0, -llevas)) return; int acum = 0; for (int tkn = 0; tkn <= MN[ida]; ++tkn) { if (tkn) acum += C[ida][tkn - 1]; if ((tkn + llevas) > M) break; pii ndp = DP(ida + 1, llevas + tkn); ndp.first += (10 * tkn) - acum; if (memo[ida][llevas] == ndp) { ANS[ida] = tkn; RECON(ida + 1, llevas + tkn); return; } } return; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> A >> M; for (int i = 0; i <= A; ++i) for (int j = 0; j <= M; ++j) memo[i][j] = MU; for (int i = 0; i < A; ++i) { cin >> MN[i]; for (int j = 0; j < MN[i]; ++j) cin >> C[i][j]; } pii res = DP(0, 0); RECON(0, 0); cout << res.first << ' ' << (-res.second) << '\n'; for (int i = 0; i < A; ++i) { if (i) cout << ' '; cout << ANS[i]; } cout << '\n'; return 0; }
64dd57ae82db158f305c4e3cdcf4c0a1ec17df9e
2994f5583efdd46b28532f88b297083e3b319a80
/compilador_processing/processing/gramatica_expan.cpp
0d549960483cec074b6a9bf3d9c2aedb8b8d7e18
[]
no_license
luigy-mach/compiladores
7400c15b0bc9031b97b7b012e5f3963dd2268c38
ee246f958451b3178f2e32d4332c49f6b7124aac
refs/heads/master
2020-12-04T10:19:33.670959
2016-12-30T15:35:55
2016-12-30T15:35:55
67,050,669
1
1
null
null
null
null
UTF-8
C++
false
false
2,953
cpp
gramatica_expan.cpp
#include"gramatica_expan.hpp" void gramatica_expan::inicializar(){ leer_archivo(_tabla,ARCHIVO_GRAMATICA); } string gramatica_expan::obtener_estado(string num_reducir){ if(_tabla.find(num_reducir)!=_tabla.end()) return _tabla.find(num_reducir)->second.begin()->first; return STR_ERROR_OBTENER_GRAMATICA; } int gramatica_expan::obtener_estado_num(string num_reducir){ if(_tabla.find(num_reducir)!=_tabla.end()) return stoi(_tabla.find(num_reducir)->second.begin()->second); return -123456; } void gramatica_expan::leer_archivo(TABLA1& t,string archivo){ queue<string> cola_buff; ifstream in(archivo); string buffer = STR_EMPTY; while(getline(in,buffer)){ convertir_a_cola(buffer,STR_SIMBOLO_SEPARACION,cola_buff); //cout<<"........ .."<<buffer<<endl; insertar(t,cola_buff); } //imprimir_tabla(_tabla); } void gramatica_expan::convertir_a_cola(string str,string delimitador,queue<string>& vec){ size_t pos=0; string buff = STR_EMPTY; while((pos=str.find(delimitador))!=string::npos){ buff=str.substr(0,pos); if(pos>0){ //cout<<"..........."<<buff<<endl; vec.push(buff); } str.erase(0,pos+delimitador.length()); } } void gramatica_expan::insertar(TABLA1& t, queue<string>& fila){ string num_fila = fila.front(); fila.pop(); string estado = fila.front(); fila.pop(); FILA1 temp; string num_estados = to_string(fila.size()); temp.insert({estado,num_estados}); //cout<<"###"<<num_fila<<"_"<<estado<<"_"<<num_estados<<endl; t.insert({num_fila,temp}); while(!fila.empty()){ fila.pop(); } } void gramatica_expan::imprimir_tabla(TABLA1& t){ cout<<"------------------------------------------------------------------"<<endl; for(TABLA1::iterator i=t.begin();i!=t.end();i++){ cout<< STR_ESPACIO_SEPARADOR; for(FILA1::iterator j=i->second.begin();j!=i->second.end();j++){ string cuadrito=STR_ESPACIO_SEPARADOR; string::iterator it=cuadrito.begin(); string temp; temp = j->first; cuadrito.replace(it,it+temp.size(),temp); cout<< cuadrito ; } cout<<endl ; break; } for(TABLA1::iterator i=t.begin();i!=t.end();i++){ string tmp=STR_ESPACIO_SEPARADOR; string tmp2=i->first +" -> "; tmp.replace(tmp.begin(),tmp.begin()+tmp2.size(),tmp2); cout<< tmp; for(FILA1::iterator j=i->second.begin();j!=i->second.end();j++){ string cuadrito=STR_ESPACIO_SEPARADOR; string::iterator it=cuadrito.begin(); string temp; for(auto z=j->second.begin();z!=j->second.end();z++){ temp+=*z; } cuadrito.replace(it,it+temp.size(),temp); cout<< cuadrito ; } cout<<endl; } cout<<"------------------------------------------------------------------"<<endl; }
5211f1427267183fc439c87bb2ee7e58c6c71725
785df77400157c058a934069298568e47950e40b
/TnbPtdModel/TnbLib/PtdModel/Models/Wing/No1/Form/MaxCamberLoc/PtdModel_WingFormNo1_MaxCamberLocIO.cxx
7c9cf74adff03b358466d05ee9fa4643d9ad7300
[]
no_license
amir5200fx/Tonb
cb108de09bf59c5c7e139435e0be008a888d99d5
ed679923dc4b2e69b12ffe621fc5a6c8e3652465
refs/heads/master
2023-08-31T08:59:00.366903
2023-08-31T07:42:24
2023-08-31T07:42:24
230,028,961
9
3
null
2023-07-20T16:53:31
2019-12-25T02:29:32
C++
UTF-8
C++
false
false
40
cxx
PtdModel_WingFormNo1_MaxCamberLocIO.cxx
#include <PtdModel_WingFormMakerNo1.hxx>
1b0d807457604ba2f053ca34924375f5093b3457
d2b2f59e3ff929bc3c12fa9f32bac90ad5882958
/code/VirtualGrasp/ShapeAnalysis/Agent/HumanTorso.cpp
8a93023a41e86cb91f793e929b7cee179daebeb5
[]
no_license
jjcao/graspSaliency
27b33bd1c3f7f550a61b6cd3661fed2f315ec38a
7a2fef80c81aca3a808544a4c4de9fbd4d2c8421
refs/heads/master
2020-12-24T05:43:29.260536
2016-11-18T11:17:01
2016-11-18T11:17:01
73,456,937
0
0
null
null
null
null
UTF-8
C++
false
false
761
cpp
HumanTorso.cpp
#include "HumanTorso.h" HumanTorso::HumanTorso( double torsoWidth, double torsoHeight, RigidPart * parent ) { this->width = torsoWidth; this->height = torsoHeight; double thick = torsoWidth * 0.4; pelvis = parent->addChild( new Box(width * 0.7, thick, height * 0.32), "Pelvis" ); middle = parent->addChild( new Box( width * 0.8, thick, height * 0.40 ), "MiddleBack" ); shoulder = middle->addChild( new Box( width, thick, height * 0.29 ), "Sholder" ); //middle->tranlsateAnchor( Vec(0,0,parent->shape->z) ); shoulder->tranlsateAnchor( Vec(0,0,middle->shape->z) ); //pelvis->tranlsateAnchor( Vec(0,0,-pelvis->shape->z) ); pelvis->rotateAnchor(5,180,0); middle->rotateAnchor(5,0,0); shoulder->rotateAnchor(-5,0,0); } void HumanTorso::draw() { }
a1bf1253adc79cc623db1fce726f02a4a1b5e101
6ae52e4249ca54b3c6cd85979b2b2cd14a457dd0
/Offscreen_v2/ProjectMesh2ImageImpl.cpp
1e96c9eb94dd87af9867443cd65aaecc1fde9365
[]
no_license
FenskeQualityMeasures2014/Source
a160254a47cde3f11196047c3f00bc1ef9e7f356
374ee65780c78412b1394754968f12803fdff1f1
refs/heads/master
2021-07-08T03:26:21.737964
2016-11-14T04:14:30
2016-11-14T04:14:30
21,395,980
0
0
null
null
null
null
UTF-8
C++
false
false
3,076
cpp
ProjectMesh2ImageImpl.cpp
/******************************************************************************* ProjectMesh2ImageImpl.cpp: implementation of the offscreen projection of a mesh onto an image. example: LabeledImageA = ProjectMesh2ImageImpl(FaceM, VertexM, CamParamSA, channelModFactor, ... ScreenSizeV, zoomFactor, ZNearFarV) *******************************************************************************/ #include <mex.h> #include <math.h> #include "OffscreenGL.h" #include "OffscreenCommon.h" void getLabeledImages( // input double *FM, int fNum, double *VM, int vNum, const mxArray *CamParamSA, double *ScreenSizeV, int zoomFactor, unsigned int channelModFactor, double *ZNearFarV, // output mxArray *LabeledImageA ) { int imageNum, i; GLuint batchList; mxArray *currentCamParamS; GLubyte *imageBuffer; int bufferDims[3]; unsigned int *LabeledImage; imageBuffer = (GLubyte *) mxMalloc(ScreenSizeV[0] * ScreenSizeV[1] * COLOR_MODULATE_CHANNEL * zoomFactor * zoomFactor); imageNum = mxGetM(CamParamSA); batchList = createDisplayList(FM, fNum, VM, vNum, channelModFactor); printf("Facet Number: %d, Vertex Number: %d\nProjecting images: \n", fNum, vNum); for (i = 0; i < imageNum; i++) { printf(" %d ", i); if (i % 8 == 7) { printf("\n"); } currentCamParamS = mxGetCell(CamParamSA, i); double *imSizeV = mxGetPr(mxGetField(currentCamParamS, 0, "imSizeV")); cameraSetup(currentCamParamS, ZNearFarV[0], ZNearFarV[1], imSizeV[0], imSizeV[1], zoomFactor); drawPatch(batchList, imageBuffer, imSizeV[0], imSizeV[1], zoomFactor); bufferDims[0] = imSizeV[0] * zoomFactor; bufferDims[1] = imSizeV[1] * zoomFactor; mxSetCell(LabeledImageA, i, mxCreateNumericArray(2, bufferDims, mxUINT32_CLASS, mxREAL)); LabeledImage = (unsigned int *) mxGetData(mxGetCell(LabeledImageA, i)); colorDemodulation(imageBuffer, channelModFactor, NULL, imSizeV[0], imSizeV[1], zoomFactor, LabeledImage); } mxFree(imageBuffer); printf("Done\n"); } /* The gateway routine */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int output1Size[1]; double *FM = mxGetPr(prhs[0]); int fNum = mxGetM(prhs[0]); double *VM = mxGetPr(prhs[1]); int vNum = mxGetM(prhs[1]); const mxArray *CamParamSA = prhs[2]; unsigned int channelModFactor = (unsigned int)mxGetScalar(prhs[3]); double *ScreenSizeV = mxGetPr(prhs[4]); double zoomFactor = mxGetScalar(prhs[5]); double *zNearFarV = mxGetPr(prhs[6]); const int *dims; mxArray *LabeledImageA; OffscreenGL offscreenGL((int)(ScreenSizeV[0] * zoomFactor), (int)(ScreenSizeV[1] * zoomFactor)); if (nlhs == 1) { output1Size[0] = mxGetM(CamParamSA); plhs[0] = mxCreateCellArray(1, output1Size); LabeledImageA = plhs[0]; if (offscreenGL.RGB8Setup()) { mexPrintf("OpenGLCanvas setup Successful\n"); getLabeledImages(FM, fNum, VM, vNum, CamParamSA, ScreenSizeV, zoomFactor, channelModFactor, zNearFarV, LabeledImageA); } else { mexPrintf("OpenGLCanvas setup failed\n"); } } }
e903b2d24bd010e8fbd3cef7d24aa18e8fe065b5
a60872e12dc6c99a9e6bd4fa5491d42ffbf255f9
/RayTraceEbtihal/Camera.h
47b3025e52abaafe75cceb08741b46e51099b6fd
[]
no_license
mohi-othman/ray-tracer-cpp-mohi
b62ff534b75e719916fd968a0a50fdec6ec99241
5e93d6349d338bc0d0f8b7fe22214646c39f507b
refs/heads/master
2020-12-24T15:05:58.235067
2012-05-11T21:39:44
2012-05-11T21:39:44
32,093,400
0
0
null
null
null
null
UTF-8
C++
false
false
421
h
Camera.h
//Base class for all camera types #ifndef CAMERA_H #define CAMERA_H #include "View.h" #include "Ray.h" #include "Vector3D.h" class Camera { public: // Function to generate a ray from the camera to the target pixel virtual Ray GenerateRay(Vector3D target)=0; // Function to generate a view based on the camera's settings virtual View GetView(int width, int height, float PixelSize)=0; }; #endif
507d0f4b35ae2cb661ef845e17383d4b789f6fb1
2b33e79699766ee15e1c19399c61f99523e47e17
/Ticket_Booth/Seat.cpp
42433ce7a33eaf37faafd40d47e7fcec88e3f04f
[]
no_license
dakotahm/-GRPZR
558e91088f3d62a8e14d4502aed9bc82063a991b
f34b2fd1b8dbfa927187c6a66e85351090206def
refs/heads/master
2021-01-17T14:05:07.478447
2016-03-31T17:43:05
2016-03-31T17:43:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
356
cpp
Seat.cpp
//need section class #include <iostream> #include "Seat.h" using namespace std; Seat::Seat(string Section, string Row_Name, int Seat_Number) : section(Section), seat_row_name(Row_Name), seat_number(Seat_Number) {} void Seat::Display() const { cout << "Section" << section << "Row " << seat_row_name << " Seat " << seat_number << endl; }
5868273f7dde62df64f28199c7e033e48b5b45db
e1d6417b995823e507a1e53ff81504e4bc795c8f
/gbk/client/Client/GameInterface/Include/GIUISystem.h
6d1ff379a622d878e60df868827e0f0663ec335a
[]
no_license
cjmxp/pap_full
f05d9e3f9390c2820a1e51d9ad4b38fe044e05a6
1963a8a7bda5156a772ccb3c3e35219a644a1566
refs/heads/master
2020-12-02T22:50:41.786682
2013-11-15T08:02:30
2013-11-15T08:02:30
null
0
0
null
null
null
null
GB18030
C++
false
false
6,748
h
GIUISystem.h
/** GIUISystem.h */ #pragma once #include "GIBasicType.h" #include "GINode.h" #include "GIMath.h" #include "GITransferItemSystem.h" /// 聊天模板的最大索引量 enum { TALK_TEMPLATE_NOBODY = 0, TALK_TEMPLATE_OTHER, TALK_TEMPLATE_MYSELF, TALK_TEMPLATE_MAX }; // 过滤类型 enum FILTER_TYPE { FT_NONE = 0, // 无类型 FT_CHAT, // 聊天 FT_ROLE, // 创建人物 FT_NAME, // 命名 FT_STALL, // 摆摊 FT_MAX, }; // 过滤等级 enum FILTER_RANK { FR_NO_MATCH = 0, // 忽略 FR_PART_MATCH, // 部分匹配 FR_FULL_MATCH, // 完全匹配 FR_MAX, }; #define TALK_HELPSTRING_MAX 200 #define TALK_HELPSTRING_KEY "help" /** 角色头顶上的信息板 */ class KYLIN_API tCreatureBoard { public: /** 删除自身 */ virtual VOID Destroy(VOID) = 0; /** 设置在屏幕上的坐标(像素) */ virtual VOID SetPosition(FLOAT nX, FLOAT nY) = 0; /** 显示/隐藏 */ virtual VOID Show(BOOL bShow) = 0; /** 显示/隐藏玩家属性(血条和等级) */ virtual VOID ShowCharAttr(BOOL bShow) = 0; /** 显示/隐藏玩家称号 */ virtual VOID ShowCharTitle(BOOL bShow, INT nType) = 0; /** 设置名字 */ virtual VOID SetElement_Name(LPCTSTR szName) = 0; /** 设置生命值 */ virtual VOID SetElement_HPProgress( INT hp, INT maxHp ) = 0; virtual VOID SetElement_HPProgress( FLOAT hpPercent ) = 0; /** 设置等级 */ virtual VOID SetElement_Level( INT nLevel, INT nType ) = 0; /** 设置称号 */ virtual VOID SetElement_Title(LPCTSTR szName, INT nType = 0) = 0; /** 设置国家标记 */ virtual VOID SetElement_CountryFlag(INT nCountry) = 0; /** 设置队长标记 */ virtual VOID SetElement_LeaderFlag( BOOL bShowj, INT nType ) = 0; /** 设置 pk标记 | 任务提示 */ virtual VOID SetElement_PKFlag( INT nType, INT nState, BOOL bShow ) = 0; /** 设置摆摊上的文字 */ virtual VOID SetElement_SaleText(LPCTSTR szSaleText) = 0; /** 设置是否显示摆摊信息 */ virtual VOID SetElement_SaleSign(BOOL bShow) = 0; /** 设置逻辑对象ID */ virtual VOID SetElement_ObjId(INT nObjId) = 0; // 设置玩家的状态(正常、死亡) virtual VOID SetInfoState( int nState ) = 0; // 设置信息离主角的位置 virtual void SetInfoDistance( float nDistance ) = 0; // 设置玩家头上聊天框里的内容 virtual VOID SetElement_PaoPaoText( LPCTSTR szPaoPao ) = 0; // 得到屏幕位置 virtual fVector2 GetPosition(void) const = 0; // 是否显示 virtual BOOL isShow() = 0; // 显示摆摊状态的信息板 20100527 BLL virtual VOID ShowIsInStall( BOOL bIsMyself ) = 0; }; /** UI系统虚接口 */ class KYLIN_API tUISystem : public tNode { public: // 窗口大小发生改变 virtual VOID OnSizeChange(UINT message, WPARAM wParam, LPARAM lParam) = 0; // 处理输入,如果返回TRUE,则表示ui截获了输入 virtual VOID InjectInput(VOID) = 0; // 文字输入消息 virtual BOOL MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) = 0; //鼠标是否在ui上空 virtual BOOL IsMouseHover(VOID) = 0; //鼠标是否在聊天信息上空 virtual BOOL IsMouseHover_ChatBoard(LONG x, LONG y) = 0; //获得聊天信息里的超链中的信息 virtual STRING getChatBoard_HyplinkContex(LONG x, LONG y) = 0; //创建一个新的角色信息板 virtual tCreatureBoard* CreateCreatureBoard(VOID) = 0; virtual VOID AddNewBeHitBoard( bool bDouble, LPCTSTR szInfo, FLOAT nStartX, FLOAT nStartY, int nType = 0 ,int nMoveType = 0) = 0; //某一组UI是否处于打开中 virtual BOOL IsWindowShow(LPCTSTR szUIName, LPCTSTR szChildName = NULL) = 0; virtual BOOL CloseAllWindow() = 0; //通知UI创建一组UI显示模型 virtual VOID FakeObj_Show(LPCTSTR szWinName, LPCTSTR szName) = 0; //通知UI销毁一组UI显示模型 virtual VOID FakeObj_Close(LPCTSTR szWinName, LPCTSTR szName) = 0; //--- FOR DEBUG virtual VOID Debug_PushChatString(LPCTSTR szName, LPCTSTR szMsg) = 0; virtual VOID Debug_SaveFontTexture(VOID) = 0; //--- FOR DEBUG virtual VOID ChangeDragFlag(bool Flag) = 0; virtual BOOL IsDragFlag(VOID) = 0; //逻辑层添加系统通知信息 virtual STRING ParserString_VarParam(LPCTSTR strID, ... ) = 0; virtual VOID ParserString_NoColor(const STRING& strSrc, STRING& strOut, BOOL bControl = FALSE) = 0; virtual STRING ParserString_NoColor_VarParam(LPCTSTR strID, ... ) = 0; virtual STRING ParserString_NoVarParam(LPCTSTR strID) = 0; virtual STRING ParserString_NoColor_NoVarParam(LPCTSTR strID) = 0; //聊天模板字串的取得 virtual STRING getTalkTemplate(const STRING& strKey, UINT index) = 0; virtual STRING ModifyChatTemplate(const STRING& strTemp, const STRING& strTalker, const STRING& strTarget) = 0; virtual STRING getTalkRandHelpMsg() = 0; //查看当前获取输入的EditBox virtual BOOL IsIMEEditboxActive(LPCTSTR szWinName) = 0; //输入法状态 virtual INT GetCurrentIMEState() = 0; //获取EditBox的文字 virtual STRING getIMEEditboxString(LPCTSTR szWinName) =0; //将一个物品信息传入 virtual bool InjectItemInfo(tTransferItemSystem::Element* pElement) = 0; virtual void OnPushEcsape() = 0; virtual void SetPaoPaoActive( bool bActive ) = 0; virtual bool IsPaoPaoActive() = 0; // virtual UINT OgreColor_CEGUIColor_Limit_Lumination( UINT OgreColor,FLOAT fLumination) = 0; virtual UINT Lumination_OgreColor( UINT OgreColor, INT Lumination ) = 0; virtual INT OgreColor_Lumination( UINT OgreColor ) = 0; //过滤字符串中的非法敏感字符 virtual BOOL CheckStringFilter(const STRING& strIn, const FILTER_TYPE filterType = FT_NONE) = 0; virtual BOOL CheckStringCode(const STRING& strIn, STRING& strOut) = 0; //完全匹配过滤 virtual BOOL CheckStringFullCompare(const STRING& strIn, const STRING& strFilterType = "all", BOOL bUseAllTable = TRUE) = 0; //获取当前的鼠标下面的窗口 virtual STRING GetDebugString(VOID) = 0; //获取当前的鼠标下面的窗口 virtual void OpenWindow(const STRING& winName) = 0; virtual void CloseWindow(const STRING& winName) = 0; virtual void ToggleWindow(const STRING& winName) = 0; virtual bool HasInputFocus() = 0; //添加聊天信息(提高显示聊天信息的效率) virtual bool addChatHistoryMessage(INT msgID,LPCTSTR szWinName, LPCTSTR szMessage, INT nOp = -1, UINT nDisappearTime = 0) =0; virtual VOID ReplaceStringUseFilter(const STRING& strIn, STRING& strOut, FILTER_TYPE filterType = FT_CHAT) =0; virtual std::string string_check_valid(const char* szString) = 0; virtual bool ReloadWindowScript( const STRING& windowName ) =0; virtual VOID UIRenderToggleShow(VOID) =0; KL_DECLARE_DYNAMIC(tUISystem); };
9a5518e2773a63b12d6785692728e172a4b780b4
5d7739bd360a447ee1c7285483d2f37d521fa99e
/Volume 001 (100-199)/174.cpp
ccd9d90c22b87ce549b783be1cbe19436230acf1
[]
no_license
aaafwd/Online-Judge
c4b23272d95a1c1f73cc3da2c95be8087a3d523c
b264f445db2787c5fc40ddef8eb3139adae72608
refs/heads/main
2023-04-02T01:01:26.303389
2021-04-11T14:17:58
2021-04-11T14:17:58
356,840,772
1
0
null
null
null
null
UTF-8
C++
false
false
2,167
cpp
174.cpp
/* @JUDGE_ID: 19899RK 174 C++ "By Anadan" */ // Strategy // Accepted (0.000 seconds with low memory spent) #include <stdio.h> int score[10], c; char programs[10][256], memory[2][2]; int cond(char *&p){ int i = c, j, nt = 0; if (p[0] == 'M') p += 2; else { p += 4; i ^= 1; } p += 4; j = *p++ - '1'; if (*p++ == '#') nt = 1; if (p[0] == 'T'){ p += 5; return ((memory[i][j] == 0) ^ nt); }else if (p[0] == 'C'){ p += 5; return ((memory[i][j] == 1) ^ nt); }else{ p += 4; return ((memory[i][j] == -1) ^ nt); } } int condition(char *&p){ int res = cond(p); while (1){ if (p[0] == 'A'){ p += 3; res &= cond(p); }else if (p[0] == 'O'){ p += 2; res |= condition(p); }else break; } return res; } // Statements: TRADE=0 CHEAT=1 int statement(char *&p){ int ret; if (p[0] == 'T') { p += 5; return 0; } if (p[0] == 'C') { p += 5; return 1; } p += 2; if (condition(p)){ p += 4; ret = statement(p); p += 4; statement(p); }else{ p += 4; statement(p); p += 4; ret = statement(p); } return ret; } void play(int a, int b){ int i, j, k; char *p; memory[0][0] = memory[0][1] = memory[1][0] = memory[1][1] = -1; for (i = 0; i < 10; ++i){ c = 0; p = programs[a]; j = statement(p); c = 1; p = programs[b]; k = statement(p); if (j == 0){ if (k == 0) ++score[a], ++score[b]; else score[a] -= 2, score[b] += 2; }else{ if (k == 0) score[a] += 2, score[b] -= 2; else --score[a], --score[b]; } memory[0][1] = memory[0][0]; memory[0][0] = j; memory[1][1] = memory[1][0]; memory[1][0] = k; } } int main(){ int N = 0, i, j; char *p; while (1){ p = programs[N]; while ((i = getchar()) != '.'){ if (i != ' ' && i != '\n') *p++ = i; } *p = 0; ++N; while ((i = getchar()) == ' ' || i == '\n'); if (i == '#') break; ungetc(i, stdin); } for (i = 0; i < N; ++i) score[i] = 0; for (i = 0; i < N; ++i){ for (j = i + 1; j < N; ++j){ play(i, j); } } for (i = 0; i < N; ++i) printf("%3d\n", score[i]); return 0; } /* @END_OF_SOURCE_CODE */
8ccc97185aa55a4305d4a028aee7960965357b75
cd258436458935352857e94295e448e08511ed8d
/codility/triangle.cc
fb20590be6af6ae730eb1997185c5069c7d0f343
[]
no_license
pmediaandy/bullpen
03b91f1a1364432a544087cd3e55041385a6ea2a
72f769cf567bcd06f87843ec8f4ce608012dba91
refs/heads/master
2020-12-03T00:03:29.108784
2017-05-24T06:58:30
2017-05-24T06:58:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
354
cc
triangle.cc
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; int solution(vector<int> &A) { int i; int N = (int) A.size(); if(N <= 2) return 0; sort(A.begin(), A.end()); for(i = 2; i < N; i++) { if((long long)A[i - 2] + A[i - 1] > A[i]) return 1; } return 0; }
a7f0fabd39df639d8102f31c8f8a32ff735f7728
184157313c7a3ad0da473d4cf9bfef0ac40b6fc1
/test/test_person.cpp
03032429669c3a75fbead802e3236962f3f132fd
[]
no_license
josh-mutian/cs22001-warmup
9dfd19e1bf1a50d48abed1d566274f4ff8239c64
14a574eb3652b70d8c0739a6ed1534557626c2a8
refs/heads/master
2021-01-19T12:56:12.341077
2017-01-26T06:39:55
2017-01-26T06:39:55
78,696,025
0
0
null
null
null
null
UTF-8
C++
false
false
10,401
cpp
test_person.cpp
#include "gtest/gtest.h" #include "person.h" // this class is used for testing public methods in class Person class test_person: public ::testing::Test { protected: Person person; Person recipient; }; // test Person constructor TEST_F(test_person, test_constructor) { //invlid username Person p1("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm", "first", "lastname", "m", 40, "tagline"); EXPECT_TRUE(p1.is_null_person()); //invlid firstname Person p2("username", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm", "lastname", "m", 40, "tagline"); EXPECT_TRUE(p2.is_null_person()); //invlid lastname Person p3("username", "first", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm", "m", 40, "tagline"); EXPECT_TRUE(p3.is_null_person()); //invlid gender Person p4("username", "first", "lastname", "sss", 40, "tagline"); EXPECT_TRUE(p4.is_null_person()); //invlid age Person p5("username", "first", "lastname", "m", 160, "tagline"); EXPECT_TRUE(p5.is_null_person()); //invlid tagline Person p6("username", "first", "lastname", "m", 40, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm"); EXPECT_TRUE(p6.is_null_person()); Person p7("username", "first", "lastname", "m", 40, "tagline"); EXPECT_STREQ(p7.get_username().c_str(), "username"); EXPECT_STREQ(p7.get_firstname().c_str(), "first"); EXPECT_STREQ(p7.get_lastname().c_str(), "lastname"); EXPECT_STREQ(p7.get_tagline().c_str(), "tagline"); EXPECT_STREQ(p7.get_gender().c_str(), "m"); EXPECT_EQ(p7.get_age(), 40); } // test get_username and set_username TEST_F(test_person, test_username) { //user name too long EXPECT_FALSE(person.set_username("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm")); //user name not alphanumerical EXPECT_FALSE(person.set_username("aaaa()")); //user name first digit is digit EXPECT_FALSE(person.set_username("2aabb")); //user name is empty EXPECT_FALSE(person.set_username("")); //exactly 64 characters will be accepted EXPECT_TRUE(person.set_username("a2222222ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl")); EXPECT_STREQ(person.get_username().c_str(), "a2222222ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl"); //invalid input should not change username EXPECT_FALSE(person.set_username("aaaa()")); EXPECT_STREQ(person.get_username().c_str(), "a2222222ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl"); } // test get_firstname and set_firstname TEST_F(test_person, test_firstname) { //first name too long EXPECT_FALSE(person.set_firstname("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); //first name not alphabetical EXPECT_FALSE(person.set_firstname("aaaa2")); //empty will be accepted EXPECT_TRUE(person.set_firstname("")); EXPECT_STREQ(person.get_firstname().c_str(), ""); //invalid input should not change firstname EXPECT_FALSE(person.set_firstname("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); EXPECT_STREQ(person.get_firstname().c_str(), ""); //exactly 64 characters will be accepted EXPECT_TRUE(person.set_firstname("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); EXPECT_STREQ(person.get_firstname().c_str(), "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); } // test get_lastname and set_lastname TEST_F(test_person, test_lastname) { //last name too long EXPECT_FALSE(person.set_lastname("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); //last name not alphabetical EXPECT_FALSE(person.set_lastname("aaaa2")); //empty will be accepted EXPECT_TRUE(person.set_lastname("")); EXPECT_STREQ(person.get_lastname().c_str(), ""); //invalid input should not change original lastname EXPECT_FALSE(person.set_lastname("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); EXPECT_STREQ(person.get_lastname().c_str(), ""); //exactly 64 characters will be accepted EXPECT_TRUE(person.set_lastname("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); EXPECT_STREQ(person.get_lastname().c_str(), "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); } /**you may need to write more test functions. * What we provide here is just for your reference */ // test get_age and set_age // test_person is the name of class your inherit from the base Test class // test_age is the name of this test case, which will show up in the test // results // make sure you cover every subroutine and branches // here we test edge cases of invalid ages // also, we test the get_age() method // avoid using ASSERT_FALSE here; if there is something wrong in ASSERT, // it will abort the whole testing which will hinder the grading process TEST_F(test_person, test_age) { EXPECT_FALSE(person.set_age(-1)); EXPECT_FALSE(person.set_age(300)); EXPECT_TRUE(person.set_age(0)); EXPECT_EQ(person.get_age(), 0); //invalid input should not change original age EXPECT_FALSE(person.set_age(128)); EXPECT_TRUE(person.set_age(0)); EXPECT_TRUE(person.set_age(127)); EXPECT_EQ(person.get_age(), 127); } // test get_tagline and set_tagline TEST_F(test_person, test_gender) { //any gender other than "m" or "f" will invalid EXPECT_FALSE(person.set_gender("")); EXPECT_FALSE(person.set_gender("mf")); EXPECT_TRUE(person.set_gender("m")); EXPECT_STREQ(person.get_gender().c_str(), "m"); //invalid input should not change original gender EXPECT_FALSE(person.set_gender("bh")); EXPECT_STREQ(person.get_gender().c_str(), "m"); EXPECT_TRUE(person.set_gender("f")); EXPECT_STREQ(person.get_gender().c_str(), "f"); } // test get_tagline and set_tagline TEST_F(test_person, test_tagline) { //tagline is too long (at 513 characters) EXPECT_FALSE(person.set_tagline("513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513characters")); EXPECT_TRUE(person.set_tagline("1qz*3")); EXPECT_STREQ(person.get_tagline().c_str(), "1qz*3"); //empty will be accepted EXPECT_TRUE(person.set_tagline("")); EXPECT_STREQ(person.get_tagline().c_str(), ""); //invalid input should not change original tagline EXPECT_FALSE(person.set_tagline("513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513characters")); EXPECT_STREQ(person.get_tagline().c_str(), ""); } // test get_info and set_info TEST_F(test_person, test_info) { EXPECT_TRUE(person.set_info("validusername", "validfirstname", "validlastname", 30, "f", "validtagline")); //test get_info EXPECT_STREQ(person.get_info().c_str(), "username: validusername, firstname: validfirstname, lastname: validlastname, age: 30, gender: f, tagline: validtagline"); //verify that valid entries of set_info could go through even if other entries are invalid EXPECT_FALSE(person.set_info("username", "*illegalfirstname", "lastname", 20, "m", "tagline")); EXPECT_STREQ(person.get_username().c_str(), "username"); EXPECT_STREQ(person.get_lastname().c_str(), "lastname"); EXPECT_STREQ(person.get_tagline().c_str(), "tagline"); EXPECT_EQ(person.get_age(), 20); //verify that all types of invalid entries can be recognized EXPECT_FALSE(person.set_info("*illegalusername", "firstname", "lastname", 20, "m", "tagline")); EXPECT_FALSE(person.set_info("username", "firstname", "*illegallastname", 20, "m", "tagline")); EXPECT_FALSE(person.set_info("username", "firstname", "lastname", 20, "m", "513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513charactersintotal513characters")); EXPECT_FALSE(person.set_info("username", "firstname", "lastname", 128, "m", "tagline")); EXPECT_FALSE(person.set_info("username", "firstname", "lastname", 25, "notagender", "tagline")); //test get_info EXPECT_STREQ(person.get_info().c_str(), "username: username, firstname: firstname, lastname: lastname, age: 25, gender: m, tagline: tagline"); } // test send_msg and read_msg // to make your code shorter, we suggest combining these tests together; you // can also separate them into several test cases TEST_F(test_person, test_msg) { //eye ball testing person.send_msg(recipient, "test_message1\n"); cout << "EXPECT: test_message1\n"; cout << " GET: "; recipient.read_msg(); cout << "EXPECT: Inbox is empty. Cannot read any message.\n"; cout << " GET: "; recipient.read_msg(); person.send_msg(recipient, "test_message2\n"); person.send_msg(recipient, "test_message3\n"); cout << "EXPECT: test_message2\n"; cout << " GET: "; recipient.read_msg(); cout << "EXPECT: test_message3\n"; cout << " GET: "; recipient.read_msg(); cout << "EXPECT: Inbox is empty. Cannot read any message.\n"; cout << " GET: "; recipient.read_msg(); }
d833a349cbb1a46bee196be27ca1a3f77c8c0257
58278f7da1c8ce95960b00e7982fc0119686d559
/main.cpp
10456ec2039c0e0dde2092e80bc0d7e64e4861e7
[]
no_license
Rhaypapenfuzz/Calendar-Cpp-
6cc8b2ec91c7a60ab6517c1a0003c38703e805c1
2b2c2cd0091623212fadd2a4d16ed3f2bd0bd7da
refs/heads/master
2020-04-01T15:27:07.884464
2018-10-16T23:39:30
2018-10-16T23:39:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,876
cpp
main.cpp
//My Simple Calendar #include <iostream> #include <string> #include <fstream> using namespace std; int getYear(); int getStartingDay(); void printHeading(int); string readMonthName(); int readNumDays(); int printMonth(int,int,string); void formatting(int); int year, numOfDays, startDate, lastDay; string monthName; //const string pathfile = "infile.txt"; ifstream infile; int main() { getYear(); getStartingDay(); printHeading(year); readMonthName(); infile.close(); return 0; } int getYear() { cout<<"Enter the Year:\n"; cin>>year; return year; } int getStartingDay() { cout<<"Enter the start date <0 = Sun, 1 = Mon, " <<"2 = Tues,\n3 = Wed, 4 = Thurs, 5 = Fri, 6 = Sat>:\n"; cin>>startDate; return startDate; } void printHeading(int year) { cout<<"\t\tYEAR -- "<< year <<"\n\n\n"; } string readMonthName() { int count = 0; infile.open("infile.txt"); while(count<12) { count++; infile >> monthName; printMonth(startDate, readNumDays(),monthName); } return monthName; } int readNumDays() { infile>>numOfDays; return numOfDays; } int printMonth(int firstDay,int numOfDays,string monthName) { lastDay = (startDate + numOfDays)%7; cout<<"\t\t"<< monthName<<endl <<"Sun:\tMon:\tTue:\tWed:\tThu:\tFri:\tSat:"<<endl; formatting(firstDay); startDate = lastDay; //daysLeft= (startDate + numOfDays)%7; for(int date=1;date<=numOfDays;date++) { if(date>1 && (date+firstDay)%7 == 1) { cout<<endl; cout<< date <<"\t"; } else { cout<< date <<"\t"; } } cout<<"\n\n"; return lastDay; } void formatting(int startDate) { switch(startDate) { case 1: cout<<"\t"; break; case 2: cout<<"\t\t"; break; case 3: cout<<"\t\t\t"; break; case 4: cout<<"\t\t\t\t"; break; case 5: cout<<"\t\t\t\t\t"; break; case 6: cout<<"\t\t\t\t\t\t"; break; default: break; } }
798615aa058fba3731a65898ef4b2c7b5cad2491
0907eefbe79af3bebc4cf96f449c16cbca5c6b27
/Libs/Core/Code/midasProgressReporter.cxx
596afca0c65f1e309384559d59f4d935f3363fed
[ "Apache-2.0" ]
permissive
midasplatform/MidasClient
04ca5595a20787ed145b30c53de54e08327bcb17
728d4a5969691b54b7d0efd2dbad5a4df85d1a0e
refs/heads/master
2021-04-26T22:10:54.785523
2018-03-06T06:51:04
2018-03-06T06:51:04
124,033,172
0
0
null
null
null
null
UTF-8
C++
false
false
1,334
cxx
midasProgressReporter.cxx
/****************************************************************************** * Copyright 2011 Kitware Inc. * * 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. *****************************************************************************/ #include "midasProgressReporter.h" midasProgressReporter::midasProgressReporter() : m_MaxCount(0), m_MaxTotal(0), m_Total(0), m_Unit("B") { } midasProgressReporter::~midasProgressReporter() { } void midasProgressReporter::SetMaxCount(int maxCount) { m_MaxCount = maxCount; } void midasProgressReporter::SetMaxTotal(double maxTotal) { m_MaxTotal = maxTotal; } void midasProgressReporter::ResetOverall() { m_Total = 0; } void midasProgressReporter::SetUnit(const std::string& unit) { m_Unit = unit; } std::string midasProgressReporter::GetUnit() { return m_Unit; }
cb68b6937d3328743178d981b4044d8ba0950da1
9fca214e01113180f49d603e014894ad2abd0f66
/src/cv/common/MatrixOperator.cpp
67f02cf2b0019ab092e49adbf6de268e9ace3f0f
[ "Apache-2.0" ]
permissive
boselor/slc
57168f1d74ecbfbcfe4648d7c67fde9d1717be41
a1fd53da3f180c4062cac7083b444b438d777d26
refs/heads/develop
2023-02-20T05:12:04.615913
2021-01-19T12:37:43
2021-01-19T12:37:43
330,430,997
0
0
Apache-2.0
2021-01-17T16:21:32
2021-01-17T16:09:33
C++
UTF-8
C++
false
false
772
cpp
MatrixOperator.cpp
// // Created by xiaoyong on 2021/1/1. // #include <cv/common/MatrixOperator.h> namespace slc{ MatrixOperator::MatrixOperator() {} MatrixOperator::~MatrixOperator() {} MatrixOperator MatrixOperator::load(cv::Mat matrix) { this->entity = matrix; return *this; } MatrixOperator MatrixOperator::show(EString title, int waitKey, int width, int height, bool openGL) { cv::namedWindow(title.toStdString(),cv::WindowFlags::WINDOW_NORMAL); cv::resizeWindow(title.toStdString(), width <= 0? this->entity.cols: width, height <= 0 ?this->entity.rows: height); cv::moveWindow(title.toStdString(), 100, 0); cv::imshow(title.toStdString(),this->entity); cv::waitKey(waitKey); return *this; } }
9c9a1b0ed711402f5aa2af6954530ee5ce0a335c
8568610480330eef8e5d3cec3e7c9faf6c244364
/BME_Datalogger/Second_Derivative.ino
ce2e5b0fd8955171b26e845241905c825f2c68ac
[ "MIT" ]
permissive
steflayanto/Plasma_Payload_Controller
ad8361e29cc5f619717f9665ce98b392edb873a6
2a9f299327f6771ff1e7d9c0282c78b381ee64b4
refs/heads/master
2020-04-19T13:39:36.067282
2019-06-15T00:54:53
2019-06-15T00:54:53
168,223,146
2
3
MIT
2019-01-29T22:14:45
2019-01-29T20:25:58
C++
UTF-8
C++
false
false
1,462
ino
Second_Derivative.ino
float rightInput = 0, leftInput = 0, centralInput = 0; // Store the data #define DATA_STORAGE 9 float secDeriData[DATA_STORAGE]; int isFull = 0; /* * @param: newValue, the new altitude value * Update the new value to the storage(use shift * for better value obtaining) */ void updateStorage(float newValue) { for (int i = 1; i <= DATA_STORAGE - 1; i++) { *(secDeriData + (DATA_STORAGE - i)) = *(secDeriData + (DATA_STORAGE - (i+1))); } *secDeriData = newValue; isFull ++; return; } /* @para: Time interval of time difference Global parameters: LeftInput, RightInput, CentralInput Estimation function of second derivative using Taylor Expansion Error EstimatedL O(dt^3) */ float secondDerivative(float tempInterval) { // Serial.print(secDeriData[0]); // Serial.print('\t'); // Serial.print(leftInput); // Serial.print('\t'); // Serial.print(centralInput); // Serial.print('\t'); // Serial.print(rightInput); // Serial.println(); return (leftInput - (2 * centralInput) + rightInput) / (tempInterval * tempInterval); } /* * Update the value that is put in; * If the data is full, start using the value in storage */ void updateInputs() { if(isFull < 9) { leftInput = centralInput; centralInput = rightInput; rightInput = secDeriData[0]; } else { leftInput = secDeriData[DATA_STORAGE - 1]; centralInput = secDeriData[int(DATA_STORAGE/2)]; rightInput = secDeriData[0]; } return; }
88cfdb34fc7faeb22f5d5e2e35959191eec34222
ed2cd3d6b3475cde90b1dda95eb03c859517c71a
/Student_Cuda_Image/src/cpp/core/07_Convolution/moo/host/ConvolutionMOO.h
c212609233d3a45296b63b2e46251d48d15ce42a
[]
no_license
jcornaz/hesso.gpu.exercices
926473089d096210b2538da0c76ec69f67e0794d
5de3288338f963e12d5c32d95d372834f57923d5
refs/heads/master
2021-01-21T06:52:08.018923
2018-04-04T11:48:23
2018-04-04T11:48:23
91,589,076
0
0
null
null
null
null
UTF-8
C++
false
false
795
h
ConvolutionMOO.h
#ifndef CONVOLUTION_MOO_H_ #define CONVOLUTION_MOO_H_ #include "Animable_I.h" #include "CVCaptureVideo.h" class ConvolutionMOO: public Animable_I { public: ConvolutionMOO(string videoPath, float* ptrKernel); ~ConvolutionMOO(); /** * Call periodicly by the api */ virtual void process(uchar4* ptrDevPixels, int w, int h); /** * Call periodicly by the api */ virtual void animationStep(); virtual float getAnimationPara(); virtual string getTitle(); virtual int getW(); virtual int getH(); private: // Inputs int t; uchar4** ptrDevImages; uchar4** ptrDevImagesOutputs; int** ptrDevMins; int** ptrDevMaxs; int nbDevices; CVCaptureVideo* videoCapter; // Tools dim3 dg; dim3 db; }; #endif
4306baae28a8334d08104a3a120bcf6b1733dd0d
dc8da3d51a5556c4435ac861a8e1d54348d2746c
/GIS/GIS.h
cd5ba63e1ab445621e873c57091144da6be80603
[]
no_license
Udironen/Advanced-Topics-in-Programming
6bcc8d335925215213761b1ba170488e54e3b7ea
57cfd0ed6e91a037a3a1ef8af4a7584de537e226
refs/heads/main
2023-03-19T02:11:06.315447
2021-03-11T14:23:25
2021-03-11T14:23:25
339,782,802
1
0
null
null
null
null
UTF-8
C++
false
false
15,364
h
GIS.h
#pragma once #include "rapidjson/document.h" // rapidjson's DOM-style API #include "rapidjson/prettywriter.h" // for stringify JSON #include "Entity.h" #include "Junction.h" #include "Way.h" #include "POI.h" #include "GridWay.h" #include "GridEntity.h" #include "../Common/GISNamedTypes.h" #include "../Common/CoordinatesMath.h" #include "IdEntityMap.h" #include "../Common/Restrictions.h" #include "../Common/AbstractGIS.h" #include <cstdio> #include <iostream> #include <fstream> #include <typeinfo> #include <cstdlib> #include <vector> #include <string> #include <iterator> #include <utility> #include <optional> #include <algorithm> #include <stdexcept> #include <memory> #include "../Common/GISRegistration.h" using namespace rapidjson; class GIS_313452542 : public AbstractGIS { static constexpr size_t len_rand_str = 10; static constexpr size_t num_of_iterations = 10; //container for std::size_t loadMapFile(const std::string& filename); std::unordered_map<EntityId, Coordinates, IDhash> juncidCoorMap; //container for std::size_t saveMapFile(const std::string& filename); IdEntityMap idEntityMap; //container for getEntities(const std::string& search_name) std::unordered_map<std::string, std::vector<EntityId>> nameIDvecMap;//id vector for the whole GIS //container for getEntities(const std::string& search_name, // const Coordinates&, Meters radius) GridEntity grid; //container for getWayClosestPoint GridWay grid_way; //container for getWaysByJunction std::unordered_map<EntityId, std::unordered_set<EntityId, IDhash>, IDhash> juncId_waysId_map; //---------------------------functions for loadMapFile--------: //if ent is valid, insert ent to the GIS and return true //else, return false bool insertEntityToGIS(std::shared_ptr<Entity>& ent); //insert pair {name, id} to nameIDvecMap according to the iterator seearch void insertToNameIdvecMap(const std::unordered_map<std::string, std::vector<EntityId>>::iterator& search, const std::string& name, const EntityId id); //insert {juncID, wayID} to juncId_waysId_map void insertTojuncIdWaysIDMap(const EntityId& juncID, const EntityId& wayID); //insert ent to idEntityMap according to ent type void insertToIdEntityMap(std::shared_ptr<Entity> ent); //generates a random string of length length std::string random_string(size_t length) const; //loading the GIS with vector of pointers of entities entitys and and updates idVec with the id of the entities void loadEntities(std::vector<std::shared_ptr<Entity>>& entitys, std::vector<EntityId>& idVec); //print error msg to screen. void printError(std::string error) const; // Parse a JSON text string to a document return 1 if success and else return 0; int createDocument(const std::string& filename, rapidjson::Document& document); //check validity of entities before inserting to gis bool validGeomtry(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validAccessibility(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validTypeGeomtry(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validRadius(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validCircleCoor(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validFrom(Value::ConstValueIterator itr, std::string type, std::string name) const; //check validity of entities before inserting to gis bool validTo(Value::ConstValueIterator itr, std::string type, std::string name) const; //check validity of entities before inserting to gis bool validDirection(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validSpeedLimit(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validtollRoad(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validCurves(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validRestricted(Value::ConstValueIterator itr, std::string name) const; //check validity of entities before inserting to gis bool validCoordinates(Value::ConstValueIterator itr, std::string type, std::string name) const; //check validity of entities before inserting to gis bool validName(Value::ConstValueIterator itr, std::string type) const; //check validity of entities before inserting to gis bool validCategoryTag(Value::ConstValueIterator itr, std::string type, std::string name, std::set<std::string>& category_tags) const; //check validity of entities before inserting to gis bool validDescription(Value::ConstValueIterator itr, std::string type, std::string name, std::string& description) const; //check validity of entities before inserting to gis bool validId(Value::ConstValueIterator itr, std::string type, std::string name, std::string& id) const; //check validity of entities before inserting to gis bool validType(Value::ConstValueIterator itr) const; // if itr points to a valid junction, insert pointer to junction to entities vector //id: junction id //name: junction name //description: junction description //category_tags: junctions category tags void insertJunction(std::vector<std::shared_ptr<Entity>>& entities, const Value::ConstValueIterator& itr, const std::string& id, const std::string& name, const std::string& description, const std::set<std::string>& category_tags); // if itr points to a valid way, insert pointer to way to entities vector //id: way id //name: way name //description: way description //category_tags: way category tags void insertWay(std::vector<std::shared_ptr<Entity>>& entities, const Value::ConstValueIterator& itr, const std::string& id, const std::string& name, const std::string& description, const std::set<std::string>& category_tags); // if itr points to a valid POI, insert pointer to POI to entities vector //id: POI id //name: POI name //description: POI description //category_tags: POI category tags void insertPOI(std::vector<std::shared_ptr<Entity>>& entities, const Value::ConstValueIterator& itr, const std::string& id, const std::string& name, const std::string& description, const std::set<std::string>& category_tags); //insert all valid entities from the rapidjson::Document document to a vector of pointers of entities void createEntityVector(rapidjson::Document& document, std::vector<std::shared_ptr<Entity>>& entities); //---------------------------functions for saveMapFile--------: //just for get entities from save map function void getJunctions(std::vector<Junction>& junctions); void getWays(std::vector<Way>& ways); void getPOIs(std::vector<POI>& pois); //writing to rapidjson file void insertKeyString(const char* key, std::string val, PrettyWriter<StringBuffer>& writer); //writing to rapidjson file void insertSharedField(const std::unique_ptr<Entity> ent, PrettyWriter<StringBuffer>& writer); //writing to rapidjson file void insertJunctionObject(const Junction& junc, PrettyWriter<StringBuffer>& writer); //writing to rapidjson file void insertWayObject(const Way& way, PrettyWriter<StringBuffer>& writer); //writing to rapidjson file void insertPOIObject(const POI& poi, PrettyWriter<StringBuffer>& writer); //---------------------------functions for getEntities-----------------------------------------------------------: //check if point is inside the circle bool ispointInCircle(const Circle& circle, const Coordinates& point) const; //check if *ent is inside the circle that defined by center and radius bool isEntityInCircle(const std::shared_ptr<Entity> p_ent, const Coordinates& center, Meters radius) const; //check if *junc is inside the circle that defined by center and radius bool isJunctionInCircle(const Junction* junc, const Coordinates& center, Meters radius) const; //check if poi is inside the circle that defined by center and radius bool isPOIInCircle(const POI& poi, const Coordinates& center, Meters radius) const; //check if *way is inside the circle that defined by center and radius bool isWayInCircle(const Way* way, const Coordinates& center, Meters radius) const; //---------------------------functions for getWayClosestPoint-----------------------------------------------------------: //find all the ways-id inside the circle that defined by coordinates and radius and store them in waysId_vec //coordinates: the center of the circle we are searching in //radius: the radius of the circle we are searching in //waysId_vec: the vector of id-s of ways in the circle, will be updated with the relevant id-s void getWays(const Coordinates& coordinates, const Meters radius, std::vector<EntityId>& waysId_vec) const; //check if id is the EntityId of a way that is closer to coordinates than the current closest_id. //if so, it will update closest_coor, closest_id, closest_dist. void checkIfCloser(const Coordinates& coordinates, const EntityId& id, std::pair<Coordinates, std::size_t>& pair_coords_segment, EntityId& closest_id, Meters& closest_dist) const; //return true if way_id is a EntityId of a way that does not fall to the restrictions of res. bool isWayNOTRestricted(const EntityId& way_id, const Restrictions& res) const; //return true if way_id is a EntityId of a way that fall to the restrictions of res. bool isWayRestricted(const EntityId& way_id, const Restrictions& res) const; //remove all the restricted ways void removeRestrictedWays(std::vector<EntityId>& waysId, const Restrictions& res) const; //---------------------------functions for getEntityClosestPoint-----------------------------------------------------------: //the function shall get *entity and Coordinates //return the closest Coordinates, on entity’s geometry, to the provided Coordinates. Coordinates getEntityClosestPoint(const std::shared_ptr<Entity> ent, const Coordinates coordinats)const; //the function shall get POI and Coordinates //return the closest Coordinates, on POI’s geometry, to the provided Coordinates. Coordinates getPOIClosestPoint(const POI& poi, const Coordinates& coordinats) const; //the function shall get Way and Coordinates //return the closest Coordinates, on way, and segment, to the provided Coordinates. std::pair<Coordinates, std::size_t> getWayClosestPoint(const Way& way, const Coordinates& coordinats) const; //print EntityIDMap //void printEntityIDMap() const; //print NameIdVecMap void printNameIdVecMap() const; //print grid void printGrid() const; // Privte field //prints all containers void print() const;//testing //print ent according to its type void printEnt(Entity* ent) const;//testing public: ~GIS_313452542() = default; void printEntityIDMap() const; // the function clears all data from the system and returns the number of entities that were cleared std::size_t clear(); //the function loads a map file and returns a vector of all the EntityIds that were loaded (either Ids that //appeared in file or generated) in the exact order as the objects that appeared in the file //- in case the system had existing data, the data loaded from file is ​added​ to the existing data //- in case entityId from file exists already the old data related to this id is ​replaced​ with the new data //- in case an entity in file doesn’t have an Id, a new Id would be generated for it automatically std::vector<EntityId> loadMapFile(const std::string& filename); //the function saves all data into a map file and returns the number of entities that were saved, //the saved entities must include their Ids std::size_t saveMapFile(const std::string& filename); // the function returns a vector of EntityIds for all entities that match the search_name // all exact matches (case sensitive) shall be first in the vector // right after shall ​optionally​ appear “partial matches”, in any order (e.g. case insensitive match, matching // based on the longer description, match based on the category tags etc. partial match may work // differently when the search is coordinates based or not - note: partial match implementation is not // mandatory, however it may grant you a bonus. // To qualify for bonus you must include in your submission zip a folder named ​bonus.partial_search,​ // that contains ​three​ items: // - partial_search.txt: ​explaining what you did and why qualify for bonus - include where code handels this exceptional partial search // - mapFile.json​ with 10-20 entities // - A file named: partial_search_test​.cpp ​that includes a google test that ​passes​ and // demonstrates your exceptional search std::vector<EntityId> getEntities(const std::string& search_name)const; // same as above, but restricted to a search area of the given circle std::vector<EntityId> getEntities(const std::string& search_name, const Coordinates& coordinates, Meters radius); //the function shall get Coordinates and return the closest Coordinates of //a Way (the Coordinates may be a point on a the way that is closest to the //given Coordinates) and the EntityId of this way, and the segment std::tuple<Coordinates, EntityId, std::size_t> getWayClosestPoint( const Coordinates& coordinates) const; //The function shall get EntityId of a Junctionand return a vector of Ids //of all the ways that start at this junction and those which end at this junction //and are bidirectional. //If the given Id is not known or is not of a junction the function shall return an empty vector std::vector<EntityId> getWaysByJunction(const EntityId& junctionId) const; //The function shall get EntityId of a Way and return the Way itself. //In case the id does not represent a valid way throw an exception. //const Way& getWay(const EntityId& wayId) const; const AbstractWay& getWay(const EntityId& way_id) const; //The function shall get Coordinatesand Restrictions and return the closest Coordinates //along a Way that complies to the restrictions provided and the EntityId of this way, and the segment. std::tuple<Coordinates, EntityId, std::size_t> getWayClosestPoint( const Coordinates&, const Restrictions& res) const; //the function shall get EntityId and Coordinates // if the Id is not known, the function returns an empty optional // otherwise, return the closest Coordinates, on entity’s perimeter, to the provided Coordinates. // (the Coordinates shall be a point on a the entity’s geometry that is closest to the given Coordinates) std::optional<Coordinates> getEntityClosestPoint( const EntityId& id, const Coordinates& coordinates) const; };
3ff1e33d246abdb61a08330925318f62bb75721d
4bccb0950c507cca0b136f73142c978d1efec09c
/combinatorics.cpp
dc46d9bdd860965d6105fabb4e8a70d98aac4e30
[]
no_license
doanphuduc/LTTS
280c5dd853d294818ed36ff28ad6f2be5f55504a
7294f3235eedecfa34adb5d9984b145c03cdd860
refs/heads/master
2023-04-14T10:23:50.851121
2021-04-23T16:32:58
2021-04-23T16:32:58
357,955,553
0
0
null
null
null
null
UTF-8
C++
false
false
606
cpp
combinatorics.cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; int c[N][N]; int C(int k, int n) { if (k > n) return 0; if (k == 0 || k == n) return 1; if (c[k][n] != -1) return c[k][n]; return c[k][n] = C(k, n - 1) + C(k - 1, n - 1); // Hạ chỉ số dưới. } int fact[N]; int main() { // C(k, n) memset(c, -1, sizeof c); // nhớ memset -1 cout << C(10, 20) << '\n'; fact[0] = 1; for (int i = 1; i < N; ++i) fact[i] = fact[i - 1] * i; // A(k, n) = C(k, n) * fact[k] cout << C(2, 3) * 2 << '\n'; return 0; }
31f6581981767072422d21a453066a94581c9141
aade1e73011f72554e3bd7f13b6934386daf5313
/Contest/WorldFinals/2015/I.cpp
cee1dda636baaa5cb5f8193e0b6544a8fc08c034
[]
no_license
edisonhello/waynedisonitau123
3a57bc595cb6a17fc37154ed0ec246b145ab8b32
48658467ae94e60ef36cab51a36d784c4144b565
refs/heads/master
2022-09-21T04:24:11.154204
2022-09-18T15:23:47
2022-09-18T15:23:47
101,478,520
34
6
null
null
null
null
UTF-8
C++
false
false
957
cpp
I.cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, w, u, v, t1, t2; cin >> n >> w >> u >> v >> t1 >> t2; set<pair<double, double>> no; no.insert(make_pair(-10000000, t1)); no.insert(make_pair(t2, 10000000)); for (int i = 1; i <= n; ++i) { char c; cin >> c; int m; cin >> m; for (int j = 1; j <= m; ++j) { int l, p; cin >> l >> p; if (c == 'E') p *= -1; auto np = make_pair((double)p / u - (double)w / v * i, (double)(p + l) / u - (double)w / v * (i - 1)); no.insert(np); } } double now = -5000000; double mx = 0; for (auto p : no) { if (p.first <= now) now = max(now, p.second); else { mx = max(mx, p.first - now); now = p.second; } } cout << fixed << setprecision(10) << mx << endl; }
757ad2ad7971d6a1d4ddfa73ca6475fcd0d23af8
d2dbd661474fa8660a18626a84289b9c1f95b49d
/iEngine/iEngine/Predicate.cpp
ae7f03904c79e75645debf01d463a19b0b79f4c6
[]
no_license
xxfast/iEngine
e40c60a54fe72beef883b0adac81903410a9483b
06f64b81fc972cf651b56984d13174a6862da3bb
refs/heads/master
2016-09-12T20:17:41.672678
2016-05-26T17:10:15
2016-05-26T17:10:15
57,947,849
1
0
null
2016-05-26T17:13:27
2016-05-03T06:50:56
C++
UTF-8
C++
false
false
1,973
cpp
Predicate.cpp
// Predicate.cpp // iEngine // // Created by Ian Adrian Wisata, Isuru Kusumal Rajapakse on 5/4/16. // Copyright © 2016 Isuru Kusumal Rajapakse. All rights reserved. // #include <sstream> #include "Predicate.h" #include "Utilities.h" using namespace std; //Predicate constructor Predicate::Predicate() { fLVal=""; fRVal=""; fConnective=NILL; } //Predicate constructor Predicate::Predicate(Variable aLeftVariable, Variable aRightVariable, Connective aConnective) { fLVal = Utilities::stripSpaces(aLeftVariable); fRVal = Utilities::stripSpaces(aRightVariable); fConnective = aConnective; } //Check whether a predicate is a Literal bool Predicate::isLiteral() const { return ((fConnective==NILL) || (fConnective==NOT)) && ((fRVal=="")||(fLVal=="")); } //Check whether a predicate is horn bool Predicate::isHorn() const { return (!(isLiteral()) && (fConnective == IMPLY)); } Variable Predicate::getLiteral() const { return (fLVal!="")?fLVal:fRVal; } //Returns a vector of variables from predicate. vector<Variable> Predicate::getVariables() const { vector<Variable>* temp = new vector<Variable>; if (fLVal!="") temp->push_back(fLVal); if (fRVal!="") temp->push_back(fRVal); return *temp; } //Returns the left variable of a predicate Variable Predicate::getLeft() const { return fLVal; } //Returns the right variable of a predicate Variable Predicate::getRight() const { return fRVal; } //Returns the connective of a predicate Connective Predicate::getConnective() const { return fConnective; } ostream& operator<<(ostream& aOStream ,Predicate& aPredicate) { aOStream << aPredicate.getLeft() << Utilities::connectiveToString(aPredicate.getConnective()) << aPredicate.getRight(); return aOStream; } bool operator==(const Predicate& aLHS ,const Predicate& aRHS) { return (aLHS.getLeft()==aRHS.getLeft()) && (aLHS.getRight()==aRHS.getRight()) && (aLHS.getConnective()==aRHS.getConnective()); }
0fcb0daca57fe3a2779e56d52ce2d310ca36df16
95cb0e38d8272759f2e177cf53d8204aab481af0
/Command/undo/DimmerLightOnCommand.hpp
f1be1df748863c41174e55d8a004e6b7d8f4b9c0
[]
no_license
Undergott/Head-First-Design-Pattern-CPP-Examples
60c2e4225f44aba0d6682511fa77fb08d30d03a4
3549784ce2c1df014c200e7a537ce2db35629088
refs/heads/master
2023-01-23T23:28:18.822674
2020-12-03T16:48:05
2020-12-03T16:48:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
477
hpp
DimmerLightOnCommand.hpp
#ifndef DIMMER_LIGHT_ON_COMMAND_H #define DIMMER_LIGHT_ON_COMMAND_H #include "Command.hpp" #include "Light.hpp" class DimmerLightOnCommand : public Command { public: DimmerLightOnCommand(Light *l) : light(l) {} void execute() override; void undo() override { light->dim(prevLevel); } private: Light *light; int prevLevel; }; inline void DimmerLightOnCommand::execute() { prevLevel = light->getLevel(); light->dim(75); } #endif /* DIMMER_LIGHT_ON_COMMAND_H */
e1bf6e959bced225ad7043155b2354b9593a15e0
d524dc1cf48dfb3dac6b288d0f5d3206ac2ad33b
/CMSSW/src/bainbrid/Test/test/SortJetCollectionsByGenJetPt.cc
4f94bbcc3c6d3b18135f9a6d29382ec782cc2f81
[]
no_license
bainbrid/usercode
59e7e2c2ba66be8ee6696be5b7fdddc3fa5d6d2a
3d1ae8563ff470725721100f6e5a2e7b5e8e125e
refs/heads/master
2016-09-07T18:38:31.267514
2013-09-10T20:21:21
2013-09-10T20:21:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,685
cc
SortJetCollectionsByGenJetPt.cc
#include "bainbrid/Test/test/SortJetCollectionsByGenJetPt.h" #include "DataFormats/Common/interface/View.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include <map> using namespace reco; // ----------------------------------------------------------------------------- // SortJetCollectionsByGenJetPt::SortJetCollectionsByGenJetPt( const edm::ParameterSet& pset ) : genJets_( pset.getParameter<edm::InputTag>("genJets") ), caloJets_( pset.getParameter< std::vector<edm::InputTag> >("caloJets") ), patJets_( pset.getParameter< std::vector<edm::InputTag> >("patJets") ) { // reco::GenJet products produces< std::vector<reco::GenJet> >( genJets_.label() ); // reco::CaloJet products { std::vector<edm::InputTag>::const_iterator ii = caloJets_.begin(); std::vector<edm::InputTag>::const_iterator jj = caloJets_.end(); for ( ; ii != jj; ++ii ) { if ( ii->label().empty() ) { continue; } produces< std::vector<reco::CaloJet> >( ii->label() ); } } // pat::Jet products { std::vector<edm::InputTag>::const_iterator ii = patJets_.begin(); std::vector<edm::InputTag>::const_iterator jj = patJets_.end(); for ( ; ii != jj; ++ii ) { if ( ii->label().empty() ) { continue; } produces< std::vector<pat::Jet> >( ii->label() ); } } } // ----------------------------------------------------------------------------- // SortJetCollectionsByGenJetPt::~SortJetCollectionsByGenJetPt() {;} // ----------------------------------------------------------------------------- // void SortJetCollectionsByGenJetPt::produce( edm::Event& event, const edm::EventSetup& setup ) { // Retrieve pat::Jet collection used to access matched reco::GenJets edm::Handle< edm::View<pat::Jet> > temp_jets; event.getByLabel( genJets_, temp_jets ); // Container for mapping std::map<GenJet,pat::Jet> mapping; // ---------- Extract reco::GenJets ---------- { std::stringstream ss; if ( edm::isDebugEnabled() ) { ss << "[SortJetCollectionsByGenJetPt::" << __func__ << "]" << " UNORDERED jets (" << temp_jets->size() << ")." << std::endl << " PatJetPt (#) : GenJetPt (#)" << std::endl; } int32_t index = 0; edm::View<pat::Jet>::const_iterator ii = temp_jets->begin(); edm::View<pat::Jet>::const_iterator jj = temp_jets->end(); for ( ; ii != jj; ++ii ) { double jet_pt = -1.; if ( ii->genJet() && ii->genJet()->pt() > 10. ) { mapping.insert( std::make_pair(*(ii->genJet()),*ii) ); jet_pt = ii->genJet()->pt(); index++; } if ( edm::isDebugEnabled() ) { std::stringstream temp1; temp1 << "(" << static_cast<uint32_t>( ii - temp_jets->begin() ) << ")"; std::stringstream temp2; temp2 << "(" << ( jet_pt < 0. ? -1 : index-1 ) << ")"; ss << " " << std::setfill(' ') << std::setw(8) << ii->pt() << " " << std::setfill(' ') << std::setw(4) << temp1.str() << " : " << std::setfill(' ') << std::setw(8) << jet_pt << " " << std::setfill(' ') << std::setw(4) << temp2.str() << std::endl; } } if ( edm::isDebugEnabled() ) { LogTrace("TEST") << ss.str(); } } // ---------- Create reco::GenJet and reference pat::Jet collections ---------- std::vector<GenJet> gen_jets; std::vector<pat::Jet> ref_jets; { uint32_t index = 0; std::stringstream ss; if ( edm::isDebugEnabled() ) { ss << "[SortJetCollectionsByGenJetPt::" << __func__ << "]" << " ORDERED jets (" << mapping.size() << ")." << std::endl << " GenJetPt (#) : RefJetPt (#)" << std::endl; } std::map<GenJet,pat::Jet>::const_iterator ii = mapping.begin(); std::map<GenJet,pat::Jet>::const_iterator jj = mapping.end(); for ( ; ii != jj; ++ii ) { gen_jets.push_back( ii->first ); ref_jets.push_back( ii->second ); if ( edm::isDebugEnabled() ) { std::stringstream temp; temp << "(" << uint32_t(index) << ")"; ss << " " << std::setfill(' ') << std::setw(8) << ii->first.pt() << " " << std::setfill(' ') << std::setw(4) << temp.str() << " : " << std::setfill(' ') << std::setw(8) << ii->second.pt() << " " << std::setfill(' ') << std::setw(4) << temp.str() << std::endl; } index++; } if ( edm::isDebugEnabled() ) { LogTrace("TEST") << ss.str(); } std::auto_ptr< std::vector<reco::GenJet> > ordered( new std::vector<reco::GenJet>(gen_jets) ); event.put(ordered,genJets_.label()); } // ---------- Create reco::CaloJet products ---------- { std::vector<edm::InputTag>::const_iterator ii = caloJets_.begin(); std::vector<edm::InputTag>::const_iterator jj = caloJets_.end(); for ( ; ii != jj; ++ii ) { // Check for non-null label if ( ii->label().empty() ) { continue; } // Debug std::stringstream ss; if ( edm::isDebugEnabled() ) { ss << "[SortJetCollectionsByGenJetPt::" << __func__ << "]" << " KEPT reco::CaloJets (" << mapping.size() << ") for \"" << ii->label() << "\"." << std::endl << " RefJetPt (#) : CaloJetPt (#)" << std::endl; } // Retrieve reco::CaloJet collection edm::Handle< edm::View<reco::CaloJet> > jets; event.getByLabel( *ii, jets ); // Sort reco::CaloJet collection according to GenJet pt std::auto_ptr< std::vector<reco::CaloJet> > ordered( new std::vector<reco::CaloJet>() ); std::vector<pat::Jet>::const_iterator iii = ref_jets.begin(); std::vector<pat::Jet>::const_iterator jjj = ref_jets.end(); for ( ; iii != jjj; ++iii ) { reco::CaloJet temp( iii->p4(), iii->caloSpecific(), iii->getJetConstituents() ); edm::View<reco::CaloJet>::const_iterator iter = std::find( jets->begin(), jets->end(), temp ); double jet_pt = -1.; int32_t index = -1; if ( iter != jets->end() ) { ordered->push_back(*iter); jet_pt = iter->pt(); index = static_cast<int32_t>( iter - jets->begin() ); } if ( edm::isDebugEnabled() ) { std::stringstream temp1; temp1 << "(" << static_cast<uint32_t>( iii - ref_jets.begin() ) << ")"; std::stringstream temp2; temp2 << "(" << index << ")"; ss << " " << std::setfill(' ') << std::setw(8) << iii->pt() << " " << std::setfill(' ') << std::setw(4) << temp1.str() << " : " << std::setfill(' ') << std::setw(8) << jet_pt << " " << std::setfill(' ') << std::setw(4) << temp2.str() << std::endl; } } event.put(ordered,ii->label()); if ( edm::isDebugEnabled() ) { LogTrace("TEST") << ss.str(); } } } // ---------- Create reco::PatJet products ---------- { std::vector<edm::InputTag>::const_iterator ii = patJets_.begin(); std::vector<edm::InputTag>::const_iterator jj = patJets_.end(); for ( ; ii != jj; ++ii ) { // Check for non-null label if ( ii->label().empty() ) { continue; } // Debug std::stringstream ss; if ( edm::isDebugEnabled() ) { ss << "[SortJetCollectionsByGenJetPt::" << __func__ << "]" << " KEPT pat::Jets (" << mapping.size() << ") for \"" << ii->label() << "\"." << std::endl << " RefJetPt (#) : PatJetPt (#)" << std::endl; } // Retrieve pat::Jet collection edm::Handle< edm::View<pat::Jet> > jets; event.getByLabel( *ii, jets ); // Sort pat::Jet collection according to GenJet pt std::auto_ptr< std::vector<pat::Jet> > ordered( new std::vector<pat::Jet>() ); std::vector<pat::Jet>::const_iterator iii = ref_jets.begin(); std::vector<pat::Jet>::const_iterator jjj = ref_jets.end(); for ( ; iii != jjj; ++iii ) { edm::View<pat::Jet>::const_iterator iter = std::find( jets->begin(), jets->end(), *iii ); double jet_pt = -1.; int32_t index = -1; if ( iter != jets->end() ) { ordered->push_back(*iter); jet_pt = iter->pt(); index = static_cast<int32_t>( iter - jets->begin() ); } if ( edm::isDebugEnabled() ) { std::stringstream temp1; temp1 << "(" << static_cast<uint32_t>( iii - ref_jets.begin() ) << ")"; std::stringstream temp2; temp2 << "(" << index << ")"; ss << " " << std::setfill(' ') << std::setw(8) << iii->pt() << " " << std::setfill(' ') << std::setw(4) << temp1.str() << " : " << std::setfill(' ') << std::setw(8) << jet_pt << " " << std::setfill(' ') << std::setw(4) << temp2.str() << std::endl; } } event.put(ordered,ii->label()); if ( edm::isDebugEnabled() ) { LogTrace("TEST") << ss.str(); } } } } #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SortJetCollectionsByGenJetPt); // // ----------------------------------------------------------------------------- // // // bool SortJetCollectionsByGenJetPt::matchJetsByCaloTowers( const pat::Jet& jet1, // const pat::Jet& jet2 ) { // std::vector< edm::Ptr<CaloTower> > towers1 = jet1.getCaloConstituents(); // std::vector< edm::Ptr<CaloTower> > towers2 = jet2.getCaloConstituents(); // if ( towers1.empty() || // towers2.empty() || // towers1.size() != towers2.size() ) { return false; } // std::vector< edm::Ptr<CaloTower> >::const_iterator ii = towers1.begin(); // std::vector< edm::Ptr<CaloTower> >::const_iterator jj = towers1.end(); // for ( ; ii != jj; ++ii ) { // std::vector< edm::Ptr<CaloTower> >::const_iterator iii = towers2.begin(); // std::vector< edm::Ptr<CaloTower> >::const_iterator jjj = towers2.end(); // for ( ; iii != jjj; ++iii ) { if ( *iii == *ii ) { break; } } // if ( iii == towers2.end() ) { return false; } // } // return true; // }
1f80e21b4176d403c190c56519dbaac0e1b9c96f
7cb6e3bc654414b45d992da7ae8a1e3ba306944b
/src/gazebo_plugins/Clock.cc
98a21cfaaee417f50567a2299cfc899b175658bf
[]
no_license
arocchi/gazebo_yarp_plugins
b84b7c3fb06a301666df1c3c20e92f1e183e2944
2abbf07cabb39ac718a56dd18280f0f069435c73
refs/heads/master
2020-12-25T17:57:01.154652
2014-02-26T09:34:19
2014-02-26T09:34:19
17,263,864
0
1
null
2015-11-04T11:00:26
2014-02-27T20:48:23
C++
UTF-8
C++
false
false
1,866
cc
Clock.cc
/* * Copyright (C) 2007-2013 Istituto Italiano di Tecnologia ADVR & iCub Facility * Authors: Enrico Mingo, Alessio Rocchi, Mirko Ferrati, Silvio Traversaro and Alessandro Settimi * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT */ #include <gazebo_yarp_plugins/Clock.hh> #include <gazebo/physics/physics.hh> #include <yarp/os/Property.h> #include <iostream> #include <cmath> namespace gazebo { GazeboYarpClock::GazeboYarpClock() : _yarp() { } GazeboYarpClock::~GazeboYarpClock() { gazebo::event::Events::DisconnectWorldUpdateBegin(time_update_event_); } void GazeboYarpClock::Load(int _argc, char **_argv) { std::cout << "GazeboYarpClock loaded." << std::endl; port_name = "/clock"; //The proper loading is done when the world is created load_gazebo_yarp_clock = gazebo::event::Events::ConnectWorldCreated(boost::bind(&GazeboYarpClock::GazeboYarpClockLoad,this,_1)); } void GazeboYarpClock::GazeboYarpClockLoad(std::string world_name) { gazebo::event::Events::DisconnectWorldCreated(load_gazebo_yarp_clock); //Opening port port.open(port_name); //Getting world pointer world_ = gazebo::physics::get_world(world_name); time_update_event_ = gazebo::event::Events::ConnectWorldUpdateBegin(boost::bind(&GazeboYarpClock::ClockUpdate,this)); } void GazeboYarpClock::ClockUpdate() { gazebo::common::Time currentTime = world_->GetSimTime(); yarp::os::Bottle& b = port.prepare(); b.clear(); b.addInt(currentTime.sec); b.addInt(currentTime.nsec); port.write(); } // Register this plugin with the simulator GZ_REGISTER_SYSTEM_PLUGIN(GazeboYarpClock) }
3520ec23c58f7e53a1b4a3cddf1d4cfa329a8d07
594975831ea01c49bc9a3253ca1ccbac9f4f5eea
/app/include/DataStructCom/TorpedoAttackTask.h
ebd623cc6ea54c197760f09df9e5a5c137e46521
[]
no_license
WarfareCode/linux
0344589884de3d345b50fa8ba9cad29e94feb9c6
a0ef3d4da620f3eeb1cf54fa2a86e14c9b96c65a
refs/heads/master
2021-10-09T18:32:47.071838
2018-12-25T08:14:56
2018-12-25T08:14:56
null
0
0
null
null
null
null
GB18030
C++
false
false
1,251
h
TorpedoAttackTask.h
//TorpedoAttackTask.h: interface for the CTorpedoAttackTask module. //!!HDOSE_CLASS(CTorpedoAttackTask,CTask) ////////////////////////////////////////////////////////////////////// #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #if !defined(AFX_TorpedoAttackTask_H) #define AFX_TorpedoAttackTask_H //{{HDOSE_CLS_DES(CTorpedoAttackTask) /* Author: Version: 1.0 Descript: */ //}}HDOSE_CLS_DES class DATASTRUCTCOMPONENTDLL_API CTorpedoAttackTask /*鱼雷攻击任务*/ : public CTask { DECLARE_CREATE; public: CTorpedoAttackTask(); virtual ~CTorpedoAttackTask(); static void ClassInit(ClassInfo *clsinfo); virtual void OnInit(); void SetFieldNo(long val){m_FieldNo=val;} long GetFieldNo(){return m_FieldNo;} void SetTargetNo(long val){m_TargetNo=val;} long GetTargetNo(){return m_TargetNo;} void SetForceType(long val){m_ForceType=val;} long GetForceType(){return m_ForceType;} //{{HDOSE_MEMBER_FUNCTION(CTorpedoAttackTask) //}}HDOSE_MEMBER_FUNCTION public: //{{HDOSE_ATTRIBUTE(CTorpedoAttackTask) long m_FieldNo/*阵地编号(岸导阵地、舰艇、飞机等作战单位的编号)*/; long m_TargetNo/*目标编号*/; long m_ForceType/*红蓝方标识(0蓝,1红)*/; //}}HDOSE_ATTRIBUTE }; #endif
ff611c054de258cec6acea76a3b2ab901d73fcc7
13e77e63c0cfaca12ed1798f43510509e47fac94
/181-351-Okunev-2sim/Lab1 log and pas/change.h
27810ce777851d6a3ca6f2174c7212206e6d06e4
[]
no_license
Steper2000/181-351-okunev
999db5f1bfc0fbb764811b6d7807f8d39f9a1904
b9d21f16076409c3a713ad10b1d23486ff0c85ab
refs/heads/master
2020-03-28T18:31:13.344732
2019-04-06T06:17:30
2019-04-06T06:17:30
148,888,430
0
0
null
null
null
null
UTF-8
C++
false
false
273
h
change.h
#pragma once #include <QDialog> #include "ui_change.h" class change : public QDialog, public Ui::change { Q_OBJECT public: change(QWidget *parent = Q_NULLPTR); ~change(); private: Ui::change ui; private slots: void on_pushButton_change_clicked(); };
c1855dcfa37961b845835c4490c845c78fb79232
f2838ef49a75a358e5065bedeaa36fa11945dc0f
/Source/Team18_AI/AI/Sensing/TAListeneningComponent.h
2a2e92b8766ad26241afcf157a2a95b79ef3c21b
[]
no_license
KennyGustavsson/AIFG
fe9622e7bbc4b7fcaf2ced7a91dd44e675522bc3
fe2cb4fb689f69f584869e6f364f6b352efed2fb
refs/heads/main
2023-04-19T11:04:38.226788
2021-05-09T20:57:30
2021-05-09T20:57:30
365,836,370
0
0
null
null
null
null
UTF-8
C++
false
false
1,028
h
TAListeneningComponent.h
#pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "TAListeneningComponent.generated.h" class UTAListeneningComponent; class ATeam18_AIGameMode; USTRUCT(BlueprintType) struct FSoundEventResult { GENERATED_BODY() public: UPROPERTY(BlueprintReadOnly) FVector Location = FVector::ZeroVector; }; DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FTASoundEventDelegate, const FSoundEventResult&, Results); UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class TEAM18_AI_API UTAListeneningComponent : public UActorComponent { GENERATED_BODY() public: UTAListeneningComponent(); virtual void BeginPlay() override; virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; UPROPERTY(EditAnywhere) float HearingMinDistance = 1000.0f; UPROPERTY(EditAnywhere) bool bDebugHearingRange = false; UPROPERTY(BlueprintAssignable) FTASoundEventDelegate OnNoiseHeard; private: ATeam18_AIGameMode* GameMode; };
e830dee1007bfcebbc04d1195e8b6cf12ca28636
7908290a3386df7be468ea7745e10208e15a74fb
/VkResult_to_CString.hxx
996f976e55f96e11e33e4b257733159f941165f8
[]
no_license
jaguardeer/automatic-garbanzo
77cf173378ea4320cd3fe6d97d571c89643db86e
cd4708e1d07d1d3598b65370c68955651ff3aba6
refs/heads/master
2020-03-16T14:02:17.399371
2018-05-09T05:26:28
2018-05-09T05:26:28
132,705,760
0
0
null
null
null
null
UTF-8
C++
false
false
1,441
hxx
VkResult_to_CString.hxx
#ifndef VKRESULT_TO_CSTRING_H #define VKRESULT_TO_CSTRING_H extern "C" { #include <vulkan/vulkan.h> } constexpr const char* VkResult_to_CString (const VkResult vk_result) { switch (vk_result) { case VK_SUCCESS: return "VK_SUCCESS"; case VK_NOT_READY: return "VK_NOT_READY"; case VK_TIMEOUT: return "VK_TIMEOUT"; case VK_EVENT_SET: return "VK_EVENT_SET"; case VK_EVENT_RESET: return "VK_EVENT_RESET"; case VK_INCOMPLETE: return "VK_INCOMPLETE"; case VK_ERROR_OUT_OF_HOST_MEMORY: return "VK_ERROR_OUT_OF_HOST_MEMORY"; case VK_ERROR_OUT_OF_DEVICE_MEMORY: return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; case VK_ERROR_INITIALIZATION_FAILED: return "VK_ERROR_INITIALIZATION_FAILED"; case VK_ERROR_DEVICE_LOST: return "VK_ERROR_DEVICE_LOST"; case VK_ERROR_MEMORY_MAP_FAILED: return "VK_ERROR_MEMORY_MAP_FAILED"; case VK_ERROR_LAYER_NOT_PRESENT: return "VK_ERROR_LAYER_NOT_PRESENT"; case VK_ERROR_EXTENSION_NOT_PRESENT: return "VK_ERROR_EXTENSION_NOT_PRESENT"; case VK_ERROR_FEATURE_NOT_PRESENT: return "VK_ERROR_FEATURE_NOT_PRESENT"; case VK_ERROR_INCOMPATIBLE_DRIVER: return "VK_ERROR_INCOMPATIBLE_DRIVER"; case VK_ERROR_TOO_MANY_OBJECTS: return "VK_ERROR_TOO_MANY_OBJECTS"; case VK_ERROR_FORMAT_NOT_SUPPORTED: return "VK_ERROR_FORMAT_NOT_SUPPORTED"; case VK_ERROR_FRAGMENTED_POOL: return "VK_ERROR_FRAGMENTED_POOL"; default: return "!!! NOT A VULKAN ERROR !!!"; } } #endif
a5447a40c1f4a0d88c092e8a2d661aedf6838e0f
560f37fb34b9d2828123de3ebf202ee7456f2e64
/src/spell.cpp
cf8c24fe975b9126aaff9107b4f713e705e28491
[]
no_license
samanthadoran/TurnBasedFight
842c6e0579189b48b206dab25b7f30a8754fec48
bb005bfd1964a008ee22336e585b245400d26e1c
refs/heads/master
2020-05-20T06:05:27.656206
2015-05-15T00:28:20
2015-05-15T00:28:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
584
cpp
spell.cpp
#include "../include/spell.h" Spell::Spell(std::string name, double hpEffect):Action(name) { this->hpEffect = hpEffect; } std::string Spell::use(Character * source, Character * target) const { target->setLife(target->getLife() + hpEffect); std::stringstream ss; ss << source->getName() << " casts " << this->getName() << " on " << target-> getName(); return ss.str(); } std::string Spell::toString() const { std::stringstream ss; ss << this->getName() << ": HP eff.(" <<hpEffect << ")"; return ss.str(); } Spell::~Spell() { //dtor }
26ecab61e04b183f8aadeb582c73e6460653d09f
0238298e966ab23a33509b5c2edc62d0e41802f8
/practicas/eclipse/prac6_2_D/edroom_glue/src/edroomdeployment.cpp
c1b92d0483fec53134b57c16b7f47f5d143fc5a4
[]
no_license
noesmoral/SistemasEmpotrados
b36058b9e24a327e1e1a25d6ec7049f9016deb83
a8b8f4b168a3d78067be1e80ac1fff68f9fc4383
refs/heads/master
2021-01-22T12:53:29.857125
2016-09-15T19:42:37
2016-09-15T19:42:37
68,328,074
0
0
null
null
null
null
UTF-8
C++
false
false
16,890
cpp
edroomdeployment.cpp
//############################################################################## //############### This file has been generated by EDROOM ############### //############################################################################## #include <edroom_glue/edroomdeployment.h> //***************************************************************************** //Main Wait void MainWait(CAClient &comp2, CAClient &comp3, CAClient &comp4, CAClient &comp5, CAClient &comp6, CAClient &comp7, CAClient &comp8, CAClient &comp9, CAServer &comp11, CAServer &comp12){ Pr_Time waitTime(3, 0); #ifdef _EDROOM_SYSTEM_CLOSE while(!comp2.EDROOMIsComponentFinished() ||!comp3.EDROOMIsComponentFinished() ||!comp4.EDROOMIsComponentFinished() ||!comp5.EDROOMIsComponentFinished() ||!comp6.EDROOMIsComponentFinished() ||!comp7.EDROOMIsComponentFinished() ||!comp8.EDROOMIsComponentFinished() ||!comp9.EDROOMIsComponentFinished() ||!comp11.EDROOMIsComponentFinished() ||!comp12.EDROOMIsComponentFinished()) #else while(true) #endif Pr_DelayIn(waitTime); } //***************************************************************************** //SetMemory void CEDROOMSystemMemory::SetMemory(){ comp2Memory.SetMemory(10, comp2Messages, &comp2MessagesMarks[0] ,15,comp2QueueNodes, &comp2QueueNodesMarks[0]); comp3Memory.SetMemory(10, comp3Messages, &comp3MessagesMarks[0] ,15,comp3QueueNodes, &comp3QueueNodesMarks[0]); comp4Memory.SetMemory(10, comp4Messages, &comp4MessagesMarks[0] ,15,comp4QueueNodes, &comp4QueueNodesMarks[0]); comp5Memory.SetMemory(10, comp5Messages, &comp5MessagesMarks[0] ,15,comp5QueueNodes, &comp5QueueNodesMarks[0]); comp6Memory.SetMemory(10, comp6Messages, &comp6MessagesMarks[0] ,15,comp6QueueNodes, &comp6QueueNodesMarks[0]); comp7Memory.SetMemory(10, comp7Messages, &comp7MessagesMarks[0] ,15,comp7QueueNodes, &comp7QueueNodesMarks[0]); comp8Memory.SetMemory(10, comp8Messages, &comp8MessagesMarks[0] ,15,comp8QueueNodes, &comp8QueueNodesMarks[0]); comp9Memory.SetMemory(10, comp9Messages, &comp9MessagesMarks[0] ,15,comp9QueueNodes, &comp9QueueNodesMarks[0]); comp11Memory.SetMemory(10, comp11Messages, &comp11MessagesMarks[0] ,14,comp11QueueNodes, &comp11QueueNodesMarks[0]); comp12Memory.SetMemory(10, comp12Messages, &comp12MessagesMarks[0] ,14,comp12QueueNodes, &comp12QueueNodesMarks[0]); } //***************************************************************************** //SetComponents void CEDROOMSystemCommSAP::SetComponents(CAClient *p_comp2, CAClient *p_comp3, CAClient *p_comp4, CAClient *p_comp5, CAClient *p_comp6, CAClient *p_comp7, CAClient *p_comp8, CAClient *p_comp9, CAServer *p_comp11, CAServer *p_comp12){ mp_comp2=p_comp2; mp_comp3=p_comp3; mp_comp4=p_comp4; mp_comp5=p_comp5; mp_comp6=p_comp6; mp_comp7=p_comp7; mp_comp8=p_comp8; mp_comp9=p_comp9; mp_comp11=p_comp11; mp_comp12=p_comp12; } //***************************************************************************** //***************************************************************************** //Signal Translation Functions //***************************************************************************** //***************************************************************************** TEDROOMSignal CEDROOMSystemCommSAP::C5Client4_PpServReq__C11Server_PpService4(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAClient::SFreeRes): signalIn=CAServer::SFreeRes; break; case( CAClient::SResReq): signalIn=CAServer::SResReq; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C11Server_PpService4__C5Client4_PpServReq(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAServer::SResAck): signalIn=CAClient::SResAck; break; case( CAServer::SResNack): signalIn=CAClient::SResNack; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C4Client3_PpServReq__C11Server_PpService3(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAClient::SFreeRes): signalIn=CAServer::SFreeRes; break; case( CAClient::SResReq): signalIn=CAServer::SResReq; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C11Server_PpService3__C4Client3_PpServReq(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAServer::SResAck): signalIn=CAClient::SResAck; break; case( CAServer::SResNack): signalIn=CAClient::SResNack; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C3Client2_PpServReq__C11Server_PpService2(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAClient::SFreeRes): signalIn=CAServer::SFreeRes; break; case( CAClient::SResReq): signalIn=CAServer::SResReq; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C11Server_PpService2__C3Client2_PpServReq(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAServer::SResAck): signalIn=CAClient::SResAck; break; case( CAServer::SResNack): signalIn=CAClient::SResNack; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C2Client1_PpServReq__C11Server_PpService1(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAClient::SFreeRes): signalIn=CAServer::SFreeRes; break; case( CAClient::SResReq): signalIn=CAServer::SResReq; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C11Server_PpService1__C2Client1_PpServReq(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAServer::SResAck): signalIn=CAClient::SResAck; break; case( CAServer::SResNack): signalIn=CAClient::SResNack; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C9Client8_PpServReq__C12Server2_PpService4(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAClient::SFreeRes): signalIn=CAServer::SFreeRes; break; case( CAClient::SResReq): signalIn=CAServer::SResReq; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C12Server2_PpService4__C9Client8_PpServReq(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAServer::SResAck): signalIn=CAClient::SResAck; break; case( CAServer::SResNack): signalIn=CAClient::SResNack; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C8Client7_PpServReq__C12Server2_PpService3(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAClient::SFreeRes): signalIn=CAServer::SFreeRes; break; case( CAClient::SResReq): signalIn=CAServer::SResReq; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C12Server2_PpService3__C8Client7_PpServReq(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAServer::SResAck): signalIn=CAClient::SResAck; break; case( CAServer::SResNack): signalIn=CAClient::SResNack; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C7Client6_PpServReq__C12Server2_PpService2(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAClient::SFreeRes): signalIn=CAServer::SFreeRes; break; case( CAClient::SResReq): signalIn=CAServer::SResReq; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C12Server2_PpService2__C7Client6_PpServReq(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAServer::SResAck): signalIn=CAClient::SResAck; break; case( CAServer::SResNack): signalIn=CAClient::SResNack; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C6Client5_PpServReq__C12Server2_PpService1(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAClient::SFreeRes): signalIn=CAServer::SFreeRes; break; case( CAClient::SResReq): signalIn=CAServer::SResReq; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } TEDROOMSignal CEDROOMSystemCommSAP::C12Server2_PpService1__C6Client5_PpServReq(TEDROOMSignal signalOut){ TEDROOMSignal signalIn; switch(signalOut){ case( CAServer::SResAck): signalIn=CAClient::SResAck; break; case( CAServer::SResNack): signalIn=CAClient::SResNack; break; default: signalIn=(TEDROOMSignal)(-1); break; } return signalIn; } //***************************************************************************** //RegisterInterfaces void CEDROOMSystemCommSAP::RegisterInterfaces(){ // Register Interface for Component 2 m_localCommSAP.RegisterInterface(1, mp_comp2->ResConfigTimer, mp_comp2); m_localCommSAP.RegisterInterface(2, mp_comp2->Timer, mp_comp2); m_localCommSAP.RegisterInterface(3, mp_comp2->pServReq, mp_comp2); // Register Interface for Component 3 m_localCommSAP.RegisterInterface(1, mp_comp3->ResConfigTimer, mp_comp3); m_localCommSAP.RegisterInterface(2, mp_comp3->Timer, mp_comp3); m_localCommSAP.RegisterInterface(3, mp_comp3->pServReq, mp_comp3); // Register Interface for Component 4 m_localCommSAP.RegisterInterface(1, mp_comp4->ResConfigTimer, mp_comp4); m_localCommSAP.RegisterInterface(2, mp_comp4->Timer, mp_comp4); m_localCommSAP.RegisterInterface(3, mp_comp4->pServReq, mp_comp4); // Register Interface for Component 5 m_localCommSAP.RegisterInterface(1, mp_comp5->ResConfigTimer, mp_comp5); m_localCommSAP.RegisterInterface(2, mp_comp5->Timer, mp_comp5); m_localCommSAP.RegisterInterface(3, mp_comp5->pServReq, mp_comp5); // Register Interface for Component 6 m_localCommSAP.RegisterInterface(1, mp_comp6->ResConfigTimer, mp_comp6); m_localCommSAP.RegisterInterface(2, mp_comp6->Timer, mp_comp6); m_localCommSAP.RegisterInterface(3, mp_comp6->pServReq, mp_comp6); // Register Interface for Component 7 m_localCommSAP.RegisterInterface(1, mp_comp7->ResConfigTimer, mp_comp7); m_localCommSAP.RegisterInterface(2, mp_comp7->Timer, mp_comp7); m_localCommSAP.RegisterInterface(3, mp_comp7->pServReq, mp_comp7); // Register Interface for Component 8 m_localCommSAP.RegisterInterface(1, mp_comp8->ResConfigTimer, mp_comp8); m_localCommSAP.RegisterInterface(2, mp_comp8->Timer, mp_comp8); m_localCommSAP.RegisterInterface(3, mp_comp8->pServReq, mp_comp8); // Register Interface for Component 9 m_localCommSAP.RegisterInterface(1, mp_comp9->ResConfigTimer, mp_comp9); m_localCommSAP.RegisterInterface(2, mp_comp9->Timer, mp_comp9); m_localCommSAP.RegisterInterface(3, mp_comp9->pServReq, mp_comp9); // Register Interface for Component 11 m_localCommSAP.RegisterInterface(1, mp_comp11->pService4, mp_comp11); m_localCommSAP.RegisterInterface(2, mp_comp11->pService3, mp_comp11); m_localCommSAP.RegisterInterface(3, mp_comp11->pService2, mp_comp11); m_localCommSAP.RegisterInterface(4, mp_comp11->pService1, mp_comp11); // Register Interface for Component 12 m_localCommSAP.RegisterInterface(1, mp_comp12->pService4, mp_comp12); m_localCommSAP.RegisterInterface(2, mp_comp12->pService3, mp_comp12); m_localCommSAP.RegisterInterface(3, mp_comp12->pService2, mp_comp12); m_localCommSAP.RegisterInterface(4, mp_comp12->pService1, mp_comp12); } //***************************************************************************** ////SetLocalConnections void CEDROOMSystemCommSAP::SetLocalConnections(){ m_localCommSAP.Connect(mp_comp5->pServReq, mp_comp11->pService4, connections[0], C5Client4_PpServReq__C11Server_PpService4, C11Server_PpService4__C5Client4_PpServReq); m_localCommSAP.Connect(mp_comp4->pServReq, mp_comp11->pService3, connections[1], C4Client3_PpServReq__C11Server_PpService3, C11Server_PpService3__C4Client3_PpServReq); m_localCommSAP.Connect(mp_comp3->pServReq, mp_comp11->pService2, connections[2], C3Client2_PpServReq__C11Server_PpService2, C11Server_PpService2__C3Client2_PpServReq); m_localCommSAP.Connect(mp_comp2->pServReq, mp_comp11->pService1, connections[3], C2Client1_PpServReq__C11Server_PpService1, C11Server_PpService1__C2Client1_PpServReq); m_localCommSAP.Connect(mp_comp9->pServReq, mp_comp12->pService4, connections[4], C9Client8_PpServReq__C12Server2_PpService4, C12Server2_PpService4__C9Client8_PpServReq); m_localCommSAP.Connect(mp_comp8->pServReq, mp_comp12->pService3, connections[5], C8Client7_PpServReq__C12Server2_PpService3, C12Server2_PpService3__C8Client7_PpServReq); m_localCommSAP.Connect(mp_comp7->pServReq, mp_comp12->pService2, connections[6], C7Client6_PpServReq__C12Server2_PpService2, C12Server2_PpService2__C7Client6_PpServReq); m_localCommSAP.Connect(mp_comp6->pServReq, mp_comp12->pService1, connections[7], C6Client5_PpServReq__C12Server2_PpService1, C12Server2_PpService1__C6Client5_PpServReq); } //***************************************************************************** ////SetRemoteConnections void CEDROOMSystemCommSAP::SetRemoteConnections(){ } //***************************************************************************** ////SetConnections void CEDROOMSystemCommSAP::SetConnections(){ SetLocalConnections(); SetRemoteConnections(); } //***************************************************************************** ////CEDROOMSystemDeployment Constructor CEDROOMSystemDeployment::CEDROOMSystemDeployment(){ #ifdef CONFIG_EDROOMSL_ADD_TRACE #endif systemMemory.SetMemory(); } //***************************************************************************** ////Config void CEDROOMSystemDeployment::Config(CAClient *p_comp2, CAClient *p_comp3, CAClient *p_comp4, CAClient *p_comp5, CAClient *p_comp6, CAClient *p_comp7, CAClient *p_comp8, CAClient *p_comp9, CAServer *p_comp11, CAServer *p_comp12){ mp_comp2=p_comp2; mp_comp3=p_comp3; mp_comp4=p_comp4; mp_comp5=p_comp5; mp_comp6=p_comp6; mp_comp7=p_comp7; mp_comp8=p_comp8; mp_comp9=p_comp9; mp_comp11=p_comp11; mp_comp12=p_comp12; systemCommSAP.SetComponents( p_comp2, p_comp3, p_comp4, p_comp5, p_comp6, p_comp7, p_comp8, p_comp9, p_comp11, p_comp12); systemCommSAP.RegisterInterfaces(); systemCommSAP.SetConnections(); } //***************************************************************************** ////StartComponents void CEDROOMSystemDeployment::StartComponents(){ mp_comp2->EDROOMStart(); mp_comp3->EDROOMStart(); mp_comp4->EDROOMStart(); mp_comp5->EDROOMStart(); mp_comp6->EDROOMStart(); mp_comp7->EDROOMStart(); mp_comp8->EDROOMStart(); mp_comp9->EDROOMStart(); mp_comp11->EDROOMStart(); mp_comp12->EDROOMStart(); } //***************************************************************************** ////Start void CEDROOMSystemDeployment::Start(){ #ifdef CONFIG_EDROOMBP_DEPLOYMENT_NEED_TASK Pr_Task MainTask(CEDROOMSystemDeployment::main_task,EDROOMprioMINIMUM,1024*16); kernel.Start(); #else StartComponents(); kernel.Start(); MainWait(*mp_comp2, *mp_comp3, *mp_comp4, *mp_comp5, *mp_comp6, *mp_comp7, *mp_comp8, *mp_comp9, *mp_comp11, *mp_comp12); #endif } #ifdef CONFIG_EDROOMBP_DEPLOYMENT_NEED_TASK extern CEDROOMSystemDeployment systemDeployment; //***************************************************************************** ////main_task Pr_TaskRV_t CEDROOMSystemDeployment::main_task(Pr_TaskP_t){ systemDeployment.StartComponents(); MainWait(*systemDeployment.mp_comp2, *systemDeployment.mp_comp3, *systemDeployment.mp_comp4, *systemDeployment.mp_comp5, *systemDeployment.mp_comp6, *systemDeployment.mp_comp7, *systemDeployment.mp_comp8, *systemDeployment.mp_comp9, *systemDeployment.mp_comp11, *systemDeployment.mp_comp12); } #endif
8d47084748647677baf3561cc3500b28c5c3deae
30a8d2ba26080134916d6580923a65f1426d8e02
/Lab01 - 597609, 453828/Exercise 3.2 - Complex_Type_2/main.cpp
376f4cad1507ae55c6e563d6697b690996d3afab
[]
no_license
aliceyang16/Software_Labs
758a59890316a535ee383dfe76c84357168da456
fea5465b29fce90e9ba45f64bce913ae010ab9b9
refs/heads/master
2020-04-26T22:56:30.910731
2015-08-31T15:51:02
2015-08-31T15:51:02
39,832,157
0
0
null
null
null
null
UTF-8
C++
false
false
2,394
cpp
main.cpp
#include <iostream> #include <string.h> #include <complex> using namespace std; typedef complex<double> complex_number; // Function prototype int prompt_value(char); double quad_equation_1(double, int, int); double quad_equation_2(double, int, int); complex_number quad_complex_equation(double, int, int); int main() { char user_input; int a_value, b_value, c_value; double temp_value = 0; while(user_input != 'q') { a_value = prompt_value('a'); cout << endl; b_value = prompt_value('b'); cout << endl; c_value = prompt_value('c'); cout << endl; // For the square root value: temp_value = (b_value * b_value) - (4 * a_value * c_value); if(temp_value < 0) { complex_number answer; temp_value = abs(temp_value); auto square = sqrt(temp_value); answer = quad_complex_equation(square, a_value, b_value); cout << "x value = " << answer << endl; cout << "or in a familar form" << endl; cout << "x_value = " << answer.real() << " +/- " << answer.imag() << "j" << endl; } else { auto square = sqrt(temp_value); auto answer_1 = quad_equation_1(square, a_value, b_value); auto answer_2 = quad_equation_2(square, a_value, b_value); if(answer_1 == answer_2) { cout << "x value = " << answer_1 << endl; } else { cout << "x value = " << answer_1 << endl; cout << "or" << endl; cout << "x value = " << answer_2 << endl; } } cout << "To quite, press q. Otherwise press any key" << endl; cin >> user_input; } } int prompt_value(char letter) { int value = 0; cout << "Please enter value " << letter << ": "; cin >> value; return value; } double quad_equation_1(double square_value, int a_value, int b_value) { double x_value = 0; x_value = (-b_value + square_value) / (2 * a_value); return x_value; } double quad_equation_2(double square_value, int a_value, int b_value) { double x_value = 0; x_value = (-b_value - square_value) / (2 * a_value); return x_value; } complex_number quad_complex_equation(double square_value, int a_value, int b_value) { double real_value; double imag_value; real_value = -b_value / (2 * a_value); imag_value = square_value / (2 * a_value); complex_number x_value{ real_value, imag_value }; return x_value; }
c06219e31826dd120e4e50df71eb26800cd574bb
f717e561649d68a2aeb626ced90587fa2b4de176
/Extensions/OpenLegacyAudio/AppleDBDMAAudio/Apple02DBDMAAudioDMAEngine.h
48ee6d0d1a3b88013ae8e5744eab46b05fd19fb0
[]
no_license
OpenDarwin-CVS/XPostFacto
9235e78d3302bc3a22911e6d33b40ff3206ccdc3
1803de6542e90ac878fd99aa808b15449a124fb4
refs/heads/master
2016-09-10T10:16:24.830437
2005-08-10T00:01:25
2005-08-10T00:01:25
19,126,537
8
2
null
null
null
null
IBM866
C++
false
false
10,955
h
Apple02DBDMAAudioDMAEngine.h
#ifndef _APPLEDBDMAAUDIODMAENGINE_H #define _APPLEDBDMAAUDIODMAENGINE_H #include <IOKit/ppc/IODBDMA.h> #include <IOKit/audio/IOAudioEngine.h> #include <IOKit/audio/IOAudioTypes.h> #include <IOKit/audio/IOAudioStream.h> #include "AudioHardwareCommon.h" #include "Apple02DBDMAAudioFloatLib.h" //#define _TIME_CLIP_ROUTINE // aml 2.28.02 adding header to get constants // #include "AppleiSubEngine.h" class IOInterruptEventSource; class IOFilterInterruptEventSource; // reducing the block size makes the problem happen less often #define DBDMAAUDIODMAENGINE_DEFAULT_NUM_BLOCKS 512 #define DBDMAAUDIODMAENGINE_DEFAULT_BLOCK_SIZE 128 #define DBDMAAUDIODMAENGINE_DEFAULT_SAMPLE_RATE 44100 #define DBDMAAUDIODMAENGINE_DEFAULT_BIT_DEPTH 16 #define DBDMAAUDIODMAENGINE_DEFAULT_NUM_CHANNELS 2 // minimum safety offset, 16 when no iSub, and 45 when iSub is attached //#define kMinimumLatency 16 #define kMinimumLatency 45 #define kMinimumLatencyiSub 45 typedef enum { e_Mode_Disabled = 0, e_Mode_CopyLeftToRight, e_Mode_CopyRightToLeft } DualMonoModeType; // class AppleiSubEngine; class Apple02DBDMAAudioDMAEngine : public IOAudioEngine { OSDeclareDefaultStructors(Apple02DBDMAAudioDMAEngine) public: virtual void free(); virtual UInt32 getCurrentSampleFrame(); virtual bool init(OSDictionary *properties, IOService *theDeviceProvider, bool hasInput, UInt32 numBlocks = DBDMAAUDIODMAENGINE_DEFAULT_NUM_BLOCKS, UInt32 blockSize = DBDMAAUDIODMAENGINE_DEFAULT_BLOCK_SIZE, UInt32 rate = DBDMAAUDIODMAENGINE_DEFAULT_SAMPLE_RATE, UInt16 bitDepth = DBDMAAUDIODMAENGINE_DEFAULT_BIT_DEPTH, UInt16 numChannels = DBDMAAUDIODMAENGINE_DEFAULT_NUM_CHANNELS); virtual bool initHardware(IOService *provider); virtual IOReturn performAudioEngineStart(); virtual IOReturn performAudioEngineStop(); IOReturn restartDMA(); virtual void setSampleLatencies (UInt32 outputLatency, UInt32 inputLatency); virtual void stop(IOService *provider); // static void requestiSubClose (IOAudioEngine * audioEngine); // virtual bool willTerminate (IOService * provider, IOOptionBits options); virtual OSString * getGlobalUniqueID(); virtual IOReturn clipOutputSamples(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); virtual IOReturn convertInputSamples(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream); // [3094574] aml, eliminate copied code // void resetiSubProcessingState(); void setPhaseInversion(const bool needsPhaseInversion); inline bool getPhaseInversion() { return fNeedsPhaseInversion; }; void setRightChanMixed(const bool needsRightChanMixed); inline bool getRightChanMixed() { return fNeedsRightChanMixed; }; // [3134221] aml, added mode for delaying right channel to compensate for TAS 3004 phase shift void setRightChanDelay(const bool needsRightChanDelay); inline bool getRightChanDelay() { return fNeedsRightChanDelay; }; void setDualMonoMode(const DualMonoModeType inDualMonoMode); void setUseSoftwareInputGain(bool inUseSoftwareInputGain); void setInputGainL(UInt32 inGainL); void setInputGainR(UInt32 inGainR); void setRightChanDelayInput(const bool needsRightChanDelay); void setBalanceAdjust(const bool needsBalanceAdjust); void setLeftBalanceAdjust(UInt32 inVolume); void setRightBalanceAdjust(UInt32 inVolume); // virtual void resetClipPosition (IOAudioStream *audioStream, UInt32 clipSampleFrame); virtual IOReturn performFormatChange(IOAudioStream *audioStream, const IOAudioStreamFormat *newFormat, const IOAudioSampleRate *newSampleRate); virtual bool getDmaState (void ); virtual IOReturn getAudioStreamFormat( IOAudioStreamFormat * streamFormatPtr ); static const int kDBDMADeviceIndex; static const int kDBDMAOutputIndex; static const int kDBDMAInputIndex; protected: IOMemoryDescriptor * dmaCommandBufferInMemDescriptor; IOMemoryDescriptor * dmaCommandBufferOutMemDescriptor; IOMemoryDescriptor * sampleBufferInMemDescriptor; IOMemoryDescriptor * sampleBufferOutMemDescriptor; IOMemoryDescriptor * stopCommandMemDescriptor; IODBDMAChannelRegisters * ioBaseDMAOutput; IODBDMAChannelRegisters * ioBaseDMAInput; IODBDMADescriptor * dmaCommandBufferOut; IODBDMADescriptor * dmaCommandBufferIn; UInt32 commandBufferSize; IOFilterInterruptEventSource * interruptEventSource; UInt32 numBlocks; UInt32 blockSize; Boolean mNeedToRestartDMA; // Next lines for iSub // iSubProcessingParams_t miSubProcessingParams; IOMemoryDescriptor * iSubBufferMemory; IOAudioToggleControl * iSubAttach; UInt32 ourSampleFrameAtiSubLoop; UInt32 clipAdjustment; IOService * ourProvider; IONotifier * iSubEngineNotifier; // AppleiSubEngine * iSubEngine; UInt32 previousClippedToFrame; UInt32 initialiSubLead; Boolean needToSync; Boolean startiSub; Boolean justResetClipPosition; Boolean restartedDMA; Boolean iSubOpen; bool fNeedsPhaseInversion; bool fNeedsRightChanMixed; bool fNeedsRightChanDelay; bool fNeedsRightChanDelayInput; bool fNeedsBalanceAdjust; float mLastInputSample; float mLastOutputSample; UInt32 mLeftBalanceAdjust; UInt32 mRightBalanceAdjust; DualMonoModeType mInputDualMonoMode; bool mUseSoftwareInputGain; float * mInputGainLPtr; float * mInputGainRPtr; bool dmaRunState; // rbm 7.12.02 added for user client support IOAudioStreamFormat dbdmaFormat; // rbm 7.15.02 added for user client support IOAudioStreamDirection direction; virtual bool filterInterrupt(int index); // [3094574] aml, added routines to set member function pointers based on state void chooseOutputClippingRoutinePtr(); void chooseInputConversionRoutinePtr(); static bool interruptFilter(OSObject *owner, IOFilterInterruptEventSource *source); static void interruptHandler(OSObject *owner, IOInterruptEventSource *source, int count); // [3094574] aml, added member function pointers IOReturn (Apple02DBDMAAudioDMAEngine::*mClipAppleLegacyDBDMAToOutputStreamRoutine)(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn (Apple02DBDMAAudioDMAEngine::*mConvertInputStreamToAppleLegacyDBDMARoutine)(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); inline void startTiming(); inline void endTiming(); #ifdef _TIME_CLIP_ROUTINE UInt32 mCallCount; AbsoluteTime mPreviousUptime; #endif #pragma mark ---------------------------------------- #pragma mark еее Output Conversion Routines #pragma mark ---------------------------------------- IOReturn clipLegacyMemCopyToOutputStream(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream16(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream16DelayRightChannel(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream16DelayRightChannelBalance(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream16MixRightChannel(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream16InvertRightChannel(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream32(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream32DelayRightChannel(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream32DelayRightChannelBalance(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn clipAppleLegacyDBDMAToOutputStream32MixRightChannel(const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); #pragma mark ---------------------------------------- #pragma mark еее Input Conversion Routines #pragma mark ---------------------------------------- IOReturn convertAppleLegacyDBDMAFromInputStream16(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn convertAppleLegacyDBDMAFromInputStream16CopyR2L(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn convertAppleLegacyDBDMAFromInputStream16CopyL2R(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); // [3306493] IOReturn convertAppleLegacyDBDMAFromInputStream16WithGain(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn convertAppleLegacyDBDMAFromInputStream16DelayRightWithGain(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn convertAppleLegacyDBDMAFromInputStream32(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn convertAppleLegacyDBDMAFromInputStream32WithGain(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); IOReturn convertAppleLegacyDBDMAFromInputStream32DelayRightWithGain(const void *sampleBuf, void *destBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat); }; #endif /* _APPLEDBDMAAUDIODMAENGINE_H */
050e40de6f7c7e837848744b38f2e90ddf7802cf
f46e4c0aca63425a64c14707facba1d074a5debc
/rona_move/src/Controller/ParabolaTransfere.cpp
42fa03b11fa7015ffdee0e1b71b69eb2d93d27aa
[]
no_license
christianpfitzner/rona
df7c22c36b08415a91ea23620fae56869ca80616
7b8397c981d2a02bc3ef96abc8a828f034a0bfdd
refs/heads/master
2021-04-28T11:01:47.355058
2018-02-20T09:57:04
2018-02-20T09:57:04
122,080,353
0
0
null
2018-02-19T15:16:58
2018-02-19T15:16:57
null
UTF-8
C++
false
false
1,242
cpp
ParabolaTransfere.cpp
/* * ParabolaTransfere.cpp * * Created on: 04.11.2014 * Author: m1ch1 */ #include "ParabolaTransfere.h" #include <string> #include <iostream> namespace controller { ParabolaTransfere::ParabolaTransfere( double max_vel_lin, double max_vel_ang, double parabola_lin_fac, double parabola_ang_fac) { _max_vel_lin = max_vel_lin; _max_vel_ang = max_vel_ang; _parabola_lin_fac = parabola_lin_fac; _parabola_ang_fac = parabola_ang_fac; } ParabolaTransfere::~ParabolaTransfere() { } controller::velocity ParabolaTransfere::control(double linear, double angular) { controller::velocity vel; double ang = angular * _parabola_ang_fac; double sng = ang > 0 ? 1 : -1; vel.angular = (std::abs(ang) < _max_vel_ang ? ang : _max_vel_ang * sng);//this->parabola(_parabola_ang_fac, angular,_max_vel_ang); vel.linear = this->parabola(_parabola_lin_fac, linear, _max_vel_lin); return vel; } double ParabolaTransfere::parabola(double scale, double value, double max_value) { max_value = std::abs(max_value); int sng = value > 0 ? 1 : -1; double tmp = 0; tmp = scale * value; return std::abs(tmp) > max_value ? (max_value * sng) : tmp; } } /* namespace controller */
b0f364ba04b9d5de93cd30dea2dc1cf24c973c46
2495ee0810bdf6f1ea50d7fa0f63b08cc1466c94
/code/opencv249_lbp_08/main.cpp
e00f874bff2462cd993f1719441cf58e2713542e
[]
no_license
jash-git/opencv249_Feature_Detection
8c57c45e8e0574fe18f14a1ae95dc5805029a761
b4a97855ddfc076682a0d85704086b449c58655c
refs/heads/master
2020-04-16T19:21:13.637909
2019-01-31T13:22:54
2019-01-31T13:22:54
165,856,194
1
1
null
null
null
null
BIG5
C++
false
false
3,955
cpp
main.cpp
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/ml/ml.hpp> //3.1的寫法- #include <opencv2/xfeatures2d.hpp> #include <opencv2/features2d/features2d.hpp> #include <opencv2/nonfree/features2d.hpp> #include <opencv2/nonfree/nonfree.hpp> #include "opencv2/objdetect/objdetect.hpp"//HOG #include <iostream> #include <cstdio> #include <sys/timeb.h> #if defined(WIN32) #define TIMEB _timeb #define ftime _ftime typedef __int64 TIME_T; #else #define TIMEB timeb typedef long long TIME_T; #endif using namespace cv; //3.1的寫法- using namespace cv::xfeatures2d; using namespace std; void Pause() { printf("Press Enter key to continue..."); fgetc(stdin); } Mat src, gray_src; int current_radius = 3; int max_count = 20; void ELBP_Demo(int, void*); int main() { src = imread("input.jpg"); if (!src.data) { printf("could not load image...\n"); } else { const char* output_tt = "LBP Result"; namedWindow("input image", CV_WINDOW_AUTOSIZE); namedWindow(output_tt, CV_WINDOW_AUTOSIZE); imshow("input image", src); // convert to gray cvtColor(src, gray_src, COLOR_BGR2GRAY); int width = gray_src.cols; int height = gray_src.rows; // 價掛LBP栳尨 Mat lbpImage = Mat::zeros(gray_src.rows - 2, gray_src.cols - 2, CV_8UC1); for (int row = 1; row < height - 1; row++) { for (int col = 1; col < width - 1; col++) { uchar c = gray_src.at<uchar>(row, col); uchar code = 0; code |= (gray_src.at<uchar>(row - 1, col - 1) > c) << 7; code |= (gray_src.at<uchar>(row - 1, col) > c) << 6; code |= (gray_src.at<uchar>(row - 1, col + 1) > c) << 5; code |= (gray_src.at<uchar>(row, col + 1) > c) << 4; code |= (gray_src.at<uchar>(row + 1, col + 1) > c) << 3; code |= (gray_src.at<uchar>(row + 1, col) > c) << 2; code |= (gray_src.at<uchar>(row + 1, col - 1) > c) << 1; code |= (gray_src.at<uchar>(row, col - 1) > c) << 0; lbpImage.at<uchar>(row - 1, col - 1) = code; } } imshow(output_tt, lbpImage); // ELBP namedWindow("ELBP Result", CV_WINDOW_AUTOSIZE); createTrackbar("ELBP Radius:", "ELBP Result", &current_radius, max_count, ELBP_Demo); ELBP_Demo(0, 0); } waitKey(0); Pause(); return 0; } void ELBP_Demo(int, void*) { int offset = current_radius * 2; Mat elbpImage = Mat::zeros(gray_src.rows - offset, gray_src.cols - offset, CV_8UC1); int width = gray_src.cols; int height = gray_src.rows; int numNeighbors = 8; for (int n = 0; n < numNeighbors; n++) { float x = static_cast<float>(current_radius) * cos(2.0 * CV_PI*n / static_cast<float>(numNeighbors)); float y = static_cast<float>(current_radius) * -sin(2.0 * CV_PI*n / static_cast<float>(numNeighbors)); int fx = static_cast<int>(floor(x)); int fy = static_cast<int>(floor(y)); int cx = static_cast<int>(ceil(x)); int cy = static_cast<int>(ceil(y)); float ty = y - fy; float tx = x - fx; float w1 = (1 - tx)*(1 - ty); float w2 = tx*(1 - ty); float w3 = (1 - tx)* ty; float w4 = tx*ty; for (int row = current_radius; row < (height - current_radius); row++) { for (int col = current_radius; col < (width - current_radius); col++) { float t = w1* gray_src.at<uchar>(row + fy, col + fx) + w2* gray_src.at<uchar>(row + fy, col + cx) + w3* gray_src.at<uchar>(row + cy, col + fx) + w4* gray_src.at<uchar>(row + cy, col + cx); elbpImage.at<uchar>(row- current_radius, col- current_radius) += ((t > gray_src.at<uchar>(row, col)) && (abs(t - gray_src.at<uchar>(row, col)) > std::numeric_limits<float>::epsilon())) << n; } } } imshow("ELBP Result", elbpImage); return; }
15761230733411c79e6a7cc0d409e83cb4f4365d
15dcaffcda41e1f8e4bd1c254384be24950f4327
/HelloWorldTest/chapter_9_10/9_10.cpp
bdb702f19b8cdea71080c70347a2fa2cf81fb349
[ "MIT" ]
permissive
choi2649/C-Study
bbaac6755bfac5ed802c31de648530d28b0e230f
790f0fd8b8c13f392183d2194348b50ad66aba7c
refs/heads/master
2020-08-01T14:13:20.448230
2020-07-07T00:10:03
2020-07-07T00:10:03
211,019,012
0
0
null
null
null
null
UTF-8
C++
false
false
658
cpp
9_10.cpp
#include <iostream> #include <cassert> using namespace std; class Fraction { private: int m_num; int m_den; public: Fraction(char) = delete; Fraction(char,char) = delete; Fraction(int num = 0, int den = 1) :m_num(num), m_den(den) { assert(den != 0); } Fraction(const Fraction &frc) :m_num(frc.m_num), m_den(frc.m_den) { cout << "copy constructor called" << endl; } friend std::ostream & operator << (std::ostream & out, const Fraction & f) { out << f.m_num << " / " << f.m_den << endl; return out; } }; void doSomething(Fraction frac) { cout << frac << endl; } int main() { //Fraction('a','a'); doSomething(7); return 0; }
d05dd5d3a6b155e6404db4ffccb8aa62730143c9
28999c5603d9e9e3db378a37169dccc17ea51f43
/code/foundation/system/win32/win32systeminfo.cc
f0fd85d79a0755a544f3d11144f6f7bd01439d2b
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
gscept/nebula
e973c2b950da93ca30e0432fc6bd6dd6f6a59bdd
4dca6f2a8f1deb2020f1b7d179dd29e1ed45a5fe
refs/heads/master
2023-08-25T06:39:53.517007
2023-08-24T15:30:57
2023-08-24T15:30:57
164,856,783
603
36
NOASSERTION
2023-09-12T22:22:41
2019-01-09T12:14:20
C++
UTF-8
C++
false
false
1,217
cc
win32systeminfo.cc
//------------------------------------------------------------------------------ // win32systeminfo.cc // (C) 2008 Radon Labs GmbH // (C) 2013-2020 Individual contributors, see AUTHORS file //------------------------------------------------------------------------------ #include "foundation/stdneb.h" #include "system/systeminfo.h" #include "system/win32/win32systeminfo.h" namespace System { CpuArchType CpuArch; PlatformType Platform; SizeT NumCpuCores; SizeT PageSize; } namespace Win32 { //------------------------------------------------------------------------------ /** */ Win32SystemInfo::Win32SystemInfo() { // get runtime-info from Windows SYSTEM_INFO sysInfo; ::GetSystemInfo(&sysInfo); switch (sysInfo.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: System::CpuArch = System::X86_64; break; case PROCESSOR_ARCHITECTURE_INTEL: System::CpuArch = System::X86_32; break; default: System::CpuArch = System::UnknownCpuType; break; } System::NumCpuCores = sysInfo.dwNumberOfProcessors; System::PageSize = sysInfo.dwPageSize; System::Platform = System::Win32; } } // namespace Win32
cc135c6167955469505e6d190cb29da54eba7968
cdbdd280ff659ef1c9386948ce6c40d4b87dfb6b
/main.cpp
590198f64e0f3dd326a6b7a5e60c1e283b13212c
[]
no_license
ewalasagas/university_directory
7151f3cc5f7c933275e889ce6459a399f70ec879
34666c39cc12da578cf6dadb64cce482f6000a61
refs/heads/master
2022-12-16T17:19:33.922767
2020-09-18T06:28:17
2020-09-18T06:28:17
293,950,600
0
0
null
null
null
null
UTF-8
C++
false
false
8,414
cpp
main.cpp
/********************************************************************* ** Program name: Lab4 ** Author: Elaine Alasagas ** Date: 2/4/2019 ** Description: CS162_400_WINTER2019 - Instructor.hpp class *********************************************************************/ #include <iostream> #include <string> #include <vector> #include <limits> #include <cmath> #include <algorithm> #include <fstream> #include<bits/stdc++.h> #include "Building.h" #include "University.h" #include "Person.h" #include "Student.h" #include "Instructor.h" using namespace std; int main() { int choice; University *obj = new University(); Student *stu = new Student(); Instructor *instruct = new Instructor(); //for adding in a person string a = stu->getName(); int b = stu->getAge(); double c = stu->getGPA(); //for adding in an instructor string d = instruct->getName(); int e = instruct->getAge(); double f = instruct->getRating(); //People add (manual) vector<Person*> test; test.push_back(new Student("Harry Potter", 12, 4.0)); test.push_back(new Student("Hermione Granger", 12, 4.0)); test.push_back(new Student("Ron Weasley", 12, 3.0)); test.push_back(new Instructor("Minerva McGonagall", 55, 5.0)); test.push_back(new Instructor("Horace Slughorn", 45, 4.8)); test.push_back(new Instructor("Quirinus Quirrell", 38, 2.2)); obj->addPeople(test); //Building add (manual) vector<Building*> test2; test2.push_back(new Building("Adams Hall", 11168, "606 SW 15TH Street, Corvallis, OR")); test2.push_back(new Building("Aero Engineering Lab", 3637, "852 SW 30th street, Corvallis, OR")); test2.push_back(new Building("Agricultural & Life Sciences Building", 185629, "2750 SW Campus Way, Corvallis, OR")); test2.push_back(new Building("Austin Hall", 107613, "2751 SW Jefferson Way, Corvallis, OR")); obj->addBuildlings(test2); obj->displayUniversity(); //Display # of people and buildings std::cout << std::endl; //break char yesorno; do //for loop menu { //Menu std::cout << "Please choose from the following 1-6: " << std::endl; std::cout << "(1) Open file Lab4.txt?" << std::endl; std::cout << "(2) Print information about all buildings " << std::endl; std::cout << "(3) Print information of everbody at the university " << std::endl; std::cout << "(4) Choose a person to do work " << std::endl; std::cout << "(5) Add a person " << std::endl; std::cout << "(6) Exit the program " << std::endl; while (true) //input validation menu choice { std::cout << "Choose: "; if (std::cin >> choice && (choice > 0 && choice < 7)) { break; } else { std::cout << "Please enter a valid choice between 1 and 6" << std::endl; std::cin.clear(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); } } std::cout << std::endl; switch (choice) { //Open file case 1: cout << "File Lab4.txt is open" << std::endl; obj->openFile(); break; //Prints info about buildings case 2: obj->displayBuildings(); break; //Prints info about people case 3: obj->displayPeople(); break; //Print people and get person to do work case 4: char workYN; do { int choiceWork; obj->displayPersonName(); while (true) //input validation menu choice { std::cout << "Please enter the # of the person to do work: " << std::endl; if (std::cin >> choiceWork && (choiceWork > 0 && choiceWork < (obj->getnumPerson()))) { break; } else { std::cout << "Please enter a valid choice between 1 and " << (obj->getnumPerson()-1) << std::endl; std::cin.clear(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); } } obj->doWork(choiceWork); std::cout << "Pick another person to do work? (Y/N) " << std::endl; cin >> workYN; } while (workYN == 'Y' || workYN == 'y'); break; //Add a student or instructor case 5: char add; do { int addPerson; while (true) //input validation menu choice { std::cout << "Choose which person to add: " << endl; std::cout << "(1) Student " << endl; std::cout << "(2) Instructor " << endl; std::cout << "Choice: "; if (std::cin >> addPerson && (addPerson ==1 || addPerson == 2)) { break; } else { std::cout << "Please enter a valid choice between 1 and 2" << std::endl; std::cin.clear(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); } } if (addPerson == 1) //Adding a student { string name2; std::cin.clear(); std::cin.sync(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); std::cout << "Enter Student Name: "; std::getline(std::cin, name2); a = name2; while (true) //input validation menu choice { std::cout << "Enter Student Age: "; if (std::cin >> b && (b > 0)) { break; } else { std::cout << "Please enter a valid choice greater than 0" << std::endl; std::cin.clear(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); } } while (true) //input validation menu choice { std::cout << "Enter Student GPA: "; if (std::cin >> c && (c > 0.0 && c < 4.0)) { break; } else { std::cout << "Please enter a valid GPA between 0 and 4.0" << std::endl; std::cin.clear(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); } } test.push_back(new Student(a, b, c)); obj->addPeople(test); } else if (addPerson == 2) //Adding an instructor { string name1; std::cin.clear(); std::cin.sync(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); std::cout << "Enter Instructor Name: "; std::getline(std::cin, name1); d = name1; while (true) //input validation greater than 0 { std::cout << "Enter Instructor Age: "; if (std::cin >> e && (e > 0)) { break; } else { std::cout << "Please enter a valid choice" << std::endl; std::cin.clear(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); } } while (true) //input validation instructor rating { std::cout << "Enter Instructor Rating: "; if (std::cin >> f && (f > 0.0 && f <= 5.0)) { break; } else { std::cout << "Please enter a valid Rating between 0 and 5.0" << std::endl; std::cin.clear(); std::cin.ignore(numeric_limits<streamsize>::max(), '\n'); } } test.push_back(new Instructor(d, e, f)); obj->addPeople(test); } obj->displayPeople(); std::cout << "Add another person? (Y/N)" << std::endl; std::cin >> add; } while (add == 'Y' || add == 'y'); //Loop for adding a menu break; case 6: //Exit the program std::cout << "Exit program. " << std::endl; //Delete unfreed memory of manual inputted vector of people for (int i = 0; i < test.size(); i++) { delete test[i]; } //Delete unfreed memory of buildings for (int j = 0; j < test2.size(); j++) { delete test2[j]; } delete obj; delete stu; delete instruct; return 0; } //obj->displayPeople(); //Ask user if they want to save to file "Lab4.txt"? char save; std::cout << "Save to file Lab4.txt? (Y/N)" << std::endl; cin >> save; if (save == 'y' || save == 'Y') { obj->peoplePrint(); //prints to file (out) } std::cout << "Return to menu? (Y/N)" << std::endl; std::cin >> yesorno; } while (yesorno == 'Y' || yesorno == 'y'); //Delete unfreed memory of manual inputted vector of people for (int i = 0; i < test.size(); i++) { delete test[i]; } //Delete unfreed memory of buildings for (int j = 0; j < test2.size(); j++) { delete test2[j]; } delete obj; delete stu; delete instruct; return 0; }
cd81f3786ba7a25098315695762dca74e19cc439
00b2421552ae8881c7d71fae6d8747e572e150f2
/Codeforces/powers of two 2.cpp
8d07ec2f204ad8ba945fbe42aedca1bdd3f002b0
[]
no_license
serendiipity/Competitive-Programming
870eabb067e1746ae76d4d6fbf94fe24ae9b6ab1
3ecca29a7d69f8bab44bec646166a3885ae4d2f5
refs/heads/master
2022-05-05T03:48:49.355716
2022-03-17T13:35:22
2022-03-17T13:35:22
184,333,777
0
1
null
null
null
null
UTF-8
C++
false
false
426
cpp
powers of two 2.cpp
#include <iostream> #include <bits/stdc++.h> using namespace std; int p[1000000], e, c; int main() { int n, k; cin >> n >> k; while (n > k && k > 0) { e = log2(n - k + 1); p[c++] = (1 << e); k--; n -= (1 << e); } if (n - k) cout << "NO" << endl; else { for (int i = 0; i < k; i++) p[c++] = 1; cout << "YES" << endl; for (int i = 0; i < c; i++) cout << p[i] << " "; cout << endl; } return 0; }
c25a1100e902a1514082a3f4cdef06aba27987b1
0b63b7b9afc7272044d9fb53b65c1a5800b2b136
/ntile/src/ntile/stats.cpp
ebed2c2ad0530dc7afe1dd759961f06362a6c085
[]
no_license
Kibande/zombie-framework
edb99c875289674815314d06636c63082b93c033
2517d2a5c5243e17a69c85f9f6d04cf827880c8c
refs/heads/master
2020-04-14T22:10:49.527378
2018-11-08T22:10:38
2018-11-08T22:10:38
164,153,682
1
0
null
2019-01-04T20:53:03
2019-01-04T20:53:02
null
UTF-8
C++
false
false
377
cpp
stats.cpp
#include "stats.hpp" #include <cmath> namespace ntile { void Stats::CalculateStats(const BaseStats& base, CharacterStats& stats) { stats.hp = 8 + (int)round(stats.level * base.bhp / 10.0f); stats.str = 2 + (int)round(pow(stats.level, 1.2f) * base.bstr / 40.0f); stats.def = 2 + (int)round(pow(stats.level, 1.2f) * base.bdef / 40.0f); } }
4d5159ee03efc9518e7472a6e7886b1e041dc75f
678328ff5e7d80e31af75bcf9a29c061117a5208
/Scarab-Engine/Source/Engine/Physics/CollisionDetection/BroadPhase/PairListener.inl
bf0ad0d68e68272aafacd2699397782aee470e5d
[]
no_license
SyGame-Engine-Team/SyGame-Engine
48ead0234e92ddae5096e0b00edfbbd0bb484291
1e2e9f174ca6a19394d50b03eb54a3d2bc2066b7
refs/heads/master
2021-01-10T15:05:24.457349
2015-09-29T21:55:15
2015-09-29T21:55:15
43,390,724
4
1
null
null
null
null
UTF-8
C++
false
false
1,597
inl
PairListener.inl
///////////////////////////////////////////////////////////////////////////////// // File : Engine/Physics/CollisionDetection/BroadPhase/PairListener.inl ///////////////////////////////////////////////////////////////////////////////// // Version : 1.0a // Began Code : 29/05/2010 // Status : Alpha // Portability : Any ///////////////////////////////////////////////////////////////////////////////// // Description : Pair events entry point for NarrowPhase. ///////////////////////////////////////////////////////////////////////////////// // Part of Scarab-Engine, licensed under the // Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License // http://creativecommons.org/licenses/by-nc-nd/3.0/ ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // Known Bugs : None ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // NodePair implementation inline Int NodePair::_Compare( const NodePair & leftPair, const NodePair & rightPair, Void * /*pUserData*/ ) { if ( leftPair.pNodeA < rightPair.pNodeA ) return +1; if ( rightPair.pNodeA < leftPair.pNodeA ) return -1; if ( leftPair.pNodeB < rightPair.pNodeB ) return +1; if ( rightPair.pNodeB < leftPair.pNodeB ) return -1; return 0; } ///////////////////////////////////////////////////////////////////////////////// // PairListener implementation
e5afea6687fc34592caf7b85eb739963109ca541
8ee5b1d44a1568b239dce3421145c0dc19e4e6c9
/xx_coro_test2/main.cpp
de7cae1c4497d330b7c48640f58c4fe93d7052f7
[ "MIT" ]
permissive
denghe/xxlib
c38a7be26f877565e02adda974319484f4aa6289
4fc059fe06bcefbcb283fac301b3703cb0d53131
refs/heads/main
2023-08-31T21:06:37.352038
2023-08-29T03:40:57
2023-08-29T03:40:57
343,328,442
18
9
null
null
null
null
UTF-8
C++
false
false
814
cpp
main.cpp
#include "xx_coro_simple.h" #include <thread> #include <iostream> CoType func1() { CoSleep(1s); std::cout << "func1 out" << std::endl; } CoType func2() { CoAwait( func1() ); CoAwait( func1() ); } int main() { xx::Coros cs; auto func = [](int b, int e)->CoType { CoYield; for (size_t i = b; i <= e; i++) { std::cout << i << std::endl; CoYield; } std::cout << b << "-" << e << " end" << std::endl; }; cs.Add(func(1, 5)); cs.Add(func(6, 10)); cs.Add(func(11, 15)); cs.Add([]()->CoType { CoSleep(1s); std::cout << "CoSleep 1s" << std::endl; }()); cs.Add(func2()); LabLoop: cs(); if (cs) { std::this_thread::sleep_for(500ms); goto LabLoop; } return 0; }