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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
33d203598155adc77d4e1af7a943045bb16600d0 | c34899f73da4227bdaf62bd0aeaf244a85cacbcf | /Server/Src/GameServer/GameObject/MapObject.h | 486ba79a59c5a455c21d1ce779cd2a90ac8a1735 | [] | no_license | ylmbtm/GameProject3 | 81864cd38534103961413d03e08a9516ba3307f3 | 356ff268130006d20022e3f0944ad6d36e4c47bb | refs/heads/master | 2023-09-03T10:18:59.569119 | 2023-08-26T09:20:02 | 2023-08-26T09:20:02 | 94,722,275 | 1,259 | 473 | null | 2020-11-07T14:26:11 | 2017-06-19T00:52:15 | C++ | UTF-8 | C++ | false | false | 1,112 | h | MapObject.h | #ifndef __MAP_OBJECT_H__
#define __MAP_OBJECT_H__
class CGrid;
class CScene;
/*
template <typename TContainer, typename TElem>
class CNodeLink
{
public:
CNodeLink()
{
m_pNext = NULL;
m_pPrev = NULL;
m_pContainer = NULL;
}
TElem* m_pNext;
TElem* m_pPrev;
TContainer* m_pContainer;
};
CNodeLink<CGrid, CMapObject> m_GridLink;
*/
class CMapObject
{
public:
CMapObject();
~CMapObject();
public:
BOOL SetUpdate();
CScene* GetScene();
VOID SetScene(CScene* pScene);
CMapObject* NextObject();
CMapObject* PrevObject();
//for (CSceneObject* pSceneObject = grid.GetHeadObject(); pSceneObject != NULL; pSceneObject = (CSceneObject*)pSceneObject->NextObject())
//{
//
//}
public:
CMapObject* m_pObjectNext;
CMapObject* m_pObjectPrev;
public:
CScene* m_pScene;
public:
};
// struct CObjectAi
// {
// virtual INT32 GetAttribute(INT32 nAttriIndex) = 0;
// virtual UINT64 GetTargetID() = 0;
// virtual CSceneObject* GetTargetObject() = 0;
// virtual FLOAT GetTargetDistance() = 0;
// //是否有目标
// };
#endif //__MAP_OBJECT_H__
|
cdb9a9ca983e72b85b4cb5ffece8f4547f457472 | d9b1d932a9bd84e55c207e137692b5fe85fd1c98 | /world/include/world/solid.h | 9dba0b3e3eb257a85edd6443ea8edda54d52b343 | [] | no_license | 1whatleytay/physics | fc4425cc088b4563fb35d16710eab6a3ef3f9c06 | 3812e3a9b4e3de25e867e22496581dd1e28f4689 | refs/heads/master | 2022-03-18T14:40:24.333284 | 2019-12-13T19:07:44 | 2019-12-13T19:07:44 | 227,905,741 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 218 | h | solid.h | #pragma once
#include <engine/thing.h>
class Engine;
class Physics;
class Solid : public Thing {
Physics &physics;
public:
void update() override;
Solid(const Arguments &arguments, Physics &physics);
}; |
df6b3287787c87a9dc3406050561ba64a3f539dc | 8d67a78a26b455aaeb3bfa5e38de8460e2719437 | /LinkedLists/NumberList1.h | 76d66cb71a99e1dbeae0a97842e0cb32dd55ea87 | [] | no_license | crvogt/functions_test | bfb5ebf87c86f61f31ad1a9e8fb8c0333385c582 | bce390a68c6caa91d29a23f97edd2ae547d385bc | refs/heads/master | 2023-03-11T10:21:10.013486 | 2023-02-18T05:44:21 | 2023-02-18T05:44:21 | 27,519,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 563 | h | NumberList1.h | //Specification file for the Numberlist class
#ifndef NUMBERLIST1_H
#define NUMBERLIST1_H
#include <cstddef>
class NumberList1{
private:
//Declare a structure for the list
struct ListNode{
//The value in this node
double value;
//To point to the next node
struct ListNode *next;
};
//List head pointer
ListNode *head;
public:
//Constructor
NumberList1(){
head = NULL;
}
//Destructor
~NumberList1();
//Linked list operations
void appendNode(double);
void insertNode(double);
void deleteNode(double);
void displayList() const;
};
#endif |
db845d93bc0dc3ddafdd6269a85ab8f5e1503b97 | 5e6a6beb0188afb99b48c2ba4eef428137bd629f | /oscitools.h | 17ca07ed77016fc5b2ea21c6281c60b3bc8e4463 | [] | no_license | GlebMan-n/OsciApp | 2919504a80c1463e6cf52a304d3ca7d31fb10e79 | 520ce72f7dc8bac104f8f8bdd925314e0459fcab | refs/heads/master | 2020-03-28T16:30:29.778234 | 2018-09-27T12:41:48 | 2018-09-27T12:41:59 | 148,702,572 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 663 | h | oscitools.h | #ifndef OSCITOOLS_H
#define OSCITOOLS_H
#include <QObject>
class QGraphicsLineItem;
class QPointF;
/*
Класс статических вспомогательных функций
*/
class OsciTools
{
public:
//создание линии по двум точкам
static QGraphicsLineItem* createLineItem(const QPointF &p1,const QPointF &p2);
//создание горизонтальной линии
static QGraphicsLineItem* createHLineItem(qreal y, qreal x1, qreal x2);
//создание вертикальной линии
static QGraphicsLineItem* createVLineItem(qreal x, qreal y1, qreal y2);
};
#endif // OSCITOOLS_H
|
367f8ffbc8c66c945cfee4378830519680d090cd | 519f553b9a35fd0d90ec2a8589c7260585caec90 | /archive/editor/client_for_list_of.h | aecb55688cc4ee89640496ced54329cd291981e1 | [
"MIT"
] | permissive | brettonw/Bedrock-C | f8c169f3529b9af1ef9e6cebc1abc5ce2d94a0b5 | 54e0140db14dcf7c498ae150a113745f2c242b82 | refs/heads/master | 2022-08-15T10:37:03.958674 | 2022-07-19T18:25:23 | 2022-07-19T18:25:23 | 139,098,842 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,600 | h | client_for_list_of.h | //------------------------------------------------------------------------------
// Copyright (C) 1997-2000 Bretton Wade
// All Rights Reserved
//------------------------------------------------------------------------------
#ifndef _BW_CLIENT_FOR_LIST_OF_H_
#define _BW_CLIENT_FOR_LIST_OF_H_
//--------------------------------------------------------------------------
// includes
//--------------------------------------------------------------------------
#ifndef _BW_ITERATOR_ON_LIST_OF_H_
#include "iterator_on_list_of.h"
#endif // _BW_ITERATOR_ON_LIST_OF_H_
//--------------------------------------------------------------------------
// class definitions
//--------------------------------------------------------------------------
template <class aType>
class ClientForListOf : public IteratorOnListOf<aType>
{
public:
ClientForListOf (ListOf<aType>& list);
ClientForListOf (ListOf<aType>* list);
void InsertBeforeCurrentItem (const aType& item);
void InsertAfterCurrentItem (const aType& item);
void RemoveCurrentItem (void);
};
//--------------------------------------------------------------------------
// template methods
//--------------------------------------------------------------------------
template <class aType>
ClientForListOf<aType>::ClientForListOf (ListOf<aType>& list) : IteratorOnListOf<aType> (list)
{
}
//--------------------------------------------------------------------------
template <class aType>
ClientForListOf<aType>::ClientForListOf (ListOf<aType>* list) : IteratorOnListOf<aType> (list)
{
}
//--------------------------------------------------------------------------
template <class aType>
void ClientForListOf<aType>::InsertBeforeCurrentItem (const aType& item)
{
ListNodeOf<aType> *tmp = new ListNodeOf<aType> (item);
tmp->AddToListBefore (myCurrent ? myCurrent : &(myList->mySentinel));
myCurrent = tmp;
myList->mySize++;
}
//--------------------------------------------------------------------------
template <class aType>
void ClientForListOf<aType>::InsertAfterCurrentItem (const aType& item)
{
ListNodeOf<aType> *tmp = new ListNodeOf<aType> (item);
tmp->AddToListAfter (myCurrent ? myCurrent : &(myList->mySentinel));
myCurrent = tmp;
myList->mySize++;
}
//--------------------------------------------------------------------------
template <class aType>
void ClientForListOf<aType>::RemoveCurrentItem (void)
{
assert (myCurrent);
delete myCurrent;
GotoHead ();
myList->mySize--;
}
//--------------------------------------------------------------------------
#endif // _BW_CLIENT_FOR_LIST_OF_H_
|
53b12aaccf989145addfa56ddc8d22a6c18dc1cb | 6d088ec295b33db11e378212d42d40d5a190c54c | /contrib/brl/bseg/boxm2/vecf/ocl/boxm2_vecf_ocl_appearance_extractor.cxx | d0fc05a8b07f044ec36ed6716582ab1c81ac2e2e | [] | no_license | vxl/vxl | 29dffd5011f21a67e14c1bcbd5388fdbbc101b29 | 594ebed3d5fb6d0930d5758630113e044fee00bc | refs/heads/master | 2023-08-31T03:56:24.286486 | 2023-08-29T17:53:12 | 2023-08-29T17:53:12 | 9,819,799 | 224 | 126 | null | 2023-09-14T15:52:32 | 2013-05-02T18:32:27 | C++ | UTF-8 | C++ | false | false | 67,088 | cxx | boxm2_vecf_ocl_appearance_extractor.cxx | #include "boxm2_vecf_ocl_appearance_extractor.h"
#include <boct/boct_bit_tree.h>
#include "../boxm2_vecf_composite_head_parameters.h"
#include "vul/vul_timer.h"
#include <vcl_where_root_dir.h>
void boxm2_vecf_ocl_appearance_extractor::compile_kernels(){
std::string options;
// sets apptypesize_ and app_type
scene_transformer_.get_scene_appearance(head_model_.left_orbit_.scene(), options);
std::cout<<" compiling trans kernel with options "<<options<< std::endl;
std::vector<std::string> src_paths;
std::string source_dir = std::string(VCL_SOURCE_ROOT_DIR) + "/contrib/brl/bseg/boxm2/ocl/cl/";
std::string vecf_source_dir = std::string(VCL_SOURCE_ROOT_DIR)+ "/contrib/brl/bseg/boxm2/vecf/ocl/cl/";
src_paths.push_back(source_dir + "scene_info.cl");
src_paths.push_back(source_dir + "atomics_util.cl");
src_paths.push_back(source_dir + "bit/bit_tree_library_functions.cl");
src_paths.push_back(source_dir + "boxm2_ocl_helpers.cl");
src_paths.push_back(vecf_source_dir + "interp_helpers.cl");
src_paths.push_back(vecf_source_dir + "eyelid_funcs.cl");
src_paths.push_back(vecf_source_dir + "orbit_funcs.cl");
src_paths.push_back(vecf_source_dir + "inverse_map_orbit.cl");
std::cout<<"compiling appearance extraction kernel with "<<options<<std::endl;
auto* appearance_extraction_kernel = new bocl_kernel();
appearance_extraction_kernel->create_kernel(&device_->context(),device_->device_id(), src_paths, "map_to_source_and_extract_appearance", options, "orbit_appearance_extraction");
kernels_.push_back(appearance_extraction_kernel);
std::string options_anatomy = options + " -D ANATOMY_CALC ";
auto* mean_anatomical_appearance_kernel = new bocl_kernel();
mean_anatomical_appearance_kernel->create_kernel(&device_->context(),device_->device_id(), src_paths, "map_to_source_and_extract_appearance", options_anatomy, "orbit_mean_appearance_calc");
kernels_.push_back(mean_anatomical_appearance_kernel);
}
void boxm2_vecf_ocl_appearance_extractor::reset(bool is_right){
ORBIT & orbit = is_right ? head_model_.right_orbit_ : head_model_.left_orbit_;
boxm2_scene_sptr scene = orbit.scene();
total_sclera_app_.fill(0); vis_sclera_ = 0.0f;
total_pupil_app_.fill(0); vis_pupil_ =0.0f;
total_iris_app_.fill(0); vis_iris_ = 0.0f;
total_lower_lid_app_.fill(0); vis_lower_lid_ = 0.0f;
total_upper_lid_app_.fill(0); vis_upper_lid_ = 0.0f;
total_eyelid_crease_app_.fill(0); vis_eyelid_crease_ = 0.0f;
orbit.reset_buffers(true);
}
bool boxm2_vecf_ocl_appearance_extractor::extract_data(boxm2_scene_sptr scene,boxm2_block_id& block,float * &alpha,gray_APM* &gray_app, color_APM* &color_app){
boxm2_data_base* gray_app_db = boxm2_cache::instance()->get_data_base(scene, block,gray_APM_prefix);
boxm2_data_base* alpha_db = boxm2_cache::instance()->get_data_base(scene, block,"alpha");
boxm2_data_base* color_app_db = boxm2_cache::instance()->get_data_base(scene, block, color_APM_prefix + "_" + (head_model_.color_apm_id_));
gray_app = reinterpret_cast<gray_APM*>(gray_app_db->data_buffer());
color_app = reinterpret_cast<color_APM*>(color_app_db->data_buffer());
alpha = reinterpret_cast<boxm2_data_traits<BOXM2_ALPHA>::datatype*>(alpha_db->data_buffer());
if (gray_app && alpha && color_app)
return true;
return false;
}
void boxm2_vecf_ocl_appearance_extractor::extract_head_appearance(){
vul_timer t;
boxm2_scene_sptr base_model = head_model_.scene();
// for each block of the target scene
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
std::vector<boxm2_block_id> target_blocks = target_scene_->get_block_ids();
std::vector<boxm2_block_id> source_blocks = base_model->get_block_ids();
// for each block of the target scene
vgl_rotation_3d<double> id; id.set_identity();
vgl_vector_3d<double> null; null.set(0, 0, 0);
scene_transformer_.transform_1_blk_interp_trilin(base_model,id, null, head_model_.scale_ ,true);
std::cout<<"extracted head appearance model from target in "<<t.real()/1000<<" seconds"<<std::endl;
}
void boxm2_vecf_ocl_appearance_extractor::extract_orbit_appearance(){
std::vector<boxm2_block_id> target_blocks = target_scene_->get_block_ids();
if (target_blocks.size()>1){
std::cout<< "visibility info cannot be used in current implementation if scene contains more than one block"<<std::endl;
current_vis_score_ = nullptr;
}else{
boxm2_data_base* vis_score_db = boxm2_cache::instance()->get_data_base(target_scene_,target_blocks[0],boxm2_data_traits<BOXM2_VIS_SCORE>::prefix(head_model_.color_apm_id_));
current_vis_score_ = reinterpret_cast<vis_score_t*>(vis_score_db->data_buffer());
}
int status;
queue_ = clCreateCommandQueue(device_->context(),*(device_->device_id()),CL_QUEUE_PROFILING_ENABLE,&status);
this->reset(true);
this->reset(false);
#ifdef USE_ORBIT_CL
this->compute_mean_anatomical_appearance(false);
this->compute_mean_anatomical_appearance(true);
this->extract_appearance_one_pass(false);
this->extract_appearance_one_pass(true);
#else
//extract and compute the mean appearance of each anatomy label
this->extract_eye_appearance(true,true);
this->extract_eye_appearance(false,true);
this->extract_iris_appearance(true,true);
this->extract_iris_appearance(false,true);
this->extract_pupil_appearance(true,true);
this->extract_pupil_appearance(false,true);
this->extract_eyelid_crease_appearance(true,true);
this->extract_eyelid_crease_appearance(false,true);
this->extract_lower_lid_appearance(true,true);
this->extract_lower_lid_appearance(false,true);
this->extract_upper_lid_appearance(true,true);
this->extract_upper_lid_appearance(false,true);
// set the appearance of occluded eye voxels to the mean appearance
this->extract_eye_appearance(true,false);
this->extract_eye_appearance(false,false);
this->extract_iris_appearance(true,false);
this->extract_iris_appearance(false,false);
this->extract_pupil_appearance(true,false);
this->extract_pupil_appearance(false,false);
this->extract_eyelid_crease_appearance(true,false);
this->extract_eyelid_crease_appearance(false,false);
this->extract_lower_lid_appearance(true,false);
this->extract_lower_lid_appearance(false,false);
this->extract_upper_lid_appearance(true,false);
this->extract_upper_lid_appearance(false,false);
this->bump_up_vis_scores();
#endif
// #ifdef USE_ORBIT_CL
// head_model_. left_orbit_.update_source_gpu_buffers(true);
// head_model_.right_orbit_.update_source_gpu_buffers(true);
// #endif
}
void boxm2_vecf_ocl_appearance_extractor::extract_iris_appearance(bool is_right,bool extract){
vul_timer t;
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
ORBIT orbit; boxm2_vecf_orbit_params orbit_params, the_other_orbit_params;
if (!is_right){
orbit = head_model_.left_orbit_;
orbit_params = head_params.l_orbit_params_;
the_other_orbit_params = head_params.r_orbit_params_;
}else{
orbit = head_model_.right_orbit_;
orbit_params = head_params.r_orbit_params_;
the_other_orbit_params = head_params.l_orbit_params_;
}
color_APM color =orbit.random_color();
vnl_vector_fixed<double, 3> Z(0.0, 0.0, 1.0);
vnl_vector_fixed<double, 3> to_dir(orbit_params.eye_pointing_dir_.x(),
orbit_params.eye_pointing_dir_.y(),
orbit_params.eye_pointing_dir_.z());
vnl_vector_fixed<double, 3> other_to_dir(the_other_orbit_params.eye_pointing_dir_.x(),
the_other_orbit_params.eye_pointing_dir_.y(),
the_other_orbit_params.eye_pointing_dir_.z());
vgl_rotation_3d<double> rot(Z, to_dir);
vgl_rotation_3d<double> other_rot(Z, other_to_dir);
float sum_vis = 0;
color_APM& curr_iris = is_right ? right_iris_app_ : left_iris_app_;
color_APM& other_iris = is_right ? left_iris_app_ : right_iris_app_;
color_APM final_iris_app;
float8 weighted_sum; weighted_sum.fill(0);
if(!extract && vis_iris_!= 0 ){
float8 final_iris_app_f = total_iris_app_ / vis_iris_;
final_iris_app = to_apm_t(final_iris_app_f);
curr_iris = individual_appearance_ ? curr_iris : final_iris_app;
}
boxm2_scene_sptr source_model = orbit.scene();
std::vector<boxm2_block_id> source_blocks = source_model->get_block_ids();
auto n_source_cells = static_cast<unsigned>(orbit.iris_cell_centers_.size());
std::cout<<"iris cell centers: "<<n_source_cells<<std::endl;
for (auto & source_block : source_blocks) {
color_APM * source_color_data; gray_APM* source_app_data; float* source_alpha_data;
if(!this->extract_data(source_model,source_block,source_alpha_data,source_app_data,source_color_data)){
std::cout<<"Data extraction failed for scene "<< source_model << " in block "<<source_block<<std::endl;
return;
}
for(unsigned i = 0; i<n_source_cells; ++i){
vgl_point_3d<double> p = (orbit.iris_cell_centers_[i]);
if(!orbit.is_type_global(p, ORBIT::IRIS))
continue;
//is a sphere voxel cell so define the vector field
vgl_point_3d<double> local_reflected_p = p;
local_reflected_p = vgl_point_3d<double>(-1 * local_reflected_p.x(), local_reflected_p.y(), local_reflected_p.z()) ;
vgl_point_3d<double> mapped_p = rot * p + orbit_params.offset_ ;
vgl_point_3d<double> reflected_p = other_rot * local_reflected_p + the_other_orbit_params.offset_ ;
// find closest sphere voxel cell
std::vector<boxm2_block_id> target_blocks = target_scene_->get_block_ids();
vgl_point_3d<double> local_tree_coords, target_cell_center; double target_side_len;
for (auto & target_block : target_blocks) {
boxm2_block *target_blk = boxm2_cache::instance()->get_block(target_scene_, target_block);
if ( target_blk->contains( mapped_p, local_tree_coords, target_cell_center, target_side_len )) {
color_APM * target_color_data; gray_APM* target_app_data; float* target_alpha_data; unsigned target_data_idx,reflected_target_data_idx;
if(!this->extract_data(target_scene_,target_block,target_alpha_data,target_app_data,target_color_data)){
std::cout<<"Data extraction failed for scene "<< target_scene_ << " in block "<<target_block<<std::endl;
return ;
}
target_blk->data_index( mapped_p, target_data_idx);
target_blk->data_index( reflected_p, reflected_target_data_idx);
unsigned source_data_idx = orbit.iris_cell_data_index_[i];
source_app_data[source_data_idx] = target_app_data[target_data_idx];
double prob =1 - exp (- target_alpha_data[target_data_idx] * target_side_len);
if(extract){
if (current_vis_score_ && prob > 0.8){
float8 curr_float_col = to_float8(target_color_data[target_data_idx]);
weighted_sum += curr_float_col * current_vis_score_[target_data_idx];
sum_vis += current_vis_score_[target_data_idx];
}
}else{
// float8 appearance = to_float8(target_color_data[target_data_idx]) * current_vis_score_[target_data_idx] + to_float8(curr_iris) * (1 - current_vis_score_[target_data_idx]);
float8 appearance = weight_intesities(current_vis_score_[target_data_idx], current_vis_score_[reflected_target_data_idx], to_float8(target_color_data[target_data_idx]),
to_float8(target_color_data[reflected_target_data_idx]),
to_float8(curr_iris),
to_float8(other_iris));
source_color_data[source_data_idx]= faux_ ? color : to_apm_t(appearance);
}
}
}
}
}
if(sum_vis != 0 && extract){
vis_iris_ += sum_vis;
total_iris_app_ +=weighted_sum;
weighted_sum /= sum_vis;
curr_iris = to_apm_t( weighted_sum );
}
// std::cout<<"Extracted iris appearance in "<<t.real()/1000<<" seconds"<<std::endl;
}
void boxm2_vecf_ocl_appearance_extractor::extract_pupil_appearance(bool is_right, bool extract){
vul_timer t;
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
ORBIT orbit; boxm2_vecf_orbit_params orbit_params, the_other_orbit_params;
if (!is_right){
orbit = head_model_.left_orbit_;
orbit_params = head_params.l_orbit_params_;
the_other_orbit_params = head_params.r_orbit_params_;
}else{
orbit = head_model_.right_orbit_;
orbit_params = head_params.r_orbit_params_;
the_other_orbit_params = head_params.l_orbit_params_;
}
color_APM color =orbit.random_color();
vnl_vector_fixed<double, 3> Z(0.0, 0.0, 1.0);
vnl_vector_fixed<double, 3> to_dir(orbit_params.eye_pointing_dir_.x(),
orbit_params.eye_pointing_dir_.y(),
orbit_params.eye_pointing_dir_.z());
vnl_vector_fixed<double, 3> other_to_dir(the_other_orbit_params.eye_pointing_dir_.x(),
the_other_orbit_params.eye_pointing_dir_.y(),
the_other_orbit_params.eye_pointing_dir_.z());
vgl_rotation_3d<double> rot(Z, to_dir);
vgl_rotation_3d<double> other_rot(Z, other_to_dir);
float sum_vis = 0;
color_APM& curr_pupil = is_right ? right_pupil_app_ : left_pupil_app_;
color_APM& other_pupil = is_right ? left_pupil_app_ : right_pupil_app_;
float8 weighted_sum; weighted_sum.fill(0);
color_APM final_pupil_app;
if(!extract && vis_pupil_!= 0 ){
float8 final_pupil_app_f = total_pupil_app_ / vis_pupil_;
final_pupil_app = to_apm_t(final_pupil_app_f);
curr_pupil = individual_appearance_ ? curr_pupil : final_pupil_app;
}
boxm2_scene_sptr source_model = orbit.scene();
std::vector<boxm2_block_id> source_blocks = source_model->get_block_ids();
auto n_source_cells = static_cast<unsigned>(orbit.pupil_cell_centers_.size());
std::cout<<"pupil cell centers: "<<n_source_cells<<std::endl;
for (auto & source_block : source_blocks) {
color_APM * source_color_data; gray_APM* source_app_data; float* source_alpha_data;
if(!this->extract_data(source_model,source_block,source_alpha_data,source_app_data,source_color_data)){
std::cout<<"Data extraction failed for scene "<< source_model << " in block "<<source_block<<std::endl;
return;
}
for(unsigned i = 0; i<n_source_cells; ++i){
vgl_point_3d<double> p = (orbit.pupil_cell_centers_[i]);
if(!orbit.is_type_global(p, ORBIT::PUPIL))
continue;
//is a sphere voxel cell so define the vector field
vgl_point_3d<double> local_reflected_p = p;
local_reflected_p = vgl_point_3d<double>(-1 * local_reflected_p.x(), local_reflected_p.y(), local_reflected_p.z()) ;
vgl_point_3d<double> mapped_p = rot * p + orbit_params.offset_ ;
vgl_point_3d<double> reflected_p = other_rot * local_reflected_p + the_other_orbit_params.offset_ ;
// find closest sphere voxel cell
std::vector<boxm2_block_id> target_blocks = target_scene_->get_block_ids();
vgl_point_3d<double> local_tree_coords, target_cell_center; double target_side_len;
for (auto & target_block : target_blocks) {
boxm2_block *target_blk = boxm2_cache::instance()->get_block(target_scene_, target_block);
if ( target_blk->contains( mapped_p, local_tree_coords, target_cell_center, target_side_len )) {
color_APM * target_color_data; gray_APM* target_app_data; float* target_alpha_data; unsigned target_data_idx,reflected_target_data_idx;
if(!this->extract_data(target_scene_,target_block,target_alpha_data,target_app_data,target_color_data)){
std::cout<<"Data extraction failed for scene "<< target_scene_ << " in block "<<target_block<<std::endl;
return ;
}
target_blk->data_index( mapped_p, target_data_idx);
target_blk->data_index( reflected_p, reflected_target_data_idx);
unsigned source_data_idx = orbit.pupil_cell_data_index_[i];
uchar8 appearance = faux_ ? color : target_color_data[target_data_idx];
source_app_data[source_data_idx] = target_app_data[target_data_idx];
double prob = 1 - exp (- target_alpha_data[target_data_idx] * target_side_len);
if(extract){
if (current_vis_score_ && prob > 0.8){
float8 curr_float_col = to_float8(target_color_data[target_data_idx]);
weighted_sum += curr_float_col * current_vis_score_[target_data_idx];
sum_vis += current_vis_score_[target_data_idx];
}
}else{
// float8 appearance = to_float8(target_color_data[target_data_idx]) * current_vis_score_[target_data_idx]+
// to_float8(curr_pupil) * (1 - current_vis_score_[target_data_idx]);
float8 appearance = weight_intesities(current_vis_score_[target_data_idx], current_vis_score_[reflected_target_data_idx], to_float8(target_color_data[target_data_idx]),
to_float8(target_color_data[reflected_target_data_idx]),
to_float8(curr_pupil),
to_float8(other_pupil));
source_color_data[source_data_idx] = faux_ ? color : to_apm_t(appearance);
}
}
}
}
}
if(sum_vis != 0 && extract){
vis_pupil_ += sum_vis;
total_pupil_app_ +=weighted_sum;
weighted_sum /= sum_vis;
curr_pupil = to_apm_t( weighted_sum );
}
if(extract)
std::cout<<"Sum vis for current pupil is "<<sum_vis<<std::endl;
// std::cout<<"Extracted pupil appearance in "<<t.real()/1000<<" seconds"<<std::endl;
}
void boxm2_vecf_ocl_appearance_extractor::extract_eye_appearance(bool is_right, bool extract){
vul_timer t;
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
ORBIT orbit,other_orbit; boxm2_vecf_orbit_params orbit_params, the_other_orbit_params;
if (!is_right){
orbit = head_model_.left_orbit_;
other_orbit = head_model_.right_orbit_;
orbit_params = head_params.l_orbit_params_;
the_other_orbit_params = head_params.r_orbit_params_;
}else{
orbit = head_model_.right_orbit_;
other_orbit = head_model_.left_orbit_;
orbit_params = head_params.r_orbit_params_;
the_other_orbit_params = head_params.l_orbit_params_;
}
color_APM color =orbit.random_color();
vnl_vector_fixed<double, 3> Z(0.0, 0.0, 1.0);
vnl_vector_fixed<double, 3> to_dir(orbit_params.eye_pointing_dir_.x(),
orbit_params.eye_pointing_dir_.y(),
orbit_params.eye_pointing_dir_.z());
vnl_vector_fixed<double, 3> other_to_dir(the_other_orbit_params.eye_pointing_dir_.x(),
the_other_orbit_params.eye_pointing_dir_.y(),
the_other_orbit_params.eye_pointing_dir_.z());
vgl_rotation_3d<double> rot(Z, to_dir);
vgl_rotation_3d<double> other_rot(Z, other_to_dir);
float sum_vis = 0;
color_APM& curr_sclera = is_right ? right_sclera_app_ : left_sclera_app_;
color_APM& other_sclera = is_right ? left_sclera_app_ : right_sclera_app_;
float8 weighted_sum; weighted_sum.fill(0);
color_APM final_sclera_app;
if(!extract && vis_sclera_!= 0 ){
float8 final_sclera_app_f = total_sclera_app_ / vis_sclera_;
final_sclera_app = to_apm_t(final_sclera_app_f);
curr_sclera = individual_appearance_ ? curr_sclera : final_sclera_app;
}
boxm2_scene_sptr source_model = orbit.scene();
std::vector<boxm2_block_id> source_blocks = source_model->get_block_ids();
auto n_source_cells = static_cast<unsigned>(orbit.sphere_cell_centers_.size());
std::cout<<"sphere cell centers: "<<n_source_cells<<std::endl;
for (auto & source_block : source_blocks) {
color_APM * source_color_data; gray_APM* source_app_data; float* source_alpha_data;
if(!this->extract_data(source_model,source_block,source_alpha_data,source_app_data,source_color_data)){
std::cout<<"Data extraction failed for scene "<< source_model << " in block "<<source_block<<std::endl;
return;
}
for(unsigned i = 0; i<n_source_cells; ++i){
vgl_point_3d<double> p = (orbit.sphere_cell_centers_[i]);
vgl_point_3d<double> test_p = (other_orbit.sphere_cell_centers_[i]);
if(!orbit.is_type_global(p, ORBIT::SPHERE) ||
orbit.is_type_global(p, ORBIT::IRIS ) ||
orbit.is_type_global(p, ORBIT::PUPIL ) )
continue;
//is a sphere voxel cell so define the vector field
vgl_point_3d<double> local_reflected_p = p;
local_reflected_p = vgl_point_3d<double>(-1 * local_reflected_p.x(), local_reflected_p.y(), local_reflected_p.z()) ;
vgl_point_3d<double> mapped_p = rot * p + orbit_params.offset_ ;
vgl_point_3d<double> reflected_p = other_rot * local_reflected_p + the_other_orbit_params.offset_ ;
if((p-test_p).length()>0.01)
std::cout<<"point difference is "<<p<<" "<<test_p<<std::endl;
// find closest sphere voxel cell
std::vector<boxm2_block_id> target_blocks = target_scene_->get_block_ids();
vgl_point_3d<double> local_tree_coords, target_cell_center; double target_side_len;
for (auto & target_block : target_blocks) {
boxm2_block *target_blk = boxm2_cache::instance()->get_block(target_scene_, target_block);
if ( target_blk->contains( mapped_p, local_tree_coords, target_cell_center, target_side_len )) {
color_APM * target_color_data; gray_APM* target_app_data; float* target_alpha_data; unsigned target_data_idx,reflected_target_data_idx;
if(!this->extract_data(target_scene_,target_block,target_alpha_data,target_app_data,target_color_data)){
std::cout<<"Data extraction failed for scene "<< target_scene_ << " in block "<<target_block<<std::endl;
return ;
}
target_blk->data_index( mapped_p, target_data_idx);
target_blk->data_index( reflected_p, reflected_target_data_idx);
unsigned source_data_idx = orbit.sphere_cell_data_index_[i];
unsigned other_source_data_idx = other_orbit.sphere_cell_data_index_[i];
if(source_data_idx - other_source_data_idx != 0)
std::cout<<" data indices are different "<<other_source_data_idx<<" "<<source_data_idx<<std::endl;
uchar8 appearance = faux_ ? color : target_color_data[target_data_idx];
source_app_data [source_data_idx] = target_app_data[target_data_idx];
double prob =1 - exp (- target_alpha_data[target_data_idx] * target_side_len);
if(extract){
if (current_vis_score_ && prob > 0.8){
float8 curr_float_col = to_float8(target_color_data[target_data_idx]);
weighted_sum += curr_float_col * current_vis_score_[target_data_idx];
sum_vis += current_vis_score_[target_data_idx];
}
}else{
float8 appearance = weight_intesities(current_vis_score_[target_data_idx], current_vis_score_[reflected_target_data_idx],
to_float8(target_color_data[target_data_idx]),
to_float8(target_color_data[reflected_target_data_idx]),
to_float8(final_sclera_app),
to_float8(other_sclera));
source_color_data[source_data_idx]= faux_ ? color : to_apm_t(appearance);
}
}
}
}
}
if(sum_vis != 0 && extract){
vis_sclera_ += sum_vis;
total_sclera_app_ +=weighted_sum;
weighted_sum /= sum_vis;
curr_sclera = to_apm_t( weighted_sum );
}
// std::cout<<"Extracted eye sphere appearance in "<<t.real()/1000<<" seconds"<<std::endl;
}
void boxm2_vecf_ocl_appearance_extractor::extract_eyelid_crease_appearance(bool is_right, bool extract){
vul_timer t;
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
ORBIT orbit,other_orbit; boxm2_vecf_orbit_params orbit_params, the_other_orbit_params;
if (!is_right){
orbit = head_model_.left_orbit_;
other_orbit = head_model_.right_orbit_;
orbit_params = head_params.l_orbit_params_;
the_other_orbit_params = head_params.r_orbit_params_;
}else{
orbit = head_model_.right_orbit_;
other_orbit = head_model_.left_orbit_;
orbit_params = head_params.r_orbit_params_;
the_other_orbit_params = head_params.l_orbit_params_;
}
color_APM color =orbit.random_color();
boxm2_scene_sptr source_model = orbit.scene();
float sum_vis = 0;
color_APM& curr_eyelid_crease = is_right ? right_eyelid_crease_app_ : left_eyelid_crease_app_ ;
color_APM& other_eyelid_crease = is_right ? left_eyelid_crease_app_ : right_eyelid_crease_app_ ;
float8 weighted_sum; weighted_sum.fill(0);
std::vector<boxm2_block_id> source_blocks = source_model->get_block_ids();
auto n_source_cells = static_cast<unsigned>(orbit.eyelid_crease_cell_centers_.size());
std::cout<<"eyelid crease cell centers "<<n_source_cells<<std::endl;
for (auto & source_block : source_blocks) {
color_APM * source_color_data; gray_APM* source_app_data; float* source_alpha_data;
if(!this->extract_data(source_model,source_block,source_alpha_data,source_app_data,source_color_data)){
std::cout<<"Data extraction failed for scene "<< source_model << " in block "<<source_block<<std::endl;
return;
}
for(unsigned i = 0; i<n_source_cells; ++i){
vgl_point_3d<double> p = (orbit.eyelid_crease_cell_centers_[i]);
if(!orbit.is_type_global(p, ORBIT::EYELID_CREASE))
continue;
//is a sphere voxel cell so define the vector field
vgl_point_3d<double> local_reflected = p;
if (is_right){
local_reflected =vgl_point_3d<double>(-1 * local_reflected.x(), local_reflected.y() , local_reflected.z());
}
//is a sphere voxel cell so define the vector field
vgl_point_3d<double> mapped_p = (local_reflected + orbit_params.offset_) ;
vgl_vector_3d<double> flip(-2 * mapped_p.x(),0,0);
vgl_point_3d <double> reflected_p = mapped_p + flip;
std::vector<boxm2_block_id> target_blocks = target_scene_->get_block_ids();
vgl_point_3d<double> local_tree_coords, target_cell_center; double target_side_len;
for (auto & target_block : target_blocks) {
boxm2_block *target_blk = boxm2_cache::instance()->get_block(target_scene_, target_block);
if ( target_blk->contains( mapped_p, local_tree_coords, target_cell_center, target_side_len )) {
color_APM * target_color_data; gray_APM* target_app_data; float* target_alpha_data; unsigned target_data_idx,reflected_target_data_idx;
if(!this->extract_data(target_scene_,target_block,target_alpha_data,target_app_data,target_color_data)){
std::cout<<"Data extraction failed for scene "<< target_scene_ << " in block "<<target_block<<std::endl;
return ;
}
target_blk->data_index( mapped_p, target_data_idx);
target_blk->data_index( reflected_p, reflected_target_data_idx);
unsigned source_data_idx = orbit.eyelid_crease_cell_data_index_[i];
double prob =1 - exp (- target_alpha_data[target_data_idx] * target_side_len);
source_app_data[source_data_idx] = target_app_data[target_data_idx];
if(extract){
if (current_vis_score_ && prob > 0.8){
float8 curr_float_col = to_float8(target_color_data[target_data_idx]);
weighted_sum += curr_float_col * current_vis_score_[target_data_idx];
sum_vis += current_vis_score_[target_data_idx];
}
}else{
float8 appearance = weight_intesities(current_vis_score_[target_data_idx], current_vis_score_[reflected_target_data_idx],
to_float8(target_color_data[target_data_idx]),
to_float8(target_color_data[reflected_target_data_idx]),
to_float8(curr_eyelid_crease),
to_float8(other_eyelid_crease));
source_color_data[source_data_idx] = faux_ ? color : to_apm_t(appearance);
}
}
}
}
}
if(sum_vis != 0 && extract){
vis_eyelid_crease_ += sum_vis;
total_eyelid_crease_app_ += weighted_sum;
weighted_sum /= sum_vis;
curr_eyelid_crease = to_apm_t( weighted_sum );
}
// std::cout<<"Extracted eyelid crease appearance in "<<t.real()/1000<<" seconds and sum_vis is "<<sum_vis<<std::endl;
}
void boxm2_vecf_ocl_appearance_extractor::extract_lower_lid_appearance(bool is_right,bool extract){
vul_timer t;
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
ORBIT orbit,other_orbit; boxm2_vecf_orbit_params orbit_params, the_other_orbit_params;
if (!is_right){
orbit = head_model_.left_orbit_;
other_orbit = head_model_.right_orbit_;
orbit_params = head_params.l_orbit_params_;
the_other_orbit_params = head_params.r_orbit_params_;
}else{
orbit = head_model_.right_orbit_;
other_orbit = head_model_.left_orbit_;
orbit_params = head_params.r_orbit_params_;
the_other_orbit_params = head_params.l_orbit_params_;
}
color_APM& curr_lower_eyelid = is_right ? right_lower_lid_app_: left_lower_lid_app_;
color_APM& other_lower_eyelid = is_right ? left_lower_lid_app_ : right_lower_lid_app_;
color_APM final_lower_lid_app;
if(!extract && vis_lower_lid_!= 0 ){
float8 final_lower_lid_app_f = total_lower_lid_app_ / vis_lower_lid_;
final_lower_lid_app = to_apm_t(final_lower_lid_app_f);
curr_lower_eyelid = individual_appearance_ ? curr_lower_eyelid : final_lower_lid_app;
}
color_APM color =orbit.random_color();
boxm2_scene_sptr source_model = orbit.scene();
float8 weighted_sum; weighted_sum.fill(0); float sum_vis =0.0f;
std::vector<boxm2_block_id> source_blocks = source_model->get_block_ids();
auto n_source_cells = static_cast<unsigned>(orbit.lower_eyelid_cell_centers_.size());
std::cout<<"lower lid cell centers "<<n_source_cells<<std::endl;
for (auto & source_block : source_blocks) {
color_APM * source_color_data; gray_APM* source_app_data; float* source_alpha_data;
if(!this->extract_data(source_model,source_block,source_alpha_data,source_app_data,source_color_data)){
std::cout<<"Data extraction failed for scene "<< source_model << " in block "<<source_block<<std::endl;
return;
}
for(unsigned i = 0; i< n_source_cells; ++i){
vgl_point_3d<double> p = (orbit.lower_eyelid_cell_centers_[i]);
if(!orbit.is_type_global(p, ORBIT::LOWER_LID))
continue;
vgl_point_3d<double> local_reflected = p;
if (is_right){
local_reflected =vgl_point_3d<double>(-1 * local_reflected.x(), local_reflected.y() , local_reflected.z());
}
//is a sphere voxel cell so define the vector field
vgl_point_3d <double> mapped_p = (local_reflected + orbit_params.offset_) ;
vgl_point_3d <double> reflected_p = vgl_point_3d<double>(-1 * mapped_p.x(), mapped_p.y() , mapped_p.z());
// find closest sphere voxel cell
std::vector<boxm2_block_id> target_blocks = target_scene_->get_block_ids();
vgl_point_3d<double> local_tree_coords, target_cell_center; double target_side_len;
for (auto & target_block : target_blocks) {
boxm2_block *target_blk = boxm2_cache::instance()->get_block(target_scene_, target_block);
if ( target_blk->contains( mapped_p, local_tree_coords, target_cell_center, target_side_len )) {
color_APM * target_color_data; gray_APM* target_app_data; float* target_alpha_data; unsigned target_data_idx,reflected_target_data_idx;
if(!this->extract_data(target_scene_,target_block,target_alpha_data,target_app_data,target_color_data)){
std::cout<<"Data extraction failed for scene "<< target_scene_ << " in block "<<target_block<<std::endl;
return ;
}
target_blk->data_index( mapped_p, target_data_idx);
target_blk->data_index( reflected_p, reflected_target_data_idx);
unsigned source_data_idx = orbit.lower_eyelid_cell_data_index_[i];
source_app_data[source_data_idx] = target_app_data[target_data_idx];
uchar8 appearance = faux_ ? color : target_color_data[target_data_idx];
source_color_data[source_data_idx] = appearance;
double prob = 1 - exp (- target_alpha_data[target_data_idx] * target_side_len);
if(extract){
if (current_vis_score_ && prob > 0.8){
float8 curr_float_col = to_float8(target_color_data[target_data_idx]);
weighted_sum += curr_float_col * current_vis_score_[target_data_idx];
sum_vis += current_vis_score_[target_data_idx];
}
}else{
float8 appearance = weight_intesities(current_vis_score_[target_data_idx], current_vis_score_[reflected_target_data_idx],
to_float8(target_color_data[target_data_idx]),
to_float8(target_color_data[reflected_target_data_idx]),
to_float8(curr_lower_eyelid),
to_float8(other_lower_eyelid));
source_color_data[source_data_idx] = faux_ ? color : to_apm_t(appearance);
vis_cells_.push_back(target_data_idx); //need to set the vis of this index to 1
}
}
}
}
}
if(sum_vis != 0 && extract){
vis_lower_lid_ += sum_vis;
total_lower_lid_app_ += weighted_sum;
weighted_sum /= sum_vis;
curr_lower_eyelid = to_apm_t( weighted_sum );
}
// std::cout<<"Extracted lower lid appearance in "<<t.real()/1000<<" seconds"<<std::endl;
}
void boxm2_vecf_ocl_appearance_extractor::extract_upper_lid_appearance(bool is_right,bool extract){
vul_timer t;
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
ORBIT orbit,other_orbit; boxm2_vecf_orbit_params orbit_params, the_other_orbit_params;
if (!is_right){
orbit = head_model_.left_orbit_;
other_orbit = head_model_.right_orbit_;
orbit_params = head_params.l_orbit_params_;
the_other_orbit_params = head_params.r_orbit_params_;
}else{
orbit = head_model_.right_orbit_;
other_orbit = head_model_.left_orbit_;
orbit_params = head_params.r_orbit_params_;
the_other_orbit_params = head_params.l_orbit_params_;
}
uchar8 red,blue; red.fill(0);blue.fill(0); red[0] =255; red[2]=255; blue[1] = 255;
color_APM color =orbit.random_color();
double dt = 0.95;
color_APM eyelid_color = is_right? red : blue;
color[0]=0; color[1]=0; color[2]=255;
float8 weighted_sum; weighted_sum.fill(0); float sum_vis =0.0f;
boxm2_scene_sptr source_model = orbit.scene();
color_APM& curr_lower_lid = is_right ? right_lower_lid_app_ : left_lower_lid_app_ ;
color_APM& curr_upper_lid = is_right ? right_upper_lid_app_ : left_upper_lid_app_ ;
color_APM& curr_eyelid_crease = is_right ? right_eyelid_crease_app_ : left_eyelid_crease_app_ ;
color_APM& other_lower_lid = is_right ? left_lower_lid_app_ : right_lower_lid_app_ ;
color_APM& other_upper_lid = is_right ? left_upper_lid_app_ : right_upper_lid_app_ ;
color_APM& other_eyelid_crease = is_right ? left_eyelid_crease_app_ : right_eyelid_crease_app_ ;
color_APM final_upper_lid_app,final_lower_lid_app,final_eyelid_crease_app;
if(!extract && vis_upper_lid_!= 0 ){
float8 final_upper_lid_app_f = total_upper_lid_app_ / vis_upper_lid_;
final_upper_lid_app = to_apm_t(final_upper_lid_app_f);
curr_upper_lid = individual_appearance_ ? curr_upper_lid : final_upper_lid_app;
}
float8 final_lower_lid_app_f = total_lower_lid_app_ / vis_lower_lid_;
final_lower_lid_app = to_apm_t(final_lower_lid_app_f);
float8 final_eyelid_crease_app_f = total_eyelid_crease_app_ / vis_eyelid_crease_;
final_eyelid_crease_app = to_apm_t(final_eyelid_crease_app_f);
uchar8 curr_lower_lid_scaled = final_lower_lid_app;
uchar8 curr_eyelid_crease_scaled = final_eyelid_crease_app;
std::vector<boxm2_block_id> source_blocks = source_model->get_block_ids();
for (auto & source_block : source_blocks) {
boxm2_block *source_blk = boxm2_cache::instance()->get_block(source_model, source_block);
auto n_source_cells = static_cast<unsigned>(orbit.eyelid_cell_centers_.size());
color_APM * source_color_data; gray_APM* source_app_data; float* source_alpha_data;
if(!this->extract_data(source_model,source_block,source_alpha_data,source_app_data,source_color_data)){
std::cout<<"Data extraction failed for scene "<< source_model << " in block "<<source_block<<std::endl;
return;
}
for(unsigned i = 0; i < n_source_cells; ++i){
bool skip = false;vgl_point_3d<double> loc_p;
vgl_point_3d<double> p = (orbit.eyelid_cell_centers_[i]);
if(!orbit.is_type_global(p, ORBIT::UPPER_LID) ){
//#if _DEBUG
if(is_right)
std::cout<<"this right eyelid point "<<p<<" was not ok w.r.t label type"<<std::endl;
else
std::cout<<"this left eyelid point "<<p<<" was not ok w.r.t label type"<<std::endl;
continue;
//#endif
}
if(!(source_blk->contains(p, loc_p) )){
#if _DEBUG
if(is_right)
std::cout<<"this right eyelid point "<<p<<" was not in bounds"<<std::endl;
else
std::cout<<"this left eyelid point "<<p<<" was not in bounds"<<std::endl;
#endif
continue;
}
//is a sphere voxel cell so define the vector field
double tc = orbit.eyelid_geo_.t(p.x(), p.y());
if(!orbit.eyelid_geo_.valid_t(tc)){
#if _DEBUG
std::cout<<"this eyelid point "<<p<<" was not ok w.r.t tc"<<std::endl;
continue;
#endif
}
// inverse field so negate dt
double ti = tc - dt;
if(!orbit.eyelid_geo_.valid_t(ti)){
skip = true;
}
if (is_right){
p =vgl_point_3d<double>(-1 * p.x(), p.y() , p.z());
}
float intensity_scale = tc > 0.7f ? 0.8f : 1.0f;
color_APM darker_lower_lid = curr_lower_lid_scaled;
darker_lower_lid[0] *= 0.95;
curr_lower_lid_scaled[0] = static_cast<unsigned char> ((0.96 - tc) * darker_lower_lid[0] +
(tc) * final_lower_lid_app [0]);
curr_lower_lid_scaled[0] = static_cast<unsigned char>( intensity_scale * (float) curr_lower_lid_scaled[0] );
//is a sphere voxel cell so define the vector field
vgl_point_3d<double> mapped_p = (p + orbit_params.offset_) ;
vgl_vector_3d<double> flip(-2 * mapped_p.x(),0,0);
vgl_point_3d <double> reflected_p = mapped_p + flip;
// find closest sphere voxel cell
std::vector<boxm2_block_id> target_blocks = target_scene_->get_block_ids();
vgl_point_3d<double> local_tree_coords, target_cell_center; double target_side_len;
for (auto & target_block : target_blocks) {
boxm2_block *target_blk = boxm2_cache::instance()->get_block(target_scene_, target_block);
if ( target_blk->contains( mapped_p, local_tree_coords, target_cell_center, target_side_len )) {
color_APM * target_color_data; gray_APM* target_app_data; float* target_alpha_data; unsigned target_data_idx, reflected_target_data_idx;
if(!this->extract_data(target_scene_,target_block,target_alpha_data,target_app_data,target_color_data)){
std::cout<<"Data extraction failed for scene "<< target_scene_ << " in block "<<target_block<<std::endl;
return ;
}
target_blk->data_index( mapped_p, target_data_idx);
target_blk->data_index( reflected_p, reflected_target_data_idx);
unsigned source_data_idx = orbit.eyelid_cell_data_index_[i];
source_app_data [source_data_idx] = target_app_data [target_data_idx];
double prob = 1 - exp (- target_alpha_data[target_data_idx] * target_side_len);
if(extract){
if (current_vis_score_ && prob > 0.8 && !skip ){
float8 curr_float_col = to_float8(target_color_data[target_data_idx]);
weighted_sum += curr_float_col * current_vis_score_[target_data_idx];
sum_vis += current_vis_score_[target_data_idx];
}
}else{
float8 appearance = weight_intesities(current_vis_score_[target_data_idx], current_vis_score_[reflected_target_data_idx],
to_float8(target_color_data[target_data_idx]),
to_float8(target_color_data[reflected_target_data_idx]),
to_float8(curr_lower_lid_scaled),
to_float8(other_lower_lid));
source_color_data[source_data_idx]= faux_ ? color : to_apm_t(appearance);
if(skip)
source_color_data[source_data_idx]= faux_ ? color: curr_lower_lid_scaled;
vis_cells_.push_back(target_data_idx); //need to set the vis of this index to 1
}
}
}
}
}
if(sum_vis != 0 && extract){
vis_upper_lid_ += sum_vis;
total_upper_lid_app_ += weighted_sum;
weighted_sum /= sum_vis;
curr_upper_lid = to_apm_t( weighted_sum );
}
// std::cout<<"Extracted upper lid appearance in "<<t.real()/1000<<" seconds"<<std::endl;
}
void boxm2_vecf_ocl_appearance_extractor::bump_up_vis_scores(){
// for (std::vector<unsigned>::iterator it =vis_cells_.begin() ; it != vis_cells_.end(); it++)
// current_vis_score_[*it] = 1;
}
#ifdef USE_ORBIT_CL
bool boxm2_vecf_ocl_appearance_extractor::extract_appearance_one_pass(bool is_right)
{
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
boxm2_vecf_ocl_orbit_scene orbit,other_orbit; boxm2_vecf_orbit_params orbit_params, other_orbit_params;
if (!is_right){
orbit = head_model_.left_orbit_;
other_orbit = head_model_.right_orbit_;
orbit_params = head_params.l_orbit_params_;
other_orbit_params = head_params.r_orbit_params_;
}else{
orbit = head_model_.right_orbit_;
other_orbit = head_model_.left_orbit_;
orbit_params = head_params.r_orbit_params_;
other_orbit_params = head_params.l_orbit_params_;
}
color_APM& curr_sclera_app = is_right ? right_sclera_app_ : left_sclera_app_;
color_APM& curr_pupil_app = is_right ? right_pupil_app_ : left_pupil_app_;
color_APM& curr_iris_app = is_right ? right_iris_app_ : left_iris_app_;
color_APM& curr_upper_lid_app = is_right ? right_upper_lid_app_ : left_upper_lid_app_;
color_APM& curr_lower_lid_app = is_right ? right_lower_lid_app_ : left_lower_lid_app_;
color_APM& curr_eyelid_crease_app = is_right ? right_eyelid_crease_app_ : left_eyelid_crease_app_;
float8 null ; null.fill(0);
float8 final_sclera_app = vis_sclera_ !=0 ? (total_sclera_app_/vis_sclera_) : null;
float8 final_pupil_app = vis_pupil_ !=0 ? (total_pupil_app_/vis_pupil_) : null;
float8 final_iris_app = vis_iris_ !=0 ? (total_iris_app_/vis_iris_) : null;
float8 final_upper_lid_app = vis_upper_lid_ !=0 ? (total_upper_lid_app_/vis_upper_lid_) : null;
float8 final_lower_lid_app = vis_lower_lid_ !=0 ? (total_lower_lid_app_/vis_lower_lid_) : null;
float8 final_eyelid_crease_app = vis_eyelid_crease_!=0 ? (total_eyelid_crease_app_/vis_eyelid_crease_) : null;
float8 app[6],total_app[6];
app[0] = to_float8 (curr_sclera_app) ; total_app[0] = final_sclera_app;
app[1] = to_float8 (curr_iris_app) ; total_app[1] = final_iris_app;
app[2] = to_float8 (curr_pupil_app) ; total_app[2] = final_pupil_app;
app[3] = to_float8 (curr_upper_lid_app) ; total_app[3] = final_upper_lid_app;
app[4] = to_float8 (curr_lower_lid_app) ; total_app[4] = final_lower_lid_app;
app[5] = to_float8 (curr_eyelid_crease_app) ; total_app[5] = final_eyelid_crease_app;
std::cout<<" mean eyelid intensity "<<total_app[3][0]<<" "<<total_app[3][1]<<" "<<total_app[3][2]<<std::endl;
float offset_buff [4],other_offset_buff [4];
float rotation_buff[9],other_rotation_buff[9];
float curr_dt = - orbit_params.eyelid_dt_;
bool good_buffs = true;
unsigned char is_right_buf = is_right;
vnl_vector_fixed<double, 3> other_to_dir(other_orbit_params.eye_pointing_dir_.x(),
other_orbit_params.eye_pointing_dir_.y(),
other_orbit_params.eye_pointing_dir_.z());
vnl_vector_fixed<double, 3> Z(0.0, 0.0, 1.0);
vnl_vector_fixed<double, 3> to_dir(orbit_params.eye_pointing_dir_.x(),
orbit_params.eye_pointing_dir_.y(),
orbit_params.eye_pointing_dir_.z());
vgl_rotation_3d<double> rot(Z, to_dir);
vgl_rotation_3d<double> other_rot(Z, other_to_dir);
offset_buff[0] = orbit_params.offset_.x(); other_offset_buff[0] = other_orbit_params.offset_.x();
offset_buff[1] = orbit_params.offset_.y(); other_offset_buff[1] = other_orbit_params.offset_.y();
offset_buff[2] = orbit_params.offset_.z(); other_offset_buff[2] = other_orbit_params.offset_.z();
vnl_matrix_fixed<double, 3, 3> R = rot.as_matrix();
rotation_buff[0] =(float) R(0,0); rotation_buff[3] =(float) R(1,0); rotation_buff[6] =(float) R(2,0);
rotation_buff[1] =(float) R(0,1); rotation_buff[4] =(float) R(1,1); rotation_buff[7] =(float) R(2,1);
rotation_buff[2] =(float) R(0,2); rotation_buff[5] =(float) R(1,2); rotation_buff[8] =(float) R(2,2);
vnl_matrix_fixed<double, 3, 3> other_R = other_rot.as_matrix();
other_rotation_buff[0] =(float) other_R(0,0); other_rotation_buff[3] =(float) other_R(1,0); other_rotation_buff[6] =(float) other_R(2,0);
other_rotation_buff[1] =(float) other_R(0,1); other_rotation_buff[4] =(float) other_R(1,1); other_rotation_buff[7] =(float) other_R(2,1);
other_rotation_buff[2] =(float) other_R(0,2); other_rotation_buff[5] =(float) other_R(1,2); other_rotation_buff[8] =(float) other_R(2,2);
bocl_mem_sptr rotation_l = new bocl_mem(device_->context(), rotation_buff, sizeof(float)*9, " rotation " );
good_buffs &= rotation_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr other_rotation_l = new bocl_mem(device_->context(), other_rotation_buff, sizeof(float)*9, " other_rotation " );
good_buffs &= other_rotation_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr offset_l = new bocl_mem(device_->context(), offset_buff, sizeof(float)*4, " offset " );
good_buffs &= offset_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr other_offset_l = new bocl_mem(device_->context(), other_offset_buff, sizeof(float)*4, "other offset " );
good_buffs &= other_offset_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr mean_app_l = new bocl_mem(device_->context(), app, sizeof(float8)*6, " mean app buff " );
good_buffs &= mean_app_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr total_app_l = new bocl_mem(device_->context(), total_app, sizeof(float8)*6, " total_mean app buff " );
good_buffs &= total_app_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr is_right_cl = new bocl_mem(device_->context(), &is_right_buf, sizeof(char), " mean app buff " );
good_buffs &= is_right_cl->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr dt_l = new bocl_mem(device_->context(), &curr_dt , sizeof(float), " dt buff " );
good_buffs &= dt_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr max_t_l = new bocl_mem(device_->context(), &max_t_color , sizeof(float), " max t color buff " );
good_buffs &= max_t_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
std::size_t local_threads[1]={64};
std::size_t global_threads[1]={1};
std::vector<boxm2_block_id> blocks_target = target_scene_->get_block_ids();
std::vector<boxm2_block_id> blocks_source = orbit.scene()->get_block_ids();
auto iter_blk_target = blocks_target.begin();
auto iter_blk_source = blocks_source.begin();
if(blocks_target.size()!=1||blocks_source.size()!=1)
return false;
boxm2_scene_info* info_buffer_source = orbit.scene()->get_blk_metadata(*iter_blk_source);
boxm2_scene_info* info_buffer_target = target_scene_->get_blk_metadata(*iter_blk_target);
auto target_data_size = (std::size_t) orbit.target_blk_->num_cells();
info_buffer_target->data_buffer_length = target_data_size;
bocl_mem_sptr blk_info_target = new bocl_mem(device_->context(), info_buffer_target, sizeof(boxm2_scene_info), " Scene Info Target" );
good_buffs &= blk_info_target->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR);
blk_info_target->write_to_buffer(queue_);
bocl_mem_sptr blk_info_source = new bocl_mem(device_->context(), info_buffer_source, sizeof(boxm2_scene_info), " Scene Info Source" );
std::size_t source_data_size = (int) orbit.blk_->num_cells();
info_buffer_source->data_buffer_length = source_data_size;
blk_info_source->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR);
blk_info_source->write_to_buffer(queue_);
auto* output = new float[source_data_size];
bocl_mem_sptr output_cl = new bocl_mem(device_->context(), output, source_data_size * sizeof(float), "Output buf" );
good_buffs &= output_cl->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
if(!good_buffs)
return false;
// output_cl->zero_gpu_buffer(queue_);
global_threads[0] = (unsigned) RoundUp(info_buffer_source->scene_dims[0]*info_buffer_source->scene_dims[1]*info_buffer_source->scene_dims[2],(int)local_threads[0]);
bocl_mem* blk_source = opencl_cache_->get_block(orbit.scene(), *iter_blk_source);
bocl_mem* blk_target = opencl_cache_->get_block(target_scene_,*iter_blk_target);
// for (int i = 0;i<6;i++){
// for(int j = 0; j<3;j++)
// std::cout<<app[i][j]<<" ";
// std::cout<<std::endl;
// }
orbit.update_target_gpu_buffers(target_scene_, *iter_blk_target);
orbit.update_source_gpu_buffers();
bocl_kernel* map_to_source_kern = kernels_[0];
map_to_source_kern->set_arg(orbit.centerX_.ptr());
map_to_source_kern->set_arg(orbit.centerY_.ptr());
map_to_source_kern->set_arg(orbit.centerZ_.ptr());
map_to_source_kern->set_arg(orbit.lookup_.ptr());
map_to_source_kern->set_arg(blk_info_target.ptr());
map_to_source_kern->set_arg(blk_info_source.ptr());
map_to_source_kern->set_arg(blk_target);
map_to_source_kern->set_arg(blk_source);
map_to_source_kern->set_arg(orbit.target_alpha_base_);
map_to_source_kern->set_arg(orbit.target_color_base_);
map_to_source_kern->set_arg(orbit.target_vis_base_);
map_to_source_kern->set_arg(orbit.source_color_base_);
map_to_source_kern->set_arg(rotation_l.ptr());
map_to_source_kern->set_arg(other_rotation_l.ptr());
map_to_source_kern->set_arg(offset_l.ptr());
map_to_source_kern->set_arg(other_offset_l.ptr());
map_to_source_kern->set_arg(orbit.sphere_base_);
map_to_source_kern->set_arg(orbit.iris_base_);
map_to_source_kern->set_arg(orbit.pupil_base_);
map_to_source_kern->set_arg(orbit.eyelid_base_);
map_to_source_kern->set_arg(orbit.eyelid_crease_base_);
map_to_source_kern->set_arg(orbit.lower_eyelid_base_);
map_to_source_kern->set_arg(output_cl.ptr());
map_to_source_kern->set_arg(orbit.eyelid_geo_cl_.ptr());
map_to_source_kern->set_arg(dt_l.ptr());
map_to_source_kern->set_arg(max_t_l.ptr());
map_to_source_kern->set_arg(total_app_l.ptr());
map_to_source_kern->set_arg(mean_app_l.ptr());
map_to_source_kern->set_arg(is_right_cl.ptr());
map_to_source_kern->set_local_arg(local_threads[0]*10*sizeof(cl_uchar) ); // cumsum buffer,
map_to_source_kern->set_local_arg(16*local_threads[0]*sizeof(unsigned char)); // local trees target
map_to_source_kern->set_local_arg(16*local_threads[0]*sizeof(unsigned char)); // local trees source
map_to_source_kern->set_local_arg(16*local_threads[0]*sizeof(unsigned char)); // reflected local trees source
map_to_source_kern->set_local_arg(16*local_threads[0]*sizeof(unsigned char)); // neighbor trees
if(!map_to_source_kern->execute(queue_, 1, local_threads, global_threads))
{
std::cout<<"Kernel Failed to Execute "<<std::endl;
return false;
}
// orbit.source_color_base_->read_to_buffer(queue_);
// output_cl->read_to_buffer(queue_);
int status = clFinish(queue_);
bool good_kern = check_val(status, CL_SUCCESS, "TRANSFORMATION KERNEL (INTERP) FAILED: " + error_to_string(status));
map_to_source_kern->clear_args();
if(!good_kern)
return false;
// for (unsigned i = 0;i<source_data_size;i++){
// if( output[i]!=0)
// std::cout<<output[i]<<" ";
// }
delete [] output;
return true;
}
bool boxm2_vecf_ocl_appearance_extractor::compute_mean_anatomical_appearance(bool is_right){
boxm2_vecf_composite_head_parameters const& head_params = head_model_.get_params();
boxm2_vecf_ocl_orbit_scene orbit,other_orbit; boxm2_vecf_orbit_params orbit_params, other_orbit_params;
if (!is_right){
orbit = head_model_.left_orbit_;
other_orbit = head_model_.right_orbit_;
orbit_params = head_params.l_orbit_params_;
other_orbit_params = head_params.r_orbit_params_;
}else{
orbit = head_model_.right_orbit_;
other_orbit = head_model_.left_orbit_;
orbit_params = head_params.r_orbit_params_;
other_orbit_params = head_params.l_orbit_params_;
}
float8 null ; null.fill(0);
color_APM& curr_sclera_app = is_right ? right_sclera_app_ : left_sclera_app_;
color_APM& curr_pupil_app = is_right ? right_pupil_app_ : left_pupil_app_;
color_APM& curr_iris_app = is_right ? right_iris_app_ : left_iris_app_;
color_APM& curr_upper_lid_app = is_right ? right_upper_lid_app_ : left_upper_lid_app_;
color_APM& curr_lower_lid_app = is_right ? right_lower_lid_app_ : left_lower_lid_app_;
color_APM& curr_eyelid_crease_app = is_right ? right_eyelid_crease_app_ : left_eyelid_crease_app_;
float8 app[6];
float vis[6];
for(unsigned i = 0;i<6;i++){
app[i] = null;
vis[i] = 0;
}
float offset_buff [4],other_offset_buff [4];
float rotation_buff[9],other_rotation_buff[9];
max_t_color = 100;
bool good_buffs = true;
unsigned char is_right_buf = is_right;
vnl_vector_fixed<double, 3> Z(0.0, 0.0, 1.0);
vnl_vector_fixed<double, 3> other_to_dir(other_orbit_params.eye_pointing_dir_.x(),
other_orbit_params.eye_pointing_dir_.y(),
other_orbit_params.eye_pointing_dir_.z());
vnl_vector_fixed<double, 3> to_dir(orbit_params.eye_pointing_dir_.x(),
orbit_params.eye_pointing_dir_.y(),
orbit_params.eye_pointing_dir_.z());
vgl_rotation_3d<double> rot(Z, to_dir);
vgl_rotation_3d<double> other_rot(Z, other_to_dir);
float curr_dt = - orbit_params.eyelid_dt_;
offset_buff[0] = orbit_params.offset_.x(); other_offset_buff[0] = other_orbit_params.offset_.x();
offset_buff[1] = orbit_params.offset_.y(); other_offset_buff[1] = other_orbit_params.offset_.y();
offset_buff[2] = orbit_params.offset_.z(); other_offset_buff[2] = other_orbit_params.offset_.z();
vnl_matrix_fixed<double, 3, 3> R = rot.as_matrix();
rotation_buff[0] =(float) R(0,0); rotation_buff[3] =(float) R(1,0); rotation_buff[6] =(float) R(2,0);
rotation_buff[1] =(float) R(0,1); rotation_buff[4] =(float) R(1,1); rotation_buff[7] =(float) R(2,1);
rotation_buff[2] =(float) R(0,2); rotation_buff[5] =(float) R(1,2); rotation_buff[8] =(float) R(2,2);
vnl_matrix_fixed<double, 3, 3> other_R = other_rot.as_matrix();
other_rotation_buff[0] =(float) other_R(0,0); other_rotation_buff[3] =(float) other_R(1,0); other_rotation_buff[6] =(float) other_R(2,0);
other_rotation_buff[1] =(float) other_R(0,1); other_rotation_buff[4] =(float) other_R(1,1); other_rotation_buff[7] =(float) other_R(2,1);
other_rotation_buff[2] =(float) other_R(0,2); other_rotation_buff[5] =(float) other_R(1,2); other_rotation_buff[8] =(float) other_R(2,2);
bocl_mem_sptr rotation_l = new bocl_mem(device_->context(), rotation_buff, sizeof(float)*9, " rotation " );
good_buffs &= rotation_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr other_rotation_l = new bocl_mem(device_->context(), other_rotation_buff, sizeof(float)*9, " other_rotation " );
good_buffs &= other_rotation_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr offset_l = new bocl_mem(device_->context(), offset_buff, sizeof(float)*4, " offset " );
good_buffs &= offset_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr other_offset_l = new bocl_mem(device_->context(), other_offset_buff, sizeof(float)*4, "other offset " );
good_buffs &= other_offset_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr vis_l = new bocl_mem(device_->context(), vis, sizeof(float)*6, " vis buff " );
good_buffs &= vis_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr mean_app_l = new bocl_mem(device_->context(), app, sizeof(float8)*6, " mean app buff " );
good_buffs &= mean_app_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr is_right_cl = new bocl_mem(device_->context(), &is_right_buf, sizeof(char), " mean app buff " );
good_buffs &= is_right_cl->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr dt_l = new bocl_mem(device_->context(), &curr_dt , sizeof(float), " dt buff " );
good_buffs &= dt_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
bocl_mem_sptr max_t_l = new bocl_mem(device_->context(), &max_t_color , sizeof(float), " max t color buff " );
good_buffs &= max_t_l->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
std::size_t local_threads[1]={64};
std::size_t global_threads[1]={1};
std::vector<boxm2_block_id> blocks_target = target_scene_->get_block_ids();
std::vector<boxm2_block_id> blocks_source = orbit.scene()->get_block_ids();
auto iter_blk_target = blocks_target.begin();
auto iter_blk_source = blocks_source.begin();
if(blocks_target.size()!=1||blocks_source.size()!=1)
return false;
boxm2_scene_info* info_buffer_source = orbit.scene()->get_blk_metadata(*iter_blk_source);
boxm2_scene_info* info_buffer_target = target_scene_->get_blk_metadata(*iter_blk_target);
auto target_data_size = (std::size_t) orbit.target_blk_->num_cells();
info_buffer_target->data_buffer_length = target_data_size;
bocl_mem_sptr blk_info_target = new bocl_mem(device_->context(), info_buffer_target, sizeof(boxm2_scene_info), " Scene Info Target" );
good_buffs &= blk_info_target->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR);
blk_info_target->write_to_buffer(queue_);
bocl_mem_sptr blk_info_source = new bocl_mem(device_->context(), info_buffer_source, sizeof(boxm2_scene_info), " Scene Info Source" );
std::size_t source_data_size = (int) orbit.blk_->num_cells();
info_buffer_source->data_buffer_length = source_data_size;
blk_info_source->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR);
blk_info_source->write_to_buffer(queue_);
auto* output = new float[source_data_size];
bocl_mem_sptr output_cl = new bocl_mem(device_->context(), output, source_data_size * sizeof(float), "Output buf" );
good_buffs &= output_cl->create_buffer(CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR );
if(!good_buffs)
return false;
// output_cl->zero_gpu_buffer(queue_);
global_threads[0] = (unsigned) RoundUp(info_buffer_source->scene_dims[0]*info_buffer_source->scene_dims[1]*info_buffer_source->scene_dims[2],(int)local_threads[0]);
bocl_mem* blk_source = opencl_cache_->get_block(orbit.scene(), *iter_blk_source);
bocl_mem* blk_target = opencl_cache_->get_block(target_scene_,*iter_blk_target);
orbit.update_target_gpu_buffers(target_scene_, *iter_blk_target);
orbit.update_source_gpu_buffers();
bocl_kernel* calc_mean_orbit_app_kern = kernels_[1];
calc_mean_orbit_app_kern->set_arg(orbit.centerX_.ptr());
calc_mean_orbit_app_kern->set_arg(orbit.centerY_.ptr());
calc_mean_orbit_app_kern->set_arg(orbit.centerZ_.ptr());
calc_mean_orbit_app_kern->set_arg(orbit.lookup_.ptr());
calc_mean_orbit_app_kern->set_arg(blk_info_target.ptr());
calc_mean_orbit_app_kern->set_arg(blk_info_source.ptr());
calc_mean_orbit_app_kern->set_arg(blk_target);
calc_mean_orbit_app_kern->set_arg(blk_source);
calc_mean_orbit_app_kern->set_arg(orbit.target_alpha_base_);
calc_mean_orbit_app_kern->set_arg(orbit.target_color_base_);
calc_mean_orbit_app_kern->set_arg(orbit.target_vis_base_);
calc_mean_orbit_app_kern->set_arg(orbit.source_color_base_);
calc_mean_orbit_app_kern->set_arg(rotation_l.ptr());
calc_mean_orbit_app_kern->set_arg(other_rotation_l.ptr());
calc_mean_orbit_app_kern->set_arg(offset_l.ptr());
calc_mean_orbit_app_kern->set_arg(other_offset_l.ptr());
calc_mean_orbit_app_kern->set_arg(orbit.sphere_base_);
calc_mean_orbit_app_kern->set_arg(orbit.iris_base_);
calc_mean_orbit_app_kern->set_arg(orbit.pupil_base_);
calc_mean_orbit_app_kern->set_arg(orbit.eyelid_base_);
calc_mean_orbit_app_kern->set_arg(orbit.eyelid_crease_base_);
calc_mean_orbit_app_kern->set_arg(orbit.lower_eyelid_base_);
calc_mean_orbit_app_kern->set_arg(output_cl.ptr());
calc_mean_orbit_app_kern->set_arg(orbit.eyelid_geo_cl_.ptr());
calc_mean_orbit_app_kern->set_arg(dt_l.ptr());
calc_mean_orbit_app_kern->set_arg(max_t_l.ptr());
calc_mean_orbit_app_kern->set_arg(vis_l.ptr());
calc_mean_orbit_app_kern->set_arg(mean_app_l.ptr());
calc_mean_orbit_app_kern->set_arg(is_right_cl.ptr());
calc_mean_orbit_app_kern->set_local_arg(local_threads[0]*10*sizeof(cl_uchar) ); // cumsum buffer,
calc_mean_orbit_app_kern->set_local_arg(16*local_threads[0]*sizeof(unsigned char)); // local trees target
calc_mean_orbit_app_kern->set_local_arg(16*local_threads[0]*sizeof(unsigned char)); // local trees source
calc_mean_orbit_app_kern->set_local_arg(16*local_threads[0]*sizeof(unsigned char)); // reflected local trees source
calc_mean_orbit_app_kern->set_local_arg(16*local_threads[0]*sizeof(unsigned char)); // neighbor trees
if(!calc_mean_orbit_app_kern->execute(queue_, 1, local_threads, global_threads))
{
std::cout<<"Calc Mean Orbit Kernel Failed to Execute "<<std::endl;
return false;
}
vis_l->read_to_buffer(queue_);
mean_app_l->read_to_buffer(queue_);
max_t_l->read_to_buffer(queue_);
std::cout<<" max t color was determined to be " <<max_t_color<< " and t min and t max are "<< orbit_params.eyelid_tmin_ <<" "<<orbit_params.eyelid_tmax_ << std::endl;
std::cout<<" dt is "<< -curr_dt<<std::endl;
// output_cl->read_to_buffer(queue_);
int status = clFinish(queue_);
bool good_kern = check_val(status, CL_SUCCESS, "Calc Mean Orbit Kernel Failed: " + error_to_string(status));
calc_mean_orbit_app_kern->clear_args();
if(!good_kern)
return false;
// for (unsigned i = 0;i < source_data_size ; i++){
// if( output[i]!=0)
// std::cout<<output[i]<<" ";
// }
float8 sclera = vis[0] != 0.0f ? app[0]/vis[0] : null; vis_sclera_ += vis[0];
float8 iris = vis[1] != 0.0f ? app[1]/vis[1] : null; vis_iris_ += vis[1];
float8 pupil = vis[2] != 0.0f ? app[2]/vis[2] : null; vis_pupil_ += vis[2];
float8 u_lid = vis[3] != 0.0f ? app[3]/vis[3] : null; vis_upper_lid_ += vis[3];
float8 l_lid = vis[4] != 0.0f ? app[4]/vis[4] : null; vis_lower_lid_ += vis[4];
float8 l_crease = vis[5] != 0.0f ? app[5]/vis[5] : null; vis_eyelid_crease_ += vis[5];
total_sclera_app_ += app[0]; curr_sclera_app = to_apm_t(sclera);
total_iris_app_ += app[1]; curr_iris_app = to_apm_t(iris);
total_pupil_app_ += app[2]; curr_pupil_app = to_apm_t(pupil);
total_upper_lid_app_ += app[3]; curr_upper_lid_app = to_apm_t(u_lid);
total_lower_lid_app_ += app[4]; curr_lower_lid_app = to_apm_t(l_lid);
total_eyelid_crease_app_+= app[5]; curr_eyelid_crease_app = to_apm_t(l_crease);
// for(unsigned i = 0; i<6;i++)
// std::cout<<vis[i]<<" ";
// std::cout<<std::endl;
delete [] output;
return true;
}
#endif
float8 boxm2_vecf_ocl_appearance_extractor::weight_intesities(float& vis_A,float& vis_B,float8 int_A,float8 int_B,float8 mean_A,float8 mean_B){
bool the_dan_way = true;
float dominant_vis = vis_A > vis_B ? vis_A : vis_B;
float8& dominant_mean = vis_A > vis_B ? mean_A : mean_B;
float8 ret_val;
if (the_dan_way){
float s = 10.0f;
float m = 1.1;
float v = 0.6f;
float inv_weight1 = 1.0/(1.0 + std::exp( -s * (vis_B - m * vis_A)));
float inv_weight2 = 1.0/(1.0 + std::exp( -s * (v - vis_A)));
float weight = 1.0f - inv_weight1 * inv_weight2;
float8 observed_intensity = int_A * weight + int_B * (1.0f - weight);
s = 16 ; v = 0.3;
weight = 1.0/(1.0 + std::exp( -s * ( dominant_vis -v )));
ret_val = observed_intensity * weight + mean_A * (1.0f - weight);
}else{
ret_val = vis_A * int_A + (1 - vis_A) * mean_A;
}
return ret_val;
}
|
88659a88b33d3735a73151e15f7ae03d66be23b8 | b357bc84dbf0c20aa0d4bb8d8d873a1392a0f1ac | /LearnDx11/LearnDx11/DxModelClass.cpp | 28d8e49986110e7c5417900086d52a764fa87425 | [] | no_license | StarOceanCN/DX11 | 4b4936ab928ebed12ed442d084cfe0c14d344226 | 8c559cba8e044ea5959ce2d5170bcac45c517782 | refs/heads/master | 2020-04-16T09:48:38.666586 | 2019-02-15T04:35:02 | 2019-02-15T04:35:02 | 165,477,793 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 5,947 | cpp | DxModelClass.cpp | #include "DxModelClass.h"
DxModelClass::DxModelClass() {
m_vertexBuffer = 0;
m_indexBuffer = 0;
m_texture = 0;
m_model = 0;
}
DxModelClass::DxModelClass(const DxModelClass& other) {
}
DxModelClass::~DxModelClass() {}
bool DxModelClass::Init(ID3D11Device* device, const char* modelFileName, const WCHAR* textureFileName) {
bool isSuccess;
//载入模型
isSuccess = LoadModel(modelFileName);
if (!isSuccess)
{
return false;
}
//读取纹理
isSuccess = LoadTexture(device, textureFileName);
if (!isSuccess) {
return false;
}
//缓冲区初始化
isSuccess = BufferInit(device);
if (!isSuccess)
return false;
return true;
}
void DxModelClass::ShutDown() {
ReleaseTexture();
BufferShutDown();
ReleaseModel();
}
void DxModelClass::Render(ID3D11DeviceContext* deviceContext) {
//put the vertex and index buffers on the graphics pipeline to prepare them for drawing
BufferRender(deviceContext);
}
int DxModelClass::GetIndexCount() {
return m_indexCount;
}
ID3D11ShaderResourceView* DxModelClass::GetTexture() {
return m_texture->GetTexture();
}
bool DxModelClass::BufferInit(ID3D11Device* device) {
VertexType* vertices;
unsigned long* indices;
D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
D3D11_SUBRESOURCE_DATA vertexData, indexData;
HRESULT result;
//set the number of vertices in the vertex array
//m_vertexCount = 3;
//set the number of indices in the index array
//m_indexCount = 3;
vertices = new VertexType[m_vertexCount];
if (!vertices)
return false;
indices = new unsigned long[m_indexCount];
if (!indices)
return false;
// Load the vertex array and index array with data.
for (int i = 0; i < m_vertexCount; i++)
{
vertices[i].position = D3DXVECTOR3(m_model[i].x, m_model[i].y, m_model[i].z);
vertices[i].texture = D3DXVECTOR2(m_model[i].tu, m_model[i].tv);
vertices[i].normal = D3DXVECTOR3(m_model[i].nx, m_model[i].ny, m_model[i].nz);
indices[i] = i;
}
/*
vertices[0].position = D3DXVECTOR3(-1.0f, -1.0f, 0.0f);//bottom left
vertices[0].texture = D3DXVECTOR2(0.0f, 1.0f);
vertices[0].normal = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
vertices[1].position = D3DXVECTOR3(0.0f, 1.0f, 0.0f);//top middle
vertices[1].texture = D3DXVECTOR2(0.5f, 0.0f);
vertices[1].normal = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
vertices[2].position = D3DXVECTOR3(1.0f, -1.0f, 0.0f);//bottom right
vertices[2].texture = D3DXVECTOR2(1.0f, 1.0f);
vertices[2].normal = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
*/
//set up the description of the static vertex buffer
vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
vertexBufferDesc.ByteWidth = sizeof(VertexType)*m_vertexCount;
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.MiscFlags = 0;
vertexBufferDesc.StructureByteStride = 0;
//give the subresource structure a pointer to the vertex data
vertexData.pSysMem = vertices;
vertexData.SysMemPitch = 0;
vertexData.SysMemSlicePitch = 0;
//now create the vertex buffer.
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
if (FAILED(result))
return false;
//set up the description of the static index buffer
indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(unsigned long)*m_indexCount;
indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;
indexBufferDesc.StructureByteStride = 0;
//give the subresource structure a pointer to the index data
indexData.pSysMem = indices;
indexData.SysMemPitch = 0;
indexData.SysMemSlicePitch = 0;
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
if (FAILED(result))
return false;
delete[] vertices;
vertices = 0;
delete[] indices;
indices = 0;
return true;
}
bool DxModelClass::LoadTexture(ID3D11Device* device, const WCHAR* fileName) {
bool isSuccess;
m_texture = new DxTextureClass();
if (!m_texture) {
return false;
}
isSuccess = m_texture->Init(device, fileName);
if (!isSuccess) {
return false;
}
return true;
}
void DxModelClass::ReleaseTexture() {
if (m_texture) {
m_texture->ShutDown();
m_texture = 0;
}
}
void DxModelClass::BufferShutDown() {
if (m_indexBuffer) {
m_indexBuffer->Release();
m_indexBuffer = 0;
}
if (m_vertexBuffer) {
m_vertexBuffer->Release();
m_vertexBuffer = 0;
}
}
void DxModelClass::BufferRender(ID3D11DeviceContext* deviceContext) {
unsigned int stride;//步长
unsigned int offset;//偏移
stride = sizeof(VertexType);
offset = 0;
//set the vertex buffer to active in the input assembler so it can be rendered
deviceContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);
//set the index buffer to active in the input assembler so it can be rendered
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
//set the type of primitive that should be rendered from this vertex buffer ,inthis case triangle
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
}
//自定义顶点格式,包括顶点数和绘制顶点顺序
bool DxModelClass::LoadModel(const char* modelFileName)
{
ifstream fin;
char input;
int i;
fin.open(modelFileName);
if (fin.fail())
{
return false;
}
fin.get(input);
while (input != ':')
{
fin.get(input);
}
fin >> m_vertexCount;
m_indexCount = m_vertexCount;
m_model = new ModelType[m_vertexCount];
if (!m_model)
{
return false;
}
fin.get(input);
while (input != ':')
{
fin.get(input);
}
fin.get(input);
fin.get(input);
for (i = 0; i < m_vertexCount; i++)
{
fin >> m_model[i].x >> m_model[i].y >> m_model[i].z;
fin >> m_model[i].tu >> m_model[i].tv;
fin >> m_model[i].nx >> m_model[i].ny >> m_model[i].nz;
}
fin.close();
return true;
}
void DxModelClass::ReleaseModel()
{
if (m_model)
{
delete[] m_model;
m_model = 0;
}
return;
}
|
91cbb227649529deaaf49b5579c46ab1d9b7cb5b | 6b3edbd003efeeb908adb1b3014a09397bc023b7 | /msp430fr5739/clock.cpp | c653f2b76930ab840ae95a3ce10f5af813d16184 | [
"MIT"
] | permissive | icaven/Interrupted | 7fb57852a31efcbf0f493f922c8edb29879723df | 6302768b7c8e65fcc411882b7d8c81dcaef4119f | refs/heads/master | 2021-01-12T00:08:32.009554 | 2017-03-17T19:33:32 | 2017-03-17T19:33:32 | 78,678,345 | 0 | 0 | null | 2017-01-11T20:46:59 | 2017-01-11T20:46:58 | null | UTF-8 | C++ | false | false | 985 | cpp | clock.cpp | #include <Energia.h>
#include "device.h"
#include "clock.h"
static Clock *c;
// see https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/118916
bool Clock::begin() {
c = this;
PJSEL0 |= BIT4 | BIT5; // XT1
CSCTL0_H = 0xa5; // unlock register
CSCTL4 &= ~XT1OFF;
do {
CSCTL5 &= ~XT1OFFG; // clear XT1 fault flag
SFRIFG1 &= ~OFIFG;
} while (SFRIFG1 & OFIFG);
CSCTL0_H = 0x01; // lock register
return true;
}
void Clock::_enable(bool e) {
RTCCTL01 |= RTCHOLD;
if (e)
RTCCTL01 |= RTCRDYIE;
else
RTCCTL01 &= ~RTCRDYIE;
RTCCTL01 &= ~RTCHOLD;
}
unsigned Clock::_sleepmode() {
return LPM4_bits;
}
void Clock::set(uint8_t h, uint8_t m, uint8_t s) {
RTCSEC = s;
RTCMIN = m;
RTCHOUR = h;
}
#pragma vector=RTC_VECTOR
__interrupt void rtc_isr(void)
{
switch (RTCIV) {
case RTCIV_NONE:
break;
case RTCIV_RTCRDYIFG:
while (!(RTCRDY));
if (c)
c->update(RTCHOUR, RTCMIN, RTCSEC);
break;
}
__bic_SR_register_on_exit(LPM4_bits | GIE);
}
|
6a62437ba3a912988deda36856b871cb921b305f | d0fb46aecc3b69983e7f6244331a81dff42d9595 | /airec/include/alibabacloud/airec/model/ListInstanceTaskResult.h | c4c49086e24577eb5b18b969f3c8e041f0ad7d8e | [
"Apache-2.0"
] | permissive | aliyun/aliyun-openapi-cpp-sdk | 3d8d051d44ad00753a429817dd03957614c0c66a | e862bd03c844bcb7ccaa90571bceaa2802c7f135 | refs/heads/master | 2023-08-29T11:54:00.525102 | 2023-08-29T03:32:48 | 2023-08-29T03:32:48 | 115,379,460 | 104 | 82 | NOASSERTION | 2023-09-14T06:13:33 | 2017-12-26T02:53:27 | C++ | UTF-8 | C++ | false | false | 1,908 | h | ListInstanceTaskResult.h | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_AIREC_MODEL_LISTINSTANCETASKRESULT_H_
#define ALIBABACLOUD_AIREC_MODEL_LISTINSTANCETASKRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/airec/AirecExport.h>
namespace AlibabaCloud
{
namespace Airec
{
namespace Model
{
class ALIBABACLOUD_AIREC_EXPORT ListInstanceTaskResult : public ServiceResult
{
public:
struct ResultItem
{
struct SubProgressInfosItem
{
int progress;
std::string type;
int totalNum;
int finishedNum;
std::string detail;
};
std::vector<ResultItem::SubProgressInfosItem> subProgressInfos;
int totalProgress;
std::string name;
};
ListInstanceTaskResult();
explicit ListInstanceTaskResult(const std::string &payload);
~ListInstanceTaskResult();
std::vector<ResultItem> getresult()const;
std::string getMessage()const;
std::string getRequestId()const;
std::string getCode()const;
protected:
void parse(const std::string &payload);
private:
std::vector<ResultItem> result_;
std::string message_;
std::string requestId_;
std::string code_;
};
}
}
}
#endif // !ALIBABACLOUD_AIREC_MODEL_LISTINSTANCETASKRESULT_H_ |
c55c49e69f249e176fa9dc50536b53d1739ed951 | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp | 4b2c16dfd4655b694633b5d875491db8b803c517 | [
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"MIT",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 51,625 | cpp | Canvas2DLayerBridgeTest.cpp | /*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
*/
#include "platform/graphics/Canvas2DLayerBridge.h"
#include "cc/resources/single_release_callback.h"
#include "cc/resources/texture_mailbox.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/capabilities.h"
#include "platform/CrossThreadFunctional.h"
#include "platform/WaitableEvent.h"
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/UnacceleratedImageBufferSurface.h"
#include "platform/graphics/test/FakeGLES2Interface.h"
#include "platform/graphics/test/FakeWebGraphicsContext3DProvider.h"
#include "public/platform/Platform.h"
#include "public/platform/WebExternalBitmap.h"
#include "public/platform/WebScheduler.h"
#include "public/platform/WebTaskRunner.h"
#include "public/platform/WebThread.h"
#include "public/platform/WebTraceLocation.h"
#include "skia/ext/texture_handle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "wtf/PtrUtil.h"
#include "wtf/RefPtr.h"
#include <memory>
using testing::AnyNumber;
using testing::AtLeast;
using testing::InSequence;
using testing::Return;
using testing::Test;
using testing::_;
namespace blink {
namespace {
class Canvas2DLayerBridgePtr {
public:
Canvas2DLayerBridgePtr() {}
Canvas2DLayerBridgePtr(PassRefPtr<Canvas2DLayerBridge> layerBridge)
: m_layerBridge(layerBridge) {}
~Canvas2DLayerBridgePtr() { clear(); }
void clear() {
if (m_layerBridge) {
m_layerBridge->beginDestruction();
m_layerBridge.clear();
}
}
void operator=(PassRefPtr<Canvas2DLayerBridge> layerBridge) {
ASSERT(!m_layerBridge);
m_layerBridge = layerBridge;
}
Canvas2DLayerBridge* operator->() { return m_layerBridge.get(); }
Canvas2DLayerBridge* get() { return m_layerBridge.get(); }
private:
RefPtr<Canvas2DLayerBridge> m_layerBridge;
};
} // anonymous namespace
class Canvas2DLayerBridgeTest : public Test {
public:
PassRefPtr<Canvas2DLayerBridge> makeBridge(
std::unique_ptr<FakeWebGraphicsContext3DProvider> provider,
const IntSize& size,
Canvas2DLayerBridge::AccelerationMode accelerationMode) {
RefPtr<Canvas2DLayerBridge> bridge = adoptRef(new Canvas2DLayerBridge(
std::move(provider), size, 0, NonOpaque, accelerationMode, nullptr));
bridge->dontUseIdleSchedulingForTesting();
return bridge.release();
}
protected:
void fullLifecycleTest() {
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
Canvas2DLayerBridge::DisableAcceleration, nullptr)));
const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo(
bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests)
->getTextureHandle(true));
EXPECT_EQ(textureInfo, nullptr);
bridge.clear();
}
void fallbackToSoftwareIfContextLost() {
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
gl.setIsContextLost(true);
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
Canvas2DLayerBridge::EnableAcceleration, nullptr)));
EXPECT_TRUE(bridge->checkSurfaceValid());
EXPECT_FALSE(bridge->isAccelerated());
}
void fallbackToSoftwareOnFailedTextureAlloc() {
{
// No fallback case.
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
Canvas2DLayerBridge::EnableAcceleration, nullptr)));
EXPECT_TRUE(bridge->checkSurfaceValid());
EXPECT_TRUE(bridge->isAccelerated());
sk_sp<SkImage> snapshot =
bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests);
EXPECT_TRUE(bridge->isAccelerated());
EXPECT_TRUE(snapshot->isTextureBacked());
}
{
// Fallback case.
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
GrContext* gr = contextProvider->grContext();
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
Canvas2DLayerBridge::EnableAcceleration, nullptr)));
EXPECT_TRUE(bridge->checkSurfaceValid());
EXPECT_TRUE(bridge->isAccelerated()); // We don't yet know that
// allocation will fail.
// This will cause SkSurface_Gpu creation to fail without
// Canvas2DLayerBridge otherwise detecting that anything was disabled.
gr->abandonContext();
sk_sp<SkImage> snapshot =
bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_FALSE(snapshot->isTextureBacked());
}
}
void noDrawOnContextLostTest() {
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr)));
EXPECT_TRUE(bridge->checkSurfaceValid());
SkPaint paint;
uint32_t genID = bridge->getOrCreateSurface()->generationID();
bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint);
EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID());
gl.setIsContextLost(true);
EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID());
bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint);
EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID());
// This results in the internal surface being torn down in response to the
// context loss.
EXPECT_FALSE(bridge->checkSurfaceValid());
EXPECT_EQ(nullptr, bridge->getOrCreateSurface());
// The following passes by not crashing
bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint);
bridge->flush();
}
void prepareMailboxWhenContextIsLost() {
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr)));
// TODO(junov): The PrepareTextureMailbox() method will fail a DCHECK if we
// don't do this before calling it the first time when the context is lost.
bridge->prepareSurfaceForPaintingIfNeeded();
// When the context is lost we are not sure if we should still be producing
// GL frames for the compositor or not, so fail to generate frames.
gl.setIsContextLost(true);
cc::TextureMailbox textureMailbox;
std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
EXPECT_FALSE(
bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
}
void prepareMailboxAndLoseResourceTest() {
// Prepare a mailbox, then report the resource as lost.
// This test passes by not crashing and not triggering assertions.
{
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr)));
cc::TextureMailbox textureMailbox;
std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
EXPECT_TRUE(
bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
bool lostResource = true;
releaseCallback->Run(gpu::SyncToken(), lostResource);
}
// Retry with mailbox released while bridge destruction is in progress.
{
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
cc::TextureMailbox textureMailbox;
std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
{
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr)));
bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback);
// |bridge| goes out of scope and would normally be destroyed, but
// object is kept alive by self references.
}
// This should cause the bridge to be destroyed.
bool lostResource = true;
// Before fixing crbug.com/411864, the following line would cause a memory
// use after free that sometimes caused a crash in normal builds and
// crashed consistently with ASAN.
releaseCallback->Run(gpu::SyncToken(), lostResource);
}
}
void accelerationHintTest() {
{
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 300), 0, NonOpaque,
Canvas2DLayerBridge::EnableAcceleration, nullptr)));
SkPaint paint;
bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint);
sk_sp<SkImage> image =
bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests);
EXPECT_TRUE(bridge->checkSurfaceValid());
EXPECT_TRUE(bridge->isAccelerated());
}
{
FakeGLES2Interface gl;
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
std::move(contextProvider), IntSize(300, 300), 0, NonOpaque,
Canvas2DLayerBridge::EnableAcceleration, nullptr)));
SkPaint paint;
bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint);
sk_sp<SkImage> image = bridge->newImageSnapshot(PreferNoAcceleration,
SnapshotReasonUnitTests);
EXPECT_TRUE(bridge->checkSurfaceValid());
EXPECT_FALSE(bridge->isAccelerated());
}
}
};
TEST_F(Canvas2DLayerBridgeTest, FullLifecycleSingleThreaded) {
fullLifecycleTest();
}
TEST_F(Canvas2DLayerBridgeTest, NoDrawOnContextLost) {
noDrawOnContextLostTest();
}
TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhenContextIsLost) {
prepareMailboxWhenContextIsLost();
}
TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxAndLoseResource) {
prepareMailboxAndLoseResourceTest();
}
TEST_F(Canvas2DLayerBridgeTest, AccelerationHint) {
accelerationHintTest();
}
TEST_F(Canvas2DLayerBridgeTest, FallbackToSoftwareIfContextLost) {
fallbackToSoftwareIfContextLost();
}
TEST_F(Canvas2DLayerBridgeTest, FallbackToSoftwareOnFailedTextureAlloc) {
fallbackToSoftwareOnFailedTextureAlloc();
}
class MockLogger : public Canvas2DLayerBridge::Logger {
public:
MOCK_METHOD1(reportHibernationEvent,
void(Canvas2DLayerBridge::HibernationEvent));
MOCK_METHOD0(didStartHibernating, void());
virtual ~MockLogger() {}
};
void runCreateBridgeTask(Canvas2DLayerBridgePtr* bridgePtr,
gpu::gles2::GLES2Interface* gl,
Canvas2DLayerBridgeTest* testHost,
WaitableEvent* doneEvent) {
std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(gl));
*bridgePtr =
testHost->makeBridge(std::move(contextProvider), IntSize(300, 300),
Canvas2DLayerBridge::EnableAcceleration);
// draw+flush to trigger the creation of a GPU surface
(*bridgePtr)->didDraw(FloatRect(0, 0, 1, 1));
(*bridgePtr)->finalizeFrame(FloatRect(0, 0, 1, 1));
(*bridgePtr)->flush();
doneEvent->signal();
}
void postAndWaitCreateBridgeTask(const WebTraceLocation& location,
WebThread* testThread,
Canvas2DLayerBridgePtr* bridgePtr,
gpu::gles2::GLES2Interface* gl,
Canvas2DLayerBridgeTest* testHost) {
std::unique_ptr<WaitableEvent> bridgeCreatedEvent =
wrapUnique(new WaitableEvent());
testThread->getWebTaskRunner()->postTask(
location, crossThreadBind(
&runCreateBridgeTask, crossThreadUnretained(bridgePtr),
crossThreadUnretained(gl), crossThreadUnretained(testHost),
crossThreadUnretained(bridgeCreatedEvent.get())));
bridgeCreatedEvent->wait();
}
void runDestroyBridgeTask(Canvas2DLayerBridgePtr* bridgePtr,
WaitableEvent* doneEvent) {
bridgePtr->clear();
if (doneEvent)
doneEvent->signal();
}
void postDestroyBridgeTask(const WebTraceLocation& location,
WebThread* testThread,
Canvas2DLayerBridgePtr* bridgePtr) {
testThread->getWebTaskRunner()->postTask(
location, crossThreadBind(&runDestroyBridgeTask,
crossThreadUnretained(bridgePtr), nullptr));
}
void postAndWaitDestroyBridgeTask(const WebTraceLocation& location,
WebThread* testThread,
Canvas2DLayerBridgePtr* bridgePtr) {
std::unique_ptr<WaitableEvent> bridgeDestroyedEvent =
wrapUnique(new WaitableEvent());
testThread->getWebTaskRunner()->postTask(
location,
crossThreadBind(&runDestroyBridgeTask, crossThreadUnretained(bridgePtr),
crossThreadUnretained(bridgeDestroyedEvent.get())));
bridgeDestroyedEvent->wait();
}
void runSetIsHiddenTask(Canvas2DLayerBridge* bridge,
bool value,
WaitableEvent* doneEvent) {
bridge->setIsHidden(value);
if (doneEvent)
doneEvent->signal();
}
void postSetIsHiddenTask(const WebTraceLocation& location,
WebThread* testThread,
Canvas2DLayerBridge* bridge,
bool value,
WaitableEvent* doneEvent = nullptr) {
testThread->getWebTaskRunner()->postTask(
location,
crossThreadBind(&runSetIsHiddenTask, crossThreadUnretained(bridge), value,
crossThreadUnretained(doneEvent)));
}
void postAndWaitSetIsHiddenTask(const WebTraceLocation& location,
WebThread* testThread,
Canvas2DLayerBridge* bridge,
bool value) {
std::unique_ptr<WaitableEvent> doneEvent = wrapUnique(new WaitableEvent());
postSetIsHiddenTask(location, testThread, bridge, value, doneEvent.get());
doneEvent->wait();
}
class MockImageBuffer : public ImageBuffer {
public:
MockImageBuffer()
: ImageBuffer(
wrapUnique(new UnacceleratedImageBufferSurface(IntSize(1, 1)))) {}
MOCK_CONST_METHOD1(resetCanvas, void(SkCanvas*));
virtual ~MockImageBuffer() {}
};
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, HibernationLifeCycle)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationLifeCycle)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Test exiting hibernation
EXPECT_CALL(
*mockLoggerPtr,
reportHibernationEvent(Canvas2DLayerBridge::HibernationEndedNormally));
postAndWaitSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(),
false);
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_TRUE(bridge->isAccelerated());
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, HibernationReEntry)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationReEntry)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
// Toggle visibility before the task that enters hibernation gets a
// chance to run.
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Test exiting hibernation
EXPECT_CALL(
*mockLoggerPtr,
reportHibernationEvent(Canvas2DLayerBridge::HibernationEndedNormally));
postAndWaitSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(),
false);
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_TRUE(bridge->isAccelerated());
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest,
HibernationLifeCycleWithDeferredRenderingDisabled)
#else
TEST_F(Canvas2DLayerBridgeTest,
DISABLED_HibernationLifeCycleWithDeferredRenderingDisabled)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
bridge->disableDeferral(DisableDeferralReasonUnknown);
MockImageBuffer mockImageBuffer;
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber());
bridge->setImageBuffer(&mockImageBuffer);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Test exiting hibernation
EXPECT_CALL(
*mockLoggerPtr,
reportHibernationEvent(Canvas2DLayerBridge::HibernationEndedNormally));
EXPECT_CALL(mockImageBuffer, resetCanvas(_))
.Times(AtLeast(1)); // Because deferred rendering is disabled
postAndWaitSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(),
false);
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
EXPECT_TRUE(bridge->isAccelerated());
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
void runRenderingTask(Canvas2DLayerBridge* bridge, WaitableEvent* doneEvent) {
bridge->didDraw(FloatRect(0, 0, 1, 1));
bridge->finalizeFrame(FloatRect(0, 0, 1, 1));
bridge->flush();
doneEvent->signal();
}
void postAndWaitRenderingTask(const WebTraceLocation& location,
WebThread* testThread,
Canvas2DLayerBridge* bridge) {
std::unique_ptr<WaitableEvent> doneEvent = wrapUnique(new WaitableEvent());
testThread->getWebTaskRunner()->postTask(
location,
crossThreadBind(&runRenderingTask, crossThreadUnretained(bridge),
crossThreadUnretained(doneEvent.get())));
doneEvent->wait();
}
#if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU
TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernating)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Rendering in the background -> temp switch to SW
EXPECT_CALL(*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::
HibernationEndedWithSwitchToBackgroundRendering));
postAndWaitRenderingTask(BLINK_FROM_HERE, testThread.get(), bridge.get());
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Unhide
postAndWaitSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(),
false);
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_TRUE(
bridge->isAccelerated()); // Becoming visible causes switch back to GPU
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU
TEST_F(Canvas2DLayerBridgeTest,
BackgroundRenderingWhileHibernatingWithDeferredRenderingDisabled)
#else
TEST_F(
Canvas2DLayerBridgeTest,
DISABLED_BackgroundRenderingWhileHibernatingWithDeferredRenderingDisabled)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
MockImageBuffer mockImageBuffer;
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber());
bridge->setImageBuffer(&mockImageBuffer);
bridge->disableDeferral(DisableDeferralReasonUnknown);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Rendering in the background -> temp switch to SW
EXPECT_CALL(*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::
HibernationEndedWithSwitchToBackgroundRendering));
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AtLeast(1));
postAndWaitRenderingTask(BLINK_FROM_HERE, testThread.get(), bridge.get());
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Unhide
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AtLeast(1));
postAndWaitSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(),
false);
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
EXPECT_TRUE(
bridge->isAccelerated()); // Becoming visible causes switch back to GPU
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber());
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU
TEST_F(Canvas2DLayerBridgeTest, DisableDeferredRenderingWhileHibernating)
#else
TEST_F(Canvas2DLayerBridgeTest,
DISABLED_DisableDeferredRenderingWhileHibernating)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
MockImageBuffer mockImageBuffer;
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber());
bridge->setImageBuffer(&mockImageBuffer);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Disable deferral while background rendering
EXPECT_CALL(*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::
HibernationEndedWithSwitchToBackgroundRendering));
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AtLeast(1));
bridge->disableDeferral(DisableDeferralReasonUnknown);
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Unhide
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AtLeast(1));
postAndWaitSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(),
false);
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
::testing::Mock::VerifyAndClearExpectations(&mockImageBuffer);
EXPECT_TRUE(
bridge->isAccelerated()); // Becoming visible causes switch back to GPU
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber());
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, TeardownWhileHibernating)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_TeardownWhileHibernating)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge while hibernating
EXPECT_CALL(*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::HibernationEndedWithTeardown));
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, SnapshotWhileHibernating)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_SnapshotWhileHibernating)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Take a snapshot and verify that it is not accelerated due to hibernation
sk_sp<SkImage> image =
bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests);
EXPECT_FALSE(image->isTextureBacked());
image.reset();
// Verify that taking a snapshot did not affect the state of bridge
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_TRUE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// End hibernation normally
std::unique_ptr<WaitableEvent> hibernationEndedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(
*mockLoggerPtr,
reportHibernationEvent(Canvas2DLayerBridge::HibernationEndedNormally))
.WillOnce(testing::InvokeWithoutArgs(hibernationEndedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
hibernationEndedEvent->wait();
// Tear down the bridge while hibernating
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, TeardownWhileHibernationIsPending)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_TeardownWhileHibernationIsPending)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationScheduledEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true,
hibernationScheduledEvent.get());
postDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
// In production, we would expect a
// HibernationAbortedDueToDestructionWhileHibernatePending event to be
// fired, but that signal is lost in the unit test due to no longer having
// a bridge to hold the mockLogger.
hibernationScheduledEvent->wait();
// Once we know the hibernation task is scheduled, we can schedule a fence.
// Assuming tasks are guaranteed to run in the order they were
// submitted, this fence will guarantee the attempt to hibernate runs to
// completion before the thread is destroyed.
// This test passes by not crashing, which proves that the WeakPtr logic
// is sound.
std::unique_ptr<WaitableEvent> fenceEvent = wrapUnique(new WaitableEvent());
testThread->getWebTaskRunner()->postTask(
BLINK_FROM_HERE,
WTF::bind(&WaitableEvent::signal, unretained(fenceEvent.get())));
fenceEvent->wait();
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToPendingTeardown)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationAbortedDueToPendingTeardown)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(
*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::HibernationAbortedDueToPendingDestruction))
.WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
testThread->getWebTaskRunner()->postTask(
BLINK_FROM_HERE, crossThreadBind(&Canvas2DLayerBridge::beginDestruction,
crossThreadUnretained(bridge.get())));
hibernationAbortedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
// Tear down bridge on thread
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToVisibilityChange)
#else
TEST_F(Canvas2DLayerBridgeTest,
DISABLED_HibernationAbortedDueToVisibilityChange)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::HibernationAbortedDueToVisibilityChange))
.WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), false);
hibernationAbortedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_TRUE(bridge->isAccelerated());
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, HibernationAbortedDueToLostContext)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_HibernationAbortedDueToLostContext)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
gl.setIsContextLost(true);
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationAbortedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::HibernationAbortedDueGpuContextLoss))
.WillOnce(testing::InvokeWithoutArgs(hibernationAbortedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationAbortedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_FALSE(bridge->isHibernating());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED
TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileHibernating)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileHibernating)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
// Test prepareMailbox while hibernating
cc::TextureMailbox textureMailbox;
std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
EXPECT_FALSE(
bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
EXPECT_CALL(*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::HibernationEndedWithTeardown));
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
#if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU
TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering)
#else
TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileBackgroundRendering)
#endif
{
FakeGLES2Interface gl;
std::unique_ptr<WebThread> testThread =
wrapUnique(Platform::current()->createThread("TestThread"));
// The Canvas2DLayerBridge has to be created on the thread that will use it
// to avoid WeakPtr thread check issues.
Canvas2DLayerBridgePtr bridge;
postAndWaitCreateBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge, &gl,
this);
// Register an alternate Logger for tracking hibernation events
std::unique_ptr<MockLogger> mockLogger = wrapUnique(new MockLogger);
MockLogger* mockLoggerPtr = mockLogger.get();
bridge->setLoggerForTesting(std::move(mockLogger));
// Test entering hibernation
std::unique_ptr<WaitableEvent> hibernationStartedEvent =
wrapUnique(new WaitableEvent());
EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(
Canvas2DLayerBridge::HibernationScheduled));
EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
.WillOnce(testing::Invoke(hibernationStartedEvent.get(),
&WaitableEvent::signal));
postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
hibernationStartedEvent->wait();
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
// Rendering in the background -> temp switch to SW
EXPECT_CALL(*mockLoggerPtr,
reportHibernationEvent(
Canvas2DLayerBridge::
HibernationEndedWithSwitchToBackgroundRendering));
postAndWaitRenderingTask(BLINK_FROM_HERE, testThread.get(), bridge.get());
::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
EXPECT_FALSE(bridge->isAccelerated());
EXPECT_FALSE(bridge->isHibernating());
EXPECT_TRUE(bridge->checkSurfaceValid());
// Test prepareMailbox while background rendering
cc::TextureMailbox textureMailbox;
std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
EXPECT_FALSE(
bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
EXPECT_TRUE(bridge->checkSurfaceValid());
// Tear down the bridge on the thread so that 'bridge' can go out of scope
// without crashing due to thread checks
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
} // namespace blink
|
e5dd7677bee71bf3f73653b35aee0d1312c7ae91 | a051eeee9611cae8211018731c2406d967cd8c40 | /exercise/CPE/UVa11220/UVa11220.cpp | d86392dcbeea809227651b19fa4dc58aae7a780d | [] | no_license | 25077667/NSYSU_Data_Structure | eefb82fa4be0d536caf70b1dfd8262199ca51c08 | 0c345df0fbbf1c1d37461488f9d40221913666e5 | refs/heads/main | 2021-12-30T07:18:15.939548 | 2021-12-29T13:34:32 | 2021-12-29T13:34:32 | 193,859,134 | 9 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,089 | cpp | UVa11220.cpp | #include <iostream>
#include <string>
using namespace std;
void removeConversion() {
while (isspace(cin.peek()))
cin.ignore();
}
bool isNullLine(string s) {
for (auto c : s)
if (!isspace(c))
return false;
return true;
}
void decode(string _line) {
int wordCounter = 0, indexCounter = 0;
bool hadPrint = false;
for (auto c : _line) {
if (isspace(c)) {
hadPrint = false;
indexCounter = -1;
}
if (!hadPrint) {
if (wordCounter == indexCounter) {
cout << c;
hadPrint = true;
indexCounter = 0;
wordCounter++;
} else
indexCounter++;
}
}
cout << endl;
}
int main() {
int cases;
cin >> cases;
for (int i = 1; i <= cases; i++) {
printf("Case #%d:\n", i);
string singleLine;
removeConversion();
while (getline(cin, singleLine) && !isNullLine(singleLine))
decode(singleLine);
cout << endl;
}
return 0;
} |
42bba33b254abb094c1295539c2bf249aa04f6e1 | 34ab7facc3d9ba0303f6b62b72670d6d349e1af6 | /categorypage/icsettingsframe.h | b0fabcd3d33dc46308e696a40a5a89b5e3ac4af4 | [] | no_license | GaussCheng/2-5AxisPunch | 0fb1532aef359b3cba27fa875ff4e34a196e43da | d57380ac8acd77fe5860d4208a5dfba0b12d117b | refs/heads/master | 2021-01-17T09:49:31.044350 | 2015-03-05T03:58:51 | 2015-03-05T03:58:51 | 31,994,191 | 3 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 596 | h | icsettingsframe.h | #ifndef ICSETTINGSFRAME_H
#define ICSETTINGSFRAME_H
#include <QFrame>
namespace Ui {
class ICSettingsFrame;
}
class ICSettingsFrame : public QFrame
{
Q_OBJECT
public:
explicit ICSettingsFrame(QWidget *parent = 0);
~ICSettingsFrame();
void SetToShowAll(bool isshow);
protected:
void showEvent(QShowEvent *e);
void changeEvent(QEvent *e);
private slots:
void on_generateButton_clicked();
void on_registerButton_clicked();
void on_fcode_textChanged(const QString &arg1);
private:
Ui::ICSettingsFrame *ui;
};
#endif // ICSETTINGSFRAME_H
|
31e2930ec479003e5129776e095b1c8e7ce60718 | da478bc774b74005370117f192ef7e9f81d4b8fa | /Final/xam/maxsizesquare-mat.cpp | 7eda724a7f1a83a937ea6a4c2568342cf8cfc9b3 | [] | no_license | Utlesh/code | 20c8b63dcec825f144d780e2f2d9b0f22191986f | 029d7030f775076be12a65564cbe80373d6e3ac0 | refs/heads/master | 2020-05-02T05:41:06.632614 | 2015-07-30T10:18:02 | 2015-07-30T10:18:02 | 39,931,679 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 702 | cpp | maxsizesquare-mat.cpp | #include<iostream>
using namespace std;
#define N 10
int min(int a,int b,int c)
{
int temp = a<b?a:b;
return c<temp?c:temp;
}
void maxSquareMat(int arr[][N],int row,int col)
{
int max = 0;
for(int i=1;i<row;++i)
for(int j=1;j<col;++j)
{
if(*(*(arr+i)+j)!=0)
*(*(arr+i)+j) = min(*(*(arr+i-1)+j-1),*(*(arr+i-1)+j),*(*(arr+i)+j-1)) + 1;
if(*(*(arr+i)+j)>max)
{max = *(*(arr+i)+j);
cout<<max<<" "<<i<<" "<<j<<" ";}
}
cout<<max<<"\n";
}
int main()
{
int arr[10][10],row,col;
cout<<"How many rows nd columns r there:\n";
cin>>row>>col;
for(int i=0;i<row;++i)
for(int j=0;j<col;++j)
cin>>arr[i][j];
maxSquareMat(arr,row,col);
return 0;
}
|
2bbab9215b9b6db3d3d2b563d7834953b3a9627d | 6789c9f206b22d38f1aab1814a771137f28eccd1 | /Radar_RCWL-0516/src/RadarSensor_RCWL0516.h | 4a13e11cc52990dce51ef35c46957c3fa2c57a5d | [] | no_license | mz-forest/mz-forest-sensors | 26297b2cf8a5c26074d64fb6cc72c096a41b31b9 | c2a7bb2aa198065c2b70d37579e93c803a03df66 | refs/heads/master | 2020-03-21T15:47:00.854226 | 2018-06-30T11:29:29 | 2018-06-30T11:29:29 | 138,732,502 | 1 | 2 | null | 2018-06-26T21:53:03 | 2018-06-26T12:07:49 | C++ | UTF-8 | C++ | false | false | 670 | h | RadarSensor_RCWL0516.h | // RadarSensor_RCWL0516.h
#ifndef _RADARSENSOR_RCWL0516_H_
#define _RADARSENSOR_RCWL0516_H_
#include "Arduino.h"
#include "SensorData.h"
class RadarSensor_RCWL0516 {
public:
RadarSensor_RCWL0516();
virtual ~RadarSensor_RCWL0516();
int setInterruptPin(int pin); // interrupt pin has to be interrupt capable
int setEnablePin(int pin);
int getInterruptPin();
int getEnablePin();
int configure();
int enable();
int disable();
void sensorIRQ();
private:
int _interruptPin;
int _enablePin;
bool _configured;
};
#endif // _RADARSENSOR_RCWL0516_H_ |
aebdfc7af0fa1a0cd1af723a89860c31a9e03b79 | 46b05565f8735066396015adbbdc240b720f62df | /server.cpp | 62558dc46483f951a545ad259b16fbe89ee24728 | [] | no_license | hahgiraffe/RDF-Partition | ba5a1e49b6ba45fd9665c62cb783e961a4926446 | 34602b86d9c5ad3fe1d65645c5fe6af221c43ad4 | refs/heads/main | 2023-01-12T20:42:27.407217 | 2020-11-19T11:50:16 | 2020-11-19T11:50:16 | 314,227,699 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,098 | cpp | server.cpp | #include "server.h"
#include "zmq.h"
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include <atomic>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;
#define MAXCOMMANDSIZE 1024
#define MAXBUFSIZE 102400
multimap<string, pair<string, string>> portMap{
{"11.11.11.4", {"11.11.11.11", "10001"}},
{"11.11.11.4", {"11.11.11.12", "10001"}},
{"11.11.11.11", {"11.11.11.4", "10001"}},
{"11.11.11.11", {"11.11.11.12", "10002"}},
{"11.11.11.12", {"11.11.11.4", "10002"}},
{"11.11.11.12", {"11.11.11.11", "10002"}},
};
server::server(){
pthread_mutex_init(&mu, NULL);
}
server::server(std::string ip, int port, vector<string> clusterNodeIP) :
serverIP(ip),
serverPort(port),
clusterIP(clusterNodeIP){
ctx = zmq_ctx_new();
receiver = zmq_socket(ctx, ZMQ_REP);
std::string serverAddr = "tcp://*:" + to_string(serverPort);
int rc = zmq_bind(receiver, serverAddr.c_str());
assert(rc == 0);
pthread_mutex_init(&mu, NULL);
}
server::~server(){
zmq_close(receiver);
zmq_ctx_destroy(ctx);
pthread_mutex_destroy(&mu);
}
//对于master通信,接收指令并执行
void server::receive_send(){
cout << "begin receive_send" << endl;
while(1){
char commandBuf[MAXCOMMANDSIZE];
int recvbyte = zmq_recv(receiver, commandBuf, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
string command(commandBuf);
cout << "command is:" << command << " size: " << command.size() << endl;
if(command.compare("heartBeat") == 0){
string resp = "OK";
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
} else if(command.compare("exit") == 0){
//先退出与其他slave连接
for(int i = 0; i < senders.size(); ++i){
string msg = "exit";
int err = zmq_send(senders[i], msg.c_str(), msg.size()+1, 0);
assert(err != -1);
char isOk[20];
int recvbyte = zmq_recv(senders[i], isOk, 20, 0);
assert(recvbyte != -1);
assert(std::string(isOk).compare("OK") == 0);
}
string resp = "OK";
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
break;
} else if(command.compare("graph") == 0){
string resp = "OK";
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
//msg's len
char msgLen[MAXCOMMANDSIZE];
int recvbyte = zmq_recv(receiver, msgLen, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
int len = atoi(msgLen);
cout << "msg's len: " << len << endl;
//msg
char* msg = new char[len];
recvbyte = zmq_recv(receiver, msg, len+1, 0);
assert(recvbyte != -1);
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
//接收到子图信息,先持久化检验
// fstream ouputFile("subData/SecondSubGraph" + to_string(serverPort), ios::out);
// ouputFile << msg;
// ouputFile.close();
//接下来根据接收到子图数据建树
string target(msg);
tree = new parallelTree(target);
tree->buildTree();
tree->traverseStatistics("subData/tree" + to_string(serverPort));
} else if(command.compare("intersection") == 0){
string resp = "OK";
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
//msg's len
char msgLen[MAXCOMMANDSIZE];
int recvbyte = zmq_recv(receiver, msgLen, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
int len = atoi(msgLen);
//msg
char *buf = new char[len+1];
recvbyte = zmq_recv(receiver, buf, len, 0);
assert(recvbyte != -1);
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
string interStr(buf);
istringstream iss(interStr);
string temp;
while (getline(iss, temp, '_')) {
intersection.push_back(atoi(temp.c_str()));
}
// cout << "intersection's actual len is:" << intersection.size() << endl;
} else if(command.compare("getEntitySize") == 0){
string resp = "OK";
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
double startTime = get_time();
//创建与slave之间的连接
buildSlaveConnector();
//接下来对每个其他的slave节点通信,问他们ID的树规模,然后再判断是否为主实体树
int entityIsLocal = 0;
vector<vector<int>> allCheckResult;
for(int i = 0; i < senders.size(); ++i){
//先发送command
string msg = "getTreeSize";
int err = zmq_send(senders[i], msg.c_str(), msg.size()+1, 0);
assert(err != -1);
char isOk[20];
int recvbyte = zmq_recv(senders[i], isOk, 20, 0);
assert(recvbyte != -1);
assert(std::string(isOk).compare("OK") == 0);
//将interseciton进行编码
string interStr;
for(int i = 0; i < intersection.size(); ++i){
interStr += to_string(intersection[i]) + "_";
}
interStr.pop_back();
//发送长度,返回ok
string interStrlen = to_string(interStr.size());
err = zmq_send(senders[i], interStrlen.c_str(), interStrlen.size()+1, 0);
assert(err != -1);
recvbyte = zmq_recv(senders[i], isOk, 20, 0);
assert(recvbyte != -1);
assert(std::string(isOk).compare("OK") == 0);
//发送信息,返回ok
err = zmq_send(senders[i], interStr.c_str(), interStr.size()+1, 0);
assert(err != -1);
recvbyte = zmq_recv(senders[i], isOk, 20, 0);
assert(recvbyte != -1);
assert(std::string(isOk).compare("OK") == 0);
//发送ok,返回结果长度
char resultLen[MAXCOMMANDSIZE];
err = zmq_send(senders[i], resp.c_str(), resp.size()+1, 0);
assert(err != -1);
recvbyte = zmq_recv(senders[i], resultLen, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
//发送ok,返回结果内容
char *result = new char[atoi(resultLen)+1];
err = zmq_send(senders[i], resp.c_str(), resp.size()+1, 0);
assert(err != -1);
recvbyte = zmq_recv(senders[i], result, atoi(resultLen), 0);
assert(recvbyte != -1);
//解析result
vector<int> entitySizeArray;
istringstream iss(result);
string temp;
while (getline(iss, temp, '_')) {
entitySizeArray.push_back(atoi(temp.c_str()));
}
allCheckResult.push_back(entitySizeArray);
}
for(int i = 0; i < allCheckResult[0].size(); ++i){
int scale = tree->getTotalNumber(intersection[i]);
bool flag = true;
for(int j = 0; j < allCheckResult.size(); ++j){
if(allCheckResult[j][i] >= scale){
flag = false;
break;
}
}
if(flag){
mainEntityTrees.push_back(intersection[i]);
entityIsLocal++;
}
}
double endTime = get_time();
cout << "getEntitySize end, entityIsLocal:" << entityIsLocal << ", time:" << endTime-startTime << "s" << endl;
} else if(command.compare("getSubEntityTree") == 0){
string resp = "OK";
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
double startTime = get_time();
//这里首先是给所有sender发送command
for(int i = 0; i < senders.size(); ++i){
//先发送命令
string msg = "getTreeContent";
int err = zmq_send(senders[i], msg.c_str(), msg.size()+1, 0);
assert(err != -1);
char isOk[20];
int recvbyte = zmq_recv(senders[i], isOk, 20, 0);
assert(recvbyte != -1);
assert(std::string(isOk).compare("OK") == 0);
}
//mainEntityTrees编码
string mainEntityTreeStr;
for(int i = 0; i < mainEntityTrees.size(); ++i){
mainEntityTreeStr += to_string(mainEntityTrees[i]) + "_";
}
mainEntityTreeStr.pop_back();
for(int i = 0; i < senders.size(); ++i){
//发送长度,返回OK
string mainEntityTreeStrLen = to_string(mainEntityTreeStr.size());
int err = zmq_send(senders[i], mainEntityTreeStrLen.c_str(), mainEntityTreeStrLen.size()+1, 0);
assert(err != -1);
char isOk[20];
recvbyte = zmq_recv(senders[i], isOk, 20, 0);
assert(recvbyte != -1);
assert(std::string(isOk).compare("OK") == 0);
//发送内容,返回OK
err = zmq_send(senders[i], mainEntityTreeStr.c_str(), mainEntityTreeStr.size()+1, 0);
assert(err != -1);
recvbyte = zmq_recv(senders[i], isOk, 20, 0);
assert(recvbyte != -1);
assert(std::string(isOk).compare("OK") == 0);
}
//存储所有节点的结果
vector<vector<string>> allNodeResult;
for(int i = 0; i < senders.size(); ++i){
//发送OK,返回长度
char resultLen[MAXCOMMANDSIZE];
int err = zmq_send(senders[i], resp.c_str(), resp.size()+1, 0);
assert(err != -1);
recvbyte = zmq_recv(senders[i], resultLen, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
// cout << "resultLen:" << atoi(resultLen) << endl;
//发送OK,返回内容
char* result = new char[atoi(resultLen)+1];
err = zmq_send(senders[i], resp.c_str(), resp.size()+1, 0);
assert(err != -1);
recvbyte = zmq_recv(senders[i], result, atoi(resultLen), 0);
assert(recvbyte != -1);
//解析resultStr
istringstream iss(result);
string temp;
vector<string> resultVec;
while (getline(iss, temp, '$')) {
resultVec.push_back(temp);
}
allNodeResult.push_back(resultVec);
cout << "slave" << i << " get TreeContent end, content's number:" << resultVec.size() << endl;
}
//check,只打印十个值
// cout << "----getSubEntityTree" << endl;
// for(int i = 0; i < 5 && i < allNodeResult[0].size(); ++i){
// cout << "ID:" << mainEntityTrees[i] << endl;
// for(int j = 0; j < allNodeResult.size(); ++j){
// cout << "node" << j << ":" << allNodeResult[j][i] << endl;
// }
// cout << endl;
// }
string originContent = tree->getContent();
set<string> check;
for(int i = 0; i < allNodeResult.size(); ++i){
for(int j = 0; j < allNodeResult[i].size(); ++j){
string tranMsg = allNodeResult[i][j];
replace(tranMsg.begin(), tranMsg.end(), '_', ' ');
replace(tranMsg.begin(), tranMsg.end(), '|', '\n');
size_t beginIndex = 0;
auto spaceIndex = tranMsg.find('\n', beginIndex);
while(spaceIndex != string::npos){
string subTriple = tranMsg.substr(beginIndex, spaceIndex-beginIndex);
if(check.find(subTriple) == check.end()){
check.insert(subTriple);
originContent += subTriple + "\n";
}
beginIndex = spaceIndex+1;
spaceIndex = tranMsg.find('\n', beginIndex);
}
}
}
//持久化
fstream outputFile("subData/result", ios::out);
outputFile << originContent;
outputFile.close();
double endTime = get_time();
cout << "getSubEntityTree end!!!time:" << endTime-startTime << "s" << endl;
} else if(command.compare("getIndex") == 0){
//这里直接返回该节点上的主实体树实体ID
string resp = "OK";
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
char isOK[MAXCOMMANDSIZE];
recvbyte = zmq_recv(receiver, isOK, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
string result;
for(auto entity : mainEntityTrees){
result += to_string(entity);
result += "_";
}
string resultLen = to_string(result.size()+1);
zmq_send(receiver, resultLen.c_str(), resultLen.size()+1, 0);
recvbyte = zmq_recv(receiver, isOK, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
zmq_send(receiver, result.c_str(), result.size()+1, 0);
} else if(command.compare("getPartitionGraphLen") == 0){
//先传输长度
string result;
string line;
fstream inputFile("subData/result", ios::in);
if(!inputFile){
cout << "open subData/result error" << endl;
}
while(getline(inputFile, line)){
result += line;
result += '\n';
}
inputFile.close();
string resultLen = to_string(result.size());
zmq_send(receiver, resultLen.c_str(), resultLen.size()+1, 0);
cout << "send parititonGraphLen is:" << resultLen << endl;
char graphCommand[MAXCOMMANDSIZE];
recvbyte = zmq_recv(receiver, graphCommand, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
//再传输内容
zmq_send(receiver, result.c_str(), result.size()+1, 0);
cout << "end getPartitionGraphLen" << endl;
} else {
//Invaild Command
string resp = "Invaild Command";
zmq_send(receiver, resp.c_str(), resp.size()+1, 0);
exit(1);
}
}
}
//服务器2 * 14 = 28虚拟cpu
const int PTHREAD_NUM = 5;
struct threadArg{
server* ser;
vector<string> tasks;
// int index;
int beginIndex;
int interval;
string threadResult;
};
//与slave进行通信的服务器端
void server::start_slaves(string port){
cout << "start listen to slave" << endl;
void* slave_ctx = zmq_ctx_new();
void* slave_receiver = zmq_socket(ctx, ZMQ_REP);
std::string serverAddr = "tcp://*:" + port;
int rc = zmq_bind(slave_receiver, serverAddr.c_str());
assert(rc == 0);
while(1){
char commandBuf[MAXCOMMANDSIZE];
int recvbyte = zmq_recv(slave_receiver, commandBuf, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
string command(commandBuf);
cout << "slave command is:" << command << endl;
if(command.compare("heartBeat") == 0){
string resp = "OK";
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
} else if(command.compare("getTreeSize") == 0){
//获得该计算节点,实体树的规模大小(目前是整体的实体出现次数)
string resp = "OK";
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
//接受长度,返回OK
char recvLen[MAXCOMMANDSIZE];
recvbyte = zmq_recv(slave_receiver, recvLen, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
int len = atoi(recvLen);
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
cout << "slave getTreeSize'len: " << len << endl;
//接受内存,返回OK
char *buf = new char[len+1];
recvbyte = zmq_recv(slave_receiver, buf, len, 0);
assert(recvbyte != -1);
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
string target(buf);
//解码内容
string result;
istringstream iss(target);
string temp;
vector<string> tmpResult;
while (getline(iss, temp, '_')) {
tmpResult.push_back(temp);
}
for(int i = 0; i < tmpResult.size(); ++i){
int scale = tree->getTotalNumber(atoi(tmpResult[i].c_str()));
result += to_string(scale) + "_";
}
result.pop_back();
//发送结果长度
string resultLen = to_string(result.size());
recvbyte = zmq_recv(slave_receiver, recvLen, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
zmq_send(slave_receiver, resultLen.c_str(), resultLen.size()+1, 0);
//发送结果内容
recvbyte = zmq_recv(slave_receiver, recvLen, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
zmq_send(slave_receiver, result.c_str(), result.size()+1, 0);
delete buf;
} else if(command.compare("getTreeContent") == 0) {
double startTime = get_time();
//获得该计算节点,实体树的所有子树(以三元组的形式传回去)
string resp = "OK";
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
//接受字符串长度,返回OK
char recvLen[MAXCOMMANDSIZE];
recvbyte = zmq_recv(slave_receiver, recvLen, MAXCOMMANDSIZE, 0);
assert(recvbyte != -1);
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
int len = atoi(recvLen);
//接受字符串,返回OK
char* buf = new char[len+1];
recvbyte = zmq_recv(slave_receiver, buf, len, 0);
assert(recvbyte != -1);
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
//解码内容
string target(buf);
istringstream iss(target);
string temp;
vector<string> taskArr;
while (getline(iss, temp, '_')) {
taskArr.push_back(temp);
}
int interval = taskArr.size() / PTHREAD_NUM + 1;
cout << "interval:" << interval << endl;
//开多个线程,并行遍历子树
std::vector<pthread_t> pidArr(PTHREAD_NUM);
std::vector<threadArg> pidArg;
for(int i = 0; i < PTHREAD_NUM; ++i){
threadArg arg;
// arg.index = i;
arg.ser = this;
arg.beginIndex = i * interval;
arg.interval = interval;
arg.tasks = taskArr;
pidArg.push_back(arg);
}
for(int i = 0; i < PTHREAD_NUM; ++i){
pthread_create(&pidArr[i], NULL, runThread, (void*)&pidArg[i]);
}
for(int i = 0; i < PTHREAD_NUM; ++i){
pthread_join(pidArr[i], NULL);
}
// check thread return value
string lastResult;
for(int i = 0; i < pidArg.size(); ++i){
lastResult += pidArg[i].threadResult;
}
//因为最后多了一个'$',则去除
lastResult.pop_back();
// 这里有问题
// for(int i = 0; i < PTHREAD_NUM; ++i){
// pthread_cancel(pidArr[i]);
// }
cout << "slave "<< port <<" thread end" << endl;
//接受OK,返回字符串长度
char isOK[20];
string lastResultLen = to_string(lastResult.size());
recvbyte = zmq_recv(slave_receiver, isOK, 20, 0);
assert(recvbyte != -1);
zmq_send(slave_receiver, lastResultLen.c_str(), lastResultLen.size()+1, 0);
//接受OK,返回字符串
recvbyte = zmq_recv(slave_receiver, isOK, 20, 0);
assert(recvbyte != -1);
zmq_send(slave_receiver, lastResult.c_str(), lastResult.size()+1, 0);
double endTime = get_time();
cout << "slave use " << endTime - startTime << "s do getTreeContent for " << port << endl;
} else if(command.compare("exit") == 0){
string resp = "OK";
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
break;
} else {
string resp = "Invaild Command";
zmq_send(slave_receiver, resp.c_str(), resp.size()+1, 0);
exit(1);
}
}
zmq_close(slave_receiver);
zmq_ctx_destroy(slave_ctx);
}
void server::buildSlaveConnector(){
for(int i = 0; i < clusterIP.size(); ++i){
if(clusterIP[i] == serverIP){
continue;
}
void* sender_ctx = zmq_ctx_new();
void *sender = zmq_socket(ctx, ZMQ_REQ);
string desPort;
auto it = portMap.find(serverIP);
for(int k = 0; k != portMap.count(serverIP); k++, it++){
if(it->second.first == clusterIP[i]){
desPort = it->second.second;
}
}
if(desPort == ""){
cout << "find portMap error" << endl;
continue;
}
string serverAddr = "tcp://" + clusterIP[i] + ":" + desPort;
cout << serverAddr << endl;
zmq_connect(sender, serverAddr.c_str());
senderContexts.push_back(sender_ctx);
senders.push_back(sender);
}
}
void server::stopSlaveConnector(){
for(int i = 0; i < senders.size(); ++i){
zmq_close(senders[i]);
}
for(int i = 0; i < senderContexts.size(); ++i){
zmq_ctx_destroy(senderContexts[i]);
}
}
void server::runGetTreeContentThread(void* arg){
threadArg* localArg = (threadArg*)arg;
int limit = localArg->beginIndex + localArg->interval;
// pthread_mutex_lock(&mu);
int n = 0;
string& result = ((threadArg*)arg)->threadResult;
for(int i = localArg->beginIndex; i < limit && i < localArg->tasks.size(); ++i){
auto tempResult = tree->getSubTree(atoi(localArg->tasks[i].c_str()));
if(tempResult.empty()){
continue;
}
string response;
for(auto r : tempResult){
response += to_string(get<0>(r));
response += '_';
response += to_string(get<1>(r));
response += '_';
response += to_string(get<2>(r));
response += '|';
}
result += response + "$";
// n++;
// if(n % 10 == 0) cout << n << endl;
}
// pthread_mutex_unlock(&mu);
}
//多开线程,非成员函数调用成员函数
void* runThread(void* arg){
((threadArg*)arg)->ser->runGetTreeContentThread(arg);
return 0;
} |
de85a70b52280691cf9300e6ac2265ab7400622d | 8a3649b3fd343b85fa5e1a64c4e6261d3c0a2fe3 | /tinh_luong_nuoc.cpp | 7b9b255cf849d8642af78fc2cef718a2e7a99440 | [] | no_license | azaharbarbie/Bai_tapC | 3c58405185e63b37f928eab46ca7e645a0a42779 | 59cdf98807c2971ec7fe8297b5a0bf84693d4bfd | refs/heads/main | 2023-07-13T02:40:11.528098 | 2021-08-20T15:22:47 | 2021-08-20T15:22:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 495 | cpp | tinh_luong_nuoc.cpp | #include <iostream>
#define ll long long
#define MAX 1000000
using namespace std;
ll a[MAX], b[MAX];
int main(){
int N, t;
cin >> N >> t;
ll sum = 0;
for (int i = 1; i <= N; i++){
cin >> a[i] >> b[i];
sum += a[i];
}
cout << sum << endl;
for (int i = 1; i <= t; i++){
for (int k = 1; k <= N; k++){
if (a[k] > 0){
a[k] -= b[k];
}
}
sum = 0;
for (int j = 1; j <= N; j++){
if (a[j] >= 0){
sum += a[j];
}
}
cout << sum << endl;
}
return 0;
}
|
8f3d5fd2f90cb8d4a4c915accf8f43483362cffd | 06cc1df84a86a4f50d200050073d77ef5292fd08 | /lib/boost/type_traits/include/boost/type_traits/has_new_operator.hpp | c615127da3435770a8ebf145d98161fabfb120c6 | [
"MIT"
] | permissive | jeaye/color_coded | 69c3d9b16aa55e189d2b085af2a7b06598e021ef | 6c3ac39e59e40124b7bcaa7bd5a18bcaa6c10429 | refs/heads/master | 2023-07-30T11:04:40.419137 | 2023-04-13T04:59:17 | 2023-04-13T04:59:17 | 24,677,959 | 1,003 | 84 | MIT | 2023-04-13T04:59:18 | 2014-10-01T12:42:28 | C++ | UTF-8 | C++ | false | false | 5,330 | hpp | has_new_operator.hpp |
// (C) Copyright Runar Undheim, Robert Ramey & John Maddock 2008.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
//
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
#ifndef BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
#define BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
#include <new> // std::nothrow_t
#include <cstddef> // std::size_t
#include <boost/type_traits/config.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/type_traits/detail/ice_or.hpp>
// should be the last #include
#include <boost/type_traits/detail/bool_trait_def.hpp>
#if defined(new)
# if BOOST_WORKAROUND(BOOST_MSVC, >= 1310)
# define BOOST_TT_AUX_MACRO_NEW_DEFINED
# pragma push_macro("new")
# undef new
# else
# error "Sorry but you can't include this header if 'new' is defined as a macro."
# endif
#endif
namespace boost {
namespace detail {
template <class U, U x>
struct test;
template <typename T>
struct has_new_operator_impl {
template<class U>
static type_traits::yes_type check_sig1(
U*,
test<
void *(*)(std::size_t),
&U::operator new
>* = NULL
);
template<class U>
static type_traits::no_type check_sig1(...);
template<class U>
static type_traits::yes_type check_sig2(
U*,
test<
void *(*)(std::size_t, const std::nothrow_t&),
&U::operator new
>* = NULL
);
template<class U>
static type_traits::no_type check_sig2(...);
template<class U>
static type_traits::yes_type check_sig3(
U*,
test<
void *(*)(std::size_t, void*),
&U::operator new
>* = NULL
);
template<class U>
static type_traits::no_type check_sig3(...);
template<class U>
static type_traits::yes_type check_sig4(
U*,
test<
void *(*)(std::size_t),
&U::operator new[]
>* = NULL
);
template<class U>
static type_traits::no_type check_sig4(...);
template<class U>
static type_traits::yes_type check_sig5(
U*,
test<
void *(*)(std::size_t, const std::nothrow_t&),
&U::operator new[]
>* = NULL
);
template<class U>
static type_traits::no_type check_sig5(...);
template<class U>
static type_traits::yes_type check_sig6(
U*,
test<
void *(*)(std::size_t, void*),
&U::operator new[]
>* = NULL
);
template<class U>
static type_traits::no_type check_sig6(...);
// GCC2 won't even parse this template if we embed the computation
// of s1 in the computation of value.
#ifdef __GNUC__
BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(has_new_operator_impl<T>::template check_sig1<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(has_new_operator_impl<T>::template check_sig2<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(has_new_operator_impl<T>::template check_sig3<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(has_new_operator_impl<T>::template check_sig4<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(has_new_operator_impl<T>::template check_sig5<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(has_new_operator_impl<T>::template check_sig6<T>(0)));
#else
#if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
#pragma warning(push)
#pragma warning(disable:6334)
#endif
BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig1<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(check_sig2<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(check_sig3<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(check_sig4<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(check_sig5<T>(0)));
BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(check_sig6<T>(0)));
#if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
#pragma warning(pop)
#endif
#endif
BOOST_STATIC_CONSTANT(bool, value =
(::boost::type_traits::ice_or<
(s1 == sizeof(type_traits::yes_type)),
(s2 == sizeof(type_traits::yes_type)),
(s3 == sizeof(type_traits::yes_type)),
(s4 == sizeof(type_traits::yes_type)),
(s5 == sizeof(type_traits::yes_type)),
(s6 == sizeof(type_traits::yes_type))
>::value)
);
};
} // namespace detail
BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_new_operator,T,::boost::detail::has_new_operator_impl<T>::value)
} // namespace boost
#if defined(BOOST_TT_AUX_MACRO_NEW_DEFINED)
# pragma pop_macro("new")
#endif
#include <boost/type_traits/detail/bool_trait_undef.hpp>
#endif // BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
|
6eac994c0746ac4b0774f0dc408b54b855570ece | 5013750dde6990bf5d384cfd806b0d411f04d675 | /leetcode/c++/1232. Check If It Is a Straight Line.cpp | b0c6d8cfa01a4110a6b9c3c9abcf4b2f3b1b7549 | [] | no_license | 543877815/algorithm | 2c403319f83630772ac94e67b35a27e71227d2db | 612b2e43fc6e1a2a746401288e1b89689e908926 | refs/heads/master | 2022-10-11T10:31:17.049279 | 2022-09-25T15:11:46 | 2022-09-25T15:11:46 | 188,680,726 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 679 | cpp | 1232. Check If It Is a Straight Line.cpp | // 数学一次遍历
// 时间复杂度:O(n)
// 空间复杂度:O(1)
class Solution {
public:
bool checkStraightLine(vector <vector<int>> &coordinates) {
int n = coordinates.size();
if (n == 1) return true;
int deltaX = coordinates[0][0], deltaY = coordinates[0][1];
for (int i = 0; i < n; i++) {
coordinates[i][0] -= deltaX;
coordinates[i][1] -= deltaY;
}
int A = coordinates[1][1], B = -coordinates[1][0];
for (int i = 2; i < n; i++) {
int x = coordinates[i][0], y = coordinates[i][1];
if (A * x + B * y != 0) return false;
}
return true;
}
}; |
a9525c281be1eb978bf7e1fcd55357afd53d77ed | d190717a95365d0d4740db203577d15eecd35706 | /Qsort.cpp | 4fefe338a9ac5a63ea39085cb08b4908ce2e5b58 | [] | no_license | arsreejith/MiscSourceCodes | ae90b4d6ba094f994fbd0f5a419e08f8e0e5c0dd | 7360a9bdc9e4eb571194162042614d6011a22a92 | refs/heads/master | 2021-01-18T19:17:49.557391 | 2017-04-01T08:03:39 | 2017-04-01T08:03:39 | 86,895,675 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,029 | cpp | Qsort.cpp | #include <iostream>
using namespace std;
int MAX =12;
void Qsort(int* array, int start, int end)
{
if(start > end)
return;
int i,j;
i = start;j=end;
int pivot = array[start];
while(i <= j)
{
while( array[i]<=pivot)
++i;
while( array[j] > pivot)
--j;
if(i<=j)
{
int temp = array[j];
array[j] = array[i];
array[i] = temp;
}
}
if( i > j)
{
int temp = array[j];
array[j] = pivot;
array[start]=temp;
}
Qsort(array,start,j-1);
Qsort(array,i,end);
}
int main()
{
int array[]={100,99,56,34,200,2,5,77,1,9,122,45};
Qsort(array, 0,12);
cout<<"\n"<<"\t"<<"After Sort.."<<"\n";
for(int i=0;i<12;++i)
{
cout<<"\t"<<"\n"<<array[i];
}
cout<<"\n";
}
|
4c2a74a48e890e359cb2d4e9626b2db3d21f9d8f | 85017870e6ffaf9c1c4a68eedbf7b0564c4b1030 | /cpplib/src_tmp/main.cpp | b277ccc1313c798129b409dc0c945f120fab798e | [] | no_license | zhangchizju2012/UofA_ETHNOPRED | bf4b6e698e8f8e7469c7dc7a87c59251a7e496c4 | 9321fa5c4ad4d78de06e491b456155ca4fbc35a7 | refs/heads/master | 2021-01-15T15:54:35.361622 | 2016-08-19T15:50:36 | 2016-08-19T15:50:36 | 40,614,011 | 6 | 2 | null | 2015-11-18T20:18:44 | 2015-08-12T17:16:26 | C++ | UTF-8 | C++ | false | false | 175,956 | cpp | main.cpp |
#include "common.hpp"
#include "TreeNode.h"
#include "DecisionTree.h"
//#include <conio.h>
#include <iostream>
//using namespace std;
TreeNode::TreeNode()
{
//set the objects pointers to NULL in default constructor
m_pYesBranch = NULL;
m_pNoBranch = NULL;
m_iNodeID = "0";
}
TreeNode::~TreeNode()
{
}
TreeNode::TreeNode(const std::string & nodeID, const std::string & newQorA, const double & nodeValue)
{
//create a tree node with a specific node id and string
m_iNodeID = nodeID;
m_strQuestOrAns = newQorA;
m_NodeValue = nodeValue;
//ensure pointers are set to NULL in the new node
m_pYesBranch = NULL;
m_pNoBranch = NULL;
}
DecisionTree::DecisionTree()
{
//set roots node to NULL upon tree creation
m_pRootNode = NULL;
}
DecisionTree::~DecisionTree()
{
//recursive call to delete tree nodes and root
RemoveNode(m_pRootNode);
}
void DecisionTree::CreateRootNode(const std::string & nodeID, const std::string & newQorA, const double & nodeValue)
{
//create the root node with a specific ID and string
m_pRootNode = new TreeNode(nodeID, newQorA, nodeValue);
}
void DecisionTree::AddYesNode(const std::string & existingNodeID, const std::string & newNodeID, const std::string & newQorA, const double & newNodeValue)
{
//if you dont have a root node you cant add another node
if (m_pRootNode == NULL)
{
std::cout << "Error - no root node in AddYesNode()\n";
return;
}
//otherwise query tree and add node
if (SearchTreeAndAddYesNode(m_pRootNode, existingNodeID, newNodeID, newQorA, newNodeValue))
{
//cout << "Added 'yes' node";
//cout << newNodeID;
//cout << " onto 'yes' branch of node ";
//cout << existingNodeID;
//cout << endl;
}
else
{
std::cout << "Node ";
std::cout << existingNodeID;
std::cout << " not found \n";
}
}
bool DecisionTree::SearchTreeAndAddYesNode(TreeNode* currentNode, const std::string & existingNodeID, const std::string & newNodeID, const std::string & newQorA, const double & newNodeValue)
{
if (currentNode->m_iNodeID == existingNodeID)//for root
{
//create node
if (currentNode->m_pYesBranch == NULL)
{
currentNode->m_pYesBranch = new TreeNode(newNodeID, newQorA, newNodeValue);
}
else//take the place
{
currentNode->m_pYesBranch = new TreeNode(newNodeID, newQorA, newNodeValue);
}
return true;
}
else//for not root
{
//try yes branch if it exists
if (currentNode->m_pYesBranch != NULL)//可以一层一层查进去
{
if (SearchTreeAndAddYesNode(currentNode->m_pYesBranch, existingNodeID, newNodeID, newQorA, newNodeValue))
{
return true;
}
else
{
//try no branch if it exists
if (currentNode->m_pNoBranch != NULL)
{
return(SearchTreeAndAddYesNode(currentNode->m_pNoBranch, existingNodeID, newNodeID, newQorA, newNodeValue));
}
else
return false;
}
}
return false;
}
}
void DecisionTree::AddNoNode(const std::string & existingNodeID, const std::string & newNodeID, const std::string & newQorA, const double & newNodeValue)
{
if (m_pRootNode == NULL)
{
std::cout << "Error no root node in AddNoNode()\n";
return;
}
if (SearchTreeAndAddNoNode(m_pRootNode, existingNodeID, newNodeID, newQorA, newNodeValue))
{
//cout << "Added 'no' node";
//cout << newNodeID;
//cout << " onto 'no' branch of node ";
//cout << existingNodeID;
//cout << endl;
}
else
{
std::cout << "Node ";
std::cout << existingNodeID;
std::cout << " not found \n";
}
}
bool DecisionTree::SearchTreeAndAddNoNode(TreeNode* currentNode, const std::string & existingNodeID, const std::string & newNodeID, const std::string & newQorA, const double & newNodeValue)
{
if (currentNode->m_iNodeID == existingNodeID)
{
if (currentNode->m_pNoBranch == NULL)
{
currentNode->m_pNoBranch = new TreeNode(newNodeID, newQorA, newNodeValue);
}
else
{
currentNode->m_pNoBranch = new TreeNode(newNodeID, newQorA, newNodeValue);
}
return true;
}
else
{
if (currentNode->m_pYesBranch != NULL)
{
if (SearchTreeAndAddNoNode(currentNode->m_pYesBranch, existingNodeID, newNodeID, newQorA, newNodeValue))
{
return true;
}
else
{
if (currentNode->m_pNoBranch != NULL)
{
return(SearchTreeAndAddNoNode(currentNode->m_pNoBranch, existingNodeID, newNodeID, newQorA, newNodeValue));
}
else
return false;
}
}
else
return false;
}
}
std::string DecisionTree::QueryBinaryTree(TreeNode* currentNode, std::vector<std::vector<std::string> > inputVector)
{
if (currentNode->m_pYesBranch == NULL)
{
//if both the yes and no branch pointers are NULL
//the tree is at a decision outcome state so output
//the string
if (currentNode->m_pNoBranch == NULL){
//cout << currentNode->m_strQuestOrAns << endl;
std::string a = currentNode->m_strQuestOrAns;
return a;
}
else{//useless if the tree I built is right
std::cout << "Missing yes branch at " + currentNode->m_strQuestOrAns + " question\n";
return "0";
}
}
if (currentNode->m_pNoBranch == NULL)
{
std::cout << "Missing no branch at " + currentNode->m_strQuestOrAns + " question\n";
return "0";
}
//otherwise default to asking the question at the currentNode
std::string a;
a = AskQuestion(currentNode, inputVector);
return a;
}
std::string DecisionTree::Query(std::vector<std::vector<std::string> > inputVector)
{
std::string result = QueryBinaryTree(m_pRootNode, inputVector);
return result;
}
std::string DecisionTree::AskQuestion(TreeNode *node, std::vector<std::vector<std::string> > inputVector)
{
//cout << node->m_strQuestOrAns + " (enter yes or no)\n";
double answer;
answer = findPosReturnValue(inputVector, (node->m_iNodeID));
//string b = "3";
//cout << inputVector[1][4];
//cout << findPosReturnValue(inputVector, b);
if (answer == 0){
std::string a = "No Value";
return a;
}
else {
if (answer < (node->m_NodeValue)){
std::string a = QueryBinaryTree(node->m_pYesBranch, inputVector);
return a;
}
else if (answer >= (node->m_NodeValue)){
std::string a = QueryBinaryTree(node->m_pNoBranch, inputVector);
return a;
}
//else//看起来好像没用了现在
//{
// std::cout << "Error please answer yes or no\n";
// AskQuestion(node, inputVector);
//}
}
}
//not use now
void DecisionTree::Output()
{
OutputBinaryTree("1", m_pRootNode);
}
//not use now
void DecisionTree::OutputBinaryTree(const std::string & tag, TreeNode* currentNode)
{
if (currentNode == NULL)
return;
//cout << "[" + tag + "] node id = ";
//cout << currentNode->m_iNodeID;
//cout << ", question/answer = ";
//cout << currentNode->m_strQuestOrAns;
//cout << endl;
// Go down yes branch
OutputBinaryTree(tag + ".1", currentNode->m_pYesBranch);
// Go down no branch
OutputBinaryTree(tag + ".2", currentNode->m_pNoBranch);
}
void DecisionTree::RemoveNode(TreeNode *node)
{
if (node != NULL)
{
if (node->m_pYesBranch != NULL)
RemoveNode(node->m_pYesBranch);
if (node->m_pNoBranch != NULL)
RemoveNode(node->m_pNoBranch);
//cout << "deleting node " << node->m_iNodeID << endl;
delete node;
node = NULL;
}
}
double DecisionTree::findPosReturnValue(std::vector<std::vector<std::string> > inputVector, const std::string & a){
for (int i = 0; i <= (inputVector[0].size()-1); i++){
if (inputVector[0][i] == a){
if (inputVector[1][i] == "A_A") return 1;
else if (inputVector[1][i] == "A_B") return 2;
else if (inputVector[1][i] == "B_B") return 3;
else if (inputVector[1][i] == "A_C") return 2;
else if (inputVector[1][i] == "A_G") return 3;
else if (inputVector[1][i] == "A_T") return 4;
else if (inputVector[1][i] == "C_A") return 2;
else if (inputVector[1][i] == "C_C") return 5;
else if (inputVector[1][i] == "C_G") return 6;
else if (inputVector[1][i] == "C_T") return 7;
else if (inputVector[1][i] == "G_A") return 3;
else if (inputVector[1][i] == "G_C") return 6;
else if (inputVector[1][i] == "G_G") return 8;
else if (inputVector[1][i] == "G_T") return 9;
else if (inputVector[1][i] == "T_A") return 4;
else if (inputVector[1][i] == "T_C") return 7;
else if (inputVector[1][i] == "T_G") return 9;
else if (inputVector[1][i] == "T_T") return 10;
else return 0;
}
}
return 0;
}
/* test vector
std::vector<vector<int> > newVector(){
std::vector<vector<int> > myvector;
myvector.resize(2);
for(int i=1;i<=10;i++) myvector[0].push_back(i);
for(int j=3;j<=12;j++) myvector[0].push_back(j);
return myvector;
}*/
/*
int findPosReturnValue(std::vector<vector<string> > inputVector, string a){
for(int i=0; i<=(inputVector[0].size()); i++){
if(inputVector[0][i] == a){
if(inputVector[1][i] == "AA") return 111;
else if(inputVector[1][i] == "Aa") return 222;
else if(inputVector[1][i] == "aa") return 333;
}
}
//return 20;
}
*/
template <class Type>
Type stringToNum(const std::string & str)
{
std::istringstream iss(str);
Type num;
iss >> num;
return num;
}
bool inTheTreeOrNot(std::vector<std::string> treevector, const std::string & a){
for (int i = 0; i <= (treevector.size() - 1); i++){
if (treevector[i] == a){
return true;
}
}
return false;
}
//string readCSVFile( const char * fileName){
std::vector<std::vector<std::string> > readCSVFile(const char * fileName){
std::vector<std::vector<std::string> > myvectorinitial;
myvectorinitial.resize(2);
std::vector<std::vector<std::string> > myvector;
myvector.resize(2);
std::ifstream file;
std::stringstream ss;
std::string str;
file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try {
file.open(fileName);
ss << file.rdbuf();
str = ss.str();
file.close();
}
catch (std::ifstream::failure e) {
std::cerr << "Exception opening file\n" << e.what() << std::endl;
exit(1);
}
//std::cout << str;
std::string delimiter = ",";
std::string linebreak = "\n";
std::string line1;
std::string line2;
std::string lineID;
std::string lineInfo;
/*
size_t breakPos = str.find(linebreak);
lineID = str.substr(0, breakPos);
lineInfo = str.erase(0, breakPos + linebreak.length());
std::cout << (breakPos == std::string::npos) << endl;
cout << breakPos << endl;
cout << std::string::npos << endl;
cout << str;
str.erase(0, breakPos + linebreak.length());
cout << str;
breakPos = str.find(linebreak);
cout << breakPos << endl;
cout << std::string::npos << endl;
return lineID;
*/
size_t breakPos = str.find(linebreak);
line1 = str.substr(0, breakPos + linebreak.length());
str = str.erase(0, breakPos + linebreak.length());
breakPos = str.find(linebreak);
line2 = str.substr(0, breakPos + linebreak.length());
//Euro 15 trees
//std::string treedata = "rs3131972,rs3748592,rs13303010,rs9697457,rs35940137,rs2710875,rs9442380,rs10907175,rs11721,rs35134975,rs873927,rs28456011,rs752965,rs6663158,rs1878752,rs4648843,rs11590198,rs4648451,rs16824089,rs12756705,rs12411035,rs4654598,rs11591221,rs7537345,rs10915671,rs2649071,rs12061902,rs12084067,rs7540503,rs4243830,rs12754538,rs11121374,rs4129341,rs2924863,rs16853148,rs1737352,rs11582182,rs1192579,rs2744705,rs9426362,rs6425820,rs2492301,rs2788031,rs17123422,rs1772618,rs11208566,rs9729825,rs17099679,rs1333717,rs41453452,rs10494252,rs1027423,rs164151,rs2015330,rs16865298,rs1496092,rs1772145,rs17048875,rs3890758,rs2671264,rs7419176,rs4853793,rs4952541,rs13396777,rs12466764,rs11694681,rs1031466,rs3791298,rs1942055,rs7599054,rs6430545,rs1446523,rs1530559,rs4954218,rs7570971,rs12988076,rs6719488,rs4988235,rs309180,rs218174,rs309160,rs309164,rs12615624,rs687670,rs309134,rs309137,rs4954557,rs11693502,rs749873,rs932206,rs4954573,rs7568884,rs11692725,rs10204606,rs11687599,rs10803574,rs2890917,rs13005337,rs1485973,rs1453406,rs10172873,rs12053389,rs17255817,rs3828267,rs4666782,rs13431857,rs1016569,rs16827500,rs10510366,rs1126098,rs615861,rs4292253,rs3773540,rs17404744,rs16849564,rs1356359,rs17786823,rs35936034,rs17018796,rs17040162,rs17040164,rs6846249,rs13143297,rs1565469,rs13150320,rs6552970,rs154160,rs17602783,rs12109110,rs12654448,rs1419644,rs439812,rs1318631,rs2395634,rs6904956,rs7740421,rs10245230,rs12690925,rs10096219,rs10113325,rs10888101,rs1481742,rs1401817,rs6998565,rs272613,rs1355640,rs2418249,rs4880987,rs11252318,rs12259741,rs1249402,rs11008809,rs760336,rs7911308,rs11602585,rs2595448,rs7395373,rs659944,rs721346,rs2283293,rs11831618,rs1871549,rs265638,rs7966178,rs7981968,rs540497,rs17091427,rs9788522,rs7168653,rs1002007,rs12905660,rs16973728,rs299955,rs4799085,rs6052070,rs6029050,rs16980843,rs233253,rs461436,rs5754554,\n";
//NorthAmerican 12 trees
//std::string treedata = "rs3131972,rs2905036,rs4245756,rs4970383,rs4475691,rs13302982,rs4040604,rs3748592,rs3748593,rs28570376,rs6696281,rs35940137,rs9331225,rs9803031,rs6667248,rs4314833,rs9729550,rs11466691,rs6603781,rs6685064,rs3737721,rs3737718,rs2274264,rs12142199,rs3855955,rs17160669,rs35242196,rs1240708,rs873927,rs35958305,rs7290,rs3766178,rs3128342,rs1926883,rs7407,rs2281173,rs2235536,rs2254669,rs4648808,rs425277,rs9442619,rs2292857,rs262680,rs10910034,rs2643885,rs2055204,rs2840530,rs4310388,rs10752748,rs2606411,rs6681741,rs2817185,rs1798246,rs2651927,rs2651912,rs2500283,rs12043519,rs2483275,rs2244013,rs6669870,rs2298225,rs12039666,rs10492944,rs7541544,rs351619,rs17348860,rs3947662,rs367673,rs13376100,rs9329417,rs973978,rs6577401,rs7517585,rs11120943,rs17031150,rs9919220,rs679563,rs11582339,rs3860318,rs11121722,rs1881559,rs1569635,rs9442235,rs638425,rs41388954,rs10737480,rs10917234,rs12410046,rs12075715,rs3767908,rs1335762,rs2183746,rs12097368,rs1498111,rs522821,rs3795501,rs274751,rs11264025,rs1861,rs11211329,rs12028663,rs12038297,rs7552342,rs3737829,rs2793661,rs10889634,rs12059795,rs12411125,rs6694203,rs11204853,rs16841094,rs2814778,rs7552141,rs4644548,rs6663420,rs1246828,rs488612,rs2802774,rs12568035,rs11119881,rs1439464,rs17742354,rs6541124,rs16846854,rs12467317,rs672463,rs4669937,rs1524007,rs10165208,rs7588439,rs1396795,rs1396797,rs6732285,rs4851370,rs2123694,rs13397666,rs260698,rs7582192,rs164736,rs2059696,rs10173594,rs6717424,rs1858104,rs6731591,rs4668272,rs1865164,rs17027638,rs5004864,rs6445254,rs2083838,rs11707443,rs1374821,rs4678073,rs6439472,rs6804194,rs16870076,rs210780,rs12108234,rs10008032,rs5743567,rs4833103,rs4624679,rs17007466,rs10025344,rs11748410,rs609096,rs2303170,rs35389,rs35391,rs28117,rs35411,rs1363845,rs331728,rs2270068,rs3776337,rs3776334,rs3776329,rs4958560,rs6932667,rs2051548,rs2691483,rs9442996,rs7759248,rs1016101,rs1338839,rs4870227,rs17084501,rs11965097,rs7782345,rs1465221,rs10245220,rs2904664,rs310373,rs1384182,rs4871389,rs10969597,rs10961635,rs7860104,rs10962599,rs2891125,rs12685829,rs715846,rs1888913,rs2377982,rs10749549,rs3814226,rs11192637,rs11198214,rs3213221,rs10835271,rs12294859,rs4930431,rs7134749,rs2519,rs12423495,rs10777469,rs1007916,rs16941717,rs692902,rs2292051,rs13378757,rs11147417,rs17640978,rs12875618,rs9573246,rs9557355,rs17128262,rs7154864,rs8007618,rs12590812,rs926144,rs4906743,rs1800414,rs11636232,rs916977,rs12595731,rs1704348,rs3848147,rs11637114,rs4436808,rs8053650,rs1133238,rs2032915,rs6500380,rs4790359,rs7214357,rs220486,rs8081204,rs9907225,rs4968239,rs9893667,rs9896466,rs8078633,rs911445,rs6053122,rs6038071,rs2039242,rs2829003,rs4819094,rs917408,rs738989,rs17425081,rs12484869,rs1960182,rs5751131,rs5758402,\n";
//African 22 trees
std::string treedata = "rs12124819,rs2905036,rs4245756,rs6694982,rs17160698,rs28499371,rs6696281,rs28391282,rs3128117,rs9697358,rs9331225,rs9803031,rs6667248,rs11807848,rs12757754,rs2298217,rs9660710,rs10907175,rs1815606,rs11466673,rs3813199,rs11260562,rs11260568,rs1739855,rs3737718,rs12142199,rs3845293,rs17160975,rs36044796,rs9782908,rs11807706,rs3128342,rs2377417,rs7520934,rs4648764,rs7531583,rs9970652,rs752965,rs2459994,rs3107145,rs427811,rs9442619,rs1713712,rs10910061,rs12033324,rs903903,rs1123571,rs2494640,rs11581548,rs7512269,rs2477703,rs2477707,rs2147905,rs2234167,rs10910097,rs897620,rs880724,rs2842909,rs2817178,rs1798246,rs10492940,rs2500297,rs12086132,rs6687835,rs1333190,rs870171,rs4648501,rs2493314,rs4648524,rs2821059,rs2794320,rs7514979,rs2298223,rs12079672,rs12090228,rs17404600,rs12093951,rs10915424,rs10915430,rs4130091,rs12071761,rs1353341,rs589870,rs6660514,rs616317,rs242058,rs242050,rs12408533,rs4654607,rs12124406,rs11584727,rs6426370,rs3128689,rs6690311,rs16840287,rs11808981,rs2071958,rs9659669,rs11805412,rs2153900,rs17027039,rs4845820,rs12122894,rs9434795,rs2693958,rs17376559,rs11121090,rs11584036,rs6684149,rs935073,rs2982364,rs10864504,rs7534387,rs6419478,rs11807931,rs816060,rs12405691,rs17038427,rs10754901,rs16853407,rs3817958,rs12409852,rs6691985,rs619345,rs1031567,rs542634,rs525448,rs881247,rs11573205,rs10916790,rs8064,rs3795845,rs641347,rs12067378,rs12040683,rs3935892,rs10799032,rs28495286,rs16824722,rs967094,rs6671001,rs2057969,rs10890311,rs1258010,rs2758735,rs17104047,rs212989,rs6668399,rs7515087,rs4926853,rs7536376,rs542727,rs11808336,rs552006,rs12025026,rs6657290,rs6700924,rs316671,rs615739,rs12097782,rs925192,rs4847372,rs2064662,rs12074249,rs12039907,rs3017627,rs11102559,rs6665912,rs4845735,rs6427184,rs11265070,rs2808651,rs485618,rs12135523,rs12136407,rs16853992,rs1417592,rs9650996,rs7534913,rs7536226,rs12758773,rs3789052,rs12058761,rs3795521,rs6659655,rs10864120,rs1776037,rs7538397,rs12141832,rs6682184,rs6685066,rs12463789,rs1389583,rs771307,rs10204491,rs16866638,rs13414905,rs16862376,rs6734731,rs7590763,rs10198116,rs41513050,rs1067344,rs9789429,rs12478385,rs7596776,rs1534110,rs7600669,rs6731365,rs11125815,rs17030159,rs6547187,rs2309582,rs4851391,rs13389290,rs17030353,rs2034357,rs12620050,rs404499,rs17044602,rs4142753,rs17007536,rs2082331,rs7589010,rs12614459,rs1446750,rs842361,rs16855615,rs4954207,rs6742013,rs7605229,rs1042712,rs309172,rs309161,rs7573555,rs309143,rs6430594,rs309154,rs10205050,rs6755409,rs13403738,rs6759948,rs4894197,rs2562831,rs1427150,rs6734110,rs1607345,rs16849099,rs10932521,rs1443670,rs6436964,rs11688448,rs1995209,rs13087319,rs12630974,rs17729838,rs6785796,rs11718932,rs422584,rs385521,rs9851767,rs6807580,rs12487340,rs11711134,rs3749388,rs1995236,rs6446241,rs4928007,rs4683973,rs2325037,rs16838604,rs349558,rs7649861,rs6770324,rs1546260,rs10513545,rs6778401,rs16848617,rs6779590,rs13081915,rs10428090,rs16855847,rs1039027,rs9290610,rs6800015,rs1374808,rs10937252,rs16862821,rs9290877,rs2378559,rs2185886,rs1000647,rs968365,rs6854453,rs7686272,rs13137543,rs7674434,rs11544855,rs1901747,rs7669018,rs17089059,rs10028900,rs10022017,rs11735775,rs6854417,rs388401,rs6848616,rs12502827,rs4235448,rs4699030,rs17042596,rs17532826,rs17048953,rs6854489,rs345981,rs544870,rs1459157,rs10461322,rs11943281,rs316598,rs1393117,rs2658083,rs852619,rs7730689,rs2388044,rs17595719,rs16901558,rs6882064,rs2913276,rs17301591,rs4513668,rs7700264,rs6595775,rs2624459,rs7446054,rs2227282,rs2237059,rs803137,rs17646556,rs17171218,rs7728894,rs309331,rs17108678,rs17450822,rs7739132,rs2753922,rs6456890,rs1233320,rs2535340,rs1793891,rs12191877,rs367645,rs12191891,rs6932992,rs11963526,rs12204275,rs7741503,rs9486141,rs4245542,rs12191383,rs1204826,rs4946158,rs9400909,rs7753502,rs10872503,rs9376452,rs11155161,rs16900601,rs12701555,rs699486,rs1409968,rs10237182,rs17144015,rs4732511,rs11980955,rs6466823,rs6967965,rs11975980,rs7783639,rs6944302,rs1404315,rs10487094,rs10487999,rs17139871,rs1523794,rs11769723,rs4987672,rs13236792,rs1364519,rs4909055,rs532885,rs4841471,rs1356946,rs748596,rs1077052,rs7010861,rs6558059,rs7017705,rs17786140,rs1404756,rs218892,rs3039743,rs7010482,rs34065840,rs2272634,rs6477310,rs10429529,rs2025319,rs10971164,rs17210010,rs10867230,rs4878051,rs4242609,rs10992623,rs10818338,rs12005198,rs10819101,rs11564096,rs7039873,rs7390989,rs11257434,rs2815617,rs950220,rs1416801,rs9988744,rs10828213,rs824602,rs2839657,rs2370791,rs1935648,rs9421731,rs9415758,rs10825916,rs1536084,rs2182160,rs7923866,rs2476949,rs714816,rs2672609,rs11018181,rs10764918,rs7914354,rs10832430,rs10836370,rs7946936,rs11828501,rs11823218,rs8191431,rs12276848,rs11603486,rs10895512,rs6591090,rs1942518,rs542650,rs10501858,rs4366501,rs7316060,rs16910077,rs10492377,rs1601745,rs10785426,rs4344559,rs11836193,rs12305915,rs10748260,rs7295341,rs10847881,rs11060955,rs9575364,rs2951787,rs12561320,rs9597104,rs9583470,rs1407893,rs1956593,rs10140504,rs7155859,rs1051388,rs12897140,rs12885391,rs10137272,rs10498587,rs2373262,rs10873649,rs1679012,rs10454039,rs199138,rs1834640,rs7169337,rs7177754,rs1037041,rs8035628,rs8027920,rs8028686,rs8041403,rs4887382,rs9788651,rs8042942,rs2191430,rs4787040,rs2287198,rs1420676,rs1982394,rs7206635,rs16972211,rs8052388,rs8051251,rs17796342,rs7185017,rs17741623,rs11654128,rs2240099,rs34052864,rs8075137,rs8892,rs1241988,rs9953932,rs28464695,rs2230233,rs16949551,rs4605270,rs9958746,rs3106146,rs6422427,rs1725501,rs123187,rs11084467,rs4815694,rs3790221,rs6119337,rs6067491,rs6099216,rs2180698,rs354742,rs218336,rs11702338,rs3761364,rs965494,rs9975332,rs2839509,rs875060,rs417252,rs2023637,rs4819836,rs2270013,rs2040435,rs2267270,rs7284910,rs5999984,rs9619574,rs2227914,rs6007462,rs5770567,\n";
//Kenyan 31 trees
//std::string treedata = "rs3131972,rs7537756,rs6694982,rs1110052,rs17160698,rs13303106,rs13303010,rs3935066,rs6696281,rs28504611,rs13303118,rs2341362,rs9697358,rs6667248,rs3766191,rs11260595,rs2298217,rs1320565,rs4314833,rs3813199,rs11260568,rs6685064,rs3737721,rs2274264,rs9782908,rs11552172,rs28635343,rs28707307,rs4648764,rs12069909,rs12742323,rs16824500,rs28625223,rs2803310,rs262656,rs2503701,rs7553178,rs4648819,rs12404555,rs1998759,rs10910099,rs12117343,rs12752801,rs6681741,rs2376821,rs2651906,rs3002685,rs6673393,rs11808276,rs947347,rs4431782,rs2181484,rs7523732,rs1175549,rs12031557,rs10915360,rs10753376,rs16838922,rs349400,rs3820250,rs392630,rs11799924,rs6671889,rs648378,rs12095221,rs7554078,rs11805516,rs4908925,rs11120876,rs12119558,rs6676442,rs2493214,rs67746,rs12022654,rs2744677,rs6429800,rs495937,rs7548984,rs16851168,rs9943244,rs7539166,rs4661748,rs1925704,rs4912106,rs897469,rs2776822,rs672138,rs4631721,rs17263039,rs7523842,rs477882,rs10890041,rs11210640,rs12145658,rs12085768,rs6697095,rs7527194,rs11208579,rs6424639,rs7415927,rs17369470,rs11583332,rs11166028,rs12064015,rs1772890,rs1844959,rs1597178,rs3125677,rs12059640,rs10908849,rs8177963,rs12739022,rs12069196,rs12135523,rs11586404,rs12722820,rs2284767,rs16863858,rs9660718,rs6424976,rs4651330,rs2488479,rs6428392,rs1125954,rs2359377,rs875044,rs12239056,rs1891231,rs445633,rs4658560,rs6677662,rs2551320,rs11884415,rs1534110,rs12994558,rs2061517,rs6731365,rs1005608,rs11125815,rs17030159,rs4233931,rs6760326,rs2861641,rs9309464,rs2190355,rs17754897,rs1595422,rs1545223,rs2241883,rs17048353,rs17044602,rs17047458,rs2315523,rs6735149,rs7586145,rs16855615,rs6742013,rs7605229,rs3806502,rs1050115,rs6724569,rs2015532,rs3769012,rs7581814,rs12472293,rs309172,rs7573555,rs309143,rs6430594,rs309154,rs10497029,rs4972277,rs6737636,rs7565410,rs6736379,rs6730036,rs1440463,rs5001924,rs985365,rs13404079,rs7561423,rs17202778,rs4142221,rs4674632,rs2058061,rs9832923,rs13319626,rs17298420,rs11916051,rs17226259,rs6794557,rs201729,rs936663,rs11915247,rs9874060,rs7653308,rs4269034,rs3935821,rs10001947,rs5743612,rs992133,rs17082523,rs9992661,rs17028457,rs12645079,rs1567049,rs13142580,rs1379602,rs316598,rs2188301,rs770308,rs9292857,rs2028723,rs10520997,rs16870510,rs6880683,rs10072084,rs973332,rs10474381,rs12188101,rs7710375,rs6862681,rs10075371,rs1366457,rs2227282,rs2237059,rs30534,rs17286578,rs312557,rs10075720,rs6556382,rs13162048,rs6458997,rs683966,rs6927023,rs364950,rs404557,rs9470872,rs7770679,rs11759220,rs1206088,rs12204275,rs6938518,rs7741503,rs7760662,rs9485572,rs7745739,rs17055737,rs4721216,rs699486,rs595541,rs6968676,rs2054788,rs6975220,rs1005032,rs1990796,rs10242455,rs4646457,rs776746,rs2740566,rs800672,rs6963345,rs4725499,rs17685410,rs4875671,rs2515542,rs532885,rs11203815,rs2237835,rs16937924,rs28399555,rs16886536,rs12541188,rs17775439,rs2720710,rs2944776,rs2721202,rs869939,rs16934647,rs10965215,rs7874475,rs1411088,rs13288508,rs4310281,rs1330684,rs4750058,rs17095806,rs7094900,rs7358097,rs1347957,rs11190458,rs809825,rs6584646,rs790660,rs2067022,rs704737,rs11547493,rs1792959,rs10792608,rs1399357,rs10897976,rs16923264,rs16905958,rs3103736,rs7136627,rs11176729,rs11842930,rs9576822,rs9516890,rs11618950,rs1956593,rs2415306,rs6572913,rs10137272,rs12885270,rs2373262,rs2430341,rs8027732,rs12438284,rs9745005,rs4402506,rs7168199,rs17241648,rs8057684,rs12601516,rs7216396,rs12943500,rs35487582,rs8070885,rs17823777,rs11660396,rs9953932,rs9948548,rs17086113,rs350130,rs2423334,rs1206810,rs6096853,rs6015825,rs8140370,rs5770567,\n";
//East Asian 47 trees
//std::string treedata = "rs12124819,rs7537756,rs4040604,rs7523549,rs3935066,rs6694632,rs6665000,rs2465126,rs2465136,rs13129,rs7526076,rs9442372,rs3737728,rs2298217,rs4970421,rs11260542,rs9442387,rs12092254,rs1320565,rs9729550,rs11466691,rs6603781,rs6662635,rs1749951,rs17854636,rs182532,rs2765015,rs2291889,rs11488462,rs1571149,rs1887284,rs1926883,rs28414855,rs4648782,rs12748433,rs6699975,rs4074197,rs760925,rs1107910,rs7534617,rs9970652,rs12403351,rs28710181,rs4648745,rs10910029,rs10752741,rs4648805,rs4648807,rs16824860,rs12034613,rs7512482,rs16824948,rs2645072,rs2840531,rs10910061,rs1123571,rs4233033,rs1998759,rs11573979,rs11573970,rs10909872,rs1869972,rs2606414,rs16823350,rs6695131,rs926244,rs2651902,rs2651929,rs10797386,rs17398063,rs2455107,rs4648468,rs12073172,rs12119711,rs3765764,rs10910017,rs1885865,rs2275819,rs2298225,rs4131373,rs34835780,rs4654522,rs12023372,rs16840755,rs608210,rs10799255,rs16839450,rs4654468,rs1841241,rs10915307,rs2199215,rs2611423,rs10915396,rs7512133,rs12080410,rs12036857,rs770698,rs17028725,rs6698924,rs6577582,rs11120837,rs6656160,rs11120989,rs707457,rs178932,rs428180,rs12738365,rs17389948,rs7530465,rs284243,rs710139,rs12085319,rs17036706,rs2379143,rs11804222,rs12755560,rs10927559,rs164868,rs16850259,rs6685406,rs4920386,rs620950,rs1317209,rs3820330,rs11585587,rs904927,rs2119320,rs7540486,rs3893319,rs12090967,rs4654354,rs10914477,rs12136921,rs4652992,rs3768337,rs2660563,rs2209477,rs11538784,rs11580074,rs6671527,rs11211612,rs4131141,rs6694834,rs1288503,rs797913,rs4926684,rs2092595,rs2272052,rs686543,rs12561942,rs12063386,rs12760071,rs10493770,rs4101233,rs10159030,rs914958,rs7547028,rs662009,rs1074739,rs10494055,rs4244129,rs7542677,rs662353,rs17033865,rs4656248,rs2295615,rs2275603,rs4298709,rs17358956,rs863454,rs10913136,rs873525,rs7544659,rs12027396,rs6668819,rs6605005,rs16843306,rs2794860,rs11586974,rs10863308,rs2000319,rs1222144,rs2273939,rs487113,rs17140182,rs4846908,rs17599139,rs615625,rs12740262,rs7520258,rs10924366,rs4455137,rs953599,rs9287778,rs342136,rs7563543,rs17018699,rs6732743,rs12615002,rs919688,rs10460504,rs17737466,rs1914778,rs1421617,rs13414393,rs10865278,rs41385746,rs11126130,rs13432159,rs41374247,rs3771848,rs1517782,rs12467106,rs12104625,rs1845017,rs11127018,rs4580387,rs1376444,rs10168169,rs13014047,rs333859,rs333851,rs333846,rs4662834,rs6737431,rs12104489,rs4646329,rs10803583,rs10496977,rs374722,rs4662280,rs7587849,rs10176837,rs4530328,rs11677624,rs16826345,rs6717406,rs6732937,rs41471147,rs10932401,rs17325821,rs10933005,rs6436971,rs11563201,rs13387193,rs13392175,rs13030338,rs2320378,rs717187,rs1369407,rs1687331,rs4525889,rs1349283,rs13085028,rs7640543,rs17029445,rs34136796,rs13084153,rs11707193,rs13322517,rs7642488,rs1011609,rs6779452,rs12490963,rs16827628,rs1355781,rs13064974,rs931250,rs7626152,rs7644875,rs360710,rs191708,rs1511412,rs2348394,rs7640145,rs2133620,rs4680238,rs603638,rs3930233,rs1868150,rs751396,rs2713721,rs16864358,rs10804925,rs3889723,rs10517011,rs4371605,rs6833864,rs7658552,rs2173201,rs243996,rs4490524,rs6844821,rs2390135,rs1498016,rs10017946,rs1113111,rs17033938,rs10013441,rs17040351,rs412763,rs7687912,rs11132199,rs828316,rs6420051,rs31300,rs12697189,rs12658762,rs17783275,rs702552,rs10060821,rs379717,rs27433,rs13160949,rs10073882,rs7705687,rs7378826,rs17286171,rs17207681,rs17385747,rs2961739,rs6860288,rs6879391,rs17069519,rs11959012,rs1960425,rs4298263,rs315808,rs6886932,rs17676033,rs3756531,rs17075791,rs2036564,rs9504229,rs9328202,rs9328204,rs17137253,rs7760235,rs9502295,rs2432785,rs2503823,rs9379827,rs6940237,rs3757181,rs16895223,rs2860580,rs2975042,rs3130244,rs3749946,rs2261033,rs9277027,rs2567274,rs3117002,rs3130235,rs3130237,rs3116996,rs6901221,rs6901830,rs2499714,rs1398572,rs689391,rs4707130,rs485276,rs313243,rs1407448,rs6926826,rs6927568,rs10046248,rs13203813,rs3777997,rs211605,rs478611,rs9497981,rs9497982,rs17633478,rs742636,rs7767039,rs946236,rs372440,rs10244477,rs4637726,rs11770368,rs11974206,rs6971267,rs1035582,rs12532805,rs17680606,rs12534948,rs4617036,rs10240570,rs319870,rs2237551,rs953184,rs10500071,rs12532116,rs10954494,rs12698186,rs1670357,rs1900102,rs17150469,rs4840510,rs17120485,rs7016943,rs1351499,rs7832879,rs13251780,rs2439292,rs1994851,rs6472787,rs1869609,rs2513850,rs2622637,rs7461808,rs871952,rs12547611,rs2976392,rs2920297,rs2382019,rs1780160,rs4571809,rs1017783,rs12006467,rs10512019,rs12551119,rs1999462,rs3824405,rs6560612,rs7859023,rs4255200,rs2418268,rs2418269,rs1490742,rs3739477,rs10858363,rs17135476,rs11251966,rs2388746,rs17151786,rs7921121,rs12765118,rs11254106,rs10904962,rs11013746,rs3762084,rs1148214,rs2663018,rs2663027,rs1317894,rs4935397,rs4935640,rs17471932,rs12250707,rs12266901,rs16933163,rs7918954,rs1250544,rs12254574,rs2000177,rs1891275,rs12219674,rs12412736,rs10765099,rs11016442,rs8181588,rs2682107,rs443592,rs3741026,rs7944342,rs2268063,rs649640,rs10836933,rs12788223,rs11034713,rs7938730,rs1369323,rs7122010,rs1817653,rs4755957,rs4939526,rs7935178,rs640655,rs642490,rs11236209,rs4753962,rs770576,rs11224762,rs11224765,rs7928922,rs10895109,rs10444351,rs11224773,rs7935581,rs11224783,rs4141989,rs2046685,rs1791466,rs321125,rs1877351,rs2298464,rs4937070,rs4937384,rs12295314,rs2105606,rs11223548,rs10849181,rs3217805,rs3809250,rs10843585,rs1874799,rs2277317,rs6581191,rs1275569,rs11104775,rs1508594,rs11104947,rs11611632,rs353887,rs701100,rs7995074,rs9603756,rs9549215,rs1535682,rs4942308,rs9562578,rs566105,rs1504418,rs9530164,rs9543281,rs9530168,rs6562748,rs11841589,rs9600325,rs7985210,rs982790,rs2209831,rs16947802,rs9518309,rs582322,rs10508158,rs16968045,rs9559436,rs1184774,rs17764769,rs946617,rs17093760,rs217656,rs10134028,rs4904385,rs174519,rs174511,rs174510,rs174504,rs1288742,rs17799178,rs3742672,rs8016966,rs1955614,rs2275595,rs2958272,rs17649182,rs1567074,rs16961283,rs8041381,rs12922641,rs7203853,rs9930735,rs4785322,rs6564809,rs41526051,rs8050818,rs7213911,rs9901316,rs3785624,rs7219975,rs3815073,rs16957364,rs17821703,rs17221329,rs4969058,rs7503887,rs10853282,rs3088182,rs17561133,rs16978159,rs7244157,rs7235487,rs8093745,rs10408164,rs4416143,rs667907,rs202481,rs12480230,rs2224609,rs2423402,rs2072978,rs6030932,rs6018084,rs13042833,rs375980,rs1569307,rs2838699,rs1883472,rs11913594,rs8135343,rs11703828,rs133503,\n";
//Hapmap 2
//std::string treedata = "rs987435,rs8091955,rs2040704,rs7921545,rs7677859,rs2324520,rs4242682,rs1450428,rs7215008,rs7974633,rs10187056,rs1588040,rs1932366,rs2204738,rs4847428,rs1909338,rs7676617,rs7158108,rs2578669,rs10758940,rs6679430,rs4835141,rs1099968,rs2214965,rs2506898,rs16953500,rs12511245,rs12921822,rs2035247,rs1679012,rs1726254,rs12681671,rs560767,rs17671597,rs2490385,rs1814538,rs12204275,rs7111521,rs7551132,rs3181372,rs2849372,rs2967391,rs2029623,rs519381,rs2463383,rs11563620,rs6035761,rs27162+F786,rs12446781,rs11098948,rs2546001,rs1854935,rs158512,rs2422098,rs277639,rs6698919,rs4791868,rs9866028,rs9595066,rs1484213,rs4705115,rs4877791,rs9821525,rs2673884,rs9931378,rs6926482,rs2631899,rs4789182,rs1437724,rs6546753,rs1942885,rs11130791,rs4713659,rs10998087,rs1437787,rs13086858,rs864386,rs12120383,rs4615248,rs11170991,rs11903376,rs35389,rs6763648,rs931410,rs12641411,rs590616,rs2605419,rs11649653,rs1320385,rs2433354,rs1117382,rs868622,rs7376483,rs2893312,rs4577845,rs735480,rs10814993,rs2000743,rs702032,rs533571,rs2305858,rs1924381,rs10759290,rs10185826,rs2200402,rs39639,rs6897135,rs4787645,rs10851731,rs12542990,rs12036675,rs6451268,rs260699,rs4722760,rs4749305,rs747094,rs12062528,rs542405,rs6468344,rs1986420,rs11085023,rs260700,rs8097206,rs738276,rs260711,rs2700392,rs282162,rs1478446,rs1805972,rs12677218,rs6977118,rs12895262,rs943773,rs4832501,rs6437783,rs7983489,rs6560084,rs12135904,rs7923368,rs1250253,rs738987,rs7689609,rs2228511,rs11691947,rs7956796,rs6534999,rs2500090,rs2907599,rs4825,rs1419138,rs2675345,rs260705,rs2002739,rs260709,\n";
//std::cout << line1;
//std::cout << line2;
std::vector<size_t>posvector1;
posvector1.push_back(-1);
std::vector<size_t>posvector2;
posvector2.push_back(-1);
std::vector<std::string> treevector;
std::vector<size_t>postree;
postree.push_back(-1);
std::vector<int>dataposvector;
for (size_t i = 0; i < treedata.length(); ++i)
{
//std::cout << str.at(i);
if (treedata.at(i) == ','){
postree.push_back(i);
}
}
postree.push_back(treedata.find(linebreak) - linebreak.length());
for (int j = 0; j < (postree.size() - 2); j++){
treevector.push_back(treedata.substr(postree[j] + delimiter.length(), postree[j + 1] - postree[j] - 1));
}
for (size_t i = 0; i < line1.length(); ++i)
{
//std::cout << str.at(i);
if (line1.at(i) == ','){
posvector1.push_back(i);
}
}
posvector1.push_back(line1.find(linebreak)-linebreak.length());
for (int j = 0; j < (posvector1.size()-2); j++){
//myvectorinitial[0].push_back(line1.substr(posvector1[j] + delimiter.length(), posvector1[j + 1] - posvector1[j] - 1));
//if (inTheTreeOrNot(treevector, line1.substr(posvector1[j] + delimiter.length(), posvector1[j + 1] - posvector1[j] - 1))){
std::vector<std::string>::iterator it;
it = find (treevector.begin(), treevector.end(), (line1.substr(posvector1[j] + delimiter.length(), posvector1[j + 1] - posvector1[j] - 1)));
if (it != treevector.end()){
dataposvector.push_back(j);
myvector[0].push_back(line1.substr(posvector1[j] + delimiter.length(), posvector1[j + 1] - posvector1[j] - 1));
}
}
for (size_t i = 0; i < line2.length(); ++i)
{
//std::cout << str.at(i);
if (line2.at(i) == ','){
posvector2.push_back(i);
}
}
posvector2.push_back(line2.find(linebreak) - linebreak.length());
for (int j = 0; j < (posvector2.size() - 2); j++){
myvectorinitial[1].push_back(line2.substr(posvector2[j] + delimiter.length(), posvector2[j + 1] - posvector2[j] - 1));
}
for (int k = 0; k <= dataposvector.size() - 1; k++){
//myvector[0].push_back(myvectorinitial[0][dataposvector[k]]);
myvector[1].push_back(myvectorinitial[1][dataposvector[k]]);
}
/*
breakPos = line1.find(linebreak);
//cout << breakPos << endl;
//cout << std::string::npos << endl;
size_t commaPos;
commaPos = line1.find(delimiter);
lineID = line1.substr(0, commaPos);
//cout << lineID << endl;
myvector[0].push_back(lineID);
while (breakPos > 11){
line1 = line1.erase(0, commaPos + delimiter.length());
breakPos = line1.find(linebreak);
//cout << breakPos << endl;
//cout << std::string::npos << endl;
commaPos = line1.find(delimiter);
if (commaPos > 100000)
commaPos = breakPos;
lineID = line1.substr(0, commaPos);
//cout << lineID << endl;
myvector[0].push_back(lineID);
}
breakPos = line2.find(linebreak);
commaPos = line2.find(delimiter);
lineID = line2.substr(0, commaPos);
//cout << lineID << endl;
myvector[1].push_back(lineID);
while (breakPos > 5){
line2 = line2.erase(0, commaPos + delimiter.length());
breakPos = line2.find(linebreak);
//cout << breakPos << endl;
//cout << std::string::npos << endl;
commaPos = line2.find(delimiter);
if (commaPos > 100000)
commaPos = breakPos;
lineID = line2.substr(0, commaPos);
//cout << lineID << endl;
myvector[1].push_back(lineID);
}
*/
return myvector;
}
void calNumReturnResult(std::vector<std::string> result){
int numEUR = 0;
int numCHN = 0;
int numAMR = 0;
int numJPN = 0;
int numNoValue = 0;
for (int i = 0; i <= (result.size() - 1); i++){
if (result[i] == "7"){ numEUR++; }
else if (result[i] == "9"){ numCHN++; }
else if (result[i] == "3"){ numAMR++; }
else if (result[i] == "6"){ numJPN++; }
else if (result[i] == "No Value"){ numNoValue++; }
}
std::cout << "EUR: " << numEUR << std::endl;
std::cout << "CHN: " << numCHN << std::endl;
std::cout << "AMR: " << numAMR << std::endl;
std::cout << "JPN: " << numJPN << std::endl;
std::cout << "NoValue: " << numNoValue << std::endl;
if ((numEUR >= numCHN) && (numEUR >= numAMR) && (numEUR >= numJPN))
std::cout << "This is EUR." << std::endl;
if ((numEUR <= numCHN) && (numCHN >= numAMR) && (numCHN >= numJPN))
std::cout << "This is CHN." << std::endl;
if ((numAMR >= numCHN) && (numEUR <= numAMR) && (numAMR >= numJPN))
std::cout << "This is AMR." << std::endl;
if ((numJPN >= numCHN) && (numJPN >= numAMR) && (numEUR <= numJPN))
std::cout << "This is JPN." << std::endl;
}
int main(int argc, char *argv[]) {
int c;
char * inputFile = NULL;
char * output_file = NULL;
while ((c = getopt (argc, argv, "i:o:")) != -1){
switch (c)
{
case 'i':
// fprintf(stderr,"[%s]-> ",optarg);
if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-'){
fprintf (stderr,
"Found illegal or NULL parameter for the option -i.\n");
return 1;
}
inputFile = optarg;
break;
case 'o':
// fprintf(stderr,"[%s]-> ",optarg);
if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-'){
fprintf (stderr,
"Found illegal or NULL parameter for the option -o.\n");
return 1;
}
output_file = optarg;
break;
case '?':
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
return 1;
}
}
if (inputFile != NULL){
std::cout << inputFile << std::endl;
}
// insert code here...
/*
std::ifstream theFile(inputFile);
int id;
std::string name;
double money;
while (theFile >> id >> name >> money) {
cout << id << ", " << name << ", " << money << endl;
}
std::cout << "Hello, World!\n";*/
//std::vector<vector<int> > my = newVector();
std::vector<std::vector<std::string> > my = readCSVFile(inputFile);
//for(int i=1;i<=5;i++) myvector.push_back(i);
/*
for(std::vector<string>::iterator it = my[0].begin();it != my[0].end();it++){std::cout << " " << *it;}
for(std::vector<string>::iterator it = my[1].begin();it != my[1].end();it++){std::cout << " " << *it;}
std::cout << endl;
cout << my[1][1];
cout << endl;
cout << (my[1][1] == "8");
cout << endl;
cout << my[0].size();
cout << endl;
string b = "4";
//cout << findPosReturnValue(my,b);
cout << endl;
//std::cout << readCSVFile(inputFile);
//std::cout << name;
*/
std::vector<std::string> myresult;
std::string treeWordBreak = ",";
std::string treeLineBreak = "\n";
std::string treeNodeBreak = "_";
//Euro 15 trees (remain 14 trees, delete the 9th)
//std::string treeInfo = "Create_rs7570971_Q_1.5,Yes_rs7570971_rs10494252_Q_3.5,No_rs7570971_rs10096219_Q_8.5,Yes_rs10494252_rs28456011_Q_6,No_rs10494252_rs12754538_Q_8.5,Yes_rs10096219_rs1878752_Q_2,No_rs10096219_rs10172873_Q_2,Yes_rs28456011_x_2_5,No_rs28456011_x_10_5,Yes_rs12754538_rs12756705_Q_8.5,No_rs12754538_x_2_5,Yes_rs1878752_x_10_5,No_rs1878752_x_2_5,Yes_rs10172873_rs13396777_Q_5.5,No_rs10172873_x_10_5,Yes_rs12756705_x_10_5,No_rs12756705_x_2_5,Yes_rs13396777_x_10_5,No_rs13396777_rs12061902_Q_8.5,Yes_rs12061902_x_10_5,No_rs12061902_x_2_5,\nCreate_rs4988235_Q_5.5,Yes_rs4988235_rs10888101_Q_8.5,No_rs4988235_rs272613_Q_2,Yes_rs10888101_x_10_5,No_rs10888101_rs7966178_Q_6,Yes_rs272613_rs16853148_Q_6,No_rs272613_rs13303010_Q_2,Yes_rs7966178_rs721346_Q_8.5,No_rs7966178_x_10_5,Yes_rs16853148_rs16849564_Q_6,No_rs16853148_x_2_5,Yes_rs13303010_x_2_5,No_rs13303010_x_10_5,Yes_rs721346_x_10_5,No_rs721346_rs17404744_Q_8.5,Yes_rs16849564_x_2_5,No_rs16849564_x_10_5,Yes_rs17404744_x_2_5,No_rs17404744_x_10_5,\nCreate_rs932206_Q_6,Yes_rs932206_rs4954218_Q_9.5,No_rs932206_rs2283293_Q_2,Yes_rs4954218_rs9426362_Q_2,No_rs4954218_rs4292253_Q_6,Yes_rs2283293_rs265638_Q_6,No_rs2283293_rs10907175_Q_1.5,Yes_rs9426362_x_2_5,No_rs9426362_x_10_5,Yes_rs4292253_x_2_5,No_rs4292253_rs1355640_Q_5.5,Yes_rs265638_x_10_5,No_rs265638_rs11008809_Q_2,Yes_rs10907175_x_10_5,No_rs10907175_x_2_5,Yes_rs1355640_x_2_5,No_rs1355640_rs11590198_Q_2,Yes_rs11008809_x_10_5,No_rs11008809_rs1485973_Q_2,Yes_rs11590198_x_2_5,No_rs11590198_x_10_5,Yes_rs1485973_rs35134975_Q_5.5,No_rs1485973_x_10_5,Yes_rs35134975_x_10_5,No_rs35134975_x_2_5,\nCreate_rs1942055_Q_5.5,Yes_rs1942055_rs309164_Q_8.5,No_rs1942055_rs6052070_Q_2,Yes_rs309164_rs1027423_Q_7,No_rs309164_rs9788522_Q_3.5,Yes_rs6052070_rs16980843_Q_3.5,No_rs6052070_rs13150320_Q_2,Yes_rs1027423_rs3131972_Q_2,No_rs1027423_rs11692725_Q_2,Yes_rs9788522_x_10_5,No_rs9788522_x_2_5,Yes_rs16980843_x_10_5,No_rs16980843_rs11121374_Q_5.5,Yes_rs13150320_x_2_5,No_rs13150320_x_10_5,Yes_rs3131972_x_10_5,No_rs3131972_x_2_5,Yes_rs11692725_x_2_5,No_rs11692725_rs1453406_Q_6,Yes_rs11121374_x_2_5,No_rs11121374_x_10_5,Yes_rs1453406_x_2_5,No_rs1453406_rs11208566_Q_5.5,Yes_rs11208566_x_2_5,No_rs11208566_x_10_5,\nCreate_rs749873_Q_6,Yes_rs749873_rs1401817_Q_2,No_rs749873_rs6430545_Q_2.5,Yes_rs1401817_rs154160_Q_7,No_rs1401817_x_2_5,Yes_rs6430545_rs12259741_Q_5.5,No_rs6430545_rs540497_Q_6,Yes_rs154160_x_2_5,No_rs154160_rs16973728_Q_8.5,Yes_rs12259741_rs16824089_Q_8.5,No_rs12259741_rs6425820_Q_8.5,Yes_rs540497_rs1126098_Q_5.5,No_rs540497_x_10_5,Yes_rs16973728_x_2_5,No_rs16973728_x_10_5,Yes_rs16824089_x_2_5,No_rs16824089_x_10_5,Yes_rs6425820_x_2_5,No_rs6425820_x_10_5,Yes_rs1126098_rs17602783_Q_2,No_rs1126098_x_10_5,Yes_rs17602783_x_10_5,No_rs17602783_rs13005337_Q_2,Yes_rs13005337_x_10_5,No_rs13005337_x_2_5,\nCreate_rs1530559_Q_5.5,Yes_rs1530559_rs10245230_Q_6,No_rs1530559_rs7911308_Q_3.5,Yes_rs10245230_rs9729825_Q_2,No_rs10245230_rs1419644_Q_2.5,Yes_rs7911308_rs10113325_Q_5.5,No_rs7911308_x_2_5,Yes_rs9729825_rs10915671_Q_5.5,No_rs9729825_rs11721_Q_3.5,Yes_rs1419644_rs6846249_Q_1.5,No_rs1419644_x_10_5,Yes_rs10113325_rs2744705_Q_8.5,No_rs10113325_rs1737352_Q_5.5,Yes_rs10915671_x_10_5,No_rs10915671_x_2_5,Yes_rs11721_x_2_5,No_rs11721_x_10_5,Yes_rs6846249_x_10_5,No_rs6846249_x_2_5,Yes_rs2744705_rs9697457_Q_5.5,No_rs2744705_x_2_5,Yes_rs1737352_x_2_5,No_rs1737352_x_10_5,Yes_rs9697457_x_2_5,No_rs9697457_x_10_5,\nCreate_rs309180_Q_5.5,Yes_rs309180_rs11252318_Q_6,No_rs309180_rs7740421_Q_2,Yes_rs11252318_rs4954557_Q_6,No_rs11252318_rs2595448_Q_6,Yes_rs7740421_rs439812_Q_6,No_rs7740421_x_2_5,Yes_rs4954557_rs1772618_Q_2,No_rs4954557_rs299955_Q_2,Yes_rs2595448_x_10_5,No_rs2595448_rs1016569_Q_8.5,Yes_rs439812_x_2_5,No_rs439812_x_10_5,Yes_rs1772618_x_10_5,No_rs1772618_x_2_5,Yes_rs299955_rs752965_Q_8.5,No_rs299955_x_2_5,Yes_rs1016569_x_10_5,No_rs1016569_rs3773540_Q_5.5,Yes_rs752965_x_10_5,No_rs752965_x_2_5,Yes_rs3773540_x_10_5,No_rs3773540_rs4243830_Q_6,Yes_rs4243830_x_10_5,No_rs4243830_x_2_5,\nCreate_rs218174_Q_5.5,Yes_rs218174_rs687670_Q_8.5,No_rs218174_rs6904956_Q_8.5,Yes_rs687670_rs2890917_Q_2.5,No_rs687670_rs164151_Q_6,Yes_rs6904956_x_2_5,No_rs6904956_rs1318631_Q_2,Yes_rs2890917_rs7395373_Q_8.5,No_rs2890917_rs1356359_Q_5.5,Yes_rs164151_x_10_5,No_rs164151_rs6552970_Q_8.5,Yes_rs1318631_x_2_5,No_rs1318631_x_10_5,Yes_rs7395373_rs873927_Q_5.5,No_rs7395373_rs6663158_Q_5.5,Yes_rs1356359_x_10_5,No_rs1356359_rs11602585_Q_8.5,Yes_rs6552970_rs12411035_Q_5.5,No_rs6552970_x_10_5,Yes_rs873927_x_10_5,No_rs873927_x_2_5,Yes_rs6663158_x_10_5,No_rs6663158_x_2_5,Yes_rs11602585_x_2_5,No_rs11602585_x_10_5,Yes_rs12411035_x_2_5,No_rs12411035_x_10_5,\nCreate_rs309137_Q_6,Yes_rs309137_rs10803574_Q_2,No_rs309137_rs1446523_Q_2,Yes_rs10803574_x_2_5,No_rs10803574_rs3890758_Q_5.5,Yes_rs1446523_rs12690925_Q_8.5,No_rs1446523_rs2418249_Q_6,Yes_rs3890758_rs9442380_Q_8.5,No_rs3890758_x_2_5,Yes_rs12690925_rs4648843_Q_8.5,No_rs12690925_rs1871549_Q_8.5,Yes_rs2418249_rs2924863_Q_9.5,No_rs2418249_rs4880987_Q_8.5,Yes_rs9442380_x_10_5,No_rs9442380_x_2_5,Yes_rs4648843_x_10_5,No_rs4648843_x_2_5,Yes_rs1871549_x_2_5,No_rs1871549_x_10_5,Yes_rs2924863_x_10_5,No_rs2924863_rs13431857_Q_6,Yes_rs4880987_x_10_5,No_rs4880987_x_2_5,Yes_rs13431857_x_10_5,No_rs13431857_rs11582182_Q_7,Yes_rs11582182_x_10_5,No_rs11582182_x_2_5,\nCreate_rs12615624_Q_2,Yes_rs12615624_rs17040162_Q_8.5,No_rs12615624_rs35936034_Q_6,Yes_rs17040162_x_10_5,No_rs17040162_rs10510366_Q_2,Yes_rs35936034_rs2492301_Q_8.5,No_rs35936034_rs12466764_Q_7,Yes_rs10510366_x_10_5,No_rs10510366_rs17255817_Q_5.5,Yes_rs2492301_rs12654448_Q_6,No_rs2492301_rs11694681_Q_5.5,Yes_rs12466764_rs3748592_Q_5.5,No_rs12466764_rs1772145_Q_8.5,Yes_rs17255817_x_2_5,No_rs17255817_x_10_5,Yes_rs12654448_rs1002007_Q_2,No_rs12654448_x_2_5,Yes_rs11694681_x_10_5,No_rs11694681_x_2_5,Yes_rs3748592_x_2_5,No_rs3748592_x_10_5,Yes_rs1772145_x_10_5,No_rs1772145_x_2_5,Yes_rs1002007_x_2_5,No_rs1002007_x_10_5,\nCreate_rs309134_Q_5.5,Yes_rs309134_rs3791298_Q_8.5,No_rs309134_rs17040164_Q_6,Yes_rs3791298_rs17018796_Q_7,No_rs3791298_rs16827500_Q_3.5,Yes_rs17040164_rs4853793_Q_8.5,No_rs17040164_x_10_5,Yes_rs17018796_x_10_5,No_rs17018796_rs7419176_Q_8.5,Yes_rs16827500_rs1565469_Q_8.5,No_rs16827500_rs2671264_Q_9.5,Yes_rs4853793_rs1249402_Q_7,No_rs4853793_x_10_5,Yes_rs7419176_x_10_5,No_rs7419176_x_2_5,Yes_rs1565469_x_2_5,No_rs1565469_x_10_5,Yes_rs2671264_x_2_5,No_rs2671264_rs12109110_Q_2.5,Yes_rs1249402_x_10_5,No_rs1249402_x_2_5,Yes_rs12109110_x_2_5,No_rs12109110_rs12084067_Q_6,Yes_rs12084067_x_10_5,No_rs12084067_x_2_5,\nCreate_rs11693502_Q_6,Yes_rs11693502_rs7168653_Q_6,No_rs11693502_rs7599054_Q_5.5,Yes_rs7168653_rs11831618_Q_1.5,No_rs7168653_rs2015330_Q_2.5,Yes_rs7599054_rs6029050_Q_6,No_rs7599054_rs1481742_Q_8.5,Yes_rs11831618_x_10_5,No_rs11831618_x_2_5,Yes_rs2015330_x_10_5,No_rs2015330_x_2_5,Yes_rs6029050_rs17048875_Q_3.5,No_rs6029050_x_10_5,Yes_rs1481742_rs35940137_Q_5.5,No_rs1481742_rs16865298_Q_2,Yes_rs17048875_x_10_5,No_rs17048875_rs7981968_Q_8.5,Yes_rs35940137_x_2_5,No_rs35940137_x_10_5,Yes_rs16865298_x_2_5,No_rs16865298_x_10_5,Yes_rs7981968_rs17123422_Q_6,No_rs7981968_x_10_5,Yes_rs17123422_rs7540503_Q_6,No_rs17123422_x_10_5,Yes_rs7540503_x_2_5,No_rs7540503_x_10_5,\nCreate_rs12988076_Q_3.5,Yes_rs12988076_rs11687599_Q_5.5,No_rs12988076_rs233253_Q_2,Yes_rs11687599_rs7568884_Q_8.5,No_rs11687599_rs12053389_Q_1.5,Yes_rs233253_rs3828267_Q_8.5,No_rs233253_x_2_5,Yes_rs7568884_rs4799085_Q_6,No_rs7568884_rs1333717_Q_2,Yes_rs12053389_x_2_5,No_rs12053389_x_10_5,Yes_rs3828267_x_2_5,No_rs3828267_rs4654598_Q_2,Yes_rs4799085_rs2395634_Q_2,No_rs4799085_rs1192579_Q_8.5,Yes_rs1333717_x_10_5,No_rs1333717_x_2_5,Yes_rs4654598_x_2_5,No_rs4654598_x_10_5,Yes_rs2395634_rs2649071_Q_2,No_rs2395634_rs17099679_Q_5.5,Yes_rs1192579_x_2_5,No_rs1192579_x_10_5,Yes_rs2649071_x_10_5,No_rs2649071_x_2_5,Yes_rs17099679_rs11591221_Q_6,No_rs17099679_x_10_5,Yes_rs11591221_x_2_5,No_rs11591221_x_10_5,\nCreate_rs6719488_Q_8.5,Yes_rs6719488_rs461436_Q_6,No_rs6719488_rs10204606_Q_2,Yes_rs461436_rs4666782_Q_2,No_rs461436_x_2_5,Yes_rs10204606_rs615861_Q_6,No_rs10204606_rs4954573_Q_8.5,Yes_rs4666782_rs7537345_Q_2,No_rs4666782_x_2_5,Yes_rs615861_x_2_5,No_rs615861_x_10_5,Yes_rs4954573_rs4952541_Q_1.5,No_rs4954573_rs17091427_Q_8.5,Yes_rs7537345_x_2_5,No_rs7537345_x_10_5,Yes_rs4952541_x_2_5,No_rs4952541_x_10_5,Yes_rs17091427_x_10_5,No_rs17091427_rs13143297_Q_6,Yes_rs13143297_rs12905660_Q_6,No_rs13143297_x_10_5,Yes_rs12905660_x_10_5,No_rs12905660_rs1031466_Q_8.5,Yes_rs1031466_x_10_5,No_rs1031466_x_2_5,\n";
//North American 12 trees
//std::string treeInfo = "Create_rs35389_Q_2,Yes_rs35389_rs11147417_Q_8.5,No_rs35389_rs2814778_Q_8.5,Yes_rs11147417_rs12038297_Q_1.5,No_rs11147417_rs8081204_Q_2,Yes_rs2814778_rs1335762_Q_6,No_rs2814778_rs1800414_Q_8.5,Yes_rs12038297_x_8_5,No_rs12038297_x_1_5,Yes_rs8081204_rs10969597_Q_9.5,No_rs8081204_x_5_5,Yes_rs1335762_x_8_5,No_rs1335762_x_1_5,Yes_rs1800414_rs6603781_Q_5.5,No_rs1800414_rs4870227_Q_7,Yes_rs10969597_x_1_5,No_rs10969597_rs17031150_Q_8.5,Yes_rs6603781_x_5_5,No_rs6603781_x_4_5,Yes_rs4870227_rs10961635_Q_8.5,No_rs4870227_rs3776334_Q_5.5,Yes_rs17031150_x_2_5,No_rs17031150_x_8_5,Yes_rs10961635_x_5_5,No_rs10961635_rs2292857_Q_5.5,Yes_rs3776334_rs1798246_Q_1.5,No_rs3776334_rs16846854_Q_8.5,Yes_rs2292857_x_4_5,No_rs2292857_x_8_5,Yes_rs1798246_x_8_5,No_rs1798246_x_4_5,Yes_rs16846854_rs4310388_Q_8.5,No_rs16846854_rs1384182_Q_7,Yes_rs4310388_x_2_5,No_rs4310388_x_8_5,Yes_rs1384182_x_2_5,No_rs1384182_rs12568035_Q_6,Yes_rs12568035_x_5_5,No_rs12568035_x_8_5,\nCreate_rs5751131_Q_2,Yes_rs5751131_rs2829003_Q_1.5,No_rs5751131_rs873927_Q_5.5,Yes_rs2829003_rs35391_Q_6,No_rs2829003_rs6577401_Q_8.5,Yes_rs873927_x_8_5,No_rs873927_x_4_5,Yes_rs35391_rs7154864_Q_5.5,No_rs35391_rs1133238_Q_5.5,Yes_rs6577401_x_1_5,No_rs6577401_x_8_5,Yes_rs7154864_rs4906743_Q_5.5,No_rs7154864_rs17027638_Q_2,Yes_rs1133238_rs2303170_Q_2,No_rs1133238_rs4930431_Q_6,Yes_rs4906743_rs9729550_Q_3.5,No_rs4906743_rs2254669_Q_5.5,Yes_rs17027638_rs2519_Q_6,No_rs17027638_rs2793661_Q_6,Yes_rs2303170_x_5_5,No_rs2303170_x_4_5,Yes_rs4930431_rs672463_Q_6,No_rs4930431_rs12685829_Q_5.5,Yes_rs9729550_x_5_5,No_rs9729550_x_4_5,Yes_rs2254669_x_8_5,No_rs2254669_x_4_5,Yes_rs2519_rs3737718_Q_5.5,No_rs2519_x_8_5,Yes_rs2793661_x_8_5,No_rs2793661_x_5_5,Yes_rs672463_x_4_5,No_rs672463_rs488612_Q_8.5,Yes_rs12685829_x_5_5,No_rs12685829_rs13376100_Q_8.5,Yes_rs3737718_x_4_5,No_rs3737718_x_2_5,Yes_rs488612_x_1_5,No_rs488612_x_5_5,Yes_rs13376100_x_8_5,No_rs13376100_x_2_5,\nCreate_rs5758402_Q_6,Yes_rs5758402_rs9893667_Q_8.5,No_rs5758402_rs3128342_Q_1.5,Yes_rs9893667_rs3947662_Q_9.5,No_rs9893667_rs28117_Q_2,Yes_rs3128342_x_4_5,No_rs3128342_x_8_5,Yes_rs3947662_x_1_5,No_rs3947662_x_8_5,Yes_rs28117_rs10245220_Q_5.5,No_rs28117_rs17084501_Q_8.5,Yes_rs10245220_rs12590812_Q_5.5,No_rs10245220_rs1396795_Q_5.5,Yes_rs17084501_rs2039242_Q_5.5,No_rs17084501_rs2032915_Q_8.5,Yes_rs12590812_rs3748592_Q_2,No_rs12590812_rs17742354_Q_3.5,Yes_rs1396795_rs1569635_Q_8.5,No_rs1396795_rs2183746_Q_8.5,Yes_rs2039242_x_5_5,No_rs2039242_rs6667248_Q_2,Yes_rs2032915_rs4871389_Q_8.5,No_rs2032915_rs973978_Q_5.5,Yes_rs3748592_x_5_5,No_rs3748592_x_8_5,Yes_rs17742354_x_2_5,No_rs17742354_rs2123694_Q_2,Yes_rs1569635_x_8_5,No_rs1569635_x_5_5,Yes_rs2183746_x_8_5,No_rs2183746_rs12043519_Q_6,Yes_rs6667248_x_8_5,No_rs6667248_x_1_5,Yes_rs4871389_x_8_5,No_rs4871389_rs9919220_Q_5.5,Yes_rs973978_x_8_5,No_rs973978_x_4_5,Yes_rs2123694_x_5_5,No_rs2123694_rs2643885_Q_1.5,Yes_rs12043519_x_2_5,No_rs12043519_x_5_5,Yes_rs9919220_x_5_5,No_rs9919220_x_4_5,Yes_rs2643885_x_1_5,No_rs2643885_x_4_5,\nCreate_rs1960182_Q_2,Yes_rs1960182_rs8078633_Q_5.5,No_rs1960182_rs2817185_Q_2,Yes_rs8078633_rs3848147_Q_2,No_rs8078633_rs11264025_Q_6,Yes_rs2817185_x_4_5,No_rs2817185_x_8_5,Yes_rs3848147_rs7134749_Q_8.5,No_rs3848147_rs10165208_Q_7,Yes_rs11264025_x_1_5,No_rs11264025_x_8_5,Yes_rs7134749_rs9573246_Q_6,No_rs7134749_rs11192637_Q_5.5,Yes_rs10165208_x_5_5,No_rs10165208_x_8_5,Yes_rs9573246_rs9442996_Q_5.5,No_rs9573246_rs12142199_Q_5.5,Yes_rs11192637_rs12075715_Q_3.5,No_rs11192637_rs11204853_Q_8.5,Yes_rs9442996_rs6685064_Q_6,No_rs9442996_rs6731591_Q_8.5,Yes_rs12142199_x_5_5,No_rs12142199_x_4_5,Yes_rs12075715_x_1_5,No_rs12075715_rs3795501_Q_6,Yes_rs11204853_rs4314833_Q_6,No_rs11204853_rs2904664_Q_6,Yes_rs6685064_x_2_5,No_rs6685064_x_5_5,Yes_rs6731591_x_5_5,No_rs6731591_rs6694203_Q_8.5,Yes_rs3795501_x_5_5,No_rs3795501_x_8_5,Yes_rs4314833_x_4_5,No_rs4314833_x_5_5,Yes_rs2904664_rs12411125_Q_6,No_rs2904664_x_5_5,Yes_rs6694203_x_2_5,No_rs6694203_x_8_5,Yes_rs12411125_x_2_5,No_rs12411125_x_8_5,\nCreate_rs2270068_Q_8.5,Yes_rs2270068_rs4790359_Q_6,No_rs2270068_rs9442235_Q_9.5,Yes_rs4790359_rs4833103_Q_3.5,No_rs4790359_rs11121722_Q_5.5,Yes_rs9442235_x_8_5,No_rs9442235_x_4_5,Yes_rs4833103_rs12467317_Q_5.5,No_rs4833103_rs12423495_Q_8.5,Yes_rs11121722_x_1_5,No_rs11121722_x_8_5,Yes_rs12467317_rs4970383_Q_1.5,No_rs12467317_rs4968239_Q_6,Yes_rs12423495_rs17640978_Q_8.5,No_rs12423495_rs917408_Q_8.5,Yes_rs4970383_x_1_5,No_rs4970383_x_8_5,Yes_rs4968239_rs6541124_Q_6,No_rs4968239_rs10737480_Q_9.5,Yes_rs17640978_rs9442619_Q_6,No_rs17640978_rs1338839_Q_9.5,Yes_rs917408_rs260698_Q_2,No_rs917408_x_8_5,Yes_rs6541124_x_2_5,No_rs6541124_x_5_5,Yes_rs10737480_x_8_5,No_rs10737480_x_2_5,Yes_rs9442619_x_8_5,No_rs9442619_x_4_5,Yes_rs1338839_x_2_5,No_rs1338839_x_5_5,Yes_rs260698_rs9803031_Q_8.5,No_rs260698_rs12097368_Q_8.5,Yes_rs9803031_x_1_5,No_rs9803031_x_4_5,Yes_rs12097368_rs7541544_Q_8.5,No_rs12097368_rs522821_Q_5.5,Yes_rs7541544_x_5_5,No_rs7541544_x_8_5,Yes_rs522821_rs262680_Q_6,No_rs522821_rs6696281_Q_6,Yes_rs262680_x_1_5,No_rs262680_x_8_5,Yes_rs6696281_x_2_5,No_rs6696281_x_4_5,\nCreate_rs6500380_Q_2,Yes_rs6500380_rs738989_Q_1.5,No_rs6500380_rs17007466_Q_9.5,Yes_rs738989_x_4_5,No_rs738989_rs4644548_Q_6,Yes_rs17007466_rs2606411_Q_8.5,No_rs17007466_rs12484869_Q_5.5,Yes_rs4644548_x_8_5,No_rs4644548_x_5_5,Yes_rs2606411_x_1_5,No_rs2606411_x_2_5,Yes_rs12484869_rs2281173_Q_2,No_rs12484869_rs911445_Q_9.5,Yes_rs2281173_x_4_5,No_rs2281173_x_8_5,Yes_rs911445_rs11636232_Q_6,No_rs911445_rs35411_Q_2,Yes_rs11636232_rs926144_Q_2,No_rs11636232_rs11748410_Q_6,Yes_rs35411_rs3767908_Q_2,No_rs35411_rs2059696_Q_2,Yes_rs926144_rs12875618_Q_2,No_rs926144_rs3213221_Q_7,Yes_rs11748410_x_2_5,No_rs11748410_x_8_5,Yes_rs3767908_rs12039666_Q_6,No_rs3767908_x_1_5,Yes_rs2059696_rs3737721_Q_2,No_rs2059696_x_8_5,Yes_rs12875618_x_5_5,No_rs12875618_x_2_5,Yes_rs3213221_rs12410046_Q_5.5,No_rs3213221_x_8_5,Yes_rs12039666_x_2_5,No_rs12039666_x_5_5,Yes_rs3737721_x_1_5,No_rs3737721_x_4_5,Yes_rs12410046_x_4_5,No_rs12410046_rs17160669_Q_6,Yes_rs17160669_x_2_5,No_rs17160669_x_5_5,\nCreate_rs7552141_Q_2,Yes_rs7552141_rs1374821_Q_6,No_rs7552141_rs41388954_Q_7,Yes_rs1374821_rs6717424_Q_2,No_rs1374821_rs11637114_Q_6,Yes_rs41388954_x_8_5,No_rs41388954_x_1_5,Yes_rs6717424_rs2500283_Q_5.5,No_rs6717424_rs1498111_Q_2,Yes_rs11637114_rs4436808_Q_5.5,No_rs11637114_rs1865164_Q_2,Yes_rs2500283_x_4_5,No_rs2500283_x_8_5,Yes_rs1498111_rs1240708_Q_2,No_rs1498111_x_8_5,Yes_rs4436808_rs10835271_Q_2,No_rs4436808_rs1524007_Q_8.5,Yes_rs1865164_rs9329417_Q_6,No_rs1865164_x_1_5,Yes_rs1240708_x_2_5,No_rs1240708_x_5_5,Yes_rs10835271_rs11120943_Q_5.5,No_rs10835271_rs2483275_Q_6,Yes_rs1524007_rs11119881_Q_3.5,No_rs1524007_rs5743567_Q_5.5,Yes_rs9329417_x_2_5,No_rs9329417_x_5_5,Yes_rs11120943_x_2_5,No_rs11120943_x_8_5,Yes_rs2483275_x_4_5,No_rs2483275_x_5_5,Yes_rs11119881_x_5_5,No_rs11119881_rs7759248_Q_6,Yes_rs5743567_rs3766178_Q_6,No_rs5743567_rs6732285_Q_1.5,Yes_rs7759248_rs4958560_Q_8.5,No_rs7759248_x_8_5,Yes_rs3766178_x_5_5,No_rs3766178_x_8_5,Yes_rs6732285_rs11965097_Q_6,No_rs6732285_x_5_5,Yes_rs4958560_x_2_5,No_rs4958560_rs2651927_Q_1.5,Yes_rs11965097_rs4245756_Q_6,No_rs11965097_x_8_5,Yes_rs2651927_x_5_5,No_rs2651927_x_1_5,Yes_rs4245756_x_2_5,No_rs4245756_x_1_5,\nCreate_rs7588439_Q_2,Yes_rs7588439_rs3776329_Q_5.5,No_rs7588439_rs7517585_Q_6,Yes_rs3776329_rs6053122_Q_2,No_rs3776329_rs210780_Q_6,Yes_rs7517585_x_8_5,No_rs7517585_x_1_5,Yes_rs6053122_rs10777469_Q_2,No_rs6053122_rs4819094_Q_9.5,Yes_rs210780_x_4_5,No_rs210780_rs4648808_Q_6,Yes_rs10777469_rs4678073_Q_1.5,No_rs10777469_rs1246828_Q_5.5,Yes_rs4819094_rs10749549_Q_2,No_rs4819094_rs13378757_Q_2,Yes_rs4648808_x_8_5,No_rs4648808_x_1_5,Yes_rs4678073_rs8007618_Q_8.5,No_rs4678073_rs4851370_Q_6,Yes_rs1246828_x_5_5,No_rs1246828_rs6663420_Q_6,Yes_rs10749549_x_4_5,No_rs10749549_rs12294859_Q_8.5,Yes_rs13378757_rs638425_Q_8.5,No_rs13378757_x_2_5,Yes_rs8007618_rs1363845_Q_2,No_rs8007618_rs3748593_Q_3.5,Yes_rs4851370_x_5_5,No_rs4851370_x_8_5,Yes_rs6663420_x_4_5,No_rs6663420_x_8_5,Yes_rs12294859_x_8_5,No_rs12294859_rs1465221_Q_5.5,Yes_rs638425_x_5_5,No_rs638425_x_2_5,Yes_rs1363845_rs6932667_Q_2,No_rs1363845_x_5_5,Yes_rs3748593_x_8_5,No_rs3748593_x_5_5,Yes_rs1465221_x_2_5,No_rs1465221_rs13302982_Q_2,Yes_rs6932667_x_8_5,No_rs6932667_x_2_5,Yes_rs13302982_x_1_5,No_rs13302982_x_5_5,\nCreate_rs16941717_Q_1.5,Yes_rs16941717_rs7214357_Q_5.5,No_rs16941717_rs6804194_Q_8.5,Yes_rs7214357_rs2651912_Q_8.5,No_rs7214357_rs10962599_Q_6,Yes_rs6804194_rs28570376_Q_5.5,No_rs6804194_rs11466691_Q_8.5,Yes_rs2651912_x_1_5,No_rs2651912_x_8_5,Yes_rs10962599_rs12595731_Q_5.5,No_rs10962599_rs4669937_Q_5.5,Yes_rs28570376_x_1_5,No_rs28570376_x_8_5,Yes_rs11466691_x_5_5,No_rs11466691_x_4_5,Yes_rs12595731_rs1439464_Q_5.5,No_rs12595731_rs3814226_Q_5.5,Yes_rs4669937_rs2377982_Q_8.5,No_rs4669937_rs1396797_Q_5.5,Yes_rs1439464_x_4_5,No_rs1439464_x_5_5,Yes_rs3814226_rs10910034_Q_8.5,No_rs3814226_rs2891125_Q_5.5,Yes_rs2377982_rs331728_Q_5.5,No_rs2377982_rs10917234_Q_2,Yes_rs1396797_rs2083838_Q_5.5,No_rs1396797_rs17348860_Q_6,Yes_rs10910034_x_4_5,No_rs10910034_x_5_5,Yes_rs2891125_rs10889634_Q_2,No_rs2891125_rs3737829_Q_2,Yes_rs331728_x_2_5,No_rs331728_rs3131972_Q_2,Yes_rs10917234_x_2_5,No_rs10917234_x_8_5,Yes_rs2083838_rs2051548_Q_6,No_rs2083838_x_5_5,Yes_rs17348860_x_8_5,No_rs17348860_x_2_5,Yes_rs10889634_rs4040604_Q_8.5,No_rs10889634_rs2244013_Q_5.5,Yes_rs3737829_x_8_5,No_rs3737829_x_1_5,Yes_rs3131972_x_1_5,No_rs3131972_x_5_5,Yes_rs2051548_x_2_5,No_rs2051548_x_8_5,Yes_rs4040604_x_4_5,No_rs4040604_x_5_5,Yes_rs2244013_x_1_5,No_rs2244013_x_2_5,\nCreate_rs609096_Q_5.5,Yes_rs609096_rs9907225_Q_6,No_rs609096_rs13397666_Q_5.5,Yes_rs9907225_rs8053650_Q_6,No_rs9907225_rs7782345_Q_9.5,Yes_rs13397666_rs6445254_Q_2,No_rs13397666_rs12059795_Q_8.5,Yes_rs8053650_rs7860104_Q_2,No_rs8053650_rs1016101_Q_5.5,Yes_rs7782345_x_1_5,No_rs7782345_x_8_5,Yes_rs6445254_rs7552342_Q_8.5,No_rs6445254_rs10752748_Q_5.5,Yes_rs12059795_x_8_5,No_rs12059795_x_4_5,Yes_rs7860104_rs164736_Q_3.5,No_rs7860104_rs16841094_Q_2,Yes_rs1016101_rs2235536_Q_8.5,No_rs1016101_rs274751_Q_8.5,Yes_rs7552342_x_5_5,No_rs7552342_x_1_5,Yes_rs10752748_x_4_5,No_rs10752748_x_8_5,Yes_rs164736_x_8_5,No_rs164736_rs2274264_Q_5.5,Yes_rs16841094_rs4624679_Q_1.5,No_rs16841094_rs1861_Q_3.5,Yes_rs2235536_x_8_5,No_rs2235536_x_5_5,Yes_rs274751_rs2840530_Q_2,No_rs274751_rs6681741_Q_6,Yes_rs2274264_x_5_5,No_rs2274264_rs11211329_Q_2,Yes_rs4624679_x_8_5,No_rs4624679_rs35242196_Q_3.5,Yes_rs1861_x_2_5,No_rs1861_x_5_5,Yes_rs2840530_x_1_5,No_rs2840530_x_8_5,Yes_rs6681741_x_5_5,No_rs6681741_x_8_5,Yes_rs11211329_rs10492944_Q_8.5,No_rs11211329_x_8_5,Yes_rs35242196_x_5_5,No_rs35242196_x_2_5,Yes_rs10492944_x_2_5,No_rs10492944_x_5_5,\nCreate_rs9896466_Q_5.5,Yes_rs9896466_rs2802774_Q_3.5,No_rs9896466_rs4668272_Q_5.5,Yes_rs2802774_x_1_5,No_rs2802774_x_8_5,Yes_rs4668272_rs1007916_Q_8.5,No_rs4668272_rs10008032_Q_6,Yes_rs1007916_rs1881559_Q_3.5,No_rs1007916_rs3855955_Q_5.5,Yes_rs10008032_rs17425081_Q_5.5,No_rs10008032_rs310373_Q_6,Yes_rs1881559_x_8_5,No_rs1881559_x_5_5,Yes_rs3855955_x_8_5,No_rs3855955_x_4_5,Yes_rs17425081_rs16870076_Q_8.5,No_rs17425081_rs7582192_Q_5.5,Yes_rs310373_rs11198214_Q_7,No_rs310373_rs6439472_Q_8.5,Yes_rs16870076_x_8_5,No_rs16870076_x_2_5,Yes_rs7582192_rs425277_Q_8.5,No_rs7582192_rs12108234_Q_2,Yes_rs11198214_x_8_5,No_rs11198214_rs3860318_Q_2.5,Yes_rs6439472_rs7407_Q_6,No_rs6439472_x_5_5,Yes_rs425277_x_2_5,No_rs425277_x_8_5,Yes_rs12108234_rs9557355_Q_8.5,No_rs12108234_rs10173594_Q_2,Yes_rs3860318_x_2_5,No_rs3860318_x_5_5,Yes_rs7407_x_2_5,No_rs7407_x_8_5,Yes_rs9557355_rs11582339_Q_9.5,No_rs9557355_x_2_5,Yes_rs10173594_rs367673_Q_7,No_rs10173594_rs4475691_Q_8.5,Yes_rs11582339_rs6669870_Q_8.5,No_rs11582339_x_2_5,Yes_rs367673_rs351619_Q_2,No_rs367673_x_4_5,Yes_rs4475691_x_8_5,No_rs4475691_x_5_5,Yes_rs6669870_x_5_5,No_rs6669870_x_4_5,Yes_rs351619_x_1_5,No_rs351619_rs7290_Q_8.5,Yes_rs7290_x_5_5,No_rs7290_x_2_5,\nCreate_rs220486_Q_5.5,Yes_rs220486_rs2298225_Q_3.5,No_rs220486_rs3776337_Q_7,Yes_rs2298225_x_8_5,No_rs2298225_x_1_5,Yes_rs3776337_rs1888913_Q_9.5,No_rs3776337_rs6038071_Q_6,Yes_rs1888913_x_1_5,No_rs1888913_rs35940137_Q_5.5,Yes_rs6038071_rs715846_Q_2,No_rs6038071_rs2292051_Q_2,Yes_rs35940137_x_5_5,No_rs35940137_x_4_5,Yes_rs715846_rs10025344_Q_5.5,No_rs715846_rs2691483_Q_6,Yes_rs2292051_rs692902_Q_6,No_rs2292051_rs11707443_Q_7,Yes_rs10025344_rs1704348_Q_8.5,No_rs10025344_rs5004864_Q_9.5,Yes_rs2691483_x_4_5,No_rs2691483_rs2905036_Q_8.5,Yes_rs692902_rs1858104_Q_5.5,No_rs692902_rs35958305_Q_9.5,Yes_rs11707443_x_4_5,No_rs11707443_rs2055204_Q_2,Yes_rs1704348_rs679563_Q_2,No_rs1704348_rs1926883_Q_2,Yes_rs5004864_rs9331225_Q_6,No_rs5004864_rs17128262_Q_5.5,Yes_rs2905036_x_1_5,No_rs2905036_x_8_5,Yes_rs1858104_x_2_5,No_rs1858104_rs12028663_Q_6,Yes_rs35958305_x_2_5,No_rs35958305_x_5_5,Yes_rs2055204_x_8_5,No_rs2055204_x_2_5,Yes_rs679563_x_5_5,No_rs679563_x_1_5,Yes_rs1926883_x_8_5,No_rs1926883_x_4_5,Yes_rs9331225_x_5_5,No_rs9331225_x_1_5,Yes_rs17128262_x_8_5,No_rs17128262_rs916977_Q_8.5,Yes_rs12028663_x_5_5,No_rs12028663_x_4_5,Yes_rs916977_x_2_5,No_rs916977_x_5_5,\n";
//African 22 trees
std::string treeInfo = "Create_rs16855615_Q_5.5,Yes_rs16855615_rs17030159_Q_2,No_rs16855615_rs199138_Q_2,Yes_rs17030159_rs9619574_Q_2,No_rs17030159_x_7_5,Yes_rs199138_rs12701555_Q_5.5,No_rs199138_rs367645_Q_5.5,Yes_rs9619574_x_7_5,No_rs9619574_rs7316060_Q_6,Yes_rs12701555_rs803137_Q_5.5,No_rs12701555_rs13081915_Q_8.5,Yes_rs367645_rs11828501_Q_8.5,No_rs367645_rs4815694_Q_8.5,Yes_rs7316060_rs4130091_Q_8.5,No_rs7316060_x_7_5,Yes_rs803137_rs6694982_Q_4.5,No_rs803137_rs4819836_Q_5.5,Yes_rs13081915_rs9970652_Q_6,No_rs13081915_rs11735775_Q_8.5,Yes_rs11828501_rs852619_Q_6,No_rs11828501_x_11_5,Yes_rs4815694_x_9_5,No_rs4815694_x_11_5,Yes_rs4130091_x_9_5,No_rs4130091_x_11_5,Yes_rs6694982_x_9_5,No_rs6694982_x_11_5,Yes_rs4819836_rs1546260_Q_8.5,No_rs4819836_rs7514979_Q_6,Yes_rs9970652_x_7_5,No_rs9970652_x_9_5,Yes_rs11735775_rs6660514_Q_8.5,No_rs11735775_rs1679012_Q_6,Yes_rs852619_x_7_5,No_rs852619_x_9_5,Yes_rs1546260_x_7_5,No_rs1546260_x_11_5,Yes_rs7514979_x_7_5,No_rs7514979_x_11_5,Yes_rs6660514_x_7_5,No_rs6660514_x_11_5,Yes_rs1679012_rs9290877_Q_8.5,No_rs1679012_x_9_5,Yes_rs9290877_x_7_5,No_rs9290877_rs12561320_Q_1.5,Yes_rs12561320_x_11_5,No_rs12561320_x_7_5,\nCreate_rs4954207_Q_2.5,Yes_rs4954207_rs1901747_Q_6,No_rs4954207_rs28464695_Q_8.5,Yes_rs1901747_rs6944302_Q_6,No_rs1901747_rs7039873_Q_6,Yes_rs28464695_rs17741623_Q_8.5,No_rs28464695_rs9486141_Q_9.5,Yes_rs6944302_rs12005198_Q_2,No_rs6944302_rs7914354_Q_2,Yes_rs7039873_rs525448_Q_5.5,No_rs7039873_rs10915430_Q_6,Yes_rs17741623_x_9_5,No_rs17741623_x_7_5,Yes_rs9486141_x_7_5,No_rs9486141_rs16855847_Q_5.5,Yes_rs12005198_rs16862376_Q_8.5,No_rs12005198_rs6657290_Q_7,Yes_rs7914354_rs7155859_Q_8.5,No_rs7914354_rs752965_Q_6,Yes_rs525448_x_9_5,No_rs525448_x_7_5,Yes_rs10915430_x_11_5,No_rs10915430_x_7_5,Yes_rs16855847_x_11_5,No_rs16855847_rs3813199_Q_2,Yes_rs16862376_rs1725501_Q_8.5,No_rs16862376_rs17007536_Q_2,Yes_rs6657290_x_11_5,No_rs6657290_x_7_5,Yes_rs7155859_x_7_5,No_rs7155859_rs12191383_Q_1.5,Yes_rs752965_x_7_5,No_rs752965_x_9_5,Yes_rs3813199_x_7_5,No_rs3813199_x_9_5,Yes_rs1725501_rs17160975_Q_8.5,No_rs1725501_rs4732511_Q_6,Yes_rs17007536_x_11_5,No_rs17007536_x_9_5,Yes_rs12191383_rs589870_Q_8.5,No_rs12191383_x_7_5,Yes_rs17160975_x_9_5,No_rs17160975_x_7_5,Yes_rs4732511_x_7_5,No_rs4732511_rs2842909_Q_6,Yes_rs589870_x_11_5,No_rs589870_x_7_5,Yes_rs2842909_x_11_5,No_rs2842909_x_7_5,\nCreate_rs12614459_Q_8.5,Yes_rs12614459_rs10205050_Q_8.5,No_rs12614459_rs2227282_Q_5.5,Yes_rs10205050_rs6687835_Q_6,No_rs10205050_rs532885_Q_7,Yes_rs2227282_rs11975980_Q_8.5,No_rs2227282_rs544870_Q_5.5,Yes_rs6687835_x_11_5,No_rs6687835_x_7_5,Yes_rs532885_x_7_5,No_rs532885_rs16900601_Q_2,Yes_rs11975980_rs3039743_Q_6,No_rs11975980_rs2227914_Q_8.5,Yes_rs544870_x_11_5,No_rs544870_x_9_5,Yes_rs16900601_x_7_5,No_rs16900601_rs6684149_Q_8.5,Yes_rs3039743_rs4142753_Q_5.5,No_rs3039743_x_7_5,Yes_rs2227914_rs2815617_Q_6,No_rs2227914_rs1459157_Q_6,Yes_rs6684149_x_9_5,No_rs6684149_x_11_5,Yes_rs4142753_x_11_5,No_rs4142753_x_7_5,Yes_rs2815617_x_7_5,No_rs2815617_x_11_5,Yes_rs1459157_rs4987672_Q_6,No_rs1459157_rs6426370_Q_9.5,Yes_rs4987672_rs10832430_Q_5.5,No_rs4987672_rs8028686_Q_8.5,Yes_rs6426370_x_7_5,No_rs6426370_x_9_5,Yes_rs10832430_x_7_5,No_rs10832430_rs3935892_Q_3.5,Yes_rs8028686_rs6691985_Q_6,No_rs8028686_rs1956593_Q_8.5,Yes_rs3935892_x_7_5,No_rs3935892_x_11_5,Yes_rs6691985_x_11_5,No_rs6691985_x_7_5,Yes_rs1956593_x_9_5,No_rs1956593_rs7753502_Q_6,Yes_rs7753502_x_11_5,No_rs7753502_rs1739855_Q_8.5,Yes_rs1739855_x_7_5,No_rs1739855_x_9_5,\nCreate_rs12135523_Q_2,Yes_rs12135523_rs6759948_Q_5.5,No_rs12135523_rs7741503_Q_5.5,Yes_rs6759948_rs1523794_Q_8.5,No_rs6759948_rs17646556_Q_8.5,Yes_rs7741503_rs4845735_Q_2,No_rs7741503_rs7589010_Q_7,Yes_rs1523794_rs9583470_Q_2,No_rs1523794_rs10828213_Q_8.5,Yes_rs17646556_rs10754901_Q_6,No_rs17646556_rs4242609_Q_5.5,Yes_rs4845735_x_7_5,No_rs4845735_x_11_5,Yes_rs7589010_rs7531583_Q_2,No_rs7589010_rs7010482_Q_2,Yes_rs9583470_rs2476949_Q_2,No_rs9583470_x_7_5,Yes_rs10828213_rs6696281_Q_6,No_rs10828213_x_7_5,Yes_rs10754901_x_9_5,No_rs10754901_x_7_5,Yes_rs4242609_rs11702338_Q_6,No_rs4242609_rs6800015_Q_8.5,Yes_rs7531583_x_7_5,No_rs7531583_x_9_5,Yes_rs7010482_x_9_5,No_rs7010482_x_7_5,Yes_rs2476949_x_7_5,No_rs2476949_rs2905036_Q_6,Yes_rs6696281_x_7_5,No_rs6696281_x_11_5,Yes_rs11702338_x_9_5,No_rs11702338_rs11807848_Q_6,Yes_rs6800015_rs28499371_Q_6,No_rs6800015_rs4894197_Q_5.5,Yes_rs2905036_x_11_5,No_rs2905036_x_9_5,Yes_rs11807848_x_11_5,No_rs11807848_x_7_5,Yes_rs28499371_x_7_5,No_rs28499371_x_9_5,Yes_rs4894197_x_7_5,No_rs4894197_rs13087319_Q_5.5,Yes_rs13087319_x_7_5,No_rs13087319_rs11544855_Q_8.5,Yes_rs11544855_x_7_5,No_rs11544855_rs1443670_Q_2,Yes_rs1443670_x_7_5,No_rs1443670_x_11_5,\nCreate_rs309172_Q_5.5,Yes_rs309172_rs6591090_Q_2,No_rs309172_rs1364519_Q_2,Yes_rs6591090_rs422584_Q_2,No_rs6591090_rs11823218_Q_3.5,Yes_rs1364519_rs6734110_Q_8.5,No_rs1364519_rs2057969_Q_8.5,Yes_rs422584_rs2270013_Q_2,No_rs422584_rs875060_Q_5.5,Yes_rs11823218_x_7_5,No_rs11823218_rs4648524_Q_8.5,Yes_rs6734110_x_7_5,No_rs6734110_rs316671_Q_3.5,Yes_rs2057969_x_7_5,No_rs2057969_x_9_5,Yes_rs2270013_rs7946936_Q_8.5,No_rs2270013_x_7_5,Yes_rs875060_rs349558_Q_2.5,No_rs875060_rs1039027_Q_5.5,Yes_rs4648524_x_7_5,No_rs4648524_x_9_5,Yes_rs316671_x_9_5,No_rs316671_x_11_5,Yes_rs7946936_x_7_5,No_rs7946936_rs13403738_Q_9.5,Yes_rs349558_rs6779590_Q_5.5,No_rs349558_rs6547187_Q_5.5,Yes_rs1039027_x_9_5,No_rs1039027_rs4946158_Q_5.5,Yes_rs13403738_rs12405691_Q_2,No_rs13403738_x_7_5,Yes_rs6779590_x_11_5,No_rs6779590_rs7185017_Q_6,Yes_rs6547187_rs1776037_Q_6,No_rs6547187_x_9_5,Yes_rs4946158_x_7_5,No_rs4946158_rs6671001_Q_8.5,Yes_rs12405691_x_11_5,No_rs12405691_x_7_5,Yes_rs7185017_x_11_5,No_rs7185017_rs552006_Q_5.5,Yes_rs1776037_x_7_5,No_rs1776037_x_11_5,Yes_rs6671001_x_11_5,No_rs6671001_x_7_5,Yes_rs552006_x_7_5,No_rs552006_x_11_5,\nCreate_rs309143_Q_5.5,Yes_rs309143_rs1051388_Q_2,No_rs309143_rs6099216_Q_6,Yes_rs1051388_rs385521_Q_2,No_rs1051388_rs10022017_Q_6,Yes_rs6099216_rs7169337_Q_6,No_rs6099216_x_7_5,Yes_rs385521_rs12630974_Q_5.5,No_rs385521_rs8052388_Q_6,Yes_rs10022017_rs427811_Q_8.5,No_rs10022017_x_7_5,Yes_rs7169337_rs2191430_Q_3.5,No_rs7169337_x_7_5,Yes_rs12630974_x_7_5,No_rs12630974_rs965494_Q_6,Yes_rs8052388_rs7728894_Q_2,No_rs8052388_rs542650_Q_3.5,Yes_rs427811_x_7_5,No_rs427811_x_9_5,Yes_rs2191430_x_11_5,No_rs2191430_rs17038427_Q_7,Yes_rs965494_rs218892_Q_6,No_rs965494_x_7_5,Yes_rs7728894_rs417252_Q_8.5,No_rs7728894_rs881247_Q_2,Yes_rs542650_x_7_5,No_rs542650_rs2185886_Q_8.5,Yes_rs17038427_x_7_5,No_rs17038427_x_9_5,Yes_rs218892_x_11_5,No_rs218892_x_7_5,Yes_rs417252_rs6668399_Q_2,No_rs417252_rs404499_Q_2.5,Yes_rs881247_x_9_5,No_rs881247_x_11_5,Yes_rs2185886_x_11_5,No_rs2185886_x_7_5,Yes_rs6668399_x_9_5,No_rs6668399_rs7017705_Q_6,Yes_rs404499_rs3128689_Q_1.5,No_rs404499_rs935073_Q_2,Yes_rs7017705_x_11_5,No_rs7017705_rs12124406_Q_5.5,Yes_rs3128689_x_7_5,No_rs3128689_x_9_5,Yes_rs935073_x_9_5,No_rs935073_x_11_5,Yes_rs12124406_x_11_5,No_rs12124406_x_7_5,\nCreate_rs9953932_Q_5.5,Yes_rs9953932_rs12276848_Q_2,No_rs9953932_rs6430594_Q_5.5,Yes_rs12276848_rs2153900_Q_5.5,No_rs12276848_rs10847881_Q_5.5,Yes_rs6430594_rs11718932_Q_5.5,No_rs6430594_rs1995236_Q_5.5,Yes_rs2153900_x_11_5,No_rs2153900_x_7_5,Yes_rs10847881_rs11805412_Q_8.5,No_rs10847881_x_7_5,Yes_rs11718932_rs12758773_Q_2,No_rs11718932_rs17450822_Q_5.5,Yes_rs1995236_rs1713712_Q_8.5,No_rs1995236_x_7_5,Yes_rs11805412_x_9_5,No_rs11805412_x_11_5,Yes_rs12758773_rs9988744_Q_8.5,No_rs12758773_rs28495286_Q_8.5,Yes_rs17450822_rs10890311_Q_6,No_rs17450822_rs2180698_Q_6,Yes_rs1713712_x_9_5,No_rs1713712_x_11_5,Yes_rs9988744_rs10932521_Q_2,No_rs9988744_rs4245542_Q_6,Yes_rs28495286_x_9_5,No_rs28495286_x_7_5,Yes_rs10890311_x_7_5,No_rs10890311_x_9_5,Yes_rs2180698_rs4926853_Q_2,No_rs2180698_x_7_5,Yes_rs10932521_rs17171218_Q_6,No_rs10932521_x_9_5,Yes_rs4245542_rs3817958_Q_8.5,No_rs4245542_rs1427150_Q_8.5,Yes_rs4926853_x_11_5,No_rs4926853_x_7_5,Yes_rs17171218_x_7_5,No_rs17171218_x_11_5,Yes_rs3817958_x_7_5,No_rs3817958_rs7590763_Q_6,Yes_rs1427150_x_11_5,No_rs1427150_rs1333190_Q_6,Yes_rs7590763_x_7_5,No_rs7590763_x_11_5,Yes_rs1333190_x_9_5,No_rs1333190_x_7_5,\nCreate_rs7573555_Q_8.5,Yes_rs7573555_rs842361_Q_5.5,No_rs7573555_rs7674434_Q_9.5,Yes_rs842361_rs968365_Q_2,No_rs842361_rs7284910_Q_6,Yes_rs7674434_rs11963526_Q_2,No_rs7674434_rs11125815_Q_5.5,Yes_rs968365_rs3795521_Q_6,No_rs968365_rs2658083_Q_6,Yes_rs7284910_rs9597104_Q_5.5,No_rs7284910_rs1407893_Q_5.5,Yes_rs11963526_rs7600669_Q_2,No_rs11963526_rs10915424_Q_5.5,Yes_rs11125815_x_9_5,No_rs11125815_rs11018181_Q_8.5,Yes_rs3795521_rs4648501_Q_2,No_rs3795521_x_7_5,Yes_rs2658083_x_9_5,No_rs2658083_x_7_5,Yes_rs9597104_x_7_5,No_rs9597104_rs13236792_Q_8.5,Yes_rs1407893_rs11121090_Q_6,No_rs1407893_rs17104047_Q_2,Yes_rs7600669_rs6854489_Q_6,No_rs7600669_x_7_5,Yes_rs10915424_x_11_5,No_rs10915424_x_7_5,Yes_rs11018181_rs6700924_Q_5.5,No_rs11018181_rs6446241_Q_5.5,Yes_rs4648501_x_7_5,No_rs4648501_x_11_5,Yes_rs13236792_x_11_5,No_rs13236792_rs11836193_Q_6,Yes_rs11121090_x_11_5,No_rs11121090_x_9_5,Yes_rs17104047_x_7_5,No_rs17104047_x_11_5,Yes_rs6854489_rs7730689_Q_3.5,No_rs6854489_rs11808336_Q_6,Yes_rs6700924_x_9_5,No_rs6700924_rs12757754_Q_5.5,Yes_rs6446241_x_7_5,No_rs6446241_x_11_5,Yes_rs11836193_x_7_5,No_rs11836193_x_9_5,Yes_rs7730689_rs12122894_Q_5.5,No_rs7730689_x_7_5,Yes_rs11808336_x_11_5,No_rs11808336_x_7_5,Yes_rs12757754_x_7_5,No_rs12757754_x_11_5,Yes_rs12122894_x_7_5,No_rs12122894_x_11_5,\nCreate_rs1834640_Q_5.5,Yes_rs1834640_rs6755409_Q_5.5,No_rs1834640_rs1374808_Q_2,Yes_rs6755409_rs6854417_Q_6,No_rs6755409_rs4851391_Q_7,Yes_rs1374808_rs316598_Q_6,No_rs1374808_rs1534110_Q_8.5,Yes_rs6854417_rs7538397_Q_8.5,No_rs6854417_x_7_5,Yes_rs4851391_x_11_5,No_rs4851391_x_7_5,Yes_rs316598_rs7649861_Q_2,No_rs316598_rs7534387_Q_6,Yes_rs1534110_rs897620_Q_5.5,No_rs1534110_x_7_5,Yes_rs7538397_x_9_5,No_rs7538397_x_7_5,Yes_rs7649861_rs1995209_Q_9.5,No_rs7649861_rs11980955_Q_5.5,Yes_rs7534387_x_9_5,No_rs7534387_x_7_5,Yes_rs897620_x_11_5,No_rs897620_x_9_5,Yes_rs1995209_x_7_5,No_rs1995209_rs10429529_Q_6,Yes_rs11980955_rs11060955_Q_6,No_rs11980955_rs9650996_Q_5.5,Yes_rs10429529_rs7739132_Q_5.5,No_rs10429529_x_7_5,Yes_rs11060955_x_11_5,No_rs11060955_x_7_5,Yes_rs9650996_x_11_5,No_rs9650996_rs2951787_Q_5.5,Yes_rs7739132_x_7_5,No_rs7739132_rs17404600_Q_8.5,Yes_rs2951787_x_9_5,No_rs2951787_rs16901558_Q_8.5,Yes_rs17404600_x_11_5,No_rs17404600_x_7_5,Yes_rs16901558_rs2477703_Q_8.5,No_rs16901558_rs2753922_Q_5.5,Yes_rs2477703_x_7_5,No_rs2477703_x_11_5,Yes_rs2753922_x_11_5,No_rs2753922_rs2494640_Q_7,Yes_rs2494640_x_7_5,No_rs2494640_x_9_5,\nCreate_rs309154_Q_8.5,Yes_rs309154_rs1942518_Q_1.5,No_rs309154_rs5770567_Q_6,Yes_rs1942518_rs7783639_Q_2,No_rs1942518_rs11603486_Q_6,Yes_rs5770567_rs12191891_Q_6,No_rs5770567_rs12079672_Q_2,Yes_rs7783639_rs11564096_Q_8.5,No_rs7783639_rs1416801_Q_6,Yes_rs11603486_x_7_5,No_rs11603486_rs12086132_Q_8.5,Yes_rs12191891_rs1798246_Q_3.5,No_rs12191891_rs7536376_Q_8.5,Yes_rs12079672_x_11_5,No_rs12079672_x_9_5,Yes_rs11564096_rs4699030_Q_5.5,No_rs11564096_rs9376452_Q_6,Yes_rs1416801_rs4366501_Q_8.5,No_rs1416801_x_7_5,Yes_rs12086132_x_7_5,No_rs12086132_x_9_5,Yes_rs1798246_x_7_5,No_rs1798246_x_11_5,Yes_rs7536376_x_11_5,No_rs7536376_rs2821059_Q_6,Yes_rs4699030_x_7_5,No_rs4699030_x_9_5,Yes_rs9376452_rs2040435_Q_6,No_rs9376452_rs5999984_Q_7,Yes_rs4366501_x_7_5,No_rs4366501_rs6665912_Q_8.5,Yes_rs2821059_x_9_5,No_rs2821059_x_7_5,Yes_rs2040435_rs11584727_Q_5.5,No_rs2040435_rs6007462_Q_5.5,Yes_rs5999984_rs1233320_Q_5.5,No_rs5999984_rs34065840_Q_8.5,Yes_rs6665912_x_7_5,No_rs6665912_x_11_5,Yes_rs11584727_x_11_5,No_rs11584727_x_7_5,Yes_rs6007462_rs10492940_Q_3.5,No_rs6007462_x_11_5,Yes_rs1233320_rs641347_Q_6,No_rs1233320_x_7_5,Yes_rs34065840_rs212989_Q_5.5,No_rs34065840_x_7_5,Yes_rs10492940_x_9_5,No_rs10492940_x_7_5,Yes_rs641347_x_9_5,No_rs641347_x_11_5,Yes_rs212989_x_11_5,No_rs212989_x_9_5,\nCreate_rs309161_Q_2,Yes_rs309161_rs12885391_Q_2,No_rs309161_rs4841471_Q_2,Yes_rs12885391_rs4909055_Q_5.5,No_rs12885391_rs10137272_Q_2.5,Yes_rs4841471_rs12191877_Q_6,No_rs4841471_rs17108678_Q_5.5,Yes_rs4909055_rs9434795_Q_8.5,No_rs4909055_rs2034357_Q_5.5,Yes_rs10137272_rs16910077_Q_2,No_rs10137272_x_7_5,Yes_rs12191877_rs1077052_Q_8.5,No_rs12191877_rs7596776_Q_5.5,Yes_rs17108678_x_7_5,No_rs17108678_x_9_5,Yes_rs9434795_x_9_5,No_rs9434795_x_7_5,Yes_rs2034357_rs9803031_Q_8.5,No_rs2034357_rs542727_Q_3.5,Yes_rs16910077_rs616317_Q_1.5,No_rs16910077_x_11_5,Yes_rs1077052_rs1389583_Q_9.5,No_rs1077052_rs2672609_Q_6,Yes_rs7596776_x_9_5,No_rs7596776_rs1067344_Q_8.5,Yes_rs9803031_x_11_5,No_rs9803031_x_7_5,Yes_rs542727_x_7_5,No_rs542727_x_9_5,Yes_rs616317_x_7_5,No_rs616317_x_9_5,Yes_rs1389583_x_7_5,No_rs1389583_x_9_5,Yes_rs2672609_rs11084467_Q_8.5,No_rs2672609_rs6558059_Q_8.5,Yes_rs1067344_rs9442619_Q_6,No_rs1067344_x_11_5,Yes_rs11084467_x_9_5,No_rs11084467_rs12502827_Q_5.5,Yes_rs6558059_rs9803031_Q_8.5,No_rs6558059_rs2624459_Q_5.5,Yes_rs9442619_x_7_5,No_rs9442619_x_9_5,Yes_rs12502827_x_7_5,No_rs12502827_rs10818338_Q_5.5,Yes_rs9803031_x_11_5,No_rs9803031_x_9_5,Yes_rs2624459_x_11_5,No_rs2624459_x_7_5,Yes_rs10818338_x_7_5,No_rs10818338_rs2377417_Q_2,Yes_rs2377417_x_7_5,No_rs2377417_x_11_5,\nCreate_rs12897140_Q_7,Yes_rs12897140_rs2240099_Q_8.5,No_rs12897140_rs10498587_Q_5.5,Yes_rs2240099_rs354742_Q_2,No_rs2240099_rs17595719_Q_8.5,Yes_rs10498587_rs17042596_Q_2,No_rs10498587_rs6967965_Q_8.5,Yes_rs354742_rs7010861_Q_5.5,No_rs354742_rs28391282_Q_5.5,Yes_rs17595719_x_9_5,No_rs17595719_rs2025319_Q_5.5,Yes_rs17042596_rs9331225_Q_8.5,No_rs17042596_x_7_5,Yes_rs6967965_rs6456890_Q_8.5,No_rs6967965_rs7686272_Q_7,Yes_rs7010861_rs16972211_Q_5.5,No_rs7010861_x_7_5,Yes_rs28391282_x_11_5,No_rs28391282_x_7_5,Yes_rs2025319_rs6682184_Q_5.5,No_rs2025319_rs242050_Q_5.5,Yes_rs9331225_x_9_5,No_rs9331225_x_7_5,Yes_rs6456890_x_7_5,No_rs6456890_rs2272634_Q_6,Yes_rs7686272_rs11711134_Q_2,No_rs7686272_rs6477310_Q_8.5,Yes_rs16972211_x_7_5,No_rs16972211_x_9_5,Yes_rs6682184_x_7_5,No_rs6682184_x_11_5,Yes_rs242050_x_11_5,No_rs242050_x_7_5,Yes_rs2272634_rs6690311_Q_2,No_rs2272634_x_9_5,Yes_rs11711134_rs11102559_Q_8.5,No_rs11711134_x_7_5,Yes_rs6477310_rs12033324_Q_3.5,No_rs6477310_rs10819101_Q_6,Yes_rs6690311_x_7_5,No_rs6690311_x_11_5,Yes_rs11102559_x_11_5,No_rs11102559_x_7_5,Yes_rs12033324_x_11_5,No_rs12033324_x_9_5,Yes_rs10819101_rs12071761_Q_5.5,No_rs10819101_rs13389290_Q_6,Yes_rs12071761_x_7_5,No_rs12071761_x_11_5,Yes_rs13389290_x_11_5,No_rs13389290_rs17301591_Q_6,Yes_rs17301591_rs17160698_Q_6,No_rs17301591_x_9_5,Yes_rs17160698_x_11_5,No_rs17160698_x_7_5,\nCreate_rs2982364_Q_6,Yes_rs2982364_rs1446750_Q_5.5,No_rs2982364_rs7177754_Q_2,Yes_rs1446750_rs10461322_Q_9.5,No_rs1446750_rs6659655_Q_2,Yes_rs7177754_rs10487094_Q_2,No_rs7177754_rs542634_Q_5.5,Yes_rs10461322_rs12408533_Q_2,No_rs10461322_rs17089059_Q_5.5,Yes_rs6659655_rs824602_Q_8.5,No_rs6659655_rs17729838_Q_7,Yes_rs10487094_x_7_5,No_rs10487094_rs16824722_Q_7,Yes_rs542634_x_7_5,No_rs542634_x_11_5,Yes_rs12408533_x_7_5,No_rs12408533_x_11_5,Yes_rs17089059_x_9_5,No_rs17089059_x_7_5,Yes_rs824602_rs7700264_Q_5.5,No_rs824602_rs950220_Q_3.5,Yes_rs17729838_rs3737718_Q_2,No_rs17729838_rs16848617_Q_2,Yes_rs16824722_x_9_5,No_rs16824722_x_11_5,Yes_rs7700264_rs11466673_Q_6,No_rs7700264_rs9290610_Q_8.5,Yes_rs950220_rs1607345_Q_5.5,No_rs950220_rs1935648_Q_5.5,Yes_rs3737718_x_7_5,No_rs3737718_x_9_5,Yes_rs16848617_rs10428090_Q_5.5,No_rs16848617_rs2459994_Q_8.5,Yes_rs11466673_x_11_5,No_rs11466673_x_9_5,Yes_rs9290610_x_9_5,No_rs9290610_rs16838604_Q_6,Yes_rs1607345_x_7_5,No_rs1607345_x_11_5,Yes_rs1935648_rs11807931_Q_8.5,No_rs1935648_x_9_5,Yes_rs10428090_rs11260568_Q_7,No_rs10428090_rs8064_Q_5.5,Yes_rs2459994_x_11_5,No_rs2459994_x_7_5,Yes_rs16838604_x_7_5,No_rs16838604_x_11_5,Yes_rs11807931_x_7_5,No_rs11807931_x_11_5,Yes_rs11260568_x_9_5,No_rs11260568_x_11_5,Yes_rs8064_rs17048953_Q_6,No_rs8064_x_9_5,Yes_rs17048953_x_11_5,No_rs17048953_rs3789052_Q_6,Yes_rs3789052_x_7_5,No_rs3789052_x_11_5,\nCreate_rs123187_Q_2,Yes_rs123187_rs10872503_Q_5.5,No_rs123187_rs9958746_Q_6,Yes_rs10872503_rs2913276_Q_8.5,No_rs10872503_rs7295341_Q_2,Yes_rs9958746_rs3106146_Q_2,No_rs9958746_rs13137543_Q_2,Yes_rs2913276_rs2182160_Q_7,No_rs2913276_rs9851767_Q_5.5,Yes_rs7295341_rs12039907_Q_2,No_rs7295341_rs10028900_Q_8.5,Yes_rs3106146_rs1417592_Q_5.5,No_rs3106146_rs485618_Q_6,Yes_rs13137543_rs10748260_Q_8.5,No_rs13137543_rs4648764_Q_8.5,Yes_rs2182160_rs6778401_Q_2,No_rs2182160_rs12478385_Q_9.5,Yes_rs9851767_x_9_5,No_rs9851767_x_7_5,Yes_rs12039907_rs3790221_Q_2,No_rs12039907_x_7_5,Yes_rs10028900_x_11_5,No_rs10028900_x_7_5,Yes_rs1417592_x_7_5,No_rs1417592_rs2562831_Q_8.5,Yes_rs485618_x_7_5,No_rs485618_x_11_5,Yes_rs10748260_rs2298217_Q_6,No_rs10748260_rs2817178_Q_6,Yes_rs4648764_x_7_5,No_rs4648764_x_11_5,Yes_rs6778401_rs12142199_Q_5.5,No_rs6778401_x_7_5,Yes_rs12478385_rs925192_Q_8.5,No_rs12478385_rs1258010_Q_5.5,Yes_rs3790221_rs12141832_Q_9.5,No_rs3790221_x_7_5,Yes_rs2562831_x_11_5,No_rs2562831_x_9_5,Yes_rs2298217_x_9_5,No_rs2298217_x_11_5,Yes_rs2817178_x_7_5,No_rs2817178_x_11_5,Yes_rs12142199_x_7_5,No_rs12142199_x_11_5,Yes_rs925192_x_9_5,No_rs925192_x_11_5,Yes_rs1258010_rs9697358_Q_5.5,No_rs1258010_x_11_5,Yes_rs12141832_x_7_5,No_rs12141832_rs11581548_Q_2,Yes_rs9697358_x_7_5,No_rs9697358_x_9_5,Yes_rs11581548_x_7_5,No_rs11581548_x_11_5,\nCreate_rs4787040_Q_2.5,Yes_rs4787040_rs12136407_Q_8.5,No_rs4787040_rs8041403_Q_8.5,Yes_rs12136407_rs2370791_Q_9.5,No_rs12136407_rs10864120_Q_5.5,Yes_rs8041403_rs11943281_Q_8.5,No_rs8041403_rs880724_Q_6,Yes_rs2370791_rs6667248_Q_2,No_rs2370791_rs771307_Q_5.5,Yes_rs10864120_rs9400909_Q_2,No_rs10864120_rs2388044_Q_8.5,Yes_rs11943281_rs17144015_Q_5.5,No_rs11943281_x_7_5,Yes_rs880724_x_11_5,No_rs880724_x_7_5,Yes_rs6667248_x_7_5,No_rs6667248_x_11_5,Yes_rs771307_x_9_5,No_rs771307_x_7_5,Yes_rs9400909_rs10992623_Q_8.5,No_rs9400909_rs870171_Q_9.5,Yes_rs2388044_rs2071958_Q_6,No_rs2388044_rs699486_Q_5.5,Yes_rs17144015_x_7_5,No_rs17144015_rs10907175_Q_3.5,Yes_rs10992623_rs7534913_Q_5.5,No_rs10992623_rs34052864_Q_6,Yes_rs870171_x_7_5,No_rs870171_x_9_5,Yes_rs2071958_x_11_5,No_rs2071958_x_7_5,Yes_rs699486_rs8892_Q_5.5,No_rs699486_rs10785426_Q_6,Yes_rs10907175_x_9_5,No_rs10907175_x_11_5,Yes_rs7534913_x_9_5,No_rs7534913_x_7_5,Yes_rs34052864_rs16862821_Q_7,No_rs34052864_x_7_5,Yes_rs8892_x_7_5,No_rs8892_rs2493314_Q_8.5,Yes_rs10785426_rs2693958_Q_6,No_rs10785426_rs714816_Q_5.5,Yes_rs16862821_x_7_5,No_rs16862821_rs7536226_Q_6,Yes_rs2493314_x_9_5,No_rs2493314_x_11_5,Yes_rs2693958_x_11_5,No_rs2693958_x_7_5,Yes_rs714816_x_9_5,No_rs714816_rs12093951_Q_8.5,Yes_rs7536226_rs1815606_Q_8.5,No_rs7536226_x_7_5,Yes_rs12093951_x_7_5,No_rs12093951_x_11_5,Yes_rs1815606_x_9_5,No_rs1815606_x_11_5,\nCreate_rs12204275_Q_9.5,Yes_rs12204275_rs6119337_Q_5.5,No_rs12204275_rs10454039_Q_6,Yes_rs6119337_rs2064662_Q_5.5,No_rs6119337_rs6785796_Q_8.5,Yes_rs10454039_rs9421731_Q_5.5,No_rs10454039_rs8035628_Q_2,Yes_rs2064662_x_11_5,No_rs2064662_x_7_5,Yes_rs6785796_x_7_5,No_rs6785796_x_9_5,Yes_rs9421731_rs6742013_Q_6,No_rs9421731_rs1793891_Q_6,Yes_rs8035628_rs12124819_Q_2,No_rs8035628_x_9_5,Yes_rs6742013_x_7_5,No_rs6742013_x_9_5,Yes_rs1793891_rs388401_Q_7,No_rs1793891_rs6067491_Q_2,Yes_rs12124819_x_7_5,No_rs12124819_x_9_5,Yes_rs388401_rs6848616_Q_2,No_rs388401_rs10867230_Q_3.5,Yes_rs6067491_rs4845820_Q_2,No_rs6067491_rs16849099_Q_8.5,Yes_rs6848616_rs10873649_Q_2,No_rs6848616_rs9660710_Q_1.5,Yes_rs10867230_rs816060_Q_2,No_rs10867230_rs11257434_Q_2,Yes_rs4845820_x_11_5,No_rs4845820_x_9_5,Yes_rs16849099_x_7_5,No_rs16849099_x_11_5,Yes_rs10873649_x_11_5,No_rs10873649_rs36044796_Q_3.5,Yes_rs9660710_x_7_5,No_rs9660710_x_11_5,Yes_rs816060_x_7_5,No_rs816060_x_9_5,Yes_rs11257434_rs7923866_Q_6,No_rs11257434_x_7_5,Yes_rs36044796_x_7_5,No_rs36044796_x_9_5,Yes_rs7923866_rs10204491_Q_5.5,No_rs7923866_x_7_5,Yes_rs10204491_rs242058_Q_8.5,No_rs10204491_x_7_5,Yes_rs242058_x_11_5,No_rs242058_x_7_5,\nCreate_rs6731365_Q_2,Yes_rs6731365_rs6932992_Q_5.5,No_rs6731365_rs7605229_Q_8.5,Yes_rs6932992_rs12620050_Q_5.5,No_rs6932992_rs10513545_Q_5.5,Yes_rs7605229_rs1241988_Q_8.5,No_rs7605229_rs6770324_Q_5.5,Yes_rs12620050_rs17796342_Q_6,No_rs12620050_rs6436964_Q_6,Yes_rs10513545_rs11654128_Q_5.5,No_rs10513545_rs8051251_Q_2,Yes_rs1241988_x_11_5,No_rs1241988_rs17030353_Q_2,Yes_rs6770324_rs3128117_Q_6,No_rs6770324_rs9975332_Q_8.5,Yes_rs17796342_rs2808651_Q_6,No_rs17796342_x_7_5,Yes_rs6436964_rs10799032_Q_8.5,No_rs6436964_rs1031567_Q_5.5,Yes_rs11654128_x_7_5,No_rs11654128_rs17376559_Q_5.5,Yes_rs8051251_rs309331_Q_8.5,No_rs8051251_rs3761364_Q_6,Yes_rs17030353_rs9415758_Q_2,No_rs17030353_x_7_5,Yes_rs3128117_x_7_5,No_rs3128117_x_11_5,Yes_rs9975332_rs10910061_Q_5.5,No_rs9975332_x_7_5,Yes_rs2808651_x_11_5,No_rs2808651_x_7_5,Yes_rs10799032_x_7_5,No_rs10799032_x_9_5,Yes_rs1031567_x_11_5,No_rs1031567_x_7_5,Yes_rs17376559_x_7_5,No_rs17376559_x_11_5,Yes_rs309331_rs4605270_Q_6,No_rs309331_rs4928007_Q_5.5,Yes_rs3761364_rs2234167_Q_8.5,No_rs3761364_x_7_5,Yes_rs9415758_x_9_5,No_rs9415758_x_7_5,Yes_rs10910061_x_11_5,No_rs10910061_x_9_5,Yes_rs4605270_x_11_5,No_rs4605270_x_7_5,Yes_rs4928007_x_7_5,No_rs4928007_x_11_5,Yes_rs2234167_x_11_5,No_rs2234167_x_9_5,\nCreate_rs2237059_Q_8.5,Yes_rs2237059_rs8191431_Q_6,No_rs2237059_rs4513668_Q_9.5,Yes_rs8191431_rs16853992_Q_2,No_rs8191431_rs1123571_Q_5.5,Yes_rs4513668_rs218336_Q_8.5,No_rs4513668_rs6466823_Q_8.5,Yes_rs16853992_rs1982394_Q_6,No_rs16853992_x_11_5,Yes_rs1123571_x_7_5,No_rs1123571_x_11_5,Yes_rs218336_x_7_5,No_rs218336_rs16853407_Q_8.5,Yes_rs6466823_rs2287198_Q_5.5,No_rs6466823_rs7206635_Q_2,Yes_rs1982394_x_9_5,No_rs1982394_x_7_5,Yes_rs16853407_x_9_5,No_rs16853407_x_11_5,Yes_rs2287198_rs10916790_Q_8.5,No_rs2287198_rs10140504_Q_7,Yes_rs7206635_rs8027920_Q_2,No_rs7206635_rs12463789_Q_8.5,Yes_rs10916790_x_7_5,No_rs10916790_x_9_5,Yes_rs10140504_x_7_5,No_rs10140504_rs3795845_Q_9.5,Yes_rs8027920_rs1601745_Q_2,No_rs8027920_rs2309582_Q_5.5,Yes_rs12463789_x_7_5,No_rs12463789_x_11_5,Yes_rs3795845_x_7_5,No_rs3795845_rs6427184_Q_2,Yes_rs1601745_rs11584036_Q_2,No_rs1601745_rs3107145_Q_5.5,Yes_rs2309582_rs2147905_Q_6,No_rs2309582_rs9788651_Q_8.5,Yes_rs6427184_rs2298223_Q_6,No_rs6427184_x_7_5,Yes_rs11584036_x_9_5,No_rs11584036_x_7_5,Yes_rs3107145_x_11_5,No_rs3107145_x_9_5,Yes_rs2147905_x_9_5,No_rs2147905_x_7_5,Yes_rs9788651_x_11_5,No_rs9788651_rs8042942_Q_8.5,Yes_rs2298223_x_11_5,No_rs2298223_x_9_5,Yes_rs8042942_rs13414905_Q_8.5,No_rs8042942_x_9_5,Yes_rs13414905_x_11_5,No_rs13414905_x_7_5,\nCreate_rs8075137_Q_5.5,Yes_rs8075137_rs10937252_Q_2,No_rs8075137_rs17044602_Q_5.5,Yes_rs10937252_rs6854453_Q_6,No_rs10937252_rs7446054_Q_6,Yes_rs17044602_rs11808981_Q_8.5,No_rs17044602_rs6422427_Q_6,Yes_rs6854453_rs3749388_Q_6,No_rs6854453_rs10237182_Q_7,Yes_rs7446054_x_7_5,No_rs7446054_x_9_5,Yes_rs11808981_x_9_5,No_rs11808981_x_7_5,Yes_rs6422427_rs41513050_Q_5.5,No_rs6422427_x_11_5,Yes_rs3749388_rs1409968_Q_2,No_rs3749388_rs12058761_Q_8.5,Yes_rs10237182_x_7_5,No_rs10237182_rs17786140_Q_2,Yes_rs41513050_x_7_5,No_rs41513050_rs17139871_Q_9.5,Yes_rs1409968_rs2839509_Q_2,No_rs1409968_rs3017627_Q_6,Yes_rs12058761_x_9_5,No_rs12058761_x_7_5,Yes_rs17786140_x_7_5,No_rs17786140_x_9_5,Yes_rs17139871_x_7_5,No_rs17139871_rs9782908_Q_6,Yes_rs2839509_rs2535340_Q_8.5,No_rs2839509_x_7_5,Yes_rs3017627_x_7_5,No_rs3017627_x_9_5,Yes_rs9782908_x_9_5,No_rs9782908_x_7_5,Yes_rs2535340_rs16840287_Q_6,No_rs2535340_rs1356946_Q_8.5,Yes_rs16840287_x_11_5,No_rs16840287_x_7_5,Yes_rs1356946_x_7_5,No_rs1356946_rs4847372_Q_2,Yes_rs4847372_rs11769723_Q_6,No_rs4847372_x_7_5,Yes_rs11769723_rs6734731_Q_2,No_rs11769723_x_9_5,Yes_rs6734731_x_7_5,No_rs6734731_x_11_5,\nCreate_rs1420676_Q_6,Yes_rs1420676_rs2082331_Q_8.5,No_rs1420676_rs7669018_Q_8.5,Yes_rs2082331_rs1404756_Q_8.5,No_rs2082331_rs4344559_Q_5.5,Yes_rs7669018_rs11573205_Q_5.5,No_rs7669018_rs619345_Q_8.5,Yes_rs1404756_x_9_5,No_rs1404756_x_7_5,Yes_rs4344559_rs2325037_Q_2,No_rs4344559_rs10492377_Q_2,Yes_rs11573205_x_7_5,No_rs11573205_rs7515087_Q_8.5,Yes_rs619345_x_7_5,No_rs619345_x_11_5,Yes_rs2325037_rs2500297_Q_6,No_rs2325037_rs9575364_Q_8.5,Yes_rs10492377_rs4235448_Q_6,No_rs10492377_rs4887382_Q_8.5,Yes_rs7515087_x_7_5,No_rs7515087_x_9_5,Yes_rs2500297_x_9_5,No_rs2500297_x_7_5,Yes_rs9575364_x_9_5,No_rs9575364_x_7_5,Yes_rs4235448_rs748596_Q_8.5,No_rs4235448_rs6807580_Q_5.5,Yes_rs4887382_rs9659669_Q_2,No_rs4887382_x_9_5,Yes_rs748596_rs10764918_Q_6,No_rs748596_rs2477707_Q_6,Yes_rs6807580_x_9_5,No_rs6807580_x_7_5,Yes_rs9659669_x_11_5,No_rs9659669_x_7_5,Yes_rs10764918_rs10501858_Q_5.5,No_rs10764918_rs7512269_Q_6,Yes_rs2477707_x_9_5,No_rs2477707_x_7_5,Yes_rs10501858_x_7_5,No_rs10501858_rs10971164_Q_6,Yes_rs7512269_x_7_5,No_rs7512269_x_11_5,Yes_rs10971164_rs11265070_Q_2,No_rs10971164_x_7_5,Yes_rs11265070_rs17027039_Q_2,No_rs11265070_x_7_5,Yes_rs17027039_x_7_5,No_rs17027039_x_11_5,\nCreate_rs1536084_Q_2.5,Yes_rs1536084_rs7390989_Q_2,No_rs1536084_rs2023637_Q_6,Yes_rs7390989_rs10895512_Q_3.5,No_rs7390989_rs17210010_Q_5.5,Yes_rs2023637_rs4878051_Q_8.5,No_rs2023637_rs16949551_Q_2,Yes_rs10895512_rs6595775_Q_2,No_rs10895512_rs12487340_Q_8.5,Yes_rs17210010_rs10198116_Q_5.5,No_rs17210010_rs6882064_Q_6,Yes_rs4878051_rs7520934_Q_9.5,No_rs4878051_rs1037041_Q_5.5,Yes_rs16949551_rs1042712_Q_7,No_rs16949551_x_7_5,Yes_rs6595775_rs11688448_Q_2,No_rs6595775_rs12040683_Q_8.5,Yes_rs12487340_rs11260562_Q_2,No_rs12487340_rs1000647_Q_2,Yes_rs10198116_x_7_5,No_rs10198116_x_9_5,Yes_rs6882064_rs967094_Q_2,No_rs6882064_rs903903_Q_5.5,Yes_rs7520934_x_9_5,No_rs7520934_x_7_5,Yes_rs1037041_rs11807706_Q_5.5,No_rs1037041_rs12025026_Q_2,Yes_rs1042712_rs12074249_Q_1.5,No_rs1042712_rs12090228_Q_2,Yes_rs11688448_rs1353341_Q_2,No_rs11688448_x_11_5,Yes_rs12040683_x_9_5,No_rs12040683_x_11_5,Yes_rs11260562_x_9_5,No_rs11260562_x_7_5,Yes_rs1000647_rs2378559_Q_8.5,No_rs1000647_rs4654607_Q_6,Yes_rs967094_x_9_5,No_rs967094_x_11_5,Yes_rs903903_x_7_5,No_rs903903_x_9_5,Yes_rs11807706_x_7_5,No_rs11807706_x_11_5,Yes_rs12025026_x_7_5,No_rs12025026_x_11_5,Yes_rs12074249_x_7_5,No_rs12074249_x_9_5,Yes_rs12090228_x_7_5,No_rs12090228_x_9_5,Yes_rs1353341_x_9_5,No_rs1353341_x_7_5,Yes_rs2378559_rs6685066_Q_5.5,No_rs2378559_x_7_5,Yes_rs4654607_x_7_5,No_rs4654607_x_9_5,Yes_rs6685066_x_7_5,No_rs6685066_rs12409852_Q_2.5,Yes_rs12409852_rs3128342_Q_1.5,No_rs12409852_x_7_5,Yes_rs3128342_x_11_5,No_rs3128342_x_9_5,\nCreate_rs10825916_Q_9.5,Yes_rs10825916_rs17532826_Q_5.5,No_rs10825916_rs345981_Q_2,Yes_rs17532826_rs12305915_Q_2,No_rs17532826_rs2373262_Q_8.5,Yes_rs345981_rs11155161_Q_8.5,No_rs345981_rs12067378_Q_6,Yes_rs12305915_rs12097782_Q_6,No_rs12305915_x_7_5,Yes_rs2373262_rs10910097_Q_8.5,No_rs2373262_rs1404315_Q_8.5,Yes_rs11155161_rs2230233_Q_8.5,No_rs11155161_rs10836370_Q_8.5,Yes_rs12067378_x_7_5,No_rs12067378_x_9_5,Yes_rs12097782_x_9_5,No_rs12097782_x_7_5,Yes_rs10910097_x_9_5,No_rs10910097_x_7_5,Yes_rs1404315_rs1204826_Q_5.5,No_rs1404315_rs3845293_Q_3.5,Yes_rs2230233_rs4245756_Q_6,No_rs2230233_rs9789429_Q_5.5,Yes_rs10836370_rs16866638_Q_2,No_rs10836370_rs2839657_Q_8.5,Yes_rs1204826_x_9_5,No_rs1204826_rs615739_Q_2,Yes_rs3845293_x_11_5,No_rs3845293_x_9_5,Yes_rs4245756_x_9_5,No_rs4245756_x_7_5,Yes_rs9789429_x_7_5,No_rs9789429_x_11_5,Yes_rs16866638_rs4683973_Q_8.5,No_rs16866638_rs2794320_Q_5.5,Yes_rs2839657_rs10864504_Q_5.5,No_rs2839657_rs10487999_Q_5.5,Yes_rs615739_x_7_5,No_rs615739_x_11_5,Yes_rs4683973_x_7_5,No_rs4683973_x_11_5,Yes_rs2794320_x_11_5,No_rs2794320_x_7_5,Yes_rs10864504_x_9_5,No_rs10864504_x_7_5,Yes_rs10487999_rs6419478_Q_8.5,No_rs10487999_rs2267270_Q_5.5,Yes_rs6419478_x_11_5,No_rs6419478_x_7_5,Yes_rs2267270_x_7_5,No_rs2267270_rs2758735_Q_5.5,Yes_rs2758735_rs1393117_Q_2,No_rs2758735_x_7_5,Yes_rs1393117_x_11_5,No_rs1393117_x_7_5,\n";
//Kenyan 31 trees
//std::string treeInfo = "Create_rs7573555_Q_8.5,Yes_rs7573555_rs7561423_Q_6,No_rs7573555_rs13162048_Q_2,Yes_rs7561423_rs10897976_Q_3.5,No_rs7561423_rs9470872_Q_8.5,Yes_rs13162048_rs17202778_Q_8.5,No_rs13162048_rs349400_Q_8.5,Yes_rs10897976_rs495937_Q_7,No_rs10897976_x_7_5,Yes_rs9470872_x_7_5,No_rs9470872_rs7760662_Q_9.5,Yes_rs17202778_x_9_5,No_rs17202778_rs12742323_Q_8.5,Yes_rs349400_x_7_5,No_rs349400_x_9_5,Yes_rs495937_x_9_5,No_rs495937_x_7_5,Yes_rs7760662_x_7_5,No_rs7760662_rs6736379_Q_8.5,Yes_rs12742323_x_7_5,No_rs12742323_x_9_5,Yes_rs6736379_x_7_5,No_rs6736379_x_9_5,\nCreate_rs1050115_Q_2,Yes_rs1050115_rs11125815_Q_5.5,No_rs1050115_rs17044602_Q_5.5,Yes_rs11125815_rs1320565_Q_6,No_rs11125815_rs17226259_Q_5.5,Yes_rs17044602_rs2058061_Q_5.5,No_rs17044602_rs2721202_Q_6,Yes_rs1320565_x_7_5,No_rs1320565_x_9_5,Yes_rs17226259_x_9_5,No_rs17226259_x_7_5,Yes_rs2058061_x_9_5,No_rs2058061_x_7_5,Yes_rs2721202_rs869939_Q_3.5,No_rs2721202_rs392630_Q_5.5,Yes_rs869939_rs2190355_Q_8.5,No_rs869939_x_7_5,Yes_rs392630_x_9_5,No_rs392630_x_7_5,Yes_rs2190355_x_7_5,No_rs2190355_x_9_5,\nCreate_rs7581814_Q_5.5,Yes_rs7581814_rs17685410_Q_5.5,No_rs7581814_rs1990796_Q_1.5,Yes_rs17685410_rs4908925_Q_1.5,No_rs17685410_rs2284767_Q_2,Yes_rs1990796_rs4721216_Q_8.5,No_rs1990796_rs7548984_Q_7,Yes_rs4908925_x_9_5,No_rs4908925_x_7_5,Yes_rs2284767_x_7_5,No_rs2284767_x_9_5,Yes_rs4721216_rs1110052_Q_9.5,No_rs4721216_rs9292857_Q_8.5,Yes_rs7548984_x_9_5,No_rs7548984_x_7_5,Yes_rs1110052_x_7_5,No_rs1110052_x_9_5,Yes_rs9292857_x_7_5,No_rs9292857_rs2188301_Q_3.5,Yes_rs2188301_x_7_5,No_rs2188301_rs12095221_Q_8.5,Yes_rs12095221_x_9_5,No_rs12095221_x_7_5,\nCreate_rs2015532_Q_9.5,Yes_rs2015532_rs2944776_Q_6,No_rs2015532_rs4658560_Q_2,Yes_rs2944776_rs6880683_Q_8.5,No_rs2944776_rs10908849_Q_8.5,Yes_rs4658560_rs1597178_Q_2,No_rs4658560_rs12031557_Q_2,Yes_rs6880683_rs2515542_Q_6,No_rs6880683_rs17298420_Q_9.5,Yes_rs10908849_x_9_5,No_rs10908849_rs13303106_Q_2,Yes_rs1597178_x_9_5,No_rs1597178_x_7_5,Yes_rs12031557_x_9_5,No_rs12031557_x_7_5,Yes_rs2515542_x_7_5,No_rs2515542_x_9_5,Yes_rs17298420_x_9_5,No_rs17298420_rs10915360_Q_6,Yes_rs13303106_x_7_5,No_rs13303106_x_9_5,Yes_rs10915360_x_9_5,No_rs10915360_x_7_5,\nCreate_rs6724569_Q_5.5,Yes_rs6724569_rs8140370_Q_9.5,No_rs6724569_rs9516890_Q_8.5,Yes_rs8140370_rs9576822_Q_1.5,No_rs8140370_rs12064015_Q_9.5,Yes_rs9516890_rs11805516_Q_8.5,No_rs9516890_rs12739022_Q_8.5,Yes_rs9576822_x_9_5,No_rs9576822_x_7_5,Yes_rs12064015_x_7_5,No_rs12064015_rs9874060_Q_2,Yes_rs11805516_x_7_5,No_rs11805516_x_9_5,Yes_rs12739022_x_9_5,No_rs12739022_x_7_5,Yes_rs9874060_rs6685064_Q_6,No_rs9874060_rs11547493_Q_8.5,Yes_rs6685064_x_9_5,No_rs6685064_x_7_5,Yes_rs11547493_x_7_5,No_rs11547493_rs12059640_Q_8.5,Yes_rs12059640_x_9_5,No_rs12059640_x_7_5,\nCreate_rs6430594_Q_2,Yes_rs6430594_rs2315523_Q_6,No_rs6430594_rs5770567_Q_6,Yes_rs2315523_rs992133_Q_5.5,No_rs2315523_rs3813199_Q_5.5,Yes_rs5770567_rs12204275_Q_9.5,No_rs5770567_rs2744677_Q_8.5,Yes_rs992133_x_9_5,No_rs992133_x_7_5,Yes_rs3813199_x_7_5,No_rs3813199_x_9_5,Yes_rs12204275_x_9_5,No_rs12204275_rs10520997_Q_5.5,Yes_rs2744677_x_7_5,No_rs2744677_rs1005032_Q_6,Yes_rs10520997_rs2651906_Q_6,No_rs10520997_rs13303118_Q_9.5,Yes_rs1005032_x_7_5,No_rs1005032_rs16824500_Q_2,Yes_rs2651906_x_9_5,No_rs2651906_x_7_5,Yes_rs13303118_x_7_5,No_rs13303118_x_9_5,Yes_rs16824500_x_7_5,No_rs16824500_x_9_5,\nCreate_rs364950_Q_2,Yes_rs364950_rs6927023_Q_5.5,No_rs364950_rs13142580_Q_8.5,Yes_rs6927023_rs9309464_Q_5.5,No_rs6927023_rs9485572_Q_5.5,Yes_rs13142580_rs6735149_Q_6,No_rs13142580_x_9_5,Yes_rs9309464_rs17160698_Q_7.5,No_rs9309464_x_7_5,Yes_rs9485572_x_7_5,No_rs9485572_rs12239056_Q_6,Yes_rs6735149_rs11586404_Q_5.5,No_rs6735149_x_9_5,Yes_rs17160698_x_7_5,No_rs17160698_x_9_5,Yes_rs12239056_rs12085768_Q_6,No_rs12239056_x_7_5,Yes_rs11586404_x_9_5,No_rs11586404_x_7_5,Yes_rs12085768_x_9_5,No_rs12085768_x_7_5,\nCreate_rs404557_Q_2,Yes_rs404557_rs6096853_Q_2,No_rs404557_rs800672_Q_2,Yes_rs6096853_rs2298217_Q_6,No_rs6096853_rs312557_Q_3.5,Yes_rs800672_rs7653308_Q_6,No_rs800672_rs7745739_Q_8.5,Yes_rs2298217_x_7_5,No_rs2298217_x_9_5,Yes_rs312557_rs445633_Q_6,No_rs312557_rs4233931_Q_8.5,Yes_rs7653308_x_9_5,No_rs7653308_x_7_5,Yes_rs7745739_x_7_5,No_rs7745739_x_9_5,Yes_rs445633_rs672138_Q_2.5,No_rs445633_x_7_5,Yes_rs4233931_x_9_5,No_rs4233931_x_7_5,Yes_rs672138_x_7_5,No_rs672138_x_9_5,\nCreate_rs1440463_Q_6,Yes_rs1440463_rs8070885_Q_8.5,No_rs1440463_rs2227282_Q_5.5,Yes_rs8070885_rs477882_Q_5.5,No_rs8070885_rs13319626_Q_7,Yes_rs2227282_rs790660_Q_7,No_rs2227282_x_9_5,Yes_rs477882_x_9_5,No_rs477882_x_7_5,Yes_rs13319626_x_7_5,No_rs13319626_rs1379602_Q_9.5,Yes_rs790660_x_9_5,No_rs790660_rs4750058_Q_5.5,Yes_rs1379602_x_7_5,No_rs1379602_rs16937924_Q_5.5,Yes_rs4750058_x_9_5,No_rs4750058_rs6671889_Q_1.5,Yes_rs16937924_x_7_5,No_rs16937924_x_9_5,Yes_rs6671889_x_9_5,No_rs6671889_x_7_5,\nCreate_rs973332_Q_6,Yes_rs973332_rs30534_Q_6,No_rs973332_rs7710375_Q_2,Yes_rs30534_rs1956593_Q_8.5,No_rs30534_rs1772890_Q_8.5,Yes_rs7710375_rs11915247_Q_5.5,No_rs7710375_rs262656_Q_1.5,Yes_rs1956593_rs6694982_Q_2,No_rs1956593_rs1206810_Q_6,Yes_rs1772890_x_7_5,No_rs1772890_x_9_5,Yes_rs11915247_x_7_5,No_rs11915247_rs12404555_Q_5.5,Yes_rs262656_x_7_5,No_rs262656_x_9_5,Yes_rs6694982_x_9_5,No_rs6694982_x_7_5,Yes_rs1206810_rs4648819_Q_2,No_rs1206810_x_9_5,Yes_rs12404555_x_7_5,No_rs12404555_x_9_5,Yes_rs4648819_x_7_5,No_rs4648819_x_9_5,\nCreate_rs309172_Q_2,Yes_rs309172_rs6737636_Q_6,No_rs309172_rs6794557_Q_5.5,Yes_rs6737636_rs7553178_Q_5.5,No_rs6737636_x_9_5,Yes_rs6794557_rs1891231_Q_5.5,No_rs6794557_rs7770679_Q_2,Yes_rs7553178_x_7_5,No_rs7553178_x_9_5,Yes_rs1891231_x_9_5,No_rs1891231_rs6424639_Q_8.5,Yes_rs7770679_rs2430341_Q_6,No_rs7770679_x_7_5,Yes_rs6424639_x_7_5,No_rs6424639_x_9_5,Yes_rs2430341_x_7_5,No_rs2430341_rs9745005_Q_2,Yes_rs9745005_rs12994558_Q_6,No_rs9745005_x_7_5,Yes_rs12994558_x_7_5,No_rs12994558_rs17754897_Q_2,Yes_rs17754897_x_7_5,No_rs17754897_x_9_5,\nCreate_rs309143_Q_2,Yes_rs309143_rs10497029_Q_5.5,No_rs309143_rs5743612_Q_5.5,Yes_rs10497029_x_9_5,No_rs10497029_rs9943244_Q_1.5,Yes_rs5743612_rs2237835_Q_2,No_rs5743612_rs1567049_Q_6,Yes_rs9943244_x_7_5,No_rs9943244_x_9_5,Yes_rs2237835_x_7_5,No_rs2237835_rs3766191_Q_6,Yes_rs1567049_rs12022654_Q_5.5,No_rs1567049_rs1844959_Q_5.5,Yes_rs3766191_x_9_5,No_rs3766191_x_7_5,Yes_rs12022654_x_9_5,No_rs12022654_x_7_5,Yes_rs1844959_x_7_5,No_rs1844959_rs17055737_Q_5.5,Yes_rs17055737_x_7_5,No_rs17055737_rs8057684_Q_2,Yes_rs8057684_rs3737721_Q_5.5,No_rs8057684_x_7_5,Yes_rs3737721_x_9_5,No_rs3737721_x_7_5,\nCreate_rs309154_Q_6,Yes_rs309154_rs4142221_Q_6,No_rs309154_rs1595422_Q_2,Yes_rs4142221_rs12119558_Q_5.5,No_rs4142221_x_9_5,Yes_rs1595422_rs11660396_Q_2,No_rs1595422_rs1366457_Q_9.5,Yes_rs12119558_x_9_5,No_rs12119558_x_7_5,Yes_rs11660396_rs6424976_Q_6,No_rs11660396_x_9_5,Yes_rs1366457_x_7_5,No_rs1366457_rs12601516_Q_2,Yes_rs6424976_x_7_5,No_rs6424976_x_9_5,Yes_rs12601516_x_7_5,No_rs12601516_rs1792959_Q_5.5,Yes_rs1792959_x_7_5,No_rs1792959_rs17030159_Q_2,Yes_rs17030159_x_9_5,No_rs17030159_x_7_5,\nCreate_rs3769012_Q_5.5,Yes_rs3769012_rs35487582_Q_3.5,No_rs3769012_rs12438284_Q_2,Yes_rs35487582_rs4402506_Q_8.5,No_rs35487582_rs7741503_Q_5.5,Yes_rs12438284_rs17263039_Q_8.5,No_rs12438284_rs11808276_Q_6,Yes_rs4402506_x_9_5,No_rs4402506_rs10890041_Q_8.5,Yes_rs7741503_rs1175549_Q_1.5,No_rs7741503_rs12069196_Q_6,Yes_rs17263039_x_9_5,No_rs17263039_x_7_5,Yes_rs11808276_x_9_5,No_rs11808276_x_7_5,Yes_rs10890041_x_9_5,No_rs10890041_x_7_5,Yes_rs1175549_x_9_5,No_rs1175549_x_7_5,Yes_rs12069196_rs10075371_Q_6,No_rs12069196_x_7_5,Yes_rs10075371_rs2274264_Q_2,No_rs10075371_x_7_5,Yes_rs2274264_x_7_5,No_rs2274264_x_9_5,\nCreate_rs10072084_Q_6,Yes_rs10072084_rs936663_Q_5.5,No_rs10072084_rs17028457_Q_8.5,Yes_rs936663_rs2067022_Q_8.5,No_rs936663_rs648378_Q_5.5,Yes_rs17028457_rs6429800_Q_2,No_rs17028457_rs17095806_Q_5.5,Yes_rs2067022_rs28707307_Q_8.5,No_rs2067022_rs4269034_Q_8.5,Yes_rs648378_x_9_5,No_rs648378_x_7_5,Yes_rs6429800_x_7_5,No_rs6429800_x_9_5,Yes_rs17095806_rs16923264_Q_1.5,No_rs17095806_x_7_5,Yes_rs28707307_x_7_5,No_rs28707307_x_9_5,Yes_rs4269034_x_9_5,No_rs4269034_x_7_5,Yes_rs16923264_rs7523842_Q_8.5,No_rs16923264_x_7_5,Yes_rs7523842_x_7_5,No_rs7523842_rs11120876_Q_6,Yes_rs11120876_x_9_5,No_rs11120876_x_7_5,\nCreate_rs10242455_Q_5.5,Yes_rs10242455_rs809825_Q_8.5,No_rs10242455_rs12885270_Q_5.5,Yes_rs809825_rs2488479_Q_8.5,No_rs809825_rs12135523_Q_2,Yes_rs12885270_rs11916051_Q_8.5,No_rs12885270_rs6458997_Q_8.5,Yes_rs2488479_x_9_5,No_rs2488479_x_7_5,Yes_rs12135523_x_7_5,No_rs12135523_rs4631721_Q_5.5,Yes_rs11916051_rs6673393_Q_6,No_rs11916051_rs16934647_Q_8.5,Yes_rs6458997_x_9_5,No_rs6458997_x_7_5,Yes_rs4631721_x_9_5,No_rs4631721_x_7_5,Yes_rs6673393_x_7_5,No_rs6673393_x_9_5,Yes_rs16934647_x_9_5,No_rs16934647_x_7_5,\nCreate_rs12472293_Q_8.5,Yes_rs12472293_rs6862681_Q_5.5,No_rs12472293_rs17823777_Q_2,Yes_rs6862681_rs201729_Q_8.5,No_rs6862681_rs1347957_Q_6,Yes_rs17823777_rs770308_Q_6,No_rs17823777_rs2803310_Q_6,Yes_rs201729_x_7_5,No_rs201729_rs6667248_Q_5.5,Yes_rs1347957_rs11884415_Q_6,No_rs1347957_rs11260595_Q_3.5,Yes_rs770308_x_9_5,No_rs770308_x_7_5,Yes_rs2803310_x_7_5,No_rs2803310_x_9_5,Yes_rs6667248_x_9_5,No_rs6667248_x_7_5,Yes_rs11884415_rs17086113_Q_5.5,No_rs11884415_x_7_5,Yes_rs11260595_x_9_5,No_rs11260595_x_7_5,Yes_rs17086113_x_7_5,No_rs17086113_rs11799924_Q_5.5,Yes_rs11799924_x_9_5,No_rs11799924_x_7_5,\nCreate_rs699486_Q_5.5,Yes_rs699486_rs11759220_Q_5.5,No_rs699486_rs4646457_Q_3.5,Yes_rs11759220_rs13303010_Q_2,No_rs11759220_rs2720710_Q_7,Yes_rs4646457_rs10474381_Q_8.5,No_rs4646457_rs12541188_Q_2,Yes_rs13303010_x_9_5,No_rs13303010_x_7_5,Yes_rs2720710_x_7_5,No_rs2720710_rs7527194_Q_8.5,Yes_rs10474381_rs3125677_Q_2,No_rs10474381_rs595541_Q_2,Yes_rs12541188_rs12752801_Q_7.5,No_rs12541188_x_9_5,Yes_rs7527194_x_9_5,No_rs7527194_x_7_5,Yes_rs3125677_x_9_5,No_rs3125677_x_7_5,Yes_rs595541_x_7_5,No_rs595541_rs7523732_Q_6,Yes_rs12752801_x_7_5,No_rs12752801_x_9_5,Yes_rs7523732_x_7_5,No_rs7523732_x_9_5,\nCreate_rs16855615_Q_5.5,Yes_rs16855615_rs10137272_Q_2.5,No_rs16855615_rs6677662_Q_2,Yes_rs10137272_rs532885_Q_7,No_rs10137272_x_7_5,Yes_rs6677662_rs6963345_Q_5.5,No_rs6677662_rs7539166_Q_8.5,Yes_rs532885_x_7_5,No_rs532885_rs13404079_Q_1.5,Yes_rs6963345_rs28635343_Q_5.5,No_rs6963345_rs17286578_Q_8.5,Yes_rs7539166_x_9_5,No_rs7539166_x_7_5,Yes_rs13404079_x_7_5,No_rs13404079_x_9_5,Yes_rs28635343_x_7_5,No_rs28635343_x_9_5,Yes_rs17286578_x_9_5,No_rs17286578_rs11208579_Q_2,Yes_rs11208579_x_9_5,No_rs11208579_x_7_5,\nCreate_rs2241883_Q_8.5,Yes_rs2241883_rs7168199_Q_5.5,No_rs2241883_rs12188101_Q_2,Yes_rs7168199_rs9992661_Q_1.5,No_rs7168199_rs7216396_Q_8.5,Yes_rs12188101_rs3935821_Q_6,No_rs12188101_rs10075720_Q_9.5,Yes_rs9992661_rs67746_Q_5.5,No_rs9992661_x_7_5,Yes_rs7216396_x_7_5,No_rs7216396_x_9_5,Yes_rs3935821_rs12943500_Q_6,No_rs3935821_rs2181484_Q_2,Yes_rs10075720_x_7_5,No_rs10075720_rs28504611_Q_8.5,Yes_rs67746_x_9_5,No_rs67746_x_7_5,Yes_rs12943500_rs7415927_Q_5.5,No_rs12943500_x_9_5,Yes_rs2181484_x_7_5,No_rs2181484_x_9_5,Yes_rs28504611_x_9_5,No_rs28504611_x_7_5,Yes_rs7415927_x_9_5,No_rs7415927_x_7_5,\nCreate_rs1545223_Q_2,Yes_rs1545223_rs2423334_Q_6,No_rs1545223_rs2551320_Q_6,Yes_rs2423334_rs6584646_Q_8.5,No_rs2423334_rs4661748_Q_9.5,Yes_rs2551320_rs4912106_Q_2,No_rs2551320_x_7_5,Yes_rs6584646_rs2376821_Q_8.5,No_rs6584646_rs1206088_Q_8.5,Yes_rs4661748_x_9_5,No_rs4661748_x_7_5,Yes_rs4912106_rs17047458_Q_5.5,No_rs4912106_x_7_5,Yes_rs2376821_x_9_5,No_rs2376821_x_7_5,Yes_rs1206088_x_9_5,No_rs1206088_rs4972277_Q_8.5,Yes_rs17047458_x_7_5,No_rs17047458_x_9_5,Yes_rs4972277_x_7_5,No_rs4972277_x_9_5,\nCreate_rs2740566_Q_5.5,Yes_rs2740566_rs16905958_Q_7,No_rs2740566_rs875044_Q_6,Yes_rs16905958_rs12645079_Q_8.5,No_rs16905958_rs16870510_Q_1.5,Yes_rs875044_rs2415306_Q_8.5,No_rs875044_rs4648764_Q_6,Yes_rs12645079_x_9_5,No_rs12645079_x_7_5,Yes_rs16870510_rs6938518_Q_6,No_rs16870510_x_7_5,Yes_rs2415306_x_9_5,No_rs2415306_rs16863858_Q_1.5,Yes_rs4648764_x_7_5,No_rs4648764_x_9_5,Yes_rs6938518_rs6676442_Q_8.5,No_rs6938518_x_7_5,Yes_rs16863858_rs4314833_Q_8.5,No_rs16863858_x_9_5,Yes_rs6676442_x_9_5,No_rs6676442_x_7_5,Yes_rs4314833_x_9_5,No_rs4314833_x_7_5,\nCreate_rs6975220_Q_5.5,Yes_rs6975220_rs1005608_Q_8.5,No_rs6975220_rs10001947_Q_7,Yes_rs1005608_rs4431782_Q_6,No_rs1005608_rs17241648_Q_6,Yes_rs10001947_rs7874475_Q_5.5,No_rs10001947_rs11210640_Q_6,Yes_rs4431782_x_7_5,No_rs4431782_x_9_5,Yes_rs17241648_rs4310281_Q_2,No_rs17241648_x_9_5,Yes_rs7874475_rs28399555_Q_5.5,No_rs7874475_x_7_5,Yes_rs11210640_x_7_5,No_rs11210640_x_9_5,Yes_rs4310281_rs13288508_Q_8.5,No_rs4310281_x_9_5,Yes_rs28399555_x_7_5,No_rs28399555_x_9_5,Yes_rs13288508_x_7_5,No_rs13288508_x_9_5,\nCreate_rs6742013_Q_6,Yes_rs6742013_rs3103736_Q_6,No_rs6742013_rs1399357_Q_8.5,Yes_rs3103736_rs947347_Q_5.5,No_rs3103736_x_9_5,Yes_rs1399357_x_9_5,No_rs1399357_rs6731365_Q_2,Yes_rs947347_x_7_5,No_rs947347_x_9_5,Yes_rs6731365_rs7136627_Q_5.5,No_rs6731365_rs683966_Q_8.5,Yes_rs7136627_rs2341362_Q_8.5,No_rs7136627_rs11583332_Q_8.5,Yes_rs683966_rs12117343_Q_6,No_rs683966_x_9_5,Yes_rs2341362_x_9_5,No_rs2341362_x_7_5,Yes_rs11583332_x_9_5,No_rs11583332_x_7_5,Yes_rs12117343_x_7_5,No_rs12117343_x_9_5,\nCreate_rs7605229_Q_8.5,Yes_rs7605229_rs10792608_Q_2,No_rs7605229_rs1125954_Q_5.5,Yes_rs10792608_rs2061517_Q_2,No_rs10792608_x_9_5,Yes_rs1125954_rs12069909_Q_5.5,No_rs1125954_rs12145658_Q_8.5,Yes_rs2061517_rs17369470_Q_5.5,No_rs2061517_rs16886536_Q_5.5,Yes_rs12069909_x_7_5,No_rs12069909_x_9_5,Yes_rs12145658_x_7_5,No_rs12145658_x_9_5,Yes_rs17369470_x_9_5,No_rs17369470_rs6572913_Q_5.5,Yes_rs16886536_x_7_5,No_rs16886536_rs897469_Q_8.5,Yes_rs6572913_x_7_5,No_rs6572913_x_9_5,Yes_rs897469_x_9_5,No_rs897469_x_7_5,\nCreate_rs3806502_Q_8.5,Yes_rs3806502_rs6968676_Q_8.5,No_rs3806502_rs2359377_Q_6,Yes_rs6968676_rs3131972_Q_5.5,No_rs6968676_rs350130_Q_2,Yes_rs2359377_rs6697095_Q_9.5,No_rs2359377_rs2503701_Q_8.5,Yes_rs3131972_x_7_5,No_rs3131972_x_9_5,Yes_rs350130_rs6015825_Q_5.5,No_rs350130_rs4674632_Q_5.5,Yes_rs6697095_x_9_5,No_rs6697095_x_7_5,Yes_rs2503701_x_9_5,No_rs2503701_x_7_5,Yes_rs6015825_rs3820250_Q_9.5,No_rs6015825_rs2028723_Q_9.5,Yes_rs4674632_rs28625223_Q_8.5,No_rs4674632_x_7_5,Yes_rs3820250_x_7_5,No_rs3820250_x_9_5,Yes_rs2028723_x_7_5,No_rs2028723_rs16838922_Q_2.5,Yes_rs28625223_x_7_5,No_rs28625223_x_9_5,Yes_rs16838922_x_7_5,No_rs16838922_x_9_5,\nCreate_rs1411088_Q_2,Yes_rs1411088_rs6760326_Q_1.5,No_rs1411088_rs17082523_Q_5.5,Yes_rs6760326_rs985365_Q_8.5,No_rs6760326_rs7586145_Q_8.5,Yes_rs17082523_x_7_5,No_rs17082523_rs6556382_Q_6,Yes_rs985365_rs9697358_Q_2,No_rs985365_rs12722820_Q_8.5,Yes_rs7586145_x_7_5,No_rs7586145_x_9_5,Yes_rs6556382_rs11166028_Q_6,No_rs6556382_rs10910099_Q_3.5,Yes_rs9697358_x_9_5,No_rs9697358_x_7_5,Yes_rs12722820_x_9_5,No_rs12722820_x_7_5,Yes_rs11166028_rs16851168_Q_3.5,No_rs11166028_x_7_5,Yes_rs10910099_x_7_5,No_rs10910099_x_9_5,Yes_rs16851168_x_7_5,No_rs16851168_x_9_5,\nCreate_rs776746_Q_8.5,Yes_rs776746_rs11842930_Q_6,No_rs776746_rs2373262_Q_8.5,Yes_rs11842930_rs9948548_Q_5.5,No_rs11842930_rs1925704_Q_5.5,Yes_rs2373262_rs9660718_Q_7,No_rs2373262_rs1330684_Q_6,Yes_rs9948548_rs11190458_Q_1.5,No_rs9948548_x_7_5,Yes_rs1925704_x_9_5,No_rs1925704_x_7_5,Yes_rs9660718_x_7_5,No_rs9660718_rs7537756_Q_5.5,Yes_rs1330684_rs11176729_Q_8.5,No_rs1330684_x_9_5,Yes_rs11190458_x_7_5,No_rs11190458_rs6428392_Q_1.5,Yes_rs7537756_x_9_5,No_rs7537756_x_7_5,Yes_rs11176729_x_7_5,No_rs11176729_x_9_5,Yes_rs6428392_x_9_5,No_rs6428392_x_7_5,\nCreate_rs2054788_Q_2,Yes_rs2054788_rs7565410_Q_6,No_rs2054788_rs9832923_Q_5.5,Yes_rs7565410_rs316598_Q_6,No_rs7565410_rs4875671_Q_5.5,Yes_rs9832923_rs6681741_Q_8.5,No_rs9832923_rs17775439_Q_8.5,Yes_rs316598_rs704737_Q_8.5,No_rs316598_rs3002685_Q_2,Yes_rs4875671_x_7_5,No_rs4875671_rs1998759_Q_2,Yes_rs6681741_rs5001924_Q_8.5,No_rs6681741_x_7_5,Yes_rs17775439_x_9_5,No_rs17775439_x_7_5,Yes_rs704737_x_7_5,No_rs704737_x_9_5,Yes_rs3002685_x_7_5,No_rs3002685_x_9_5,Yes_rs1998759_x_7_5,No_rs1998759_x_9_5,Yes_rs5001924_x_7_5,No_rs5001924_x_9_5,\nCreate_rs6730036_Q_6,Yes_rs6730036_rs7094900_Q_8.5,No_rs6730036_rs4725499_Q_5.5,Yes_rs7094900_rs1534110_Q_8.5,No_rs7094900_rs2493214_Q_2,Yes_rs4725499_rs6696281_Q_6,No_rs4725499_rs2861641_Q_6,Yes_rs1534110_rs8177963_Q_2.5,No_rs1534110_rs10753376_Q_5.5,Yes_rs2493214_x_9_5,No_rs2493214_x_7_5,Yes_rs6696281_x_7_5,No_rs6696281_x_9_5,Yes_rs2861641_rs10965215_Q_2,No_rs2861641_rs11552172_Q_8.5,Yes_rs8177963_rs17048353_Q_5.5,No_rs8177963_x_7_5,Yes_rs10753376_x_9_5,No_rs10753376_x_7_5,Yes_rs10965215_x_9_5,No_rs10965215_x_7_5,Yes_rs11552172_x_7_5,No_rs11552172_x_9_5,Yes_rs17048353_x_7_5,No_rs17048353_rs7554078_Q_5.5,Yes_rs7554078_x_9_5,No_rs7554078_x_7_5,\nCreate_rs2237059_Q_8.5,Yes_rs2237059_rs11618950_Q_2,No_rs2237059_rs11203815_Q_7,Yes_rs11618950_x_7_5,No_rs11618950_rs7358097_Q_5.5,Yes_rs11203815_rs8027732_Q_2,No_rs11203815_rs9953932_Q_5.5,Yes_rs7358097_x_7_5,No_rs7358097_x_9_5,Yes_rs8027732_rs3935066_Q_2,No_rs8027732_rs9782908_Q_6,Yes_rs9953932_rs4651330_Q_1.5,No_rs9953932_rs2776822_Q_8.5,Yes_rs3935066_x_9_5,No_rs3935066_x_7_5,Yes_rs9782908_x_9_5,No_rs9782908_x_7_5,Yes_rs4651330_x_9_5,No_rs4651330_x_7_5,Yes_rs2776822_x_9_5,No_rs2776822_rs11260568_Q_5.5,Yes_rs11260568_x_9_5,No_rs11260568_x_7_5,\n";
//East Asian 47 trees
//std::string treeInfo = "Create_rs2860580_Q_5.5,Yes_rs2860580_rs16961283_Q_5.5,No_rs2860580_rs9603756_Q_6,Yes_rs16961283_rs2663018_Q_8.5,No_rs16961283_rs3765764_Q_5.5,Yes_rs9603756_rs4244129_Q_6,No_rs9603756_rs3117002_Q_2,Yes_rs2663018_x_6_5,No_rs2663018_rs6694632_Q_5.5,Yes_rs3765764_x_6_5,No_rs3765764_x_3_5,Yes_rs4244129_rs6671527_Q_2,No_rs4244129_x_6_5,Yes_rs3117002_rs1670357_Q_9.5,No_rs3117002_x_3_5,Yes_rs6694632_x_3_5,No_rs6694632_x_6_5,Yes_rs6671527_rs4654522_Q_7,No_rs6671527_x_6_5,Yes_rs1670357_rs1288503_Q_6,No_rs1670357_x_3_5,Yes_rs4654522_x_3_5,No_rs4654522_x_6_5,Yes_rs1288503_x_3_5,No_rs1288503_x_6_5,\nCreate_rs2975042_Q_9.5,Yes_rs2975042_rs1567074_Q_5.5,No_rs2975042_rs6901221_Q_1.5,Yes_rs1567074_rs1885865_Q_5.5,No_rs1567074_rs2663027_Q_8.5,Yes_rs6901221_rs7705687_Q_8.5,No_rs6901221_x_3_5,Yes_rs1885865_x_6_5,No_rs1885865_x_3_5,Yes_rs2663027_x_6_5,No_rs2663027_rs2465136_Q_6,Yes_rs7705687_rs982790_Q_6,No_rs7705687_rs11236209_Q_5.5,Yes_rs2465136_x_6_5,No_rs2465136_x_3_5,Yes_rs982790_x_6_5,No_rs982790_x_3_5,Yes_rs11236209_x_3_5,No_rs11236209_rs9562578_Q_5.5,Yes_rs9562578_x_3_5,No_rs9562578_rs2036564_Q_6,Yes_rs2036564_x_3_5,No_rs2036564_rs10494055_Q_8.5,Yes_rs10494055_x_3_5,No_rs10494055_x_6_5,\nCreate_rs12698186_Q_2,Yes_rs12698186_rs1184774_Q_5.5,No_rs12698186_rs7503887_Q_8.5,Yes_rs1184774_rs12104625_Q_8.5,No_rs1184774_rs3889723_Q_6,Yes_rs7503887_rs4937070_Q_6,No_rs7503887_rs1074739_Q_3.5,Yes_rs12104625_rs13014047_Q_5.5,No_rs12104625_x_6_5,Yes_rs3889723_x_6_5,No_rs3889723_x_3_5,Yes_rs4937070_x_6_5,No_rs4937070_rs1887284_Q_2,Yes_rs1074739_rs12085319_Q_8.5,No_rs1074739_rs10933005_Q_2,Yes_rs13014047_rs7523549_Q_8.5,No_rs13014047_x_6_5,Yes_rs1887284_x_6_5,No_rs1887284_x_3_5,Yes_rs12085319_x_6_5,No_rs12085319_x_3_5,Yes_rs10933005_x_3_5,No_rs10933005_rs12124819_Q_2,Yes_rs7523549_x_3_5,No_rs7523549_x_6_5,Yes_rs12124819_x_6_5,No_rs12124819_x_3_5,\nCreate_rs4939526_Q_6,Yes_rs4939526_rs17385747_Q_2,No_rs4939526_rs12023372_Q_5.5,Yes_rs17385747_rs931250_Q_8.5,No_rs17385747_rs412763_Q_8.5,Yes_rs12023372_x_3_5,No_rs12023372_x_6_5,Yes_rs931250_rs3771848_Q_9.5,No_rs931250_x_6_5,Yes_rs412763_x_3_5,No_rs412763_x_6_5,Yes_rs3771848_x_6_5,No_rs3771848_rs12295314_Q_2,Yes_rs12295314_rs6927568_Q_5.5,No_rs12295314_x_6_5,Yes_rs6927568_x_6_5,No_rs6927568_rs6860288_Q_6,Yes_rs6860288_rs11804222_Q_2,No_rs6860288_x_6_5,Yes_rs11804222_x_6_5,No_rs11804222_x_3_5,\nCreate_rs11974206_Q_7,Yes_rs11974206_rs16843306_Q_5.5,No_rs11974206_rs2838699_Q_6,Yes_rs16843306_rs178932_Q_5.5,No_rs16843306_rs17040351_Q_2,Yes_rs2838699_rs17207681_Q_2,No_rs2838699_rs13251780_Q_6,Yes_rs178932_x_3_5,No_rs178932_x_6_5,Yes_rs17040351_rs1535682_Q_9.5,No_rs17040351_x_3_5,Yes_rs17207681_rs2072978_Q_5.5,No_rs17207681_rs2275819_Q_5.5,Yes_rs13251780_x_6_5,No_rs13251780_x_3_5,Yes_rs1535682_rs17398063_Q_5.5,No_rs1535682_rs904927_Q_6,Yes_rs2072978_x_6_5,No_rs2072978_rs2682107_Q_2,Yes_rs2275819_x_6_5,No_rs2275819_x_3_5,Yes_rs17398063_x_3_5,No_rs17398063_x_6_5,Yes_rs904927_x_3_5,No_rs904927_x_6_5,Yes_rs2682107_x_6_5,No_rs2682107_x_3_5,\nCreate_rs11104947_Q_5.5,Yes_rs11104947_rs3130244_Q_3.5,No_rs11104947_rs9600325_Q_8.5,Yes_rs3130244_rs1498016_Q_3.5,No_rs3130244_rs9549215_Q_7,Yes_rs9600325_x_6_5,No_rs9600325_rs17029445_Q_6,Yes_rs1498016_rs6699975_Q_1.5,No_rs1498016_x_3_5,Yes_rs9549215_rs11260542_Q_5.5,No_rs9549215_x_6_5,Yes_rs17029445_rs7760235_Q_7,No_rs17029445_x_6_5,Yes_rs6699975_x_3_5,No_rs6699975_x_6_5,Yes_rs11260542_x_3_5,No_rs11260542_x_6_5,Yes_rs7760235_x_6_5,No_rs7760235_rs9901316_Q_5.5,Yes_rs9901316_rs770698_Q_7,No_rs9901316_rs41471147_Q_5.5,Yes_rs770698_x_6_5,No_rs770698_x_3_5,Yes_rs41471147_x_6_5,No_rs41471147_rs3785624_Q_5.5,Yes_rs3785624_x_6_5,No_rs3785624_x_3_5,\nCreate_rs11224783_Q_3.5,Yes_rs11224783_rs9970652_Q_8.5,No_rs11224783_rs10508158_Q_6,Yes_rs9970652_x_6_5,No_rs9970652_x_3_5,Yes_rs10508158_rs9530164_Q_2,No_rs10508158_rs2133620_Q_3.5,Yes_rs9530164_rs17471932_Q_5.5,No_rs9530164_x_6_5,Yes_rs2133620_rs10924366_Q_6,No_rs2133620_rs2439292_Q_5.5,Yes_rs17471932_rs1107910_Q_8.5,No_rs17471932_rs946617_Q_9.5,Yes_rs10924366_x_6_5,No_rs10924366_x_3_5,Yes_rs2439292_x_3_5,No_rs2439292_rs9729550_Q_1.5,Yes_rs1107910_x_6_5,No_rs1107910_x_3_5,Yes_rs946617_x_6_5,No_rs946617_rs6732743_Q_2,Yes_rs9729550_x_3_5,No_rs9729550_x_6_5,Yes_rs6732743_rs17120485_Q_5.5,No_rs6732743_x_6_5,Yes_rs17120485_x_6_5,No_rs17120485_x_3_5,\nCreate_rs3217805_Q_5.5,Yes_rs3217805_rs17633478_Q_2,No_rs3217805_rs3130235_Q_5.5,Yes_rs17633478_rs16947802_Q_3.5,No_rs17633478_x_6_5,Yes_rs3130235_x_3_5,No_rs3130235_rs6886932_Q_5.5,Yes_rs16947802_x_6_5,No_rs16947802_rs7935178_Q_2,Yes_rs6886932_x_3_5,No_rs6886932_x_6_5,Yes_rs7935178_rs17676033_Q_6,No_rs7935178_x_6_5,Yes_rs17676033_rs4840510_Q_5.5,No_rs17676033_x_6_5,Yes_rs4840510_rs662353_Q_5.5,No_rs4840510_x_6_5,Yes_rs662353_rs11677624_Q_2,No_rs662353_x_6_5,Yes_rs11677624_x_6_5,No_rs11677624_x_3_5,\nCreate_rs11224762_Q_2.5,Yes_rs11224762_rs13064974_Q_8.5,No_rs11224762_rs717187_Q_5.5,Yes_rs13064974_rs2465126_Q_2,No_rs13064974_rs12788223_Q_8.5,Yes_rs717187_x_3_5,No_rs717187_rs12063386_Q_8.5,Yes_rs2465126_x_6_5,No_rs2465126_x_3_5,Yes_rs12788223_rs1780160_Q_6,No_rs12788223_rs12080410_Q_7,Yes_rs12063386_rs12034613_Q_5.5,No_rs12063386_x_3_5,Yes_rs1780160_rs2209831_Q_6,No_rs1780160_x_6_5,Yes_rs12080410_x_6_5,No_rs12080410_x_3_5,Yes_rs12034613_x_3_5,No_rs12034613_x_6_5,Yes_rs2209831_rs10244477_Q_8.5,No_rs2209831_x_6_5,Yes_rs10244477_x_6_5,No_rs10244477_rs4654354_Q_6,Yes_rs4654354_rs12740262_Q_5.5,No_rs4654354_x_6_5,Yes_rs12740262_x_3_5,No_rs12740262_x_6_5,\nCreate_rs11224765_Q_6,Yes_rs11224765_rs7626152_Q_8.5,No_rs11224765_rs10765099_Q_2,Yes_rs7626152_rs10910061_Q_2,No_rs7626152_rs11034713_Q_3.5,Yes_rs10765099_x_3_5,No_rs10765099_rs6971267_Q_5.5,Yes_rs10910061_x_3_5,No_rs10910061_x_6_5,Yes_rs11034713_rs10927559_Q_9.5,No_rs11034713_rs3756531_Q_7,Yes_rs6971267_x_3_5,No_rs6971267_x_6_5,Yes_rs10927559_x_6_5,No_rs10927559_x_3_5,Yes_rs3756531_x_6_5,No_rs3756531_rs10496977_Q_8.5,Yes_rs10496977_x_6_5,No_rs10496977_rs12480230_Q_8.5,Yes_rs12480230_rs6926826_Q_2,No_rs12480230_x_6_5,Yes_rs6926826_rs2119320_Q_8.5,No_rs6926826_x_6_5,Yes_rs2119320_x_3_5,No_rs2119320_x_6_5,\nCreate_rs1490742_Q_8.5,Yes_rs1490742_rs1891275_Q_6,No_rs1490742_rs6779452_Q_5.5,Yes_rs1891275_rs10017946_Q_6,No_rs1891275_rs13387193_Q_8.5,Yes_rs6779452_rs7540486_Q_6,No_rs6779452_rs1407448_Q_5.5,Yes_rs10017946_rs6668819_Q_8.5,No_rs10017946_rs13085028_Q_8.5,Yes_rs13387193_rs4490524_Q_8.5,No_rs13387193_x_6_5,Yes_rs7540486_x_3_5,No_rs7540486_x_6_5,Yes_rs1407448_x_6_5,No_rs1407448_rs16850259_Q_8.5,Yes_rs6668819_x_3_5,No_rs6668819_x_6_5,Yes_rs13085028_x_3_5,No_rs13085028_rs7213911_Q_2,Yes_rs4490524_x_3_5,No_rs4490524_x_6_5,Yes_rs16850259_x_6_5,No_rs16850259_x_3_5,Yes_rs7213911_rs4648468_Q_5.5,No_rs7213911_x_3_5,Yes_rs4648468_x_3_5,No_rs4648468_x_6_5,\nCreate_rs2261033_Q_5.5,Yes_rs2261033_rs7122010_Q_6,No_rs2261033_rs1351499_Q_5.5,Yes_rs7122010_rs615625_Q_1.5,No_rs7122010_rs2840531_Q_8.5,Yes_rs1351499_rs10013441_Q_8.5,No_rs1351499_rs2499714_Q_8.5,Yes_rs615625_rs2388746_Q_2,No_rs615625_rs10915307_Q_2,Yes_rs2840531_x_6_5,No_rs2840531_x_3_5,Yes_rs10013441_x_6_5,No_rs10013441_rs2651902_Q_6,Yes_rs2499714_rs7859023_Q_5.5,No_rs2499714_x_3_5,Yes_rs2388746_x_6_5,No_rs2388746_rs9497981_Q_2,Yes_rs10915307_x_3_5,No_rs10915307_x_6_5,Yes_rs2651902_x_3_5,No_rs2651902_x_6_5,Yes_rs7859023_x_6_5,No_rs7859023_x_3_5,Yes_rs9497981_rs10159030_Q_5.5,No_rs9497981_x_6_5,Yes_rs10159030_x_6_5,No_rs10159030_x_3_5,\nCreate_rs10865278_Q_5.5,Yes_rs10865278_rs2961739_Q_8.5,No_rs10865278_rs11223548_Q_8.5,Yes_rs2961739_rs27433_Q_9.5,No_rs2961739_rs6018084_Q_5.5,Yes_rs11223548_rs2275595_Q_5.5,No_rs11223548_rs608210_Q_2,Yes_rs27433_rs13042833_Q_8.5,No_rs27433_rs12073172_Q_5.5,Yes_rs6018084_x_6_5,No_rs6018084_rs12403351_Q_5.5,Yes_rs2275595_x_6_5,No_rs2275595_rs13322517_Q_2,Yes_rs608210_x_3_5,No_rs608210_x_6_5,Yes_rs13042833_rs379717_Q_8.5,No_rs13042833_x_3_5,Yes_rs12073172_x_3_5,No_rs12073172_x_6_5,Yes_rs12403351_x_6_5,No_rs12403351_x_3_5,Yes_rs13322517_rs12467106_Q_5.5,No_rs13322517_x_6_5,Yes_rs379717_x_3_5,No_rs379717_rs6581191_Q_2,Yes_rs12467106_x_6_5,No_rs12467106_x_3_5,Yes_rs6581191_x_3_5,No_rs6581191_x_6_5,\nCreate_rs9530168_Q_5.5,Yes_rs9530168_rs2794860_Q_6,No_rs9530168_rs9497982_Q_2,Yes_rs2794860_x_3_5,No_rs2794860_x_6_5,Yes_rs9497982_rs17137253_Q_2,No_rs9497982_x_6_5,Yes_rs17137253_rs12532805_Q_8.5,No_rs17137253_x_6_5,Yes_rs12532805_rs6717406_Q_9.5,No_rs12532805_rs10954494_Q_2,Yes_rs6717406_x_6_5,No_rs6717406_rs10803583_Q_3.5,Yes_rs10954494_x_3_5,No_rs10954494_x_6_5,Yes_rs10803583_x_6_5,No_rs10803583_rs11563201_Q_6,Yes_rs11563201_rs11586974_Q_8.5,No_rs11563201_x_6_5,Yes_rs11586974_x_3_5,No_rs11586974_x_6_5,\nCreate_rs1508594_Q_8.5,Yes_rs1508594_rs12615002_Q_6,No_rs1508594_rs770576_Q_2,Yes_rs12615002_rs211605_Q_5.5,No_rs12615002_rs3768337_Q_2,Yes_rs770576_rs13203813_Q_6,No_rs770576_rs17069519_Q_3.5,Yes_rs211605_rs11254106_Q_5.5,No_rs211605_x_3_5,Yes_rs3768337_x_3_5,No_rs3768337_x_6_5,Yes_rs13203813_rs16968045_Q_5.5,No_rs13203813_x_6_5,Yes_rs17069519_x_3_5,No_rs17069519_x_6_5,Yes_rs11254106_x_3_5,No_rs11254106_x_6_5,Yes_rs16968045_x_6_5,No_rs16968045_rs12219674_Q_8.5,Yes_rs12219674_x_6_5,No_rs12219674_rs4637726_Q_2,Yes_rs4637726_x_3_5,No_rs4637726_x_6_5,\nCreate_rs10176837_Q_2.5,Yes_rs10176837_rs313243_Q_2,No_rs10176837_rs7985210_Q_9.5,Yes_rs313243_rs11224773_Q_2,No_rs313243_x_6_5,Yes_rs7985210_x_3_5,No_rs7985210_x_6_5,Yes_rs11224773_rs1817653_Q_5.5,No_rs11224773_rs7832879_Q_5.5,Yes_rs1817653_rs4648745_Q_6,No_rs1817653_rs3809250_Q_1.5,Yes_rs7832879_rs4648782_Q_5.5,No_rs7832879_x_3_5,Yes_rs4648745_x_3_5,No_rs4648745_x_6_5,Yes_rs3809250_rs17783275_Q_5.5,No_rs3809250_x_6_5,Yes_rs4648782_x_3_5,No_rs4648782_x_6_5,Yes_rs17783275_x_6_5,No_rs17783275_rs667907_Q_5.5,Yes_rs667907_rs2298225_Q_1.5,No_rs667907_x_6_5,Yes_rs2298225_x_6_5,No_rs2298225_x_3_5,\nCreate_rs7644875_Q_2,Yes_rs7644875_rs17799178_Q_2,No_rs7644875_rs16823350_Q_2,Yes_rs17799178_rs17286171_Q_6,No_rs17799178_rs1994851_Q_5.5,Yes_rs16823350_x_3_5,No_rs16823350_x_6_5,Yes_rs17286171_rs12136921_Q_5.5,No_rs17286171_rs2092595_Q_3.5,Yes_rs1994851_x_3_5,No_rs1994851_rs1749951_Q_2,Yes_rs12136921_rs4074197_Q_2,No_rs12136921_rs17150469_Q_6,Yes_rs2092595_x_6_5,No_rs2092595_x_3_5,Yes_rs1749951_x_3_5,No_rs1749951_x_6_5,Yes_rs4074197_x_6_5,No_rs4074197_x_3_5,Yes_rs17150469_rs11703828_Q_6,No_rs17150469_x_6_5,Yes_rs11703828_rs1222144_Q_2,No_rs11703828_x_6_5,Yes_rs1222144_rs9504229_Q_6,No_rs1222144_x_6_5,Yes_rs9504229_x_3_5,No_rs9504229_x_6_5,\nCreate_rs41385746_Q_6,Yes_rs41385746_rs7928922_Q_6,No_rs41385746_rs9379827_Q_3.5,Yes_rs7928922_rs10849181_Q_8.5,No_rs7928922_rs7544659_Q_2,Yes_rs9379827_rs7640543_Q_5.5,No_rs9379827_rs3088182_Q_6,Yes_rs10849181_rs10493770_Q_6,No_rs10849181_rs6656160_Q_2,Yes_rs7544659_x_3_5,No_rs7544659_x_6_5,Yes_rs7640543_x_6_5,No_rs7640543_x_3_5,Yes_rs3088182_rs7219975_Q_2,No_rs3088182_rs2390135_Q_8.5,Yes_rs10493770_x_6_5,No_rs10493770_rs12092254_Q_2,Yes_rs6656160_x_3_5,No_rs6656160_x_6_5,Yes_rs7219975_x_3_5,No_rs7219975_rs7547028_Q_2,Yes_rs2390135_x_6_5,No_rs2390135_rs13129_Q_6,Yes_rs12092254_x_6_5,No_rs12092254_x_3_5,Yes_rs7547028_rs2645072_Q_1.5,No_rs7547028_x_3_5,Yes_rs13129_x_3_5,No_rs13129_x_6_5,Yes_rs2645072_x_3_5,No_rs2645072_x_6_5,\nCreate_rs12697189_Q_6,Yes_rs12697189_rs7935581_Q_2,No_rs12697189_rs9277027_Q_2,Yes_rs7935581_rs2224609_Q_2,No_rs7935581_rs12027396_Q_8.5,Yes_rs9277027_rs4935640_Q_3.5,No_rs9277027_rs8135343_Q_2,Yes_rs2224609_rs4755957_Q_8.5,No_rs2224609_rs10910017_Q_2,Yes_rs12027396_x_3_5,No_rs12027396_x_6_5,Yes_rs4935640_x_3_5,No_rs4935640_x_6_5,Yes_rs8135343_x_3_5,No_rs8135343_x_6_5,Yes_rs4755957_x_6_5,No_rs4755957_rs13392175_Q_9.5,Yes_rs10910017_x_3_5,No_rs10910017_x_6_5,Yes_rs13392175_rs11120989_Q_2,No_rs13392175_rs11770368_Q_2,Yes_rs11120989_x_6_5,No_rs11120989_x_3_5,Yes_rs11770368_x_3_5,No_rs11770368_x_6_5,\nCreate_rs6436971_Q_8.5,Yes_rs6436971_rs953184_Q_3.5,No_rs6436971_rs12765118_Q_5.5,Yes_rs953184_x_3_5,No_rs953184_rs28414855_Q_1.5,Yes_rs12765118_rs1883472_Q_6,No_rs12765118_rs7378826_Q_9.5,Yes_rs28414855_x_3_5,No_rs28414855_x_6_5,Yes_rs1883472_rs10915396_Q_6,No_rs1883472_rs11132199_Q_6,Yes_rs7378826_rs16824860_Q_8.5,No_rs7378826_rs34136796_Q_3.5,Yes_rs10915396_x_6_5,No_rs10915396_x_3_5,Yes_rs11132199_x_3_5,No_rs11132199_x_6_5,Yes_rs16824860_x_6_5,No_rs16824860_x_3_5,Yes_rs34136796_rs4654468_Q_6,No_rs34136796_rs333851_Q_2,Yes_rs4654468_x_3_5,No_rs4654468_x_6_5,Yes_rs333851_rs17599139_Q_5.5,No_rs333851_x_6_5,Yes_rs17599139_x_6_5,No_rs17599139_rs17389948_Q_8.5,Yes_rs17389948_x_3_5,No_rs17389948_x_6_5,\nCreate_rs360710_Q_5.5,Yes_rs360710_rs12036857_Q_7,No_rs360710_rs12658762_Q_8.5,Yes_rs12036857_x_6_5,No_rs12036857_x_3_5,Yes_rs12658762_rs16957364_Q_8.5,No_rs12658762_rs4298263_Q_2,Yes_rs16957364_rs7512482_Q_6,No_rs16957364_rs3739477_Q_7,Yes_rs4298263_rs1376444_Q_6,No_rs4298263_rs7537756_Q_2,Yes_rs7512482_x_3_5,No_rs7512482_x_6_5,Yes_rs3739477_x_6_5,No_rs3739477_rs1288742_Q_5.5,Yes_rs1376444_rs17358956_Q_1.5,No_rs1376444_x_3_5,Yes_rs7537756_x_3_5,No_rs7537756_x_6_5,Yes_rs1288742_rs17737466_Q_6,No_rs1288742_x_6_5,Yes_rs17358956_x_6_5,No_rs17358956_x_3_5,Yes_rs17737466_rs1845017_Q_5.5,No_rs17737466_x_6_5,Yes_rs1845017_rs11126130_Q_2.5,No_rs1845017_x_6_5,Yes_rs11126130_x_3_5,No_rs11126130_x_6_5,\nCreate_rs3749946_Q_3.5,Yes_rs3749946_rs321125_Q_5.5,No_rs3749946_rs17140182_Q_2,Yes_rs321125_rs7512133_Q_5.5,No_rs321125_rs11120837_Q_8.5,Yes_rs17140182_rs1569307_Q_5.5,No_rs17140182_rs10797386_Q_2,Yes_rs7512133_x_6_5,No_rs7512133_x_3_5,Yes_rs11120837_x_3_5,No_rs11120837_x_6_5,Yes_rs1569307_rs919688_Q_2,No_rs1569307_rs191708_Q_2,Yes_rs10797386_x_3_5,No_rs10797386_x_6_5,Yes_rs919688_x_6_5,No_rs919688_x_3_5,Yes_rs191708_rs12006467_Q_8.5,No_rs191708_x_6_5,Yes_rs12006467_x_6_5,No_rs12006467_rs914958_Q_2,Yes_rs914958_rs828316_Q_2,No_rs914958_x_6_5,Yes_rs828316_x_6_5,No_rs828316_x_3_5,\nCreate_rs13414393_Q_6,Yes_rs13414393_rs10895109_Q_6,No_rs13414393_rs353887_Q_8.5,Yes_rs10895109_rs7918954_Q_6,No_rs10895109_rs4652992_Q_8.5,Yes_rs353887_rs4298709_Q_5.5,No_rs353887_rs1998759_Q_2,Yes_rs7918954_rs7563543_Q_5.5,No_rs7918954_x_6_5,Yes_rs4652992_x_3_5,No_rs4652992_x_6_5,Yes_rs4298709_rs10804925_Q_2,No_rs4298709_rs3815073_Q_8.5,Yes_rs1998759_x_6_5,No_rs1998759_x_3_5,Yes_rs7563543_x_6_5,No_rs7563543_rs17854636_Q_6,Yes_rs10804925_x_6_5,No_rs10804925_rs2379143_Q_6,Yes_rs3815073_rs284243_Q_2,No_rs3815073_rs31300_Q_6,Yes_rs17854636_x_3_5,No_rs17854636_x_6_5,Yes_rs2379143_x_6_5,No_rs2379143_x_3_5,Yes_rs284243_x_3_5,No_rs284243_x_6_5,Yes_rs31300_x_3_5,No_rs31300_x_6_5,\nCreate_rs6562748_Q_1.5,Yes_rs6562748_rs4571809_Q_9.5,No_rs6562748_rs10060821_Q_8.5,Yes_rs4571809_rs6737431_Q_2,No_rs4571809_rs7640145_Q_2,Yes_rs10060821_x_6_5,No_rs10060821_x_3_5,Yes_rs6737431_rs342136_Q_6,No_rs6737431_rs582322_Q_8.5,Yes_rs7640145_rs3930233_Q_8.5,No_rs7640145_x_6_5,Yes_rs342136_rs4131141_Q_6,No_rs342136_rs6665000_Q_1.5,Yes_rs582322_x_6_5,No_rs582322_x_3_5,Yes_rs3930233_rs4455137_Q_5.5,No_rs3930233_rs4646329_Q_6,Yes_rs4131141_x_3_5,No_rs4131141_x_6_5,Yes_rs6665000_x_6_5,No_rs6665000_x_3_5,Yes_rs4455137_x_6_5,No_rs4455137_x_3_5,Yes_rs4646329_rs3893319_Q_2,No_rs4646329_x_6_5,Yes_rs3893319_x_3_5,No_rs3893319_x_6_5,\nCreate_rs11841589_Q_8.5,Yes_rs11841589_rs4707130_Q_2,No_rs11841589_rs6605005_Q_8.5,Yes_rs4707130_rs17680606_Q_5.5,No_rs4707130_rs10910029_Q_2,Yes_rs6605005_x_3_5,No_rs6605005_x_6_5,Yes_rs17680606_rs9328202_Q_3.5,No_rs17680606_rs4580387_Q_2,Yes_rs10910029_x_3_5,No_rs10910029_x_6_5,Yes_rs9328202_x_6_5,No_rs9328202_rs11013746_Q_6,Yes_rs4580387_x_3_5,No_rs4580387_x_6_5,Yes_rs11013746_rs10858363_Q_6,No_rs11013746_rs9442387_Q_6,Yes_rs10858363_rs16978159_Q_8.5,No_rs10858363_x_6_5,Yes_rs9442387_x_6_5,No_rs9442387_x_3_5,Yes_rs16978159_x_6_5,No_rs16978159_rs182532_Q_8.5,Yes_rs182532_x_3_5,No_rs182532_x_6_5,\nCreate_rs3130237_Q_8.5,Yes_rs3130237_rs2765015_Q_2,No_rs3130237_rs12104489_Q_9.5,Yes_rs2765015_x_6_5,No_rs2765015_x_3_5,Yes_rs12104489_rs6940237_Q_6,No_rs12104489_rs2298464_Q_5.5,Yes_rs6940237_rs6564809_Q_2,No_rs6940237_rs12748433_Q_5.5,Yes_rs2298464_rs16933163_Q_2,No_rs2298464_rs11016442_Q_8.5,Yes_rs6564809_x_3_5,No_rs6564809_rs1369407_Q_6,Yes_rs12748433_x_3_5,No_rs12748433_x_6_5,Yes_rs16933163_x_6_5,No_rs16933163_x_3_5,Yes_rs11016442_x_6_5,No_rs11016442_rs315808_Q_9.5,Yes_rs1369407_x_3_5,No_rs1369407_rs4233033_Q_8.5,Yes_rs315808_x_6_5,No_rs315808_rs6420051_Q_6,Yes_rs4233033_x_6_5,No_rs4233033_x_3_5,Yes_rs6420051_x_6_5,No_rs6420051_x_3_5,\nCreate_rs3116996_Q_7,Yes_rs3116996_rs2291889_Q_2,No_rs3116996_rs2920297_Q_2,Yes_rs2291889_x_6_5,No_rs2291889_x_3_5,Yes_rs2920297_rs443592_Q_1.5,No_rs2920297_rs11959012_Q_6,Yes_rs443592_rs217656_Q_6,No_rs443592_rs4920386_Q_2.5,Yes_rs11959012_rs1791466_Q_5.5,No_rs11959012_rs17649182_Q_6,Yes_rs217656_rs28710181_Q_8.5,No_rs217656_x_6_5,Yes_rs4920386_x_6_5,No_rs4920386_x_3_5,Yes_rs1791466_rs16839450_Q_6,No_rs1791466_rs17561133_Q_8.5,Yes_rs17649182_x_3_5,No_rs17649182_rs2298217_Q_6,Yes_rs28710181_x_3_5,No_rs28710181_x_6_5,Yes_rs16839450_x_6_5,No_rs16839450_x_3_5,Yes_rs17561133_x_3_5,No_rs17561133_rs1999462_Q_8.5,Yes_rs2298217_x_3_5,No_rs2298217_x_6_5,Yes_rs1999462_x_6_5,No_rs1999462_x_3_5,\nCreate_rs6901830_Q_5.5,Yes_rs6901830_rs11488462_Q_5.5,No_rs6901830_rs2976392_Q_5.5,Yes_rs11488462_x_3_5,No_rs11488462_x_6_5,Yes_rs2976392_rs1960425_Q_8.5,No_rs2976392_rs9518309_Q_2,Yes_rs1960425_rs375980_Q_8.5,No_rs1960425_rs10460504_Q_6,Yes_rs9518309_rs10500071_Q_8.5,No_rs9518309_x_6_5,Yes_rs375980_rs11585587_Q_2,No_rs375980_x_6_5,Yes_rs10460504_rs8181588_Q_8.5,No_rs10460504_rs7995074_Q_5.5,Yes_rs10500071_rs4926684_Q_2,No_rs10500071_x_6_5,Yes_rs11585587_x_6_5,No_rs11585587_x_3_5,Yes_rs8181588_rs7203853_Q_5.5,No_rs8181588_x_3_5,Yes_rs7995074_x_3_5,No_rs7995074_x_6_5,Yes_rs4926684_x_6_5,No_rs4926684_x_3_5,Yes_rs7203853_x_3_5,No_rs7203853_x_6_5,\nCreate_rs4662280_Q_3.5,Yes_rs4662280_rs16895223_Q_5.5,No_rs4662280_rs1349283_Q_6,Yes_rs16895223_rs6833864_Q_8.5,No_rs16895223_rs12119711_Q_6,Yes_rs1349283_rs7244157_Q_3.5,No_rs1349283_rs662009_Q_7,Yes_rs6833864_x_3_5,No_rs6833864_rs13160949_Q_8.5,Yes_rs12119711_x_3_5,No_rs12119711_x_6_5,Yes_rs7244157_rs6694834_Q_6,No_rs7244157_rs4648805_Q_5.5,Yes_rs662009_x_6_5,No_rs662009_rs2503823_Q_1.5,Yes_rs13160949_rs1275569_Q_5.5,No_rs13160949_rs6844821_Q_5.5,Yes_rs6694834_x_6_5,No_rs6694834_x_3_5,Yes_rs4648805_x_6_5,No_rs4648805_x_3_5,Yes_rs2503823_rs12755560_Q_2,No_rs2503823_x_6_5,Yes_rs1275569_x_3_5,No_rs1275569_x_6_5,Yes_rs6844821_x_3_5,No_rs6844821_x_6_5,Yes_rs12755560_x_6_5,No_rs12755560_x_3_5,\nCreate_rs374722_Q_2,Yes_rs374722_rs485276_Q_3.5,No_rs374722_rs2418268_Q_6,Yes_rs485276_x_6_5,No_rs485276_rs2272052_Q_8.5,Yes_rs2418268_rs11580074_Q_5.5,No_rs2418268_rs12254574_Q_5.5,Yes_rs2272052_x_6_5,No_rs2272052_rs17221329_Q_5.5,Yes_rs11580074_rs3935066_Q_5.5,No_rs11580074_rs2199215_Q_8.5,Yes_rs12254574_rs2651929_Q_8.5,No_rs12254574_rs478611_Q_5.5,Yes_rs17221329_rs10932401_Q_7,No_rs17221329_x_6_5,Yes_rs3935066_x_6_5,No_rs3935066_x_3_5,Yes_rs2199215_x_3_5,No_rs2199215_x_6_5,Yes_rs2651929_x_3_5,No_rs2651929_x_6_5,Yes_rs478611_x_3_5,No_rs478611_rs710139_Q_8.5,Yes_rs10932401_rs17033865_Q_7,No_rs10932401_x_6_5,Yes_rs710139_rs760925_Q_2,No_rs710139_x_3_5,Yes_rs17033865_x_6_5,No_rs17033865_x_3_5,Yes_rs760925_x_3_5,No_rs760925_x_6_5,\nCreate_rs11104775_Q_6,Yes_rs11104775_rs174511_Q_5.5,No_rs11104775_rs17033938_Q_2,Yes_rs174511_rs1355781_Q_8.5,No_rs174511_rs3777997_Q_2,Yes_rs17033938_rs4648807_Q_6,No_rs17033938_rs10408164_Q_5.5,Yes_rs1355781_rs620950_Q_5.5,No_rs1355781_x_3_5,Yes_rs3777997_rs871952_Q_5.5,No_rs3777997_x_6_5,Yes_rs4648807_x_6_5,No_rs4648807_x_3_5,Yes_rs10408164_x_3_5,No_rs10408164_rs1011609_Q_2,Yes_rs620950_x_6_5,No_rs620950_x_3_5,Yes_rs871952_x_6_5,No_rs871952_rs566105_Q_8.5,Yes_rs1011609_x_3_5,No_rs1011609_rs11466691_Q_8.5,Yes_rs566105_rs17075791_Q_8.5,No_rs566105_x_6_5,Yes_rs11466691_x_3_5,No_rs11466691_x_6_5,Yes_rs17075791_x_6_5,No_rs17075791_rs1841241_Q_5.5,Yes_rs1841241_x_3_5,No_rs1841241_x_6_5,\nCreate_rs4525889_Q_6,Yes_rs4525889_rs9328204_Q_2,No_rs4525889_rs10843585_Q_6,Yes_rs9328204_rs8016966_Q_5.5,No_rs9328204_rs1926883_Q_5.5,Yes_rs10843585_rs3762084_Q_6,No_rs10843585_rs3820330_Q_3.5,Yes_rs8016966_rs9502295_Q_7,No_rs8016966_rs6695131_Q_8.5,Yes_rs1926883_x_6_5,No_rs1926883_x_3_5,Yes_rs3762084_rs2455107_Q_8.5,No_rs3762084_rs4040604_Q_8.5,Yes_rs3820330_rs10909872_Q_9.5,No_rs3820330_x_3_5,Yes_rs9502295_x_6_5,No_rs9502295_rs1955614_Q_8.5,Yes_rs6695131_x_6_5,No_rs6695131_x_3_5,Yes_rs2455107_x_3_5,No_rs2455107_x_6_5,Yes_rs4040604_x_6_5,No_rs4040604_x_3_5,Yes_rs10909872_x_3_5,No_rs10909872_x_6_5,Yes_rs1955614_x_6_5,No_rs1955614_rs10512019_Q_8.5,Yes_rs10512019_x_6_5,No_rs10512019_x_3_5,\nCreate_rs10073882_Q_8.5,Yes_rs10073882_rs1250544_Q_2,No_rs10073882_rs12534948_Q_5.5,Yes_rs1250544_x_3_5,No_rs1250544_rs3737728_Q_2,Yes_rs12534948_rs7235487_Q_8.5,No_rs12534948_rs1869609_Q_5.5,Yes_rs3737728_x_3_5,No_rs3737728_x_6_5,Yes_rs7235487_rs6603781_Q_5.5,No_rs7235487_rs2277317_Q_2,Yes_rs1869609_x_6_5,No_rs1869609_x_3_5,Yes_rs6603781_x_3_5,No_rs6603781_x_6_5,Yes_rs2277317_rs1900102_Q_8.5,No_rs2277317_rs11707193_Q_1.5,Yes_rs1900102_x_3_5,No_rs1900102_x_6_5,Yes_rs11707193_rs603638_Q_5.5,No_rs11707193_x_6_5,Yes_rs603638_x_6_5,No_rs603638_rs863454_Q_1.5,Yes_rs863454_x_6_5,No_rs863454_x_3_5,\nCreate_rs2622637_Q_9.5,Yes_rs2622637_rs12532116_Q_7,No_rs2622637_rs946236_Q_5.5,Yes_rs12532116_rs12547611_Q_5.5,No_rs12532116_rs10168169_Q_8.5,Yes_rs946236_rs2382019_Q_2,No_rs946236_rs1687331_Q_2,Yes_rs12547611_rs751396_Q_6,No_rs12547611_rs13084153_Q_8.5,Yes_rs10168169_rs319870_Q_5.5,No_rs10168169_x_6_5,Yes_rs2382019_rs164868_Q_6,No_rs2382019_rs1914778_Q_2,Yes_rs1687331_x_3_5,No_rs1687331_x_6_5,Yes_rs751396_x_3_5,No_rs751396_x_6_5,Yes_rs13084153_rs17028725_Q_2,No_rs13084153_x_6_5,Yes_rs319870_rs17036706_Q_9.5,No_rs319870_x_6_5,Yes_rs164868_x_6_5,No_rs164868_x_3_5,Yes_rs1914778_x_3_5,No_rs1914778_x_6_5,Yes_rs17028725_x_3_5,No_rs17028725_x_6_5,Yes_rs17036706_x_3_5,No_rs17036706_x_6_5,\nCreate_rs7938730_Q_8.5,Yes_rs7938730_rs12561942_Q_7,No_rs7938730_rs10444351_Q_5.5,Yes_rs12561942_x_6_5,No_rs12561942_x_3_5,Yes_rs10444351_rs1035582_Q_5.5,No_rs10444351_rs873525_Q_5.5,Yes_rs1035582_x_3_5,No_rs1035582_rs2611423_Q_1.5,Yes_rs873525_rs2000319_Q_5.5,No_rs873525_rs640655_Q_6,Yes_rs2611423_x_6_5,No_rs2611423_x_3_5,Yes_rs2000319_x_6_5,No_rs2000319_x_3_5,Yes_rs640655_rs742636_Q_6,No_rs640655_x_6_5,Yes_rs742636_rs12250707_Q_6,No_rs742636_rs487113_Q_8.5,Yes_rs12250707_rs3757181_Q_2,No_rs12250707_x_6_5,Yes_rs487113_x_6_5,No_rs487113_x_3_5,Yes_rs3757181_x_3_5,No_rs3757181_x_6_5,\nCreate_rs1369323_Q_8.5,Yes_rs1369323_rs4101233_Q_8.5,No_rs1369323_rs7542677_Q_6,Yes_rs4101233_x_6_5,No_rs4101233_x_3_5,Yes_rs7542677_rs10046248_Q_8.5,No_rs7542677_rs17764769_Q_8.5,Yes_rs10046248_rs10914477_Q_5.5,No_rs10046248_rs11573979_Q_5.5,Yes_rs17764769_rs10799255_Q_5.5,No_rs17764769_x_3_5,Yes_rs10914477_rs1320565_Q_8.5,No_rs10914477_rs6030932_Q_9.5,Yes_rs11573979_x_3_5,No_rs11573979_x_6_5,Yes_rs10799255_x_6_5,No_rs10799255_x_3_5,Yes_rs1320565_x_6_5,No_rs1320565_x_3_5,Yes_rs6030932_x_6_5,No_rs6030932_rs333846_Q_2,Yes_rs333846_rs642490_Q_2,No_rs333846_x_6_5,Yes_rs642490_rs7921121_Q_5.5,No_rs642490_x_6_5,Yes_rs7921121_x_6_5,No_rs7921121_rs6698924_Q_1.5,Yes_rs6698924_x_3_5,No_rs6698924_x_6_5,\nCreate_rs8093745_Q_2,Yes_rs8093745_rs10836933_Q_7,No_rs8093745_rs6577582_Q_3.5,Yes_rs10836933_rs1123571_Q_2,No_rs10836933_rs4617036_Q_1.5,Yes_rs6577582_x_3_5,No_rs6577582_x_6_5,Yes_rs1123571_x_3_5,No_rs1123571_x_6_5,Yes_rs4617036_rs2513850_Q_5.5,No_rs4617036_rs689391_Q_8.5,Yes_rs2513850_x_6_5,No_rs2513850_x_3_5,Yes_rs689391_rs1869972_Q_2,No_rs689391_rs7767039_Q_5.5,Yes_rs1869972_x_3_5,No_rs1869972_x_6_5,Yes_rs7767039_rs17018699_Q_1.5,No_rs7767039_rs2268063_Q_6,Yes_rs17018699_x_3_5,No_rs17018699_x_6_5,Yes_rs2268063_rs333859_Q_5.5,No_rs2268063_x_6_5,Yes_rs333859_x_6_5,No_rs333859_rs2273939_Q_6,Yes_rs2273939_x_3_5,No_rs2273939_x_6_5,\nCreate_rs1017783_Q_5.5,Yes_rs1017783_rs2000177_Q_8.5,No_rs1017783_rs2295615_Q_5.5,Yes_rs2000177_rs8041381_Q_2,No_rs2000177_x_3_5,Yes_rs2295615_rs3824405_Q_9.5,No_rs2295615_rs7526076_Q_5.5,Yes_rs8041381_rs202481_Q_8.5,No_rs8041381_x_3_5,Yes_rs3824405_rs2173201_Q_1.5,No_rs3824405_rs1317894_Q_6,Yes_rs7526076_x_3_5,No_rs7526076_x_6_5,Yes_rs202481_x_3_5,No_rs202481_rs7016943_Q_6,Yes_rs2173201_rs17151786_Q_8.5,No_rs2173201_x_3_5,Yes_rs1317894_rs7687912_Q_8.5,No_rs1317894_x_6_5,Yes_rs7016943_x_3_5,No_rs7016943_rs16840755_Q_1.5,Yes_rs17151786_x_3_5,No_rs17151786_x_6_5,Yes_rs7687912_x_6_5,No_rs7687912_x_3_5,Yes_rs16840755_x_3_5,No_rs16840755_x_6_5,\nCreate_rs1421617_Q_5.5,Yes_rs1421617_rs2320378_Q_8.5,No_rs1421617_rs8050818_Q_5.5,Yes_rs2320378_rs3741026_Q_5.5,No_rs2320378_rs17093760_Q_9.5,Yes_rs8050818_rs4846908_Q_5.5,No_rs8050818_rs16827628_Q_6,Yes_rs3741026_x_3_5,No_rs3741026_rs4785322_Q_6,Yes_rs17093760_rs4416143_Q_5.5,No_rs17093760_rs12090967_Q_6,Yes_rs4846908_x_3_5,No_rs4846908_x_6_5,Yes_rs16827628_rs16826345_Q_8.5,No_rs16827628_x_6_5,Yes_rs4785322_x_3_5,No_rs4785322_x_6_5,Yes_rs4416143_rs7534617_Q_8.5,No_rs4416143_rs2606414_Q_8.5,Yes_rs12090967_x_6_5,No_rs12090967_x_3_5,Yes_rs16826345_x_6_5,No_rs16826345_rs4131373_Q_5.5,Yes_rs7534617_x_3_5,No_rs7534617_x_6_5,Yes_rs2606414_x_3_5,No_rs2606414_x_6_5,Yes_rs4131373_x_6_5,No_rs4131373_x_3_5,\nCreate_rs174510_Q_8.5,Yes_rs174510_rs4969058_Q_5.5,No_rs174510_rs17821703_Q_2,Yes_rs4969058_rs11538784_Q_9.5,No_rs4969058_rs4942308_Q_8.5,Yes_rs17821703_rs11251966_Q_2,No_rs17821703_rs12738365_Q_8.5,Yes_rs11538784_x_3_5,No_rs11538784_x_6_5,Yes_rs4942308_x_6_5,No_rs4942308_x_3_5,Yes_rs11251966_rs2105606_Q_2,No_rs11251966_rs10240570_Q_6,Yes_rs12738365_x_6_5,No_rs12738365_x_3_5,Yes_rs2105606_rs1511412_Q_5.5,No_rs2105606_x_6_5,Yes_rs10240570_rs16824948_Q_6,No_rs10240570_x_6_5,Yes_rs1511412_x_6_5,No_rs1511412_rs1877351_Q_2,Yes_rs16824948_x_3_5,No_rs16824948_x_6_5,Yes_rs1877351_rs11127018_Q_6,No_rs1877351_x_6_5,Yes_rs11127018_x_6_5,No_rs11127018_x_3_5,\nCreate_rs174504_Q_9.5,Yes_rs174504_rs4937384_Q_8.5,No_rs174504_rs4255200_Q_2,Yes_rs4937384_rs7658552_Q_8.5,No_rs4937384_rs428180_Q_3.5,Yes_rs4255200_rs372440_Q_5.5,No_rs4255200_rs10752741_Q_5.5,Yes_rs7658552_x_6_5,No_rs7658552_x_3_5,Yes_rs428180_x_3_5,No_rs428180_x_6_5,Yes_rs372440_rs1398572_Q_2,No_rs372440_rs12490963_Q_5.5,Yes_rs10752741_x_6_5,No_rs10752741_x_3_5,Yes_rs1398572_rs4935397_Q_6,No_rs1398572_x_6_5,Yes_rs12490963_rs7520258_Q_6,No_rs12490963_x_3_5,Yes_rs4935397_x_6_5,No_rs4935397_rs11611632_Q_8.5,Yes_rs7520258_x_3_5,No_rs7520258_x_6_5,Yes_rs11611632_rs9287778_Q_1.5,No_rs11611632_x_6_5,Yes_rs9287778_x_3_5,No_rs9287778_x_6_5,\nCreate_rs4904385_Q_2,Yes_rs4904385_rs6560612_Q_6,No_rs4904385_rs1148214_Q_8.5,Yes_rs6560612_rs243996_Q_7,No_rs6560612_rs2348394_Q_7,Yes_rs1148214_x_3_5,No_rs1148214_rs702552_Q_8.5,Yes_rs243996_rs1571149_Q_5.5,No_rs243996_x_6_5,Yes_rs2348394_x_6_5,No_rs2348394_rs2713721_Q_2,Yes_rs702552_x_3_5,No_rs702552_x_6_5,Yes_rs1571149_x_6_5,No_rs1571149_x_3_5,Yes_rs2713721_x_6_5,No_rs2713721_rs12266901_Q_8.5,Yes_rs12266901_x_6_5,No_rs12266901_rs9559436_Q_9.5,Yes_rs9559436_x_6_5,No_rs9559436_rs4530328_Q_8.5,Yes_rs4530328_x_6_5,No_rs4530328_rs2958272_Q_9.5,Yes_rs2958272_x_3_5,No_rs2958272_x_6_5,\nCreate_rs174519_Q_8.5,Yes_rs174519_rs1874799_Q_8.5,No_rs174519_rs2423402_Q_8.5,Yes_rs1874799_rs686543_Q_6,No_rs1874799_rs6662635_Q_2,Yes_rs2423402_rs10913136_Q_2,No_rs2423402_rs2237551_Q_8.5,Yes_rs686543_x_3_5,No_rs686543_x_6_5,Yes_rs6662635_x_3_5,No_rs6662635_x_6_5,Yes_rs10913136_x_3_5,No_rs10913136_x_6_5,Yes_rs2237551_rs10863308_Q_3.5,No_rs2237551_rs2432785_Q_3.5,Yes_rs10863308_x_3_5,No_rs10863308_x_6_5,Yes_rs2432785_x_6_5,No_rs2432785_rs1868150_Q_6,Yes_rs1868150_rs6879391_Q_2.5,No_rs1868150_x_6_5,Yes_rs6879391_rs7944342_Q_8.5,No_rs6879391_x_6_5,Yes_rs7944342_x_6_5,No_rs7944342_rs953599_Q_3.5,Yes_rs953599_x_6_5,No_rs953599_x_3_5,\nCreate_rs7587849_Q_8.5,Yes_rs7587849_rs2418269_Q_2,No_rs7587849_rs11211612_Q_1.5,Yes_rs2418269_rs2046685_Q_7,No_rs2418269_rs12551119_Q_2,Yes_rs11211612_rs12412736_Q_6,No_rs11211612_rs10904962_Q_6,Yes_rs2046685_rs7530465_Q_5.5,No_rs2046685_x_3_5,Yes_rs12551119_rs41374247_Q_5.5,No_rs12551119_rs4371605_Q_6,Yes_rs12412736_rs6472787_Q_6,No_rs12412736_x_6_5,Yes_rs10904962_rs707457_Q_3.5,No_rs10904962_rs9442372_Q_2,Yes_rs7530465_x_3_5,No_rs7530465_x_6_5,Yes_rs41374247_x_3_5,No_rs41374247_x_6_5,Yes_rs4371605_x_3_5,No_rs4371605_rs4970421_Q_5.5,Yes_rs6472787_x_6_5,No_rs6472787_x_3_5,Yes_rs707457_x_3_5,No_rs707457_x_6_5,Yes_rs9442372_x_6_5,No_rs9442372_x_3_5,Yes_rs4970421_x_3_5,No_rs4970421_x_6_5,\nCreate_rs9543281_Q_5.5,Yes_rs9543281_rs4680238_Q_1.5,No_rs9543281_rs10853282_Q_8.5,Yes_rs4680238_x_6_5,No_rs4680238_x_3_5,Yes_rs10853282_rs17325821_Q_6,No_rs10853282_rs17135476_Q_1.5,Yes_rs17325821_rs133503_Q_8.5,No_rs17325821_x_3_5,Yes_rs17135476_rs1517782_Q_3.5,No_rs17135476_rs701100_Q_8.5,Yes_rs133503_rs34835780_Q_2,No_rs133503_x_3_5,Yes_rs1517782_x_6_5,No_rs1517782_rs2660563_Q_6,Yes_rs701100_x_3_5,No_rs701100_rs1317209_Q_2,Yes_rs34835780_x_3_5,No_rs34835780_x_6_5,Yes_rs2660563_rs13030338_Q_6,No_rs2660563_x_6_5,Yes_rs1317209_x_3_5,No_rs1317209_x_6_5,Yes_rs13030338_rs926244_Q_5.5,No_rs13030338_x_6_5,Yes_rs926244_x_3_5,No_rs926244_x_6_5,\nCreate_rs649640_Q_2,Yes_rs649640_rs41526051_Q_7,No_rs649640_rs6732937_Q_6,Yes_rs41526051_rs2275603_Q_2,No_rs41526051_rs7642488_Q_6,Yes_rs6732937_rs11913594_Q_8.5,No_rs6732937_x_6_5,Yes_rs2275603_x_6_5,No_rs2275603_x_3_5,Yes_rs7642488_rs16864358_Q_8.5,No_rs7642488_rs4753962_Q_8.5,Yes_rs11913594_rs7461808_Q_6,No_rs11913594_rs12760071_Q_7,Yes_rs16864358_x_6_5,No_rs16864358_x_3_5,Yes_rs4753962_x_3_5,No_rs4753962_rs13432159_Q_9.5,Yes_rs7461808_rs9930735_Q_6,No_rs7461808_x_6_5,Yes_rs12760071_x_6_5,No_rs12760071_x_3_5,Yes_rs13432159_x_3_5,No_rs13432159_x_6_5,Yes_rs9930735_rs11573970_Q_3.5,No_rs9930735_x_6_5,Yes_rs11573970_x_6_5,No_rs11573970_x_3_5,\nCreate_rs2567274_Q_6,Yes_rs2567274_rs3742672_Q_5.5,No_rs2567274_rs1113111_Q_3.5,Yes_rs3742672_rs4662834_Q_2,No_rs3742672_rs4141989_Q_8.5,Yes_rs1113111_rs10134028_Q_5.5,No_rs1113111_rs1504418_Q_2,Yes_rs4662834_x_3_5,No_rs4662834_x_6_5,Yes_rs4141989_x_6_5,No_rs4141989_rs797913_Q_6,Yes_rs10134028_rs2209477_Q_8.5,No_rs10134028_rs12922641_Q_5.5,Yes_rs1504418_x_6_5,No_rs1504418_x_3_5,Yes_rs797913_x_3_5,No_rs797913_x_6_5,Yes_rs2209477_x_3_5,No_rs2209477_x_6_5,Yes_rs12922641_rs10517011_Q_2,No_rs12922641_rs6685406_Q_2,Yes_rs10517011_x_6_5,No_rs10517011_rs4656248_Q_8.5,Yes_rs6685406_x_3_5,No_rs6685406_x_6_5,Yes_rs4656248_x_6_5,No_rs4656248_x_3_5,\n";//origin
//Hapmap 2
//std::string treeInfo = "Create_rs6437783_Q_1.5,Yes_rs6437783_rs4835141_Q_1.5,No_rs6437783_rs735480_Q_1.5,Yes_rs4835141_x_2_5,No_rs4835141_x_3_5,Yes_rs735480_x_3_5,No_rs735480_x_1_5,\nCreate_rs35389_Q_2.5,Yes_rs35389_rs4787645_Q_1.5,No_rs35389_rs1726254_Q_2.5,Yes_rs4787645_rs4847428_Q_1.5,No_rs4787645_x_3_5,Yes_rs1726254_x_1_5,No_rs1726254_x_2_5,Yes_rs4847428_x_1_5,No_rs4847428_x_2_5,\nCreate_rs1986420_Q_2.5,Yes_rs1986420_rs12135904_Q_2.5,No_rs1986420_x_1_5,Yes_rs12135904_rs1679012_CHN_1.5,No_rs12135904_x_3_5,Yes_rs1679012_x_2_5,No_rs1679012_x_1_5,\nCreate_rs2675345_Q_1.5,Yes_rs2675345_rs9931378_Q_2.5,No_rs2675345_rs6546753_Q_2.5,Yes_rs9931378_x_1_5,No_rs9931378_x_3_5,Yes_rs6546753_x_3_5,No_rs6546753_x_2_5,\nCreate_rs2700392_Q_1.5,Yes_rs2700392_rs1924381_Q_1.5,No_rs2700392_rs747094_Q_2.5,Yes_rs1924381_x_2_5,No_rs1924381_x_1_5,Yes_rs747094_x_3_5,No_rs747094_rs17671597_Q_1.5,Yes_rs17671597_x_2_5,No_rs17671597_x_1_5,\nCreate_rs260700_Q_2.5,Yes_rs260700_rs6451268_Q_2.5,No_rs260700_rs12204275_Q_1.5,Yes_rs6451268_rs987435_Q_1.5,No_rs6451268_rs16953500_Q_2.5,Yes_rs12204275_x_2_5,No_rs12204275_x_3_5,Yes_rs987435_x_3_5,No_rs987435_rs4242682_Q_2.5,Yes_rs16953500_x_1_5,No_rs16953500_x_2_5,Yes_rs4242682_x_2_5,No_rs4242682_x_1_5,\nCreate_rs260699_Q_1.5,Yes_rs260699_rs11130791_Q_2.5,No_rs260699_rs6897135_Q_1.5,Yes_rs11130791_x_2_5,No_rs11130791_x_3_5,Yes_rs6897135_x_1_5,No_rs6897135_rs1588040_Q_1.5,Yes_rs1588040_x_3_5,No_rs1588040_rs7974633_Q_1.5,Yes_rs7974633_x_1_5,No_rs7974633_x_2_5,\nCreate_rs260705_Q_1.5,Yes_rs260705_rs11649653_Q_1.5,No_rs260705_rs2433354_Q_2.5,Yes_rs11649653_x_2_5,No_rs11649653_x_3_5,Yes_rs2433354_rs2204738_Q_2.5,No_rs2433354_rs4791868_Q_1.5,Yes_rs2204738_x_2_5,No_rs2204738_x_3_5,Yes_rs4791868_x_2_5,No_rs4791868_x_1_5,\nCreate_rs282162_Q_2.5,Yes_rs282162_rs4825_Q_2.5,No_rs282162_rs864386_Q_1.5,Yes_rs4825_rs1814538_Q_1.5,No_rs4825_rs10187056_Q_1.5,Yes_rs864386_x_3_5,No_rs864386_x_1_5,Yes_rs1814538_x_2_5,No_rs1814538_x_1_5,Yes_rs10187056_x_3_5,No_rs10187056_x_2_5,\nCreate_rs2002739_Q_2.5,Yes_rs2002739_rs12120383_Q_1.5,No_rs2002739_rs2000743_Q_2.5,Yes_rs12120383_rs7111521_Q_1.5,No_rs12120383_rs12921822_Q_1.5,Yes_rs2000743_x_3_5,No_rs2000743_x_1_5,Yes_rs7111521_x_2_5,No_rs7111521_x_1_5,Yes_rs12921822_x_3_5,No_rs12921822_x_2_5,\nCreate_rs4722760_Q_1.5,Yes_rs4722760_rs13086858_Q_2.5,No_rs4722760_rs1320385_Q_2.5,Yes_rs13086858_rs7676617_Q_1.5,No_rs13086858_x_3_5,Yes_rs1320385_rs7215008_Q_1.5,No_rs1320385_rs6698919_Q_2.5,Yes_rs7676617_x_1_5,No_rs7676617_x_2_5,Yes_rs7215008_x_3_5,No_rs7215008_x_2_5,Yes_rs6698919_x_1_5,No_rs6698919_x_2_5,\nCreate_rs2907599_Q_1.5,Yes_rs2907599_rs12036675_Q_2.5,No_rs2907599_rs10814993_Q_1.5,Yes_rs12036675_x_2_5,No_rs12036675_x_1_5,Yes_rs10814993_rs2463383_Q_1.5,No_rs10814993_rs1484213_Q_2.5,Yes_rs2463383_x_2_5,No_rs2463383_x_3_5,Yes_rs1484213_x_2_5,No_rs1484213_x_1_5,\nCreate_rs2893312_Q_1.5,Yes_rs2893312_rs868622_Q_1.5,No_rs2893312_rs12062528_Q_2.5,Yes_rs868622_x_3_5,No_rs868622_rs2578669_Q_2.5,Yes_rs12062528_rs519381_Q_1.5,No_rs12062528_rs9595066_Q_2.5,Yes_rs2578669_x_2_5,No_rs2578669_x_1_5,Yes_rs519381_x_3_5,No_rs519381_x_2_5,Yes_rs9595066_x_1_5,No_rs9595066_x_2_5,\nCreate_rs590616_Q_1.5,Yes_rs590616_rs2605419_Q_2.5,No_rs590616_rs12895262_Q_1.5,Yes_rs2605419_x_3_5,No_rs2605419_x_1_5,Yes_rs12895262_x_1_5,No_rs12895262_rs1909338_Q_2.5,Yes_rs1909338_rs10758940_Q_1.5,No_rs1909338_x_3_5,Yes_rs10758940_x_1_5,No_rs10758940_x_2_5,\nCreate_rs533571_Q_2.5,Yes_rs533571_rs6468344_Q_2.5,No_rs533571_rs4577845_Q_2.5,Yes_rs6468344_rs11098948_Q_1.5,No_rs6468344_rs2029623_Q_1.5,Yes_rs4577845_x_3_5,No_rs4577845_x_1_5,Yes_rs11098948_x_3_5,No_rs11098948_x_2_5,Yes_rs2029623_x_2_5,No_rs2029623_x_1_5,\nCreate_rs260709_Q_2.5,Yes_rs260709_rs11691947_Q_2.5,No_rs260709_rs1437724_Q_1.5,Yes_rs11691947_rs7158108_3_2.5,No_rs11691947_rs4705115_1_1.5,Yes_rs1437724_x_2_5,No_rs1437724_x_3_5,Yes_rs7158108_x_1_5,No_rs7158108_x_2_5,Yes_rs4705115_x_3_5,No_rs4705115_rs2214965_Q_1.5,Yes_rs2214965_x_1_5,No_rs2214965_x_2_5,\nCreate_rs6534999_Q_2.5,Yes_rs6534999_rs7689609_Q_2.5,No_rs6534999_rs12542990_Q_2.5,Yes_rs7689609_x_1_5,No_rs7689609_rs1450428_Q_1.5,Yes_rs12542990_rs7551132_Q_1.5,No_rs12542990_x_3_5,Yes_rs1450428_x_3_5,No_rs1450428_x_2_5,Yes_rs7551132_x_1_5,No_rs7551132_x_2_5,\nCreate_rs4832501_Q_1.5,Yes_rs4832501_rs2200402_Q_2.5,No_rs4832501_rs931410_Q_1.5,Yes_rs2200402_rs2546001_Q_1.5,No_rs2200402_rs8091955_Q_2.5,Yes_rs931410_rs1099968_Q_2.5,No_rs931410_x_1_5,Yes_rs2546001_x_2_5,No_rs2546001_x_1_5,Yes_rs8091955_x_3_5,No_rs8091955_x_2_5,Yes_rs1099968_rs7921545_Q_2.5,No_rs1099968_x_1_5,Yes_rs7921545_x_2_5,No_rs7921545_x_3_5,\nCreate_rs1437787_Q_1.5,Yes_rs1437787_rs11170991_Q_2.5,No_rs1437787_rs1805972_Q_1.5,Yes_rs11170991_x_3_5,No_rs11170991_x_1_1.5,Yes_rs1805972_rs2422098_Q_1.5,No_rs1805972_rs9821525_Q_1.5,Yes_rs2422098_x_2_5,No_rs2422098_x_1_5,Yes_rs9821525_x_3_5,No_rs9821525_rs12511245_Q_2.5,Yes_rs12511245_x_2_5,No_rs12511245_x_1_5,\nCreate_rs4749305_Q_1.5,Yes_rs4749305_rs2631899_Q_2.5,No_rs4749305_rs7956796_Q_2.5,Yes_rs2631899_x_3_5,No_rs2631899_x_2_5,Yes_rs7956796_x_1_5,No_rs7956796_rs4877791_Q_2.5,Yes_rs4877791_rs1932366_Q_1.5,No_rs4877791_x_3_5,Yes_rs1932366_x_1_5,No_rs1932366_x_2_5,\nCreate_rs542405_Q_2.5,Yes_rs542405_rs6977118_Q_1.5,No_rs542405_rs2305858_Q_2.5,Yes_rs6977118_rs11563620_Q_1.5,No_rs6977118_x_3_5,Yes_rs2305858_rs2040704_Q_1.5,No_rs2305858_x_1_5,Yes_rs11563620_x_2_5,No_rs11563620_x_1_5,Yes_rs2040704_x_3_5,No_rs2040704_x_2_5,\nCreate_rs738276_Q_1.5,Yes_rs738276_rs4615248_Q_2.5,No_rs738276_rs7983489_Q_1.5,Yes_rs4615248_rs12681671_Q_1.5,No_rs4615248_x_3_5,Yes_rs7983489_rs6035761_Q_1.5,No_rs7983489_rs2324520_Q_2.5,Yes_rs12681671_x_2_5,No_rs12681671_x_1_5,Yes_rs6035761_x_2_5,No_rs6035761_x_1_5,Yes_rs2324520_rs3181372_Q_2.5,No_rs2324520_x_3_5,Yes_rs3181372_x_2_5,No_rs3181372_x_1_5,\nCreate_rs943773_Q_1.5,Yes_rs943773_rs4789182_Q_1.5,No_rs943773_rs702032_Q_2.5,Yes_rs4789182_x_2_5,No_rs4789182_x_3_5,Yes_rs702032_rs6926482_Q_1.5,No_rs702032_x_1_5,Yes_rs6926482_x_3_5,No_rs6926482_rs2490385_Q_1.5,Yes_rs2490385_x_1_5,No_rs2490385_x_2_5,\nCreate_rs8097206_Q_2.5,Yes_rs8097206_rs39639_Q_1.5,No_rs8097206_rs12641411_Q_2.5,Yes_rs39639_rs9866028_Q_1.5,No_rs39639_rs4713659_Q_2.5,Yes_rs12641411_x_1_5,No_rs12641411_x_3_5,Yes_rs9866028_x_2_5,No_rs9866028_x_1_5,Yes_rs4713659_rs27162_Q_2.5,No_rs4713659_x_3_5,Yes_rs27162_x_2_5,No_rs27162_x_1_5,\nCreate_rs10851731_Q_1.5,Yes_rs10851731_rs6560084_Q_2.5,No_rs10851731_rs11085023_Q_2.5,Yes_rs6560084_x_1_5,No_rs6560084_x_2_5,Yes_rs11085023_rs277639_Q_1.5,No_rs11085023_x_3_5,Yes_rs277639_x_1_5,No_rs277639_rs7677859_Q_1.5,Yes_rs7677859_x_3_5,No_rs7677859_x_2_5,\nCreate_rs2228511_Q_2.5,Yes_rs2228511_rs738987_Q_1.5,No_rs2228511_rs2500090_Q_2.5,Yes_rs738987_rs560767_2_2.5,No_rs738987_rs2967391_3_2.5,Yes_rs2500090_x_1_5,No_rs2500090_x_2_5,Yes_rs560767_x_3_5,No_rs560767_x_2_5,Yes_rs2967391_x_2_5,No_rs2967391_x_1_5,\nCreate_rs1942885_Q_2.5,Yes_rs1942885_rs11903376_Q_1.5,No_rs1942885_rs12677218_Q_2.5,Yes_rs11903376_x_1_5,No_rs11903376_rs2035247_Q_1.5,Yes_rs12677218_rs2849372_Q_2.5,No_rs12677218_x_3_5,Yes_rs2035247_x_1_5,No_rs2035247_rs6679430_Q_2.5,Yes_rs2849372_x_2_5,No_rs2849372_x_1_5,Yes_rs6679430_x_2_5,No_rs6679430_x_3_5,\nCreate_rs260711_Q_1.5,Yes_rs260711_rs10998087_Q_2.5,No_rs260711_rs1117382_Q_2.5,Yes_rs10998087_x_3_5,No_rs10998087_x_2_5,Yes_rs1117382_x_1_5,No_rs1117382_rs7376483_Q_2.5,Yes_rs7376483_rs12446781_Q_1.5,No_rs7376483_x_3_5,Yes_rs12446781_x_1_5,No_rs12446781_x_2_5,\nCreate_rs1250253_Q_2.5,Yes_rs1250253_rs1478446_Q_2.5,No_rs1250253_rs6763648_Q_1.5,Yes_rs1478446_rs2673884_Q_2.5,No_rs1478446_rs2506898_Q_2.5,Yes_rs6763648_x_3_5,No_rs6763648_x_2_5,Yes_rs2673884_rs158512_Q_1.5,No_rs2673884_x_3_5,Yes_rs2506898_x_1_5,No_rs2506898_x_2_5,Yes_rs158512_x_1_5,No_rs158512_x_2_5,\nCreate_rs7923368_Q_2.5,Yes_rs7923368_rs1419138_Q_2.5,No_rs7923368_rs10759290_Q_1.5,Yes_rs1419138_rs10185826_Q_2.5,No_rs1419138_x_1_5,Yes_rs10759290_x_1_5,No_rs10759290_x_3_5,Yes_rs10185826_rs1854935_Q_1.5,No_rs10185826_x_3_5,Yes_rs1854935_x_1_5,No_rs1854935_x_2_5,\n";
//string treeInfo = "Create_rs198642_Q_2.5,Yes_rs198642_rs1213594_Q_2.5,No_rs198642_x_1_5,Yes_rs1213594_rs167912_CHN_1.5,No_rs1213594_x_3_5,Yes_rs167912_x_2_5,No_rs167912_x_1_5,\n";
std::string treeLineInfo;
std::string treeWordInfo;
std::vector<std::string> treeNodeInfo;
size_t treeNodePos;
size_t treeWordPos;
size_t treeLinePos;
treeLinePos = treeInfo.find(treeLineBreak);
while(treeLinePos < 1000000){//应该为while循环
treeLineInfo = treeInfo.substr(0, treeLinePos + treeLineBreak.length());
DecisionTree* newTree = new DecisionTree();
treeWordPos = treeLineInfo.find(treeWordBreak);
while(treeWordPos < 1000000){
treeWordInfo = treeLineInfo.substr(0, treeWordPos + treeWordBreak.length());
treeNodePos = treeWordInfo.find(treeNodeBreak);
treeNodeInfo.push_back(treeWordInfo.substr(0, treeNodePos));
//cout << treeNodeInfo[0] << endl;
treeWordInfo.erase(0, treeNodePos + treeNodeBreak.length());
treeNodePos = treeWordInfo.find(treeNodeBreak);
treeNodeInfo.push_back(treeWordInfo.substr(0, treeNodePos));
//cout << treeNodeInfo[1] << endl;
treeWordInfo.erase(0, treeNodePos + treeNodeBreak.length());
treeNodePos = treeWordInfo.find(treeNodeBreak);
treeNodeInfo.push_back(treeWordInfo.substr(0, treeNodePos));
//cout << treeNodeInfo[2] << endl;
if(treeNodeInfo[0] == "Create"){
treeWordInfo.erase(0, treeNodePos + treeNodeBreak.length());
treeNodePos = treeWordInfo.find(treeNodeBreak);
treeNodeInfo.push_back(treeWordInfo.substr(0, treeNodePos));
double a = stringToNum<double>(treeNodeInfo[3]);
newTree->CreateRootNode(treeNodeInfo[1], treeNodeInfo[2], a);
treeNodeInfo.clear();
}
else if (treeNodeInfo[0] == "Yes"){
treeWordInfo.erase(0, treeNodePos + treeNodeBreak.length());
treeNodePos = treeWordInfo.find(treeNodeBreak);
treeNodeInfo.push_back(treeWordInfo.substr(0, treeNodePos));
treeWordInfo.erase(0, treeNodePos + treeNodeBreak.length());
treeNodePos = treeWordInfo.find(treeNodeBreak);
treeNodeInfo.push_back(treeWordInfo.substr(0, treeNodePos));
double a = stringToNum<double>(treeNodeInfo[4]);
newTree->AddYesNode(treeNodeInfo[1], treeNodeInfo[2], treeNodeInfo[3], a);
treeNodeInfo.clear();
}
else if (treeNodeInfo[0] == "No"){
treeWordInfo.erase(0, treeNodePos + treeNodeBreak.length());
treeNodePos = treeWordInfo.find(treeNodeBreak);
treeNodeInfo.push_back(treeWordInfo.substr(0, treeNodePos));
treeWordInfo.erase(0, treeNodePos + treeNodeBreak.length());
treeNodePos = treeWordInfo.find(treeNodeBreak);
treeNodeInfo.push_back(treeWordInfo.substr(0, treeNodePos));
double a = stringToNum<double>(treeNodeInfo[4]);
newTree->AddNoNode(treeNodeInfo[1], treeNodeInfo[2], treeNodeInfo[3], a);
treeNodeInfo.clear();
}
treeLineInfo.erase(0, treeWordPos + treeWordBreak.length());
treeWordPos = treeLineInfo.find(treeWordBreak);
}
//newTree->Output();
std::string result;
result = newTree->Query(my);
std::cout << result << std::endl;
delete newTree;
myresult.push_back(result);
treeInfo.erase(0, treeLinePos + treeLineBreak.length());
treeLinePos = treeInfo.find(treeLineBreak);
}
/*
//create he new decision tree object
DecisionTree* newTree1 = new DecisionTree();
//add the required root node
newTree1->CreateRootNode("rs6437783", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree1->AddYesNode("rs6437783", "rs4835141", "Q", 1.5);
newTree1->AddNoNode("rs6437783", "rs735480", "Q", 1.5);
newTree1->AddYesNode("rs4835141", "x", "2", 5);
newTree1->AddNoNode("rs4835141", "x", "3", 5);
newTree1->AddYesNode("rs735480", "x", "3", 5);
newTree1->AddNoNode("rs735480", "x", "1", 5);
//output the created tree
newTree1->Output();
//query the tree
string result1;
result1 = newTree1->Query(my);
cout << result1 << endl;
delete newTree1;
myresult.push_back(result1);
DecisionTree* newTree2 = new DecisionTree();
//add the required root node
newTree2->CreateRootNode("rs35389", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree2->AddYesNode("rs35389", "rs4787645", "Q", 1.5);
newTree2->AddNoNode("rs35389", "rs1726254", "Q", 2.5);
newTree2->AddYesNode("rs4787645", "rs4847428", "Q", 1.5);
newTree2->AddNoNode("rs4787645", "x", "3", 5);
newTree2->AddYesNode("rs1726254", "x", "1", 5);
newTree2->AddNoNode("rs1726254", "x", "2", 5);
newTree2->AddYesNode("rs4847428", "x", "1", 5);
newTree2->AddNoNode("rs4847428", "x", "2", 5);
//output the created tree
newTree2->Output();
//query the tree
string result2;
result2 = newTree2->Query(my);
cout << result2 << endl;
delete newTree2;
myresult.push_back(result2);
DecisionTree* newTree3 = new DecisionTree();
//add the required root node
newTree3->CreateRootNode("rs1986420", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree3->AddYesNode("rs1986420", "rs12135904", "Q", 2.5);
newTree3->AddNoNode("rs1986420", "x", "1", 5);
newTree3->AddYesNode("rs12135904", "rs1679012", "CHN", 1.5);
newTree3->AddNoNode("rs12135904", "x", "3", 5);
newTree3->AddYesNode("rs1679012", "x", "2", 5);
newTree3->AddNoNode("rs1679012", "x", "1", 5);
//output the created tree
newTree3->Output();
//query the tree
string result3;
result3 = newTree3->Query(my);
cout << result3 << endl;
delete newTree3;
myresult.push_back(result3);
DecisionTree* newTree4 = new DecisionTree();
//add the required root node
newTree4->CreateRootNode("rs2675345", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree4->AddYesNode("rs2675345", "rs9931378", "Q", 2.5);
newTree4->AddNoNode("rs2675345", "rs6546753", "Q", 2.5);
newTree4->AddYesNode("rs9931378", "x", "1", 5);
newTree4->AddNoNode("rs9931378", "x", "3", 5);
newTree4->AddYesNode("rs6546753", "x", "3", 5);
newTree4->AddNoNode("rs6546753", "x", "2", 5);
//output the created tree
newTree4->Output();
//query the tree
string result4;
result4 = newTree4->Query(my);
cout << result4 << endl;
delete newTree4;
myresult.push_back(result4);
DecisionTree* newTree5 = new DecisionTree();
//add the required root node
newTree5->CreateRootNode("rs2700392", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree5->AddYesNode("rs2700392", "rs1924381", "Q", 1.5);
newTree5->AddNoNode("rs2700392", "rs747094", "Q", 2.5);
newTree5->AddYesNode("rs1924381", "x", "2", 5);
newTree5->AddNoNode("rs1924381", "x", "1", 5);
newTree5->AddYesNode("rs747094", "x", "3", 5);
newTree5->AddNoNode("rs747094", "rs17671597", "Q", 1.5);
newTree5->AddYesNode("rs17671597", "x", "2", 5);
newTree5->AddNoNode("rs17671597", "x", "1", 5);
//output the created tree
newTree5->Output();
//query the tree
string result5;
result5 = newTree5->Query(my);
cout << result5 << endl;
delete newTree5;
myresult.push_back(result5);
DecisionTree* newTree6 = new DecisionTree();
//add the required root node
newTree6->CreateRootNode("rs260700", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree6->AddYesNode("rs260700", "rs6451268", "Q", 2.5);
newTree6->AddNoNode("rs260700", "rs12204275", "Q", 1.5);
newTree6->AddYesNode("rs6451268", "rs987435", "Q", 1.5);
newTree6->AddNoNode("rs6451268", "rs16953500", "Q", 2.5);
newTree6->AddYesNode("rs12204275", "x", "2", 5);
newTree6->AddNoNode("rs12204275", "x", "3", 5);
newTree6->AddYesNode("rs987435", "x", "3", 5);
newTree6->AddNoNode("rs987435", "rs4242682", "Q", 2.5);
newTree6->AddYesNode("rs16953500", "x", "1", 5);
newTree6->AddNoNode("rs16953500", "x", "2", 5);
newTree6->AddYesNode("rs4242682", "x", "2", 5);
newTree6->AddNoNode("rs4242682", "x", "1", 5);
//output the created tree
newTree6->Output();
//query the tree
string result6;
result6 = newTree6->Query(my);
cout << result6 << endl;
delete newTree6;
myresult.push_back(result6);
DecisionTree* newTree7 = new DecisionTree();
//add the required root node
newTree7->CreateRootNode("rs260699", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree7->AddYesNode("rs260699", "rs11130791", "Q", 2.5);
newTree7->AddNoNode("rs260699", "rs6897135", "Q", 1.5);
newTree7->AddYesNode("rs11130791", "x", "2", 5);
newTree7->AddNoNode("rs11130791", "x", "3", 5);
newTree7->AddYesNode("rs6897135", "x", "1", 5);
newTree7->AddNoNode("rs6897135", "rs1588040", "Q", 1.5);
newTree7->AddYesNode("rs1588040", "x", "3", 5);
newTree7->AddNoNode("rs1588040", "rs7974633", "Q", 1.5);
newTree7->AddYesNode("rs7974633", "x", "1", 5);
newTree7->AddNoNode("rs7974633", "x", "2", 5);
//output the created tree
newTree7->Output();
//query the tree
string result7;
result7 = newTree7->Query(my);
cout << result7 << endl;
delete newTree7;
myresult.push_back(result7);
DecisionTree* newTree8 = new DecisionTree();
//add the required root node
newTree8->CreateRootNode("rs260705", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree8->AddYesNode("rs260705", "rs11649653", "Q", 1.5);
newTree8->AddNoNode("rs260705", "rs2433354", "Q", 2.5);
newTree8->AddYesNode("rs11649653", "x", "2", 5);
newTree8->AddNoNode("rs11649653", "x", "3", 5);
newTree8->AddYesNode("rs2433354", "rs2204738", "Q", 2.5);
newTree8->AddNoNode("rs2433354", "rs4791868", "Q", 1.5);
newTree8->AddYesNode("rs2204738", "x", "2", 5);
newTree8->AddNoNode("rs2204738", "x", "3", 5);
newTree8->AddYesNode("rs4791868", "x", "2", 5);
newTree8->AddNoNode("rs4791868", "x", "1", 5);
//output the created tree
newTree8->Output();
//query the tree
string result8;
result8 = newTree8->Query(my);
cout << result8 << endl;
delete newTree8;
myresult.push_back(result8);
DecisionTree* newTree9 = new DecisionTree();
//add the required root node
newTree9->CreateRootNode("rs282162", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree9->AddYesNode("rs282162", "rs4825", "Q", 2.5);
newTree9->AddNoNode("rs282162", "rs864386", "Q", 1.5);
newTree9->AddYesNode("rs4825", "rs1814538", "Q", 1.5);
newTree9->AddNoNode("rs4825", "rs10187056", "Q", 1.5);
newTree9->AddYesNode("rs864386", "x", "3", 5);
newTree9->AddNoNode("rs864386", "x", "1", 5);
newTree9->AddYesNode("rs1814538", "x", "2", 5);
newTree9->AddNoNode("rs1814538", "x", "1", 5);
newTree9->AddYesNode("rs10187056", "x", "3", 5);
newTree9->AddNoNode("rs10187056", "x", "2", 5);
//output the created tree
newTree9->Output();
//query the tree
string result9;
result9 = newTree9->Query(my);
cout << result9 << endl;
delete newTree9;
myresult.push_back(result9);
DecisionTree* newTree10 = new DecisionTree();
//add the required root node
newTree10->CreateRootNode("rs2002739", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree10->AddYesNode("rs2002739", "rs12120383", "Q", 1.5);
newTree10->AddNoNode("rs2002739", "rs2000743", "Q", 2.5);
newTree10->AddYesNode("rs12120383", "rs7111521", "Q", 1.5);
newTree10->AddNoNode("rs12120383", "rs12921822", "Q", 1.5);
newTree10->AddYesNode("rs2000743", "x", "3", 5);
newTree10->AddNoNode("rs2000743", "x", "1", 5);
newTree10->AddYesNode("rs7111521", "x", "2", 5);
newTree10->AddNoNode("rs7111521", "x", "1", 5);
newTree10->AddYesNode("rs12921822", "x", "3", 5);
newTree10->AddNoNode("rs12921822", "x", "2", 5);
//output the created tree
newTree10->Output();
//query the tree
string result10;
result10 = newTree10->Query(my);
cout << result10 << endl;
delete newTree10;
myresult.push_back(result10);
DecisionTree* newTree11 = new DecisionTree();
//add the required root node
newTree11->CreateRootNode("rs4722760", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree11->AddYesNode("rs4722760", "rs13086858", "Q", 2.5);
newTree11->AddNoNode("rs4722760", "rs1320385", "Q", 2.5);
newTree11->AddYesNode("rs13086858", "rs7676617", "Q", 1.5);
newTree11->AddNoNode("rs13086858", "x", "3", 5);
newTree11->AddYesNode("rs1320385", "rs7215008", "Q", 1.5);
newTree11->AddNoNode("rs1320385", "rs6698919", "Q", 2.5);
newTree11->AddYesNode("rs7676617", "x", "1", 5);
newTree11->AddNoNode("rs7676617", "x", "2", 5);
newTree11->AddYesNode("rs7215008", "x", "3", 5);
newTree11->AddNoNode("rs7215008", "x", "2", 5);
newTree11->AddYesNode("rs6698919", "x", "1", 5);
newTree11->AddNoNode("rs6698919", "x", "2", 5);
//output the created tree
newTree11->Output();
//query the tree
string result11;
result11 = newTree11->Query(my);
cout << result11 << endl;
delete newTree11;
myresult.push_back(result11);
DecisionTree* newTree12 = new DecisionTree();
//add the required root node
newTree12->CreateRootNode("rs2907599", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree12->AddYesNode("rs2907599", "rs12036675", "Q", 2.5);
newTree12->AddNoNode("rs2907599", "rs10814993", "Q", 1.5);
newTree12->AddYesNode("rs12036675", "x", "2", 5);
newTree12->AddNoNode("rs12036675", "x", "1", 5);
newTree12->AddYesNode("rs10814993", "rs2463383", "Q", 1.5);
newTree12->AddNoNode("rs10814993", "rs1484213", "Q", 2.5);
newTree12->AddYesNode("rs2463383", "x", "2", 5);
newTree12->AddNoNode("rs2463383", "x", "3", 5);
newTree12->AddYesNode("rs1484213", "x", "2", 5);
newTree12->AddNoNode("rs1484213", "x", "1", 5);
//output the created tree
newTree12->Output();
//query the tree
string result12;
result12 = newTree12->Query(my);
cout << result12 << endl;
delete newTree12;
myresult.push_back(result12);
DecisionTree* newTree13 = new DecisionTree();
//add the required root node
newTree13->CreateRootNode("rs2893312", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree13->AddYesNode("rs2893312", "rs868622", "Q", 1.5);
newTree13->AddNoNode("rs2893312", "rs12062528", "Q", 2.5);
newTree13->AddYesNode("rs868622", "x", "3", 5);
newTree13->AddNoNode("rs868622", "rs2578669", "Q", 2.5);
newTree13->AddYesNode("rs12062528", "rs519381", "Q", 1.5);
newTree13->AddNoNode("rs12062528", "rs9595066", "Q", 2.5);
newTree13->AddYesNode("rs2578669", "x", "2", 5);
newTree13->AddNoNode("rs2578669", "x", "1", 5);
newTree13->AddYesNode("rs519381", "x", "3", 5);
newTree13->AddNoNode("rs519381", "x", "2", 5);
newTree13->AddYesNode("rs9595066", "x", "1", 5);
newTree13->AddNoNode("rs9595066", "x", "2", 5);
//output the created tree
newTree13->Output();
//query the tree
string result13;
result13 = newTree13->Query(my);
cout << result13 << endl;
delete newTree13;
myresult.push_back(result13);
DecisionTree* newTree14 = new DecisionTree();
//add the required root node
newTree14->CreateRootNode("rs590616", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree14->AddYesNode("rs590616", "rs2605419", "Q", 2.5);
newTree14->AddNoNode("rs590616", "rs12895262", "Q", 1.5);
newTree14->AddYesNode("rs2605419", "x", "3", 5);
newTree14->AddNoNode("rs2605419", "x", "1", 5);
newTree14->AddYesNode("rs12895262", "x", "1", 5);
newTree14->AddNoNode("rs12895262", "rs1909338", "Q", 2.5);
newTree14->AddYesNode("rs1909338", "rs10758940", "Q", 1.5);
newTree14->AddNoNode("rs1909338", "x", "3", 5);
newTree14->AddYesNode("rs10758940", "x", "1", 5);
newTree14->AddNoNode("rs10758940", "x", "2", 5);
//output the created tree
newTree14->Output();
//query the tree
string result14;
result14 = newTree14->Query(my);
cout << result14 << endl;
delete newTree14;
myresult.push_back(result14);
DecisionTree* newTree15 = new DecisionTree();
//add the required root node
newTree15->CreateRootNode("rs533571", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree15->AddYesNode("rs533571", "rs6468344", "Q", 2.5);
newTree15->AddNoNode("rs533571", "rs4577845", "Q", 2.5);
newTree15->AddYesNode("rs6468344", "rs11098948", "Q", 1.5);
newTree15->AddNoNode("rs6468344", "rs2029623", "Q", 1.5);
newTree15->AddYesNode("rs4577845", "x", "3", 5);
newTree15->AddNoNode("rs4577845", "x", "1", 5);
newTree15->AddYesNode("rs11098948", "x", "3", 5);
newTree15->AddNoNode("rs11098948", "x", "2", 5);
newTree15->AddYesNode("rs2029623", "x", "2", 5);
newTree15->AddNoNode("rs2029623", "x", "1", 5);
//output the created tree
newTree15->Output();
//query the tree
string result15;
result15 = newTree15->Query(my);
cout << result15 << endl;
delete newTree15;
myresult.push_back(result15);
DecisionTree* newTree16 = new DecisionTree();
//add the required root node
newTree16->CreateRootNode("rs260709", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree16->AddYesNode("rs260709", "rs11691947", "Q", 2.5);
newTree16->AddNoNode("rs260709", "rs1437724", "Q", 1.5);
newTree16->AddYesNode("rs11691947", "rs7158108", "3", 2.5);
newTree16->AddNoNode("rs11691947", "rs4705115", "1", 1.5);
newTree16->AddYesNode("rs1437724", "x", "2", 5);
newTree16->AddNoNode("rs1437724", "x", "3", 5);
newTree16->AddYesNode("rs7158108", "x", "1", 5);
newTree16->AddNoNode("rs7158108", "x", "2", 5);
newTree16->AddYesNode("rs4705115", "x", "3", 5);
newTree16->AddNoNode("rs4705115", "rs2214965", "Q", 1.5);
newTree16->AddYesNode("rs2214965", "x", "1", 5);
newTree16->AddNoNode("rs2214965", "x", "2", 5);
//output the created tree
newTree16->Output();
//query the tree
string result16;
result16 = newTree16->Query(my);
cout << result16 << endl;
delete newTree16;
myresult.push_back(result16);
DecisionTree* newTree17 = new DecisionTree();
//add the required root node
newTree17->CreateRootNode("rs6534999", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree17->AddYesNode("rs6534999", "rs7689609", "Q", 2.5);
newTree17->AddNoNode("rs6534999", "rs12542990", "Q", 2.5);
newTree17->AddYesNode("rs7689609", "x", "1", 5);
newTree17->AddNoNode("rs7689609", "rs1450428", "Q", 1.5);
newTree17->AddYesNode("rs12542990", "rs7551132", "Q", 1.5);
newTree17->AddNoNode("rs12542990", "x", "3", 5);
newTree17->AddYesNode("rs1450428", "x", "3", 5);
newTree17->AddNoNode("rs1450428", "x", "2", 5);
newTree17->AddYesNode("rs7551132", "x", "1", 5);
newTree17->AddNoNode("rs7551132", "x", "2", 5);
//output the created tree
newTree17->Output();
//query the tree
string result17;
result17 = newTree17->Query(my);
cout << result17 << endl;
delete newTree17;
myresult.push_back(result17);
DecisionTree* newTree18 = new DecisionTree();
//add the required root node
newTree18->CreateRootNode("rs4832501", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree18->AddYesNode("rs4832501", "rs2200402", "Q", 2.5);
newTree18->AddNoNode("rs4832501", "rs931410", "Q", 1.5);
newTree18->AddYesNode("rs2200402", "rs2546001", "Q", 1.5);
newTree18->AddNoNode("rs2200402", "rs8091955", "Q", 2.5);
newTree18->AddYesNode("rs931410", "rs1099968", "Q", 2.5);
newTree18->AddNoNode("rs931410", "x", "1", 5);
newTree18->AddYesNode("rs2546001", "x", "2", 5);
newTree18->AddNoNode("rs2546001", "x", "1", 5);
newTree18->AddYesNode("rs8091955", "x", "3", 5);
newTree18->AddNoNode("rs8091955", "x", "2", 5);
newTree18->AddYesNode("rs1099968", "rs7921545", "Q", 2.5);
newTree18->AddNoNode("rs1099968", "x", "1", 5);
newTree18->AddYesNode("rs7921545", "x", "2", 5);
newTree18->AddNoNode("rs7921545", "x", "3", 5);
//output the created tree
newTree18->Output();
//query the tree
string result18;
result18 = newTree18->Query(my);
cout << result18 << endl;
delete newTree18;
myresult.push_back(result18);
DecisionTree* newTree19 = new DecisionTree();
//add the required root node
newTree19->CreateRootNode("rs1437787", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree19->AddYesNode("rs1437787", "rs11170991", "Q", 2.5);
newTree19->AddNoNode("rs1437787", "rs1805972", "Q", 1.5);
newTree19->AddYesNode("rs11170991", "x", "3", 5);
newTree19->AddNoNode("rs11170991", "x", "1", 1.5);
newTree19->AddYesNode("rs1805972", "rs2422098", "Q", 1.5);
newTree19->AddNoNode("rs1805972", "rs9821525", "Q", 1.5);
newTree19->AddYesNode("rs2422098", "x", "2", 5);
newTree19->AddNoNode("rs2422098", "x", "1", 5);
newTree19->AddYesNode("rs9821525", "x", "3", 5);
newTree19->AddNoNode("rs9821525", "rs12511245", "Q", 2.5);
newTree19->AddYesNode("rs12511245", "x", "2", 5);
newTree19->AddNoNode("rs12511245", "x", "1", 5);
//output the created tree
newTree19->Output();
//query the tree
string result19;
result19 = newTree19->Query(my);
cout << result19 << endl;
delete newTree19;
myresult.push_back(result19);
DecisionTree* newTree20 = new DecisionTree();
//add the required root node
newTree20->CreateRootNode("rs4749305", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree20->AddYesNode("rs4749305", "rs2631899", "Q", 2.5);
newTree20->AddNoNode("rs4749305", "rs7956796", "Q", 2.5);
newTree20->AddYesNode("rs2631899", "x", "3", 5);
newTree20->AddNoNode("rs2631899", "x", "2", 5);
newTree20->AddYesNode("rs7956796", "x", "1", 5);
newTree20->AddNoNode("rs7956796", "rs4877791", "Q", 2.5);
newTree20->AddYesNode("rs4877791", "rs1932366", "Q", 1.5);
newTree20->AddNoNode("rs4877791", "x", "3", 5);
newTree20->AddYesNode("rs1932366", "x", "1", 5);
newTree20->AddNoNode("rs1932366", "x", "2", 5);
//output the created tree
newTree20->Output();
//query the tree
string result20;
result20 = newTree20->Query(my);
cout << result20 << endl;
delete newTree20;
myresult.push_back(result20);
DecisionTree* newTree21 = new DecisionTree();
//add the required root node
newTree21->CreateRootNode("rs542405", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree21->AddYesNode("rs542405", "rs6977118", "Q", 1.5);
newTree21->AddNoNode("rs542405", "rs2305858", "Q", 2.5);
newTree21->AddYesNode("rs6977118", "rs11563620", "Q", 1.5);
newTree21->AddNoNode("rs6977118", "x", "3", 5);
newTree21->AddYesNode("rs2305858", "rs2040704", "Q", 1.5);
newTree21->AddNoNode("rs2305858", "x", "1", 5);
newTree21->AddYesNode("rs11563620", "x", "2", 5);
newTree21->AddNoNode("rs11563620", "x", "1", 5);
newTree21->AddYesNode("rs2040704", "x", "3", 5);
newTree21->AddNoNode("rs2040704", "x", "2", 5);
//output the created tree
newTree21->Output();
//query the tree
string result21;
result21 = newTree21->Query(my);
cout << result21 << endl;
delete newTree21;
myresult.push_back(result21);
DecisionTree* newTree22 = new DecisionTree();
//add the required root node
newTree22->CreateRootNode("rs738276", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree22->AddYesNode("rs738276", "rs4615248", "Q", 2.5);
newTree22->AddNoNode("rs738276", "rs7983489", "Q", 1.5);
newTree22->AddYesNode("rs4615248", "rs12681671", "Q", 1.5);
newTree22->AddNoNode("rs4615248", "x", "3", 5);
newTree22->AddYesNode("rs7983489", "rs6035761", "Q", 1.5);
newTree22->AddNoNode("rs7983489", "rs2324520", "Q", 2.5);
newTree22->AddYesNode("rs12681671", "x", "2", 5);
newTree22->AddNoNode("rs12681671", "x", "1", 5);
newTree22->AddYesNode("rs6035761", "x", "2", 5);
newTree22->AddNoNode("rs6035761", "x", "1", 5);
newTree22->AddYesNode("rs2324520", "rs3181372", "Q", 2.5);
newTree22->AddNoNode("rs2324520", "x", "3", 5);
newTree22->AddYesNode("rs3181372", "x", "2", 5);
newTree22->AddNoNode("rs3181372", "x", "1", 5);
//output the created tree
newTree22->Output();
//query the tree
string result22;
result22 = newTree22->Query(my);
cout << result22 << endl;
delete newTree22;
myresult.push_back(result22);
DecisionTree* newTree23 = new DecisionTree();
//add the required root node
newTree23->CreateRootNode("rs943773", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree23->AddYesNode("rs943773", "rs4789182", "Q", 1.5);
newTree23->AddNoNode("rs943773", "rs702032", "Q", 2.5);
newTree23->AddYesNode("rs4789182", "x", "2", 5);
newTree23->AddNoNode("rs4789182", "x", "3", 5);
newTree23->AddYesNode("rs702032", "rs6926482", "Q", 1.5);
newTree23->AddNoNode("rs702032", "x", "1", 5);
newTree23->AddYesNode("rs6926482", "x", "3", 5);
newTree23->AddNoNode("rs6926482", "rs2490385", "Q", 1.5);
newTree23->AddYesNode("rs2490385", "x", "1", 5);
newTree23->AddNoNode("rs2490385", "x", "2", 5);
//output the created tree
newTree23->Output();
//query the tree
string result23;
result23 = newTree23->Query(my);
cout << result23 << endl;
delete newTree23;
myresult.push_back(result23);
DecisionTree* newTree24 = new DecisionTree();
//add the required root node
newTree24->CreateRootNode("rs8097206", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree24->AddYesNode("rs8097206", "rs39639", "Q", 1.5);
newTree24->AddNoNode("rs8097206", "rs12641411", "Q", 2.5);
newTree24->AddYesNode("rs39639", "rs9866028", "Q", 1.5);
newTree24->AddNoNode("rs39639", "rs4713659", "Q", 2.5);
newTree24->AddYesNode("rs12641411", "x", "1", 5);
newTree24->AddNoNode("rs12641411", "x", "3", 5);
newTree24->AddYesNode("rs9866028", "x", "2", 5);
newTree24->AddNoNode("rs9866028", "x", "1", 5);
newTree24->AddYesNode("rs4713659", "rs27162", "Q", 2.5);
newTree24->AddNoNode("rs4713659", "x", "3", 5);
newTree24->AddYesNode("rs27162", "x", "2", 5);
newTree24->AddNoNode("rs27162", "x", "1", 5);
//output the created tree
newTree24->Output();
//query the tree
string result24;
result24 = newTree24->Query(my);
cout << result24 << endl;
delete newTree24;
myresult.push_back(result24);
DecisionTree* newTree25 = new DecisionTree();
//add the required root node
newTree25->CreateRootNode("rs10851731", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree25->AddYesNode("rs10851731", "rs6560084", "Q", 2.5);
newTree25->AddNoNode("rs10851731", "rs11085023", "Q", 2.5);
newTree25->AddYesNode("rs6560084", "x", "1", 5);
newTree25->AddNoNode("rs6560084", "x", "2", 5);
newTree25->AddYesNode("rs11085023", "rs277639", "Q", 1.5);
newTree25->AddNoNode("rs11085023", "x", "3", 5);
newTree25->AddYesNode("rs277639", "x", "1", 5);
newTree25->AddNoNode("rs277639", "rs7677859", "Q", 1.5);
newTree25->AddYesNode("rs7677859", "x", "3", 5);
newTree25->AddNoNode("rs7677859", "x", "2", 5);
//output the created tree
newTree25->Output();
//query the tree
string result25;
result25 = newTree25->Query(my);
cout << result25 << endl;
delete newTree25;
myresult.push_back(result25);
DecisionTree* newTree26 = new DecisionTree();
//add the required root node
newTree26->CreateRootNode("rs2228511", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree26->AddYesNode("rs2228511", "rs738987", "Q", 1.5);
newTree26->AddNoNode("rs2228511", "rs2500090", "Q", 2.5);
newTree26->AddYesNode("rs738987", "rs560767", "2", 2.5);
newTree26->AddNoNode("rs738987", "rs2967391", "3", 2.5);
newTree26->AddYesNode("rs2500090", "x", "1", 5);
newTree26->AddNoNode("rs2500090", "x", "2", 5);
newTree26->AddYesNode("rs560767", "x", "3", 5);
newTree26->AddNoNode("rs560767", "x", "2", 5);
newTree26->AddYesNode("rs2967391", "x", "2", 5);
newTree26->AddNoNode("rs2967391", "x", "1", 5);
//output the created tree
newTree26->Output();
//query the tree
string result26;
result26 = newTree26->Query(my);
cout << result26 << endl;
delete newTree26;
myresult.push_back(result26);
DecisionTree* newTree27 = new DecisionTree();
//add the required root node
newTree27->CreateRootNode("rs1942885", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree27->AddYesNode("rs1942885", "rs11903376", "Q", 1.5);
newTree27->AddNoNode("rs1942885", "rs12677218", "Q", 2.5);
newTree27->AddYesNode("rs11903376", "x", "1", 5);
newTree27->AddNoNode("rs11903376", "rs2035247", "Q", 1.5);
newTree27->AddYesNode("rs12677218", "rs2849372", "Q", 2.5);
newTree27->AddNoNode("rs12677218", "x", "3", 5);
newTree27->AddYesNode("rs2035247", "x", "1", 5);
newTree27->AddNoNode("rs2035247", "rs6679430", "Q", 2.5);
newTree27->AddYesNode("rs2849372", "x", "2", 5);
newTree27->AddNoNode("rs2849372", "x", "1", 5);
newTree27->AddYesNode("rs6679430", "x", "2", 5);
newTree27->AddNoNode("rs6679430", "x", "3", 5);
//output the created tree
newTree27->Output();
//query the tree
string result27;
result27 = newTree27->Query(my);
cout << result27 << endl;
delete newTree27;
myresult.push_back(result27);
DecisionTree* newTree28 = new DecisionTree();
//add the required root node
newTree28->CreateRootNode("rs260711", "Q", 1.5);
//add subsequent nodes based on problem definition
newTree28->AddYesNode("rs260711", "rs10998087", "Q", 2.5);
newTree28->AddNoNode("rs260711", "rs1117382", "Q", 2.5);
newTree28->AddYesNode("rs10998087", "x", "3", 5);
newTree28->AddNoNode("rs10998087", "x", "2", 5);
newTree28->AddYesNode("rs1117382", "x", "1", 5);
newTree28->AddNoNode("rs1117382", "rs7376483", "Q", 2.5);
newTree28->AddYesNode("rs7376483", "rs12446781", "Q", 1.5);
newTree28->AddNoNode("rs7376483", "x", "3", 5);
newTree28->AddYesNode("rs12446781", "x", "1", 5);
newTree28->AddNoNode("rs12446781", "x", "2", 5);
//output the created tree
newTree28->Output();
//query the tree
string result28;
result28 = newTree28->Query(my);
cout << result28 << endl;
delete newTree28;
myresult.push_back(result28);
DecisionTree* newTree29 = new DecisionTree();
//add the required root node
newTree29->CreateRootNode("rs1250253", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree29->AddYesNode("rs1250253", "rs1478446", "Q", 2.5);
newTree29->AddNoNode("rs1250253", "rs6763648", "Q", 1.5);
newTree29->AddYesNode("rs1478446", "rs2673884", "Q", 2.5);
newTree29->AddNoNode("rs1478446", "rs2506898", "Q", 2.5);
newTree29->AddYesNode("rs6763648", "x", "3", 5);
newTree29->AddNoNode("rs6763648", "x", "2", 5);
newTree29->AddYesNode("rs2673884", "rs158512", "Q", 1.5);
newTree29->AddNoNode("rs2673884", "x", "3", 5);
newTree29->AddYesNode("rs2506898", "x", "1", 5);
newTree29->AddNoNode("rs2506898", "x", "2", 5);
newTree29->AddYesNode("rs158512", "x", "1", 5);
newTree29->AddNoNode("rs158512", "x", "2", 5);
//output the created tree
newTree29->Output();
//query the tree
string result29;
result29 = newTree29->Query(my);
cout << result29 << endl;
delete newTree29;
myresult.push_back(result29);
DecisionTree* newTree30 = new DecisionTree();
//add the required root node
newTree30->CreateRootNode("rs7923368", "Q", 2.5);
//add subsequent nodes based on problem definition
newTree30->AddYesNode("rs7923368", "rs1419138", "Q", 2.5);
newTree30->AddNoNode("rs7923368", "rs10759290", "Q", 1.5);
newTree30->AddYesNode("rs1419138", "rs10185826", "Q", 2.5);
newTree30->AddNoNode("rs1419138", "x", "1", 5);
newTree30->AddYesNode("rs10759290", "x", "1", 5);
newTree30->AddNoNode("rs10759290", "x", "3", 5);
newTree30->AddYesNode("rs10185826", "rs1854935", "Q", 1.5);
newTree30->AddNoNode("rs10185826", "x", "3", 5);
newTree30->AddYesNode("rs1854935", "x", "1", 5);
newTree30->AddNoNode("rs1854935", "x", "2", 5);
//output the created tree
newTree30->Output();
//query the tree
string result30;
result30 = newTree30->Query(my);
cout << result30 << endl;
delete newTree30;
myresult.push_back(result30);
*/
calNumReturnResult(myresult);
//took about 15 seconds
system("pause");
return 0;
}
///Users/zhangchi/Desktop/Machine learning_1/Test_data_270_50000_markers.csv
/*
#include "common.hpp"
int main(int argc, char *argv[]){
int c;
char * inputFile = NULL;
char * output_file = NULL;
while ((c = getopt (argc, argv, "i:o:")) != -1){
switch (c)
{
case 'i':
// fprintf(stderr,"[%s]-> ",optarg);
if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-'){
fprintf (stderr,
"Found illegal or NULL parameter for the option -i.\n");
return 1;
}
inputFile = optarg;
break;
case 'o':
// fprintf(stderr,"[%s]-> ",optarg);
if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-'){
fprintf (stderr,
"Found illegal or NULL parameter for the option -o.\n");
return 1;
}
output_file = optarg;
break;
case '?':
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
return 1;
}
}
if (inputFile != NULL){
std::cout << inputFile << std::endl;
}
if (output_file != NULL){
std::cout << output_file << std::endl;
}
auto str = "Hello World!!";
return 0;
}
*/
|
dcee00f832c03eb7a877d63d239da70463099ad8 | a1dfaf49d2672cc28244144274b9d62e560c23e4 | /Reni/NumberType.cpp | 270525bcd9c370390156088023352eb6cdac638d | [
"MIT"
] | permissive | hahoyer/reni.cpp | 89e8ae0e87afd21f463103fd0014361d13ef38b7 | de3d775af833fc4d508bc8a7e8538ec8ba870707 | refs/heads/master | 2022-12-05T06:53:26.367042 | 2022-11-28T19:14:55 | 2022-11-28T19:14:55 | 16,156,275 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,278 | cpp | NumberType.cpp | #include "Import.h"
#include "NumberType.h"
#include "Address.h"
#include "AddressType.h"
#include "ArrayType.h"
#include "CodeItems.h"
#include "ContainerContext.h"
#include "Context.h"
#include "DefineableToken.h"
#include "ExpressionSyntax.h"
#include "Feature.h"
#include "Global.h"
#include "ReplaceVisitor.h"
#include "Result.h"
#include "SyntaxContainer.h"
#include "VoidType.h"
#include "../HWLib/RefCountContainer.instance.h"
namespace Reni
{
class NumberConversionProvider final : public Feature::Extended
{
using baseType = Extended;
using thisType = NumberConversionProvider;
ResultData Result(Category const&category, Type const& target, Type const& destination) const override
{
const auto destinationAddress = destination.toAddress;
return ResultData::GetSmartHollowSizeClosure
(
category,
l_(CodeItem::NumberConversion(destinationAddress, target)),
l_(&destination.thisRef)
);
}
};
}
using namespace Reni;
static bool Trace = true;
NumberType::NumberType(WeakRef<ArrayType> const parent)
: parent(*parent)
{
SetDumpString();
HW_ASSERT(!parent->hollow, HW_D_VALUE(parent));
}
HW_PR_IMPL_GETTER(NumberType, Size, size){return parent.size;};
HW_PR_IMPL_GETTER(NumberType, WeakRef<Global>, global){return parent.global;};
HW_PR_IMPL_GETTER(NumberType, Array<string>,DumpData){ return{HW_D_VALUE(parent)}; };
HW_PR_IMPL_GETTER(NumberType, string, DumpShort)
{
return HW_PR_BASE_GETTER_NAME(DumpShort) + " size=" + size.DumpShort;
}
SearchResult<Feature> NumberType::DeclarationsForType(DeclarationType const& target) const
{
return target.Declarations(*this);
};
SearchResult<Feature> const NumberType::Declarations(NumberType const& provider) const
{
if (size < provider.size)
return{};
return Feature::From<NumberConversionProvider>(*this);
}
SearchResult<Feature> const NumberType::Declarations(EnableCutType const& ) const
{
return Feature::From<NumberConversionProvider>(*this);
}
WeakRef<NumberType> const NumberType::Resize(size_t newSize)const
{
return parent
.elementType
.array(newSize)
->numberType
->thisRef;
} |
1df9a01d316d71eefac5c5d99c2d2add14ba6934 | ebe1e922d0237f8bf79d018cab7ff9878fcd2101 | /EGG-club/xep_ba_lo_khong_de_qui.cpp | 0ecfcba898c99bca23aced331d7723b1146b8cb8 | [] | no_license | BinhMinhs10/dev-C- | b79d1ea314c314e1dea8c4fef4c8e7d489285deb | 7100683517bdde4840545fa4c7f8ececd5eff618 | refs/heads/master | 2021-04-15T18:33:05.080965 | 2018-03-23T16:17:09 | 2018-03-23T16:17:09 | 126,510,397 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 869 | cpp | xep_ba_lo_khong_de_qui.cpp | #include <stdio.h>
#include <conio.h>
#include <stdlib.h>
main()
{
int a[100],b[100],n,m,j,t,s=0;
printf("nhap khoi luong toi da ba lo: "); scanf("%d",&m);
printf("\nnhap so luong: "); scanf("%d",&n);
printf("nhap khoi luong va gia tri: \n");
for(int i=0;i<n;i++)
{
printf("\na[%d]= ",i+1); scanf("%d",&a[i]);
printf("\nb[%d]= ",i+1); scanf("%d",&b[i]);
}
int k,temp,flag;
for(int i=1;i<n;i++)
{
temp=b[i];
flag=a[i];
k=i-1;
while((k>=0)&&(b[k]>temp))
{
b[k+1]=b[k];
a[k+1]=a[k];
k--;
}
a[k+1]=flag;
b[k+1]=temp;
}
for(int i=n;i>0;i--)
{
s+=a[i]; t=t+a[i]*b[i];
if(s>m)
{
t=t-(s-m)*b[i];
j=i+1;
break;
}
}
printf("\nnhung hang can lay: ");
for(int i=n-1;i>=j;i--)
{
if(i==j)
{
printf("\n%d",s-m); printf("\t%d",b[i]);
}
else
{
printf("\n%d",a[i]); printf("\t%d",b[i]);
}
}
getch();
}
|
d1b16937fa0b5ebbf93962d25bd0c196c6224f62 | 36c78b7dd2992a055b380be9e2fdb92d4173b04a | /713 - Adding Reversed Numbers.cpp | f6cc933a6405ac5b580c2f0ad05b95695ea90316 | [] | no_license | israt-urme/UVA | a8a9231a114f5687f0e63cd0af205f7692098457 | 528475a54ea0b334c9c563463a1d1cc9b8cad6bb | refs/heads/master | 2023-06-03T00:45:35.199764 | 2021-06-28T09:09:15 | 2021-06-28T09:09:15 | 380,964,471 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 437 | cpp | 713 - Adding Reversed Numbers.cpp | #include<bits/stdc++.h>
using namespace std;
long long int r(long long int x);
int main()
{
long long int t,a,b,sum,sum1,sum2,c;
cin>>t;
while(t--)
{
cin>>a>>b;
sum=r(a);
sum1=r(b);
c=sum+sum1;
cout<<r(c)<<endl;
}
return 0;
}
long long int r(long long int a)
{
long long int sum=0;
while(a!=0)
{
sum=sum*10+a%10;
a=a/10;
}
return sum;
}
|
9b755aae849574c57cd4c2230a84b4f5bb74d7b3 | ad01d0a97641df1b0f57b9e2bb8c5558ce2f0cbd | /autoroute.cpp | c586f62e810b206f4e3c2325024e74d7ae444427 | [] | no_license | yangbo/autoroute | 36107d501ec26e09213c827fecbebf018c9a5f61 | 33c3a65bca9c0b1df1b9070db53ac38bb5908a73 | refs/heads/master | 2016-10-15T11:43:21.474498 | 2011-09-22T18:25:17 | 2011-09-22T18:25:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,822 | cpp | autoroute.cpp | #include "stdafx.h"
#include "resource.h"
#include "autoroute.h"
#include <atlsync.h>
#include <atlutil.h>
#include <Ras.h>
#include <IPHlpApi.h>
#include "atl_ext.h"
#include "messages.h"
#pragma comment(lib, "Rasapi32")
#pragma comment(lib, "iphlpapi")
#pragma comment(lib, "ws2_32")
class CAutoRouteModule : public ATL::CAtlServiceModuleT<CAutoRouteModule, IDS_SERVICENAME>, public ATL::IWorkerThreadClient {
ATL::CWorkerThread<> connectionListenerThread;
DWORD addRoute(PCTSTR ip, PCTSTR mask, PCTSTR gateway, DWORD interfaceIndex) {
ATL::EmptyStruct<MIB_IPFORWARDROW> row;
row.dwForwardProto = MIB_IPPROTO_NETMGMT;
row.dwForwardIfIndex = interfaceIndex;
row.dwForwardType = 4;
row.dwForwardAge = INFINITE;
row.dwForwardMetric1 = 1;
row.dwForwardMetric2 =
row.dwForwardMetric3 =
row.dwForwardMetric4 = -1;
row.dwForwardDest = inet_addr(ATL::CT2A(ip));
row.dwForwardMask = inet_addr(ATL::CT2A(mask));
row.dwForwardNextHop = inet_addr(ATL::CT2A(gateway));
return CreateIpForwardEntry(&row);
}
void LogEventEx(const DWORD id, const WORD category, PCTSTR* strings,
const WORD count, WORD type) throw() {
if (m_szServiceName) {
HANDLE hEventSource = RegisterEventSource(NULL, m_szServiceName);
if (hEventSource != NULL) {
ReportEvent(hEventSource,
type,
category,
id,
NULL,
count,
0,
strings,
NULL);
DeregisterEventSource(hEventSource);
}
}
}
virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* pRegistrar) throw() {
pRegistrar->AddReplacement(_T("ServiceName"), m_szServiceName);
ATL::CStringW types;
types.Format(_T("%d"), EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE);
pRegistrar->AddReplacement(_T("SupportedTypes"), types);
return __super::AddCommonRGSReplacements(pRegistrar);
}
HRESULT Execute(DWORD_PTR dwParam, HANDLE hObject) {
DWORD size = 0;
PIP_ADAPTER_ADDRESSES ipadapters = (PIP_ADAPTER_ADDRESSES)HeapAlloc(GetProcessHeap(), 0, sizeof(IP_ADAPTER_ADDRESSES));
if (ERROR_BUFFER_OVERFLOW == GetAdaptersAddresses (AF_INET, 0, 0, ipadapters, &size)) {
HeapFree(GetProcessHeap(), 0, ipadapters);
ipadapters = (PIP_ADAPTER_ADDRESSES)HeapAlloc(GetProcessHeap(), 0, size);
}
DWORD error = GetAdaptersAddresses (AF_INET, 0, 0, ipadapters, &size);
if (NO_ERROR != error) {
return HRESULT_FROM_WIN32(error);
}
ATL::CModulePath modulePath;
modulePath.RemoveFileSpec();
for (PIP_ADAPTER_ADDRESSES item = ipadapters; item; item = item->Next) {
// Try to open routes files
ATL::CPath filePath(modulePath);
filePath.Append(item->FriendlyName);
filePath.AddExtension(_T(".ini"));
if (filePath.FileExists()) {
TCHAR ip[MAX_PATH];
TCHAR gateway[MAX_PATH];
TCHAR mask[MAX_PATH];
const TCHAR sectionNameFormat[] = _T("Route.%d");
ATL::CString sectionName;
for (int i=1; ;++i) {
sectionName.Format(sectionNameFormat, i);
GetPrivateProfileString(sectionName, _T("IP"), _T(""), ip, MAX_PATH, filePath);
GetPrivateProfileString(sectionName, _T("Gateway"), _T(""), gateway, MAX_PATH, filePath);
GetPrivateProfileString(sectionName, _T("Mask"), _T("255.255.255.0"), mask, MAX_PATH, filePath);
if (*ip && *gateway && *mask) {
DWORD result = addRoute(ip, mask, gateway, item->IfIndex);
if (NO_ERROR == result) {
PCTSTR args[] = { ip, mask, gateway, item->FriendlyName, filePath };
LogEventEx(ROUTE_SET, CATEGORY_ONE, args, sizeof(args) / sizeof(args[0]), EVENTLOG_SUCCESS);
//LogEvent(_T("Route %s with MASK %s and Gateway %s added for %s using file \"%s\""), ip, mask, gateway, item->FriendlyName, filePath);
} else {
PCTSTR args[] = { ip, mask, gateway, item->FriendlyName, filePath, ATL::AtlErrorMessage(result) };
LogEventEx(ROUTE_NOT_SET, CATEGORY_ONE, args, sizeof(args) / sizeof(args[0]), EVENTLOG_ERROR_TYPE);
//CString message;
//message.Format(_T("Could not add route %s with MASK %s and Gateway %s added for %s using file \"%s\":\nError: %s"), ip, mask, gateway, item->FriendlyName, filePath, AtlErrorMessage(result));
//LogEventEx(0, message, EVENTLOG_ERROR_TYPE);
}
} else {
break;
}
}
}
}
HeapFree(GetProcessHeap(), 0, ipadapters);
/*if (connections != &connection) {
HeapFree(GetProcessHeap(), 0, connections);
}*/
return S_OK;
}
HRESULT CloseHandle(HANDLE handle) {
return ::CloseHandle(handle) ? S_OK : E_FAIL;
}
ATL::CEvent killEvent;
public:
CAutoRouteModule() {
}
void OnStop() {
connectionListenerThread.Shutdown();
__super::OnStop();
}
HRESULT Run(int nShowCmd = SW_HIDE) throw() {
connectionListenerThread.Initialize();
HANDLE connectionEvent = CreateEvent(0, false, false, _T("ConnectionEvent"));
connectionListenerThread.AddHandle(connectionEvent, this, 0);
RasConnectionNotification(0, connectionEvent, RASCN_Connection);
SetEvent(connectionEvent);
return __super::Run(nShowCmd);
}
HRESULT InitializeSecurity() throw() {
return S_OK;
}
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_AUTOROUTE, "{3B6FAF03-9205-41CE-84B5-56921CD61097}")
};
CAutoRouteModule _AtlModule;
extern "C" int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int nShowCmd) {
return _AtlModule.WinMain(nShowCmd);
} |
da07232e4c1797e876f7ed0628037249a8a21154 | 12fe2109410b45b49e5e59d6b6ecaa1845ff5cc3 | /assign8_jlj147/StudentDriver.cpp | f78e2dc8eea8593de8d9348ab6fae240b80733ae | [] | no_license | jlj147/Data-Structures-and-Algorithms-Programs | e5e796e38e6750d3ccb5ab92ab50e51ddf2086ee | 8ecba5a36ae8060d6b4b90b59dfe952147bf2a99 | refs/heads/master | 2020-03-27T17:13:31.893813 | 2018-08-31T03:13:30 | 2018-08-31T03:13:30 | 146,837,076 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,128 | cpp | StudentDriver.cpp | // File Name: StudentDriver.cpp
//
// Author: Jayce Jones
// Date: 11/18/16
// Assignment Number: 8
// CS 3358: Fall 2016
// Instructor: CJ Hwang
//
// Represents a student record list in vector form
// Includes a students ID, name, GPA, and address
// Supports searching for student ID as a way to find the full
// student record
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <vector>
#include <ctime>
#include "Students.h"
using namespace std;
int main()
{
vector <Student> records(20); //Declaration of records vector
int ID; //Variable that students ID from input file is stored in
string name; //Variable that students name from input file is stored in
float GPA; //Variable that students GPA from input file is sotred in
string address; //Variable that students address from input file is stored
int scores[10]; //Array that students scores from input file are stored in
int count = 0; //Counter to count how many records have been pushed
//onto vector
Student found; //Accessor for accessing the records vector
//Read student records into record vector
ifstream fin;
fin.open("records.txt");
if (!fin)
{
cout << "Error - File not found" << endl;
return (0);
}
//Add student records into vector until there are 20 records
do
{
Student *add = nullptr; //Accessor for adding to the records vector
cout << "Adding Records: " << endl;
for (int i=0;i<20;i++)
{
while (fin >> ID)
{
add = new Student;
add -> setID(ID);
records[i].setID(ID);
cin.get();
break;
}
while (fin >> name)
{
add -> setName(name);
records[i].setName(name);
cin.get();
break;
}
while (fin >> GPA)
{
add -> setGPA(GPA);
records[i].setGPA(GPA);
cin.get();
break;
}
while (fin >> address)
{
add -> setAddress(address);
records[i].setAddress(address);
cin.get();
break;
}
for (int k=0;k<10;k++)
{
fin >> scores[k];
add -> setScores(scores);
records[i].setScores(scores);
}
records.push_back(*add); //Push back newest record onto vector
add->print();
count++; //Incriment counter
}
}while(count < 20);
cout << "Count is: " << count << endl;
fin.close(); //Stop reading student records into record vector
cout << endl;
//Display the student record vector
cout << "Student Vector: " << endl;
cout << endl;
for (int j=0;j<20;j++)
{
cout << "ID: " << records[j].getID() << endl;
cout << "Name: " << records[j].getName() << endl;
cout << "GPA: " << records[j].getGPA() << endl;
cout << "Address: "<< records[j].getAddress() << endl;
cout << "Scores: ";
for (int i=0; i<10;i++)
{
cout << records[j].getScores() << " ";
}
cout << endl;
cout << endl;
}
cout << endl;
//Modify the IDs read in from file into random ID numbers
for (int k=0;k<20;k++)
{
int randomNumber;
randomNumber = rand()% 1000000+1;
records[k].setID(randomNumber);
}
found.quickSort(records,0,20);
//Display the student records with new sorted ID's
cout << "Display the new student records sorted by ID"
<< " ready to be searched" << endl;
cout << endl;
for(int i=1; i<20; i++)
{
cout << "ID: " << records[i].getID() << endl;
cout << "Name: " << records[i].getName() << endl;
cout << "GPA: " << records[i].getGPA() << endl;
cout << "Address: "<< records[i].getAddress() << endl;
cout << "Scores: ";
for (int j=0; j<10;j++)
{
cout << records[i].getScores() << " ";
}
cout << endl;
cout << endl;
}
//****Test Cases****
int foundRecord;//The vector subscript returned from the binary search
//Test Case 1: Search for an ID
foundRecord = found.binarySearch(records,0,19,records[1].getID());
cout << "Test Case #1: " << endl;
found.printVect(records, foundRecord);
//Test Case 2: Search for a second ID
foundRecord = found.binarySearch(records,0,19,records[7].getID());
cout << "Test Case #2: " << endl;
found.printVect(records, foundRecord);
//Test Case 3: Search for a third ID
foundRecord = found.binarySearch(records,0,19,records[13].getID());
cout << "Test Case #3: " << endl;
found.printVect(records, foundRecord);
return 0;
}
|
2214d26cf8e919058c95f34a4fa97f3cd78851cc | 92bb12186c0eecce5b6c5b509e1fcd094b578ebc | /Containment and Delegation/Containment and Delegation/target.h | da361f6ffa0105fc31dda4f9c8bb5abefd2b158b | [] | no_license | rosswelltiongco/Data-Structures | 0d443800d45f65e8e2edba06b59479d8d7e72567 | b15be52cd64bfa8d98cc6e260f6a4134d0da8340 | refs/heads/master | 2021-09-01T16:11:38.035402 | 2017-12-27T21:39:35 | 2017-12-27T21:39:35 | 108,180,297 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,884 | h | target.h | /*
Target
Class Target contains an array of circles based on passed in count of rings
*/
#ifndef TARGET_H
#define TARGET_H
#include <iostream>
#include <vector>
using namespace std;
class Target
{
public:
/*
Method Name: Target()
Default constructor
Input Only:
None
Input & Output:
None
Output Only:
None
Returns:
None
Side Effects:
None
*/
Target();
/*
Method Name: Target(x,y,RingRadius,count)
Constructor given x, y, radius, and count of rings
Input Only:
x - x coordinate
y - y coordinate
RingRadius - a ring's radius
count - number of rings in target
Input & Output:
None
Output Only:
None
Returns:
None
Side Effects:
None
*/
Target(int x, int y, int RingRadius, int count);
/*
Method Name: Target(center, count)
Constructor given an existing circle and new ring count
Input Only:
center - an existing circle
count - number of rings
Input & Output:
None
Output Only:
None
Returns:
None
Side Effects:
None
*/
Target(Circle center, int count);
/*
Method Name: Target(center, radius)
Returns member X
Input Only:
None
Input & Output:
None
Output Only:
None
Returns:
x coordinate
Side Effects:
None
*/
/*
Method Name: otherTarget(otherTarget)
Constructor given an existing target
Input Only:
otherTarget - an existing target
Input & Output:
None
Output Only:
None
Returns:
None
Side Effects:
None
*/
Target(const Target &otherTarget);
/*
Method Name: operator=(otherTarget)
Sets target equal to another target
Input Only:
otherTarget - an existing target
Input & Output:
None
Output Only:
None
Returns:
point to the object
Side Effects:
None
*/
Target operator=(const Target &otherTarget);
/*
Method Name: ~Target()
Destructor
Input Only:
None
Input & Output:
None
Output Only:
None
Returns:
None
Side Effects:
None
*/
~Target();
/*
Method Name: getBullsEye()
Retrieves innermost circle
Input Only:
None
Input & Output:
None
Output Only:
None
Returns:
Innermost circle
Side Effects:
None
*/
Circle getBullsEye() const;
/*
Method Name: getCount()
Retrieves number of rings in target
Input Only:
None
Input & Output:
None
Output Only:
None
Returns:
Number of rings
Side Effects:
None
*/
int getCount() const;
/*
Method Name: getRingRadius(ring)
Retrieves the radius of a certain ring
Input Only:
ringToFindRadiusOf - index of ring to the radius
Input & Output:
None
Output Only:
None
Returns:
radius of a particular ring
Side Effects:
None
*/
int getRingRadius(int ringToFindRadiusOf) const;
/*
Method Name: getVectorCircles()
Retrieves array of circles
Input Only:
None
Input & Output:
None
Output Only:
None
Returns:
An array of circles
Side Effects:
None
*/
vector<Circle> getVectorCircles() const;
/*
Method Name: setRingRadius(ringToGetChanged, newRadius)
Changes a ring's radius to a new value
Input Only:
ringToGetChanged - index of ring to be changed
newRadius - the new radius of ring
Input & Output:
None
Output Only:
None
Returns:
None
Side Effects:
None
*/
void setRingRadius(int ringToGetChanged, int newRadius);
/*
Method Name: operator==(otherTarget)
Checks to see if another target is the same
Input Only:
otherTarget - an existing target
Input & Output:
None
Output Only:
None
Returns:
True if the other target is the same
Side Effects:
None
*/
bool operator==(Target &otherTarget);
/*
Method Name: operator!=(otherTarget)
Checks if another target is not the same
Input Only:
otherTarget - an existing target
Input & Output:
None
Output Only:
None
Returns:
True if the other target is not the same
Side Effects:
None
*/
bool operator!=(Target &otherTarget);
/*
Method Name: move(deltaX,deltaY)
Shifts target to a new location
Input Only:
deltaX - change in x coordinate
deltaY - change in y coordinate
Input & Output:
None
Output Only:
None
Returns:
None
Side Effects:
None
*/
void move(int deltaX, int deltaY);
/*
Method Name: getDistance(otherTarget)
Retrieves distance from an existing target
Input Only:
otherTarget - an existing target
Input & Output:
None
Output Only:
None
Returns:
The distance from another target
Side Effects:
None
*/
double Target::getDistance(const Target &otherTarget) const;
/*
Method Name: operator<<(os,t)
Overloads printing operator
Input Only:
t - a target
Input & Output:
os - output stream
Output Only:
None
Returns:
A modified printing message
Side Effects:
Prints all rings and their radii
*/
friend ostream& operator<<(ostream &os, Target &t);
private:
void init(Circle circle, int count);
void copy(const Target &otherTarget);
void deleteAll();
vector<Circle> mVectorCircles;
int mCount;
//Circle mArrayCircles[5];
};
#endif
|
f3cf8ecadaf1365a8d0513e3ffba5bcf62a4b5a9 | 7cd65aa9c59b9746ce5577f123189a36fcd9fcda | /src/test/dissonance_test.cpp | b7887ab1f98b4c020ab57ae2db30597e6c3c6343 | [] | no_license | Phirxian/sacred-fractal | 119274a16fad510c7a452cbf12e75a28601bae59 | 626d95e33602c14b93897b715a18639f9b6a6f4e | refs/heads/main | 2023-01-11T21:02:46.003008 | 2020-11-16T20:39:31 | 2020-11-16T20:39:31 | 313,420,730 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,473 | cpp | dissonance_test.cpp |
#include "../sounds/SignalSource.h"
#include "../sounds/track/Track.h"
#include "../sounds/extractors/Dissonance.h"
#include "../sounds/window/HammingWindow.h"
#include <iostream>
using namespace sacred::sounds;
auto track = std::make_shared<sacred::sounds::Track>();
sacred::sounds::Dissonance dissonance;
sacred::sounds::HammingWindow window;
void printSampleFrameMono(SampleFrame_ptr frame){
using namespace sacred::sounds;
if (!frame->stereo){
/*for (int n=0; n<SignalSource::FRAME_SIZE; ++n){
std::cout << "\t\t\t\t\t\t" << frame.samples_left[n] << "\t\t\t\t\t\t" << std::endl;
}*/
std::cout << "\t\t\t\t\t\t" << frame->samples[0][0] << "\t\t\t\t\t\t" << std::endl;
}else{
std::cerr << "Expected MONO frame, got STEREO (printing)" << std::endl;
}
}
void printSampleFrameStereo(SampleFrame_ptr frame){
using namespace sacred::sounds;
if (frame->stereo){
/*for (int n=0; n<SignalSource::FRAME_SIZE; ++n){
std::cout << frame.samples_left[n] << "\t\t\t\t\t\t" << frame.samples_right[n] << std::endl;
}*/
std::cout << frame->samples[0][0] << "\t\t\t\t\t\t" << frame->samples[1][0] << std::endl;
}else{
std::cerr << "Expected STEREO frame, got MONO (printing)" << std::endl;
}
}
int main(int argc, char* argv[]){
using namespace sacred::sounds;
if (argc != 2){
std::cerr << "Usage : $ ./program audiofilepath" << std::endl;
}
std::string audioFilePath(argv[1]);
track->setFilePath(audioFilePath);
//dissonance.setWindow(window);
dissonance.addInput(track);
SampleFrame_ptr frame;
bool stereo = track->isStereo();
dissonance.setStereo(stereo);
int frameNb = 0;
if (stereo){
std::cout << "STEREO" << std::endl << std::endl;
std::cout << "LEFT"<< "\t\t\t\t\t\t"<< "RIGHT" << std::endl << std::endl;
while (!dissonance.isFinished()){
printSampleFrameStereo(dissonance.getProcessedFrame(++frameNb));
}
std::cout << "<3 ~~~~~~ <3 Finished <3 ~~~~~~ <3" << std::endl;
}
else{
std::cout << "MONO" << std::endl << std::endl;
while (!dissonance.isFinished()){
printSampleFrameMono(dissonance.getProcessedFrame(++frameNb));
}
std::cout << "<3 ~~~~~~ <3 Finished <3 ~~~~~~ <3" << std::endl;
}
return 0;
}
|
ef1e3f8c15dae478652686f4aa1ccb04d8e60c09 | 2ff6b6071f472195707d50c656ea13bb23db2b19 | /Desborde1.cpp | def38468edc7b07b7bba971103e59d003710de06 | [] | no_license | sergiobravo-git/IPC202101 | c0c79b5b8792a321239a30acb2fff516e091e64d | 13b041b1e935779162c55cd80f42630ab20423f0 | refs/heads/master | 2023-04-20T14:21:30.832377 | 2021-05-05T21:22:57 | 2021-05-05T21:22:57 | 359,329,101 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 176 | cpp | Desborde1.cpp | #include<iostream>
using namespace std;
int main()
{
int valor[3];
valor[0]=1;
valor[1]=1;
valor[2]=1;
//valor[3]
cout<<"El programa termino correctamente"<<endl;
}
|
d8d82fc7b1d45ef7e327a60355142d6d4300b451 | 67baab02cfda6c54a287d63d0874824cf15f3ba6 | /atcoder/abc116c.cpp | f0db77b0f1414622270a0cfee398b1ac76fd27ce | [
"MIT"
] | permissive | sogapalag/problems | a14eedd8cfcdb52661479c8c90e08737aaeeb32b | 0ea7d65448e1177f8b3f81124a82d187980d659c | refs/heads/master | 2021-01-12T17:49:52.007234 | 2020-08-18T14:51:40 | 2020-08-18T14:51:40 | 71,629,601 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 409 | cpp | abc116c.cpp | #include <bits/stdc++.h>
using namespace std;
// [0..n] +1 while can, split-by-0
// = increaing
void solve() {
int n; cin >> n;
int las = 0;
int res = 0;
for (int _ = 0; _ < n; _++) {
int x; cin >> x;
if (x > las) res += x-las;
las = x;
}
cout << res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
cout << endl;
}
|
bb2180ea47796d6b10a74857cd1ee9427029abc5 | b9c6efa07b665848ae684ae4e2523c47546f6e2b | /Logic/Objects/water.cpp | 3d2675067412aee4dbaf90f24cf7788a238bc1eb | [] | no_license | radiofox1/ConsoleGame | e8e99c5e029f2dcad22f3ae9769ab959595618cf | b123a8554cd17f41dda076505a5ca2366de3646a | refs/heads/master | 2020-04-28T02:08:50.226816 | 2019-04-17T20:47:22 | 2019-04-17T20:47:22 | 174,887,203 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 97 | cpp | water.cpp | #include "Logic/Objects/water.h"
#include "Logic/Objects/immovable.h"
//Water::Water()
//{
//}
|
3ce4db83fd583dbedbca66f50d6ce1389045d6d4 | cfeac52f970e8901871bd02d9acb7de66b9fb6b4 | /generated/src/aws-cpp-sdk-monitoring/source/model/GetMetricWidgetImageRequest.cpp | 091487f4710a0ff042cb5100fc95bf5f6dc01ca2 | [
"Apache-2.0",
"MIT",
"JSON"
] | permissive | aws/aws-sdk-cpp | aff116ddf9ca2b41e45c47dba1c2b7754935c585 | 9a7606a6c98e13c759032c2e920c7c64a6a35264 | refs/heads/main | 2023-08-25T11:16:55.982089 | 2023-08-24T18:14:53 | 2023-08-24T18:14:53 | 35,440,404 | 1,681 | 1,133 | Apache-2.0 | 2023-09-12T15:59:33 | 2015-05-11T17:57:32 | null | UTF-8 | C++ | false | false | 1,045 | cpp | GetMetricWidgetImageRequest.cpp | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/monitoring/model/GetMetricWidgetImageRequest.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
using namespace Aws::CloudWatch::Model;
using namespace Aws::Utils;
GetMetricWidgetImageRequest::GetMetricWidgetImageRequest() :
m_metricWidgetHasBeenSet(false),
m_outputFormatHasBeenSet(false)
{
}
Aws::String GetMetricWidgetImageRequest::SerializePayload() const
{
Aws::StringStream ss;
ss << "Action=GetMetricWidgetImage&";
if(m_metricWidgetHasBeenSet)
{
ss << "MetricWidget=" << StringUtils::URLEncode(m_metricWidget.c_str()) << "&";
}
if(m_outputFormatHasBeenSet)
{
ss << "OutputFormat=" << StringUtils::URLEncode(m_outputFormat.c_str()) << "&";
}
ss << "Version=2010-08-01";
return ss.str();
}
void GetMetricWidgetImageRequest::DumpBodyToUrl(Aws::Http::URI& uri ) const
{
uri.SetQueryString(SerializePayload());
}
|
7dc8b5aa3571fced9f18dc6f8dca3a9d2c2ddeea | 7a562591320b208409bf98f9caef901bc556f769 | /operators_in_c++/Increment__Decrement_Operators.cpp | d8a0a40dec22d729ab0a96d833c2b2a96d73a38c | [] | no_license | lehuuvinh92/introduction-to-programming | dc0c0db5aa273931b1da5cc905d7acb15999939b | f4ff2cedfebefcbb8cb581aa40e46398fd2e9cd8 | refs/heads/main | 2023-08-02T16:29:41.891172 | 2021-09-30T15:12:20 | 2021-09-30T15:12:20 | 402,616,853 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 545 | cpp | Increment__Decrement_Operators.cpp | // Increment__Decrement_Operators.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int a = 10, b = 100;
cout<<"++a = "<<++a<<endl;
cout<<"a++ = "<<a++<<endl;
cout<<"--b = "<<--b<<endl;
cout<<"b-- = "<<b--<<endl;
cout<<"-----------------"<<endl;
int x = 10;
int y;
y = ++x;//x = 11 and y = 11
cout<<"y = ++x = "<<y<<endl;
x = 10;//assign x=10
y = x++;//y = 10 and x = 11
cout<<"y = x++ = "<<y<<endl;
system("pause");
}
|
e4f534285c8a7b17634cfffd58a2b17b09d6ea02 | cfc44155b3579746f65d7b274358137a8694e655 | /FCNFlashMatch.cxx | 2483acae4b8e00db97de394648a2c45a4d6c7b6d | [] | no_license | LArbys/flashtune1mu1p | 823433daaa3173e4733edd9e7d178b242efc960a | c0826d3678d68e807d1abff41d19de75ccb0c99f | refs/heads/master | 2021-09-09T10:21:22.695506 | 2018-03-15T05:00:13 | 2018-03-15T05:00:13 | 125,099,989 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,912 | cxx | FCNFlashMatch.cxx | #include "FCNFlashMatch.h"
#include <iostream>
#include "TFile.h"
#include "TTree.h"
#include "HandScanTable.h"
namespace ftune {
FCNFlashMatch::FCNFlashMatch( std::string handscantable, std::string flashdata, FCNFlashMatch::HypoType hypotype ) {
// load hand-scan table
if ( !handscantable.empty() ) {
m_goodreco_info = new HandScanTable( handscantable );
fNEntries = m_goodreco_info->numEntries();
std::cout << "HandScanTable Loaded w/ " << fNEntries << "." << std::endl;
}
else {
m_goodreco_info = nullptr;
fNEntries = -1;
std::cout << "No HandScanTable Loaded." << std::endl;
}
fShapeOnly = false;
// load flash data
int run;
int subrun;
int event;
int vtxid;
float pe_data[32];
float pe_hypo[32];
float longestdir[3];
float vertex[3];
TFile froot( flashdata.c_str() );
TTree* tree = (TTree*)froot.Get("ffmatch");
tree->SetBranchAddress( "run", &run );
tree->SetBranchAddress( "subrun", &subrun );
tree->SetBranchAddress( "event", &event );
tree->SetBranchAddress( "vertexid", &vtxid );
tree->SetBranchAddress( "data_pe", pe_data );
if ( hypotype=kMuon )
tree->SetBranchAddress( "hypo_pe_1mu1p", pe_hypo );
else
tree->SetBranchAddress( "hypo_pe_1e1p", pe_hypo );
tree->SetBranchAddress( "longestdir", longestdir );
tree->SetBranchAddress( "vtxpos", vertex );
fNEntries = tree->GetEntries();
std::cout << "Number of Good Reco Entries: " << fNEntries << std::endl;
// data tables
m_data_array.resize(32*fNEntries,0);
// hypo thesis tables
m_hypo_array.resize(32*fNEntries,0);
unsigned long ientry = 0;
unsigned long bytes = tree->GetEntry(ientry);
int idata_entry = 0;
while ( bytes>0 ) {
// we using this vertex?
int entry_goodvtx = -1;
if ( m_goodreco_info )
entry_goodvtx = m_goodreco_info->GetVertexID( run, subrun, event );
// std::cout << "entry " << ientry << ": "
// << "(rse)=(" << run << "," << subrun << "," << event << ") "
// << "vtxid=" << vtxid << " "
// << "goodvtx=" << entry_goodvtx
// << std::endl;
if ( entry_goodvtx==vtxid || m_goodreco_info==nullptr) {
// a good vertex. copy into data arrays
for (int ich=0; ich<32; ich++) {
m_data_array[ 32*idata_entry + ich ] = pe_data[ich];
m_hypo_array[ 32*idata_entry + ich ] = pe_hypo[ich];
}
std::vector<int> rsev(4);
rsev[0] = run;
rsev[1] = subrun;
rsev[2] = event;
rsev[3] = vtxid;
m_rse.push_back( rsev );
std::vector<float> pos(3);
for (int i=0; i<3; i++)
pos[i] = vertex[i];
std::vector<float> dir(3);
for (int i=0; i<3; i++)
dir[i] = longestdir[i];
m_pos.push_back(pos);
m_dir.push_back(dir);
idata_entry++;
}
if ( idata_entry==fNEntries ) {
std::cout << "we've filled all the allotted data positions (" << fNEntries << ")" << std::endl;
break;
}
ientry++;
bytes = tree->GetEntry(ientry);
}
std::cout << "Filled " << idata_entry << " entries" << std::endl;
fNEntries = idata_entry;
m_last_chi2.resize(fNEntries,0.0);
// don't need this anymore
delete m_goodreco_info;
}
FCNFlashMatch::~FCNFlashMatch() {
m_data_array.clear();
m_hypo_array.clear();
}
double FCNFlashMatch::DoEval( const double* x ) const {
float globalfactor = 1;
//if ( !fShapeOnly )
globalfactor = x[32];
// std::cout << "pars [ ";
// for (int i=0; i<33; i++)
// std::cout << x[i] << " ";
// std::cout << "]" << std::endl;
float chi2 = 0;
for (int ientry=0; ientry<fNEntries; ientry++) {
float chi2_entry = 0.;
float norm_hypo = 1.0;
float norm_data = 1.0;
if ( fShapeOnly ) {
norm_hypo = 0.;
norm_data = 0.;
for (int ich=0; ich<32; ich++) {
float pmtfactor = x[ich];
float pred = m_hypo_array[ ientry*32 + ich ]*globalfactor*pmtfactor; // we allow for global correction and per-pmt correction
if ( pred<1.0e-3 )
pred = 1.0e-3;
norm_hypo += pred;
norm_data += m_data_array[ientry*32 + ich];
}
}
for (int ich=0; ich<32; ich++) {
float obs = m_data_array[ ientry*32 + ich ];
float pmtfactor = x[ich];
float pred = m_hypo_array[ ientry*32 + ich ]*globalfactor*pmtfactor; // we allow for global correction and per-pmt correction
if ( pred<1.0e-3)
pred = 1.0e-3;
float diff = (obs/norm_data)-(pred/norm_hypo);
float fracerr_obs = 0.0;
if ( obs>0 )
sqrt(obs)/obs;
float fracerr_pred = sqrt(pred)/pred;
float err_obs = (obs/norm_data)*fracerr_obs;
float err_pred = (pred/norm_hypo)*fracerr_pred;
//float err = sqrt( err_obs*err_obs + err_pred*err_pred );
float err = pred/norm_hypo;
chi2_entry += diff*diff/err;
}
chi2 += chi2_entry;
}
chi2 /= (fNEntries*32-33); // number of bins we're fitting - dof
//std::cout << "total chi2=" << chi2 << std::endl;
//std::cin.get();
return chi2;
};
void FCNFlashMatch::EvalChi2( const double* x ) {
float globalfactor = 1;
//if ( !fShapeOnly )
globalfactor = x[32];
// std::cout << "pars [ ";
// for (int i=0; i<33; i++)
// std::cout << x[i] << " ";
// std::cout << "]" << std::endl;
for (int ientry=0; ientry<fNEntries; ientry++) {
float chi2_entry = 0.;
float norm_hypo = 1.0;
float norm_data = 1.0;
if ( fShapeOnly ) {
norm_hypo = 0.;
for (int ich=0; ich<32; ich++) {
float pred = m_hypo_array[ ientry*32 + ich ]*globalfactor*x[ich]; // we allow for global correction and per-pmt correction
if ( pred<1.0e-3 )
pred = 1.0e-3;
norm_hypo += pred;
norm_data += m_data_array[ientry*32 + ich];
}
}
for (int ich=0; ich<32; ich++) {
float obs = m_data_array[ ientry*32 + ich ]/norm_data;
float pred = m_hypo_array[ ientry*32 + ich ]*globalfactor*x[ich]/norm_hypo; // we allow for global correction and per-pmt correction
if ( pred<1.0e-3)
pred = 1.0e-3;
float diff = obs-pred;
float fracerr_obs = 0.0;
if (obs>0)
fracerr_obs = sqrt(obs)/obs;
float fracerr_pred = sqrt(pred)/pred;
float err_obs = (obs/norm_data)*fracerr_obs;
float err_pred = (pred/norm_hypo)*fracerr_pred;
float err = pred;
chi2_entry += diff*diff/err;
}
// store chi2-entry
m_last_chi2[ientry] = chi2_entry;
}
};
// copy constructor
ROOT::Math::IBaseFunctionMultiDim * FCNFlashMatch::Clone() const {
FCNFlashMatch* clone = new FCNFlashMatch;
clone->fNEntries = this->fNEntries;
clone->m_data_array = this->m_data_array;
clone->m_hypo_array = this->m_hypo_array;
}
std::vector<float> FCNFlashMatch::GetEntryDataPE( int ientry ) {
std::vector<float> pe(32);
float norm = 1.0;
if ( fShapeOnly ) {
norm = 0.;
for (int i=0; i<32; i++)
norm += m_data_array[ 32*ientry+i ];
}
for ( int i=0; i<32; i++) {
pe[i] = m_data_array[ 32*ientry + i ]/norm;
}
return pe;
}
std::vector<float> FCNFlashMatch::GetEntryHypoPE( int ientry, bool shapeonly, const double *pars ) {
std::vector<float> pe(32);
float globalfactor = 1.0;
if ( pars!=NULL )
globalfactor = pars[32];
std::vector<float> pmtfactors(32,1.0);
if ( pars!=NULL ) {
for (int i=0; i<32; i++)
pmtfactors[i] = pars[i];
}
float norm = 1.0;
if (shapeonly ) {
norm = 0.;
for (int i=0; i<32; i++) {
norm += m_hypo_array[ 32*ientry+i ]*pmtfactors[i];
}
}
for ( int i=0; i<32; i++) {
pe[i] = m_hypo_array[ 32*ientry + i ]*pmtfactors[i]/norm;
}
return pe;
}
void FCNFlashMatch::GetEntryRSEV( int ientry, int& run, int& subrun, int& event, int& vtxid ) {
const std::vector<int>& rsev = m_rse[ientry];
run = rsev[0];
subrun = rsev[1];
event = rsev[2];
vtxid = rsev[3];
}
}
|
52d5c526be9095bd62d458af9db79105157ecf0e | 95045938fb3d69309aead4fa08f275ebca8c790e | /dummies/DummyGameServerEngine.h | 81f7501db3f3c42660eb637c2a98d86ae1423f11 | [] | no_license | emrebayrm/BlindGame | 9fc7b88aa75a5f1a7799c03f7ddbce9c6ce59162 | 397647221b8809dc441cb64f84bf9421b7bfc99e | refs/heads/master | 2020-03-23T15:02:30.648385 | 2018-11-29T21:08:32 | 2018-11-29T21:08:32 | 141,716,893 | 0 | 0 | null | 2018-11-29T21:08:33 | 2018-07-20T13:42:23 | C | UTF-8 | C++ | false | false | 517 | h | DummyGameServerEngine.h | //
// Created by patates on 7/17/18.
//
#ifndef BLINDGAME_DUMMYGAMESERVERENGINE_H
#define BLINDGAME_DUMMYGAMESERVERENGINE_H
#include "../engine.hpp"
#include "DummyNetworkModule.h"
class DummyGameServerEngine : public GameServerEngine {
public:
DummyGameServerEngine(){
networkModule = new DummyNetworkModule();
}
Command *doHandshake() override;
Game *createGame(GameCreateCommand_t createPacket, GameJoinCommand_t joinPacket) override;
};
#endif //BLINDGAME_DUMMYGAMESERVERENGINE_H
|
569dc108d961b3eb1d0d8a741f70e8123716dcf3 | 64a71ce005efd1733bfcf8268ea1455f6f6c05ea | /Neural Net/NetworkDialog.h | 5cac51e22f09eadb04ba2167a9e80ca151919879 | [] | no_license | sdiersen/Neural-Net | 28b924b1645b4880d329e6a66ec9f5e86a892c70 | 297c0c5a8fec644220b407530fab21d733b0f7a9 | refs/heads/master | 2023-03-04T22:01:01.922211 | 2021-02-12T23:30:11 | 2021-02-12T23:30:11 | 334,412,152 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,234 | h | NetworkDialog.h | #pragma once
#include "afxwin.h"
// CNetworkDialog dialog
class CNetworkDialog : public CDialogEx
{
DECLARE_DYNAMIC(CNetworkDialog)
public:
CNetworkDialog(CWnd* pParent = NULL); // standard constructor
virtual ~CNetworkDialog();
// Dialog Data
enum { IDD = IDD_CREATENETWORK };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CEdit nameControl;
CEdit inputControl;
CEdit outputControl;
CEdit hidden1Control;
CEdit hidden2Control;
CEdit hidden3Control;
CEdit hidden4Control;
CEdit learningRateControl;
CEdit momentumControl;
CButton validateControl;
CButton okControl;
CEdit errorControl;
CString name;
int input;
int output;
int hidden1;
int hidden2;
int hidden3;
int hidden4;
double learningRate;
double momentum;
CString error;
afx_msg void OnEnChangeCnNetname();
afx_msg void OnEnChangeCnNetinput();
afx_msg void OnEnChangeCnNetoutput();
afx_msg void OnEnChangeCnNethidden1();
afx_msg void OnEnChangeCnNethidden2();
afx_msg void OnEnChangeCnNethidden3();
afx_msg void OnEnChangeCnNethidden4();
afx_msg void OnEnChangeCnNetlearning();
afx_msg void OnEnChangeCnNetmomentum();
afx_msg void OnBnClickedCnNetvalidate();
};
|
42af931d2e8e78a3af954eaf3eafa83c71875305 | a8fb07f8e48781870ddbeb23491d24a91fdb24a9 | /SSBPLib/ss/SS5Player.cpp | 203f4a48a82f6c5df92b4124f4391ec83900af03 | [
"MIT"
] | permissive | kagematya/SSBPLib | 1678668c1a5e3b6b18127a434ddf05d6020eb465 | c3aa88c9997d295144e00f9c806dbfb5e55392ae | refs/heads/master | 2023-04-07T10:13:14.061238 | 2023-03-25T16:22:00 | 2023-03-25T16:22:00 | 78,367,526 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 15,060 | cpp | SS5Player.cpp | #include "SS5Player.h"
#include <time.h>
#include "SS5PlayerData.h"
#include "SS5PlayerTypes.h"
#include "player/ToPointer.h"
#include "player/DataArrayReader.h"
#include "player/Util.h"
#include "player/AnimeCache.h"
#include "player/CellCache.h"
#include "player/CustomSprite.h"
#include "player/EffectCache.h"
#include "player/State.h"
#include "player/ResourceSet.h"
#include "player/PlayerDef.h"
#include "player/InstancePartStatus.h"
#include "ResultState.h"
#include "SS5ResourceManager.h"
#include "SS5EventListener.h"
#include "effect/ssplayer_effect2.h"
#include "SS5Effect.h"
using namespace std;
namespace ss{
//乱数シードに利用するユニークIDを作成します。
//この値は全てのSS5プレイヤー共通で使用します
static int s_seedMakeID = 123456;
//エフェクトに与えるシードを取得する関数
static unsigned int getRandomSeed()
{
s_seedMakeID++; //ユニークIDを更新します。
//時間+ユニークIDにする事で毎回シードが変わるようにします。
unsigned int rc = (unsigned int)time(0) + (s_seedMakeID);
return rc;
}
SS5Player::SS5Player(SS5EventListener* eventListener, const ResourceSet* resource, const string& animeName)
: m_eventListener(eventListener)
, m_resource(resource)
, m_animationData(nullptr)
, m_textures()
, m_parts()
, m_drawOrderIndex()
, m_partVisible()
, m_changeCellIndex()
, m_currentFrameTime(0.0f)
, m_seedOffset(0)
, m_rootMatrix()
, m_alpha(1.0f)
{
SS_ASSERT_LOG(m_eventListener, "eventListener is null");
SS_ASSERT_LOG(m_resource, "resource is null");
//ロードイベントを投げてcellMapのテクスチャを取得する
int cellMapNum = m_resource->m_cellCache->getCellMapNum();
m_textures.resize(cellMapNum);
for(int i = 0; i < cellMapNum; ++i){
const CellMapTextureInfo& texInfo = m_resource->m_cellCache->getTextureInfo(i);
m_textures[i] = m_eventListener->TextureLoad(
i, texInfo.m_imagePaths, texInfo.m_wrapMode, texInfo.m_filterMode
);
}
//最初にアニメーションを入れておく
play(animeName, 0);
SS_ASSERT_LOG(m_animationData, "animationData is null");
}
SS5Player::~SS5Player()
{
releaseParts();
//テクスチャの解放イベントを投げる
for(TextureID textureID : m_textures){
m_eventListener->TextureRelease(textureID);
}
m_textures.clear();
}
void SS5Player::play(const string& animeName, float startFrame)
{
const AnimeRef* animeRef = m_resource->m_animeCache->getReference(animeName);
SS_ASSERT_LOG(animeRef, "Not found animation > anime=%s", animeName.c_str());
play(animeRef, startFrame);
}
void SS5Player::play(const AnimeRef* animeRef, float startFrame)
{
m_animationData = animeRef;
allocParts(animeRef->m_numParts); //割り当て
setPartsParentage(); //親子関係構築
setCurrentFrame(startFrame);
setFrame(getCurrentFrameInt());
//play実行時に最初のフレームのユーザーデータを確認する
checkUserData(getCurrentFrameInt());
}
void SS5Player::allocParts(int numParts)
{
releaseParts(); //すべてのパーツを消す
//パーツ数だけ用意する
m_parts.resize(numParts);
m_drawOrderIndex.resize(numParts, 0);
m_partVisible.resize(numParts, true);
m_changeCellIndex.resize(numParts, -1);
}
void SS5Player::releaseParts()
{
// パーツの子CustomSpriteを全て削除
for(int i = 0; i < m_parts.size(); ++i){
CustomSprite* sprite = &m_parts[i];
//ChildPlayerがあるなら、spriteを破棄する前にリリースイベントを飛ばす
if(sprite->isInstancePart()){
m_eventListener->ChildPlayerRelease(i);
}
if(sprite->isEffectPart()){
m_eventListener->EffectRelease(i);
}
}
m_parts.clear();
}
void SS5Player::setPartsParentage()
{
ToPointer ptr(m_resource->m_data);
//親子関係を設定
for(int partIndex = 0; partIndex < m_parts.size(); partIndex++){
const PartData* partData = m_animationData->getPartData(partIndex);
CustomSprite* sprite = &m_parts.at(partIndex);
if(partData->parentIndex < 0){
sprite->m_parent = nullptr;
}
else{
sprite->m_parent = &m_parts.at(partData->parentIndex);
}
//変化しない値はここでセットします
sprite->m_partType = static_cast<AnimationPartType>(partData->type);
sprite->m_blendfunc = static_cast<BlendType>(partData->alphaBlendType);
//インスタンスパーツならChildPlayerの生成イベントを飛ばす
if(sprite->isInstancePart()){
string refanimeName = ptr.toString(partData->refname);
m_eventListener->ChildPlayerLoad(partIndex, refanimeName);
}
//エフェクトパーツならパラメータを設定する
if(sprite->isEffectPart()){
string refeffectName = ptr.toString(partData->effectfilename);
m_eventListener->EffectLoad(partIndex, refeffectName, getRandomSeed());
}
}
}
const string& SS5Player::getPlayAnimeName() const{
return m_animationData->m_animePath;
}
int SS5Player::getMaxFrame() const{
return m_animationData->m_animationData->numFrames;
}
// 指定したアニメーションの総フレーム数を取得
int SS5Player::getMaxFrame(const string& animeName) const
{
const AnimeRef* animeRef = m_resource->m_animeCache->getReference(animeName);
SS_ASSERT_LOG(animeRef, "Not found animation > anime=%s", animeName.c_str());
return animeRef->m_animationData->numFrames;
}
float SS5Player::getCurrentFrame() const {
return m_currentFrameTime;
}
int SS5Player::getCurrentFrameInt() const{
return static_cast<int>(m_currentFrameTime);
}
void SS5Player::setCurrentFrame(float frame){
m_currentFrameTime = frame;
}
void SS5Player::update(float dt)
{
// フレームを進める.
float nextFrameTime = m_currentFrameTime + (dt * getAnimeFPS());
float nextFrameRemainder = nextFrameTime - static_cast<int>(nextFrameTime);
int checkFrame = getCurrentFrameInt(); // ここから整数単位でフレームを進め、イベントをチェックする
int seekCount = nextFrameTime - checkFrame; // 進めるフレーム数
// 順再生時.
for(int i = 0; i < seekCount; ++i){
checkFrame = m_eventListener->LimitFrame(checkFrame + 1, getMaxFrame()); //範囲制限
SS_ASSERT_LOG(0 <= checkFrame && checkFrame < getMaxFrame(), "checkFrame is out of range. checkFrame=%d", checkFrame);
// このフレームのユーザーデータをチェック
checkUserData(checkFrame);
if(checkFrame == 0){ //一巡した
m_seedOffset++; //シードオフセットを加算
}
}
// 逆再生時.
for(int i = 0; i > seekCount; --i){
checkFrame = m_eventListener->LimitFrame(checkFrame - 1, getMaxFrame()); //範囲制限
SS_ASSERT_LOG(0 <= checkFrame && checkFrame < getMaxFrame(), "checkFrame is out of range. checkFrame=%d", checkFrame);
// このフレームのユーザーデータをチェック
checkUserData(checkFrame);
if(checkFrame == getMaxFrame()-1){ //一巡した
m_seedOffset++; //シードオフセットを加算
}
}
m_currentFrameTime = checkFrame + nextFrameRemainder;
setFrame(getCurrentFrameInt());
}
//再生しているアニメーションに含まれるパーツ数を取得
int SS5Player::getPartsNum() const
{
return m_parts.size(); //return _animationData->m_numParts;
}
//indexからパーツ名を取得
string SS5Player::getPartName(int partIndex) const
{
ToPointer ptr(m_resource->m_data);
const PartData* partData = m_animationData->getPartData(partIndex);
const char* name = ptr.toString(partData->name);
return name;
}
//パーツ名からindexを取得
int SS5Player::indexOfPart(const string& partName) const
{
ToPointer ptr(m_resource->m_data);
for (int i = 0; i < m_animationData->m_numParts; i++){
const PartData* partData = m_animationData->getPartData(i);
const char* name = ptr.toString(partData->name);
if(partName == name){ //if(partName == getPartName(i)) と同じ
return i;
}
}
return -1;
}
//パーツ情報取得
void SS5Player::getPartState(ResultState* result, int partIndex) const
{
SS_ASSERT(result);
SS_ASSERT(partIndex >= 0 && partIndex < m_parts.size());
ToPointer ptr(m_resource->m_data);
const PartData* partData = m_animationData->getPartData(partIndex);
const CustomSprite* sprite = &m_parts[partIndex];
result->m_worldMatrix = &(sprite->m_worldMatrix);
result->m_alpha = sprite->m_alpha;
result->m_boundsType = static_cast<BoundsType>(partData->boundsType);
result->boundingRadius = sprite->m_state.getBoundingRadius();
result->m_colorLabel = ptr.toString(partData->colorLabel);
}
//ラベル名からラベルの設定されているフレームを取得
//ラベルが存在しない場合は戻り値が-1となります。
//ラベル名が全角でついていると取得に失敗します。
int SS5Player::getLabelToFrame(const string& labelName) const
{
ToPointer ptr(m_resource->m_data);
const AnimationData* animeData = m_animationData->m_animationData;
if (!animeData->labelData) return -1;
const ss_offset* labelDataIndex = static_cast<const ss_offset*>(ptr(animeData->labelData));
for (int i = 0; i < animeData->labelNum; i++ ){
if (!labelDataIndex[i]) return -1;
const ss_u16* labelDataArray = static_cast<const ss_u16*>(ptr(labelDataIndex[i]));
DataArrayReader reader(labelDataArray);
ss_offset offset = reader.readOffset();
const char* str = ptr.toString(offset);
int labelFrame = reader.readU16();
if(labelName == str){
return labelFrame; //同じ名前のラベルが見つかった
}
}
return -1;
}
//特定パーツの表示、非表示を設定します
//パーツ番号はスプライトスタジオのフレームコントロールに配置されたパーツが
//プライオリティでソートされた後、上に配置された順にソートされて決定されます。
void SS5Player::setPartVisible(int partIndex, bool visible)
{
SS_ASSERT(partIndex >= 0 && partIndex < m_parts.size());
m_partVisible[partIndex] = visible;
}
//パーツに割り当たるセルを変更します
void SS5Player::setPartCell(int partIndex, const string& cellname)
{
int changeCellIndex = -1;
if (cellname != ""){
changeCellIndex = m_resource->m_cellCache->indexOfCell(cellname);
}
m_changeCellIndex[partIndex] = changeCellIndex; //セル番号を設定
}
void SS5Player::setFrame(int frameNo)
{
ToPointer ptr(m_resource->m_data);
const AnimationData* animeData = m_animationData->m_animationData;
const ss_offset* frameDataIndex = static_cast<const ss_offset*>(ptr(animeData->frameData));
const ss_u16* frameDataArray = static_cast<const ss_u16*>(ptr(frameDataIndex[frameNo]));
DataArrayReader reader(frameDataArray);
const AnimationInitialData* initialDataList = ptr.toAnimationInitialDatas(animeData);
//各パーツの読み取り
for (int index = 0; index < m_parts.size(); index++){
int partIndex = reader.readS16();
m_drawOrderIndex[index] = partIndex;
const AnimationInitialData* init = &initialDataList[partIndex];
CustomSprite* sprite = &m_parts.at(partIndex);
sprite->m_state.readData(reader, init);
//セルを取得する
int cellIndex = sprite->m_state.getCellIndex();
if (m_changeCellIndex[partIndex] != -1){ //ユーザーがセルを上書きした場合はそちらを使う
cellIndex = m_changeCellIndex[partIndex];
}
const CellRef* cellRef = cellIndex >= 0 ? m_resource->m_cellCache->getReference(cellIndex) : nullptr;
//各パーツのテクスチャ情報を設定
sprite->m_textureID = TEXTURE_ID_INVALID;
if (cellRef){
sprite->m_textureID = m_textures[cellRef->m_cellMapIndex];
}
//quad更新
sprite->constructQuad(cellRef);
}
// 行列更新してワールド変換する
for(CustomSprite& sprite : m_parts){
sprite.updateToWorld(m_rootMatrix, m_alpha);
}
// 特殊パーツのアップデート
for (int partIndex = 0; partIndex < m_parts.size(); partIndex++){
CustomSprite* sprite = &m_parts[partIndex];
//インスタンスアニメーションがある場合は親パーツ情報を通知する
if(sprite->isInstancePart()){
m_eventListener->ChildPlayerUpdate(
partIndex, sprite->m_worldMatrix, sprite->m_alpha,
frameNo, sprite->m_state.getInstanceValue() //InstancePartStatus::getFrame(frameNo), m_independent,,,
);
}
//エフェクトのアップデート
if (sprite->isEffectPart()){
m_eventListener->EffectUpdate(
partIndex, sprite->m_worldMatrix, sprite->m_alpha,
frameNo, m_seedOffset, sprite->m_state.getEffectValue()
);
}
}
}
//プレイヤーの描画
void SS5Player::draw()
{
for (int index = 0; index < m_parts.size(); index++){
int partIndex = m_drawOrderIndex[index];
//スプライトの表示
const CustomSprite& sprite = m_parts[partIndex];
//非表示設定なら無視する
if(sprite.isVisibled() == false || m_partVisible[partIndex] == false){ //ユーザーが任意に非表示としたパーツも考慮する
continue;
}
//パーツタイプに応じた描画イベントを投げる
if (sprite.isInstancePart()){
m_eventListener->ChildPlayerDraw(partIndex); //インスタンスパーツ
}
else if (sprite.isEffectPart()){
m_eventListener->EffectDraw(partIndex); //エフェクトパーツ
}
else{
const State& state = sprite.m_state;
m_eventListener->DrawSprite(sprite.m_quad, sprite.m_textureID, sprite.m_blendfunc, state.getColorBlendVertexFunc());
}
}
}
//描画したときのAABBを返す
AABB3 SS5Player::getAABB() const
{
AABB3 aabb;
for (int i = 0; i < m_parts.size(); i++) {
const CustomSprite& sprite = m_parts[i];
// 非表示設定なら無視する
if (sprite.isVisibled() == false || m_partVisible[i] == false) {
continue;
}
if (sprite.isInstancePart() || sprite.isEffectPart()) {
continue;
}
aabb.absorb(sprite.m_quad.tl.vertices);
aabb.absorb(sprite.m_quad.tr.vertices);
aabb.absorb(sprite.m_quad.bl.vertices);
aabb.absorb(sprite.m_quad.br.vertices);
}
return aabb;
}
void SS5Player::checkUserData(int frameNo)
{
ToPointer ptr(m_resource->m_data);
const AnimationData* animeData = m_animationData->m_animationData;
if (!animeData->userData) return;
const ss_offset* userDataIndex = static_cast<const ss_offset*>(ptr(animeData->userData));
if (!userDataIndex[frameNo]) return;
const ss_u16* userDataArray = static_cast<const ss_u16*>(ptr(userDataIndex[frameNo]));
DataArrayReader reader(userDataArray);
int numUserData = reader.readU16();
for (int i = 0; i < numUserData; i++){
UserData userData;
userData.readData(reader, ptr);
m_eventListener->OnUserData(userData, frameNo);
}
}
int SS5Player::getAnimeFPS() const{
return m_animationData->m_animationData->fps;
}
// RootMatrix
void SS5Player::setRootMatrix(const Matrix& matrix) {
m_rootMatrix = matrix;
}
const Matrix& SS5Player::getRootMatrix() const {
return m_rootMatrix;
}
// alpha
void SS5Player::setAlpha(float a) {
m_alpha = clamp(a, 0.0f, 1.0f);
}
float SS5Player::getAlpha() const {
return m_alpha;
}
vector<string> SS5Player::getAnimationList() const{
return m_resource->m_animeCache->getAnimationList();
}
};
|
59ba8d410f42c65e76b602ca4e70a4626fec86c2 | db77c0cb6337a8db5b6240fdcf8a138f495d7e51 | /Classes/AiTest.cpp | bf77c57e23dfcc923b90d96ee2123057dd51e6ef | [] | no_license | Fitz135/game | bd12dbe010e882c7c7deea13bfc333c4cab6587f | 0cee6c50529d42c149a60f5915953409a83946b5 | refs/heads/master | 2020-05-09T16:38:27.792439 | 2019-06-27T12:02:27 | 2019-06-27T12:02:27 | 181,276,392 | 0 | 0 | null | 2019-06-27T12:02:28 | 2019-04-14T07:49:19 | C++ | UTF-8 | C++ | false | false | 391 | cpp | AiTest.cpp | #include"AiTest.h"
AiTest::AiTest(std::string name, int type) :Player(name, type) {
isUp = false;
isRight = false;
isDown = false;
isLeft = false;
//
}
AiTest* AiTest::create(std::string name,int type) {
auto ai = static_cast<AiTest*>(Player::create(name,type));
ai->isUp = false; //
ai->isRight = false;
ai->isDown = false;
ai->isLeft = false;
//ai->_type = type;
return ai;
} |
c8a432aa1715a5fd260e138e4446a884723fa17a | c0fa97ed5e259da94e6d6396f78d2c3782ab1b46 | /source/rvg-harfbuzz-buffer.h | 47e0d734fecdba1f3980b671e783145a55f8bfd2 | [] | no_license | hadryansalles/vector-graphics-renderer | 59a27b72a5e647fbb3c4b6601cd0235b36b9bd01 | 894136ce1436897e20ef00fcbd6bdf39eb7c312c | refs/heads/master | 2023-03-09T15:18:20.647791 | 2021-02-25T18:28:05 | 2021-02-25T18:28:05 | 232,360,396 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,221 | h | rvg-harfbuzz-buffer.h | #ifndef RVG_HARFBUZZ_BUFFER_H
#define RVG_HARFBUZZ_BUFFER_H
#include <hb.h>
#include <hb-icu.h>
#include "rvg-ptr.h"
#include "rvg-harfbuzz-features.h"
namespace rvg {
class harfbuzz_buffer: public boost::intrusive_ref_counter<harfbuzz_buffer> {
hb_buffer_t *m_buffer;
public:
using ptr = boost::intrusive_ptr<harfbuzz_buffer>;
using const_ptr = boost::intrusive_ptr<const harfbuzz_buffer>;
harfbuzz_buffer() {
m_buffer = hb_buffer_create();
if (m_buffer != hb_buffer_get_empty()) {
hb_buffer_set_unicode_funcs(m_buffer, hb_icu_get_unicode_funcs());
hb_buffer_set_direction(m_buffer, HB_DIRECTION_LTR); // default
}
}
~harfbuzz_buffer() {
if (valid()) {
hb_buffer_destroy(m_buffer);
}
}
int valid(void) const {
return m_buffer != hb_buffer_get_empty();
}
void set_direction(const char *dir_str, int len) {
hb_direction_t dir = hb_direction_from_string(dir_str, len);
if (dir != HB_DIRECTION_INVALID)
hb_buffer_set_direction(m_buffer, dir);
}
void set_direction(hb_direction_t dir) {
hb_buffer_set_direction(m_buffer, dir);
}
void set_script(hb_script_t script) {
hb_buffer_set_script(m_buffer, script);
}
void set_script(const char *script_str, int len) {
hb_script_t script = hb_script_from_string(script_str, len);
if (script != HB_SCRIPT_INVALID)
hb_buffer_set_script(m_buffer, script);
}
void set_language(const char *lang_str, int len) {
hb_language_t lang = hb_language_from_string(lang_str, len);
if (lang != HB_LANGUAGE_INVALID)
hb_buffer_set_language(m_buffer, lang);
}
void set_language(hb_language_t lang) {
hb_buffer_set_language(m_buffer, lang);
}
void set_cluster_level(hb_buffer_cluster_level_t level) {
hb_buffer_set_cluster_level(m_buffer, level);
}
void guess_segment_properties(void) {
hb_buffer_guess_segment_properties(m_buffer);
}
void add(const char *data, int data_len, int text_os, int text_len) {
hb_buffer_add_utf8(m_buffer, data, data_len, text_os, text_len);
}
void add(const char *data) {
add(data, -1, 0, -1);
}
void reset(void) {
hb_buffer_reset(m_buffer);
}
void shape(harfbuzz_font::ptr font, harfbuzz_features::const_ptr feat) {
if (feat && !feat->empty()) {
int len = static_cast<int>(feat->size());
hb_shape(font->get(), m_buffer, &(*feat)[0], len);
} else {
hb_shape(font->get(), m_buffer, nullptr, 0);
}
}
void shape(harfbuzz_font::ptr font) {
hb_shape(font->get(), m_buffer, nullptr, 0);
}
void normalize_glyphs(void) {
hb_buffer_normalize_glyphs(m_buffer);
}
hb_glyph_info_t* get_glyph_infos(unsigned *length) {
return hb_buffer_get_glyph_infos(m_buffer, length);
}
hb_glyph_position_t* get_glyph_positions(unsigned *length) {
return hb_buffer_get_glyph_positions(m_buffer, length);
}
hb_buffer_t *get(void) const {
return m_buffer;
}
};
}
#endif
|
c120acdeab042fd3967f46cfd7cda0c93efb037d | 33cc75a925b12133bc78fe0f307140878bb093b6 | /oia/11p5nS/oth.cpp | d0996a5fd1e65866f22569dfe78609c8199b9f77 | [] | no_license | redeff/cmp | 05603369f404cff25d168105b1f1c7a956fd07b8 | 8974bacf61b6c73d1cb5d3b5aa33c12af0d687d0 | refs/heads/master | 2021-05-08T01:10:47.542693 | 2019-10-13T22:19:32 | 2019-10-13T22:19:32 | 107,782,810 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,387 | cpp | oth.cpp | // #include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <functional>
using namespace std;
struct Dp {
int x;
int y;
int size;
int operator< (const Dp a) const {
return size < a.size;
}
};
int main() {
#ifndef LOCAL
#define cin asjdfahssdlfkj
#define cout lksadflkjasld
ifstream cin("yurumi.in");
ofstream cout("yurumi.out");
#endif
int n, m, x;
cin >> n >> m >> x;
vector<vector<array<Dp, 2>>> dp = vector<vector<array<Dp, 2>>>(n, vector<array<Dp, 2>>(m, {Dp {}, Dp {}}));
vector<vector<bool>> board(n, vector<bool>(m, false));
for(int i = 0; i < x; ++i) {
int x, y;
cin >> x >> y;
x--; y--;
board[x][y] = true;
}
function<bool(int, int)> isin = [&](int x, int y) {
return 0 <=x && x < n && 0 <= y && y < m;
};
for(int side = 0; side < 2; ++side) {
int d = 2 * side - 1;
for(int x = side ? 0 : n-1; x != (side ? n : -1); x += d) {
for(int y = side ? 0 : m-1; y != (side ? m : -1); y += d) {
if(board[x][y]) {
dp[x][y][side].size = 0;
continue;
}
int one = isin(x - d, y) ? dp[x - d][y][side].size : 0;
int two = isin(x, y - d) ? dp[x][y - d][side].size : 0;
int three = isin(x - d, y - d) ? dp[x - d][y - d][side].size : 0;
dp[x][y][side].size = min(one, min(two, three)) + 1;
}
}
/*
for(int x = 0; x < n; ++x) {
for(int y = 0; y < m; ++y) {
cerr << "(" << dp[x][y][side].size << ") ";
}
cerr << endl;
}
*/
for(int x = side ? 0 : n-1; x != (side ? n : -1); x += d) {
for(int y = side ? 0 : m-1; y != (side ? m : -1); y += d) {
dp[x][y][side].x = side ? x - dp[x][y][side].size + 1 : x;
dp[x][y][side].y = side ? y - dp[x][y][side].size + 1 : y;
if(isin(x - d, y)) {
dp[x][y][side] = max(dp[x][y][side], dp[x-d][y][side]);
}
if(isin(x, y - d)) {
dp[x][y][side] = max(dp[x][y][side], dp[x][y-d][side]);
}
}
}
}
int biggest = 0;
Dp resa;
Dp resb;
for(int side = 0; side < 2; ++side) {
for(int i = 0; i < (side ? n-1 : m-1); ++i) {
Dp a = side ? dp[i+1][0][0] : dp[0][i+1][0];
Dp b = side ? dp[i][m-1][1] : dp[n-1][i][1];
if(a.size * a.size + b.size * b.size > biggest) {
biggest = a.size * a.size + b.size * b.size;
resa = a;
resb = b;
}
}
}
cout << resa.x << " " << resa.y << " " << resa.size << "\n";
cout << resb.x << " " << resb.y << " " << resb.size << "\n";
}
|
40c2c1d249c9451f297148569ab68c62a76de14d | fb39726be5a78bfadbba48181f6deee84c9b5a83 | /SparkD/Engine/cvlibbase/Src/imagecodec/CoImage.cpp | e2e8dc6633642d20a36819037adf0d235430ebe9 | [] | no_license | kmhk/SparkD | b6833b93803b181ef997a4d7388fa73fa2ca6250 | 9ed72f0b5a22d835a4695cb9e4d7c7a6b532d217 | refs/heads/master | 2022-11-06T21:49:24.709316 | 2020-07-01T04:35:34 | 2020-07-01T04:35:34 | 269,883,069 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,339 | cpp | CoImage.cpp | /*!
* \file CoImage.cpp
* \ingroup base
* \brief
* \author
*/
#include "cvlibmacros.h"
#ifdef _MSC_VER
#include <windows.h>
#include "TCHAR.h"
#endif
#include "CoImage.h"
#include "MatOperation.h"
#include "CoImageBMP.h"
#include "CoImageJPG.h"
#include "CoImagePNG.h"
#include "CoImageTIF.h"
#include "CoImageJAS.h"
#include "CoImageJ2K.h"
#include "XFileDisk.h"
#include "BmpStructs.h"
#include <cmath>
namespace cvlib {
CoImage::CoImage ()
{
m_pPalette = 0;
Startup (0);
InitBMPHeader (0, 0);
}
CoImage::~CoImage ()
{
release();
}
void CoImage::release()
{
if (m_pPalette)
free (m_pPalette);
m_pPalette = 0;
}
ulong CoImage::GetPaletteSize() const
{
return (m_Head.biClrUsed * sizeof(COLOR));
}
long CoImage::GetXDPI() const
{
return m_Info.xDPI;
}
long CoImage::GetYDPI() const
{
return m_Info.yDPI;
}
void CoImage::SetXDPI(long dpi)
{
if (dpi<=0) dpi=96;
m_Info.xDPI = dpi;
m_Head.biXPelsPerMeter = (int) floor(dpi * 10000.0 / 254.0 + 0.5);
}
void CoImage::SetYDPI(long dpi)
{
if (dpi<=0) dpi=96;
m_Info.yDPI = dpi;
m_Head.biYPelsPerMeter = (int) floor(dpi * 10000.0 / 254.0 + 0.5);
}
uchar CoImage::GetJpegScale() const
{
return m_Info.nJpegScale;
}
uchar CoImage::GetJpegQuality() const
{
return m_Info.nQuality;
}
void CoImage::SetJpegQuality(uchar q)
{
m_Info.nQuality = q;
}
void CoImage::InitBMPHeader(int nW, int nH)
{
memset (&m_Head, 0, sizeof(m_Head));
m_Head.biSize = sizeof(BITMAPINFOHEADER1);
m_Head.biCompression = BI_RGB;
m_Head.biWidth = nW;
m_Head.biHeight = nH;
m_Head.biBitCount = 24;
m_Head.biPlanes = 1;
int wBpp = 24;
m_Info.dwEffWidth = ((((wBpp * nW) + 31) / 32) * 4);
m_Head.biSizeImage = m_Info.dwEffWidth * nH;
SetXDPI (96);
SetYDPI (96);
int nSize = (int)GetPaletteSize();
if (nSize)
m_pPalette = (COLOR*)malloc(nSize);
}
void CoImage::Startup(ulong imagetype)
{
memset(&m_Head,0,sizeof(BITMAPINFOHEADER1));
memset(&m_Info,0,sizeof(COIMAGEINFO));
//init default attributes
m_Info.dwType = (uint)imagetype;
m_Info.nQuality = 90;
m_Info.nAlphaMax = 255;
m_Info.nBkgndIndex = -1;
m_Info.bEnabled = true;
m_Info.nJpegScale = 1;
SetXDPI(96);
SetYDPI(96);
m_pPalette = NULL;
}
/**
* \sa SetCodecOption
*/
ulong CoImage::GetCodecOption(ulong imagetype) const
{
if (imagetype<CVLIB_IMG_MAX_FORMATS)
{
if (imagetype==0)
imagetype = m_Info.dwType;
return m_Info.dwCodecOpt[imagetype];
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Encode option for GIF, TIF and JPG.
* - GIF : 0 = LZW (default), 1 = none, 2 = RLE.
* - TIF : 0 = automatic (default), or a valid compression code as defined in "tiff.h" (COMPRESSION_NONE = 1, COMPRESSION_CCITTRLE = 2, ...)
* - JPG : valid values stored in enum CODEC_OPTION ( ENCODE_BASELINE = 0x01, ENCODE_PROGRESSIVE = 0x10, ...)
*
* \return true if everything is ok
*/
bool CoImage::SetCodecOption(ulong opt, ulong imagetype)
{
if (imagetype<CVLIB_IMG_MAX_FORMATS)
{
if (imagetype==0)
imagetype = m_Info.dwType;
m_Info.dwCodecOpt[imagetype] = opt;
return true;
}
return false;
}
/**
* Returns the color of the specified index.
* \param i = palette index
* \param r, g, b = output color channels
*/
bool CoImage::GetPaletteColor(uchar i, uchar* rgb) const
{
COLOR* ppal = GetPalette();
if (ppal)
{
*rgb = ppal[i].x;
*(rgb + 1) = ppal[i].y;
*(rgb + 2) = ppal[i].z;
return true;
}
return false;
}
bool CoImage::GetPaletteColor(uchar i, uchar* r, uchar* g, uchar* b) const
{
COLOR* ppal = GetPalette();
if (ppal)
{
*r = ppal[i].x;
*g = ppal[i].y;
*b = ppal[i].z;
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
void CoImage::SetPalette(ulong n, uchar *r, uchar *g, uchar *b)
{
if ((!r) || (m_pPalette == NULL) || (m_Head.biClrUsed == 0)) return;
if (!g) g = r;
if (!b) b = g;
COLOR* ppal = GetPalette();
ulong m = MIN(n, m_Head.biClrUsed);
for (ulong i = 0; i < m; i++) {
ppal[i].x = r[i];
ppal[i].y = g[i];
ppal[i].z = b[i];
}
m_Info.last_c_isvalid = false;
}
////////////////////////////////////////////////////////////////////////////////
void CoImage::SetPalette(rgb_color *rgb, ulong nColors)
{
if ((!rgb) || (GetPalette() == NULL) || (m_Head.biClrUsed == 0)) return;
COLOR* ppal = GetPalette();
ulong m = MIN(nColors, m_Head.biClrUsed);
for (ulong i = 0; i < m; i++) {
ppal[i].x = rgb[i].r;
ppal[i].y = rgb[i].g;
ppal[i].z = rgb[i].b;
}
m_Info.last_c_isvalid = false;
}
////////////////////////////////////////////////////////////////////////////////
void CoImage::SetPalette(COLOR* pPal,ulong nColors)
{
if ((pPal==NULL)||(GetPalette()==NULL)||(m_Head.biClrUsed==0)) return;
memcpy(GetPalette(),pPal,MIN(GetPaletteSize(),nColors*sizeof(COLOR)));
m_Info.last_c_isvalid = false;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets (or replaces) the palette to gray scale palette.
* The function doesn't change the pixels; for standard
* gray scale conversion use GrayScale().
*/
void CoImage::SetGrayPalette()
{
if ((GetPalette()==NULL)||(m_Head.biClrUsed==0)) return;
COLOR* pal=GetPalette();
for (ulong ni=0;ni<m_Head.biClrUsed;ni++)
pal[ni].z=pal[ni].y = pal[ni].x = (uchar)(ni*(255/(m_Head.biClrUsed-1)));
}
////////////////////////////////////////////////////////////////////////////////
/**
* Colorize the palette.
* \sa Colorize
*/
void CoImage::BlendPalette(COLOR cr,long perc) const
{
if ((GetPalette()==NULL)||(m_Head.biClrUsed==0)) return;
ulong i,r,g,b;
COLOR* pPal=GetPalette();
r = cr.x;
g = cr.y;
b = cr.z;
if (perc>100) perc=100;
for(i=0;i<m_Head.biClrUsed;i++){
pPal[i].z=(uchar)((pPal[i].z*(100-perc)+b*perc)/100);
pPal[i].y =(uchar)((pPal[i].y*(100-perc)+g*perc)/100);
pPal[i].x =(uchar)((pPal[i].x*(100-perc)+r*perc)/100);
}
}
COLOR* CoImage::GetPalette() const
{
return (COLOR*)m_pPalette;
}
int CoImage::CreateInfo (int nRows, int nCols, int wBpp, int nImageType)
{
// prevent further actions if width or height are not vaild <Balabasnia>
if ((nCols == 0) || (nRows == 0))
{
strcpy(m_Info.szLastError,"CoImage::create : width and height must be greater than zero");
return 0;
}
// Make sure bits per pixel is valid
if (wBpp <= 1) wBpp = 1;
else if (wBpp <= 4) wBpp = 4;
else if (wBpp <= 8) wBpp = 8;
else wBpp = 24;
// set the correct bpp value
switch (wBpp)
{
case 1:
m_Head.biClrUsed = 2; break;
case 4:
m_Head.biClrUsed = 16; break;
case 8:
m_Head.biClrUsed = 256; break;
default:
m_Head.biClrUsed = 0;
}
//set the common image informations
m_Info.dwEffWidth = ((((wBpp * nCols) + 31) / 32) * 4);
m_Info.dwType = nImageType;
// initialize BITMAPINFOHEADER1
m_Head.biSize = sizeof(BITMAPINFOHEADER1); //<ralphw>
m_Head.biWidth = nCols; // fill in width from parameter
m_Head.biHeight = nRows; // fill in height from parameter
m_Head.biPlanes = 1; // must be 1
m_Head.biBitCount = (ushort)wBpp; // from parameter
m_Head.biCompression = BI_RGB;
m_Head.biSizeImage = m_Info.dwEffWidth * nRows;
// m_Head.biXPelsPerMeter = 0; See SetXDPI
// m_Head.biYPelsPerMeter = 0; See SetYDPI
m_Head.biClrImportant = 0;
int nSize = (int)GetPaletteSize();
if (nSize)
{
m_pPalette = (COLOR*)malloc(nSize);
if (!m_pPalette)
{
strcpy(m_Info.szLastError,"CoImage::create can't allocate memory");
return NULL;
}
//clear the palette
memset(m_pPalette,0,nSize);
}
return 1;
}
void CoImage::SetBpp24(int nh, int nw)
{
int wBPP = 24;
m_Info.dwEffWidth = ((((wBPP * nw) + 31) / 32) * 4);
m_Info.dwType = CVLIB_IMG_FORMAT_UNKNOWN;
m_Head.biClrUsed = 0;
int dwEffWidth = ((((wBPP * nw) + 31) / 32) * 4);
// initialize BITMAPINFOHEADER1
m_Head.biSize = sizeof(BITMAPINFOHEADER1); //<ralphw>
m_Head.biWidth = nw; // fill in width from parameter
m_Head.biHeight = nh; // fill in height from parameter
m_Head.biPlanes = 1; // must be 1
m_Head.biBitCount = (ushort)wBPP; // from parameter
m_Head.biCompression = BI_RGB;
m_Head.biSizeImage = dwEffWidth * nh;
// m_Head.biXPelsPerMeter = 0; See SetXDPI
// m_Head.biYPelsPerMeter = 0; See SetYDPI
m_Head.biClrImportant = 0;
}
void CoImage::SetPixelIndex(long x,long y,uchar i)
{
if ((GetPalette() == NULL) || (m_Head.biClrUsed == 0) ||
(x<0) || (y<0)||(x >= m_Head.biWidth) || (y >= m_Head.biHeight)) return ;
if (m_Head.biBitCount == 8)
{
m_Info.pImage[y*m_Info.dwEffWidth + x]=i;
return;
}
else
{
uchar pos;
uchar* iDst= m_Info.pImage + y*m_Info.dwEffWidth + (x*m_Head.biBitCount >> 3);
if (m_Head.biBitCount == 4)
{
pos = (uchar)(4*(1-x%2));
*iDst &= ~(0x0F<<pos);
*iDst |= ((i & 0x0F)<<pos);
return;
}
else if (m_Head.biBitCount == 1)
{
pos = (uchar)(7-x%8);
*iDst &= ~(0x01<<pos);
*iDst |= ((i & 0x01)<<pos);
return;
}
}
}
uchar CoImage::GetPixelIndex(long x,long y) const
{
if ((GetPalette()==NULL)||(m_Head.biClrUsed==0)) return 0;
if ((x<0)||(y<0)||(x>=m_Head.biWidth)||(y>=m_Head.biHeight))
{
if (m_Info.nBkgndIndex != -1)
return (uchar)m_Info.nBkgndIndex;
else
return *m_Info.pImage;
}
if (m_Head.biBitCount==8)
{
return m_Info.pImage[y*m_Info.dwEffWidth + x];
}
else
{
uchar pos;
uchar iDst= m_Info.pImage[y*m_Info.dwEffWidth + (x*m_Head.biBitCount >> 3)];
if (m_Head.biBitCount==4)
{
pos = (uchar)(4*(1-x%2));
iDst &= (0x0F<<pos);
return (uchar)(iDst >> pos);
}
else if (m_Head.biBitCount==1)
{
pos = (uchar)(7-x%8);
iDst &= (0x01<<pos);
return (uchar)(iDst >> pos);
}
}
return 0;
}
void CoImage::SetPaletteColor(uchar idx, uchar r, uchar g, uchar b, uchar alpha)
{
if (GetPalette() && (m_Head.biClrUsed))
{
uchar* iDst = (uchar*)(m_pPalette);
if (idx < m_Head.biClrUsed)
{
long ldx= idx * sizeof(COLOR);
iDst[ldx++] = (uchar) b;
iDst[ldx++] = (uchar) g;
iDst[ldx++] = (uchar) r;
iDst[ldx] = (uchar) alpha;
m_Info.last_c_isvalid = false;
}
}
}
void CoImage::SetPaletteColor(uchar idx, COLOR c)
{
if (GetPalette() && (m_Head.biClrUsed))
{
uchar* iDst = (uchar*)(m_pPalette);
if (idx < m_Head.biClrUsed)
{
long ldx=idx * sizeof(COLOR);
iDst[ldx++] = (uchar) c.z;
iDst[ldx++] = (uchar) c.y;
iDst[ldx++] = (uchar) c.x;
iDst[ldx] = (uchar) c.w;
m_Info.last_c_isvalid = false;
}
}
}
COLOR CoImage::GetPaletteColor(uchar idx) const
{
COLOR rgb;
if ( GetPalette() && (m_Head.biClrUsed) )
{
uchar* iDst = (uchar*)m_pPalette;
if ( idx < m_Head.biClrUsed )
{
long ldx = idx * sizeof(COLOR);
rgb.z = iDst[ldx++];
rgb.y = iDst[ldx++];
rgb.x = iDst[ldx++];
rgb.w = iDst[ldx];
}
}
return rgb;
}
uchar CoImage::GetPixelIndex(uchar* pData,long x) const
{
if ((pData==NULL)||(m_Head.biClrUsed==0))
return 0;
if (m_Head.biBitCount==8)
{
return pData[x];
}
else
{
uchar pos;
uchar iDst= pData[x*m_Head.biBitCount >> 3];
if (m_Head.biBitCount==4)
{
pos = (uchar)(4*(1-x%2));
iDst &= (0x0F<<pos);
return (uchar)(iDst >> pos);
}
else if (m_Head.biBitCount==1)
{
pos = (uchar)(7-x%8);
iDst &= (0x01<<pos);
return (uchar)(iDst >> pos);
}
}
return 0;
}
COLOR CoImage::getPixelColor(const Mat& image, long x,long y, bool fGetAlpha) const
{
int cn = image.channels();
COLOR rgb = m_Info.nBkgndColor; //<mpwolski>
if ((!image.isValid())||(x<0)||(y<0)||
(x>=m_Head.biWidth)||(y>=m_Head.biHeight))
{
if (m_Info.nBkgndIndex != -1)
{
if (m_Head.biBitCount<24)
return GetPaletteColor((uchar)m_Info.nBkgndIndex);
else return m_Info.nBkgndColor;
}
else if (GetPalette())
return getPixelColor(image, 0,0);
return rgb;
}
if (m_Head.biClrUsed)
{
rgb = GetPaletteColor(GetPixelIndex(x,y));
}
else
{
rgb.x = image.data.ptr[y][x*cn];
rgb.y= image.data.ptr[y][x*cn+1];
rgb.z = image.data.ptr[y][x*cn+2];
}
#if CVLIB_IMG_SUPPORT_ALPHA
if (fGetAlpha) rgb.w = image.data.ptr[y][x*cn+3];
#else
rgb.w = 0;
#endif //CVLIB_IMG_SUPPORT_ALPHA
return rgb;
}
void CoImage::setPixelColor(Mat& image, long x,long y,float* color)
{
int cn = image.channels();
for (int i = 0; i<3; i ++)
image.data.ptr[y][x*cn+i] = (uchar)color[i];
}
void CoImage::setPixelColor(Mat& image, long x,long y,COLOR c, bool bSetAlpha)
{
int cn = image.channels();
if ((!image.isValid()) || (x<0) || (y<0) ||
(x>=m_Head.biWidth) || (y>=m_Head.biHeight))
return;
if (m_Head.biClrUsed)
SetPixelIndex(x,y,GetNearestIndex(c));
else
{
image.data.ptr[y][x*cn] = c.x;
image.data.ptr[y][x*cn+1] = c.y;
image.data.ptr[y][x*cn+2] = c.z;
#if CVLIB_IMG_SUPPORT_ALPHA
if (bSetAlpha)
image.data.ptr[y][x*cn+3] = c.w;
#endif //CVLIB_IMG_SUPPORT_ALPHA
}
}
void CoImage::RGBtoBGR(uchar *buffer, int length, int cn)
{
if (buffer && (m_Head.biClrUsed==0))
{
uchar temp;
length = MIN(length,(int)m_Info.dwEffWidth);
for (int i=0;i<length;i+=cn)
{
temp = buffer[i]; buffer[i] = buffer[i+2]; buffer[i+2] = temp;
}
}
}
uchar CoImage::GetNearestIndex(COLOR c)
{
if ((GetPalette() == NULL)||(m_Head.biClrUsed==0)) return 0;
// <RJ> check matching with the previous result
if (m_Info.last_c_isvalid && (*(long*)&m_Info.last_c == *(long*)&c)) return m_Info.last_c_index;
m_Info.last_c = c;
m_Info.last_c_isvalid = true;
uchar* iDst = (uchar*)(GetPalette()) + sizeof(BITMAPINFOHEADER1);
long distance=200000;
int i,j = 0;
long k,l;
int m = (int)(m_Head.biClrImportant==0 ? m_Head.biClrUsed : m_Head.biClrImportant);
for(i=0,l=0;i<m;i++,l+=sizeof(COLOR))
{
k = (iDst[l]-c.z)*(iDst[l]-c.z)+
(iDst[l+1]-c.y)*(iDst[l+1]-c.y)+
(iDst[l+2]-c.x)*(iDst[l+2]-c.x);
// k = abs(iDst[l]-c.z)+abs(iDst[l+1]-c.y)+abs(iDst[l+2]-c.x);
if (k==0)
{
j=i;
break;
}
if (k<distance)
{
distance=k;
j=i;
}
}
m_Info.last_c_index = (uchar)j;
return (uchar)j;
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
bool CoImage::Decode (Mat& image, unsigned char* szbuf, int nsize, ulong nImageType)
{
XFileMem hfile(szbuf, nsize);
return Decode(image, &hfile, nImageType);
}
bool CoImage::DecodeUnknown (Mat& image, XFile* pFile, ulong nImageType)
{
int pos = pFile->tell();
if (nImageType == CVLIB_IMG_FORMAT_UNKNOWN)
{
#if CVLIB_IMG_SUPPORT_BMP
{
CoImageBMP newImage;
if (newImage.Decode (image, pFile))
return true;
else
pFile->seek(pos, SEEK_SET);
}
#endif
#ifndef CVLIB_IMG_NOCODEC
#if CVLIB_IMG_SUPPORT_JPG
{
CoImageJPG newImage;
if (newImage.Decode (image, pFile))
return true;
else
pFile->seek (pos, SEEK_SET);
}
#endif
#if CVLIB_IMG_SUPPORT_PNG
{
CoImagePNG newImage;
if (newImage.Decode (image, pFile))
return true;
else
pFile->seek (pos, SEEK_SET);
}
#endif
#if CVLIB_IMG_SUPPORT_TIF
{
CoImageTIF newImage;
if (newImage.Decode (image, pFile))
return true;
else
pFile->seek (pos, SEEK_SET);
}
#endif
#if CVLIB_IMG_SUPPORT_JP2
{
CoImageJAS newImage;
if (newImage.Decode (image, pFile, CVLIB_IMG_FORMAT_JP2))
return true;
else
pFile->seek (pos, SEEK_SET);
}
#endif
#if CVLIB_IMG_SUPPORT_JPC
{
CoImageJAS newImage;
if (newImage.Decode (image, pFile, CVLIB_IMG_FORMAT_JPC))
return true;
else
pFile->seek (pos, SEEK_SET);
}
#endif
#if CVLIB_IMG_SUPPORT_PGX
{
CoImageJAS newImage;
if (newImage.Decode (image, pFile, CVLIB_IMG_FORMAT_PGX))
return true;
else pFile->seek (pos, SEEK_SET);
}
#endif
#if CVLIB_IMG_SUPPORT_PNM
{
CoImageJAS newImage;
if (newImage.Decode (image, pFile, CVLIB_IMG_FORMAT_PNM))
return true;
else
pFile->seek (pos, SEEK_SET);
}
#endif
#if CVLIB_IMG_SUPPORT_RAS
{
CoImageJAS newImage;
if (newImage.Decode (image, pFile, CVLIB_IMG_FORMAT_RAS))
return true;
else
pFile->seek (pos, SEEK_SET);
}
#endif
#if CVLIB_IMG_SUPPORT_J2K
{
CoImageJ2K newImage;
if (newImage.Decode(image, pFile))
return true;
else
pFile->seek(pos, SEEK_SET);
}
#endif
#endif //CVLIB_IMG_NOCODEC
}
return false;
}
bool CoImage::Decode (Mat& image, XFile* pFile, ulong nImageType)
{
if (nImageType == CVLIB_IMG_FORMAT_UNKNOWN)
return DecodeUnknown(image, pFile, nImageType);
int pos = pFile->tell();
#if CVLIB_IMG_SUPPORT_BMP
if (nImageType == CVLIB_IMG_FORMAT_BMP)
{
CoImageBMP newImage;
if (newImage.Decode (image, pFile))
return true;
else {
pFile->seek (pos, SEEK_SET);
return DecodeUnknown(image, pFile, CVLIB_IMG_FORMAT_UNKNOWN);
}
}
#endif
#ifndef CVLIB_IMG_NOCODEC
#if CVLIB_IMG_SUPPORT_JPG
if (nImageType == CVLIB_IMG_FORMAT_JPG)
{
CoImageJPG newImage;
if (newImage.Decode (image, pFile))
return true;
else {
pFile->seek (pos, SEEK_SET);
return DecodeUnknown(image, pFile, CVLIB_IMG_FORMAT_UNKNOWN);
}
}
#endif
#if CVLIB_IMG_SUPPORT_PNG
if (nImageType == CVLIB_IMG_FORMAT_PNG)
{
CoImagePNG newImage;
if (newImage.Decode (image, pFile))
return true;
else {
pFile->seek (pos, SEEK_SET);
return DecodeUnknown(image, pFile, CVLIB_IMG_FORMAT_UNKNOWN);
}
}
#endif
#if CVLIB_IMG_SUPPORT_TIF
if (nImageType == CVLIB_IMG_FORMAT_TIF)
{
CoImageTIF newImage;
if (newImage.Decode (image, pFile))
return true;
else {
pFile->seek (pos, SEEK_SET);
return DecodeUnknown(image, pFile, CVLIB_IMG_FORMAT_UNKNOWN);
}
}
#endif
#if CVLIB_IMG_SUPPORT_JAS
if (nImageType == CVLIB_IMG_FORMAT_JP2 ||
nImageType == CVLIB_IMG_FORMAT_JPC ||
nImageType == CVLIB_IMG_FORMAT_PGX ||
nImageType == CVLIB_IMG_FORMAT_PNM ||
nImageType == CVLIB_IMG_FORMAT_RAS )
{
CoImageJAS newImage;
if (newImage.Decode (image, pFile, nImageType))
return true;
else {
pFile->seek (pos, SEEK_SET);
return DecodeUnknown(image, pFile, CVLIB_IMG_FORMAT_UNKNOWN);
}
}
#endif
#if CVLIB_IMG_SUPPORT_J2K
if (nImageType == CVLIB_IMG_FORMAT_J2K)
{
CoImageJ2K newImage;
if (newImage.Decode(image, pFile))
return true;
else {
pFile->seek(pos, SEEK_SET);
return DecodeUnknown(image, pFile, CVLIB_IMG_FORMAT_UNKNOWN);
}
}
#endif
#endif //CVLIB_IMG_NOCODEC
return false;
}
bool CoImage::Encode(const Mat& image, uchar* &buffer, int &size, ulong imagetype) const
{
XFileMem xfile(buffer, size);
return Encode(image, &xfile, imagetype);
}
bool CoImage::Encode(const Mat& image, XFile * pFile, ulong imagetype) const
{
#if CVLIB_IMG_SUPPORT_BMP
if (imagetype == CVLIB_IMG_FORMAT_BMP)
{
CoImageBMP newImage;
if (newImage.Encode (image, pFile))
return true;
else
return false;
}
#endif
#ifndef CVLIB_IMG_NOCODEC
#if CVLIB_IMG_SUPPORT_JPG
if (imagetype == CVLIB_IMG_FORMAT_JPG)
{
CoImageJPG newImage;
if (newImage.Encode (image, pFile))
return true;
else
return false;
}
#endif
#if CVLIB_IMG_SUPPORT_PNG
if (imagetype == CVLIB_IMG_FORMAT_PNG)
{
CoImagePNG newImage;
if (newImage.Encode (image, pFile))
return true;
else
return false;
}
#endif
#if CVLIB_IMG_SUPPORT_TIF
if (imagetype == CVLIB_IMG_FORMAT_TIF)
{
CoImageTIF newImage;
if (newImage.Encode (image, pFile))
return true;
else
return false;
}
#endif
#if CVLIB_IMG_SUPPORT_JAS
if (imagetype == CVLIB_IMG_FORMAT_JP2 ||
imagetype == CVLIB_IMG_FORMAT_JPC ||
imagetype == CVLIB_IMG_FORMAT_PGX ||
imagetype == CVLIB_IMG_FORMAT_PNM ||
imagetype == CVLIB_IMG_FORMAT_RAS )
{
CoImageJAS newImage;
if (newImage.Encode (image, pFile, imagetype))
return true;
else
return false;
}
#endif
#if CVLIB_IMG_SUPPORT_J2K
if (imagetype == CVLIB_IMG_FORMAT_J2K)
{
CoImageJ2K newImage;
if (newImage.Encode(image, pFile))
return true;
else
return false;
}
#endif
#endif //CVLIB_IMG_NOCODEC
return false;
}
}
#ifndef CVLIB_NO_PRAGMA
#if CVLIB_OS == CVLIB_OS_WIN32
#ifndef CVLIB_IMG_NOCODEC
#ifdef NDEBUG
#if CVLIB_IMG_SUPPORT_J2K
#pragma comment(lib,"j2k.lib")
#endif //CVLIB_IMG_SUPPORT_J2K
#if CVLIB_IMG_SUPPORT_JAS
#pragma comment(lib,"jasper.lib")
#endif //CVLIB_IMG_SUPPORT_JAS
#if CVLIB_IMG_SUPPORT_JBG
#pragma comment(lib,"jbig.lib")
#endif //CVLIB_IMG_SUPPORT_JBG
#if CVLIB_IMG_SUPPORT_JPG
#pragma comment(lib,"jpeg.lib")
#endif //CVLIB_IMG_SUPPORT_JPG
#if CVLIB_IMG_SUPPORT_PNG
#pragma comment(lib,"png.lib")
#endif //CVLIB_IMG_SUPPORT_PNG
#if CVLIB_IMG_SUPPORT_TIF
#pragma comment(lib,"tiff.lib")
#endif //CVLIB_IMG_SUPPORT_TIF
#if CVLIB_IMG_SUPPORT_PNG || CVLIB_IMG_SUPPORT_TIF
#pragma comment(lib,"zlib.lib")
#endif //CVLIB_IMG_SUPPORT_PNG || CVLIB_IMG_SUPPORT_TIF
#else //DEBUG
#if CVLIB_IMG_SUPPORT_J2K
#pragma comment(lib,"j2kd.lib")
#endif //CVLIB_IMG_SUPPORT_J2K
#if CVLIB_IMG_SUPPORT_JAS
#pragma comment(lib,"jasperd.lib")
#endif //CVLIB_IMG_SUPPORT_JAS
#if CVLIB_IMG_SUPPORT_JBG
#pragma comment(lib,"jbigd.lib")
#endif //CVLIB_IMG_SUPPORT_JBG
#if CVLIB_IMG_SUPPORT_JPG
#pragma comment(lib,"jpegd.lib")
#endif //CVLIB_IMG_SUPPORT_JPG
#if CVLIB_IMG_SUPPORT_PNG
#pragma comment(lib,"pngd.lib")
#endif //CVLIB_IMG_SUPPORT_PNG
#if CVLIB_IMG_SUPPORT_TIF
#pragma comment(lib,"tiffd.lib")
#endif //CVLIB_IMG_SUPPORT_TIF
#if CVLIB_IMG_SUPPORT_PNG || CVLIB_IMG_SUPPORT_TIF
#pragma comment(lib,"zlibd.lib")
#endif //CVLIB_IMG_SUPPORT_PNG || CVLIB_IMG_SUPPORT_TIF
#endif //NDEBUG
#endif //CVLIB_IMG_NOCODEC
#endif // CVLIB_OS
#endif
|
fb0dfc4f4d4a76438e55b564054115c064a47d32 | 19194c2f2c07ab3537f994acfbf6b34ea9b55ae7 | /android-31/java/util/AbstractSet.hpp | 329c58f09acbc6df60d2a46ce7ed01ac30db436b | [
"GPL-3.0-only"
] | permissive | YJBeetle/QtAndroidAPI | e372609e9db0f96602da31b8417c9f5972315cae | ace3f0ea2678967393b5eb8e4edba7fa2ca6a50c | refs/heads/Qt6 | 2023-08-05T03:14:11.842336 | 2023-07-24T08:35:31 | 2023-07-24T08:35:31 | 249,539,770 | 19 | 4 | Apache-2.0 | 2022-03-14T12:15:32 | 2020-03-23T20:42:54 | C++ | UTF-8 | C++ | false | false | 733 | hpp | AbstractSet.hpp | #pragma once
#include "../../JObject.hpp"
#include "./AbstractSet.def.hpp"
namespace java::util
{
// Fields
// Constructors
// Methods
inline jboolean AbstractSet::equals(JObject arg0) const
{
return callMethod<jboolean>(
"equals",
"(Ljava/lang/Object;)Z",
arg0.object<jobject>()
);
}
inline jint AbstractSet::hashCode() const
{
return callMethod<jint>(
"hashCode",
"()I"
);
}
inline jboolean AbstractSet::removeAll(JObject arg0) const
{
return callMethod<jboolean>(
"removeAll",
"(Ljava/util/Collection;)Z",
arg0.object()
);
}
} // namespace java::util
// Base class headers
#include "./AbstractCollection.hpp"
#ifdef QT_ANDROID_API_AUTOUSE
using namespace java::util;
#endif
|
24ee5fcfb4453efff28351ac453eb7ded4cda7d1 | 30b7ffd17845db982883a91ce8d04551281658c4 | /Atcoder/Beginner Contest/Round 191/D.cpp | 795fb7c90d9fc95dcfb76d459747b476ed8350d4 | [] | no_license | shas9/codehub | 95418765b602b52edb0d48a473ad7e7a798f76e5 | bda856bf6ca0f3a1d59980895cfab82f690c75a2 | refs/heads/master | 2023-06-21T01:09:34.275708 | 2021-07-26T14:54:03 | 2021-07-26T14:54:03 | 389,404,954 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,949 | cpp | D.cpp | // God put a smile upon your face <3
#include <bits/stdc++.h>
#define slld(longvalue) scanf("%lld", &longvalue)
#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define bug printf("BUG\n")
#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX
#define mxd 2e8
#define mnd -2e8
#define pi 3.14159265359
using namespace std;
bool check(ll n, ll pos)
{
return n & (1LL << pos);
}
ll Set(ll n, ll pos)
{
return n = n | (1LL << pos);
}
#define eps 1e-12
bool yes(ll x, ll y, long double xx, long double yy, long double r)
{
long double dist = (x - xx) * (x - xx) + (y - yy) * (y - yy);
return dist <= (r * r) + eps;
}
ll calc1(ll yy, ll lim, long double x, long double y, long double r)
{
ll hi = lim;
ll lo = -1e10;
ll ret = hi + 1;
while(lo <= hi)
{
ll mid = (lo + hi) / 2;
if(yes(mid, yy, x, y, r))
{
ret = mid;
hi = mid - 1;
}
else
{
lo = mid + 1;
}
}
return lim - ret + 1;
}
ll calc2(ll yy, ll lim, long double x, long double y, long double r)
{
ll hi = 1e10;
ll lo = lim;
ll ret = lo - 1;
while(lo <= hi)
{
ll mid = (lo + hi) / 2;
if(yes(mid, yy, x, y, r))
{
ret = mid;
lo = mid + 1;
}
else
{
hi = mid - 1;
}
}
return ret - lim + 1;
}
void solve(ll &ans)
{
long double x, y, r;
cin >> x >> y >> r;
ll up = y - r - 5;
ll down = y + r + 5;
ans = 0;
// cout << up << " " << down << endl;
for(ll i = up; i <= down; i++)
{
ans += calc1(i,floor(x), x, y, r) + calc2(i,floor(x) + 1, x, y, r);
// cout << ans << " " << calc2(i,x + 1, x, y, r) << endl;
}
return;
}
int main()
{
ll i, j, k, l, m, n, o, r, q;
ll testcase;
ll input, flag, tag, ans;
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// while(1)
{
solve(ans);
cout << ans << "\n";
}
}
|
a775cea6935d0495829f0c7dfda83fe0937985e4 | d0473a4bb6531903ab44bb2843d21bb792ceb7bd | /Matterbot/MatterbotSample/UselessFacts.h | 302672a70d6ad67e321018b88e9551ee21d5ef57 | [
"MIT"
] | permissive | mpettyjr/matterbot | a2e2152976e6d6b5a72821637ca039c64317a873 | e3b49eb71dcd8bc17a8663b0348febfc6463b7fc | refs/heads/master | 2021-01-19T22:48:18.123584 | 2017-04-28T12:47:03 | 2017-04-28T12:47:03 | 88,873,300 | 1 | 0 | null | 2017-04-20T14:12:38 | 2017-04-20T14:12:38 | null | WINDOWS-1252 | C++ | false | false | 15,184 | h | UselessFacts.h | #pragma once
#include "Matterbot.h"
namespace lospi
{
struct UselessFacts : ICommand {
std::wstring get_name() override {
return L"fact";
}
std::wstring get_help() override {
return L"`fact [1-100]`: `number` will return a useless fact.";
}
std::wstring handle_command(const std::wstring &team, const std::wstring &channel,
const std::wstring &user, const std::wstring &command_text) override {
if (command_text == L"1")
{
return L"There is one piece of silk for every kernel of corn AND every row of corn contains exactly the same number of kernels";
}
else if (command_text == L"2")
{
return L"If all the females in a group of clownfish die a male will change its gender in order to keep its group alive.";
}
else if (command_text == L"3")
{
return L"A Pineapple is actually a bunch of small berries fused together into a single mass.";
}
else if (command_text == L"4")
{
return L"Barbie's full name is Barbara Millicent Roberts.";
}
else if (command_text == L"5")
{
return L"Your stomach has to produce a new layer of mucus every 2 weeks otherwise it will digest itself.";
}
else if (command_text == L"6")
{
return L"A pig's orgasm lasts for 30 minutes.";
}
else if (command_text == L"7")
{
return L"No word in the English language rhymes with month, orange, silver and purple.";
}
else if (command_text == L"8")
{
return L"The very first bomb dropped by the Allies on Berlin during World War II Killed the only elephant in the Berlin Zoo.";
}
else if (command_text == L"8")
{
return L"More people are killed annually by donkeys than airplane crashes.";
}
else if (command_text == L"9")
{
return L"A 'jiffy' is a unit of time for 1/100th of a second.";
}
else if (command_text == L"10")
{
return L"A whale's penis is called a dork.";
}
else if (command_text == L"11")
{
return L"It has NEVER rained in Calama, a town in the Atacama Desert of Chile.";
}
else if (command_text == L"12")
{
return L"A giraffe can go without water longer than a camel.";
}
else if (command_text == L"13")
{
return L"It costs more to buy a new car today in the United States than it cost Christopher Columbus to equip and undertake three voyages to and from the New World.";
}
else if (command_text == L"14")
{
return L"More people are killed annually by donkeys than airplane crashes.";
}
else if (command_text == L"15")
{
return L"The plastic things on the end of shoelaces are called aglets.";
}
else if (command_text == L"16")
{
return L"Daylight Saving Time is not observed in most of the state of Arizona and parts of Indiana.";
}
else if (command_text == L"17")
{
return L"Bees have 5 eyes. There are 3 small eyes on the top of a bee's head and 2 larger ones in front.";
}
else if (command_text == L"18")
{
return L"One-fourth of the world's population lives on less than $200 a year. Ninety million people survive on less than $75 a year.";
}
else if (command_text == L"19")
{
return L"Count the number of cricket chirps in a 15-second period, add 37 to the total, and your result will be very close to the actual outdoor Fahrenheit temperature.";
}
else if (command_text == L"20")
{
return L"Butterflies taste with their hind feet.";
}
else if (command_text == L"21")
{
return L"Only female mosquito’s' bite and most are attracted to the color blue twice as much as to any other color.";
}
else if (command_text == L"22")
{
return L"If one places a tiny amount of liquor on a scorpion, it will instantly go mad and sting itself to death.";
}
else if (command_text == L"23")
{
return L"It is illegal to hunt camels in the state of Arizona.";
}
else if (command_text == L"24")
{
return L"The first product to have a bar code was Wrigley’s gum.";
}
else if (command_text == L"25")
{
return L"When you sneeze, air and particles travel through the nostrils at speeds over100 mph. During this time, all bodily functions stop, including your heart, contributing to the impossibility of keeping one's eyes open during a sneeze.";
}
else if (command_text == L"26")
{
return L"%60 of all people using the Internet, use it for pornography";
}
else if (command_text == L"27")
{
return L"Sex burns 360 calories per hour. ";
}
else if (command_text == L"28")
{
return L"Celery has negative calories! It takes more calories to eat a piece of celery than the celery has in it.";
}
else if (command_text == L"29")
{
return L"The pop you hear when you crack your knuckles is actually a bubble of gas burning.";
}
else if (command_text == L"30")
{
return L"In a lifetime the average human produces enough quarts of spit to fill 2 swimming pools.";
}
else if (command_text == L"31")
{
return L"It's against the law to doze off under a hair dryer in Florida/against the law to slap an old friend on the back in Georgia/against the law to Play hopscotch on a Sunday in Missouri.";
}
else if (command_text == L"32")
{
return L"The human heart creates enough pressure to squirt blood 30ft.";
}
else if (command_text == L"33")
{
return L"For some time Frederic Chopin, the composer and pianist, wore a beard on only one side of his face, explaining: \"It does not matter, my audience sees only my right side.\"";
}
else if (command_text == L"34")
{
return L"1 in every 4 Americans has appeared someway or another on television.";
}
else if (command_text == L"35")
{
return L"1 in 8 Americans has worked at a McDonalds restaurant.";
}
else if (command_text == L"36")
{
return L"A pregnant goldfish is called a twit.";
}
else if (command_text == L"37")
{
return L"The shortest war in history was between Zanzibar and England in 1896. Zanzibar surrendered after 38 minutes.";
}
else if (command_text == L"38")
{
return L"You were born with 300 bones, but by the time you are an adult you will only have 206.";
}
else if (command_text == L"39")
{
return L"Women blink nearly twice as much as men.";
}
else if (command_text == L"40")
{
return L"The strongest muscle (Relative to size) in the body is the tongue.";
}
else if (command_text == L"41")
{
return L"Average life span of a major league baseball: 7 pitches.";
}
else if (command_text == L"42")
{
return L"The first CD pressed in the US was Bruce Springsteen's 'Born in the USA'";
}
else if (command_text == L"43")
{
return L"The thumbnail grows the slowest, the middle nail the fastest, nearly 4 times faster than toenails.";
}
else if (command_text == L"44")
{
return L"The 57 on Heinz ketchup bottles represents the number of varieties of pickles the company once had.";
}
else if (command_text == L"45")
{
return L"Tom Sawyer was the first novel written on a typewriter.";
}
else if (command_text == L"46")
{
return L"The 'Golden Arches' of fast food chain McDonalds is more recognized worldwide than the religious cross of Christianity.";
}
else if (command_text == L"47")
{
return L"The average talker sprays about 300 microscopic saliva droplets per minute, about 2.5 droplets per word.";
}
else if (command_text == L"48")
{
return L"Every year 11,000 Americans injure themselves while trying out bizarre sexual positions.";
}
else if (command_text == L"49")
{
return L"Coca-Cola was originally green.";
}
else if (command_text == L"50")
{
return L"Men can read smaller print than women; women can hear better.";
}
else if (command_text == L"51")
{
return L"Average number of people airborne over the US any given hour: 61,000.";
}
else if (command_text == L"52")
{
return L"The Main Library at Indiana University sinks over an inch every year because when it was built, engineers failed to take into account the weight of all the books that would occupy the building.";
}
else if (command_text == L"53")
{
return L"111,111,111 x 111,111,111 = 12,345,678,987,654,321";
}
else if (command_text == L"54")
{
return L"The expression 'to get fired' comes from long ago Clans that wanted to get rid of unwanted people, so they would burn their houses instead of killing them, creating the term 'Got fired'.";
}
else if (command_text == L"55")
{
return L"\"I am.\" is the shortest complete sentence in the English language.";
}
else if (command_text == L"56")
{
return L"Hershey's Kisses are called that because the machine that makes them looks like it's kissing the conveyor belt.";
}
else if (command_text == L"57")
{
return L"The phrase \"rule of thumb\" is derived from an old English law, which stated that you couldn't beat your wife with anything wider than your thumb.";
}
else if (command_text == L"58")
{
return L"The Eisenhower interstate system requires that one mile in every five must be straight in case of war or emergency, they could be used as airstrips.";
}
else if (command_text == L"59")
{
return L"The name Jeep came from the abbreviation used in the army. G.P. for 'General Purpose' vehicle.";
}
else if (command_text == L"60")
{
return L"Honking of car horns for a couple that just got married is an old superstition to insure great sex.";
}
else if (command_text == L"61")
{
return L"Dr. John Harvey Kellogg introduced Kellogg's Corn Flakes in hopes that it would reduce masturbation.";
}
else if (command_text == L"62")
{
return L"In medieval France, unfaithful wives were made to chase a chicken through town naked.";
}
else if (command_text == L"63")
{
return L"The Black Widow spider eats her mate during or after sex.";
}
else if (command_text == L"64")
{
return L"Napoleon's penis was sold to an American Urologist for $40,000.";
}
else if (command_text == L"65")
{
return L"Men can read smaller print than women; women can hear better.";
}
else if (command_text == L"66")
{
return L"When a Hawaiian woman wears a flower over her left ear, it means that she is not available.";
}
else if (command_text == L"67")
{
return L"The only nation whose name begins with an \"A\", but doesn't end in an \"A\" is Afghanistan.";
}
else if (command_text == L"68")
{
return L"The only 15-letter word that can be spelled without repeating a letter is uncopyrightable.";
}
else if (command_text == L"69")
{
return L"Cats have over one hundred vocal sounds, while dogs only have about ten.";
}
else if (command_text == L"70")
{
return L"Blueberry Jelly Bellies were created especially for Ronald Reagan.";
}
else if (command_text == L"71")
{
return L"The airplane Buddy Holly died in was the \"American Pie.\" (Thus the name of the Don McLean song.)";
}
else if (command_text == L"72")
{
return L"Each king in a deck of playing cards represents a great king from history. Spades - King David, Clubs - Alexander the Great, Hearts - Charlemagne, and Diamonds - Julius Caesar.";
}
else if (command_text == L"73")
{
return L"A piece of paper can be folded no more then 9 times.";
}
else if (command_text == L"74")
{
return L"You can be fined up to $1,000 for whistling on Sunday in Salt Lake City, Utah.";
}
else if (command_text == L"75")
{
return L"It is illegal to eat oranges while bathing in California.";
}
else if (command_text == L"76")
{
return L"There is a town in Newfoundland, Canada called Dildo.";
}
else if (command_text == L"77")
{
return L"The name of the girl on the statue of liberty is Mother of Exiles.";
}
else if (command_text == L"78")
{
return L"If done perfectly, a rubix cube combination can be solved in 17 turns.";
}
else if (command_text == L"79")
{
return L"It takes about 142.18 licks to reach the center of a Tootsie pop.";
}
else if (command_text == L"80")
{
return L"There are 1,575 steps from the ground floor to the top of the Empire State building.";
}
else if (command_text == L"81")
{
return L"The world's record for keeping a Lifesaver in the mouth with the hole intact is 7 hrs 10 min.";
}
else if (command_text == L"82")
{
return L"In the Philippine jungle, the yo-yo was first used as a weapon.";
}
else if (command_text == L"83")
{
return L"Dueling is legal in Paraguay as long as both parties are registered blood donors.";
}
else if (command_text == L"84")
{
return L"Texas is also the only state that is allowed to fly its state flag at the same height as the U.S. flag.";
}
else if (command_text == L"85")
{
return L"All 50 states are listed across the top of the Lincoln Memorial on the back of the $5 bill.";
}
else if (command_text == L"86")
{
return L"In space, astronauts are unable to cry, because there is no gravity and the tears won't flow.";
}
else if (command_text == L"87")
{
return L"Chewing gum while peeling onions will keep you from crying.";
}
else if (command_text == L"88")
{
return L"There are more plastic flamingos in the U.S that there are real ones.";
}
else if (command_text == L"89")
{
return L"The crack of a whip is actually a tiny sonic boom, since the tip breaks the sound barrier.";
}
else if (command_text == L"90")
{
return L"Honey is the only food which does not spoil.";
}
else if (command_text == L"91")
{
return L"Babies are born without kneecaps. They don't appear until the child reaches 2-6 years of age.";
}
else if (command_text == L"92")
{
return L"The only real person to ever to appear on a pez dispenser was Betsy Ross.";
}
else if (command_text == L"93")
{
return L"Mozart wrote the nursery rhyme 'twinkle, twinkle, little star' at the age of 5.";
}
else if (command_text == L"94")
{
return L"Einstein couldn't speak fluently until after his ninth birthday. His parents thought he was mentally retarded.";
}
else if (command_text == L"95")
{
return L"Al Capone's business card said he was a used furniture dealer.";
}
else if (command_text == L"96")
{
return L"Thomas Edison, acclaimed inventor of the light bulb, was afraid of the dark.";
}
else if (command_text == L"97")
{
return L"\"Dreamt\" is the only English word that ends in the letters \"mt.\"";
}
else if (command_text == L"98")
{
return L"Almonds are a member of the peach family.";
}
else if (command_text == L"99")
{
return L"Maine is the only state whose name is just one syllable.";
}
else if (command_text == L"100")
{
return L"Tigers not only have striped fur, they have striped skin!";
}
else
{
return L"1-100 dumbass!";
}
}
};
}
|
174b581de7caeeb50aaacd8f239fbea48ffc3fbb | f26d9c7d6560ffff2fb0479e3ecd52a48432052e | /1114B.cpp | d32487e6d6fdf94ff9b72c49668b846e57b53eaa | [] | no_license | HelioStrike/Codeforces | e7fc10af38546638ad1049e3a80a9c0884a3ca92 | 39ae1a0cd8c4ea6b795e74db7b486bef94db84dc | refs/heads/master | 2021-06-24T18:29:57.882308 | 2020-10-29T16:44:44 | 2020-10-29T16:44:44 | 158,788,257 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 567 | cpp | 1114B.cpp | #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define MAXN 200010
using namespace std;
int n,m,k,c,arr[MAXN];
priority_queue<pair<int,int> > pq;
ll tot;
int main()
{
scanf("%d%d%d",&n,&m,&k); FOR(i,1,n+1) { scanf("%d",&c); pq.push({c,i}); }
FOR(i,0,m*k) { tot+=pq.top().fi; arr[i]=pq.top().se; pq.pop(); }
sort(arr,arr+m*k);
printf("%lli\n",tot);
for(int i=m-1;i<m*k-1;i+=m) printf("%d ",arr[i]);
printf("\n");
return 0;
} |
99ad9abf38ea39ebb9427ff8707451d606f8c628 | ded5f0aee1f11417c186bc02a8ce40a14f8e17eb | /libMTPerfBase/includes/PerfBasic/MTLog.h | 5d5668b0d9eddf20601f9e2746529b27738e1a37 | [] | no_license | jafo2128/StreamPerf | 53cc4dda1dd7795ee11d10ec1492a359281d47fc | 5e16483a9a8d0bf0862333baa563fa577b9912f9 | refs/heads/master | 2021-08-29T04:54:34.742526 | 2017-12-13T12:46:20 | 2017-12-13T12:46:20 | 287,817,866 | 0 | 1 | null | 2020-08-15T20:12:34 | 2020-08-15T20:12:33 | null | UTF-8 | C++ | false | false | 3,070 | h | MTLog.h | /*
* Copyright (C) 2017-2020 MediaTime
* http://media-tm.com (shareviews@sina.com)
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MediaTime; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
* Original Author: shareviews@sina.com (2017-12-XX)
*/
#pragma once
#include <stdio.h>
//#include "MTSystem/SkOSFile.h"
//#include "MTSystem/SkString.h"
#define LOG_LEVEL_NONE -1 // nothing at all is logged
#define LOG_LEVEL_NORMAL 0 // shows notice, error, severe and fatal
#define LOG_LEVEL_DEBUG 1 // shows all
#define LOG_LEVEL_DEBUG_FREEMEM 2 // shows all + shows freemem on screen
#define LOG_LEVEL_MAX LOG_LEVEL_DEBUG_FREEMEM
// ones we use in the code
#define LOGDEBUG 0
#define LOGINFO 1
#define LOGNOTICE 2
#define LOGWARNING 3
#define LOGERROR 4
#define LOGSEVERE 5
#define LOGFATAL 6
#define LOGNONE 7
// extra masks - from bit 5
#define LOGMASKBIT 5
#define LOGMASK ((1 << LOGMASKBIT) - 1)
#define LOGSAMBA (1 << (LOGMASKBIT + 0))
#define LOGCURL (1 << (LOGMASKBIT + 1))
#define LOGFFMPEG (1 << (LOGMASKBIT + 2))
#define LOGDBUS (1 << (LOGMASKBIT + 4))
#define LOGJSONRPC (1 << (LOGMASKBIT + 5))
#define LOGAUDIO (1 << (LOGMASKBIT + 6))
#define LOGAIRTUNES (1 << (LOGMASKBIT + 7))
#define LOGUPNP (1 << (LOGMASKBIT + 8))
#define LOGCEC (1 << (LOGMASKBIT + 9))
#define LOGVIDEO (1 << (LOGMASKBIT + 10))
#define LOGWEBSERVER (1 << (LOGMASKBIT + 11))
/*Log Print Toolkit, virtual class*/
class MTLogListener {
public:
MTLogListener(){};
~MTLogListener(){};
virtual void OsLog(const char*tag, int level, const char*message) = 0;
};
class MTLog
{
public:
virtual ~MTLog() {}
static void Log(int logLevel, const char *format, ...);
static void LogE(const char* tag, const char *format, ...);
static void LogD(const char* tag, const char *format, ...);
static void LogEx(const char* tag, const char *func, const char *format, ...);
static void LogDebug(const char* tag, const char *func, int debug, const char *format, ...);
static void SetLogLevel(int logLevel);
static void setLogListener(MTLogListener* listener){mLogListener = listener;};
private:
static bool PrintLog(const char* tag, int logLevel, const char* message);
static bool CheckLogLevel(int logLevel);
private:
static int mLogLevel;
static MTLogListener* mLogListener;
};
|
2e01816e94a15da0c7a2db8c151ba4c3008cbaf5 | 6d79e28bbc1fd853aea038810960114f464a1a1b | /FishBrains_Arduino_Rev2/FishBrains_Arduino_Rev2.ino | 1e40df9b8c112677320e7bac6ce20de15f7b0d0e | [] | no_license | BlueFish-MECH400/BlueFish | 7963cf3c55be27d1b86df03b49721865aef1fec7 | a95e046b3a38f078618b597abade8160c821cdcb | refs/heads/main | 2023-04-19T02:29:54.065478 | 2021-04-26T06:06:45 | 2021-04-26T06:06:45 | 347,285,180 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,406 | ino | FishBrains_Arduino_Rev2.ino | /**************************************************************************/
/* Libraries */
/**************************************************************************/
#include <Adafruit_Sensor.h> // IMU
#include <Adafruit_BNO055.h> // IMU
#include <utility/imumaths.h> // IMU math
#include "ping1d.h" // Ping Sonar
#include "SoftwareSerial.h" // Software Serial
#include "MS5837.h" // Bar30 Sensor
#include <PID_v1.h> // PID
#include <Servo.h> // Servo
#include <Wire.h> // I2C
/**************************************************************************/
/* Definitions */
/**************************************************************************/
/* Arduino Pins */
#define EINT1_PIN 2 // External interrupt 1 pin
#define LEAK_PIN 4 // Leak signal pin
#define SERVO_1_PIN 5 // Servo 1 pin
#define SERVO_2_PIN 6 // Servo 2 pin
#define SRX_PIN 9 // Software serial Rx pin
#define STX_PIN 10 // Software serial Tx pin
#define LED_1_PIN 11 // LED pin (for debugging)
#define LED_2_PIN 12 // LED pin (for debugging)
#define LED_3_PIN 13 // LED pin (for debugging)
#define ADC_1_PIN A0 // ADC 1 pin for batt voltage measurement (Pin 4 of power sense)
#define ADC_2_PIN A1 // ADC 2 pin for batt current measurement (Pin 3 of power sense)
/* States */
#define IDLE 0
#define DEPTH 1
#define ALTITUDE 2
#define SURFACE 3
/* General Constants */
#define SEA_WATER 997 // Density of seawater in kg/m^3 (997 Fresh/1029 Salt)
#define BAUD_RATE 9600 // Serial baud rate
#define INIT_SERVO_POS 90 // Initial servo position 90 degrees
#define SERVO_LIMIT 18 // Max servo position in degrees (inital + 45)
#define HEIGHT_LIMIT 250 // Range of acceptable height/depth varation (mm)
/* IMU Sample Rate */
#define BNO055_SAMPLERATE_DELAY_MS (100) // BNO055 sample delay in ms
/**************************************************************************/
/* Global Variables */
/**************************************************************************/
uint8_t leak = 0; // 0 = Dry , 1 = Leak
uint8_t leakState = 0; // 0 = LED off , 1 = LED on
uint8_t state = IDLE; // State value
int adc1, adc2 = 0; // Variables for ADC values
unsigned long currentTime, lastTime, transmitTime = 0; // For time tracking
int logRate = 0;
double logPeriod = 0;
double minAltitude = 1000; // Minimum distance from sea floor (mm)
double maxDepth = 100000; // Maximum depth
/* Sensor Variables */
double depth, pressure, temperature = 0; // Bar30 data
double dx, dy, dz = 0; // BNO055 IMU gyro data (y is pitch, z is roll)
double altitude = 0; // Ping sonar data
double dAltitude, dDepth = 0;
double voltage, current = 0;
/* PID Variables */
double targetDepth, targetAltitude = 0; // Target values of depth and altitude
double heightSetpoint, heightInput, heightOutput, OutH = 0; // Height PID
double rollSetpoint, rollInput, rollOutput, OutR = 0; // Roll PID
double output1, output2 = 0; // Servo1 and servo2 output
/* PID Tuning Parameters */
double hKp, hKi, hKd = 0; // Height proportional, integral, derivative gains
double dKp, dKi, dKd = 0; // Depth proportional, integral, derivative gains
double rKp, rKi, rKd = 0; // Roll proportional, integral, derivative gains
double aKp, aKi, aKd = 0; // Adaptive proportional, integral, derivative gains
unsigned int mDelay = 15; // Delay for servo motors
unsigned int sDelay = 500; // Short delay
unsigned int lDelay = 2000; // Long delay
unsigned int servoMax = INIT_SERVO_POS + SERVO_LIMIT;
unsigned int servoMin = INIT_SERVO_POS - SERVO_LIMIT;
unsigned int servoRatio = SERVO_LIMIT/HEIGHT_LIMIT; //ratio of servo angle to depth/height range
/**************************************************************************/
/* Object Declarations */
/**************************************************************************/
SoftwareSerial pingSerial = SoftwareSerial(SRX_PIN, STX_PIN); // Set ping serial to use SS pins
static Ping1D ping { pingSerial }; // Create ping object with SS
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28); // Create BNO055 object and set I2C address
sensors_event_t event; // Create event for BNO055
MS5837 bar30; // Create Bar30 object
Servo servo1; // Servo 1 object
Servo servo2; // Servo 2 object
PID heightPID(&heightInput, &heightOutput, &heightSetpoint, hKp, hKi, hKd, P_ON_M, DIRECT); // Height PID
PID rollPID(&rollInput, &rollOutput, &rollSetpoint, rKp, rKi, rKd, P_ON_M, DIRECT); // Roll PID
/**************************************************************************/
/* Functions */
/**************************************************************************/
void initSensor(void); // Checks if sensors are functioning
void displayCalStatus(void); // Display IMU calibration (for debugging)
void readSensors(void); // Read all sensors and store values
void transmitData(void); // Transmit data via serial
void leakWarningFlash(void); // Display leak warning on LEDs
void runPID(void); // Compute PID outputs
void updateSettings(void); // ISR to update settings sent from RPi
void outputPID(void); // Display PID I/O (for debugging)
/**************************************************************************/
/* Program Setup */
/**************************************************************************/
void setup(void)
{
/* Set I/O pinmodes */
pinMode(LEAK_PIN, INPUT); // Set leak sensor pin to INPUT
pinMode(EINT1_PIN, INPUT); // Set interrupt pin to INPUT
pinMode(LED_1_PIN, OUTPUT); // Set LED1 pin to OUTPUT
pinMode(LED_2_PIN, OUTPUT); // Set LED2 pin to OUTPUT
pinMode(LED_3_PIN, OUTPUT); // Set LED3 pin to OUTPUT
analogReference(EXTERNAL); // External ADC ref for more accurate reading
// Aref pin is connected to 3.3V out
/* Initialize serial and I2C */
Serial.begin(BAUD_RATE); // Initialize serial at baud rate
pingSerial.begin(BAUD_RATE); // Initialize software serial at baud rate
Wire.begin(); // Initialize I2C
bno.begin(); // Begin bno sensor
bar30.init(); // Initialize Bar30 sensor
ping.initialize(); // Initialize ping sensor
initSensor(); // Checks if sensors are functioning
/* Bar 30 sensor setup */
bar30.setModel(MS5837::MS5837_30BA);
bar30.setFluidDensity(SEA_WATER); // Set fluid density to sea water
sensor_t sensor; // Used for BNO055
bno.getSensor(&sensor);
bno.setExtCrystalUse(true);
displayCalStatus(); // Wait until BNO055 calibrated (display status on LEDs)
attachInterrupt(digitalPinToInterrupt(EINT1_PIN),updateSettings,RISING);
/* Attach servos and write initial position */
servo1.attach(SERVO_1_PIN, 500, 2500); // Attach servo1 to servo1 pin
servo1.write(INIT_SERVO_POS); // Set servo1 position to initial position
delay(sDelay);
servo2.attach(SERVO_2_PIN, 500, 2500); // Attach servo2 to servo2 pin
servo2.write(INIT_SERVO_POS); // Set servo2 position to initial position
delay(mDelay);
/* Turn on PID and set output limits
heightPID.SetMode(AUTOMATIC); // Set height PID mode automatic (ON)
rollPID.SetMode(AUTOMATIC); // Set roll PID mode automatic (ON)
heightPID.SetOutputLimits(-HEIGHT_LIMIT,HEIGHT_LIMIT); // Set Height PID limits (+-250 mm)
rollPID.SetOutputLimits(-SERVO_LIMIT,SERVO_LIMIT); // Set roll PID limits to servo limits
*/
/* Bar 30 sensor setup
bar30.setModel(MS5837::MS5837_30BA);
bar30.setFluidDensity(SEA_WATER); // Set fluid density to sea water
sensor_t sensor; // Used for BNO055
bno.getSensor(&sensor);
bno.setExtCrystalUse(true);
*/
delay(1000); // Delay for IMU calibration
}
/**************************************************************************/
/* Main Routine */
/**************************************************************************/
void loop(void){
//displayCalStatus(); // Wait until BNO055 calibrated (display status on LEDs)
goto RUN_BLUEFISH;
RUN_BLUEFISH:
/* Check for leak */
leak = digitalRead(LEAK_PIN);// Read the Leak Sensor Pin
if (leak == HIGH) { // If leak detected
state = DEPTH; // Set state to DEPTH mode
leakWarningFlash(); // Flash LEDs indicating leak
goto MODE_SWITCH;
}
logPeriod = (1/logRate)*1000; // Convert log rate in Hz to period in milliseconds
currentTime = millis(); // Set current time
goto MODE_SWITCH;
MODE_SWITCH:
switch(state) {
case IDLE:
goto IDLE_MODE;
break;
case DEPTH:
goto DEPTH_MODE;
break;
case ALTITUDE:
goto ALTITUDE_MODE;
break;
case SURFACE:
goto SURFACE_MODE;
break;
default:
goto RUN_BLUEFISH;
}
IDLE_MODE:
servo1.write(INIT_SERVO_POS);
servo2.write(INIT_SERVO_POS);
delay(mDelay);
goto RUN_BLUEFISH;
DEPTH_MODE:
if (leak == HIGH) { // If leak detected
targetDepth = 0; // Set target depth to 0 (surface)
}
if((currentTime-transmitTime)>=logPeriod) { // Check if time to transmit data
readSensors();
transmitTime = currentTime;
transmitData(); // Transmit data to Raspberry Pi
}
else{
readSensors(); // Read sensor data
}
if(altitude <= minAltitude) { // Check if close to seafloor
servo1.write(servoMin); // Set servo1 position to min
servo2.write(servoMax); // Set servo1 position to max
delay(mDelay);
} else if(depth >= maxDepth) { // Check if maximum depth
servo1.write(servoMin); // Set servo1 position to min
servo2.write(servoMax); // Set servo1 position to max
delay(mDelay);
} else {
heightSetpoint = targetDepth; // Set height setpoint to target depth
heightInput = depth; // Set PID height input to depth
runPID(); // Run PID to computed servo outputs
servo1.write(output1); // Write output to servo1
servo2.write(output2); // Write output to servo2
delay(mDelay);
}
goto RUN_BLUEFISH;
ALTITUDE_MODE:
if((currentTime-transmitTime)>=logPeriod) { // Check if time to transmit data
readSensors();
transmitTime = currentTime;
transmitData(); // Transmit data to Raspberry Pi
}else{
readSensors();
}
if(altitude < minAltitude) { // Check if close to seafloor
servo1.write(servoMin); // Set servo1 position to min
servo2.write(servoMax); // Set servo1 position to max
delay(mDelay);
} else if(depth >= maxDepth) { // Check if maximum depth
servo1.write(servoMin); // Set servo1 position to min
servo2.write(servoMax); // Set servo1 position to max
delay(mDelay);
} else {
heightSetpoint = targetAltitude; // Set height setpoint to target altitude
heightInput = altitude; // Set PID height input to altitude
runPID(); // Run PID to computed servo outputs
servo1.write(output1); // Write output to servo1
servo2.write(output2); // Write output to servo2
delay(mDelay);
}
goto RUN_BLUEFISH;
SURFACE_MODE:
servo1.write(INIT_SERVO_POS); // Set servo positions to initial position
servo2.write(INIT_SERVO_POS);
delay(mDelay);
goto RUN_BLUEFISH;
}
/*---- End of Main Routine -----------------------------------------------*/
/**************************************************************************/
/* Function Definitions */
/**************************************************************************/
/*========================================================================*/
/*------Sensor Intitialziation Verification-------------------------------*/
/*========================================================================*/
void initSensor(void) {
int bnoC, bar30C, pingC = 0; // Sensor status: 0 = connected, 1 = disconnected
if(!bno.begin()){ //check if BNO055 functioning
bnoC = 1;
}else{
bnoC = 0;
}
if(!bar30.init()) { //check if Bar30 functioning
bar30C = 1;
}else{
bar30C = 0;
}
if(!ping.initialize()) { //check if Ping functioning
pingC = 1;
}else{
pingC = 0;
}
/* Blink LED while sensor is not initiailized */
/* LED1 = BNO055, LED2 = Bar30, LED3 = Ping */
while((bnoC==1)||(bar30C==1)||(pingC==1)) {
if(bnoC == 1) {
digitalWrite(LED_1_PIN,HIGH);
}
if(bar30C == 1) {
digitalWrite(LED_2_PIN,HIGH);
}
if(pingC == 1) {
digitalWrite(LED_3_PIN,HIGH);
}
delay(sDelay);
digitalWrite(LED_1_PIN,LOW);
digitalWrite(LED_2_PIN,LOW);
digitalWrite(LED_3_PIN,LOW);
delay(sDelay);
}
}
/*========================================================================*/
/*------Display sensor calibration status (For Debugging)-----------------*/
/*========================================================================*/
void displayCalStatus(void) {
uint8_t system, gyro, accel, mag = 0;
/* While all values not calibrated, get calibration status.*/
/* 3 means 'fully calibrated" and requires system > 0 */
/* When fully calibrated, all LEDs are on. */
/* (LED1 = gyro, LED2 = accel, LED3 = mag) */
while(!((gyro==3)&&(accel== 3) && (mag == 3) && (system== 1))){
/* Get the four calibration values (0..3) */
bno.getCalibration(&system, &gyro, &accel, &mag);
if(gyro==3){
digitalWrite(LED_1_PIN,HIGH);
}else{
digitalWrite(LED_1_PIN,LOW);
}
if(accel==3){
digitalWrite(LED_2_PIN,HIGH);
}else{
digitalWrite(LED_2_PIN,LOW);
}
if(mag==3){
digitalWrite(LED_3_PIN,HIGH);
}else{
digitalWrite(LED_3_PIN,LOW);
}
}
Serial.println("Calibration Complete");
}
/*========================================================================*/
/*------Leak Sensor Warning-----------------------------------------------*/
/*========================================================================*/
void leakWarningFlash(void) {
if((currentTime-lastTime)>=sDelay) {
lastTime = currentTime;
if(leakState==LOW) {
leakState = HIGH;
digitalWrite(LED_1_PIN, leakState);
digitalWrite(LED_2_PIN, leakState);
digitalWrite(LED_3_PIN, leakState);
}else if(leakState == HIGH) {
leakState = LOW;
digitalWrite(LED_1_PIN, leakState);
digitalWrite(LED_2_PIN, leakState);
digitalWrite(LED_3_PIN, leakState);
}
}
}
/*========================================================================*/
/*------Read Sensor Data--------------------------------------------------*/
/*========================================================================*/
void readSensors(void) {
/* Read Bar30 sensor data */
bar30.read();
pressure = bar30.pressure()*10; //read pressure and convert to kPa
temperature = bar30.temperature(); // temperature in degrees celcius
depth = bar30.depth()*1000; // depth in mm
dDepth = targetDepth-depth; // error in depth
/* Read BNO055 sensor data */
/* Get a new sensor event */
sensors_event_t event;
bno.getEvent(&event);
/* Store data */
dx = event.orientation.x;
dy = event.orientation.y;
dz = event.orientation.z;
/* Read Ping sensor Data*/
if (ping.update()) {
altitude = ping.distance(); //get distance in mm
dAltitude = targetAltitude-altitude; //determine error in altitude (mm)
}
adc1 = analogRead(ADC_1_PIN); // Perform ADC on A0 (batt voltage)
adc2 = analogRead(ADC_2_PIN); // Perform ADC on A1 (batt current)
/* Using 3.3V connected to AREF pin */
voltage = adc1*(3.3/1024)*11.0; // convert 10 bit number to volts
current = (adc2*(3.3/1024)-0.33)*38.8788; // convert 10 bit number to amps
/* Uncomment if not using 3.3V AREF jumper (ie 5V ref) */ /*
voltage = adc1*(5.0/1024)*11.0; // convert 10 bit number to volts
current = (adc2*(5.0/1024)-0.33)*38.8788; // convert 10 bit number to amps
*/
}
/*========================================================================*/
/*------Transmit Data via Serial------------------------------------------*/
/*========================================================================*/
void transmitData(void) {
/* Transmit sensor data */
Serial.print(altitude/1000);
Serial.print(",");
Serial.print(dAltitude/1000); // Error in altitude
Serial.print(",");
Serial.print(depth/1000);
Serial.print(",");
Serial.print(dDepth/1000); // Error in altitude
Serial.print(",");
Serial.print(pressure);
Serial.print(",");
Serial.print(temperature);
Serial.print(",");
Serial.print(dx); // THESE WILL LIKELY CHANGE TO ERRORS
Serial.print(",");
Serial.print(dy);
Serial.print(",");
Serial.print(dz);
Serial.print(",");
Serial.print(voltage); // Error in altitude
Serial.print(",");
Serial.println(current); // Error in altitude
}
/*========================================================================*/
/*------Compute PID Output------------------------------------------------*/
/*========================================================================*/
void runPID(void) {
/* Compute PID outputs for height and roll */
if(state==DEPTH){
heightPID.SetTunings(dKp,dKi,dKd);
}
if(state==ALTITUDE){
heightPID.SetTunings(hKp,hKi,hKd);
}
heightPID.Compute();
OutH = heightOutput;
rollInput = dz; // Roll input = z position
rollPID.SetTunings(rKp,rKi,rKd);
rollPID.Compute();
OutR = rollOutput;
/* Compute combined roll and height outputs */
output1 = 90 - (servoRatio*OutH) + OutR; // Convert height output to angular and add roll angle
output2 = 90 + (servoRatio*OutH) + OutR;
}
/*========================================================================*/
/*------Interrupt ISR for Updating Settings-------------------------------*/
/*========================================================================*/
void updateSettings() {
if(Serial.available() > 0) {
String temp = Serial.readStringUntil(',');
logRate = temp.toDouble();
temp = Serial.readStringUntil(',');
state = temp.toInt();
temp = Serial.readStringUntil(',');
targetDepth = (temp.toDouble())*1000;
temp = Serial.readStringUntil(',');
targetAltitude = (temp.toDouble())*1000;
temp = Serial.readStringUntil(',');
rKp = temp.toDouble();
temp = Serial.readStringUntil(',');
rKi = temp.toDouble();
temp = Serial.readStringUntil(',');
rKd = temp.toDouble();
hKp = temp.toDouble();
temp = Serial.readStringUntil(',');
hKi = temp.toDouble();
temp = Serial.readStringUntil(',');
hKd = temp.toDouble();
temp = Serial.readStringUntil(',');
dKp = temp.toDouble();
temp = Serial.readStringUntil(',');
dKi = temp.toDouble();
temp = Serial.readStringUntil(',');
dKd = temp.toDouble();
temp = Serial.readStringUntil(',');
/* Uncomment if using adaptive tuning */
/*
aKp = temp.toDouble();
temp = Serial.readStringUntil(',');
aKi = temp.toDouble();
temp = Serial.readStringUntil(',');
aKd = temp.toDouble();
*/
}
}
/*========================================================================*/
/*------Display PID I/O (For Debugging)-----------------------------------*/
/*========================================================================*/
void outputPID(void){
/* Display PID pinput and output values in serial*/
Serial.print("Height PID Input: ");
Serial.println(heightInput);
Serial.print("Height PID Output: ");
Serial.println(heightOutput);
Serial.print("Roll PID Input: ");
Serial.println(rollInput);
Serial.print("Roll PID Output: ");
Serial.println(rollOutput);
Serial.print("PID OutH: ");
Serial.println(OutH);
Serial.print("PID OutR: ");
Serial.println(OutR);
Serial.print("Output1: ");
Serial.println(output1);
Serial.print("Output2: ");
Serial.println(output2);
}
|
650752f7a9ac9e5687d2511b0cca59bdabe71f7a | b7ebcd1a5818c25632baad1e80aa1967cfb26766 | /QDirectX/D3D11/src/D3D11Utils.cpp | b3336a4852f6315abd3d125280ef3dc145bb6626 | [
"MIT"
] | permissive | jiawen/libcgt | b97094915aebfa388ca57ed0ce6b67869bd8267f | ba4d17b009e98967276159d71e06a1a441712d2f | refs/heads/master | 2021-01-17T00:59:52.402375 | 2017-04-04T18:41:43 | 2017-04-04T18:41:43 | 2,549,060 | 16 | 2 | null | 2017-01-19T23:12:22 | 2011-10-10T15:45:28 | C++ | UTF-8 | C++ | false | false | 17,955 | cpp | D3D11Utils.cpp | #include "D3D11Utils.h"
#include <QFile>
#include <QTextStream>
#include <common/BasicTypes.h>
#include <color/ColorUtils.h>
#include "DynamicTexture2D.h"
#include "StagingTexture2D.h"
#include "StagingStructuredBuffer.h"
// static
std::vector< IDXGIAdapter* > D3D11Utils::getDXGIAdapters()
{
std::vector< IDXGIAdapter* > adapters;
IDXGIFactory1* pFactory;
HRESULT hr = CreateDXGIFactory1( __uuidof( IDXGIFactory1 ), ( void** )( &pFactory ) );
if( SUCCEEDED( hr ) )
{
uint i = 0;
IDXGIAdapter* pAdapter;
while( pFactory->EnumAdapters( i, &pAdapter ) != DXGI_ERROR_NOT_FOUND )
{
adapters.push_back( pAdapter );
++i;
}
pFactory->Release();
}
return adapters;
}
// static
D3D11_VIEWPORT D3D11Utils::createViewport( int width, int height )
{
return createViewport( 0, 0, width, height, 0.0f, 1.0f );
}
// static
D3D11_VIEWPORT D3D11Utils::createViewport( const Vector2i& wh )
{
return createViewport( wh[ 0 ], wh[ 1 ] );
}
// static
D3D11_VIEWPORT D3D11Utils::createViewport( int topLeftX, int topLeftY, int width, int height, float zMin, float zMax )
{
D3D11_VIEWPORT vp;
vp.TopLeftX = topLeftX;
vp.TopLeftY = topLeftY;
vp.Width = width;
vp.Height = height;
vp.MinDepth = zMin;
vp.MaxDepth = zMax;
return vp;
}
// static
D3D11_VIEWPORT D3D11Utils::createViewport( const Rect2f& rect, float zMin, float zMax )
{
D3D11_VIEWPORT vp;
vp.TopLeftX = rect.origin().x;
vp.TopLeftY = rect.origin().y;
vp.Width = rect.width();
vp.Height = rect.height();
vp.MinDepth = zMin;
vp.MaxDepth = zMax;
return vp;
}
// static
std::vector< VertexPosition4fNormal3fTexture2f > D3D11Utils::createBox( bool normalsPointOutward )
{
Vector4f positions[ 8 ];
for( int i = 0; i < 8; ++i )
{
positions[ i ][ 0 ] = ( i & 0x1 ) ? 1 : 0;
positions[ i ][ 1 ] = ( i & 0x2 ) ? 1 : 0;
positions[ i ][ 2 ] = ( i & 0x4 ) ? 1 : 0;
positions[ i ][ 3 ] = 1;
}
Vector3f normals[ 6 ]; // pointing outward
normals[ 0 ] = Vector3f( 1, 0, 0 ); // right
normals[ 1 ] = Vector3f( -1, 0, 0 ); // left
normals[ 2 ] = Vector3f( 0, 1, 0 ); // top
normals[ 3 ] = Vector3f( 0, -1, 0 ); // bottom
normals[ 4 ] = Vector3f( 0, 0, 1 ); // front
normals[ 5 ] = Vector3f( 0, 0, -1 ); // back
Vector2f tc( 0, 0 );
std::vector< VertexPosition4fNormal3fTexture2f > vertexArray;
vertexArray.reserve( 36 );
if( normalsPointOutward )
{
// bottom
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 4 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 1 ], normals[ 3 ], tc ) );
// left
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 4 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 2 ], normals[ 1 ], tc ) );
// back
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 1 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 2 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 2 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 1 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 5 ], tc ) );
// front
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 7 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 4 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 4 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 7 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 4 ], tc ) );
// top
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 2 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 7 ], normals[ 2 ], tc ) );
// right
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 1 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 7 ], normals[ 0 ], tc ) );
}
else
{
// bottom
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 4 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 2 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 1 ], normals[ 2 ], tc ) );
// left
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 4 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 0 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 2 ], normals[ 0 ], tc ) );
// back
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 0 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 1 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 2 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 2 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 1 ], normals[ 4 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 4 ], tc ) );
// front
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 7 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 4 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 4 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 7 ], normals[ 5 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 5 ], tc ) );
// top
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 2 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 6 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 3 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 7 ], normals[ 3 ], tc ) );
// right
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 1 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 3 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 5 ], normals[ 1 ], tc ) );
vertexArray.push_back( VertexPosition4fNormal3fTexture2f( positions[ 7 ], normals[ 1 ], tc ) );
}
return vertexArray;
}
// static
DynamicVertexBuffer* D3D11Utils::createFrustum( ID3D11Device* pDevice,
const Vector3f& eye, const std::vector< Vector3f >& frustumCorners,
const Vector4f& color )
{
DynamicVertexBuffer* pBuffer = DynamicVertexBuffer::create( pDevice, 24, VertexPosition4fColor4f::sizeInBytes() );
VertexPosition4fColor4f* vertexArray = pBuffer->mapForWriteDiscardAs< VertexPosition4fColor4f >();
writeFrustum( eye, frustumCorners, color, vertexArray );
pBuffer->unmap();
return pBuffer;
}
// static
void D3D11Utils::writeFrustum( const Vector3f& eye, const std::vector< Vector3f >& frustumCorners, VertexPosition4f* vertexArray )
{
// 4 lines from eye to each far corner
vertexArray[0].position = Vector4f( eye, 1 );
vertexArray[1].position = Vector4f( frustumCorners[4], 1 );
vertexArray[2].position = Vector4f( eye, 1 );
vertexArray[3].position = Vector4f( frustumCorners[5], 1 );
vertexArray[4].position = Vector4f( eye, 1 );
vertexArray[5].position = Vector4f( frustumCorners[6], 1 );
vertexArray[6].position = Vector4f( eye, 1 );
vertexArray[7].position = Vector4f( frustumCorners[7], 1 );
// 4 lines between near corners
vertexArray[8].position = Vector4f( frustumCorners[0], 1 );
vertexArray[9].position = Vector4f( frustumCorners[1], 1 );
vertexArray[10].position = Vector4f( frustumCorners[1], 1 );
vertexArray[11].position = Vector4f( frustumCorners[2], 1 );
vertexArray[12].position = Vector4f( frustumCorners[2], 1 );
vertexArray[13].position = Vector4f( frustumCorners[3], 1 );
vertexArray[14].position = Vector4f( frustumCorners[3], 1 );
vertexArray[15].position = Vector4f( frustumCorners[0], 1 );
// 4 lines between far corners
vertexArray[16].position = Vector4f( frustumCorners[4], 1 );
vertexArray[17].position = Vector4f( frustumCorners[5], 1 );
vertexArray[18].position = Vector4f( frustumCorners[5], 1 );
vertexArray[19].position = Vector4f( frustumCorners[6], 1 );
vertexArray[20].position = Vector4f( frustumCorners[6], 1 );
vertexArray[21].position = Vector4f( frustumCorners[7], 1 );
vertexArray[22].position = Vector4f( frustumCorners[7], 1 );
vertexArray[23].position = Vector4f( frustumCorners[4], 1 );
}
// static
void D3D11Utils::writeFrustum( const Vector3f& eye, const std::vector< Vector3f >& frustumCorners, const Vector4f& color,
VertexPosition4fColor4f* vertexArray )
{
// 4 lines from eye to each far corner
vertexArray[0].position = Vector4f( eye, 1 );
vertexArray[1].position = Vector4f( frustumCorners[4], 1 );
vertexArray[2].position = Vector4f( eye, 1 );
vertexArray[3].position = Vector4f( frustumCorners[5], 1 );
vertexArray[4].position = Vector4f( eye, 1 );
vertexArray[5].position = Vector4f( frustumCorners[6], 1 );
vertexArray[6].position = Vector4f( eye, 1 );
vertexArray[7].position = Vector4f( frustumCorners[7], 1 );
// 4 lines between near corners
vertexArray[8].position = Vector4f( frustumCorners[0], 1 );
vertexArray[9].position = Vector4f( frustumCorners[1], 1 );
vertexArray[10].position = Vector4f( frustumCorners[1], 1 );
vertexArray[11].position = Vector4f( frustumCorners[2], 1 );
vertexArray[12].position = Vector4f( frustumCorners[2], 1 );
vertexArray[13].position = Vector4f( frustumCorners[3], 1 );
vertexArray[14].position = Vector4f( frustumCorners[3], 1 );
vertexArray[15].position = Vector4f( frustumCorners[0], 1 );
// 4 lines between far corners
vertexArray[16].position = Vector4f( frustumCorners[4], 1 );
vertexArray[17].position = Vector4f( frustumCorners[5], 1 );
vertexArray[18].position = Vector4f( frustumCorners[5], 1 );
vertexArray[19].position = Vector4f( frustumCorners[6], 1 );
vertexArray[20].position = Vector4f( frustumCorners[6], 1 );
vertexArray[21].position = Vector4f( frustumCorners[7], 1 );
vertexArray[22].position = Vector4f( frustumCorners[7], 1 );
vertexArray[23].position = Vector4f( frustumCorners[4], 1 );
for( int i = 0; i < 24; ++i )
{
vertexArray[i].color = color;
}
}
// static
std::vector< Vector4f > D3D11Utils::createAxes()
{
std::vector< Vector4f > output( 6 );
// x
output[ 0 ] = Vector4f( 0, 0, 0, 1 );
output[ 1 ] = Vector4f( 1, 0, 0, 1 );
// y
output[ 2 ] = Vector4f( 0, 0, 0, 1 );
output[ 3 ] = Vector4f( 0, 1, 0, 1 );
// z
output[ 4 ] = Vector4f( 0, 0, 0, 1 );
output[ 5 ] = Vector4f( 0, 0, 1, 1 );
return output;
}
// static
DynamicVertexBuffer* D3D11Utils::createAxes( ID3D11Device* pDevice )
{
DynamicVertexBuffer* buffer = DynamicVertexBuffer::create( pDevice, 6, VertexPosition4fColor4f::sizeInBytes() );
VertexPosition4fColor4f* vertexArray = reinterpret_cast< VertexPosition4fColor4f* >( buffer->mapForWriteDiscard().pData );
writeAxes( vertexArray );
buffer->unmap();
return buffer;
}
// static
void D3D11Utils::writeAxes( VertexPosition4fColor4f* vertexArray )
{
// x
vertexArray[ 0 ] = VertexPosition4fColor4f( 0, 0, 0, 1, 0, 0 );
vertexArray[ 1 ] = VertexPosition4fColor4f( 1, 0, 0, 1, 0, 0 );
// y
vertexArray[ 2 ] = VertexPosition4fColor4f( 0, 0, 0, 0, 1, 0 );
vertexArray[ 3 ] = VertexPosition4fColor4f( 0, 1, 0, 0, 1, 0 );
// z
vertexArray[ 4 ] = VertexPosition4fColor4f( 0, 0, 0, 0, 0, 1 );
vertexArray[ 5 ] = VertexPosition4fColor4f( 0, 0, 1, 0, 0, 1 );
}
// static
bool D3D11Utils::saveFloat2BufferToTXT( ID3D11Device* pDevice, std::shared_ptr< StaticDataBuffer > pBuffer, QString filename )
{
int ne = pBuffer->numElements();
int esb = pBuffer->elementSizeBytes();
std::shared_ptr< StagingStructuredBuffer > sb
(
StagingStructuredBuffer::create( pDevice, ne, esb )
);
sb->copyFrom( pBuffer->buffer() );
QFile outputFile( filename );
// try to open the file in write only mode
if( !( outputFile.open( QIODevice::WriteOnly ) ) )
{
return false;
}
QTextStream outputTextStream( &outputFile );
outputTextStream.setCodec( "UTF-8" );
outputTextStream << "float2 buffer: nElements = " << ne << "\n";
outputTextStream << "[index]: x y\n";
float* pData = reinterpret_cast< float* >( sb->mapForReadWrite().pData );
for( int i = 0; i < ne; ++i )
{
float x = pData[ 2 * i ];
float y = pData[ 2 * i + 1 ];
outputTextStream << "[" << i << "]: " << x << " " << y << "\n";
}
outputFile.close();
return true;
}
// static
bool D3D11Utils::saveFloat2BufferToTXT( ID3D11Device* pDevice, std::shared_ptr< StaticStructuredBuffer > pBuffer, QString filename )
{
int ne = pBuffer->numElements();
int esb = pBuffer->elementSizeBytes();
std::shared_ptr< StagingStructuredBuffer > sb
(
StagingStructuredBuffer::create( pDevice, ne, esb )
);
sb->copyFrom( pBuffer->buffer() );
QFile outputFile( filename );
// try to open the file in write only mode
if( !( outputFile.open( QIODevice::WriteOnly ) ) )
{
return false;
}
QTextStream outputTextStream( &outputFile );
outputTextStream.setCodec( "UTF-8" );
outputTextStream << "float2 buffer: nElements = " << ne << "\n";
outputTextStream << "[index]: x y\n";
float* pData = reinterpret_cast< float* >( sb->mapForReadWrite().pData );
for( int i = 0; i < ne; ++i )
{
float x = pData[ 2 * i ];
float y = pData[ 2 * i + 1 ];
outputTextStream << "[" << i << "]: " << x << " " << y << "\n";
}
outputFile.close();
return true;
}
|
f8a56c0bd4072dfa41b8b1ff494c2cde24fa6cde | 6aba833bfe411f6c003d41c46a985701ad2f281a | /XcodeProject/minDeleteOperationToMakeAllElementsSame.cpp | e10fc45e7b8700b3e37a0dca122c00b04847a9af | [] | no_license | shakyajay/cp | d08bda1380381593cf2c0408e339d0c3dae72395 | 7259644609bae814d8c12d2b7f2632c50e06dc46 | refs/heads/master | 2022-03-20T05:11:20.662377 | 2019-12-01T20:05:05 | 2019-12-01T20:05:05 | 118,436,879 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 751 | cpp | minDeleteOperationToMakeAllElementsSame.cpp | //
// minDeleteOperationToMakeAllElementsSame.cpp
// XcodeProject
//
// Created by Ajay Shakya on 11/29/19.
// Copyright © 2019 Ajay Shakya. All rights reserved.
//
#include <iostream>
#include <unordered_map>
using namespace std;
void minDelOperation(int arr[],int size){
unordered_map<int, int> mp;
int maxCnt=0;
for(int i=0;i<size;i++){
mp[arr[i]]++;
}
for(auto& [key,value] : mp){
if(maxCnt<value)maxCnt=value;
}
cout<< "minimum no of delete operation to make all elements same in array: "<< (size-maxCnt)<<endl;
}
int main(){
int arr[] = {1, 2, 3, 4, 5};
int size = sizeof(arr)/sizeof(arr[0]);
minDelOperation(arr,size);
return 0;
}
|
bb5bc576a46a615abe01f5ffec40eec4fcdb78d8 | 7da62ebabb321b26e741f2161ea3fb7680184c5e | /longest_palindromic_substring.cpp | 1e08c281fae94dca9bad1c7e6adfac160af90802 | [] | no_license | saga92/leetcode | 1f04730f580abbfaa01c6fa822fe2c9de6e0cec8 | 6781b4052336fda78da8459be93823c948c4734a | refs/heads/master | 2021-01-23T04:29:11.939013 | 2017-05-26T07:13:39 | 2017-05-26T07:13:39 | 86,200,218 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,125 | cpp | longest_palindromic_substring.cpp | #include<string>
#include <vector>
using namespace std;
class Solution {
public:
string longestPalindrome(string s) {
if(s.empty()) return "";
if(s.size()==1) return s;
int min_start=0,max_len=1;
int slen=s.size();
vector<vector<int>> dp(slen, vector<int>(slen));
//init
for(int i=0;i<slen;i++){
for(int j=0;j<slen;j++){
if(i>=j){
dp[i][j]=1;
}
}
}
int i=0,j=0;
for(int k=1;k<s.size();k++){
for(i=0;(j=i+k)<s.size();i++){
if(s[i]==s[j]){
dp[i][j]=dp[i+1][j-1];
if(dp[i][j]){
if(k+1>max_len){
min_start=i;
max_len=k+1;
}
}
}else{
dp[i][j]=0;
}
}
}
return s.substr(min_start,max_len);
}
};
int main(){
Solution solution;
string res=solution.longestPalindrome("bb");
return 0;
} |
47e71bddde0c8c4a20ce202c3b52ba12cc5ec843 | 8352ca72d4f1e8e8ebbbb7d6b07a4e0963be7f41 | /DataServer/DataServer_TIP/TA_APP/transactive/test/TestQT/TestQtPaint/src/RectAreaBoundingAreas.cpp | 65372ae5616c9abdcf1f4de16b5fec4900386957 | [] | no_license | radtek/slin_code | 114f61695fc1a23a018da727452c3c42f64ebe39 | a0073e52d600839f7836c2b7673b45b4266259e2 | refs/heads/master | 2020-06-04T15:03:56.618177 | 2015-04-27T10:27:47 | 2015-04-27T10:27:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,395 | cpp | RectAreaBoundingAreas.cpp | #include "RectAreaBoundingAreas.h"
CRectAreaBoundingAreas::CRectAreaBoundingAreas( QPointF scenePos, QRectF rectDraw, qreal nBoundingRectWidth, qreal nBoundingRectHeight )
{
m_scenePos = scenePos;
m_rectDraw = rectDraw;
m_nBoundingRectWidth = nBoundingRectWidth;
m_nBoundingRectHeight = nBoundingRectHeight;
_ResetEightRectAreas();
}
CRectAreaBoundingAreas::~CRectAreaBoundingAreas()
{
}
void CRectAreaBoundingAreas::_ResetEightRectAreas()
{
QRectF rectDrawInScenePos;
rectDrawInScenePos.setTopLeft(m_scenePos + QPointF(m_rectDraw.x(), m_rectDraw.y()));
rectDrawInScenePos.setBottomLeft(m_scenePos + QPointF(m_rectDraw.x(), m_rectDraw.y() + m_rectDraw.height()));
rectDrawInScenePos.setTopRight(m_scenePos + QPointF(m_rectDraw.x() + m_rectDraw.width(), m_rectDraw.y()));
rectDrawInScenePos.setBottomRight(m_scenePos + QPointF(m_rectDraw.x() + m_rectDraw.width(), m_rectDraw.y() + m_rectDraw.height()));
m_nBoundingRectWidthHalf = m_nBoundingRectWidth / 2;
m_nBoundingRectHeightHalf = m_nBoundingRectHeight / 2;
//1 RectAreaBoundingType_LeftMiddle
m_rectLeftMiddleArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_LeftMiddle);
m_rectLeftMiddleArea.setX(rectDrawInScenePos.left() - m_nBoundingRectWidthHalf);
m_rectLeftMiddleArea.setY(rectDrawInScenePos.top() + m_nBoundingRectHeightHalf);
m_rectLeftMiddleArea.setWidth(m_nBoundingRectWidth);
m_rectLeftMiddleArea.setHeight(rectDrawInScenePos.height() - m_nBoundingRectHeight);
//2 RectAreaBoundingType_LeftBottom
m_rectLeftBottomArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_LeftBottom);
m_rectLeftBottomArea.setX(rectDrawInScenePos.left() - m_nBoundingRectWidthHalf);
m_rectLeftBottomArea.setY(rectDrawInScenePos.bottom() - m_nBoundingRectHeightHalf);
m_rectLeftBottomArea.setWidth(m_nBoundingRectWidth);
m_rectLeftBottomArea.setHeight(m_nBoundingRectHeight);
//3 RectAreaBoundingType_MiddleBottom
m_rectMiddleBottomArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_MiddleBottom);
m_rectMiddleBottomArea.setX(rectDrawInScenePos.left() + m_nBoundingRectWidthHalf);
m_rectMiddleBottomArea.setY(rectDrawInScenePos.bottom() - m_nBoundingRectHeightHalf);
m_rectMiddleBottomArea.setWidth(rectDrawInScenePos.width() - m_nBoundingRectWidth);
m_rectMiddleBottomArea.setHeight(m_nBoundingRectHeight);
//4 RectAreaBoundingType_RightBottom
m_rectRightBottomArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_RightBottom);
m_rectRightBottomArea.setX(rectDrawInScenePos.right() - m_nBoundingRectWidthHalf);
m_rectRightBottomArea.setY(rectDrawInScenePos.bottom() - m_nBoundingRectHeightHalf);
m_rectRightBottomArea.setWidth(m_nBoundingRectWidth);
m_rectRightBottomArea.setHeight(m_nBoundingRectHeight);
//5 RectAreaBoundingType_RightMiddle
m_rectRightMiddleArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_RightMiddle);
m_rectRightMiddleArea.setX(rectDrawInScenePos.right() - m_nBoundingRectWidthHalf);
m_rectRightMiddleArea.setY(rectDrawInScenePos.top() + m_nBoundingRectHeightHalf);
m_rectRightMiddleArea.setWidth(m_nBoundingRectWidth);
m_rectRightMiddleArea.setHeight(rectDrawInScenePos.height() - m_nBoundingRectHeight);
//6 RectAreaBoundingType_RightTop
m_rectRightTopArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_RightTop);
m_rectRightTopArea.setX(rectDrawInScenePos.right() - m_nBoundingRectWidthHalf);
m_rectRightTopArea.setY(rectDrawInScenePos.top() - m_nBoundingRectHeightHalf);
m_rectRightTopArea.setWidth(m_nBoundingRectWidth);
m_rectRightTopArea.setHeight(m_nBoundingRectHeight);
//7 RectAreaBoundingType_MiddleTop
m_rectMiddleTopArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_MiddleTop);
m_rectMiddleTopArea.setX(rectDrawInScenePos.left() + m_nBoundingRectWidthHalf);
m_rectMiddleTopArea.setY(rectDrawInScenePos.top() - m_nBoundingRectHeightHalf);
m_rectMiddleTopArea.setWidth(rectDrawInScenePos.width() - m_nBoundingRectWidth);
m_rectMiddleTopArea.setHeight(m_nBoundingRectHeight);
//8 RectAreaBoundingType_LeftTop
m_rectLeftTopArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_LeftTop);
m_rectLeftTopArea.setX(rectDrawInScenePos.left() - m_nBoundingRectWidthHalf);
m_rectLeftTopArea.setY(rectDrawInScenePos.top() - m_nBoundingRectHeightHalf);
m_rectLeftTopArea.setWidth(m_nBoundingRectWidth);
m_rectLeftTopArea.setHeight(m_nBoundingRectHeight);
//9 RectAreaBoundingType_Inside
m_rectInsideArea.setRectAreaBoundingType(CRectAreaBounding::RectAreaBoundingType_InSide);
m_rectInsideArea.setX(rectDrawInScenePos.left() + m_nBoundingRectWidthHalf);
m_rectInsideArea.setY(rectDrawInScenePos.top() + m_nBoundingRectHeightHalf);
m_rectInsideArea.setWidth(rectDrawInScenePos.width() - m_nBoundingRectWidth);
m_rectInsideArea.setHeight(rectDrawInScenePos.height() - m_nBoundingRectHeight);
//10 CRectAreaBounding::RectAreaBoundingType_OutSide
}
void CRectAreaBoundingAreas::resetRectDraw( QPointF scenePos, QRectF rectDraw, qreal nBoundingRectWidth, qreal nBoundingRectHeight )
{
m_scenePos = scenePos;
m_rectDraw = rectDraw;
m_nBoundingRectWidth = nBoundingRectWidth;
m_nBoundingRectHeight = nBoundingRectHeight;
_ResetEightRectAreas();
}
CRectAreaBounding::RectAreaBoundingType CRectAreaBoundingAreas::checkInWhichArea( QPointF pointPos )
{
CRectAreaBounding::RectAreaBoundingType nRectAreaType = CRectAreaBounding::RectAreaBoundingType_OutSide;
//1
if (_CheckInRect(pointPos, m_rectLeftMiddleArea))
{
nRectAreaType = m_rectLeftMiddleArea.getRectAreaBoundingType();
return nRectAreaType;
}
//2
if (_CheckInRect(pointPos, m_rectLeftBottomArea))
{
nRectAreaType = m_rectLeftBottomArea.getRectAreaBoundingType();
return nRectAreaType;
}
//3
if (_CheckInRect(pointPos, m_rectMiddleBottomArea))
{
nRectAreaType = m_rectMiddleBottomArea.getRectAreaBoundingType();
return nRectAreaType;
}
//4
if (_CheckInRect(pointPos, m_rectRightBottomArea))
{
nRectAreaType = m_rectRightBottomArea.getRectAreaBoundingType();
return nRectAreaType;
}
//5
if (_CheckInRect(pointPos, m_rectRightMiddleArea))
{
nRectAreaType = m_rectRightMiddleArea.getRectAreaBoundingType();
return nRectAreaType;
}
//6
if (_CheckInRect(pointPos, m_rectRightTopArea))
{
nRectAreaType = m_rectRightTopArea.getRectAreaBoundingType();
return nRectAreaType;
}
//7
if (_CheckInRect(pointPos, m_rectMiddleTopArea))
{
nRectAreaType = m_rectMiddleTopArea.getRectAreaBoundingType();
return nRectAreaType;
}
//8
if (_CheckInRect(pointPos, m_rectLeftTopArea))
{
nRectAreaType = m_rectLeftTopArea.getRectAreaBoundingType();
return nRectAreaType;
}
//9
if (_CheckInRect(pointPos, m_rectInsideArea))
{
nRectAreaType = m_rectInsideArea.getRectAreaBoundingType();
return nRectAreaType;
}
return nRectAreaType;
}
bool CRectAreaBoundingAreas::_CheckInRect( QPointF pointPos, CRectAreaBounding nRectArea )
{
bool bCheckInRectRes = false;
if (
( (pointPos.x() >= nRectArea.left()) && (pointPos.x() <= nRectArea.right()) )
&& ( (pointPos.y() >= nRectArea.top()) && (pointPos.y() <= nRectArea.bottom()) )
)
{
bCheckInRectRes = true;
}
return bCheckInRectRes;
}
|
936b870783d9eedac3917561da12115a864ff2e3 | d1d031fbb0eedad95e9db006e87bbb47859fed1d | /cpp/pcl_projects/supervoxel_segmentation_playground/defines.hpp | 0ae70bec0416ac743c0b2f32ac62deb2a0f84427 | [] | no_license | markpp/computer_vision_samples | bcd402f941347d1282a3943aff1a1470b1712362 | c4775798dd640e3b071690cde1b1ad66b1e0c622 | refs/heads/master | 2020-12-24T10:55:56.030925 | 2017-10-10T08:35:45 | 2017-10-10T08:35:45 | 73,118,066 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 492 | hpp | defines.hpp | #pragma once
/*--------- INCLUDES------------*/
#include <stdio.h>
#include <iostream>
#include <pcl/point_types.h>
// Types
typedef pcl::PointXYZRGB PointT;
typedef pcl::PointXYZRGBA PointTA;
//typedef pcl::PointCloud<pcl::PointXYZRGBA> PointCloudT;
typedef pcl::PointNormal PointNT;
typedef pcl::PointXYZRGBL PointTL;
enum modes {PassThroughMode, smoothingMode, NormalsMode, CRGSMode, RGSMode, colorDepthMode, SVCMode, LCCPMode, CPCMode, NUMBER_OF_MODE};
#define numModes NUMBER_OF_MODE
|
e31598a44aeafb28a84438feb70733a170bf1b92 | d38e7ff696e0574a3e537527e7b703ca3f262ec1 | /simulateur_netlist/src/types/Expression.hpp | e6174013095ead66bd2f5c64cc0180120df0ebd5 | [] | no_license | TheLortex/sys-dig | ae7e1cef69535801623c3ee95ce0e9bbbe868a56 | b7b08bd98f4ed88e8edf531424bbe653d3f075dd | refs/heads/master | 2021-01-02T09:06:53.516894 | 2017-01-17T13:22:52 | 2017-01-17T13:22:52 | 99,146,027 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 954 | hpp | Expression.hpp | #ifndef EXPRESSION_HPP
#define EXPRESSION_HPP
#include <string>
#include <vector>
class Var;
class Expression
{
public:
Expression(Var *result);
virtual ~Expression();
//Renvoie un pointeur sur le résultat de l'opération
Var* get_result();
//Renvoie l'expression correspondante sous forme de fonction netlist (AND x y par exemple).
//Sert uniquement pour le debug
virtual std::string get_expression() const = 0;
//Renvoie les variables dont le calcul est nécessaire pour le calcul de _result
virtual std::vector<Var*> get_dependencies() const = 0;
//Renvoie les instructions cpp pour effectuer l'opération correspondante
virtual std::string get_instructions_beginning() const;
virtual std::string get_instructions_mid() const;
virtual std::string get_instructions_end() const;
protected:
//Pointeur sur la variable recevant le résultat de l'opération
Var *_result;
};
#endif
|
8fb7fc724ff4b819c758e1101478aa85d6c74d10 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5752104073297920_0/C++/ballonguy/main.cpp | fcfe2b9c4b8058942fee018b716b546fc7723637 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 990 | cpp | main.cpp | #include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<cstdio>
#include<queue>
#include<sstream>
#include<ctime>
using namespace std;
typedef long long Int;
#define FOR(i,a,b) for(int i=(a); i<=(b);++i)
#define mp make_pair
#define pb push_back
#define sz(s) (int)((s).size())
const int inf = 1000000000;
const int MOD = 1000000007;
const double pi = acos(-1.0);
int a[1111][1111];
bool used[1111];
string ans[1111];
int f[1111];
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int t;cin>>t;
FOR(i,1,t) {
int n;cin>>n;
FOR(j,1,n) cin>>a[i][j];
int mx=0;
FOR(j,1,n) if(a[i][j]==j) ++mx;
f[i]=mx;
}
vector<pair<int,int> >g;
FOR(i,1,t) g.pb(mp(f[i], i));
sort(g.begin(), g.end());
FOR(i,1,t) ans[i]="GOOD";
FOR(i,0,t/2-1) ans[g[i].second]="BAD";
FOR(i,1,t) cout<<"Case #"<<i<<": "<<ans[i]<<endl;
}
|
60ab4d18a86a3d8556240d344cffdaad5550892c | 30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a | /Codes/AC/2625.cpp | 26cc5760f60b4a8716069e1999ec3e7b0e3ae666 | [] | no_license | thegamer1907/Code_Analysis | 0a2bb97a9fb5faf01d983c223d9715eb419b7519 | 48079e399321b585efc8a2c6a84c25e2e7a22a61 | refs/heads/master | 2020-05-27T01:20:55.921937 | 2019-11-20T11:15:11 | 2019-11-20T11:15:11 | 188,403,594 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,358 | cpp | 2625.cpp | /// i am on fire
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <math.h>
using namespace std;
const int N=100005;
const int M=205;
typedef long long ll;
typedef pair<int,int>ii;
typedef pair<int,ii>node;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int a[10000001],arr[10000001];
bool is[10000000];
void sieve(){
is[0]=is[1]=1;
for(int i=2;i<10000001;i++){
if(is[i]==0){
for(int j=i;j<10000001;j+=i){
a[i]+=arr[j];
is[j]=1;
}
}
}
}
int main(){
// freopen("test.in","r",stdin);
//freopen("input.txt","w",stdout);
int n;
memset(arr,0,sizeof(arr));
scanf("%d",&n);
for(int i=0;i<n;i++){
int a;
scanf("%d",&a);
arr[a]++;
}
sieve();
for(int i=1;i<=10000000;i++)
a[i]+=a[i-1];
int m;
scanf("%d",&m);
while(m--){
int l,r;
scanf("%d%d",&l,&r);
l=min(l,10000000);
r=min(r,10000000);
printf("%d\n",a[r]-a[l-1]);
}
return 0;
}
|
d2a45a1aa6efbde92809c7c1a6739da6fbdfbc10 | f4e17640afef6d1b4d4a85f583a90e37f705dbd5 | /B2G/system/netd/TetherController.cpp | 2059cceb237b6cde5c05d02d062df14b711ed7b8 | [
"Apache-2.0"
] | permissive | wilebeast/FireFox-OS | d370362916f0c5a5408fa08285dbf4779f8b5eb3 | 43067f28711d78c429a1d6d58c77130f6899135f | refs/heads/master | 2016-09-05T22:06:54.838558 | 2013-09-03T13:49:21 | 2013-09-03T13:49:21 | 12,572,236 | 4 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 6,777 | cpp | TetherController.cpp | /*
* Copyright (C) 2008 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.
*/
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define LOG_TAG "TetherController"
#include <cutils/log.h>
#include <cutils/properties.h>
#include "TetherController.h"
TetherController::TetherController() {
mInterfaces = new InterfaceCollection();
mDnsForwarders = new NetAddressCollection();
mDaemonFd = -1;
mDaemonPid = 0;
}
TetherController::~TetherController() {
InterfaceCollection::iterator it;
for (it = mInterfaces->begin(); it != mInterfaces->end(); ++it) {
free(*it);
}
mInterfaces->clear();
mDnsForwarders->clear();
}
int TetherController::setIpFwdEnabled(bool enable) {
LOGD("Setting IP forward enable = %d", enable);
// In BP tools mode, do not disable IP forwarding
char bootmode[PROPERTY_VALUE_MAX] = {0};
property_get("ro.bootmode", bootmode, "unknown");
if ((enable == false) && (0 == strcmp("bp-tools", bootmode))) {
return 0;
}
int fd = open("/proc/sys/net/ipv4/ip_forward", O_WRONLY);
if (fd < 0) {
LOGE("Failed to open ip_forward (%s)", strerror(errno));
return -1;
}
if (write(fd, (enable ? "1" : "0"), 1) != 1) {
LOGE("Failed to write ip_forward (%s)", strerror(errno));
close(fd);
return -1;
}
close(fd);
return 0;
}
bool TetherController::getIpFwdEnabled() {
int fd = open("/proc/sys/net/ipv4/ip_forward", O_RDONLY);
if (fd < 0) {
LOGE("Failed to open ip_forward (%s)", strerror(errno));
return false;
}
char enabled;
if (read(fd, &enabled, 1) != 1) {
LOGE("Failed to read ip_forward (%s)", strerror(errno));
close(fd);
return -1;
}
close(fd);
return (enabled == '1' ? true : false);
}
int TetherController::startTethering(int num_addrs, struct in_addr* addrs) {
if (mDaemonPid != 0) {
LOGE("Tethering already started");
errno = EBUSY;
return -1;
}
LOGD("Starting tethering services");
pid_t pid;
int pipefd[2];
if (pipe(pipefd) < 0) {
LOGE("pipe failed (%s)", strerror(errno));
return -1;
}
/*
* TODO: Create a monitoring thread to handle and restart
* the daemon if it exits prematurely
*/
if ((pid = fork()) < 0) {
LOGE("fork failed (%s)", strerror(errno));
close(pipefd[0]);
close(pipefd[1]);
return -1;
}
if (!pid) {
close(pipefd[1]);
if (pipefd[0] != STDIN_FILENO) {
if (dup2(pipefd[0], STDIN_FILENO) != STDIN_FILENO) {
LOGE("dup2 failed (%s)", strerror(errno));
return -1;
}
close(pipefd[0]);
}
int num_processed_args = 4 + (num_addrs/2) + 1; // 1 null for termination
char **args = (char **)malloc(sizeof(char *) * num_processed_args);
args[num_processed_args - 1] = NULL;
args[0] = (char *)"/system/bin/dnsmasq";
args[1] = (char *)"--no-daemon";
args[2] = (char *)"--no-resolv";
args[3] = (char *)"--no-poll";
int nextArg = 4;
for (int addrIndex=0; addrIndex < num_addrs;) {
char *start = strdup(inet_ntoa(addrs[addrIndex++]));
char *end = strdup(inet_ntoa(addrs[addrIndex++]));
asprintf(&(args[nextArg++]),"--dhcp-range=%s,%s,1h", start, end);
}
if (execv(args[0], args)) {
LOGE("execl failed (%s)", strerror(errno));
}
LOGE("Should never get here!");
free(args);
return 0;
} else {
close(pipefd[0]);
mDaemonPid = pid;
mDaemonFd = pipefd[1];
LOGD("Tethering services running");
}
return 0;
}
int TetherController::stopTethering() {
if (mDaemonPid == 0) {
LOGE("Tethering already stopped");
return 0;
}
LOGD("Stopping tethering services");
kill(mDaemonPid, SIGTERM);
waitpid(mDaemonPid, NULL, 0);
mDaemonPid = 0;
close(mDaemonFd);
mDaemonFd = -1;
LOGD("Tethering services stopped");
return 0;
}
bool TetherController::isTetheringStarted() {
return (mDaemonPid == 0 ? false : true);
}
#define MAX_CMD_SIZE 1024
int TetherController::setDnsForwarders(char **servers, int numServers) {
int i;
char daemonCmd[MAX_CMD_SIZE];
strcpy(daemonCmd, "update_dns");
int cmdLen = strlen(daemonCmd);
mDnsForwarders->clear();
for (i = 0; i < numServers; i++) {
LOGD("setDnsForwarders(%d = '%s')", i, servers[i]);
struct in_addr a;
if (!inet_aton(servers[i], &a)) {
LOGE("Failed to parse DNS server '%s'", servers[i]);
mDnsForwarders->clear();
return -1;
}
cmdLen += strlen(servers[i]);
if (cmdLen + 2 >= MAX_CMD_SIZE) {
LOGD("Too many DNS servers listed");
break;
}
strcat(daemonCmd, ":");
strcat(daemonCmd, servers[i]);
mDnsForwarders->push_back(a);
}
if (mDaemonFd != -1) {
LOGD("Sending update msg to dnsmasq [%s]", daemonCmd);
if (write(mDaemonFd, daemonCmd, strlen(daemonCmd) +1) < 0) {
LOGE("Failed to send update command to dnsmasq (%s)", strerror(errno));
mDnsForwarders->clear();
return -1;
}
}
return 0;
}
NetAddressCollection *TetherController::getDnsForwarders() {
return mDnsForwarders;
}
int TetherController::tetherInterface(const char *interface) {
mInterfaces->push_back(strdup(interface));
return 0;
}
int TetherController::untetherInterface(const char *interface) {
InterfaceCollection::iterator it;
for (it = mInterfaces->begin(); it != mInterfaces->end(); ++it) {
if (!strcmp(interface, *it)) {
free(*it);
mInterfaces->erase(it);
return 0;
}
}
errno = ENOENT;
return -1;
}
InterfaceCollection *TetherController::getTetheredInterfaceList() {
return mInterfaces;
}
|
a52faaf65d98e7ec849ac606c97b0e190fc33835 | c6394dafd93a41a4ec11088aab3503bd8bffae23 | /GDV/Vec4.h | 37394a85210b87af60bf0cd63ff24470b0bcd98b | [] | no_license | tectronics/jfk-ck | 6019e0bda353f30479145d44de675b8729d90bb1 | 801e0ce262a7cc0b4c1790392b58908886fc8ca3 | refs/heads/master | 2018-01-11T15:16:45.747117 | 2012-06-20T20:22:12 | 2012-06-20T20:22:12 | 45,966,245 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 713 | h | Vec4.h | /*
* Vec4.h
*
* Created on: 07.05.2012
* Author: jan
*/
#ifndef VEC4_H_
#define VEC4_H_
#include <ostream>
class Vec4 {
private:
double x, y, z, w;
public:
Vec4(double x, double y, double z, double w):
x(x), y(y), z(z), w(w) {};
virtual ~Vec4();
// double setVec4(double x, double y, double z, double w);
double& operator[] (int index);
const double& operator[] (int index) const;
Vec4 operator+ (Vec4 const& v);
Vec4 operator- (Vec4 const& v);
double operator* (Vec4 const& v);
double norm();
};
Vec4 operator* (Vec4 const&, double a);
Vec4 operator* (double a, Vec4 const&);
std::ostream& operator<< (std::ostream& o, Vec4 const& v);
#endif
|
19cc3c45b9cbcdefd6ea0dce468b910886cbd990 | a054a6db2f7804bd18a951483ed638b4dd3009ef | /Casino game.cpp | a5ad2de48b806ae069b20272b865fe20be00dc12 | [
"MIT"
] | permissive | amanpratapsingh9/Cpp_Project-Casino_Game | 458416e5fd1d01a03d758e57e60cc78a270f53e3 | 22288f6fb504270724747a0ed0488238bb4d1e40 | refs/heads/main | 2023-07-09T11:16:53.798223 | 2021-08-16T15:56:42 | 2021-08-16T15:56:42 | 393,999,575 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,730 | cpp | Casino game.cpp | #include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
void drawLine(int n, char symbol);
void rules();
int main()
{
string playerName;
int amount;
int bettingAmount;
int guess;
int dice;
char choice;
srand(time(0));
drawLine(60, '_');
cout<<"\n\n\n\t\tCASINO GAME\n\n\n\n";
drawLine(60, '_');
cout<<"\n\nEnter Your Name: ";
getline(cin, playerName);
cout<<"\n\nEnter Deposit amount to play game: $";
cin>>amount;
do
{
system("cls");
rules();
cout<<"\n\nYour current balance is $ "<<amount<<"\n";
do
{
cout<<playerName<<", enter money to bet : $";
cin>>bettingAmount;
if(bettingAmount > amount)
cout<<"Your betting amount is more than your current balance\n"
<<"\nRe-enter data\n";
}
while(bettingAmount > amount);
do
{
cout<<"Guess your number to bet between 1 to 10 :";
cin>>guess;
if(guess <= 0 || guess > 10)
cout<<"Please check the number!! should be between 1 to 10\n"
<<"\nRe-enter data\n";
}
while (guess <=0 || guess>10);
dice = rand()%10 + 1;
if(dice == guess)
{
cout<<"\n\nGood Luck!! You won $ "<<bettingAmount * 10;
amount = amount + bettingAmount * 10;
}
else
{
cout<<"Bad luck this time!! You lost $ "<<bettingAmount<<"\n";
amount = amount - bettingAmount;
}
cout<<"\nThe winning number was : "<<dice<<"\n";
cout<<"\n"<<playerName<<", You have $ "<<amount<<"\n";
if(amount == 0)
{
cout<<"You have no money to play";
break;
}
cout<<"\n\n-->Do you want to play again(y/n)? ";
cin>>choice;
}
while(choice == 'Y' || choice == 'y');
cout<<"\n\n\n";
drawLine(70,'=');
cout<<"\n\nThanks for playing game. Your balance amount is $ "<<amount<<"\n\n";
drawLine(70, '=');
return 0;
}
void drawLine(int n, char symbol)
{
for(int i = 0; i<n; i++)
cout<<symbol;
cout<<"\n";
}
void rules()
{
system("cls");
cout<<"\n\n";
drawLine(80, '-');
cout<<"\nt1. Choose any number between 1 to 10\n";
cout<<"\nt2. If you win you will get 10 times the money you bet\n";
cout<<"nt3. Iff you bet on wrong number you will loose your betting amount\n\n";
drawLine(80,'-');
}
|
dff8efd48576f84c9e3bda098348dd59141d7ef5 | 5d83739af703fb400857cecc69aadaf02e07f8d1 | /Archive2/12/6a242a296d3fd5/main.cpp | a58fcc598abcb22dcee21bc7661b41bba856399f | [] | 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 | 833 | cpp | main.cpp | #include <map>
#include <iostream>
#include <string>
#include <boost/foreach.hpp>
#include <sstream>
#include <cstdarg>
enum JType {
JInt = 0,
JVoid = 1,
JString = 2,
JBool = 3
};
std::string JTypeToString(JType type)
{
switch (type)
{
case(JInt): return "I";
case(JVoid): return "V";
case(JString): return "Ljava/lang/String;";
case(JBool): return "Z";
default: return "";
}
return "";
}
std::string MakeSig(JType returnType, std::initializer_list<JType> args)
{
std::stringstream ss;
ss << "(";
for (auto arg : args)
{
ss << JTypeToString(arg);
}
ss << ")" << JTypeToString(returnType);
return ss.str();
}
int main()
{
std::cout << MakeSig(JInt, {JString, JBool}) << std::endl;
std::cout << MakeSig(JInt, {});
} |
2936abecba78fc580ce08250fc2cf9c4521d5473 | c7d835f18604a26d4c0147f9182d10937003a81f | /src/networkMessage.cpp | 136660870ce6ce025782fe931bb622e6e9ed94f3 | [] | no_license | lwehmeier/cs4103-node | 1309526bfbff4ddc1202d8cea1ea76a903b4ed56 | e3c5dc1596f1c0ab59ff86ef65f40086df4fd630 | refs/heads/master | 2020-03-08T22:52:09.463121 | 2018-04-23T19:51:23 | 2018-04-23T19:51:23 | 128,444,633 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 314 | cpp | networkMessage.cpp | //
// Created by lw96 on 06/04/18.
//
#include <memory>
#include <cstring>
#include "networkMessage.h"
std::shared_ptr<networkMessage> networkMessage::mk_shared_copy(const networkMessage* msg){
auto ret = std::make_shared<networkMessage>();
std::memcpy(&(ret->type),&(msg->type),MSG_SZ);
return ret;
} |
8f9ff0d8335676d8daba148569a094ade1041608 | 0b508c21b3a219f0c9f05e7457f34517fd31a119 | /UVA/11827/12128133_AC_0ms_0kB.cpp | 626c67796b8dd49eaa5530ffe190c9cf398c91c0 | [] | no_license | shiningflash/Online-Judge-Solutions | fa7402d37f8ca3238012d7cff76255dec3e9e2b0 | fc267f87b6c0551d5bdf41f2e160fce58b136ba9 | refs/heads/master | 2021-06-11T20:52:16.777025 | 2021-03-31T12:52:54 | 2021-03-31T12:52:54 | 164,604,423 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 730 | cpp | 12128133_AC_0ms_0kB.cpp | #include <bits/stdc++.h>
using namespace std;
int fnc(vector <int> n){
int len = n.size();
int sum = 0;
int g = 0;
for(int i = 0; i < len - 1; i++){
for(int j = i + 1; j < len; j++){
g = __gcd(n[i], n[j]);
sum = max(sum, g);
}
}
return sum;
}
int main()
{
int t, n = 0, sum, len;
string s;
scanf("%d", &t);
getline(cin, s); // dummy string
while(t--){
sum = n = 0;
getline(cin, s);
vector <int> v;
len = s.size();
for(int i = 0; i < len; i++){
if(s[i] != ' ') n = (n * 10) + (s[i] - '0');
else{
v.push_back(n);
n = 0;
}
}
if(s[len - 1] != ' ') v.push_back(n);
sum = fnc(v);
printf("%d\n", sum);
}
return 0;
} |
c4dd67d31bc0fec01f68931511393a921bd2f6d3 | febc8116dda5af52b5c395a4917a46a89fc551c9 | /sensors/test/body_led_rf_pwd/body_led_rf_pwd.ino | a336dbdba438bd91bcfdaa9a24ed0ab3b6ecf371 | [
"MIT"
] | permissive | goodspeed24e/2014iOT | 4461eb1ce8cb550b17b238a5ce9d9feb43791206 | 139f6e2131f8a94cb876328b5f733e3feef77707 | refs/heads/master | 2021-01-18T15:14:45.696781 | 2015-03-16T15:37:22 | 2015-03-16T15:44:38 | 32,333,359 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,276 | ino | body_led_rf_pwd.ino |
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
static int intrusion_pin = 4;
const unsigned long GasOffset = 10000;
const unsigned long FlameOffset = 20000;
const unsigned long IntrusionOffset = 30000;
unsigned long g_IntrusionResult = 0;
RF24 radio(9,10);
void setup_RF2401_2_RPI(void)
{
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
const int channelID = 110;
printf_begin();
printf("\n\rRF24/examples/pingpair/\n\r");
printf("ROLE: Pong back\n\r");
radio.begin();
radio.enableDynamicPayloads();
//radio.setRetries(15,15);
radio.setDataRate(RF24_1MBPS);
radio.setPALevel(RF24_PA_HIGH);
radio.setChannel(channelID);
radio.setCRCLength(RF24_CRC_16);
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1,pipes[0]);
radio.startListening();
radio.printDetails();
}
void RF2RPI(void)
{
if (radio.available())
{
unsigned long got_time;
bool done = false;
while(!done)
{
done = radio.read( &got_time, sizeof(unsigned long) );
printf("Got payload %lu...\n\r",got_time);
delay(20);
}
radio.stopListening();
if (g_IntrusionResult == IntrusionOffset)
{
g_IntrusionResult += 1;
printf("Sent Instrusion -- "); Serial.println(g_IntrusionResult,DEC); //Print the value to serial port
radio.write( &g_IntrusionResult, sizeof(unsigned long) );
g_IntrusionResult = 0;
}
else
{
radio.write( &got_time, sizeof(unsigned long) );
//printf("Sent response.\n\r");
}
radio.startListening();
}
}
void SleepTime(void)
{
delay(100); // idea 0.5 sec
}
void setup_intrusion()
{
pinMode(intrusion_pin, INPUT);
}
void Intrusion()
{
int val = digitalRead(intrusion_pin);
if (val == 1)
{
Serial.print("Flame Detected!!! ");
Serial.println(val,DEC); //Print the value to serial port
g_IntrusionResult = IntrusionOffset;
}
}
void setup(void)
{
Serial.begin(9600); //Set serial baud rate to 9600 bps
//setup_intrusion();
setup_RF2401_2_RPI();
}
void loop(void)
{
//Intrusion();
RF2RPI();
SleepTime();
}
|
03c7a705c95988ad2328348c55d8194cf408b2f0 | b30fa1ec4e5d21437ee69ad5cbebf218d67cb101 | /TGE/core/tgInput.h | cc104a51c6dc285bf98be7e90c65c170a511fbe3 | [] | no_license | DCubix/TGE | 7753e997a7f59c968f83f79eabae8a7a7caf2694 | aca3d9c4cddec779d6801ed1f3705be4d2b48b56 | refs/heads/master | 2021-01-22T20:40:15.950565 | 2017-04-06T17:19:34 | 2017-04-06T17:19:34 | 85,341,356 | 0 | 0 | null | 2017-03-24T02:04:32 | 2017-03-17T18:06:50 | C | UTF-8 | C++ | false | false | 999 | h | tgInput.h | #ifndef INPUT_H
#define INPUT_H
#include <unordered_map>
#include <SDL2/SDL.h>
typedef struct tgState {
bool pressed, released, down;
} tgState;
class tgInput {
public:
static void update();
static const tgState getKeyboardState(int key);
static const tgState getMouseState(int button);
static bool isKeyPressed(int key);
static bool isKeyReleased(int key);
static bool isKeyDown(int key);
static bool isMouseButtonPressed(int btn);
static bool isMouseButtonReleased(int btn);
static bool isMouseButtonDown(int btn);
static int getScrollOffset() { return m_scrollOffset; }
static int getMouseX() { return m_mouseX; }
static int getMouseY() { return m_mouseY; }
static bool isCloseRequested() { return m_closeRequested; }
private:
static SDL_Event m_sdlEvent;
static std::unordered_map<int, tgState> m_keyboard;
static std::unordered_map<int, tgState> m_mouse;
static int m_mouseX, m_mouseY;
static int m_scrollOffset;
static bool m_closeRequested;
};
#endif // INPUT_H
|
798ee336b67465a6400801a5116bfd84875ddee2 | 0fe9c0c7ac91fe08b032968726b8bbea36e2e0e6 | /Source/DynamicVoxelHierarchy/timer.h | 49ee56cc4efb6d3494039db32357adb5de6fb94b | [] | no_license | dougboudreau/Rambo3D | 3ef686c9d04cd0b1e3e9da0acbd061fdfc5822bf | 0a83a9a64731ed077b4775aeb1d6aa14c38d47f5 | refs/heads/master | 2021-01-15T22:46:53.330165 | 2013-04-07T15:42:19 | 2013-04-07T15:42:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 177 | h | timer.h | #ifndef TIMER_H
#define TIMER_H
#include <time.h>
class timer
{
time_t seconds;
public:
timer();
void setTime();
time_t timeElapsed();
};
#endif // TIMER_H
|
8ff061fe36cc2643a5113d1a2763fdbb875d8829 | 3622c3528c39aaed7b6e28f839d5baf9846b6a1b | /QuickData/QuickData.Validate/main.cpp | 0fd9ec25fe1a44f17d2622778732d33be4737edd | [] | no_license | tylercamp/UICColum | 4fc0bbfae81fc33ae2f6f82dd03b1e2c0d1f1546 | 41275bee353093fbbf9aff1606e43256d5f96e9a | refs/heads/master | 2020-04-16T17:43:35.882235 | 2016-10-03T18:27:46 | 2016-10-03T18:27:46 | 45,938,280 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,755 | cpp | main.cpp |
/*
Validates input data against normal deviations
*/
// Possibility - continuance check?
#include <iostream>
#include <ctime>
#include <Windows.h>
#include "../QuickData/MshReader.h"
#include "../QuickData/Workflows/ImportMshWorkflow.h"
using namespace concurrency::graphics;
struct MshSample
{
float_3 min, max, avg;
};
// Modified from GatherMeshBoundsWorkflow
void gather_point_bounds( gpu_vertex_array * pts, float_3 * out_min, float_3 * out_max )
{
using namespace concurrency::fast_math;
// TODO: Look into tile operations
const int target_size = 100;
auto & dev_pts = *pts;
auto base_extent = dev_pts.extent;
#define TILE_SIZE 256
array_view<float_3> mins( base_extent / TILE_SIZE + 1 );
mins.discard_data( );
array_view<float_3> maxs( base_extent / TILE_SIZE + 1 );
maxs.discard_data( );
// Repeat while size > target_size
int tris_per_tile = base_extent[0] / TILE_SIZE;
if( tris_per_tile > 0xFFFF )
{
throw "Mesh too large, tiling size must be increased for processing";
}
// FUTURE TODO: USE 2D TILE EXTENTS
parallel_for_each(
base_extent.tile<TILE_SIZE>( ).pad( ),
[dev_pts, mins, maxs]( tiled_index<TILE_SIZE> t_idx ) restrict( amp )
{
tile_static float_3 tile_ranges[TILE_SIZE];
if( t_idx.global[0] < dev_pts.extent[0] )
tile_ranges[t_idx.local[0]] = dev_pts[t_idx];
t_idx.barrier.wait( );
if( t_idx.local[0] == 0 )
{
float_3 min = tile_ranges[0], max = tile_ranges[0];
for( int i = 1; i < TILE_SIZE; i++ )
{
if( t_idx.global[0] + i >= dev_pts.extent[0] )
break;
float_3 & current = tile_ranges[i];
min.x = fminf( min.x, current.x );
min.y = fminf( min.y, current.y );
min.z = fminf( min.z, current.z );
max.x = fmaxf( max.x, current.x );
max.y = fmaxf( max.y, current.y );
max.z = fmaxf( max.z, current.z );
}
mins[t_idx.tile[0]] = min;
maxs[t_idx.tile[0]] = max;
}
} );
#undef TILE_SIZE
mins.synchronize( );
maxs.synchronize( );
float_3 min, max;
min = mins[0];
max = maxs[0];
for( int i = 0; i < mins.extent[0]; i++ )
{
float_3 current = mins[i];
min.x = fminf( min.x, current.x );
min.y = fminf( min.y, current.y );
min.z = fminf( min.z, current.z );
}
for( int i = 0; i < mins.extent[0]; i++ )
{
float_3 current = maxs[i];
max.x = fmaxf( max.x, current.x );
max.y = fmaxf( max.y, current.y );
max.z = fmaxf( max.z, current.z );
}
float_3 range = max - min;
// Extend working bounds to offset error
min -= range * 0.01f;
max += range * 0.01f;
*out_min = min;
*out_max = max;
}
MshSample generate_sample( const std::string & mshFile )
{
gpu_vertex_array * verts;
VolumeType type;
MshReader reader( mshFile );
std::vector<float_3> cpu_verts;
cpu_verts.reserve( reader.PointData[0].count );
for( std::size_t i = 0; i < reader.PointData[0].count; i++ )
{
auto pt = reader.PointData[0].data[i];
cpu_verts.push_back( float_3( pt.data[0], pt.data[1], pt.data[2] ) );
}
verts = new gpu_vertex_array( cpu_verts );
MshSample result;
float_3 min, max;
gather_point_bounds( verts, &min, &max );
result.min = min;
result.max = max;
result.avg = float_3(-1);
delete verts;
return result;
}
std::ostream& operator<<(std::ostream & strm, float_3 & f)
{
strm << f.x << ", " << f.y << ", " << f.z;
return strm;
}
#ifndef BUILD_DLL
int main( )
#else
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmd, int show )
#endif
{
auto file = "../QuickData/patients/KevinBestV7.GAMBIT.msh";
// todo - find proper values
MshSample reference;
MshSample sample = generate_sample( file );
std::cout << "min: " << sample.min << std::endl;
std::cout << "max: " << sample.max << std::endl;
std::getline( std::cin, std::string(), '\n' );
return 0;
} |
ada87b297df100a76db85320ff2831980b7ad948 | 3e6d721ce5ebd35bd152165cc575bac99168581f | /TrafficLightManager.h | 7a394c2d11ed99a4a00e741a588106af7dd89a2c | [] | no_license | qearly/traffic-simulation | 8f19e44a7e1a0a74cd61b2eaa7c4b7943e603130 | f87e95b12503de19c8477a5cd9357ab6255309a6 | refs/heads/master | 2020-05-02T12:00:24.186192 | 2017-08-06T20:34:44 | 2017-08-06T20:34:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,096 | h | TrafficLightManager.h | /*******************************************************************
* CS 307 Programming Assignment 1
* File: TrafficLightManager.h
* Author: Matt Stewart
* Desc: Traffic Light header file
* Date: 3-19-2017
*
* I attest that this program is entirely my own work
*******************************************************************/
#ifndef TrafficLightManager_H_
#define TrafficLightManager_H_
#include "Intersection.h"
#include <sys/types.h>
#include <sys/timeb.h>
#include <time.h>
enum LightState { GREEN, RED, YELLOW };
class Intersection;
class TrafficLightManager
{
private:
struct _timeb tStruct;
double thisTime;
double outputTime;
bool done;
int counter;
int counterEW;
Intersection *intersectInstance;
protected:
LightState NSState;
LightState EWState;
public:
void UpDate();
void NSLightUpDate();
void EWLightUpDate();
void PrintLight();
LightState getNSState();
LightState getEWState();
void setNSState(LightState state);
void setEWState(LightState state);
};
#endif
|
098c8851bd55ddea47a8e8f400c268bef5c2c8d2 | 7da813269f4d6ecfa8cdbce1a0a1560f98ac3897 | /lab02/src/http/HttpServerLogger.cpp | c4316df18992721606b9ada08e7744c4fc550160 | [] | no_license | Lasoloz/computer_networks_assignments | d65f5784ff96b3d33632caebc78db0fde3d0b858 | ac766a30a6a3cf7ee430744f8124c2ef9098e060 | refs/heads/master | 2021-01-25T13:34:47.174076 | 2018-06-18T13:24:44 | 2018-06-18T13:24:44 | 123,583,518 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 406 | cpp | HttpServerLogger.cpp | /*
* Heim László
* hlim1626
* 522-es csoport
* lab02
*/
#include <http/HttpServerLogger.hpp>
HttpServerLogger::HttpServerLogger(std::ostream *capturedStream) {
_out = capturedStream;
_owned = false;
}
// For future expansions:
// HttpServerLogger::HttpServerLogger(const std::string &filename) {
// }
HttpServerLogger::~HttpServerLogger() {
if (_owned) {
delete _out;
}
}
|
62caf0fad519d7ca4c11fe29199e28570d887051 | 92e7a96c196e563b70f78db321680d830af80a53 | /FastTrader/FastTraderPlugins/AlgoAutoOrder/GeneralParamDlg.h | 6787270758332311174a53c270625174b038b93b | [] | no_license | alexfordc/zq | 513723341132dd2b01f5ca3debb567b2fd31c033 | a0b05b7416fe68784e072da477e8c869097584e2 | refs/heads/master | 2021-05-25T14:19:37.317957 | 2018-02-24T05:57:23 | 2018-02-24T05:57:23 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,584 | h | GeneralParamDlg.h | #pragma once
#include "OptimizeSetupDlg.h"
#include "afxwin.h"
#include "afxcmn.h"
#include "BookOrderOperations.h"
#include "AlgoAutoData.h"
#include "kernelstruct.h"
#include "afxdtctl.h"
#include "WBButton.h"
#include "ColorTextStatic.h"
#include "NumericEdit.h"
// CGeneralParamDlg dialog
class CGeneralParamDlg : public CDialog //CBookOrderOperations//
{
DECLARE_DYNAMIC(CGeneralParamDlg)
public:
CGeneralParamDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CGeneralParamDlg();
// Dialog Data
enum { IDD = IDD_GENERALOPTIMIZE_DIALOG };
protected:
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
afx_msg void OnBnClickedBtnParamsetup();
afx_msg void OnDeltaposSpinPricelimit(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnDeltaposSpinMarketdegreed(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedBtnOk();
afx_msg void OnPaint();
afx_msg void OnCbnSelchangeComboOrdercount();
afx_msg void OnEnChangeEditInstrumentid();
afx_msg void OnBnClickedBtnCancel();
afx_msg void OnEnChangeEditMarketdegreed();
afx_msg void OnBnClickedCheckMultiPrice();
afx_msg void OnCbnCloseupComboBasicprice();
DECLARE_MESSAGE_MAP()
private:
CWBButton m_btnPlay;
CWBButton m_btnStop;
CWBButton m_btnOptSetup;
CEdit m_editInstrumentID;
CButton m_checkActiveOptimize;
CNumericEdit m_editInstrumentCount;
CNumericEdit m_editPriceLimit;
CSpinButtonCtrl m_spinPriceLimit;
CDateTimeCtrl m_editInstrumentStartTime;
CDateTimeCtrl m_editInstrumentEndTime;
CSliderCtrl m_slidMarketDegreed;
CEdit m_editMarketDegreed;
CSpinButtonCtrl m_spinMarketDegreed;
CComboBox m_comboOrderCount;
// CComboBox m_comboResetOrderCount;
CComboBox m_comboBasicPrice;
// CNumericEdit m_editSlidPriceSpread1;
CNumericEdit m_editSlidPriceSpread2;
CNumericEdit m_editSlidPriceSpread3;
CNumericEdit m_editSlidPriceSpread4;
CNumericEdit m_editSlidPriceSpread5;
// CComboBox m_comboRelateOrderCount;
// CNumericEdit m_editRelateOrderCount1;
CNumericEdit m_editRelateOrderCount2;
CNumericEdit m_editRelateOrderCount3;
CNumericEdit m_editRelateOrderCount4;
CNumericEdit m_editRelateOrderCount5;
CColorTextStatic m_staticMust1;
CColorTextStatic m_staticMust2;
CColorTextStatic m_staticMust3;
CColorTextStatic m_staticMust4;
CColorTextStatic m_staticTitleSellPrice;
CColorTextStatic m_staticTitleLatestPrice;
CColorTextStatic m_staticTitleBuyPrice;
CColorTextStatic m_staticTitleMiddlePrice;
CColorTextStatic m_staticTitleYesterdayPrice;
CColorTextStatic m_staticSellPrice;
CColorTextStatic m_staticLatestPrice;
CColorTextStatic m_staticBuyPrice;
CColorTextStatic m_staticMiddlePrice;
CColorTextStatic m_staticYesterdayPrice;
CComboBox m_comboActiveOptimize;
CComboBox m_comboIdleTime;
CComboBox m_comboExecuteTime;
CComboBox m_comboOverTimeTotal;
CNumericEdit m_editIdleTime;
CNumericEdit m_editExecuteTime;
CButton m_checkOverTimeRetryCount;
CNumericEdit m_editOverTimeRetryCount;
CButton m_checkOverTimeTotal;
CNumericEdit m_editOverTimeTotal;
CStatic m_staticSplit;
CToolTipCtrl m_toolTip;
public:
CNumericEdit m_editOrderCount;
// CNumericEdit m_editResetOrderCount;
CEdit m_editBasicPrice;
CComboBox m_comboBuysell;
CComboBox m_comboOpenclose;
CButton m_btnCheckMultiPrice;
CComboBox m_comboMultiPrice;
// CComboBox m_comboSlidPriceSpread;
void GetAlgoParamFromWnd(void);
void SetAlgoParamToWnd(BOOL bEditChanged = FALSE);
void SetInstrumentID(CString& strInstrumentID);
CString GetInstrumentID();
void UpdateDepthMarketContent(PlatformStru_DepthMarketData& depthMarketDate);
void UpdataOptCombo(int optIndex,BOOL bHaveItem);
void EnableCtrls(bool bEnable);
CWnd *m_pAlgoAutoOrderDlg;
private:
BOOL CheckParam(void);
void AddToolTip();//添加提示功能
void EnableMultiPriceControls(BOOL bEnable);
int m_nCurVolume;//现交易量 当前的减去上一次的
PlatformStru_DepthMarketData m_depthMarketDate;
COptimizeSetupDlg m_OptimizeSetupDlg;
bool m_bCloseupComboBasicprice;//是否选择完成
public:
BOOL m_bOkClicked;
afx_msg void OnCbnDropdownComboBasicprice();
afx_msg void OnCbnSelchangeComboBasicprice();
};
|
53fffb699460e5cbcc97fe555308881b65743912 | 21ef516c20961b9a29148258552cf1072c93715c | /lib/Galois/libgalois/include/galois/UnionFind.h | a2a3ba8590b1fe18130ca104bf6b536a16421f51 | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | rovinski/LSOracle | b6426c3e45129faa4c41e0f569c323d9d78a9643 | 0a3f08fb9925e45fa912799d0ee96513c02005e1 | refs/heads/master | 2023-06-08T05:35:28.164760 | 2021-07-02T00:46:41 | 2021-07-02T00:46:41 | 382,189,413 | 0 | 0 | MIT | 2021-07-02T00:33:59 | 2021-07-02T00:33:59 | null | UTF-8 | C++ | false | false | 3,832 | h | UnionFind.h | /*
* This file belongs to the Galois project, a C++ library for exploiting parallelism.
* The code is being released under the terms of the 3-Clause BSD License (a
* copy is located in LICENSE.txt at the top-level directory).
*
* Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
* UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
* SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
* PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
* DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
* RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
* shall University be liable for incidental, special, indirect, direct or
* consequential damages or loss of profits, interruption of business, or
* related expenses which may arise from use of Software or Documentation,
* including but not limited to those resulting from defects in Software and/or
* Documentation, or loss or inaccuracy of data of any kind.
*/
#ifndef GALOIS_UNIONFIND_H
#define GALOIS_UNIONFIND_H
#include <atomic>
namespace galois {
/**
* Intrusive union-find implementation. Users subclass this to get disjoint
* functionality for the subclass object.
*/
template <typename T>
class UnionFindNode {
T* findImpl() const {
if (isRep())
return m_component.load(std::memory_order_relaxed);
T* rep = m_component;
while (rep->m_component != rep) {
T* next = rep->m_component.load(std::memory_order_relaxed);
rep = next;
}
return rep;
}
protected:
std::atomic<T*> m_component;
UnionFindNode(T* s) : m_component(s) {}
public:
typedef UnionFindNode<T> SuperTy;
bool isRep() const {
return m_component.load(std::memory_order_relaxed) == this;
}
T* get() const { return m_component.load(std::memory_order_relaxed); }
const T* find() const { return findImpl(); }
T* find() { return findImpl(); }
//! Compress ONLY node to point directly to the root of the tree;
//! nodes on path are not altered
void compress() {
if (isRep()) return;
// my current component
T* rep = m_component;
// loop until rep == itself; i.e. get root
while (rep->m_component.load(std::memory_order_relaxed) != rep) {
// get next parent
T* next = rep->m_component.load(std::memory_order_relaxed);
rep = next;
}
// at this point rep is the parent: save as my parent
m_component.store(rep, std::memory_order_relaxed);
}
T* findAndCompress() {
// Basic outline of race in synchronous path compression is that two path
// compressions along two different paths to the root can create a cycle
// in the union-find tree. Prevent that from happening by compressing
// incrementally.
if (isRep())
return m_component.load(std::memory_order_relaxed);
T* rep = m_component;
T* prev = 0;
while (rep->m_component.load(std::memory_order_relaxed) != rep) {
T* next = rep->m_component.load(std::memory_order_relaxed);
if (prev && prev->m_component.load(std::memory_order_relaxed) == rep) {
prev->m_component.store(next, std::memory_order_relaxed);
}
prev = rep;
rep = next;
}
return rep;
}
//! Lock-free merge. Returns if merge was done.
T* merge(T* b) {
T* a = m_component.load(std::memory_order_relaxed);
while (true) {
a = a->findAndCompress();
b = b->findAndCompress();
if (a == b)
return 0;
// Avoid cycles by directing edges consistently
if (a < b)
std::swap(a, b);
if (a->m_component.compare_exchange_strong(a, b)) {
return b;
}
}
}
};
} // namespace galois
#endif
|
39e75dd7b37791b1a040dd54899767003b9c8b0f | 0bcd128368e2de959ca648960ffd7944067fcf27 | /docs/examples/Surface_readPixels_2.cpp | e4f4c813e4a7e20ceb905a88a269d307b626aabb | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | google/skia | ac6e39179cd33cf0c8a46d29c1a70bf78b4d74ee | bf6b239838d3eb56562fffd0856f4047867ae771 | refs/heads/main | 2023-08-31T21:03:04.620734 | 2023-08-31T18:24:15 | 2023-08-31T20:20:26 | 15,773,229 | 8,064 | 1,487 | BSD-3-Clause | 2023-09-11T13:42:07 | 2014-01-09T17:09:57 | C++ | UTF-8 | C++ | false | false | 1,085 | cpp | Surface_readPixels_2.cpp | // Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
// HASH=484d60dab5d846bf28c7a4d48892324a
REG_FIDDLE(Surface_readPixels_2, 256, 64, false, 0) {
void draw(SkCanvas* canvas) {
sk_sp<SkSurface> surf(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
auto surfCanvas = surf->getCanvas();
surfCanvas->clear(SK_ColorRED);
SkPaint paint;
surfCanvas->drawOval({4, 8, 58, 54}, paint);
SkImageInfo info = SkImageInfo::Make(64, 64, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<SkData> data(SkData::MakeUninitialized(info.minRowBytes() * info.height()));
sk_bzero(data->writable_data(), info.minRowBytes() * info.height());
for (int x : { 32, -32 } ) {
for (int y : { 32, -32 } ) {
surf->readPixels(info, data->writable_data(), info.minRowBytes(), x, y);
}
}
sk_sp<SkImage> image = SkImages::RasterFromData(info, data, info.minRowBytes());
canvas->drawImage(image, 0, 0);
}
} // END FIDDLE
|
d5f3d7a1a889363abd1ce03749e107665922b935 | fa73ad7a78238f8050d20f196805f729d0333919 | /src/Engine/Headers/EngineUtils.h | b62d3e317c91a54b31d5ff6531d0adfb88ac0e6c | [] | no_license | quiksilver4210/SelSQL | 3c9494fe331579d74dec07b7d1bf04595af12bb7 | f4593ee2ccea54b7ba0221ee74b8ad9af38b29ed | refs/heads/master | 2021-10-27T01:28:19.477068 | 2021-10-15T11:59:01 | 2021-10-15T11:59:01 | 210,825,355 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,099 | h | EngineUtils.h | //
// Created by quiks on 31.10.2019.
//
#ifndef SELSQL_ENGINEUTILS_H
#define SELSQL_ENGINEUTILS_H
#include <cstring>
#include <filesystem>
#include <fstream>
#include <memory>
#include "../../Utils/Headers/Constants.h"
#include "../../Utils/Structures/Data/DataBlock.h"
#include "../../Utils/Structures/Data/Table.h"
#ifdef __WIN32
#define DIR_SEPARATOR '\\'
#elif __linux
#define DIR_SEPARATOR '/'
#endif
typedef std::pair<char*, int> buffer_data;
typedef std::pair<int, int> Position;
typedef Constants C;
namespace fs = std::filesystem;
int GetFileSize(std::fstream* file);
buffer_data GetTableBuffer(Table* table);
buffer_data GetDataBlockBuffer(DataBlock* data_block);
std::shared_ptr<DataBlock> ReadDataBlockFromBuffer(char* data);
std::shared_ptr<Table> ReadTableFromBuffer(char* data);
void RestoreFromTemp(std::fstream* src, std::fstream* dist, int record_size);
std::string ConstructFileName(const std::string& table_name, size_t transaction_id);
std::string FindTempFile(const std::string& table_name, size_t transaction_id);
class FileNotOpened {};
#endif // SELSQL_ENGINEUTILS_H
|
e5e89811cfbd4c41e5de17e37dea3c855ef81058 | ebd908d2c0abb67da37a328263437761414f91dc | /examples/sdl/tiles/tiles.David/spriteFactory.h | a56ca592ff632291acc59540a3cef8d3672df99b | [] | no_license | wangyu-/4160assets-2018fall | 589b3d7df2f8e7538acc6f67743d6b9ef5ca3561 | ade414390d6bec41a4cf53d849a9a175b4bc4526 | refs/heads/master | 2021-10-10T09:06:07.834808 | 2019-01-08T19:54:23 | 2019-01-08T19:54:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 925 | h | spriteFactory.h | #include <string>
#include <vector>
#include <map>
#include "gamedata.h"
#include "sprite.h"
#include "multisprite.h"
#include "multisprite2way.h"
class SpriteFactory {
public:
static SpriteFactory& getInstance();
~SpriteFactory();
std::map<std::string, Drawable*>::iterator begin();
std::map<std::string, Drawable*>::iterator end();
Drawable* addSprite(const std::string&, const int type);
Drawable* getSprite(const std::string&);
Drawable* getCurrent();
Drawable* getNext();
static const int SPRITE;
static const int MULTI_SPRITE;
static const int MULTI_SPRITE_2WAY;
private:
Gamedata* gdata;
std::string currentSprite;
std::map<std::string, Drawable*> sprites;
SpriteFactory() :
gdata( Gamedata::getInstance() ), currentSprite(), sprites()
{}
SpriteFactory(const SpriteFactory&);
SpriteFactory& operator=(const SpriteFactory&);
};
|
3a36e05759b087061aaefcdf06fa79d9ef95a610 | b69e7274028b10bf5ea55483a5dba9ec818802d4 | /src/CharGlyph.cpp | aed903afd0cbf2cd22e500a09439e94b784a6d54 | [] | no_license | Borisoo/Lexi | 8ab31261939f261f69bdddd60d00d44564dcf912 | 88aa9aa21bc5769db2e4599e763555acf58a12ab | refs/heads/master | 2020-07-11T19:03:31.152122 | 2017-05-27T08:45:04 | 2017-05-27T08:45:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 600 | cpp | CharGlyph.cpp | #include "CharGlyph.h"
#include <iostream>
CharGlyph::CharGlyph(char _ch, int _w, int _h, int _x, int _y) : ch(_ch), width(_w), height(_h), x(_x), y(_y)
{
//ctor
}
CharGlyph::~CharGlyph()
{
//dtor
}
void CharGlyph::Draw(MainWindow *w)
{
w->DrawChar(ch, x, y);
}
void CharGlyph::Bounds(Rect & r)
{
r.x = x;
r.y = y;
r.width = width;
r.height = height;
}
bool CharGlyph::Intersects(const Point & p)
{
bool intersectsX = (x <= p.x) && (p.x <= (x + width - 1));
bool intersectsY = (y <= p.y) && (p.y <= (y + height - 1));
return intersectsX && intersectsY;
}
|
f3be5c650b55275ddb71b9a13b6aa226e04e12dd | e28ce358b784148849530bae0f206bbc6e9d47a1 | /Visitor.h | 057897f46d0a0c48ad280af067c9fb7f2c226a46 | [] | no_license | Dimassio/rocket3-compiler | 58bd80af2219c1f472ffa576c076fca57e82dd58 | fd653069346752402d56a099f8d0e6111778c333 | refs/heads/master | 2020-12-22T03:08:14.182420 | 2017-09-18T22:09:36 | 2017-09-18T22:09:36 | 42,932,558 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,001 | h | Visitor.h | #pragma once
class CProgram;
class CMainClass;
class CClassDecl;
class CClassDeclList;
class CExp;
class CExpMethodCall;
class CExpNewIntArray;
class CExpNewCustomType;
class CExpSquareBrackets;
class CExpRoundBrackets;
class CExpNot;
class CExpNumber;
class CExpId;
class CExpSingle;
class CExpLength;
class CExpBinOperation;
class CExpList;
class CFormalList;
class CFormalRest;
class CFormalRestList;
class CMethodDecl;
class CMethodDeclList;
class CStatement;
class CStatementList;
class CType;
class CVarDecl;
class CVarDeclList;
class CExpRest;
class CExpRestList;
class IVisitor {
public:
virtual ~IVisitor()
{
}
virtual void visit( const CProgram* ) = 0;
virtual void visit( const CMainClass* ) = 0;
virtual void visit( const CClassDecl* ) = 0;
virtual void visit( const CClassDeclList* ) = 0;
virtual void visit( const CExp* ) = 0;
virtual void visit( const CExpMethodCall* ) = 0;
virtual void visit( const CExpNewIntArray* ) = 0;
virtual void visit( const CExpNewCustomType* ) = 0;
virtual void visit( const CExpSquareBrackets* ) = 0;
virtual void visit( const CExpRoundBrackets* ) = 0;
virtual void visit( const CExpNot* ) = 0;
virtual void visit( const CExpNumber* ) = 0;
virtual void visit( const CExpId* ) = 0;
virtual void visit( const CExpSingle* ) = 0;
virtual void visit( const CExpBinOperation* ) = 0;
virtual void visit( const CExpLength* ) = 0;
virtual void visit( const CExpList* ) = 0;
virtual void visit( const CFormalList* ) = 0;
virtual void visit( const CFormalRest* ) = 0;
virtual void visit( const CFormalRestList* ) = 0;
virtual void visit( const CMethodDecl* ) = 0;
virtual void visit( const CMethodDeclList* ) = 0;
virtual void visit( const CStatement* ) = 0;
virtual void visit( const CStatementList* ) = 0;
virtual void visit( const CType* ) = 0;
virtual void visit( const CVarDecl* ) = 0;
virtual void visit( const CVarDeclList* ) = 0;
virtual void visit( const CExpRest* ) = 0;
virtual void visit( const CExpRestList* ) = 0;
}; |
3d5d286c22a5bd37d93406106745b0ad2b2809c8 | e58e1e29ccce9be9274eb6dc27bed9a3aa77d181 | /Contest/Contest D18/Contest 6/d_Bai17.cpp | 2a0c2487463298db18f7d62c31b25d658a6d6c01 | [] | no_license | nguyenkimdao1998/Contest_D19 | f6ab5b9e64a2e98d396fe09d3fd3002896aca693 | 33e6e2c4298aa1fc9121648daab60e0b5670a802 | refs/heads/main | 2023-03-21T04:42:26.284866 | 2021-03-15T16:43:53 | 2021-03-15T16:43:53 | 348,044,435 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 342 | cpp | d_Bai17.cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
long long n, m;
cin >> n >> m;
long long a[n], b[m];
for(int i=0; i<n; i++){
cin >> a[i];
}
for(long long i=0; i<m; i++){
cin >> b[i];
}
sort(a,a+n);
sort(b,b+m);
long long d;
d = a[n-1] * b[0];
cout << d << endl;
}
}
|
e3b1a5287ba174c6b794e528c589d8fd5b7e44a2 | 21c36a3a42260c3bd75c5d300e291953cb0f59f4 | /Exercices_Cpp/Exercices_Loop/Questão_3.cpp | 5c18db59e125088c3eac182f9df6ccddae2ed78a | [
"MIT"
] | permissive | ViniciusCRQ/Cpp | dcf55d7dc3d36f2d7b7101c7a4cb24fc3d966152 | af4c78481606deb65b67c5fb4eb8dd138582d755 | refs/heads/master | 2023-04-03T23:52:13.940310 | 2021-04-04T04:38:42 | 2021-04-04T04:38:42 | 260,776,468 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 581 | cpp | Questão_3.cpp | /*Question_3
Faça um algoritmo que leia 50 números. Informe quantos são positivos, negativos e
nulos. */
#include <iostream>
#include <conio.h>
int main (){
int c,t=0;
int negativo=0,neutro=0,positivo=0;
while ( t < 50 ){
t++;
printf ("Digite um número:");
scanf ("%d",&c);
if ( c < 0 ){
negativo = negativo + 1;
}
else if ( c > 0 ){
positivo = positivo + 1;
}
else {
neutro = neutro + 1;
}
}
printf ("No total, existem %d numeros negativos, %d zeros e %d numeros positivos",negativo,neutro,positivo);
getch();
return 0;
}
|
01fae5d6f74b0069024409d589dfc3eb888ac78d | bab64ebbd47cbba12b1ab1095ca9ccf8b0bd72f1 | /src/wifi.ino | a27f5d404fb6c113184759849918616498d003fa | [
"BSD-3-Clause"
] | permissive | avion23/esp-remote-logging | dd7da10ca0b68e2195f17fbf295985dd9b469898 | 83262d52e2f0a52889ec0811603c58aeed3c15a9 | refs/heads/master | 2021-01-20T06:30:15.190269 | 2017-08-30T11:47:06 | 2017-08-30T11:47:06 | 101,502,698 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,237 | ino | wifi.ino | /*
* wifi.cpp
*
* Created on: Apr 9, 2017
* Author: avion
*/
#include <ESP8266WiFi.h> //ESP8266 Core WiFi Library (you most likely already have this in your sketch)
#include <DNSServer.h> //Local DNS Server used for redirecting all requests to the configuration portal
#include <ESP8266WebServer.h> //Local WebServer used to serve the configuration portal
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
#include <Streaming.h>
const auto ledPin = 13; // ESP-12E
void wifiSetup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // inverted
static WiFiManager wifiManager;
wifiManager.setDebugOutput(true);
wifiManager.setAPCallback(
[](WiFiManager *myWiFiManager) {
Serial << "[Wifimanager] Entered config mode. IP: " << WiFi.softAPIP() << endl;
Serial << "[Wifimanager] my SSID: " << myWiFiManager->getConfigPortalSSID() << endl;
});
wifiManager.autoConnect();
digitalWrite(ledPin, HIGH); // inverted
// WiFi.mode(WIFI_STA);
// WiFi.begin(ssid, password);
// while (WiFi.waitForConnectResult() != WL_CONNECTED) {
// Serial.println("[OTA] Connection Failed! Rebooting...");
// delay(5000);
// ESP.restart();
// }
}
|
95f8462f21ccf4c15935cc6a4df2f973f378a9b1 | 0529d33a9015ee4a6a9ef0504d97171735d84a00 | /C++/Creating static member functions_Oops.cpp | 2681fd150a739515b79c6d9649fa6e2e523b30ae | [] | no_license | sravanthkorada/Hacktoberfest | 857b261812ab7999478520b93eaeb8023330e86d | 5e5e905d996807b7c89d5cbd731c7c30b37e00d8 | refs/heads/master | 2023-08-15T21:22:03.176634 | 2021-10-20T09:17:07 | 2021-10-20T09:17:07 | 419,257,925 | 0 | 0 | null | 2021-10-20T09:16:56 | 2021-10-20T09:04:13 | C++ | UTF-8 | C++ | false | false | 508 | cpp | Creating static member functions_Oops.cpp | //a static member fun is a fun or a member of a class with the static keyword
#include <bits/stdc++.h>
using namespace std;
class human{
public:
static int cnt;
human(){
cnt++;
}
static void display(){
cout << "counter" << " " << cnt << endl;
}
};
int human::cnt=0;
int main(){
cout << human::cnt << endl;
human anil;
human ahmed;
human akash;
human suman;
anil.display();
human::display();
cout << human::cnt << endl;
return 0;
}
|
09ddc0f9b60ec1e79d7c3f2ec6d831b7baf767d0 | 936c198ed2b84ca01c3ab45211d436caa863e3ea | /Scene/Raytracing.h | 20c8979069066fc514bd308d3b71745196334026 | [
"MIT"
] | permissive | MangioneAndrea/PathTracing | ca7f490cc868fb58795f0a8bb251d455b88ded60 | 9159a90020c4e9ee78ca6aff8b1266fc1d007aab | refs/heads/main | 2023-08-31T04:22:04.856717 | 2021-11-04T18:22:25 | 2021-11-04T18:22:25 | 416,052,383 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,749 | h | Raytracing.h | //
// Created by Andrea Mangione on 27/09/2021.
//
#include "Scene.h"
#include "glm/ext.hpp"
#include <cmath>
#define iterations 1
#define fRand() ((double) rand() / (RAND_MAX / 2) - 1)
#define p 0.4
class Raytracing : public Scene {
public:
Raytracing(int width, int height) {
srand((unsigned int) time(NULL));
this->width = width;
this->height = height;
objects = new std::vector<Sphere *>{
new Sphere{glm::vec3{-0.6, -0.7, -0.6}, 0.3, 0xDDDD11},
new Sphere{glm::vec3{0.3, -0.4, 0.3}, 0.6, 0xDDDDDD},
new Sphere{
glm::vec3{0, 0, 101},
100,
0x11ff11,
},
new Sphere{
glm::vec3{-101, 0, 0},
100,
0xff1111,
},
new Sphere{
glm::vec3{101, 0, 0},
100,
0x1111dd,
},
new Sphere{glm::vec3{0, 101, 0}, 100, 0xffffff, Color(0xffffff)},
new Sphere{
glm::vec3{0, -101, 0},
100,
0x888811,
}};
pixels = (uint32_t *) malloc(sizeof(uint32_t) * width * height);
aspectRatio = (double) width / (double) height;
eye = glm::dvec3(0, 0, -4);
lookAt = glm::dvec3(0, 0, 6);
}
void GetPixels() override {
glm::dvec3 up = glm::vec3(0, 1, 0);
auto direction = glm::normalize(lookAt - eye);
auto r = glm::normalize(glm::cross(up, direction));
auto u = glm::normalize(glm::cross(direction, r));
double fovScale = std::tan(fov / 2);
for (auto i = 0; i < width * height; i++) {
pixels[i] = 0;
auto x = (float) (i % width);
auto y = (float) std::floor(i / width);
// x,y from -1 to 1
x = (x / ((float) width / 2) - 1) * aspectRatio;
y = (y / ((float) height / 2) - 1);
auto tmp = r * glm::dvec1(fovScale * x);
auto tmp2 = u * (-fovScale * y);
glm::dvec3 d = direction + tmp + tmp2;// lookAt.no.plus(&tmp).plus(&tmp2);
if (i == 240050) {
i = i;
}
pixels[i] = ComputeColor(eye, d).ToInt();
}
}
glm::dvec3 *ClosestVectorFrom(glm::dvec3 o, glm::dvec3 d, Sphere *&closestObj) {
glm::dvec3 *closest = nullptr;
for (auto &elem : *objects) {
glm::dvec3 *intersection = elem->ClosestIntersection(o, d);
if (intersection != nullptr) {
double d1 = glm::distance(o, *intersection);
if (d1 == 0) {
delete intersection;
continue;
}
if (closest != nullptr) {
double d2 = glm::distance(o, *closest);
if (d1 < d2) {
delete closest;
closest = intersection;
closestObj = elem;
} else {
delete intersection;
}
} else {
closest = intersection;
closestObj = elem;
}
}
}
return closest;
}
Color ComputeColor(glm::dvec3 origin, glm::dvec3 direction) {
// auto r = Ray(origin, direction);
Sphere *closest = nullptr;
ClosestVectorFrom(origin, direction, closest);
if (closest == nullptr) {
return BLACK;
}
return closest->color;
}
}; |
faa6abc7d641f7bcf55acfd241ac097dcd8acd94 | 52b148a3d5b2d1c5285445df9fb1816dbf4f6248 | /bitmap_objects/image.h | 706f9d0e1b7af45a3e82cd15cbe1596eef75c314 | [] | no_license | quebin31/spaceship-cpp | fa7bcf063b80d8926142caef6cb9bfdbfed8a866 | 41f3a36edf6f2b0707e9490e861ab1b5878019fa | refs/heads/master | 2023-04-29T18:48:04.599314 | 2023-04-21T03:37:41 | 2023-04-21T03:37:41 | 74,414,776 | 0 | 0 | null | 2023-04-21T03:37:42 | 2016-11-21T23:23:44 | C++ | UTF-8 | C++ | false | false | 391 | h | image.h | //
// Created by kevin on 7/12/16.
//
#ifndef SPACESHIP2_IMAGE_H
#define SPACESHIP2_IMAGE_H
#include "bitmap.h"
class Image : public Bitmap
{
public:
Image(const char* file, const int nwidth, const int nheight);
bool check_colision_with(Bitmap *some) override;
void draw_bitmap(const int flags) override;
void reset_bitmap() override;
};
#endif //SPACESHIP2_IMAGE_H
|
abd41809698498e77de378e89353e96184403d56 | 28de82cabe22fb9330803357958cde891aad0246 | /uniqueNo.cpp | 3f78dd5da67d19fd6c6fa882b6ac2c90e528c2ae | [] | no_license | emily7901/practice_BitManipulation | ad969ab5cb15490996635f11963b986b4ffdb3e9 | d0c28fca003e75873b9b73952b15fd3eddffd365 | refs/heads/main | 2023-04-14T09:04:00.635809 | 2021-04-21T10:19:48 | 2021-04-21T10:19:48 | 360,124,756 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,596 | cpp | uniqueNo.cpp | #include<bits/stdc++.h>
#include<iostream>
using namespace std;
int unique(int arr[], int n)
{
int xorsum=0;
for(int i=0; i<n; i++)
{
xorsum= xorsum^arr[i];
}
return xorsum;
}
int setBit(int n,int pos){
return ((n & (1<<pos))!=0);
}
void unique2NO(int arr[], int n)
{
int xorsum=0;
for(int i=0; i<n; i++)
{
xorsum= xorsum^arr[i];
}
int tempxor= xorsum;
int setbit=0;
int pos=0;
while(setbit!=1)
{
setbit = xorsum & 1;
pos++;
xorsum = xorsum >>1;
}
int newxor=0;
for(int i=0; i<n; i++)
{
if(setBit(arr[i],pos-1))
{
newxor = newxor^arr[i];
}
}
cout<< newxor << endl;
int xor2= tempxor^newxor;
cout<< xor2 << endl;
}
bool getBit(int n, int pos)
{
return ((n & (1<<pos))!=0);
}
int SetBit(int n, int pos)
{
return (n |( 1<<pos));
}
int unique3NO(int arr[], int n)
{
int result=0;
for(int i=0; i<64; i++)
{
int sum=0;
for(int j=0; j<n; j++)
{
if(getBit(arr[j],i))
{
sum++;
}
}
if (sum%3!=0)
{
result = SetBit(result, i);
}
}
return result;
}
int main(){
// int arr[]= {1,2,5,7,5,1,2};
// cout<< unique(arr,7) <<endl;
// int arr[]= {1,2,4,5,5,4,2,1,6,8};
// unique2NO(arr,10);
int arr[]={ 1,2,3,4,1,2,3,1,2,3};
cout<< unique3NO(arr,10)<<endl;
return 0;
} |
fd2651d82bbf1f74a28e864aeb66ab252cf59005 | e4a50114db2830a5cc93a740eea0b016daa06932 | /801_1.cpp | c6a8d9c05c8781e78131c0638428ce4701342514 | [] | no_license | DPCEKY/myleet | abb516ad3d318e10e70443990647d936c65dd516 | 081703f0b6e6df9f4959225e8ba62e00fafa1d78 | refs/heads/master | 2021-06-18T14:15:45.519346 | 2019-08-01T18:40:44 | 2019-08-01T18:40:44 | 130,633,713 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 585 | cpp | 801_1.cpp | class Solution {
public:
int minSwap(vector<int>& A, vector<int>& B) {
int fix = 0, swap = 1;
for(int i = 1; i < A.size(); i++) {
if(A[i - 1] >= A[i] || B[i - 1] >= B[i]) {
// must swap right now
int tmp = swap;
swap = fix + 1;
fix = tmp;
}
else if(A[i - 1] >= B[i] || B[i - 1] >= A[i]) {
//must not swap
fix = fix;
swap = swap + 1;
}
else {
// free to go
int tmp = min(swap, fix);
fix = tmp;
swap = tmp + 1;
}
}
return min(swap, fix);
}
};
|
94647b84f96c4b538fd78a3ae805852737c0f845 | 502f16380f162d531d434af1ed71635d7a220841 | /https:/github.com/iahelr/The-Best-Project-Ever.git/TheBestProjectEver/PathFinder.cpp | ad7691412454eefb0b7984eed8ce681cf0e9af2e | [] | no_license | iahelr/The-Best-Project-Ever | 99c19be5302635cad41f1fffe2d8089c834a191e | f8ee3a43087a2bf69274d3031231a6a091ba306f | refs/heads/master | 2021-01-10T10:17:07.391428 | 2015-07-16T16:07:08 | 2015-07-16T16:07:08 | 36,739,775 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,259 | cpp | PathFinder.cpp | /*
* PathFinder.cpp
*
* Created on: Jun 6, 2015
* Author: colman
*/
#include "PathFinder.h"
PathFinder::PathFinder(Map map)
{
this->_map = map;
_costsMap.DefineSize(map._map._height, map._map._width);
}
//************
// Navigation methods
//************
vector<Location> PathFinder::findPath(Location source, Location destination)
{
// a graph object
MapHolderAStar graphObject(_map);
// Apply A*
_searcher.aStarSearch(graphObject, source, destination, _parentsMap, _costsMap);
// Get path from parents map
_resultPath = pathFromParentMap(source, destination);
// Copy the original map
IntMatrix mapWithPath;
mapWithPath.DefineSize(_map._map._height, _map._map._width);
for (int row = 0; row < _map._map._height; ++row)
{
for (int col = 0; col < _map._map._width; ++col)
{
mapWithPath._matrix[row][col] = _map._map._matrix[row][col];
}
}
// Add the path to the map
for (int i = 0; i < _resultPath.size(); i++)
{
Location location = _resultPath[i];
mapWithPath._matrix[location.getY()][location.getX()] = 5;
}
// Save the map with the path to PNG file
Map::WriteMapMatrixToPng(mapWithPath._matrix, mapWithPath._height, mapWithPath._width, "mapWithPath.png");
// Return the path
return (_resultPath);
}
|
d2c82aa8c8ff0730b75ae9655371e44fe46a02f5 | 6329da02d73f8f2cf11f71436379f4e1d1e92eea | /智能指针/SharedPtr.h | 432eeab22c9a7a9299de186aad503140d58439e4 | [] | no_license | XHfight/CPP-Language | 6eb5c35dfd1a8076db64a6c14561d328d9001bb1 | 5b037e8cc6d63c7a750c656e1a4eec54444e1980 | refs/heads/master | 2020-04-12T08:14:07.870427 | 2017-06-26T05:28:09 | 2017-06-26T05:28:09 | 61,987,227 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,148 | h | SharedPtr.h | #pragma once
#include <iostream>
using namespace std;
struct DefaultDel
{
void operator()(void *ptr)
{
delete ptr;
}
};
template <class T,class D = DefaultDel>
class SharedPtr
{
public:
SharedPtr(T* ptr = NULL, D& d = DefaultDel())
:_ptr(ptr)
,_PCount(new int(1))
,_del(d)
{}
SharedPtr(const SharedPtr<T>& shp)
:_ptr(shp._ptr)
,_PCount(shp._PCount)
,_del(shp._del)
{
++GetCount();
}
/*SharedPtr& operator=(const SharedPtr<T>& shp)
{
if(_ptr != shp._ptr)
{
Release();
_ptr = shp._ptr;
_PCount = shp._PCount;
++GetCount();
}
return *this;
}*/
//ÏÖ´ú°æÐ´·¨
SharedPtr& operator=(SharedPtr sp)
{
swap(_ptr,sp._ptr);
swap(_PCount,sp._PCount);
return *this;
}
~SharedPtr()
{
Release();
}
T& operator*()const
{
assert(_ptr);
return *_ptr;
}
T* operator->()const
{
assert(_ptr);
return _ptr;
}
T* Get()const
{
return _ptr;
}
private:
void Release()
{
if(--GetCount() == 0)
{
_del(_ptr); //·Âº¯Êý
_ptr = NULL;
delete _PCount;
_PCount = NULL;
}
}
int& GetCount()
{
return *(_PCount);
}
private:
T* _ptr;
int* _PCount;
D _del;
}; |
bb392ba57b7f1c58bd5fd39471213ed7e0ab291d | 948252ad882bce6d4e323eb3586f9a8b88ae24d2 | /src/124_Binary_Tree_Maximum_Path_Sum.cpp | 03c1f053ff1e2c15e902af8ee4b8220a97fb942d | [] | no_license | zjiash/leetcode | 65cfa1d2277b76018278288e5c7a4acb172a1607 | 4945a2b8402567b1080d4ac1d43ed918964e5227 | refs/heads/master | 2016-09-06T04:07:12.806508 | 2013-08-18T07:37:18 | 2013-08-18T07:37:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,163 | cpp | 124_Binary_Tree_Maximum_Path_Sum.cpp | /*
* =====================================================================================
*
* Filename: 124_Binary_Tree_Maximum_Path_Sum.cpp
*
* Description:
*
* Version: 1.0
* Created: 2013年05月18日 13时54分10秒
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:
*
* =====================================================================================
*/
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
int max;
public:
int getMax(int a, int b, int c){
int tmp = a > b ? a : b;
return tmp > c ? tmp : c;
}
int solve(TreeNode *root){
if(!root)
return 0;
int val = root->val;
int l = solve(root->left);
int r = solve(root->right);
int m = l > r ? l : r;
if(m <= 0)
max = max > val ? max : val;
else
max = getMax(max, m + val, l + r + val);
return getMax(val, val + l, val + r);
}
int maxPathSum(TreeNode *root) {
max = 0x80000000;
solve(root);
return max;
}
};
|
980e093271779f942a767d74722cb86e2ac35ca2 | 46cbb66a37a14b61ccd3c409cb99f38aac0db6b1 | /weldroidProject/include/base/singleton.h | 09dd8244384dbd540aec659e936e1b4d3f79b870 | [] | no_license | 295924038/robotics | 55855ef128ba026ba626e69eeda25013d71e0d60 | 9401e5dbcde51b37ef9a058ab236611cf13489c6 | refs/heads/master | 2020-07-05T02:40:37.635433 | 2019-08-22T09:56:50 | 2019-08-22T09:56:50 | 202,497,170 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,401 | h | singleton.h | #ifndef SINGLETON_H
#define SINGLETON_H
#include <memory>
#include <mutex>
/// 单例类模板[线程安全] [实例类的线程安全需要自己实现]
template <typename Device>
class Singleton
{
public:
/// 实例类的构造
/// @param args 支持任意形式的构造函数
template <typename ... Args>
Singleton( Args && ... args )
{
std::lock_guard<std::recursive_mutex> lck( _mtx ) ;
if ( nullptr == _device_ptr ) {
_device_ptr.reset(new Device(std::forward<Args>(args)...)) ;
}
}
/// &符号的重载
Device *operator&()
{
return _device_ptr.get() ;
}
/// 获取当前实例,获取前必须要确保构造已经执行
static std::shared_ptr<Device> get()
{
return _device_ptr ;
}
/// ->符号的重载
std::shared_ptr<Device> operator->()
{
return _device_ptr ;
}
/// 析构
~Singleton()
{
_device_ptr.reset() ;
}
private:
/// 全局线程同步锁,每一个类对应一个
static std::recursive_mutex _mtx ;
/// 指向实例对象的智能指针,每个实例对象一个
static std::shared_ptr<Device> _device_ptr ;
};
template <typename Device>
std::recursive_mutex Singleton<Device>::_mtx ;
template <typename Device>
std::shared_ptr<Device> Singleton<Device>::_device_ptr ;
#endif // SINGLETON_H
|
061d3ff7bc97ca6d8b2a1ff884fb446a2c1e8494 | ef315e2ab31d04ea931c73c61a041b2dbe85bbb8 | /11051_bi_coef_memo.cpp | 6a86df4326984cc3b84f733cd1d110eab89ec051 | [] | no_license | ParkYeoungJun/Algorithm | bc12203628af52d95e022a27070b1d72a13c5d4e | b8340c657125caed5a9924bac13e88ea11f8ea84 | refs/heads/master | 2021-01-19T20:40:53.009966 | 2018-11-30T14:12:56 | 2018-11-30T14:12:56 | 88,531,742 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 402 | cpp | 11051_bi_coef_memo.cpp | #include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
#define mod 10007
int dp[1002][1002];
int main()
{
int n=0, k=0;
scanf("%d %d", &n, &k);
dp[0][0] = 1;
dp[1][0] = 1;
dp[1][1] = 1;
for(int i = 2 ; i <= n ; ++i)
{
for(int j = 0 ; j <= k ; ++j)
{
dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
dp[i][j] %= mod;
}
}
printf("%d", dp[n][k]);
return 0;
}
|
7e2b5cd85f4a1b57b9909c3875fdc82f5ad5d00f | e8b57cf8f0d26aaa133a4fcbd65f41a0d16d09f2 | /test/test.cpp | 90fe1ccbcc9b8f04be29538311a08936aa7dcbca | [] | no_license | Prasheel24/TDD-G9-PID | d82264cfea2a04195ef8cf3665b1861f752f1ef0 | a9bb3160b497f30f4186102f321c38794cb22bdc | refs/heads/master | 2020-08-03T11:50:42.729730 | 2019-09-30T19:02:43 | 2019-09-30T19:02:43 | 211,742,471 | 0 | 7 | null | 2019-09-30T18:37:07 | 2019-09-30T00:04:12 | C++ | UTF-8 | C++ | false | false | 10,891 | cpp | test.cpp | ///*
// *
// * Copyright 2019 Prasheel Renkuntla
// *
// * @file test.cpp
// * @author Prasheel Renkuntla (Driver - Part 1)
// * Suyash Yeotikar (Navigator - Part 1)
// * @date 09/25/2019
// * @version 1.0
// *
// * @brief Test Driven Development - Part 1
// *
// * @section DESCRIPTION
// *
// * Test the functionality of the PID Controller
// *
// */
#include <gtest/gtest.h>
#include <cmath>
#include <memory>
#include "pid.hpp"
/**
* @brief Get KP Gain Negative
*
* Check -- the individual x,y,z values are Greater than 0
* take a negative vector
* Check -- It should not be able to set negative vector
* Check -- If negative, then it should contain last value
*
* @param none
* @return none
*/
TEST(getKpGainNeg, testgetKpGainNeg) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> kp = testObj.GetKpGain();
for (auto i : *kp) {
ASSERT_GE(i, 0);
}
std::shared_ptr<std::vector<double>> testNeg = std::make_shared<
std::vector<double>>(3, -1);
ASSERT_FALSE(testObj.SetKpGain(testNeg));
ASSERT_EQ((*testObj.GetKpGain())[0], (*kp)[0]);
ASSERT_EQ((*testObj.GetKpGain())[1], (*kp)[1]);
ASSERT_EQ((*testObj.GetKpGain())[2], (*kp)[2]);
}
/**
* @brief Get KP Gain Positive
*
* Check -- the individual x,y,z values are Greater than 0
* take a positive vector
* Check -- It should be able to set positive vector
* Check -- If positive, then it should contain new value
*
* @param none
* @return none
*/
TEST(getKpGainPos, testGetKpGainPos) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> kp = testObj.GetKpGain();
for (auto i : *kp) {
ASSERT_GE(i, 0);
}
std::shared_ptr<std::vector<double>> testPos = std::make_shared<
std::vector<double>>(3, 1);
ASSERT_TRUE(testObj.SetKpGain(testPos));
ASSERT_EQ((*testObj.GetKpGain())[0], (*testPos)[0]);
ASSERT_EQ((*testObj.GetKpGain())[1], (*testPos)[1]);
ASSERT_EQ((*testObj.GetKpGain())[2], (*testPos)[2]);
}
/**
* @brief Get Ki Gain Negative
*
* Check -- the individual x,y,z values are Greater than 0
* take a negative vector
* Check -- It should not be able to set negative vector
* Check -- If negative, then it should contain last value
*
* @param none
* @return none
*/
TEST(getKiGainNeg, testgetKiGainNeg) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> ki = testObj.GetKiGain();
for (auto i : *ki) {
ASSERT_GE(i, 0);
}
std::shared_ptr<std::vector<double>> testNeg = std::make_shared<
std::vector<double>>(3, -1);
ASSERT_FALSE(testObj.SetKiGain(testNeg));
ASSERT_EQ((*testObj.GetKiGain())[0], (*ki)[0]);
ASSERT_EQ((*testObj.GetKiGain())[1], (*ki)[1]);
ASSERT_EQ((*testObj.GetKiGain())[2], (*ki)[2]);
}
/**
* @brief Get Ki Gain Positive
*
* Check -- the individual x,y,z values are Greater than 0
* take a positive vector
* Check -- It should be able to set positive vector
* Check -- If positive, then it should contain new value
*
* @param none
* @return none
*/
TEST(getKiGainPos, testGetKiGainPos) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> ki = testObj.GetKiGain();
for (auto i : *ki) {
ASSERT_GE(i, 0);
}
std::shared_ptr<std::vector<double>> testPos = std::make_shared<
std::vector<double>>(3, 1);
ASSERT_TRUE(testObj.SetKiGain(testPos));
ASSERT_EQ((*testObj.GetKiGain())[0], (*testPos)[0]);
ASSERT_EQ((*testObj.GetKiGain())[1], (*testPos)[1]);
ASSERT_EQ((*testObj.GetKiGain())[2], (*testPos)[2]);
}
/**
* @brief Get Kd Gain Negative
*
* Check -- the individual x,y,z values are Greater than 0
* take a negative vector
* Check -- It should not be able to set negative vector
* Check -- If negative, then it should contain last value
*
* @param none
* @return none
*/
TEST(getKdGainNeg, testgetKdGainNeg) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> kd = testObj.GetKdGain();
for (auto i : *kd) {
ASSERT_GE(i, 0);
}
std::shared_ptr<std::vector<double>> testNeg = std::make_shared<
std::vector<double>>(3, -1);
ASSERT_FALSE(testObj.SetKdGain(testNeg));
ASSERT_EQ((*testObj.GetKdGain())[0], (*kd)[0]);
ASSERT_EQ((*testObj.GetKdGain())[1], (*kd)[1]);
ASSERT_EQ((*testObj.GetKdGain())[2], (*kd)[2]);
}
/**
* @brief Get Ki Gain Positive
*
* Check -- the individual x,y,z values are Greater than 0
* take a positive vector
* Check -- It should be able to set positive vector
* Check -- If positive, then it should contain new value
*
* @param none
* @return none
*/
TEST(getKdGainPos, testGetKdGainPos) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> kd = testObj.GetKdGain();
for (auto i : *kd) {
ASSERT_GE(i, 0);
}
std::shared_ptr<std::vector<double>> testPos = std::make_shared<
std::vector<double>>(3, 1);
ASSERT_TRUE(testObj.SetKdGain(testPos));
ASSERT_EQ((*testObj.GetKdGain())[0], (*testPos)[0]);
ASSERT_EQ((*testObj.GetKdGain())[1], (*testPos)[1]);
ASSERT_EQ((*testObj.GetKdGain())[2], (*testPos)[2]);
}
/**
* @brief Compute output velocity magnitude
*
* Check -- if output velocity magnitude is less than max limit
*
* @param none
* @return none
*/
TEST(computeOutput, testComputeOutput) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> comOut = testObj.ComputeOutput();
double sum = 0;
for (auto i : *comOut) {
sum += (i) * (i);
}
double newSum = sqrt(sum);
ASSERT_LE(newSum, testObj.GetMaxLimitVel());
}
/**
* @brief Compute actual velocity magnitude
*
* Check -- if actual velocity magnitude is less than max limit
*
* @param none
* @return none
*/
TEST(actualVelocity, testActualVelocity) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> actVel = testObj.GetActualVelocity();
double sum = 0;
for (auto i : *actVel) {
sum += (i) * (i);
}
double newSum = sqrt(sum);
ASSERT_LE(newSum, testObj.GetMaxLimitVel());
}
/**
* @brief Compute target set point velocity magnitude
*
* Check -- if target set point velocity magnitude is less than max limit
*
* @param none
* @return none
*/
TEST(targetSetPoint, testTargetSetPoint) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> tgtSetPoint =
testObj.GetTargetSetPoint();
double sum = 0;
for (auto i : *tgtSetPoint) {
sum += (i) * (i);
}
double newSum = sqrt(sum);
ASSERT_LE(newSum, testObj.GetMaxLimitVel());
}
/**
* @brief Set Actual Velocity
*
* Check -- if new velocity magnitude is less than max limit
*
* @param none
* @return none
*/
TEST(setActVelocity, testSetActVelocity) {
PIDController testObj;
std::shared_ptr<std::vector<double>> av =
std::make_shared<std::vector<double>>(3, 1.1);
double sum = 0;
for (auto i : *av) {
sum += (i) * (i);
}
double newSum = sqrt(sum);
ASSERT_LE(newSum, testObj.GetMaxLimitVel());
}
/**
* @brief Get Actual Velocity Vector
*
* Check -- magnitude of current vector is less than Max Limit
* take a positive vector
* Check -- it should be able to assign a positive vector
* Check -- if positive, it should contain the new value
*
* @param none
* @return none
*/
TEST(getActualVelPos, testgetActualVelPos) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> av = testObj.GetActualVelocity();
double sum = 0;
for (auto i : *av) {
sum += (i) * (i);
}
double newSum = sqrt(sum);
ASSERT_LE(newSum, testObj.GetMaxLimitVel());
std::shared_ptr<std::vector<double>> testPos = std::make_shared<
std::vector<double>>(3, 3);
ASSERT_TRUE(testObj.SetActualVelocity(testPos));
ASSERT_EQ((*testObj.GetActualVelocity())[0], (*testPos)[0]);
ASSERT_EQ((*testObj.GetActualVelocity())[1], (*testPos)[1]);
ASSERT_EQ((*testObj.GetActualVelocity())[2], (*testPos)[2]);
}
/**
* @brief Get Actual Velocity Positive Vector
*
* Check -- magnitude of current vector is less than Max Limit
* take a positive vector
* Check -- it should be able to assign a positive vector
* Check -- if positive, it should contain the new value
*
* @param none
* @return none
*/
TEST(getTgtSetPointPos, testGetTgtSetPointPos) {
PIDController testObj = PIDController();
std::shared_ptr<std::vector<double>> tpt = testObj.GetTargetSetPoint();
double sum = 0;
for (auto i : *tpt) {
sum += (i) * (i);
}
double newSum = sqrt(sum);
ASSERT_LE(newSum, testObj.GetMaxLimitVel());
std::shared_ptr<std::vector<double>> testPos = std::make_shared<
std::vector<double>>(3, 3);
ASSERT_TRUE(testObj.SetTargetSetPoint(testPos));
ASSERT_EQ((*testObj.GetTargetSetPoint())[0], (*testPos)[0]);
ASSERT_EQ((*testObj.GetTargetSetPoint())[1], (*testPos)[1]);
ASSERT_EQ((*testObj.GetTargetSetPoint())[2], (*testPos)[2]);
}
/**
* @brief Set Max Limit Range
*
* Check -- set the max limit value
* Check -- if max limit is Greater than 0
*
* @param none
* @return none
*/
TEST(setMaxLimitVel, testSetMaxLimitVel) {
PIDController testObj;
double mx = 10;
ASSERT_TRUE(testObj.SetMaxLimitVel(mx));
ASSERT_EQ(testObj.GetMaxLimitVel(), 10);
std::shared_ptr<std::vector<double>> testPos = std::make_shared<
std::vector<double>>(3, 10);
ASSERT_FALSE(testObj.SetActualVelocity(testPos));
std::shared_ptr<std::vector<double>> testPositive = std::make_shared<
std::vector<double>>(3, 10);
ASSERT_FALSE(testObj.SetTargetSetPoint(testPositive));
}
/**
* @brief Compute Output for one iteration
*
* take Kp, Ki, Kd, Actual Velocity, Target Set point
* Check -- set the corresponding values
* Check -- the output velocity from PID
*
* @param none
* @return none
*/
TEST(computePIDIteration, testcomputePIDIteration) {
PIDController testObj;
std::shared_ptr<std::vector<double>> testKp = std::make_shared<
std::vector<double>>(3, 0.1);
std::shared_ptr<std::vector<double>> testKi = std::make_shared<
std::vector<double>>(3, 0.1);
std::shared_ptr<std::vector<double>> testKd = std::make_shared<
std::vector<double>>(3, 0.1);
std::shared_ptr<std::vector<double>> testVel = std::make_shared<
std::vector<double>>(3, 0.5);
std::shared_ptr<std::vector<double>> testTPT = std::make_shared<
std::vector<double>>(3, 1);
ASSERT_TRUE(testObj.SetKpGain(testKp));
ASSERT_TRUE(testObj.SetKiGain(testKi));
ASSERT_TRUE(testObj.SetKdGain(testKd));
ASSERT_TRUE(testObj.SetActualVelocity(testVel));
ASSERT_TRUE(testObj.SetTargetSetPoint(testTPT));
std::shared_ptr<std::vector<double>> outVel;
outVel = testObj.ComputeOutput();
ASSERT_EQ(0.55, (*outVel)[0]);
ASSERT_EQ(0.55, (*outVel)[1]);
ASSERT_EQ(0.55, (*outVel)[2]);
}
|
75cbb02cf6c8f44a67c9c7333bc63c0ce58af199 | 7ffaa6055406dc31d1ad2b53d5b379f66486078a | /q-3-b.cpp | 592bd9f878e8c31b9a0215346395fbbfcd8cf401 | [] | no_license | tarun0409/ipsc-assignment-1 | abf8a258f93cd2fed461d913b5a05f68090ce35e | 0105862809f03db021f8e114f40b72ff2eaaacae | refs/heads/master | 2020-04-26T07:46:47.528199 | 2019-05-08T15:51:00 | 2019-05-08T15:51:00 | 173,403,751 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,431 | cpp | q-3-b.cpp | #include<iostream>
#include<cmath>
using namespace std;
double dot_vectors(double * a, double * b, int n)
{
double c = 0;
for(int i=0; i<n; i++)
{
c += a[i]*b[i];
}
return c;
}
double magnitude_vector(double * a, int n)
{
double m;
for(int i=0; i<n; i++)
{
m += (a[i]*a[i]);
}
m = sqrt(m);
return m;
}
double * scalar_vector_multiply(double scalar, double * vector, int n)
{
for(int i=0; i<n; i++)
{
vector[i] = vector[i]*scalar;
}
return vector;
}
double * subtract_vectors(double * a, double * b, int n)
{
double * diff = (double *)calloc(n,sizeof(double));
for(int i=0; i<n; i++)
{
diff[i] = a[i]-b[i];
}
return diff;
}
double ** transpose_matrix(double ** A, int m, int n)
{
double ** T = (double **)calloc(n,sizeof(double *));
for(int i=0; i<n; i++)
{
T[i] = (double *)calloc(m,sizeof(double));
for(int j=0; j<m; j++)
{
T[i][j] = A[j][i];
}
}
return T;
}
double ** matrix_multiply(double ** A, double ** B, int m1, int n1, int m2, int n2)
{
if(n1!=m2)
{
cout<<"\nDimensions of matrices "<<m1<<"x"<<n1<<" and "<<m2<<"x"<<n2<<" do not comply for multiplication";
exit(1);
}
double ** C = (double **)calloc(m1,sizeof(double *));
for(int i=0; i<m1; i++)
{
C[i] = (double *)calloc(n2,sizeof(double));
for(int j=0; j<n2; j++)
{
for(int k=0; k<n1; k++)
{
C[i][j] = C[i][j] + (A[i][k]*B[k][j]);
}
if((C[i][j]>0 && C[i][j]<0.00001) || (C[i][j]<0 && C[i][j]>-0.00001))
{
C[i][j] = 0;
}
}
}
return C;
}
double ** my_qr(double ** A, double ** b, int m, int n)
{
double ** Q = (double **)calloc(m,sizeof(double *));
for(int i=0; i<m; i++)
{
Q[i] = (double *)calloc(n,sizeof(double));
for(int j=0; j<n; j++)
{
Q[i][j] = A[i][j];
}
}
double ** x = (double **)calloc(m,sizeof(double *));
for(int i=0; i<m; i++)
{
x[i] = (double *)calloc(1,sizeof(double));
}
for(int j=1; j<n; j++)
{
double * curr_vector = (double *)calloc(m,sizeof(double));
for(int i=0; i<m; i++)
{
curr_vector[i] = A[i][j];
}
double * curr_diff =(double *)calloc(m,sizeof(double));
for(int i=0; i<m; i++)
{
curr_diff[i] = A[i][j];
}
for(int k=0; k<j; k++)
{
double * curr_basis = (double *)calloc(m,sizeof(double));
for(int i=0; i<m; i++)
{
curr_basis[i] = Q[i][k];
}
double dot1 = dot_vectors(curr_vector,curr_basis,m);
double dot2 = dot_vectors(curr_basis,curr_basis,m);
double scale = dot1/dot2;
curr_diff = subtract_vectors(curr_diff,scalar_vector_multiply(scale,curr_basis,m),m);
}
for(int i=0; i<m; i++)
{
Q[i][j] = curr_diff[i];
}
}
for(int j=0; j<n; j++)
{
double * vec = (double *)calloc(m,sizeof(double));
for(int i=0; i<m; i++)
{
vec[i] = Q[i][j];
}
double mag = magnitude_vector(vec,m);
for(int i=0; i<m; i++)
{
Q[i][j] = Q[i][j]/mag;
}
}
cout<<"\nQ matrix : \n";
for(int i=0; i<m; i++)
{
for(int j=0; j<n; j++)
{
cout<<Q[i][j]<<"\t";
}
cout<<endl;
}
double ** qt = transpose_matrix(Q,m,n);
double ** R = matrix_multiply(qt, A, n,m,m,n);
cout<<"\nR matrix is : \n";
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
{
cout<<R[i][j]<<"\t";
}
cout<<endl;
}
double ** y = matrix_multiply(qt,b, n,m,m,1);
for(int i=(n-1); i>=0; i--)
{
for(int j=(n-1); j>i; j--)
{
y[i][0] = y[i][0] - (R[i][j]*x[j][0]);
}
x[i][0] = y[i][0]/R[i][i];
}
return x;
}
int main()
{
int m,n;
cout<<"\nEnter the number of linear equations : ";
cin>>m;
cout<<"\nEnter the number of variables : ";
cin>>n;
cout<<"\nEnter the elements of the matrix A in row major order :";
double ** A = (double **)calloc(m,sizeof(double *));
double ** orth = (double **)calloc(m,sizeof(double *));
for(int i=0; i<m; i++)
{
A[i] = (double *)calloc(n,sizeof(double));
orth[i] = (double *)calloc(n,sizeof(double));
for(int j=0; j<n;j++)
{
cin>>A[i][j];
orth[i][j] = A[i][j];
}
}
cout<<"\nEnter the elements of b (RHS) : ";
double ** b = (double **)calloc(m,sizeof(double *));
for(int i=0; i<m; i++)
{
b[i] = (double *)calloc(1,sizeof(double));
cin>>b[i][0];
}
cout<<"\nThe A matrix is : \n";
for(int i=0; i<m; i++)
{
for(int j=0; j<n; j++)
{
cout<<A[i][j]<<"\t";
}
cout<<endl;
}
cout<<"\nb vector is : ";
for(int i=0; i<m; i++)
{
cout<<b[i][0]<<" ";
}
cout<<endl;
double ** x = my_qr(A,b,m,n);
cout<<"\nx vector is : ";
for(int i=0; i<m; i++)
{
cout<<x[i][0]<<" ";
}
cout<<endl;
return 0;
} |
f71fb63cea9b44049b0351bbd84094b234447148 | ae6afef817813f4d92d041bf135bf1a9e0948df3 | /include/cppurses/widget/widgets/blank_width.hpp | 962ac2d0eab6a587aa87b8a76664bb215894e591 | [
"MIT"
] | permissive | jktjkt/CPPurses | 1ea5429d24ddaf8ddb2e8f509445faa830c27373 | 652d702258db8fab55ae945f7bb38e0b7c29521b | refs/heads/master | 2020-03-29T23:58:42.332998 | 2018-09-19T17:48:08 | 2018-09-19T17:48:08 | 150,499,046 | 0 | 0 | MIT | 2018-09-26T22:51:29 | 2018-09-26T22:51:29 | null | UTF-8 | C++ | false | false | 394 | hpp | blank_width.hpp | #ifndef CPPURSES_WIDGET_WIDGETS_BLANK_WIDTH_HPP
#define CPPURSES_WIDGET_WIDGETS_BLANK_WIDTH_HPP
#include <cstddef>
#include <cppurses/widget/widget.hpp>
namespace cppurses {
/// Empty space Widget with fixed width.
class Blank_width : public Widget {
public:
explicit Blank_width(std::size_t width = 1);
};
} // namespace cppurses
#endif // CPPURSES_WIDGET_WIDGETS_BLANK_WIDTH_HPP
|
b72460819b009de3fad8b3a89c904b2f567838ba | 3cbbef3a0c82bc196d8b0fafdb6b72ae6bf48cc2 | /ch14 ex4.cpp | f917b5fd7383cb43549ed02c8d79d691858e09af | [] | no_license | Matrix4555/Study-Exercises | 9c12fdc0925d58f2773496e034a71b33d478d82b | e3960f5b7d82ce156ed86f9755d3a4e5b43381df | refs/heads/master | 2023-01-21T20:22:08.209474 | 2020-12-04T00:02:11 | 2020-12-04T00:02:11 | 298,464,040 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 307 | cpp | ch14 ex4.cpp | #include <iostream>
using namespace std;
template <typename T>
void swaps(T& aaa, T& bbb)
{
T temp = aaa;
aaa = bbb;
bbb = temp;
}
int main()
{
char a = 'Y';
char b = 'm';
cout << a << " and " << b << endl;
swaps(a, b);
cout << a << " and " << b << endl;
return 0;
} |
2a35c2f7eb84c780181e3842aba71b61059a37c1 | 4b0a5965c46d2bf82d191868b3aaed684b3404c4 | /NightEngine2/src/Core/Message/MessageObject.hpp | 7c837fb84d2a8d61e551b948e2f31ef4b47b3a8b | [
"MIT"
] | permissive | anu-prakash-dev/NightEngine2 | e5522ceb091b67f4d74128608a3471c48c6539a6 | 14004b48d1708736373010a3fe47d05d876e0baa | refs/heads/master | 2023-02-04T23:50:55.704056 | 2020-12-02T04:47:37 | 2020-12-02T04:47:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,638 | hpp | MessageObject.hpp | /*!
@file MessageObject.hpp
@author Rittikorn Tangtrongchit
@brief Contain the Interface of MessageObject
*/
#pragma once
//! @brief Macros for quick message declaration
#define MSG_GENERATE_METHOD_DECL() \
virtual void SendMessageTo(IMessageHandler& handler) const override;
//! @brief Macros for quick message definition in .cpp
#define MSG_GENERATE_METHOD_DEF(TYPE) \
void TYPE ::SendMessageTo(IMessageHandler & handler) const \
{ \
handler.HandleMessage(*this); \
}
//! @brief Macros for quick message definition in .cpp
#define MSG_GENERATE_METHOD_DEF_HPP(TYPE) \
virtual void SendMessageTo(IMessageHandler & handler) const \
{ \
handler.HandleMessage(*this); \
}
namespace NightEngine
{
//Forward declaration
class IMessageHandler;
enum class MessageType : unsigned;
//! @brief MessageObject base class with virtual method for double dispatch
struct MessageObject
{
//! @brief Default payload data
union Payload
{
void* m_pointer;
int m_int;
unsigned m_unsigned;
long m_long;
float m_float;
double m_double;
bool m_bool;
const char* m_chars;
};
//! @brief Constructor for setting MessageType enum
MessageObject(MessageType msgType) : m_msgType(msgType), m_payload() {}
//! @brief For sending message directly to handler
virtual void SendMessageTo(IMessageHandler&) const = 0;
//**************************************************
// Public Members
//**************************************************
MessageType m_msgType;
Payload m_payload;
};
} // Message
|
9800c44e3e8707a82cf6d73360910afcddb51d0b | 3ca3a32d7e752e5deb85724365227977b6f3d6be | /tests/test.cpp | 7b47aa207aa6f89312e8e84f7ab8035c26d7b2ef | [] | no_license | gala377/Engeneer | 0af7c81ad7a6089edf8daead0fcd2bafb02c8732 | 7087a379d3db285df6a8952b61151cdd6e960856 | refs/heads/master | 2020-04-11T14:12:47.639343 | 2019-05-31T20:44:22 | 2019-05-31T20:44:22 | 161,845,894 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 196 | cpp | test.cpp | //
// Created by igor on 30.09.18.
//
#define BOOST_TEST_MODULE All_Tests
#include <boost/test/unit_test.hpp>
#include "parser/tests.cpp"
#include "lexer/tests.cpp"
#include "visitor/tests.cpp" |
0a7e82a0a33c5476129ca0388e750c2858360516 | a97e71c60d4006f8e0ca0b92da0a8adb7eb706cf | /main.cpp | 34033589130fd041cbd946f5dc20a2db94896db5 | [] | no_license | XxVadimxX/SidorovLab15kursNGTU | 46233860cceebe2b980fce4dcd7cf81e66e803a1 | 1706b5e09a27e8fdc0e77a5d70ecfed5e8809f4b | refs/heads/master | 2023-07-18T16:48:12.161266 | 2021-09-14T18:18:31 | 2021-09-14T18:18:31 | 406,097,915 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 132 | cpp | main.cpp | #include "procapp.h"
int main()
{
ProcApp app;
app.procConfig.coeff = 2;
int ret = procAppRun(app);
return ret;
}
|
6c9ebaf61f1342356e05e1bc210d8aeace168c7c | 009cca46aed9599d633441b044987ae78b60685a | /include/QweakSimCerenkovDetector_PMTSD.hh | 20eb19fad9c9bfd5ab4ac3a204519a9ace6a42f9 | [] | no_license | cipriangal/QweakG4DD | 0de40f6c2693021db44916e03d8d55703aa37387 | 5c8f55be4ba0ec3a3898a40c4e1ff8eb42c550ad | refs/heads/master | 2021-01-23T10:29:53.163237 | 2018-06-25T19:03:24 | 2018-06-25T19:03:24 | 29,534,503 | 0 | 4 | null | 2017-03-27T21:06:14 | 2015-01-20T14:45:37 | C++ | UTF-8 | C++ | false | false | 1,357 | hh | QweakSimCerenkovDetector_PMTSD.hh | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef QweakSimCerenkovDetector_PMTSD_h
#define QweakSimCerenkovDetector_PMTSD_h
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// user includes
#include "QweakSimSensitiveDetectorDeclaration.hh"
#include "QweakSimCerenkovDetector_PMTHit.hh"
// user classes
class QweakSimTrajectory;
class QweakSimUserInformation;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class QweakSimCerenkovDetector_PMTSD : public G4VSensitiveDetector
{
public:
QweakSimCerenkovDetector_PMTSD(G4String name, QweakSimUserInformation *myUserInfo);
~QweakSimCerenkovDetector_PMTSD();
void Initialize(G4HCofThisEvent* HCE);
G4bool ProcessHits(G4Step* /*aStep*/,G4TouchableHistory* /*ROhist*/){
// ProcessHits_constStep(aStep, ROhist);
return true;
};
G4bool ProcessHits_constStep(const G4Step* aStep,G4TouchableHistory* ROhist);
void EndOfEvent(G4HCofThisEvent* HCE);
QweakSimTrajectory* GetParentTrajectory(G4int parentID);
private:
QweakSimUserInformation *myUserInfo;
QweakSimCerenkovDetector_PMTHitsCollection* CerenkovDetector_PMTHitsCollection;
G4int CerenkovDetectorPMT_CollectionID;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
|
e5a12cba8679a815f77e1aa588ed4498319e4f0e | cfeac52f970e8901871bd02d9acb7de66b9fb6b4 | /generated/src/aws-cpp-sdk-marketplace-entitlement/include/aws/marketplace-entitlement/model/Entitlement.h | 96a26cdbc3fe2a9b5c608afec00d09495c751f3c | [
"Apache-2.0",
"MIT",
"JSON"
] | permissive | aws/aws-sdk-cpp | aff116ddf9ca2b41e45c47dba1c2b7754935c585 | 9a7606a6c98e13c759032c2e920c7c64a6a35264 | refs/heads/main | 2023-08-25T11:16:55.982089 | 2023-08-24T18:14:53 | 2023-08-24T18:14:53 | 35,440,404 | 1,681 | 1,133 | Apache-2.0 | 2023-09-12T15:59:33 | 2015-05-11T17:57:32 | null | UTF-8 | C++ | false | false | 14,110 | h | Entitlement.h | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/marketplace-entitlement/MarketplaceEntitlementService_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/marketplace-entitlement/model/EntitlementValue.h>
#include <aws/core/utils/DateTime.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace MarketplaceEntitlementService
{
namespace Model
{
/**
* <p>An entitlement represents capacity in a product owned by the customer. For
* example, a customer might own some number of users or seats in an SaaS
* application or some amount of data capacity in a multi-tenant
* database.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/entitlement.marketplace-2017-01-11/Entitlement">AWS
* API Reference</a></p>
*/
class Entitlement
{
public:
AWS_MARKETPLACEENTITLEMENTSERVICE_API Entitlement();
AWS_MARKETPLACEENTITLEMENTSERVICE_API Entitlement(Aws::Utils::Json::JsonView jsonValue);
AWS_MARKETPLACEENTITLEMENTSERVICE_API Entitlement& operator=(Aws::Utils::Json::JsonView jsonValue);
AWS_MARKETPLACEENTITLEMENTSERVICE_API Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p>The product code for which the given entitlement applies. Product codes are
* provided by AWS Marketplace when the product listing is created.</p>
*/
inline const Aws::String& GetProductCode() const{ return m_productCode; }
/**
* <p>The product code for which the given entitlement applies. Product codes are
* provided by AWS Marketplace when the product listing is created.</p>
*/
inline bool ProductCodeHasBeenSet() const { return m_productCodeHasBeenSet; }
/**
* <p>The product code for which the given entitlement applies. Product codes are
* provided by AWS Marketplace when the product listing is created.</p>
*/
inline void SetProductCode(const Aws::String& value) { m_productCodeHasBeenSet = true; m_productCode = value; }
/**
* <p>The product code for which the given entitlement applies. Product codes are
* provided by AWS Marketplace when the product listing is created.</p>
*/
inline void SetProductCode(Aws::String&& value) { m_productCodeHasBeenSet = true; m_productCode = std::move(value); }
/**
* <p>The product code for which the given entitlement applies. Product codes are
* provided by AWS Marketplace when the product listing is created.</p>
*/
inline void SetProductCode(const char* value) { m_productCodeHasBeenSet = true; m_productCode.assign(value); }
/**
* <p>The product code for which the given entitlement applies. Product codes are
* provided by AWS Marketplace when the product listing is created.</p>
*/
inline Entitlement& WithProductCode(const Aws::String& value) { SetProductCode(value); return *this;}
/**
* <p>The product code for which the given entitlement applies. Product codes are
* provided by AWS Marketplace when the product listing is created.</p>
*/
inline Entitlement& WithProductCode(Aws::String&& value) { SetProductCode(std::move(value)); return *this;}
/**
* <p>The product code for which the given entitlement applies. Product codes are
* provided by AWS Marketplace when the product listing is created.</p>
*/
inline Entitlement& WithProductCode(const char* value) { SetProductCode(value); return *this;}
/**
* <p>The dimension for which the given entitlement applies. Dimensions represent
* categories of capacity in a product and are specified when the product is listed
* in AWS Marketplace.</p>
*/
inline const Aws::String& GetDimension() const{ return m_dimension; }
/**
* <p>The dimension for which the given entitlement applies. Dimensions represent
* categories of capacity in a product and are specified when the product is listed
* in AWS Marketplace.</p>
*/
inline bool DimensionHasBeenSet() const { return m_dimensionHasBeenSet; }
/**
* <p>The dimension for which the given entitlement applies. Dimensions represent
* categories of capacity in a product and are specified when the product is listed
* in AWS Marketplace.</p>
*/
inline void SetDimension(const Aws::String& value) { m_dimensionHasBeenSet = true; m_dimension = value; }
/**
* <p>The dimension for which the given entitlement applies. Dimensions represent
* categories of capacity in a product and are specified when the product is listed
* in AWS Marketplace.</p>
*/
inline void SetDimension(Aws::String&& value) { m_dimensionHasBeenSet = true; m_dimension = std::move(value); }
/**
* <p>The dimension for which the given entitlement applies. Dimensions represent
* categories of capacity in a product and are specified when the product is listed
* in AWS Marketplace.</p>
*/
inline void SetDimension(const char* value) { m_dimensionHasBeenSet = true; m_dimension.assign(value); }
/**
* <p>The dimension for which the given entitlement applies. Dimensions represent
* categories of capacity in a product and are specified when the product is listed
* in AWS Marketplace.</p>
*/
inline Entitlement& WithDimension(const Aws::String& value) { SetDimension(value); return *this;}
/**
* <p>The dimension for which the given entitlement applies. Dimensions represent
* categories of capacity in a product and are specified when the product is listed
* in AWS Marketplace.</p>
*/
inline Entitlement& WithDimension(Aws::String&& value) { SetDimension(std::move(value)); return *this;}
/**
* <p>The dimension for which the given entitlement applies. Dimensions represent
* categories of capacity in a product and are specified when the product is listed
* in AWS Marketplace.</p>
*/
inline Entitlement& WithDimension(const char* value) { SetDimension(value); return *this;}
/**
* <p>The customer identifier is a handle to each unique customer in an
* application. Customer identifiers are obtained through the ResolveCustomer
* operation in AWS Marketplace Metering Service.</p>
*/
inline const Aws::String& GetCustomerIdentifier() const{ return m_customerIdentifier; }
/**
* <p>The customer identifier is a handle to each unique customer in an
* application. Customer identifiers are obtained through the ResolveCustomer
* operation in AWS Marketplace Metering Service.</p>
*/
inline bool CustomerIdentifierHasBeenSet() const { return m_customerIdentifierHasBeenSet; }
/**
* <p>The customer identifier is a handle to each unique customer in an
* application. Customer identifiers are obtained through the ResolveCustomer
* operation in AWS Marketplace Metering Service.</p>
*/
inline void SetCustomerIdentifier(const Aws::String& value) { m_customerIdentifierHasBeenSet = true; m_customerIdentifier = value; }
/**
* <p>The customer identifier is a handle to each unique customer in an
* application. Customer identifiers are obtained through the ResolveCustomer
* operation in AWS Marketplace Metering Service.</p>
*/
inline void SetCustomerIdentifier(Aws::String&& value) { m_customerIdentifierHasBeenSet = true; m_customerIdentifier = std::move(value); }
/**
* <p>The customer identifier is a handle to each unique customer in an
* application. Customer identifiers are obtained through the ResolveCustomer
* operation in AWS Marketplace Metering Service.</p>
*/
inline void SetCustomerIdentifier(const char* value) { m_customerIdentifierHasBeenSet = true; m_customerIdentifier.assign(value); }
/**
* <p>The customer identifier is a handle to each unique customer in an
* application. Customer identifiers are obtained through the ResolveCustomer
* operation in AWS Marketplace Metering Service.</p>
*/
inline Entitlement& WithCustomerIdentifier(const Aws::String& value) { SetCustomerIdentifier(value); return *this;}
/**
* <p>The customer identifier is a handle to each unique customer in an
* application. Customer identifiers are obtained through the ResolveCustomer
* operation in AWS Marketplace Metering Service.</p>
*/
inline Entitlement& WithCustomerIdentifier(Aws::String&& value) { SetCustomerIdentifier(std::move(value)); return *this;}
/**
* <p>The customer identifier is a handle to each unique customer in an
* application. Customer identifiers are obtained through the ResolveCustomer
* operation in AWS Marketplace Metering Service.</p>
*/
inline Entitlement& WithCustomerIdentifier(const char* value) { SetCustomerIdentifier(value); return *this;}
/**
* <p>The EntitlementValue represents the amount of capacity that the customer is
* entitled to for the product.</p>
*/
inline const EntitlementValue& GetValue() const{ return m_value; }
/**
* <p>The EntitlementValue represents the amount of capacity that the customer is
* entitled to for the product.</p>
*/
inline bool ValueHasBeenSet() const { return m_valueHasBeenSet; }
/**
* <p>The EntitlementValue represents the amount of capacity that the customer is
* entitled to for the product.</p>
*/
inline void SetValue(const EntitlementValue& value) { m_valueHasBeenSet = true; m_value = value; }
/**
* <p>The EntitlementValue represents the amount of capacity that the customer is
* entitled to for the product.</p>
*/
inline void SetValue(EntitlementValue&& value) { m_valueHasBeenSet = true; m_value = std::move(value); }
/**
* <p>The EntitlementValue represents the amount of capacity that the customer is
* entitled to for the product.</p>
*/
inline Entitlement& WithValue(const EntitlementValue& value) { SetValue(value); return *this;}
/**
* <p>The EntitlementValue represents the amount of capacity that the customer is
* entitled to for the product.</p>
*/
inline Entitlement& WithValue(EntitlementValue&& value) { SetValue(std::move(value)); return *this;}
/**
* <p>The expiration date represents the minimum date through which this
* entitlement is expected to remain valid. For contractual products listed on AWS
* Marketplace, the expiration date is the date at which the customer will renew or
* cancel their contract. Customers who are opting to renew their contract will
* still have entitlements with an expiration date.</p>
*/
inline const Aws::Utils::DateTime& GetExpirationDate() const{ return m_expirationDate; }
/**
* <p>The expiration date represents the minimum date through which this
* entitlement is expected to remain valid. For contractual products listed on AWS
* Marketplace, the expiration date is the date at which the customer will renew or
* cancel their contract. Customers who are opting to renew their contract will
* still have entitlements with an expiration date.</p>
*/
inline bool ExpirationDateHasBeenSet() const { return m_expirationDateHasBeenSet; }
/**
* <p>The expiration date represents the minimum date through which this
* entitlement is expected to remain valid. For contractual products listed on AWS
* Marketplace, the expiration date is the date at which the customer will renew or
* cancel their contract. Customers who are opting to renew their contract will
* still have entitlements with an expiration date.</p>
*/
inline void SetExpirationDate(const Aws::Utils::DateTime& value) { m_expirationDateHasBeenSet = true; m_expirationDate = value; }
/**
* <p>The expiration date represents the minimum date through which this
* entitlement is expected to remain valid. For contractual products listed on AWS
* Marketplace, the expiration date is the date at which the customer will renew or
* cancel their contract. Customers who are opting to renew their contract will
* still have entitlements with an expiration date.</p>
*/
inline void SetExpirationDate(Aws::Utils::DateTime&& value) { m_expirationDateHasBeenSet = true; m_expirationDate = std::move(value); }
/**
* <p>The expiration date represents the minimum date through which this
* entitlement is expected to remain valid. For contractual products listed on AWS
* Marketplace, the expiration date is the date at which the customer will renew or
* cancel their contract. Customers who are opting to renew their contract will
* still have entitlements with an expiration date.</p>
*/
inline Entitlement& WithExpirationDate(const Aws::Utils::DateTime& value) { SetExpirationDate(value); return *this;}
/**
* <p>The expiration date represents the minimum date through which this
* entitlement is expected to remain valid. For contractual products listed on AWS
* Marketplace, the expiration date is the date at which the customer will renew or
* cancel their contract. Customers who are opting to renew their contract will
* still have entitlements with an expiration date.</p>
*/
inline Entitlement& WithExpirationDate(Aws::Utils::DateTime&& value) { SetExpirationDate(std::move(value)); return *this;}
private:
Aws::String m_productCode;
bool m_productCodeHasBeenSet = false;
Aws::String m_dimension;
bool m_dimensionHasBeenSet = false;
Aws::String m_customerIdentifier;
bool m_customerIdentifierHasBeenSet = false;
EntitlementValue m_value;
bool m_valueHasBeenSet = false;
Aws::Utils::DateTime m_expirationDate;
bool m_expirationDateHasBeenSet = false;
};
} // namespace Model
} // namespace MarketplaceEntitlementService
} // namespace Aws
|
f479e8606eedbfbff2d9f2e96197f466ebe20b6f | 86e3a1fe6dcbae60c2b371300f4d467ee0b3ed36 | /Enrutador.cpp | b99fcd5a10f0f93b2b4f3b2368bde737049936b0 | [] | no_license | MiguelGil1/lab_4 | 4a00837ce02027ef6cde71bd6f84b65c1651b5d5 | 7a4755da36fc7e1e4e937880789fc03c415def4f | refs/heads/master | 2023-07-30T10:19:49.333361 | 2021-09-21T01:48:55 | 2021-09-21T01:48:55 | 400,853,421 | 0 | 0 | null | 2021-09-21T01:48:56 | 2021-08-28T17:38:01 | C++ | UTF-8 | C++ | false | false | 2,119 | cpp | Enrutador.cpp | #include "Enrutador.h"
Enrutador::Enrutador(string _enrutadorSalida){
//Constructor, se aggrega a si mismo como un enrtudatoy su ruta es cero
_nombre = _enrutadorSalida;
Caracteristicas enrutador;
enrutador.costoDirecto = 0;
enrutador.costo = 0;
enrutador.ruta = _enrutadorSalida;
_enrutador[_enrutadorSalida].push_back(enrutador);
//Se le hace pushback al vector de enrutadores
}
void Enrutador::calcularMejorRuta(map<string, int> _rutas){
//Se calcula la mejor ruta
string rutaMenor = "";
for(auto parRutas = _rutas.begin(); parRutas != _rutas.end(); parRutas++){//Se recorre el contenedor _rutas
if(parRutas->first[0] == _nombre[0]){//Se evalua si el primer enrutador en la ruta es el nombre del objeto
for(auto par = _enrutador.begin(); par != _enrutador.end(); par++){
rutaMenor = parRutas->first;
int cantCaracteres = rutaMenor.length();
if(rutaMenor[cantCaracteres-1] == par->first[0]){//Se evalua si el final de la ruta es el enrutador de llegada
for(auto enru = begin(par->second); enru != end(par->second); enru++){
if(enru->costo == 0){//Si el cosot es cero, se agrega la ruta como ruta menor
enru->ruta = rutaMenor;
enru->costo = parRutas->second;
}else if(enru->costo > parRutas->second){//Si la ruta actual es menor a la ruta que se tiene, se realiza el cambio
enru->ruta = rutaMenor;
enru->costo = parRutas->second;
}
}
}
}
}
}
}
//METODOS SETTER Y GETTER DE LOS ATRIBUTOS PRIVADOS
string Enrutador::Getnombre() const{
return _nombre;
}
void Enrutador::setNombre(const string &nombre){
_nombre = nombre;
}
map<string, list<Caracteristicas> > Enrutador::Getenrutador() const{
return _enrutador;
}
void Enrutador::setEnrutador(const map<string, list<Caracteristicas> > &enrutador){
_enrutador = enrutador;
}
|
59e40a7360b66b8e8c48ddd27d82a05e1e24ff36 | 050c8a810d34fe125aecae582f9adfd0625356c6 | /roboti1/main.cpp | 6b9e647b0e0874c54c319f3b49b38cf556c731f1 | [] | no_license | georgerapeanu/c-sources | adff7a268121ae8c314e846726267109ba1c62e6 | af95d3ce726325dcd18b3d94fe99969006b8e138 | refs/heads/master | 2022-12-24T22:57:39.526205 | 2022-12-21T16:05:01 | 2022-12-21T16:05:01 | 144,864,608 | 11 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,906 | cpp | main.cpp | #include <cstdio>
#include <fstream>
#include <queue>
using namespace std;
FILE *f=fopen("roboti1.in","r");
FILE *g=fopen("roboti1.out","w");
struct{bool E;int x,y,relx,rely;} V[55];
int M[2][55][55];
int i;
int p,q;
int n,m,nr,maxim,j,x,y;
char C[55][55];
char c;
int F[55][55];
typedef pair<int,int> data;
queue <data> Q;
int main()
{
fscanf(f,"%d %d\n%d",&p,&q,&n);
for(i=1;i<=n;i++)
{
fscanf(f,"%d %d %c",&V[i].x,&V[i].y,&c);
if(c=='N')
V[i]={1,V[i].x,V[i].y,-1,0};
else if(c=='E')
V[i]={1,V[i].x,V[i].y,0,1};
else if(c=='S')
V[i]={1,V[i].x,V[i].y,1,0};
else
V[i]={1,V[i].x,V[i].y,0,-1};
F[V[i].x][V[i].y]=1;
}
nr=n;
fscanf(f,"%d\n",&m);
for(i=1;i<=n;i++)
fgets(C[i]+1,55,f);
for(j=1;j<=m;j++)
{
for(i=1;i<=n;i++)
{
if(V[i].E)
{
if(C[i][j]=='F')
{
V[i].x+=V[i].relx;
V[i].y+=V[i].rely;
if(M[j%2][V[i].x][V[i].y]==0)
{
M[j%2][V[i].x][V[i].y]=i;
}
else
{
V[i].E=0;
V[M[j%2][V[i].x][V[i].y]].E=0;
Q.push(make_pair(V[i].x,V[i].y));
}
M[(j+1)%2][V[i].x-V[i].relx][V[i].y-V[i].rely]=0;
F[V[i].x][V[i].y]++;
if((1>V[i].x||p<V[i].x)||(1>V[i].y||q<V[i].y)){M[j%2][V[i].x][V[i].y]=0;V[i].E=0;};
}
else if(C[i][j]=='L')
{
if(V[i].relx==-1&&V[i].rely==0)
V[i]={V[i].E,V[i].x,V[i].y,0,-1};
else if(V[i].relx==0&&V[i].rely==-1)
V[i]={V[i].E,V[i].x,V[i].y,1,0};
else if(V[i].relx==1&&V[i].rely==0)
V[i]={V[i].E,V[i].x,V[i].y,0,1};
else if(V[i].relx==0&&V[i].rely==1)
V[i]={V[i].E,V[i].x,V[i].y,-1,0};
if(M[j%2][V[i].x][V[i].y]!=0)
{
V[i].E=0;
V[M[j%2][V[i].x][V[i].y]].E=0;
Q.push(make_pair(V[i].x,V[i].y));
}
else
M[j%2][V[i].x][V[i].y]=i;
M[(j+1)%2][V[i].x][V[i].y]=0;
}
else
{
if(V[i].relx==-1&&V[i].rely==0)
V[i]={V[i].E,V[i].x,V[i].y,0,1};
else if(V[i].relx==0&&V[i].rely==-1)
V[i]={V[i].E,V[i].x,V[i].y,-1,0};
else if(V[i].relx==1&&V[i].rely==0)
V[i]={V[i].E,V[i].x,V[i].y,0,-1};
else if(V[i].relx==0&&V[i].rely==1)
V[i]={V[i].E,V[i].x,V[i].y,1,0};
if(M[j%2][V[i].x][V[i].y]!=0)
{
V[i].E=0;
V[M[j%2][V[i].x][V[i].y]].E=0;
Q.push(make_pair(V[i].x,V[i].y));
}
else
M[j%2][V[i].x][V[i].y]=i;
M[(j+1)%2][V[i].x][V[i].y]=0;
}
}
}
while(!Q.empty())
{M[j%2][(Q.front()).first][(Q.front()).second]=0;Q.pop();}
}
nr=0;
for(i=1;i<=n;i++)
nr+=V[i].E;
fprintf(g,"%d\n",nr);
for(i=1;i<=p;i++)
{
for(j=1;j<=q;j++)
{
if(F[i][j]>maxim)
{
maxim=F[i][j];
x=i;
y=j;
}
}
}
fprintf(g,"%d %d %d",x,y,maxim);
fclose(f);
fclose(g);
return 0;
}
|
b04705522d59f84c2d7c642cc74086409548b11c | f0c6aad028552f1b40ee5861283590aef9872d1a | /test/event_handler_test.cc | 66b061f9714c6176420914465081a69dcd7350bf | [
"MIT"
] | permissive | flandr/what-the-event | 577f02abd92446b27f14fbccee76f8f79958392b | 2707c3f564310a65ce563dcfa5d6c24ddd2eff20 | refs/heads/master | 2020-04-15T16:12:57.116136 | 2015-08-20T18:36:06 | 2015-08-20T18:36:06 | 30,946,745 | 0 | 0 | null | 2015-08-20T18:36:06 | 2015-02-18T01:14:40 | C++ | UTF-8 | C++ | false | false | 2,766 | cc | event_handler_test.cc | /*
* Copyright © 2015 Nathan Rosenblum <flander@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "event_base_test.h"
#include "wte/event_handler.h"
#include "wte/porting.h"
namespace wte {
class EventHandlerTest : public EventBaseTest {
public:
class TestEventHandler final : public EventHandler {
public:
explicit TestEventHandler(int fd) : EventHandler(fd),
last_event(What::NONE) { }
~TestEventHandler() {
unregister();
}
void ready(What event) NOEXCEPT override {
last_event = event;
}
What last_event;
};
};
TEST_F(EventHandlerTest, WriteEventsPostImmediately) {
TestEventHandler handler(fds[0]);
base->registerHandler(&handler, What::WRITE);
ASSERT_EQ(What::NONE, handler.last_event);
// Loop once
base->loop(EventBase::LoopMode::ONCE);
// Writeable event fired
ASSERT_EQ(What::WRITE, handler.last_event);
}
TEST_F(EventHandlerTest, ReadEventsPostWhenAvailable) {
TestEventHandler handler(fds[0]);
base->registerHandler(&handler, What::READ);
char buf[1] = {'A'};
ASSERT_EQ(1, xwrite(fds[1], buf, sizeof(buf)));
// Loop once
base->loop(EventBase::LoopMode::ONCE);
// Readable event fired
ASSERT_EQ(What::READ, handler.last_event);
}
TEST_F(EventHandlerTest, UnregisteredEventsNotRaised) {
TestEventHandler handler(fds[0]);
base->registerHandler(&handler, What::READ);
char buf[1] = {'A'};
ASSERT_EQ(1, xwrite(fds[1], buf, sizeof(buf)));
handler.unregister();
// Loop until empty (starts empty)
base->loop(EventBase::LoopMode::UNTIL_EMPTY);
ASSERT_EQ(What::NONE, handler.last_event);
}
} // wte namespace
|
7b54d6781191a977fe4a50bb048b9664e921bafd | c451cb186764b7de60eace0d3b34b27bb3404bd6 | /1285C.cpp | 9766e04c8651a345e9bea281ca3e57b91b7c942d | [] | no_license | Tsugiru/codeforces | 759f9abd46daa748202f720c6e6003654d553c15 | 3cc16d7cb8b0ae7f9da075c54e39640f00bd73e5 | refs/heads/master | 2021-08-16T21:50:31.625336 | 2021-06-27T11:02:02 | 2021-06-27T11:02:02 | 207,086,606 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,138 | cpp | 1285C.cpp | #include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
struct int_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
struct pair_hash {
size_t operator()(pii x) const {
return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
}
};
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<pll>> vvpll;
typedef vector<vvi> vvvi;
typedef unordered_map<int, int, int_hash> umii;
typedef unordered_map<ll, ll, int_hash> umll;
typedef unordered_set<int, int_hash> usi;
typedef unordered_set<ll, int_hash> usll;
typedef unordered_set<pii, pair_hash> uspii;
typedef queue<int> qi;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = numeric_limits<int>::max();
const int MX = 100001; //check the limits, dummy
ll p(ll x, ll y) {
ll res = 1;
while(y--) res *= x;
return res;
}
void f(vector<ll> &val, ll &resx, ll &resy, ll x, ll y, int i) {
if(i == val.size() && max(x, y) < max(resx, resy)) {
resx = x;
resy = y;
}
else if(i < val.size()) {
f(val, resx, resy, x * val[i], y, i + 1);
f(val, resx, resy, x, y * val[i], i + 1);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll x; cin >> x;
if(x == 1) {
cout << 1 << " " << 1 << endl;
return 0;
}
unordered_map<ll, int> factors;
for(ll i = 2; i * i <= x; i++) {
while(x % i == 0) {
factors[i]++;
x /= i;
}
}
if(x > 1) factors[x]++;
vector<ll> pwr;
for(auto it : factors) {
pwr.emplace_back(p(it.first, it.second));
}
sort(begin(pwr), end(pwr));
ll res1 = INF, res2 = INF;
f(pwr, res1, res2, 1, 1, 0);
cout << res1 << " " << res2 << endl;
} |
6b223e0eb8bc16328dd8436dce1c379e41908f21 | 7452457bf715cf50f251d086c5c9bfe0821b1538 | /include/Furrovine++/Text/Encoding/tutf16.h | 0c3475a99f9de18db0c73a6d9376cd1643661ab7 | [
"MIT"
] | permissive | bananu7/Furropen | 3d91c49b5b833f5f269cf5516a8f8c7cf1385cdc | 968351c1268d8994116cd8312f067dd2cacdbf5b | refs/heads/master | 2021-01-10T20:44:17.606000 | 2014-02-13T22:28:09 | 2014-02-13T22:28:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,697 | h | tutf16.h | #ifndef FURROVINETUTF16_H
#define FURROVINETUTF16_H
#include <array>
#include <Furrovine++/Text/Encoding/TextEncodingUnit.h>
namespace Furrovine { namespace Text { namespace Encoding {
template <typename TChar16, typename TEndian>
struct tutf16 : public TextEncodingUnit<tutf16<TChar16, TEndian>, TChar16, 2> {
public:
template <typename TIterator>
TIterator DecodeOneBytes( TIterator bytes, codepoint& c ) const {
uint16 c0, c1;
c0 = *bytes++;
c0 |= ( *bytes++ ) << 8;
c0 = TEndian::Value( c0 );
c = c0;
if ( c0 >= 0xD800 && c0 <= 0xDBFF ) {
TIterator twobytemarker( bytes );
c1 = *bytes++;
c1 |= ( *bytes ) << 8;
if ( c1 >= 0xDC00 && c1 <= 0xDFFF ) {
c1 = TEndian::Value( c1 );
c = ( ( c - 0xD800 ) << 10 )
+ ( c1 - 0xDC00 ) + 0x00010000;
++bytes;
}
else {
// TODO: decoder error
return twobytemarker;
}
}
return bytes;
}
template <typename TIterator>
TIterator ReverseDecodeOneBytes( TIterator forwardbytes, codepoint& c ) const {
std::reverse_iterator<TIterator> bytes( forwardbytes );
uint16 c0, c1;
c0 = ( *bytes++ ) << 8;
c0 |= ( *bytes++ );
c0 = TEndian::Value( c0 );
if ( c0 > 0xDC00 && c0 < 0xDFFF ) {
decltype( bytes ) twobytemarker = bytes;
c1 = c0;
c0 = ( *bytes++ ) << 8;
c0 |= ( *bytes++ );
c0 = TEndian::Value( c0 );
if ( c0 < 0xD800 || c0 > 0xDBFF ) {
// TODO: decoder error
return twobytemarker.base();
}
else {
c = c0;
c = ( ( c - 0xD800 ) << 10 )
+ ( c1 - 0xDC00 ) + 0x00010000;
}
}
else {
c = c0;
}
return bytes.base();
}
template <typename TIterator>
TIterator EncodeOneBytes ( codepoint c, TIterator bytes ) const {
std::array<TChar16, 2> uint16s;
byte* u16cb = reinterpret_cast<byte*>( uint16s.data() );
if ( c < 0xFFFF ) {
uint16s[0] = static_cast<TChar16>( TEndian::Value( static_cast<TChar16>( c ) ) );
*bytes++ = *u16cb++;
*bytes++ = *u16cb;
}
else if ( c < 0x110000 ) {
c -= 0x00010000;
uint16s[0] = static_cast<TChar16>( ( c >> 10 ) + 0xD800 );
uint16s[1] = static_cast<TChar16>( ( c & 0x03FF ) + 0xDC00 );
uint16s[0] = static_cast<TChar16>( TEndian::Value( uint16s[0] ) );
uint16s[1] = static_cast<TChar16>( TEndian::Value( uint16s[1] ) );
*bytes++ = *u16cb++;
*bytes++ = *u16cb++;
*bytes++ = *u16cb++;
*bytes++ = *u16cb;
}
else {
// TODO: Encoding throw
return EncodeOneBytes( ReplacementCodePoint, bytes );
}
return bytes;
}
};
}}}
#endif // FURROVINETUTF16_H |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.