blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
8b53b973a4b5ce3ed3fcfd02d196544f3befa1ea
31f5cddb9885fc03b5c05fba5f9727b2f775cf47
/thirdparty/google/tensorflow/lite/kernels/squeeze_test.cc
5adec2473398c15c9cb3c1e28af87b78f03f3e43
[ "MIT" ]
permissive
timi-liuliang/echo
2935a34b80b598eeb2c2039d686a15d42907d6f7
d6e40d83c86431a819c6ef4ebb0f930c1b4d0f24
refs/heads/master
2023-08-17T05:35:08.104918
2023-08-11T18:10:35
2023-08-11T18:10:35
124,620,874
822
102
MIT
2021-06-11T14:29:03
2018-03-10T04:07:35
C++
UTF-8
C++
false
false
6,047
cc
/* Copyright 2018 The TensorFlow Authors. 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. ==============================================================================*/ #include <stdint.h> #include <initializer_list> #include <vector> #include <gmock/gmock.h> #include <gtest/gtest.h> #include "flatbuffers/flatbuffers.h" // from @flatbuffers #include "tensorflow/lite/kernels/test_util.h" #include "tensorflow/lite/schema/schema_generated.h" namespace tflite { namespace { using ::testing::ElementsAreArray; using ::testing::IsEmpty; class BaseSqueezeOpModel : public SingleOpModel { public: BaseSqueezeOpModel(const TensorData& input, const TensorData& output, std::initializer_list<int> axis) { input_ = AddInput(input); output_ = AddOutput(output); SetBuiltinOp( BuiltinOperator_SQUEEZE, BuiltinOptions_SqueezeOptions, CreateSqueezeOptions(builder_, builder_.CreateVector<int>(axis)) .Union()); BuildInterpreter({GetShape(input_)}); } int input() { return input_; } protected: int input_; int output_; }; template <typename T> class SqueezeOpModel : public BaseSqueezeOpModel { public: using BaseSqueezeOpModel::BaseSqueezeOpModel; void SetInput(std::initializer_list<T> data) { PopulateTensor(input_, data); } void SetStringInput(std::initializer_list<string> data) { PopulateStringTensor(input_, data); } std::vector<T> GetOutput() { return ExtractVector<T>(output_); } std::vector<string> GetStringOutput() { return ExtractVector<string>(output_); } std::vector<int> GetOutputShape() { return GetTensorShape(output_); } }; template <typename T> class SqueezeOpTest : public ::testing::Test {}; using DataTypes = ::testing::Types<float, int8_t, int16_t, int32_t>; TYPED_TEST_SUITE(SqueezeOpTest, DataTypes); TYPED_TEST(SqueezeOpTest, SqueezeAll) { std::initializer_list<TypeParam> data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}; SqueezeOpModel<TypeParam> m({GetTensorType<TypeParam>(), {1, 24, 1}}, {GetTensorType<TypeParam>(), {24}}, {}); m.SetInput(data); m.Invoke(); EXPECT_THAT(m.GetOutputShape(), ElementsAreArray({24})); EXPECT_THAT( m.GetOutput(), ElementsAreArray({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24})); } TYPED_TEST(SqueezeOpTest, SqueezeSelectedAxis) { std::initializer_list<TypeParam> data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}; SqueezeOpModel<TypeParam> m({GetTensorType<TypeParam>(), {1, 24, 1}}, {GetTensorType<TypeParam>(), {24}}, {2}); m.SetInput(data); m.Invoke(); EXPECT_THAT(m.GetOutputShape(), ElementsAreArray({1, 24})); EXPECT_THAT( m.GetOutput(), ElementsAreArray({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24})); } TYPED_TEST(SqueezeOpTest, SqueezeNegativeAxis) { std::initializer_list<TypeParam> data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}; SqueezeOpModel<TypeParam> m({GetTensorType<TypeParam>(), {1, 24, 1}}, {GetTensorType<TypeParam>(), {24}}, {-1, 0}); m.SetInput(data); m.Invoke(); EXPECT_THAT(m.GetOutputShape(), ElementsAreArray({24})); EXPECT_THAT( m.GetOutput(), ElementsAreArray({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24})); } TYPED_TEST(SqueezeOpTest, SqueezeAllDims) { std::initializer_list<TypeParam> data = {3}; SqueezeOpModel<TypeParam> m( {GetTensorType<TypeParam>(), {1, 1, 1, 1, 1, 1, 1}}, {GetTensorType<TypeParam>(), {1}}, {}); m.SetInput(data); m.Invoke(); EXPECT_THAT(m.GetOutputShape(), IsEmpty()); EXPECT_THAT(m.GetOutput(), ElementsAreArray({3})); } TEST(SqueezeOpTest, SqueezeAllString) { std::initializer_list<std::string> data = {"a", "b"}; SqueezeOpModel<std::string> m({GetTensorType<std::string>(), {1, 2, 1}}, {GetTensorType<std::string>(), {2}}, {}); m.SetStringInput(data); m.Invoke(); EXPECT_THAT(m.GetOutputShape(), ElementsAreArray({2})); EXPECT_THAT(m.GetStringOutput(), ElementsAreArray({"a", "b"})); } TEST(SqueezeOpTest, SqueezeNegativeAxisString) { std::initializer_list<std::string> data = {"a", "b"}; SqueezeOpModel<std::string> m({GetTensorType<std::string>(), {1, 2, 1}}, {GetTensorType<std::string>(), {24}}, {-1}); m.SetStringInput(data); m.Invoke(); EXPECT_THAT(m.GetOutputShape(), ElementsAreArray({1, 2})); EXPECT_THAT(m.GetStringOutput(), ElementsAreArray({"a", "b"})); } TEST(SqueezeOpTest, SqueezeAllDimsString) { std::initializer_list<std::string> data = {"a"}; SqueezeOpModel<std::string> m( {GetTensorType<std::string>(), {1, 1, 1, 1, 1, 1, 1}}, {GetTensorType<std::string>(), {1}}, {}); m.SetStringInput(data); m.Invoke(); EXPECT_THAT(m.GetOutputShape(), IsEmpty()); EXPECT_THAT(m.GetStringOutput(), ElementsAreArray({"a"})); } } // namespace } // namespace tflite
[ "qq79402005@gmail.com" ]
qq79402005@gmail.com
29025009bdd6f4bb741220f0473bfc52d4fdffb4
c3524677697850f7be979396023f6f3893dbed61
/actionhuffman.cpp
93047d9b01894a34a677bd401c81e6d1c3b7e9f2
[]
no_license
JoicySoares/Huffman
b6e64e38066d6a11bde5388d655dfcf2ee37dbe3
37ca0ce5213aa41f3d2702b588abe7a3335ee979
refs/heads/master
2021-01-10T16:36:40.092833
2015-11-24T02:51:46
2015-11-24T02:51:46
46,719,715
0
0
null
null
null
null
UTF-8
C++
false
false
306
cpp
#include "actionhuffman.h" void ActionHuffman::doCompress(QString name, QString newname){ if(newname == "out") newname = ""; compress(name,newname); } void ActionHuffman::doDecompress(QString name, QString local){ if(local == "out") local = ""; decompress(name,local); }
[ "gio@outlook.com.br" ]
gio@outlook.com.br
2432d43634d4af12382e34a90fa77bbf2c1bbeb8
f6f323c895e18433159627bd61efccf63a5fe12f
/dancers.cpp
f8f0d7d1fc07b76d89f77f0d895f79980eace473
[]
no_license
Adarsh-kumar/Competitive_coding_practice
200d869d072b97daa5e900b0c35b91e1da128247
88bb368b107b35eb5e9c40a683a3e41fbe16b469
refs/heads/master
2020-03-30T14:03:30.177798
2018-10-02T18:09:40
2018-10-02T18:09:40
151,299,363
0
0
null
null
null
null
UTF-8
C++
false
false
460
cpp
#include<bits/stdc++.h> using namespace std; int main() { int n,m; cin>>n>>m; map<int,int> my_map; bool tempbool[3]; for(int i=0;i<m;i++) { memset(tempbool,0,sizeof(tempbool)); for(int j=0;j<3;j++) { int temp; cin>>temp; if(my_map.find(temp)==my_map.end()) { for(int k=0;k<3;k++) { if(tempbool[k]==0) { tempbool[k]=1; my_map[temp]=k+1; break; } } } else tempbool[my_map[temp]-1]=1; } } for(int i=1;i<=n;i++) { cout<<my_map[i]<<" "; } return 0; }
[ "adarsh.kumar.phe15@itbhu.ac.in" ]
adarsh.kumar.phe15@itbhu.ac.in
a76293e7c668449f8ba453a7ca21eedf7a57a9b8
d42690a835c5d3a7468d124c218d73d5814a9719
/manacher.cpp
474bda50b5a8ec32a5066a6e3e7a6c670492491b
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
gostkin/algo
90613d43dddd92475c971c8db679d9386c752e12
d04caf8cc73da396afb67c65275a4509033b2299
refs/heads/master
2020-12-30T22:32:59.319422
2017-03-22T00:56:39
2017-03-22T00:56:39
86,512,006
5
0
null
2017-03-28T22:11:49
2017-03-28T22:11:49
null
UTF-8
C++
false
false
614
cpp
vector<int> manacher_odd(string s){ int n = (int) s.size(); vector<int> d(n, 1); int l = 0, r = 0; for(int i = 1; i < n; i++){ if(i < r) d[i] = min(r-i+1, d[l+r-i]); while(i-d[i] >= 0 && i+d[i] < n && s[i-d[i]] == s[i+d[i]]) d[i]++; if(i+d[i]-1 > r) l = i-d[i]+1, r = i+d[i]-1; } return d; } vector<int> manacher_even(string s){ int n = (int) s.size(); vector<int> d(n, 0); int l = -1, r = -1; for(int i = 0; i < n-1; i++){ if(i < r) d[i] = min(r-i, d[l+r-i-1]); while(i-d[i] >= 0 && i+d[i]+1 < n && s[i-d[i]] == s[i+d[i]+1]) d[i]++; if(i+d[i] > r) l = i-d[i]+1, r = i+d[i]; } return d; }
[ "slotserg@gmail.com" ]
slotserg@gmail.com
7f1420f83e4694aeeeded678d144b5f0b097317d
ea04bfc6fd704b52393f3f635a67644f0012d152
/include/rsSim/cubusgroup.tpp
a990438d683d66d28d64576848b35666c3273e4c
[]
no_license
gucwakj/librs
d3181e7df9de9036232ae0a5fcd037d7af8d3555
222ae28db46cd47f3b32cdb6a32b360df68b75b8
refs/heads/master
2021-01-13T09:43:48.565374
2014-12-04T19:29:49
2014-12-04T19:29:49
69,404,202
2
0
null
null
null
null
UTF-8
C++
false
false
1,420
tpp
int CubusGroup::move(double angle1, double angle2, double angle3, double angle4, double angle5, double angle6) { moveNB(angle1, angle2, angle3, angle4, angle5, angle6); return moveWait(); } int CubusGroup::moveNB(double angle1, double angle2, double angle3, double angle4, double angle5, double angle6) { for (int i = 0; i < _robots.size(); i++) { _robots[i]->moveNB(angle1, angle2, angle3, angle4, angle5, angle6); } return 0; } int CubusGroup::moveTo(double angle1, double angle2, double angle3, double angle4, double angle5, double angle6) { moveToNB(angle1, angle2, angle3, angle4, angle5, angle6); return moveWait(); } int CubusGroup::moveToNB(double angle1, double angle2, double angle3, double angle4, double angle5, double angle6) { for (int i = 0; i < _robots.size(); i++) { _robots[i]->moveToNB(angle1, angle2, angle3, angle4, angle5, angle6); } return 0; } int CubusGroup::setJointSpeeds(double speed1, double speed2, double speed3, double speed4, double speed5, double speed6) { for (int i = 0; i < _robots.size(); i++) { _robots[i]->setJointSpeeds(speed1, speed2, speed3, speed4, speed5, speed6); } return 0; } int CubusGroup::setJointSpeedRatios(double ratio1, double ratio2, double ratio3, double ratio4, double ratio5, double ratio6) { for (int i = 0; i < _robots.size(); i++) { _robots[i]->setJointSpeedRatios(ratio1, ratio2, ratio3, ratio4, ratio5, ratio6); } return 0; }
[ "gucwakj@gmail.com" ]
gucwakj@gmail.com
aee618963b4b2f416877a576c24a322b4be9bb05
876c7dba66959a02d00ba300adcf64285085ae85
/Info/Birthday/main.cpp
75fe3897c81e13f2f661885321519fe33d393527
[]
no_license
viftode4/PBINFOOOO
69b36ce9458e03061fec67981904b3fb2485430b
8aebb5488f91735218404c36a983e23d833f2d1d
refs/heads/master
2023-04-23T12:39:14.031554
2021-05-18T17:54:51
2021-05-18T17:54:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
291
cpp
#include <iostream> using namespace std; long long m,n,k,l; int main() { cin>>n>>m>>k>>l; if(m>n) cout<<-1; else { int i=1; while(m*i-k<=l) i++; if(m*i>n) cout<<-1; else cout<<i; } return 0; }
[ "37593074+Levladutz@users.noreply.github.com" ]
37593074+Levladutz@users.noreply.github.com
969da689771b247fbf6350ed641b9062e1114c17
8de313497e44dce303a75c827af2288f57a8c19e
/src/01.HW/library/happyhog/FoodSchedule.h
9b52576b88a64c1198acba95a1e6dfca0a42ec2d
[]
no_license
MyHappyHog/ProjectPrototype
49d4c271a84c230cd39049d363a46ddba276f133
161741584cee306594680115e65acba2e9d0eae1
refs/heads/master
2021-01-17T10:09:56.355681
2016-06-02T03:42:23
2016-06-02T03:42:23
41,733,994
2
0
null
2016-05-28T00:33:38
2015-09-01T11:14:01
Swift
UHC
C++
false
false
941
h
#ifndef __FOODSCHEDULE_H__ #define __FOODSCHEDULE_H__ #include "Setting.h" #define DEFAULT_FOODSCHEDULE_FILENAME "/FoodSchedule.json" #define NUM_ROTATION_KEY "numRotation" #define TIME_KEY "time" /// @brief Food 스케줄을 담고 있는 클래스 /// @details /// @author Jongho Lim, sloth@kookmin.ac.kr /// @date 2016-02-11 /// @version 0.0.1 typedef struct _FoodScheduleList { struct _FoodScheduleList* nextSchedule; int numRotation; String time; } FoodScheduleList; class FoodSchedule : public Setting { public: FoodSchedule(String fileName); FoodSchedule(String filePath, String fileName); virtual ~FoodSchedule(); virtual bool deserialize(String json, bool rev = false); virtual String serialize(bool rev = false); void addSchedule(int numRotation, String time); void removeSchedule(FoodScheduleList* delSchedule); FoodScheduleList* getFoodScheduleHeader(); private : FoodScheduleList* schedule; }; #endif
[ "sloth@kookmin.ac.kr" ]
sloth@kookmin.ac.kr
4dfcbe568e9b67e24e492c0aa6884a23aa2d8d16
1f5da44dc3060ed069ea39f603c4defc66929524
/include/stack.hpp
77a29b8176301d1fe200a33d395e0842af9465a4
[ "MIT" ]
permissive
zikhik/Stack-1
57c71d40e614899129affa4e8c909cc4d206271a
498e855ff016050e69418def79641cfc33855c89
refs/heads/master
2021-01-11T09:23:57.956927
2016-12-22T06:53:35
2016-12-22T06:53:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,003
hpp
#ifndef stack_cpp #define stack_cpp #pragma once #include <iostream> #include <thread> #include <memory> class bitset { public: explicit bitset(size_t size); bitset(bitset const & other) = delete; auto operator =(bitset const & other)->bitset & = delete; bitset(bitset && other) = delete; auto operator =(bitset && other)->bitset & = delete; auto set(size_t index) -> void; auto reset(size_t index) -> void; auto test(size_t index) -> bool; auto size() const -> size_t; auto counter() const -> size_t; private: std::unique_ptr<bool[]> ptr_; size_t size_; size_t counter_; }; bitset::bitset(size_t size) : ptr_(std::make_unique<bool[]>(size)), size_(size), counter_(0) {} auto bitset::set(size_t index) -> void { if (index < size_) { ptr_[index] = true; ++counter_; } else throw("false_index"); } auto bitset::reset(size_t index) -> void { if (index < size_) { ptr_[index] = false; --counter_; } else throw("false_index"); } auto bitset::test(size_t index) -> bool { if (index < size_) { return !ptr_[index]; } else throw("false_index"); } auto bitset::size() const -> size_t { return size_; } auto bitset::counter() const -> size_t { return counter_; } /*=====================================================================================*/ template <typename T> class allocator { public: explicit allocator( std::size_t size = 0 ); allocator( allocator const & other ); auto operator =( allocator const & other ) -> allocator & = delete; ~allocator(); auto resize() -> void; auto construct(T * ptr, T const & value ) -> void; auto destroy( T * ptr ) -> void; auto get() -> T *; auto get() const -> T const *; auto count() const -> size_t; auto full() const -> bool; auto empty() const -> bool; auto swap(allocator & other) -> void; private: auto destroy(T * first, T * last) -> void; T * ptr_; size_t count_; size_t size_; std::unique_ptr<bitset> map_; }; template <typename T> allocator<T>::allocator(size_t size) : ptr_((T*)(operator new(size*sizeof(T)))), size_(size), map_(std::make_unique<bitset>(size)) {}; template<typename T> allocator<T>::allocator(allocator const& other) : allocator<T>(other.size_) { for (size_t i=0; i < size_; ++i) if (other.map_->test(i)) construct(ptr_ + i, other.ptr_[i]); } template<typename T> allocator<T>::~allocator() { destroy(ptr_, ptr_+size_); operator delete(ptr_); } template<typename T> auto allocator<T>::resize() -> void { allocator<T> buff(size_ * 2 + (size_ == 0)); for (size_t i = 0; i < size_; ++i) construct(buff.ptr_ + i, ptr_[i]); this->swap(buff); } template<typename T> auto allocator<T>::construct(T * ptr, T const & value)->void { if (ptr >= ptr_&&ptr < ptr_ + size_&&map_->test(ptr - ptr_)) { new(ptr)T(value); map_->set(ptr - ptr_); } else throw("error"); } template<typename T> auto allocator<T>::destroy(T * ptr) -> void { if(ptr>=ptr_&&ptr<=ptr_+this->count()) { if (!map_->test(ptr-ptr_)) { ptr->~T(); map_->reset(ptr-ptr_); } } else throw("error"); } template<typename T> auto allocator<T>::destroy(T * first, T * last) -> void { if(first>=ptr_&&last<=ptr_+this->count()) for (; first != last; ++first) { destroy(&*first); } } template<typename T> auto allocator<T>::get()-> T* { return ptr_; } template<typename T> auto allocator<T>::get() const -> T const * { return ptr_; } template<typename T> auto allocator<T>::count() const -> size_t { return map_->counter(); } template<typename T> auto allocator<T>::full() const -> bool { return map_->counter()==size_; } template<typename T> auto allocator<T>::empty() const -> bool { return map_->counter()==0; } template<typename T> auto allocator<T>::swap(allocator & other) -> void { std::swap(ptr_, other.ptr_); std::swap(map_, other.map_); std::swap(size_, other.size_); std::swap(count_, other.count_); } /*=====================================================================================*/ template <typename T> class stack : private allocator<T> { public: explicit stack(size_t size = 0); //noexcept stack(stack const & other); auto pop() -> std::shared_ptr<T>; auto push(T const &vaule) -> void; //strong auto operator=(stack const & other)->stack &; //strong auto empty() const -> bool; //noexcept auto count() const -> size_t; private: allocator<T> allocator_; auto throw_is_empty() const -> void; mutable std::mutex m; }; template <typename T> stack<T>::stack(size_t size):allocator_(size), m() {}; template <typename T> stack<T>::stack(stack const & other) : allocator_(0), m() { std::lock_guard<std::mutex> locker2(other.m); allocator_.swap(allocator<T>(other.allocator_)); } template <typename T> void stack<T>::push(T const &val) { std::lock_guard<std::mutex> locker(m); if (allocator_.full()) { allocator_.resize(); } allocator_.construct(allocator_.get() + allocator_.count(), val); } template <typename T> auto stack<T>::pop()->std::shared_ptr<T> { std::lock_guard<std::mutex> locker(m); if (allocator_.count() == 0) throw_is_empty(); std::shared_ptr<T> top_(std::make_shared<T>(std::move(allocator_.get()[allocator_.count() - 1]))); allocator_.destroy(allocator_.get() + allocator_.count() - 1); return top_; } template<typename T> auto stack<T>::operator=(stack const & other)-> stack & { if (this != &other) { std::lock(m, other.m); std::lock_guard<std::mutex> locker1(m, std::adopt_lock); std::lock_guard<std::mutex> locker2(other.m, std::adopt_lock); (allocator<T>(other.allocator_)).swap(allocator_); } return *this; } template<typename T> auto stack<T>::empty() const -> bool { std::lock_guard<std::mutex> locker(m); return (allocator_.count() == 0); } template<typename T> auto stack<T>::throw_is_empty() const -> void { std::lock_guard<std::mutex> lk(m); throw("Stack is empty!"); } template <typename T> auto stack<T>::count() const ->size_t { std::lock_guard<std::mutex> lockerk(m); return allocator_.count(); } #endif
[ "noreply@github.com" ]
noreply@github.com
0d7d3c35d7f4af9b4110ddb4c9ecfb48d4a81620
1323abdeae70120f30adb6ed0fc8607366b3c423
/separate_jun.ino
603eca5f48b7dd386da64229ed6928d8222930c5
[]
no_license
sshhj89/Audio-Project
7fae3e2565f902473ef988d8b97c3a271284411d
ae956373636b0afc872efae43e41072c883542e0
refs/heads/master
2020-12-26T01:16:19.073996
2015-02-17T21:43:35
2015-02-17T21:43:35
28,971,488
0
0
null
2015-01-08T15:15:57
2015-01-08T15:15:57
null
UTF-8
C++
false
false
4,230
ino
/*************************************************** This is an example for the Adafruit VS1053 Codec Breakout Designed specifically to work with the Adafruit VS1053 Codec Breakout ----> https://www.adafruit.com/products/1381 Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution ****************************************************/ // include SPI, MP3 and SD libraries #include <SPI.h> #include <Adafruit_VS1053.h> #include <SD.h> // define the pins used //#define CLK 13 // SPI Clock, shared with SD card //#define MISO 12 // Input data, from VS1053/SD card //#define MOSI 11 // Output data, to VS1053/SD card // Connect CLK, MISO and MOSI to hardware SPI pins. // See http://arduino.cc/en/Reference/SPI "Connections" // These are the pins used for the breakout example #define BREAKOUT_RESET 9 // VS1053 reset pin (output) #define BREAKOUT_CS 10 // VS1053 chip select pin (output) #define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output) // These are the pins used for the music maker shield #define SHIELD_CS 7 // VS1053 chip select pin (output) #define SHIELD_DCS 6 // VS1053 Data/command select pin (output) // These are common pins between breakout and shield #define CARDCS 4 // Card chip select pin // DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt #define DREQ 3 // VS1053 Data request, ideally an Interrupt pin Adafruit_VS1053_FilePlayer musicPlayer = // create breakout-example object! //Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS); // create shield-example object! Adafruit_VS1053_FilePlayer(SHIELD_CS, SHIELD_DCS, DREQ, CARDCS); //initial setup of pins (buttons) int inputPin1 = 3; //!!!!!!!reassign the pins here to test out the pause/play and stop functions int inputPin2 = 2; int inputPin3 = A0; // check plugin. it should be pulled up when it is initial. and connect with headphone jack int outputPin1 = 5; // send signal to spk off int count = 0; boolean buttonPressed1 = false; boolean buttonPressed2 = false;//boolean testing // char *names[3]={"sample 1", "sample 2", "sample 3"}; char *files[3]={"sample1.mp3", "sample2.mp3", "sample3.mp3"}; void setup() { pinMode(inputPin1, INPUT);//pin mode setup for both buttons pinMode(inputPin2, INPUT); pinMode(inputPin3, INPUT); pinMode(outputPin1, OUTPUT); digitalWrite(outputPin1,HIGH); Serial.begin(9600); Serial.println("Adafruit VS1053 Simple Test"); if (! musicPlayer.begin()) { // initialise the music player Serial.println(F("Couldn't find VS1053, do you have the right pins defined?")); while (1); } Serial.println(F("VS1053 found")); SD.begin(CARDCS); // initialise the SD card // Set volume for left, right channels. lower numbers == louder volume! musicPlayer.setVolume(5,5); // Timer interrupts are not suggested, better to use DREQ interrupt! //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background // audio playing musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int while (count < 3){ Serial.print("Playing "); Serial.println(files[count]); musicPlayer.startPlayingFile(files[count]); count ++ ; Serial.println(count); while (!musicPlayer.stopped()){ loop(); } } } boolean plugin = false; //button calling void loop() { // File is playing in the background if (musicPlayer.stopped()) { Serial.println("Done playing music"); while (1); } plugin = digitalRead(inputPin3); if(plugin == 1) { plugin = false; } else { plugin = true; } if(plugin) { digitalWrite(outputPin1, LOW); } else { digitalWrite(outputPin1, HIGH); } Serial.println(digitalRead(inputPin3)); delay(100); }
[ "smuoon4680@gmail.com" ]
smuoon4680@gmail.com
a955c22078e3f1aab79afdc755110458fb1b3111
b77349e25b6154dae08820d92ac01601d4e761ee
/Thumbnail/EasyFavorite/EasyFavorite/OleURLDropTarget.h
803f7c6eaeda17afbf6a41afbdc071d0b6701feb
[]
no_license
ShiverZm/MFC
e084c3460fe78f820ff1fec46fe1fc575c3e3538
3d05380d2e02b67269d2f0eb136a3ac3de0dbbab
refs/heads/master
2023-02-21T08:57:39.316634
2021-01-26T10:18:38
2021-01-26T10:18:38
332,725,087
0
0
null
2021-01-25T11:35:20
2021-01-25T11:29:59
null
UHC
C++
false
false
1,421
h
////////////////////////////////////////////////////////// // // 만든이 : 서우석 // ---------------------------------------------------- // 이 소스는 공개 소스이며, 이 소스를 사용할 경우 // 반드시 저의 이름을 같이 올려주시면 감사하겠습니다. ^^. // // e-mail : seaousak@hotmail.com ////////////////////////////////////////////////////////// #if !defined(AFX_OLEURLDROPTARGET_H__4B13BE66_7B3E_4FAA_B0A3_419EF939D700__INCLUDED_) #define AFX_OLEURLDROPTARGET_H__4B13BE66_7B3E_4FAA_B0A3_419EF939D700__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <afxole.h> class COleURLDropTarget : public COleDropTarget { public: COleURLDropTarget(CWnd* pParent = NULL); virtual ~COleURLDropTarget(); void SetParent(CWnd* pParent); DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point ); DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point ); void OnDragLeave(CWnd* pWnd); BOOL OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point ); // 변수들 protected: CWnd* m_pParent; }; #endif // !defined(AFX_OLEURLDROPTARGET_H__4B13BE66_7B3E_4FAA_B0A3_419EF939D700__INCLUDED_)
[ "w.z.y2006@163.com" ]
w.z.y2006@163.com
fa7e1eb81a579fb178d1dcd499a1ee2c0e874654
8b92dbc33bb31d7639d9b7e79a0f3eadae9351e9
/wavefront_obj.h
a8aae935452b37c1133acc11efac37980064aa95
[]
no_license
asui1/OpenGL-Cow-Modelling
a2ec5823846cbe93b1da060ec97c3feea59bb0e2
b868116be88bcea382205519ef6de659c8e66812
refs/heads/master
2022-11-24T05:44:08.642543
2020-07-20T19:31:41
2020-07-20T19:31:41
281,208,039
0
0
null
null
null
null
UTF-8
C++
false
false
887
h
#ifndef _WAVEFRONT_OBJ_H_ #define _WAVEFRONT_OBJ_H_ #include <vector> #include <array> #include <utility> #include <GL/GL.h> class wavefront_obj_t { public: static constexpr GLuint gl_primitive_mode = GL_POLYGON; using double2 = std::array<double, 2>; using double3 = std::array<double, 3>; struct face_t { std::size_t idx_begin; std::size_t count; double3 normal; }; std::vector<double3> vertices; // x, y, z std::vector<double3> normals; // x, y, z // unit vector or {0, 0, 0} std::vector<double2> texcoords; // u, v std::vector<face_t> faces; std::vector<int> vertex_indices; std::vector<int> normal_indices; std::vector<int> texcoord_indices; bool is_flat; std::pair<double3, double3> aabb; // bounding box wavefront_obj_t(const char *path); // constructor: load from file void draw(); }; #endif // _WAVEFRONT_OBJ_H_
[ "noreply@github.com" ]
noreply@github.com
7713c95426013ebbb5ebaf30d99becc6499c0f6f
545a6226fbc29c9c395d98cc56a6e52b345b7fec
/Kingdom of the Lich/Kingdom of the Lich/Door.h
4342f73c6ebe439f9fbb69533344435a60a6123e
[]
no_license
Redbeard2794/Kingdom-of-the-Lich
ef4fcdeeb65bb305b9dad91eaa2bd87240214c99
f3878a63269ae4369f474957dd70a31600f266b9
refs/heads/master
2021-01-10T16:09:53.959429
2016-04-21T08:04:28
2016-04-21T08:04:28
44,171,667
0
0
null
2016-04-21T08:04:29
2015-10-13T11:28:31
C++
UTF-8
C++
false
false
718
h
#ifndef DOOR_H #define DOOR_H class Door : public sf::Sprite { private: enum DoorType { TrapDoor, StoneDoorway, HouseDoorOne, HouseExitDoor }; int type;//deciding sprite sf::Texture texture; bool open; enum Areas { TUTORIAL, SEWER, GENERALSTORE1, House1, House2, TheDrunkenDragonInn }; int area; int id; public: /*constructor. params: type, position, whether its open or not, area it leads to, id*/ Door(int t, sf::Vector2f pos, bool o, int a, int i); //destructor ~Door(); //check if the player is standing in the doorway bool IsPlayerInDoorway(sf::Vector2f playerPos); //is the door open bool IsOpen(); void SetOpen(bool o); int GetArea(); int GetId(); }; #endif
[ "jayo2794@gmail.com" ]
jayo2794@gmail.com
a57556bf76bf762bc713820bf8ed75a48af8f44f
841dc918a66a9cb8f0babd0227c9055958fde867
/cartographer_ros_migrate/cartographer_ros/cartographer_ros/metrics/internal/histogram.cc
62bb6e25c2b5c4e98dbb15a5548199364e186768
[ "Apache-2.0" ]
permissive
oyfp86/cartographer_migrate_to_ros2
b59995a6fedb5669218d6ecbdbbcc5b01eba4a44
269dce141171575e121cf9b7781bab3d958268cb
refs/heads/master
2020-03-24T02:12:08.169470
2018-07-25T14:41:35
2018-07-25T14:41:35
142,366,237
1
0
null
2018-07-26T00:07:40
2018-07-26T00:07:39
null
UTF-8
C++
false
false
3,045
cc
/* * Copyright 2018 The Cartographer Authors * * 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 "cartographer_ros/metrics/internal/histogram.h" #include <algorithm> #include <numeric> #include "glog/logging.h" namespace cartographer_ros { namespace metrics { using BucketBoundaries = ::cartographer::metrics::Histogram::BucketBoundaries; Histogram::Histogram(const std::map<std::string, std::string>& labels, const BucketBoundaries& bucket_boundaries) : labels_(labels), bucket_boundaries_(bucket_boundaries), bucket_counts_(bucket_boundaries.size() + 1) { ::cartographer::common::MutexLocker lock(&mutex_); CHECK(std::is_sorted(std::begin(bucket_boundaries_), std::end(bucket_boundaries_))); } void Histogram::Observe(double value) { auto bucket_index = std::distance(bucket_boundaries_.begin(), std::upper_bound(bucket_boundaries_.begin(), bucket_boundaries_.end(), value)); ::cartographer::common::MutexLocker lock(&mutex_); sum_ += value; bucket_counts_[bucket_index] += 1; } std::map<double, double> Histogram::CountsByBucket() { ::cartographer::common::MutexLocker lock(&mutex_); std::map<double, double> counts_by_bucket; // Add the finite buckets. for (size_t i = 0; i < bucket_boundaries_.size(); ++i) { counts_by_bucket[bucket_boundaries_.at(i)] = bucket_counts_.at(i); } // Add the "infinite" bucket. counts_by_bucket[kInfiniteBoundary] = bucket_counts_.back(); return counts_by_bucket; } double Histogram::Sum() { ::cartographer::common::MutexLocker lock(&mutex_); return sum_; } double Histogram::CumulativeCount() { ::cartographer::common::MutexLocker lock(&mutex_); return std::accumulate(bucket_counts_.begin(), bucket_counts_.end(), 0.); } cartographer_ros_msgs::msg::Metric Histogram::ToRosMessage() { cartographer_ros_msgs::msg::Metric msg; msg.type = cartographer_ros_msgs::msg::Metric::TYPE_HISTOGRAM; for (const auto& label : labels_) { cartographer_ros_msgs::msg::MetricLabel label_msg; label_msg.key = label.first; label_msg.value = label.second; msg.labels.push_back(label_msg); } for (const auto& bucket : CountsByBucket()) { cartographer_ros_msgs::msg::HistogramBucket bucket_msg; bucket_msg.bucket_boundary = bucket.first; bucket_msg.count = bucket.second; msg.counts_by_bucket.push_back(bucket_msg); } return msg; } } // namespace metrics } // namespace cartographer_ros
[ "adayimaxiga@hotmail.com" ]
adayimaxiga@hotmail.com
7f068b13143b340d1b13711947a73aacf9fae110
46a1862be22680d5ff27fb9f5a20f6c62511b3d5
/算法/作业/第5次作业/A.cpp
b54c2a42e61917f5fb438fcb3cedbd60171d9828
[]
no_license
Chen-Qixian/2020-Fall-PKU
16fb2af4baf9e6c517c5d4a7098d9b8734f965c8
704be1f44dbb668072204ab2961a0d5c9fe3e976
refs/heads/master
2023-03-03T19:44:46.956437
2021-02-05T10:44:40
2021-02-05T10:44:40
336,241,272
1
1
null
null
null
null
UTF-8
C++
false
false
815
cpp
#include <bits/stdc++.h> using namespace std; int T, N; int a[50001]; int dpl[50001]; int dpr[50001]; void left() { dpl[0] = a[0]; for(int i = 1 ; i < N ; i ++) { dpl[i] = max(a[i], a[i] + dpl[i-1]); } for(int i = 1 ; i < N ; i ++) { dpl[i] = max(dpl[i], dpl[i-1]); } } void right() { dpr[N-1] = a[N-1]; for(int i = N - 2 ; i >= 0 ; i --) { dpr[i] = max(a[i], a[i] + dpr[i+1]); } for(int i = N - 2 ; i >= 0 ; i --) { dpr[i] = max(dpr[i], dpr[i+1]); } } int getAns() { int res = INT_MIN; for(int i = 0 ; i < N - 1 ; i ++) { res = max(res, dpl[i] + dpr[i+1]); } return res; } int main(void) { scanf("%d", &T); while(T--) { scanf("%d", &N); for(int i = 0 ; i < N ; i ++) { scanf("%d", &a[i]); } left(); right(); int ans = getAns(); printf("%d\n", ans); } return 0; }
[ "Chen_Qixian@icloud.com" ]
Chen_Qixian@icloud.com
b1c85a1d437fed2c4b4b97ddd10778a2d6aaa662
bc0d19929ea06c2d9f9e271d9cc2ad8a23ebcf1e
/f/mitrem1/Projects/MITReM/src/ElecReaction_Linear.h
a4a667bfddd2f6ca0396d590eea15942124c6e8b
[]
no_license
pmaciel/m
a7eb9827a6fd8ed45231bd0edecbe296fd746497
83904d9286aff1a8f9aaeeabaee22efc4f2a4419
refs/heads/master
2020-04-16T23:33:03.658527
2015-11-07T03:37:31
2015-11-07T03:37:31
3,329,694
0
0
null
null
null
null
UTF-8
C++
false
false
1,017
h
//--------------------------------------------------------------------------- #ifndef ElecReaction_LinearH #define ElecReaction_LinearH //--------------------------------------------------------------------------- #include "ElecReaction.h" //--------------------------------------------------------------------------- class ElecReaction_Linear : public ElecReaction { public : ElecReaction_Linear(ElectrolyteSolution* electrolyteSolution_, unsigned nAgentsRed_, unsigned nAgentsOxi_); virtual ~ElecReaction_Linear(); // Methods virtual double calcReactionRate(double V) const; virtual double calcReactionRateDerivativeU(double V) const; virtual double calcReactionRateDerivativeV(double V) const; virtual double calcReactionRateDerivativeCRed(double V, unsigned i) const; virtual double calcReactionRateDerivativeCOxi(double V, unsigned i) const; virtual double calcEquilibriumPotential() const; }; //--------------------------------------------------------------------------- #endif
[ "pmaciel@vub.ac.be" ]
pmaciel@vub.ac.be
9f9f53bf05e0538a18a69d48ae9b6b9181cffea5
c547c4da323f293150978d399b41ed097344f850
/Pocket/Serialization/TypeInterpolator.hpp
a98674139eb6198c0ad2197ee2cb811849c3b4a7
[]
no_license
Guanzhe/PocketEngine
48686a77714cf8e0c52c68896fc4db31e828efab
7728f6d8e520f54be5cd39023801286c78cce446
refs/heads/master
2021-09-18T06:32:28.031072
2017-12-29T20:50:22
2017-12-29T20:50:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,370
hpp
// // TypeInterpolator.hpp // PocketEditor // // Created by Jeppe Nielsen on 03/07/2017. // Copyright © 2017 Jeppe Nielsen. All rights reserved. // #pragma once #include <type_traits> #include "Quaternion.hpp" #include "Colour.hpp" #include "Property.hpp" #include "Matrix4x4.hpp" #include "Rect.hpp" #include "Box.hpp" namespace Pocket { template<class T, typename S = void> struct TypeInterpolator { static void Interpolate(T* value, float t, const T& a, const T& b) { *value = t<0.5f ? a : b; } }; template<> struct TypeInterpolator<float> { static void Interpolate(float* value, float t, const float& a, const float& b) { *value = a + (b-a) * t; } }; template<> struct TypeInterpolator<double> { static void Interpolate(double* value, float t, const double& a, const double& b) { *value = a + (b-a) * t; } }; template<> struct TypeInterpolator<int> { static void Interpolate(int* value, float t, const int& a, const int& b) { *value = a + (b-a) * t; } }; template<> struct TypeInterpolator<Vector2> { static void Interpolate(Vector2* value, float t, const Vector2& a, const Vector2& b) { *value = Vector2::Lerp(a, b, t); } }; template<> struct TypeInterpolator<Vector3> { static void Interpolate(Vector3* value, float t, const Vector3& a, const Vector3& b) { *value = Vector3::Lerp(a, b, t); } }; template<> struct TypeInterpolator<Quaternion> { static void Interpolate(Quaternion* value, float t, const Quaternion& a, const Quaternion& b) { *value = Quaternion::Slerp(t, a, b); } }; template<> struct TypeInterpolator<Colour> { static void Interpolate(Colour* value, float t, const Colour& a, const Colour& b) { *value = Colour::Lerp(a, b, t); } }; template<> struct TypeInterpolator<Matrix4x4> { static void Interpolate(Matrix4x4* value, float t, const Matrix4x4& a, const Matrix4x4& b) { *value = Matrix4x4::Lerp(a,b, t); } }; template<> struct TypeInterpolator<Rect> { static void Interpolate(Rect* value, float t, const Rect& a, const Rect& b) { *value = Rect::Lerp(a, b, t); } }; template<> struct TypeInterpolator<Box> { static void Interpolate(Box* value, float t, const Box& a, const Box& b) { *value = Box::Lerp(a, b, t); } }; template<typename T> struct TypeInterpolator<Property<T>> { static void Interpolate(Property<T>* value, float t, const Property<T>& a, const Property<T>& b) { T v; TypeInterpolator<T>::Interpolate(&v, t, a(), b()); value->operator=(v); } }; template<typename T> struct TypeInterpolator<T, typename std::enable_if< std::is_enum<T>::value >::type> { static void Interpolate(T* value, float t, const T& a, const T& b) { int aVal = static_cast<int>(a); int bVal = static_cast<int>(b); float val = aVal + (float)(bVal - aVal) * t; int intVal = (int)val; *value = (T)intVal; } }; }
[ "nielsen_jeppe@hotmail.com" ]
nielsen_jeppe@hotmail.com
22fa86cbb1401d92b744801b576eef3a36562d4f
57a1152ab9c48a35923950a12b136a8f5e7300ac
/expression.h
5b5453edff4af68c75b9e7ffa3893f4a63350f89
[]
no_license
shaevg/Calculator
c0f027ea04639109c0d638da9e25bd3b50d43e30
5af8d4bdbe3a5b8b6c9b40fa0278f1493df87abf
refs/heads/master
2021-01-01T20:43:52.169071
2017-07-31T19:41:58
2017-07-31T19:41:58
98,918,760
0
0
null
null
null
null
UTF-8
C++
false
false
627
h
#ifndef EXPRESSION_H #define EXPRESSION_H #include <vector> #include <array> #include <string> #include <algorithm> #include "core.h" #include "number.h" using std::string; using std::vector; class Expression { public: Expression(); int makeExpression(const string& expr); int makeConstant(const string& expr); bool isCalculated(); Number getValue() const; private: int parse(); int calculate(); Number _resultValue; bool _calculated; string _expr; vector<Expression> _exprVector; vector<Number> _resultVector; vector<char> _operatorVector; }; #endif // EXPRESSION_H
[ "shabalin.evgeniy@yandex.ru" ]
shabalin.evgeniy@yandex.ru
8c2519e20083e18da52ebe0367654709e4369e5f
26df6604faf41197c9ced34c3df13839be6e74d4
/ext/src/java/awt/Component_FlipSubRegionBufferStrategy.hpp
1c03bed1259cec6e35ebcf0a590ad0e2e7c051fd
[ "Apache-2.0" ]
permissive
pebble2015/cpoi
58b4b1e38a7769b13ccfb2973270d15d490de07f
6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6
refs/heads/master
2021-07-09T09:02:41.986901
2017-10-08T12:12:56
2017-10-08T12:12:56
105,988,119
0
0
null
null
null
null
UTF-8
C++
false
false
1,177
hpp
// Generated from /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/rt.jar #pragma once #include <fwd-POI.hpp> #include <java/awt/fwd-POI.hpp> #include <java/awt/Component_FlipBufferStrategy.hpp> #include <sun/awt/SubRegionShowable.hpp> struct default_init_tag; class java::awt::Component_FlipSubRegionBufferStrategy : public Component_FlipBufferStrategy , public virtual ::sun::awt::SubRegionShowable { public: typedef Component_FlipBufferStrategy super; public: /* package */ Component* this$0 { }; protected: void ctor(int32_t numBuffers, BufferCapabilities* caps); public: void show(int32_t x1, int32_t y1, int32_t x2, int32_t y2) override; bool showIfNotLost(int32_t x1, int32_t y1, int32_t x2, int32_t y2) override; // Generated public: /* protected */ Component_FlipSubRegionBufferStrategy(Component *Component_this, int32_t numBuffers, BufferCapabilities* caps); protected: Component_FlipSubRegionBufferStrategy(Component *Component_this, const ::default_init_tag&); public: static ::java::lang::Class *class_(); void show(); private: virtual ::java::lang::Class* getClass0(); };
[ "zhang.chen.yu@outlook.com" ]
zhang.chen.yu@outlook.com
dd4f072b9cfa9999d3c983137a21f961865a0aa8
1af49694004c6fbc31deada5618dae37255ce978
/weblayer/browser/persistence/browser_persistence_common.cc
9ca03a353d28daee692aa1e9a51d78be7d098bd8
[ "BSD-3-Clause" ]
permissive
sadrulhc/chromium
59682b173a00269ed036eee5ebfa317ba3a770cc
a4b950c23db47a0fdd63549cccf9ac8acd8e2c41
refs/heads/master
2023-02-02T07:59:20.295144
2020-12-01T21:32:32
2020-12-01T21:32:32
317,678,056
3
0
BSD-3-Clause
2020-12-01T21:56:26
2020-12-01T21:56:25
null
UTF-8
C++
false
false
6,839
cc
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "weblayer/browser/persistence/browser_persistence_common.h" #include "components/sessions/content/content_serialized_navigation_builder.h" #include "components/sessions/content/session_tab_helper.h" #include "components/sessions/core/session_command.h" #include "components/sessions/core/session_service_commands.h" #include "components/sessions/core/session_types.h" #include "content/public/browser/browser_url_handler.h" #include "content/public/browser/dom_storage_context.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/storage_partition.h" #include "weblayer/browser/browser_context_impl.h" #include "weblayer/browser/browser_impl.h" #include "weblayer/browser/profile_impl.h" #include "weblayer/browser/tab_impl.h" namespace weblayer { namespace { void ProcessRestoreCommands( BrowserImpl* browser, const std::vector<std::unique_ptr<sessions::SessionWindow>>& windows) { if (windows.empty() || windows[0]->tabs.empty()) return; const bool had_tabs = !browser->GetTabs().empty(); content::BrowserContext* browser_context = browser->profile()->GetBrowserContext(); for (int i = 0; i < static_cast<int>(windows[0]->tabs.size()); ++i) { const sessions::SessionTab& session_tab = *(windows[0]->tabs[i]); if (session_tab.navigations.empty()) continue; // Associate sessionStorage (if any) to the restored tab. scoped_refptr<content::SessionStorageNamespace> session_storage_namespace; if (!session_tab.session_storage_persistent_id.empty()) { session_storage_namespace = content::BrowserContext::GetDefaultStoragePartition(browser_context) ->GetDOMStorageContext() ->RecreateSessionStorage( session_tab.session_storage_persistent_id); } const int selected_navigation_index = session_tab.normalized_navigation_index(); GURL restore_url = session_tab.navigations[selected_navigation_index].virtual_url(); content::SessionStorageNamespaceMap session_storage_namespace_map; session_storage_namespace_map[std::string()] = session_storage_namespace; content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( &restore_url, browser_context); content::WebContents::CreateParams create_params( browser_context, content::SiteInstance::ShouldAssignSiteForURL(restore_url) ? content::SiteInstance::CreateForURL(browser_context, restore_url) : nullptr); create_params.initially_hidden = true; create_params.desired_renderer_state = content::WebContents::CreateParams::kNoRendererProcess; create_params.last_active_time = session_tab.last_active_time; std::unique_ptr<content::WebContents> web_contents = content::WebContents::CreateWithSessionStorage( create_params, session_storage_namespace_map); std::vector<std::unique_ptr<content::NavigationEntry>> entries = sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( session_tab.navigations, browser_context); blink::UserAgentOverride ua_override; ua_override.ua_string_override = session_tab.user_agent_override.ua_string_override; ua_override.ua_metadata_override = blink::UserAgentMetadata::Demarshal( session_tab.user_agent_override.opaque_ua_metadata_override); web_contents->SetUserAgentOverride(ua_override, false); // CURRENT_SESSION matches what clank does. On the desktop, we should // use a different type. web_contents->GetController().Restore(selected_navigation_index, content::RestoreType::CURRENT_SESSION, &entries); DCHECK(entries.empty()); TabImpl* tab = browser->CreateTabForSessionRestore(std::move(web_contents), session_tab.guid); tab->SetData(session_tab.data); if (!had_tabs && i == (windows[0])->selected_tab_index) browser->SetActiveTab(tab); } if (!had_tabs && !browser->GetTabs().empty() && !browser->GetActiveTab()) browser->SetActiveTab(browser->GetTabs().back()); } } // namespace void RestoreBrowserState( BrowserImpl* browser, std::vector<std::unique_ptr<sessions::SessionCommand>> commands) { std::vector<std::unique_ptr<sessions::SessionWindow>> windows; SessionID active_window_id = SessionID::InvalidValue(); sessions::RestoreSessionFromCommands(commands, &windows, &active_window_id); ProcessRestoreCommands(browser, windows); if (browser->GetTabs().empty()) { // Nothing to restore, or restore failed. Create a default tab. browser->SetActiveTab( browser->CreateTabForSessionRestore(nullptr, std::string())); } } std::vector<std::unique_ptr<sessions::SessionCommand>> BuildCommandsForTabConfiguration(const SessionID& browser_session_id, TabImpl* tab, int index_in_browser) { DCHECK(tab); std::vector<std::unique_ptr<sessions::SessionCommand>> result; const SessionID& tab_id = GetSessionIDForTab(tab); result.push_back( sessions::CreateSetTabWindowCommand(browser_session_id, tab_id)); result.push_back(sessions::CreateLastActiveTimeCommand( tab_id, tab->web_contents()->GetLastActiveTime())); const blink::UserAgentOverride& ua_override = tab->web_contents()->GetUserAgentOverride(); if (!ua_override.ua_string_override.empty()) { sessions::SerializedUserAgentOverride serialized_override; serialized_override.ua_string_override = ua_override.ua_string_override; serialized_override.opaque_ua_metadata_override = blink::UserAgentMetadata::Marshal(ua_override.ua_metadata_override); result.push_back(sessions::CreateSetTabUserAgentOverrideCommand( tab_id, serialized_override)); } if (index_in_browser != -1) { result.push_back( sessions::CreateSetTabIndexInWindowCommand(tab_id, index_in_browser)); } result.push_back(sessions::CreateSetSelectedNavigationIndexCommand( tab_id, tab->web_contents()->GetController().GetCurrentEntryIndex())); result.push_back(sessions::CreateSetTabGuidCommand(tab_id, tab->GetGuid())); result.push_back(sessions::CreateSetTabDataCommand(tab_id, tab->GetData())); return result; } const SessionID& GetSessionIDForTab(Tab* tab) { sessions::SessionTabHelper* session_tab_helper = sessions::SessionTabHelper::FromWebContents( static_cast<TabImpl*>(tab)->web_contents()); DCHECK(session_tab_helper); return session_tab_helper->session_id(); } } // namespace weblayer
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
3d7ed6207744f784cd5a8f726d1677116db39813
c91128bbbe14c05ac4d4f0a5d669f87521e24a8e
/mongoTestWriteOne.cpp
b53d8523281add75f879524a51a44467885a656d
[ "Apache-2.0" ]
permissive
arangodb/1mDocsPerSec
4a82f76ee0f05651c14ffbe57f7bc3b0eb575344
9812eaf7a1d412cd22917d579f03d1e55ac59436
refs/heads/master
2021-01-17T06:48:36.654982
2016-07-18T23:54:07
2016-07-18T23:54:07
46,554,641
10
0
null
null
null
null
UTF-8
C++
false
false
1,950
cpp
#include "utils.h" #include <mongo/bson/bson.h> #include <mongo/client/dbclient.h> int N = 100000; int main(int argc, char* argv[]) { if (argc < 3) { std::cout << "Need HOST and PORT as command line arguments." << std::endl; return 1; } if (argc >= 4) { N = atoi(argv[3]); } std::string resulturl; if (argc >= 5) { resulturl = argv[4]; } std::cout << "MongoDB latency test, calling " << N << " times insert()" << std::endl; std::vector<uint64_t> timings; timings.reserve(N); mongo::client::initialize(); mongo::DBClientConnection c; std::string serverendpoint(argv[1]); serverendpoint.push_back(':'); serverendpoint.append(argv[2]); std::cout << "MongoDB server endpoint: " << serverendpoint << std::endl; try { c.connect(serverendpoint); std::cout << "connected ok" << std::endl; } catch( const mongo::DBException &e ) { std::cout << "caught " << e.what() << std::endl; return 2; } mongo::BSONObjBuilder builder; builder << "name" << "Neunhöffer" << "firstName" << "Max"; mongo::BSONObj p = builder.obj(); timePointType t = timeNow(); uint64_t s = 0; timePointType t3, t4; for (int i = 0; i < N; i++) { t3 = timeNow(); c.insert("test.guck2", p); std::string error = c.getLastError(); if (error != "") { s += 1; } t4 = timeNow(); timings.push_back(timeDiff(t3,t4)); } timePointType t2 = timeNow(); std::cout << "Total count: " << s << std::endl; uint64_t d = timeDiff(t,t2); std::cout << "Number of errors: " << s << std::endl; std::cout << "Total time: " << d << " ns" << std::endl; analyzeTimings("mongoTestWriteOne" + std::to_string(getpid()) + ".times", timings, 0); dumpTimings("mongoTestWriteOne" + std::to_string(getpid()) + ".times", timings); if (! resulturl.empty()) { submitTimings(resulturl, "mongoWriteOne", timings, 0); } return 0; }
[ "max@arangodb.com" ]
max@arangodb.com
bb2062c154fc3322ec3a74385f9431666e5d546d
013dad21e759fd4e5c55bea93fccd6ddc30e8143
/Hand.h
20a4436ffd30840d2eac03884b60d357f201f5c8
[]
no_license
Burhan-Khawaja/Mexicantrain
2be34229c6a71a2d4eba744b10eefdee3ac44918
b008e1d031a63087228d9604290950b7f408aa72
refs/heads/main
2023-08-07T03:08:44.697395
2021-09-28T23:00:24
2021-09-28T23:00:24
404,874,450
0
0
null
null
null
null
UTF-8
C++
false
false
4,576
h
#pragma once #include <iostream> #include <vector> #include "Tile.h" class Hand { public: /* ********************************************************************* Function Name: Hand Purpose: Default constructor for hand object Parameters: None Return Value: None Assistance Received: none ********************************************************************* */ Hand(); /* ********************************************************************* Function Name: addTile Purpose: Add a tile to our hand, which is a vecto Parameters: tileToAdd which is an object of type Tile Return Value: none Algorithm: call push_back on our vector with the Tile as a parameter. Assistance Received: none ********************************************************************* */ void addTile(Tile tileToAdd); /* ********************************************************************* Function Name: removeTile Purpose: Remove a tile from our hand, based on index. Parameters: tileToRemove - integer value that is the index we want to remove. Return Value: none Algorithm: Assistance Received: none ********************************************************************* */ void removeTile(int tileToRemove); /* ********************************************************************* Function Name: removeTile Purpose: Remove a tile from our hand, based on the value of the tile. Parameters: index1- an integer that is the 1 of the 2 numbers of the tile index2- an integer that is the second number of the tile we want to remove Return Value: none Algorithm: 1)Create a tile with the 2 values given as the tiles numbers 2)call the erase function of the vector and search the array from beginning to end for the tile we created in step 1 when the tile is found, it will be removed. Assistance Received: none ********************************************************************* */ void removeTile(int index1, int index2); /* ********************************************************************* Function Name: printHand Purpose: Print all the tile in a user's hand to the console. Parameters: None Return Value: none Assistance Received: none ********************************************************************* */ void printHand(); /* ********************************************************************* Function Name: getTile Purpose: get a tile from the hand Parameters: index - integer value that is the index and we get the tile at that index. Return Value: Tile object, represents the tile at the index position. Assistance Received: none ********************************************************************* */ Tile getTile(int index); /* ********************************************************************* Function Name: getSize Purpose: get size of users hand. Parameters: None Return Value: const int, the size of the users hand Assistance Received: none ********************************************************************* */ int const getSize(); /* ********************************************************************* Function Name: operator[] Purpose: Overload array indexing operators Parameters: index, integer value of what vector spot we want to access Return Value: the tile at the index we want to access, Tile object Assistance Received: none ********************************************************************* */ Tile& operator[](int index); /* ********************************************************************* Function Name: clearHand Purpose: Empty the user's hand Parameters: None Return Value: None Assistance Received: none ********************************************************************* */ void clearHand(); /* ********************************************************************* Function Name: getHand Purpose: return the vector that has the user's hand data. Parameters: None Return Value: Returns a copy of the user's hand, as a vector of Tile objects. Assistance Received: none ********************************************************************* */ const std::vector<Tile> getHand(); protected: private: //stores the user's tiles. std::vector<Tile> m_hand; };
[ "noreply@github.com" ]
noreply@github.com
29f4d114be439495495e57ec08df1b6aefd46275
f90342b5793b5f320a0d6fc6c77fd68168dbd2d1
/sorting/homework2/kthlargest.cc
7007ff6aa9fc0b84758c5e2d7a0b022e89f9ccb4
[]
no_license
vivekh-git/prepare
1edddaa9696b52dd005adc221be6f5e0f2562809
7def24c5d8d321e7937e3dc1135a3eaa1f751622
refs/heads/master
2020-03-22T02:52:36.325502
2018-07-02T06:05:56
2018-07-02T06:05:56
139,398,647
0
0
null
null
null
null
UTF-8
C++
false
false
1,603
cc
#include <bits/stdc++.h> using namespace std; class Solution { public: void swap(vector<int>& arr, int pos1, int pos2) { int tmp = arr[pos1]; arr[pos1] = arr[pos2]; arr[pos2] = tmp; } int partition(vector<int>& arr, int start, int end) { int pivot = end; int lo = start; int hi = start; while (hi < end) { if (arr[hi] < arr[pivot]) { swap(arr, hi, lo); lo++; hi++; } else { hi++; } } swap(arr, end, lo); return lo; } int randomPartition(vector<int>& nums, int start, int end) { //int width = end-start+1; //int r = rand()%width; //swap(nums, end, start+r); return partition(nums, start, end); } int findkthlargest(vector<int>& nums, int start, int end, int k) { if (k > 0 && k <= end-start+1) { int pivot = randomPartition(nums, start, end); if (k-1 == end-pivot) return nums[pivot]; else if (end-pivot < k-1) return findkthlargest(nums, start, pivot-1, (k-(end-pivot+1))); else return findkthlargest(nums, pivot+1, end, k); } return INT_MIN; } int findKthLargest(vector<int>& nums, int k) { return findkthlargest(nums, 0, nums.size()-1, k); } }; int main() { vector<int> arr = {3,2,3,1,2,4,5,5,6}; int k = 4; Solution sol; int res = sol.findKthLargest(arr, k); cout << "res = " << res << endl; return 0; }
[ "vivekh@viveks-air.lan" ]
vivekh@viveks-air.lan
55828c59533b9d73bc65ef4643756e9bb99b10b4
bf407f1974b5e7a3258973768ada4151d3227dfd
/test/src/box/test_skip.cpp
5b12c15e567a74a88d000ac23973fa952bfece20
[ "BSD-3-Clause" ]
permissive
wprayudo/petro
bc536728dca98e1d17f7a6a3013a084df163cfb8
a4c8b702fec59a33ce1b46c6d92d97bc143cf9c6
refs/heads/master
2020-06-03T13:45:15.787872
2017-04-07T00:21:36
2017-04-07T00:21:36
94,132,296
1
0
null
2017-06-12T19:22:27
2017-06-12T19:22:27
null
UTF-8
C++
false
false
391
cpp
// Copyright (c) Steinwurf ApS 2016. // All Rights Reserved // // Distributed under the "BSD License". See the accompanying LICENSE.rst file. #include <petro/box/skip.hpp> #include <petro/box/box.hpp> #include <gtest/gtest.h> #include <memory> TEST(box_test_skip, construct) { std::weak_ptr<petro::box::box> parent; petro::box::skip b(parent); EXPECT_EQ("skip", b.type()); }
[ "jpihl08@gmail.com" ]
jpihl08@gmail.com
bc12336c408066dbf9779a1de9eaafad9c15898b
421f5b6d1a471a554ba99f6052ebc39a67581c96
/Codeforces/Round 302 - Div 2/2. Sea and Islands.cpp
57fd6800273f776840c5ed6d56c80982b7d11c9e
[]
no_license
avinashw50w/practice_problems
045a2a60998dcf2920a1443319f958ede4f58385
1968132eccddb1edeb68babaa05aaa81a7c8ecf3
refs/heads/master
2022-08-31T08:39:19.934398
2022-08-10T16:11:35
2022-08-10T16:11:35
193,635,081
0
0
null
null
null
null
UTF-8
C++
false
false
1,826
cpp
/*A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island). Find a way to cover some cells with sand so that exactly k islands appear on the n × n map, or determine that no such way exists. Input The single line contains two positive integers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ n2) — the size of the map and the number of islands you should form. Output If the answer doesn't exist, print "NO" (without the quotes) in a single line. Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n. If there are multiple answers, you may print any of them. You should not maximize the sizes of islands. Examples inputCopy 5 2 output YES SSSSS LLLLL SSSSS LLLLL SSSSS*/ #include <iostream> using namespace std; int n, k; int main() { cin >> n >> k; if((n*n + 1)/2 > k) { cout << "NO\n"; return 0; } for(int i = 1; i <= n; ++i) { for(int j = 1; j <= n; ++j) printf((i+j)&1 == 0 && k-- ? "L" : "S"); printf("\n"); } }
[ "avinash.kumar@seenit.in" ]
avinash.kumar@seenit.in
f04617048f52f048f9d7bdf462562c6a768e100f
e7b39265f5432339eaaa78216e302bafd4dfe80d
/ReadNoise_DB.cpp
e8fec3541c4dbcc10e54eab2928776ce139b65e7
[]
no_license
fedmante/NoiseValidation
f889b0e6d0dc84958abb6b2b00c6780826cb9509
6f45004c76a6eec4d95fcc1763ab6051ba96ed62
refs/heads/master
2021-01-20T10:21:29.299387
2015-02-10T16:32:23
2015-02-10T16:32:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
32,697
cpp
/************************************************************* simple program to read bin files compile with ---> c++ -o ReadNoise_DB `root-config --cflags --glibs` ReadNoise_DB.cpp geometryUtils.cc or with ---> c++ -o ReadNoise_DB ReadNoise_DB.cpp `root-config --cflags --glibs` geometryUtils.cc run with ---> ./ReadNoise_DB dump_list_DB.txt chstatus_list_DB.txt 3 *************************************************************/ #include <fstream> #include <iostream> #include <stdlib.h> #include <sstream> #include "TFile.h" #include "TH1F.h" #include "TH2F.h" #include "TGraphErrors.h" #include "geometryUtils.h" std::vector<std::string> splitString(std::string& inputName, char split_char); int main(int argc, char** argv) { char* inputLISTNoise = argv[1]; char* inputLISTChStatus = argv[2]; int cutChStatus = atoi(argv[3]); std::string inputListNoise = std::string(inputLISTNoise); std::string inputListChStatus = std::string(inputLISTChStatus); std::cout << "inputListNoise = " << inputListNoise << std::endl; std::cout << "inputListChStatus = " << inputListChStatus << std::endl; std::cout << "cutChStatus = " << cutChStatus << std::endl; std::vector<std::string> inputFiles; std::vector<std::string> inputFilesChStatus; char dumps[500]; FILE *f_dumps; f_dumps = fopen(inputListNoise.c_str(),"r"); while(fscanf(f_dumps,"%s \n", dumps) !=EOF ){ //std::cout << "Reading inputFile: " << dumps << std::endl; std::string DUMPS = std::string(dumps); if(DUMPS.find("#") != std::string::npos) continue; inputFiles.push_back(DUMPS); } f_dumps = fopen(inputListChStatus.c_str(),"r"); while(fscanf(f_dumps,"%s \n", dumps) !=EOF ){ //std::cout << "Reading inputFile: " << dumps << std::endl; std::string DUMPS = std::string(dumps); if(DUMPS.find("#") != std::string::npos) continue; inputFilesChStatus.push_back(DUMPS); } std::map<int,std::pair<int,int> > mapChStatusRun; for(unsigned int ii = 0; ii < inputFilesChStatus.size(); ii++) { std::string inputName = splitString(inputFilesChStatus.at(ii),'/').at(splitString(inputFilesChStatus.at(ii),'/').size()-1); std::vector<std::string> tokens = splitString(inputName,'_'); tokens.at(6) = tokens.at(6).erase(0,2); tokens.at(8) = tokens.at(8).erase(tokens.at(8).size()-4,tokens.at(8).size()); tokens.at(8) = tokens.at(8).erase(0,2); mapChStatusRun[ii] = std::make_pair(atoi(tokens.at(6).c_str()),atoi(tokens.at(8).c_str())); } TH1F* h_Ped_EB_g12[100][3]; TH1F* h_Ped_EB_g6[100][3]; TH1F* h_Ped_EB_g1[100][3]; TH1F* h_RMS_EB_g12[100][3]; TH1F* h_RMS_EB_g6[100][3]; TH1F* h_RMS_EB_g1[100][3]; TH1F* h_Ped_EE_g12[40][3]; TH1F* h_Ped_EE_g6[40][3]; TH1F* h_Ped_EE_g1[40][3]; TH1F* h_RMS_EE_g12[40][3]; TH1F* h_RMS_EE_g6[40][3]; TH1F* h_RMS_EE_g1[40][3]; TH2F* h2_NoiseChannels_EB_g12_1sigma; TH2F* h2_NoiseChannels_EE_g12_1sigma[3]; TH2F* h2_NoiseChannels_EB_g12_2sigma; TH2F* h2_NoiseChannels_EE_g12_2sigma[3]; TH2F* h2_NoiseChannels_EB_g6_1sigma; TH2F* h2_NoiseChannels_EE_g6_1sigma[3]; TH2F* h2_NoiseChannels_EB_g6_2sigma; TH2F* h2_NoiseChannels_EE_g6_2sigma[3]; TH2F* h2_NoiseChannels_EB_g1_1sigma; TH2F* h2_NoiseChannels_EE_g1_1sigma[3]; TH2F* h2_NoiseChannels_EB_g1_2sigma; TH2F* h2_NoiseChannels_EE_g1_2sigma[3]; TEndcapRegions* eeId = new TEndcapRegions(); TGraphErrors* g_Ped_EB_g12[3]; TGraphErrors* g_Ped_EB_g6[3]; TGraphErrors* g_Ped_EB_g1[3]; TGraphErrors* g_Ped_EE_g12[3]; TGraphErrors* g_Ped_EE_g6[3]; TGraphErrors* g_Ped_EE_g1[3]; TGraphErrors* g_RMS_EB_g12[3]; TGraphErrors* g_RMS_EB_g6[3]; TGraphErrors* g_RMS_EB_g1[3]; TGraphErrors* g_RMS_EE_g12[3]; TGraphErrors* g_RMS_EE_g6[3]; TGraphErrors* g_RMS_EE_g1[3]; TGraphErrors* g_RMS_EB_g12_1sigma[3]; TGraphErrors* g_RMS_EB_g6_1sigma[3]; TGraphErrors* g_RMS_EB_g1_1sigma[3]; TGraphErrors* g_RMS_EE_g12_1sigma[3]; TGraphErrors* g_RMS_EE_g6_1sigma[3]; TGraphErrors* g_RMS_EE_g1_1sigma[3]; TGraphErrors* g_RMS_EB_g12_2sigma[3]; TGraphErrors* g_RMS_EB_g6_2sigma[3]; TGraphErrors* g_RMS_EB_g1_2sigma[3]; TGraphErrors* g_RMS_EE_g12_2sigma[3]; TGraphErrors* g_RMS_EE_g6_2sigma[3]; TGraphErrors* g_RMS_EE_g1_2sigma[3]; for(int iz = 0; iz<3; iz++){ g_Ped_EB_g12[iz]= new TGraphErrors(); g_Ped_EB_g6[iz]= new TGraphErrors(); g_Ped_EB_g1[iz]= new TGraphErrors(); g_Ped_EE_g12[iz]= new TGraphErrors(); g_Ped_EE_g6[iz]= new TGraphErrors(); g_Ped_EE_g1[iz]= new TGraphErrors(); g_RMS_EB_g12[iz]= new TGraphErrors(); g_RMS_EB_g6[iz]= new TGraphErrors(); g_RMS_EB_g1[iz]= new TGraphErrors(); g_RMS_EE_g12[iz]= new TGraphErrors(); g_RMS_EE_g6[iz]= new TGraphErrors(); g_RMS_EE_g1[iz]= new TGraphErrors(); g_RMS_EB_g12_1sigma[iz]= new TGraphErrors(); g_RMS_EB_g6_1sigma[iz]= new TGraphErrors(); g_RMS_EB_g1_1sigma[iz]= new TGraphErrors(); g_RMS_EE_g12_1sigma[iz]= new TGraphErrors(); g_RMS_EE_g6_1sigma[iz]= new TGraphErrors(); g_RMS_EE_g1_1sigma[iz]= new TGraphErrors(); g_RMS_EB_g12_2sigma[iz]= new TGraphErrors(); g_RMS_EB_g6_2sigma[iz]= new TGraphErrors(); g_RMS_EB_g1_2sigma[iz]= new TGraphErrors(); g_RMS_EE_g12_2sigma[iz]= new TGraphErrors(); g_RMS_EE_g6_2sigma[iz]= new TGraphErrors(); g_RMS_EE_g1_2sigma[iz]= new TGraphErrors(); } std::map<int,std::map<int,std::map<int,float> > > noiseMap_g12; std::map<int,std::map<int,std::map<int,float> > > noiseMap_g6; std::map<int,std::map<int,std::map<int,float> > > noiseMap_g1; for(unsigned int ii = 0; ii < inputFiles.size(); ii++){ char Name[500]; for(int ieta = 0; ieta<100; ieta++) for(int iz = 0; iz<3; iz++){ if(iz == 1) continue; sprintf(Name,"h_Ped_EB_g12_%d_%d",ieta+1,iz-1); h_Ped_EB_g12[ieta][iz]=new TH1F(Name,Name,50000,0.,500.); sprintf(Name,"h_Ped_EB_g6_%d_%d",ieta+1,iz-1); h_Ped_EB_g6[ieta][iz]=new TH1F(Name,Name,50000,0.,500.); sprintf(Name,"h_Ped_EB_g1_%d_%d",ieta+1,iz-1); h_Ped_EB_g1[ieta][iz]=new TH1F(Name,Name,50000,0.,500.); sprintf(Name,"h_RMS_EB_g12_%d_%d",ieta+1,iz-1); h_RMS_EB_g12[ieta][iz]=new TH1F(Name,Name,1500,0.,15.); sprintf(Name,"h_RMS_EB_g6_%d_%d",ieta+1,iz-1); h_RMS_EB_g6[ieta][iz]=new TH1F(Name,Name,1500,0.,15.); sprintf(Name,"h_RMS_EB_g1_%d_%d",ieta+1,iz-1); h_RMS_EB_g1[ieta][iz]=new TH1F(Name,Name,1500,0.,15.); } for(int ir = 0; ir<40; ir++) for(int iz = 0; iz<3; iz++){ if(iz == 1) continue; sprintf(Name,"h_Ped_EE_g12_%d_%d",ir+1,iz-1); h_Ped_EE_g12[ir][iz]=new TH1F(Name,Name,50000,0.,500.); sprintf(Name,"h_Ped_EE_g6_%d_%d",ir+1,iz-1); h_Ped_EE_g6[ir][iz]=new TH1F(Name,Name,50000,0.,500.); sprintf(Name,"h_Ped_EE_g1_%d_%d",ir+1,iz-1); h_Ped_EE_g1[ir][iz]=new TH1F(Name,Name,50000,0.,500.); sprintf(Name,"h_RMS_EE_g12_%d_%d",ir+1,iz-1); h_RMS_EE_g12[ir][iz]=new TH1F(Name,Name,1500,0.,15.); sprintf(Name,"h_RMS_EE_g6_%d_%d",ir+1,iz-1); h_RMS_EE_g6[ir][iz]=new TH1F(Name,Name,1500,0.,15.); sprintf(Name,"h_RMS_EE_g1_%d_%d",ir+1,iz-1); h_RMS_EE_g1[ir][iz]=new TH1F(Name,Name,1500,0.,15.); } h2_NoiseChannels_EB_g12_1sigma = new TH2F("h2_NoiseChannels_EB_g12_1sigma","h2_NoiseChannels_EB_g12_1sigma",360,0,360,170,-85,85); h2_NoiseChannels_EB_g12_2sigma = new TH2F("h2_NoiseChannels_EB_g12_2sigma","h2_NoiseChannels_EB_g12_2sigma",360,0,360,170,-85,85); h2_NoiseChannels_EB_g6_1sigma = new TH2F("h2_NoiseChannels_EB_g6_1sigma","h2_NoiseChannels_EB_g6_1sigma",360,0,360,170,-85,85); h2_NoiseChannels_EB_g6_2sigma = new TH2F("h2_NoiseChannels_EB_g6_2sigma","h2_NoiseChannels_EB_g6_2sigma",360,0,360,170,-85,85); h2_NoiseChannels_EB_g1_1sigma = new TH2F("h2_NoiseChannels_EB_g1_1sigma","h2_NoiseChannels_EB_g1_1sigma",360,0,360,170,-85,85); h2_NoiseChannels_EB_g1_2sigma = new TH2F("h2_NoiseChannels_EB_g1_2sigma","h2_NoiseChannels_EB_g1_2sigma",360,0,360,170,-85,85); for(int iz = 0; iz<3; iz++){ if(iz == 1) continue; sprintf(Name,"h2_NoiseChannels_EE_g12_1sigma_%d",iz-1); h2_NoiseChannels_EE_g12_1sigma[iz] = new TH2F(Name,Name,100,1,101,100,1,101); sprintf(Name,"h2_NoiseChannels_EE_g12_2sigma_%d",iz-1); h2_NoiseChannels_EE_g12_2sigma[iz] = new TH2F(Name,Name,100,1,101,100,1,101); sprintf(Name,"h2_NoiseChannels_EE_g6_1sigma_%d",iz-1); h2_NoiseChannels_EE_g6_1sigma[iz] = new TH2F(Name,Name,100,1,101,100,1,101); sprintf(Name,"h2_NoiseChannels_EE_g6_2sigma_%d",iz-1); h2_NoiseChannels_EE_g6_2sigma[iz] = new TH2F(Name,Name,100,1,101,100,1,101); sprintf(Name,"h2_NoiseChannels_EE_g1_1sigma_%d",iz-1); h2_NoiseChannels_EE_g1_1sigma[iz] = new TH2F(Name,Name,100,1,101,100,1,101); sprintf(Name,"h2_NoiseChannels_EE_g1_2sigma_%d",iz-1); h2_NoiseChannels_EE_g1_2sigma[iz] = new TH2F(Name,Name,100,1,101,100,1,101); } std::cout << "Reading inputFile: " << inputFiles.at(ii) << std::endl; std::string inputName = splitString(inputFiles.at(ii),'/').at(splitString(inputFiles.at(ii),'/').size()-1); std::vector<std::string> tokens = splitString(inputName,'_'); tokens.at(5) = tokens.at(5).erase(0,2); tokens.at(7) = tokens.at(7).erase(tokens.at(7).size()-4,tokens.at(7).size()); tokens.at(7) = tokens.at(7).erase(0,2); int run_min = atoi(tokens.at(5).c_str()); int run_max = atoi(tokens.at(7).c_str()); int iFile=0; for(unsigned int jj = 0; jj < mapChStatusRun.size(); jj++) if(run_max >= mapChStatusRun[jj].first && run_max <= mapChStatusRun[jj].second) iFile=jj; char cieta[100], ciphi[100], ciz[100], crawid[100], cped12[100], crms12[100], cped6[100], crms6[100], cped1[100], crms1[100]; int ieta, iphi, ix, iy, iz, chStatus; long int rawid; float ped12, rms12, ped6, rms6, ped1, rms1; std::cout << "Reading inputFileChStatus: " << inputFilesChStatus.at(iFile) << std::endl; std::map<int,std::map<int,std::map<int,int> > > ichStatus; std::ifstream infileChStatus(inputFilesChStatus.at(iFile).c_str()); while(infileChStatus >> ieta >> iphi >> iz >> chStatus) { ichStatus[ieta][iphi][iz]=chStatus; } TFile *myOutFile = new TFile(("NoisePlots_DB_"+tokens.at(5)+"_"+tokens.at(7)+".root").c_str(),"RECREATE"); std::ifstream infile(inputFiles.at(ii).c_str()); int iline = 0; std::string line; noiseMap_g12.clear(); noiseMap_g6.clear(); noiseMap_g1.clear(); while(infile >> cieta >> ciphi >> ciz >> cped12 >> crms12 >> cped6 >> crms6 >> cped1 >> crms1 >> crawid) { iline++; if(iline > 1 && iline <= 61201){ ieta = atoi(cieta); iphi = atoi(ciphi); iz = atoi(ciz); rawid = atol(crawid); ped12 = atof(cped12); rms12 = atof(crms12); ped6 = atof(cped6); rms6 = atof(crms6); ped1 = atof(cped1); rms1 = atof(crms1); if(ped12 == -999 || rms12 == -999) continue; if(ichStatus[ieta][iphi][iz]>cutChStatus) continue; if(ieta < 0){ ieta = abs(ieta)-1; iz = 0; } else if(ieta > 0){ ieta = ieta-1; iz = 2; } h_Ped_EB_g12[ieta][iz]->Fill(ped12); h_RMS_EB_g12[ieta][iz]->Fill(4.*rms12); h_Ped_EB_g6[ieta][iz]->Fill(ped6); h_RMS_EB_g6[ieta][iz]->Fill(4.*rms6); h_Ped_EB_g1[ieta][iz]->Fill(ped1); h_RMS_EB_g1[ieta][iz]->Fill(4.*rms1); noiseMap_g12[ieta][iphi][iz]=4*rms12; noiseMap_g6[ieta][iphi][iz]=4*rms6; noiseMap_g1[ieta][iphi][iz]=4*rms1; }else if(iline > 61201){ ix = atoi(cieta); iy = atoi(ciphi); iz = atoi(ciz); rawid = atol(crawid); ped12 = atof(cped12); rms12 = atof(crms12); ped6 = atof(cped6); rms6 = atof(crms6); ped1 = atof(cped1); rms1 = atof(crms1); if(ped12 == -999 || rms12 == -999) continue; if(ichStatus[ieta][iphi][iz]>cutChStatus) continue; int ir = eeId->GetEndcapRing(ix,iy,iz); h_Ped_EE_g12[ir][iz+1]->Fill(ped12); h_RMS_EE_g12[ir][iz+1]->Fill(4.*rms12); h_Ped_EE_g6[ir][iz+1]->Fill(ped6); h_RMS_EE_g6[ir][iz+1]->Fill(4.*rms6); h_Ped_EE_g1[ir][iz+1]->Fill(ped1); h_RMS_EE_g1[ir][iz+1]->Fill(4.*rms1); noiseMap_g12[ix][iy][iz]=4*rms12; noiseMap_g6[ix][iy][iz]=4*rms6; noiseMap_g1[ix][iy][iz]=4*rms1; } } myOutFile->cd(); for(int iETA = -85; iETA<=85; iETA++) for(int iPhi = 1; iPhi<=360; iPhi++){ int iZ = 0; int iEta = iETA; if(iEta==0) continue; if(iEta < 0){ iEta = abs(iEta)-1; iZ = 0; } else if(iEta > 0){ iEta = iEta-1; iZ = 2; } if(iZ==0){ if(noiseMap_g12[iEta][iPhi][iZ]>h_RMS_EB_g12[iEta][iZ]->GetMean()+1.*h_RMS_EB_g12[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g12_1sigma->SetBinContent(h2_NoiseChannels_EB_g12_1sigma->FindBin(iPhi,-iEta-1),noiseMap_g12[iEta][iPhi][iZ]/4.); if(noiseMap_g6[iEta][iPhi][iZ]>h_RMS_EB_g6[iEta][iZ]->GetMean()+1.*h_RMS_EB_g6[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g6_1sigma->SetBinContent(h2_NoiseChannels_EB_g6_1sigma->FindBin(iPhi,-iEta-1),noiseMap_g6[iEta][iPhi][iZ]/4.); if(noiseMap_g1[iEta][iPhi][iZ]>h_RMS_EB_g1[iEta][iZ]->GetMean()+1.*h_RMS_EB_g1[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g1_1sigma->SetBinContent(h2_NoiseChannels_EB_g1_1sigma->FindBin(iPhi,-iEta-1),noiseMap_g1[iEta][iPhi][iZ]/4.); if(noiseMap_g12[iEta][iPhi][iZ]>h_RMS_EB_g12[iEta][iZ]->GetMean()+2.*h_RMS_EB_g12[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g12_2sigma->SetBinContent(h2_NoiseChannels_EB_g12_2sigma->FindBin(iPhi,-iEta-1),noiseMap_g12[iEta][iPhi][iZ]/4.); if(noiseMap_g6[iEta][iPhi][iZ]>h_RMS_EB_g6[iEta][iZ]->GetMean()+2.*h_RMS_EB_g6[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g6_2sigma->SetBinContent(h2_NoiseChannels_EB_g6_2sigma->FindBin(iPhi,-iEta-1),noiseMap_g6[iEta][iPhi][iZ]/4.); if(noiseMap_g1[iEta][iPhi][iZ]>h_RMS_EB_g1[iEta][iZ]->GetMean()+2.*h_RMS_EB_g1[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g1_2sigma->SetBinContent(h2_NoiseChannels_EB_g1_2sigma->FindBin(iPhi,-iEta-1),noiseMap_g1[iEta][iPhi][iZ]/4.); }else if(iZ==2){ if(noiseMap_g12[iEta][iPhi][iZ]>h_RMS_EB_g12[iEta][iZ]->GetMean()+1.*h_RMS_EB_g12[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g12_1sigma->SetBinContent(h2_NoiseChannels_EB_g12_1sigma->FindBin(iPhi,iEta),noiseMap_g12[iEta][iPhi][iZ]/4.); if(noiseMap_g6[iEta][iPhi][iZ]>h_RMS_EB_g6[iEta][iZ]->GetMean()+1.*h_RMS_EB_g6[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g6_1sigma->SetBinContent(h2_NoiseChannels_EB_g6_1sigma->FindBin(iPhi,iEta),noiseMap_g6[iEta][iPhi][iZ]/4.); if(noiseMap_g1[iEta][iPhi][iZ]>h_RMS_EB_g1[iEta][iZ]->GetMean()+1.*h_RMS_EB_g1[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g1_1sigma->SetBinContent(h2_NoiseChannels_EB_g1_1sigma->FindBin(iPhi,iEta),noiseMap_g1[iEta][iPhi][iZ]/4.); if(noiseMap_g12[iEta][iPhi][iZ]>h_RMS_EB_g12[iEta][iZ]->GetMean()+2.*h_RMS_EB_g12[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g12_2sigma->SetBinContent(h2_NoiseChannels_EB_g12_2sigma->FindBin(iPhi,iEta),noiseMap_g12[iEta][iPhi][iZ]/4.); if(noiseMap_g6[iEta][iPhi][iZ]>h_RMS_EB_g6[iEta][iZ]->GetMean()+2.*h_RMS_EB_g6[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g6_2sigma->SetBinContent(h2_NoiseChannels_EB_g6_2sigma->FindBin(iPhi,iEta),noiseMap_g6[iEta][iPhi][iZ]/4.); if(noiseMap_g1[iEta][iPhi][iZ]>h_RMS_EB_g1[iEta][iZ]->GetMean()+2.*h_RMS_EB_g1[iEta][iZ]->GetRMS()) h2_NoiseChannels_EB_g1_2sigma->SetBinContent(h2_NoiseChannels_EB_g1_2sigma->FindBin(iPhi,iEta),noiseMap_g1[iEta][iPhi][iZ]/4.); } } for(int iX = 1; iX<=100; iX++) for(int iY = 1; iY<=100; iY++) for(int iZ = 0; iZ<3; iZ++){ if(iZ == 1) continue; if(noiseMap_g12[iX][iY][iZ-1]==0) continue; int iR = eeId->GetEndcapRing(iX,iY,iZ); if(noiseMap_g12[iX][iY][iZ-1]>h_RMS_EE_g12[iR][iZ]->GetMean()+1.*h_RMS_EE_g12[iR][iZ]->GetRMS()) h2_NoiseChannels_EE_g12_1sigma[iZ]->SetBinContent(h2_NoiseChannels_EE_g12_1sigma[iZ]->FindBin(iX,iY),noiseMap_g12[iX][iY][iZ-1]/4.); if(noiseMap_g6[iX][iY][iZ-1]>h_RMS_EE_g6[iR][iZ]->GetMean()+1.*h_RMS_EE_g6[iR][iZ]->GetRMS()) h2_NoiseChannels_EE_g6_1sigma[iZ]->SetBinContent(h2_NoiseChannels_EE_g6_1sigma[iZ]->FindBin(iX,iY),noiseMap_g6[iX][iY][iZ-1]/4.); if(noiseMap_g1[iX][iY][iZ-1]>h_RMS_EE_g1[iR][iZ]->GetMean()+1.*h_RMS_EE_g1[iR][iZ]->GetRMS()) h2_NoiseChannels_EE_g1_1sigma[iZ]->SetBinContent(h2_NoiseChannels_EE_g1_1sigma[iZ]->FindBin(iX,iY),noiseMap_g1[iX][iY][iZ-1]/4.); if(noiseMap_g12[iX][iY][iZ-1]>h_RMS_EE_g12[iR][iZ]->GetMean()+2.*h_RMS_EE_g12[iR][iZ]->GetRMS()) h2_NoiseChannels_EE_g12_2sigma[iZ]->SetBinContent(h2_NoiseChannels_EE_g12_2sigma[iZ]->FindBin(iX,iY),noiseMap_g12[iX][iY][iZ-1]/4.); if(noiseMap_g6[iX][iY][iZ-1]>h_RMS_EE_g6[iR][iZ]->GetMean()+2.*h_RMS_EE_g6[iR][iZ]->GetRMS()) h2_NoiseChannels_EE_g6_2sigma[iZ]->SetBinContent(h2_NoiseChannels_EE_g6_2sigma[iZ]->FindBin(iX,iY),noiseMap_g6[iX][iY][iZ-1]/4.); if(noiseMap_g1[iX][iY][iZ]>h_RMS_EE_g1[iR][iZ]->GetMean()+2.*h_RMS_EE_g1[iR][iZ]->GetRMS()) h2_NoiseChannels_EE_g1_2sigma[iZ]->SetBinContent(h2_NoiseChannels_EE_g1_2sigma[iZ]->FindBin(iX,iY),noiseMap_g1[iX][iY][iZ-1]/4.); } for(int iEta = 0; iEta<100; iEta++) for(int iZ = 0; iZ<3; iZ++){ if(iZ == 1) continue; if(h_Ped_EB_g12[iEta][iZ]->GetEntries() != 0){ g_Ped_EB_g12[iZ]->SetPoint(iEta,iEta+1,h_Ped_EB_g12[iEta][iZ]->GetMean()); g_Ped_EB_g12[iZ]->SetPointError(iEta,0,h_Ped_EB_g12[iEta][iZ]->GetRMS()); h_Ped_EB_g12[iEta][iZ]->Write(); } if(h_RMS_EB_g12[iEta][iZ]->GetEntries() != 0){ g_RMS_EB_g12[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g12[iEta][iZ]->GetMean()); g_RMS_EB_g12[iZ]->SetPointError(iEta,0,h_RMS_EB_g12[iEta][iZ]->GetRMS()); h_RMS_EB_g12[iEta][iZ]->Write(); h_RMS_EB_g12[iEta][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EB_g12[iEta][iZ]->GetMean()+2.*h_RMS_EB_g12[iEta][iZ]->GetRMS()); g_RMS_EB_g12_2sigma[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g12[iEta][iZ]->GetMean()); g_RMS_EB_g12_2sigma[iZ]->SetPointError(iEta,0,h_RMS_EB_g12[iEta][iZ]->GetRMS()); h_RMS_EB_g12[iEta][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EB_g12[iEta][iZ]->GetMean()+1.*h_RMS_EB_g12[iEta][iZ]->GetRMS()); g_RMS_EB_g12_1sigma[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g12[iEta][iZ]->GetMean()); g_RMS_EB_g12_1sigma[iZ]->SetPointError(iEta,0,h_RMS_EB_g12[iEta][iZ]->GetRMS()); } if(h_Ped_EB_g6[iEta][iZ]->GetEntries() != 0){ g_Ped_EB_g6[iZ]->SetPoint(iEta,iEta+1,h_Ped_EB_g6[iEta][iZ]->GetMean()); g_Ped_EB_g6[iZ]->SetPointError(iEta,0,h_Ped_EB_g6[iEta][iZ]->GetRMS()); h_Ped_EB_g6[iEta][iZ]->Write(); } if(h_RMS_EB_g6[iEta][iZ]->GetEntries() != 0){ g_RMS_EB_g6[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g6[iEta][iZ]->GetMean()); g_RMS_EB_g6[iZ]->SetPointError(iEta,0,h_RMS_EB_g6[iEta][iZ]->GetRMS()); h_RMS_EB_g6[iEta][iZ]->Write(); h_RMS_EB_g6[iEta][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EB_g6[iEta][iZ]->GetMean()+2.*h_RMS_EB_g6[iEta][iZ]->GetRMS()); g_RMS_EB_g6_2sigma[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g6[iEta][iZ]->GetMean()); g_RMS_EB_g6_2sigma[iZ]->SetPointError(iEta,0,h_RMS_EB_g6[iEta][iZ]->GetRMS()); h_RMS_EB_g6[iEta][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EB_g6[iEta][iZ]->GetMean()+1.*h_RMS_EB_g6[iEta][iZ]->GetRMS()); g_RMS_EB_g6_1sigma[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g6[iEta][iZ]->GetMean()); g_RMS_EB_g6_1sigma[iZ]->SetPointError(iEta,0,h_RMS_EB_g6[iEta][iZ]->GetRMS()); } if(h_Ped_EB_g1[iEta][iZ]->GetEntries() != 0){ g_Ped_EB_g1[iZ]->SetPoint(iEta,iEta+1,h_Ped_EB_g1[iEta][iZ]->GetMean()); g_Ped_EB_g1[iZ]->SetPointError(iEta,0,h_Ped_EB_g1[iEta][iZ]->GetRMS()); h_Ped_EB_g1[iEta][iZ]->Write(); } if(h_RMS_EB_g1[iEta][iZ]->GetEntries() != 0){ g_RMS_EB_g1[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g1[iEta][iZ]->GetMean()); g_RMS_EB_g1[iZ]->SetPointError(iEta,0,h_RMS_EB_g1[iEta][iZ]->GetRMS()); h_RMS_EB_g1[iEta][iZ]->Write(); h_RMS_EB_g1[iEta][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EB_g1[iEta][iZ]->GetMean()+2.*h_RMS_EB_g1[iEta][iZ]->GetRMS()); g_RMS_EB_g1_2sigma[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g1[iEta][iZ]->GetMean()); g_RMS_EB_g1_2sigma[iZ]->SetPointError(iEta,0,h_RMS_EB_g1[iEta][iZ]->GetRMS()); h_RMS_EB_g1[iEta][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EB_g1[iEta][iZ]->GetMean()+1.*h_RMS_EB_g1[iEta][iZ]->GetRMS()); g_RMS_EB_g1_1sigma[iZ]->SetPoint(iEta,iEta+1,h_RMS_EB_g1[iEta][iZ]->GetMean()); g_RMS_EB_g1_1sigma[iZ]->SetPointError(iEta,0,h_RMS_EB_g1[iEta][iZ]->GetRMS()); } } for(int iR = 0; iR<40; iR++) for(int iZ = 0; iZ<3; iZ++){ if(iZ == 1) continue; if(h_Ped_EE_g12[iR][iZ]->GetEntries() != 0){ g_Ped_EE_g12[iZ]->SetPoint(iR,iR,h_Ped_EE_g12[iR][iZ]->GetMean()); g_Ped_EE_g12[iZ]->SetPointError(iR,0,h_Ped_EE_g12[iR][iZ]->GetRMS()); h_Ped_EE_g12[iR][iZ]->Write(); } if(h_RMS_EE_g12[iR][iZ]->GetEntries() != 0){ g_RMS_EE_g12[iZ]->SetPoint(iR,iR,h_RMS_EE_g12[iR][iZ]->GetMean()); g_RMS_EE_g12[iZ]->SetPointError(iR,0,h_RMS_EE_g12[iR][iZ]->GetRMS()); h_RMS_EE_g12[iR][iZ]->Write(); h_RMS_EE_g12[iR][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EE_g12[iR][iZ]->GetMean()+2.*h_RMS_EE_g12[iR][iZ]->GetRMS()); g_RMS_EE_g12_2sigma[iZ]->SetPoint(iR,iR,h_RMS_EE_g12[iR][iZ]->GetMean()); g_RMS_EE_g12_2sigma[iZ]->SetPointError(iR,0,h_RMS_EE_g12[iR][iZ]->GetRMS()); h_RMS_EE_g12[iR][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EE_g12[iR][iZ]->GetMean()+1.*h_RMS_EE_g12[iR][iZ]->GetRMS()); g_RMS_EE_g12_1sigma[iZ]->SetPoint(iR,iR,h_RMS_EE_g12[iR][iZ]->GetMean()); g_RMS_EE_g12_1sigma[iZ]->SetPointError(iR,0,h_RMS_EE_g12[iR][iZ]->GetRMS()); } if(h_Ped_EE_g6[iR][iZ]->GetEntries() != 0){ g_Ped_EE_g6[iZ]->SetPoint(iR,iR,h_Ped_EE_g6[iR][iZ]->GetMean()); g_Ped_EE_g6[iZ]->SetPointError(iR,0,h_Ped_EE_g6[iR][iZ]->GetRMS()); h_Ped_EE_g6[iR][iZ]->Write(); } if(h_RMS_EE_g6[iR][iZ]->GetEntries() != 0){ g_RMS_EE_g6[iZ]->SetPoint(iR,iR,h_RMS_EE_g6[iR][iZ]->GetMean()); g_RMS_EE_g6[iZ]->SetPointError(iR,0,h_RMS_EE_g6[iR][iZ]->GetRMS()); h_RMS_EE_g6[iR][iZ]->Write(); h_RMS_EE_g6[iR][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EE_g6[iR][iZ]->GetMean()+2.*h_RMS_EE_g6[iR][iZ]->GetRMS()); g_RMS_EE_g6_2sigma[iZ]->SetPoint(iR,iR,h_RMS_EE_g6[iR][iZ]->GetMean()); g_RMS_EE_g6_2sigma[iZ]->SetPointError(iR,0,h_RMS_EE_g6[iR][iZ]->GetRMS()); h_RMS_EE_g6[iR][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EE_g6[iR][iZ]->GetMean()+1.*h_RMS_EE_g6[iR][iZ]->GetRMS()); g_RMS_EE_g6_1sigma[iZ]->SetPoint(iR,iR,h_RMS_EE_g6[iR][iZ]->GetMean()); g_RMS_EE_g6_1sigma[iZ]->SetPointError(iR,0,h_RMS_EE_g6[iR][iZ]->GetRMS()); } if(h_Ped_EE_g1[iR][iZ]->GetEntries() != 0){ g_Ped_EE_g1[iZ]->SetPoint(iR,iR,h_Ped_EE_g1[iR][iZ]->GetMean()); g_Ped_EE_g1[iZ]->SetPointError(iR,0,h_Ped_EE_g1[iR][iZ]->GetRMS()); h_Ped_EE_g1[iR][iZ]->Write(); } if(h_RMS_EE_g1[iR][iZ]->GetEntries() != 0){ g_RMS_EE_g1[iZ]->SetPoint(iR,iR,h_RMS_EE_g1[iR][iZ]->GetMean()); g_RMS_EE_g1[iZ]->SetPointError(iR,0,h_RMS_EE_g1[iR][iZ]->GetRMS()); h_RMS_EE_g1[iR][iZ]->Write(); h_RMS_EE_g1[iR][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EE_g1[iR][iZ]->GetMean()+2.*h_RMS_EE_g1[iR][iZ]->GetRMS()); g_RMS_EE_g1_2sigma[iZ]->SetPoint(iR,iR,h_RMS_EE_g1[iR][iZ]->GetMean()); g_RMS_EE_g1_2sigma[iZ]->SetPointError(iR,0,h_RMS_EE_g1[iR][iZ]->GetRMS()); h_RMS_EE_g1[iR][iZ]->GetXaxis()->SetRangeUser(0.,h_RMS_EE_g1[iR][iZ]->GetMean()+1.*h_RMS_EE_g1[iR][iZ]->GetRMS()); g_RMS_EE_g1_1sigma[iZ]->SetPoint(iR,iR,h_RMS_EE_g1[iR][iZ]->GetMean()); g_RMS_EE_g1_1sigma[iZ]->SetPointError(iR,0,h_RMS_EE_g1[iR][iZ]->GetRMS()); } } g_Ped_EB_g12[0]->Write("g_Ped_EB_g12_M"); g_Ped_EB_g12[2]->Write("g_Ped_EB_g12_P"); g_Ped_EB_g6[0]->Write("g_Ped_EB_g6_M"); g_Ped_EB_g6[2]->Write("g_Ped_EB_g6_P"); g_Ped_EB_g1[0]->Write("g_Ped_EB_g1_M"); g_Ped_EB_g1[2]->Write("g_Ped_EB_g1_P"); g_RMS_EB_g12[0]->Write("g_RMS_EB_g12_M"); g_RMS_EB_g12[2]->Write("g_RMS_EB_g12_P"); g_RMS_EB_g6[0]->Write("g_RMS_EB_g6_M"); g_RMS_EB_g6[2]->Write("g_RMS_EB_g6_P"); g_RMS_EB_g1[0]->Write("g_RMS_EB_g1_M"); g_RMS_EB_g1[2]->Write("g_RMS_EB_g1_P"); g_RMS_EB_g12_1sigma[0]->Write("g_RMS_EB_g12_1sigma_M"); g_RMS_EB_g12_1sigma[2]->Write("g_RMS_EB_g12_1sigma_P"); g_RMS_EB_g6_1sigma[0]->Write("g_RMS_EB_g6_1sigma_M"); g_RMS_EB_g6_1sigma[2]->Write("g_RMS_EB_g6_1sigma_P"); g_RMS_EB_g1_1sigma[0]->Write("g_RMS_EB_g1_1sigma_M"); g_RMS_EB_g1_1sigma[2]->Write("g_RMS_EB_g1_1sigma_P"); g_RMS_EB_g12_2sigma[0]->Write("g_RMS_EB_g12_2sigma_M"); g_RMS_EB_g12_2sigma[2]->Write("g_RMS_EB_g12_2sigma_P"); g_RMS_EB_g6_2sigma[0]->Write("g_RMS_EB_g6_2sigma_M"); g_RMS_EB_g6_2sigma[2]->Write("g_RMS_EB_g6_2sigma_P"); g_RMS_EB_g1_2sigma[0]->Write("g_RMS_EB_g1_2sigma_M"); g_RMS_EB_g1_2sigma[2]->Write("g_RMS_EB_g1_2sigma_P"); g_Ped_EE_g12[0]->Write("g_Ped_EE_g12_M"); g_Ped_EE_g12[2]->Write("g_Ped_EE_g12_P"); g_Ped_EE_g6[0]->Write("g_Ped_EE_g6_M"); g_Ped_EE_g6[2]->Write("g_Ped_EE_g6_P"); g_Ped_EE_g1[0]->Write("g_Ped_EE_g1_M"); g_Ped_EE_g1[2]->Write("g_Ped_EE_g1_P"); g_RMS_EE_g12[0]->Write("g_RMS_EE_g12_M"); g_RMS_EE_g12[2]->Write("g_RMS_EE_g12_P"); g_RMS_EE_g6[0]->Write("g_RMS_EE_g6_M"); g_RMS_EE_g6[2]->Write("g_RMS_EE_g6_P"); g_RMS_EE_g1[0]->Write("g_RMS_EE_g1_M"); g_RMS_EE_g1[2]->Write("g_RMS_EE_g1_P"); g_RMS_EE_g12_1sigma[0]->Write("g_RMS_EE_g12_1sigma_M"); g_RMS_EE_g12_1sigma[2]->Write("g_RMS_EE_g12_1sigma_P"); g_RMS_EE_g6_1sigma[0]->Write("g_RMS_EE_g6_1sigma_M"); g_RMS_EE_g6_1sigma[2]->Write("g_RMS_EE_g6_1sigma_P"); g_RMS_EE_g1_1sigma[0]->Write("g_RMS_EE_g1_1sigma_M"); g_RMS_EE_g1_1sigma[2]->Write("g_RMS_EE_g1_1sigma_P"); g_RMS_EE_g12_2sigma[0]->Write("g_RMS_EE_g12_2sigma_M"); g_RMS_EE_g12_2sigma[2]->Write("g_RMS_EE_g12_2sigma_P"); g_RMS_EE_g6_2sigma[0]->Write("g_RMS_EE_g6_2sigma_M"); g_RMS_EE_g6_2sigma[2]->Write("g_RMS_EE_g6_2sigma_P"); g_RMS_EE_g1_2sigma[0]->Write("g_RMS_EE_g1_2sigma_M"); g_RMS_EE_g1_2sigma[2]->Write("g_RMS_EE_g1_2sigma_P"); h2_NoiseChannels_EB_g12_1sigma->Write("h2_NoiseChannels_EB_g12_1sigma"); h2_NoiseChannels_EB_g6_1sigma->Write("h2_NoiseChannels_EB_g6_1sigma"); h2_NoiseChannels_EB_g1_1sigma->Write("h2_NoiseChannels_EB_g1_1sigma"); h2_NoiseChannels_EE_g12_1sigma[0]->Write("h2_NoiseChannels_EE_g12_1sigma_M"); h2_NoiseChannels_EE_g6_1sigma[0]->Write("h2_NoiseChannels_EE_g6_1sigma_M"); h2_NoiseChannels_EE_g1_1sigma[0]->Write("h2_NoiseChannels_EE_g1_1sigma_M"); h2_NoiseChannels_EE_g12_1sigma[2]->Write("h2_NoiseChannels_EE_g12_1sigma_P"); h2_NoiseChannels_EE_g6_1sigma[2]->Write("h2_NoiseChannels_EE_g6_1sigma_P"); h2_NoiseChannels_EE_g1_1sigma[2]->Write("h2_NoiseChannels_EE_g1_1sigma_P"); h2_NoiseChannels_EB_g12_2sigma->Write("h2_NoiseChannels_EB_g12_2sigma"); h2_NoiseChannels_EB_g6_2sigma->Write("h2_NoiseChannels_EB_g6_2sigma"); h2_NoiseChannels_EB_g1_2sigma->Write("h2_NoiseChannels_EB_g1_2sigma"); h2_NoiseChannels_EE_g12_2sigma[0]->Write("h2_NoiseChannels_EE_g12_2sigma_M"); h2_NoiseChannels_EE_g6_2sigma[0]->Write("h2_NoiseChannels_EE_g6_2sigma_M"); h2_NoiseChannels_EE_g1_2sigma[0]->Write("h2_NoiseChannels_EE_g1_2sigma_M"); h2_NoiseChannels_EE_g12_2sigma[2]->Write("h2_NoiseChannels_EE_g12_2sigma_P"); h2_NoiseChannels_EE_g6_2sigma[2]->Write("h2_NoiseChannels_EE_g6_2sigma_P"); h2_NoiseChannels_EE_g1_2sigma[2]->Write("h2_NoiseChannels_EE_g1_2sigma_P"); myOutFile->Close(); } } std::vector<std::string> splitString(std::string& inputName, char split_char) { std::vector<std::string> tokens; std::istringstream split(inputName); for(std::string each; getline(split, each, split_char); tokens.push_back(each)); return tokens; }
[ "badder.marzocchi@cern.ch" ]
badder.marzocchi@cern.ch
be93f7fd667d0bdb29601d80febad8b854ebe42b
df8c4c9b9a2598db02cf31b97dcbf66bd00e50e8
/uri/BilletesyMonedas.cpp
a5162e7f117a3de4a33e1ebb408c83c526140e8a
[]
no_license
carogomezt/Maratones
7b72f0244cc44b81a28384569a744b04927107c3
b2fcf14646f6f5cf96e9f66ddaf99b8d710c04b9
refs/heads/master
2021-01-17T13:02:54.040710
2017-10-11T22:25:32
2017-10-11T22:25:32
56,722,951
0
1
null
2017-10-11T22:25:33
2016-04-20T21:42:21
C++
UTF-8
C++
false
false
1,312
cpp
#include <bits/stdc++.h> using namespace std; int main(){ double n; cin>>n; int p_ent, p_flot, aux1; p_ent = n; aux1 = (n*100); p_flot = aux1%100; double aux=0; aux = p_ent/100; p_ent = p_ent%100; cout<<"NOTAS:"<<endl; cout<<aux<<" nota(s) de R$ 100.00"<<endl; aux = p_ent/50; p_ent = p_ent%50; cout<<aux<<" nota(s) de R$ 50.00"<<endl; aux = p_ent/20; p_ent = p_ent%20; cout<<aux<<" nota(s) de R$ 20.00"<<endl; aux = p_ent/10; p_ent = p_ent%10; cout<<aux<<" nota(s) de R$ 10.00"<<endl; aux = p_ent/5; p_ent = p_ent%5; cout<<aux<<" nota(s) de R$ 5.00"<<endl; aux = p_ent/2; p_ent = p_ent%2; cout<<aux<<" nota(s) de R$ 2.00"<<endl; cout<<"MOEDAS:"<<endl; aux = p_ent/1; p_ent = p_ent%1; cout<<aux<<" moeda(s) de R$ 1.00"<<endl; aux = p_flot/50; p_flot = p_flot%50; cout<<aux<<" moeda(s) de R$ 0.50"<<endl; aux = p_flot/25; p_flot = p_flot%25; cout<<aux<<" moeda(s) de R$ 0.25"<<endl; aux = p_flot/10; p_flot = p_flot%10; cout<<aux<<" moeda(s) de R$ 0.10"<<endl; aux = p_flot/5; p_flot = p_flot%5; cout<<aux<<" moeda(s) de R$ 0.05"<<endl; aux = p_flot/1; p_flot = p_flot%1; cout<<aux<<" moeda(s) de R$ 0.01"<<endl; return 0; }
[ "carolina9511@gmail.com" ]
carolina9511@gmail.com
6d4d0aa8375fd49dc1fb1b81fc8bc14c8932288e
80a02d63cab0de89d288a5902aa7115c354e2144
/libs/famitracker/Source/DirectSound.cpp
27118c1536c1ebc54ce58f738ea0d7fb760227ce
[]
no_license
keichacon/nesicide
4901cbcfe98a6e9c0487ce96a36c5455043fb8e7
62b5e1bf0063bda1c361f726173142eb0ee6b5c5
refs/heads/master
2021-01-17T05:22:38.377689
2014-06-07T23:31:45
2014-06-07T23:31:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,782
cpp
/* ** FamiTracker - NES/Famicom sound tracker ** Copyright (C) 2005-2012 Jonathan Liss ** ** 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 of the License, 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 ** Library General Public License for more details. To obtain a ** copy of the GNU Library General Public License, write to the Free ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ** ** Any permitted reproduction of these routines, in whole or in part, ** must bear this legend. */ // // DirectSound Interface // #include "stdafx.h" #include <cstdio> #include "common.h" #include "DirectSound.h" #include "resource.h" // The single CDSound object CDSound *CDSound::pThisObject = NULL; // Class members //BOOL CALLBACK CDSound::DSEnumCallback(LPGUID lpGuid, LPCTSTR lpcstrDescription, LPCTSTR lpcstrModule, LPVOID lpContext) //{ // return pThisObject->EnumerateCallback(lpGuid, lpcstrDescription, lpcstrModule, lpContext); //} // Instance members CDSound::CDSound(HWND hWnd, HANDLE hNotification) : m_iDevices(0)//, // m_lpDirectSound(NULL), // m_hWndTarget(hWnd), // m_hNotificationHandle(hNotification) { ASSERT(pThisObject == NULL); pThisObject = this; } CDSound::~CDSound() { // for (int i = 0; i < (int)m_iDevices; ++i) { // delete [] m_pcDevice[i]; // delete [] m_pGUIDs[i]; // } } static unsigned char* m_pSoundBuffer = NULL; static unsigned int m_iSoundProducer = 0; static unsigned int m_iSoundConsumer = 0; static unsigned int m_iSoundBufferSize = 0; QSemaphore ftmAudioSemaphore(0); QList<SDL_Callback> sdlHooks; extern "C" void SDL_FamiTracker(void* userdata, uint8_t* stream, int32_t len) { if ( !stream ) return; #if 0 LARGE_INTEGER t; static LARGE_INTEGER to; LARGE_INTEGER f; QueryPerformanceFrequency(&f); QueryPerformanceCounter(&t); QString str; str.sprintf("Smp: %d, Freq: %d, Ctr: %d, Diff %d, Per %lf", len>>1, f.LowPart, t.LowPart,t.LowPart-to.LowPart,(float)(t.LowPart-to.LowPart)/(float)f.LowPart); to = t; qDebug(str.toAscii().constData()); #endif if ( m_pSoundBuffer ) SDL_MixAudio(stream,m_pSoundBuffer,len,SDL_MIX_MAXVOLUME); m_iSoundConsumer += len; m_iSoundConsumer %= m_iSoundBufferSize; foreach ( SDL_Callback cb, sdlHooks ) { if ( cb._valid ) { cb._func(cb._user,stream,len); } } ftmAudioSemaphore.release(); } bool CDSound::Init(int Device) { SDL_Init ( SDL_INIT_AUDIO ); // if (Device > (int)m_iDevices) // Device = 0; // if (m_lpDirectSound) { // m_lpDirectSound->Release(); // m_lpDirectSound = NULL; // } // if (FAILED(DirectSoundCreate((LPCGUID)m_pGUIDs[Device], &m_lpDirectSound, NULL))) { // m_lpDirectSound = NULL; // return false; // } // if (FAILED(m_lpDirectSound->SetCooperativeLevel(m_hWndTarget, DSSCL_PRIORITY))) // return false; return true; } void CDSound::Close() { // if (!m_lpDirectSound) // return; // m_lpDirectSound->Release(); // m_lpDirectSound = NULL; // if (m_iDevices != 0) // ClearEnumeration(); } void CDSound::ClearEnumeration() { // for (unsigned i = 0; i < m_iDevices; ++i) { // delete [] m_pcDevice[i]; // if (m_pGUIDs[i] != NULL) // delete m_pGUIDs[i]; // } m_iDevices = 0; } BOOL CDSound::EnumerateCallback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) { // m_pcDevice[m_iDevices] = new char[strlen(lpcstrDescription) + 1]; // strcpy(m_pcDevice[m_iDevices], lpcstrDescription); // if (lpGuid != NULL) { // m_pGUIDs[m_iDevices] = new GUID; // memcpy(m_pGUIDs[m_iDevices], lpGuid, sizeof(GUID)); // } // else // m_pGUIDs[m_iDevices] = NULL; // ++m_iDevices; return TRUE; } void CDSound::EnumerateDevices() { if (m_iDevices != 0) ClearEnumeration(); qDebug("Hook SDL2 here?"); // DirectSoundEnumerate(DSEnumCallback, NULL); } unsigned int CDSound::GetDeviceCount() const { return m_iDevices; } char *CDSound::GetDeviceName(int iDevice) const { return m_pcDevice[iDevice]; } int CDSound::MatchDeviceID(char *Name) const { for (unsigned int i = 0; i < m_iDevices; ++i) { if (!strcmp(Name, m_pcDevice[i])) return i; } return 0; } int CDSound::CalculateBufferLength(int BufferLen, int Samplerate, int Samplesize, int Channels) const { // Calculate size of the buffer, in bytes return ((Samplerate * BufferLen) / 1000) * (Samplesize / 8) * Channels; } CDSoundChannel *CDSound::OpenChannel(int SampleRate, int SampleSize, int Channels, int BufferLength, int Blocks) { SDL_AudioSpec sdlAudioSpecIn; SDL_AudioSpec sdlAudioSpecOut; // Open a new secondary buffer // // DSBPOSITIONNOTIFY dspn[MAX_BLOCKS]; // WAVEFORMATEX wfx; // DSBUFFERDESC dsbd; // if (!m_lpDirectSound) // return NULL; // Adjust buffer length in case a buffer would end up in half samples while ((SampleRate * BufferLength / (Blocks * 1000) != (double)SampleRate * BufferLength / (Blocks * 1000))) ++BufferLength; CDSoundChannel *pChannel = new CDSoundChannel(); HANDLE hBufferEvent = CreateEvent(NULL, FALSE, FALSE, NULL); int SoundBufferSize = CalculateBufferLength(BufferLength, SampleRate, SampleSize, Channels); int BlockSize = SoundBufferSize / Blocks; sdlAudioSpecIn.callback = SDL_FamiTracker; sdlAudioSpecIn.userdata = NULL; sdlAudioSpecIn.channels = Channels; if ( SampleSize == 8 ) { sdlAudioSpecIn.format = AUDIO_U8; } else { sdlAudioSpecIn.format = AUDIO_S16SYS; } sdlAudioSpecIn.freq = SampleRate; // Set up audio sample rate for video mode... sdlAudioSpecIn.samples = (BlockSize/(SampleSize>>3)); SDL_OpenAudio ( &sdlAudioSpecIn, &sdlAudioSpecOut ); qDebug("Adjusting audio: %d",memcmp(&sdlAudioSpecIn,&sdlAudioSpecOut,sizeof(sdlAudioSpecIn))); SoundBufferSize = sdlAudioSpecOut.samples*sdlAudioSpecOut.channels*((sdlAudioSpecOut.format==AUDIO_U8?8:16)>>3); BlockSize = SoundBufferSize / Blocks; if ( m_pSoundBuffer ) delete m_pSoundBuffer; m_pSoundBuffer = new unsigned char[SoundBufferSize]; memset(m_pSoundBuffer,0,SoundBufferSize); m_iSoundProducer = 0; m_iSoundConsumer = 0; m_iSoundBufferSize = SoundBufferSize; pChannel->m_iBufferLength = BufferLength; // in ms pChannel->m_iSoundBufferSize = SoundBufferSize; // in bytes pChannel->m_iBlockSize = BlockSize; // in bytes pChannel->m_iBlocks = Blocks; pChannel->m_iSampleSize = SampleSize; pChannel->m_iSampleRate = SampleRate; pChannel->m_iChannels = Channels; // pChannel->m_iCurrentWriteBlock = 0; // pChannel->m_hWndTarget = m_hWndTarget; // pChannel->m_hEventList[0] = m_hNotificationHandle; // pChannel->m_hEventList[1] = hBufferEvent; // memset(&wfx, 0x00, sizeof(WAVEFORMATEX)); // wfx.cbSize = sizeof(WAVEFORMATEX); // wfx.nChannels = Channels; // wfx.nSamplesPerSec = SampleRate; // wfx.wBitsPerSample = SampleSize; // wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample / 8); // wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; // wfx.wFormatTag = WAVE_FORMAT_PCM; // memset(&dsbd, 0x00, sizeof(DSBUFFERDESC)); // dsbd.dwSize = sizeof(DSBUFFERDESC); // dsbd.dwBufferBytes = SoundBufferSize; // dsbd.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GETCURRENTPOSITION2; // dsbd.lpwfxFormat = &wfx; // if (FAILED(m_lpDirectSound->CreateSoundBuffer(&dsbd, &pChannel->m_lpDirectSoundBuffer, NULL))) { // delete pChannel; // return NULL; // } // // Setup notifications // for (int i = 0; i < Blocks; ++i) { // dspn[i].dwOffset = i * BlockSize; // dspn[i].hEventNotify = hBufferEvent; // } // if (FAILED(pChannel->m_lpDirectSoundBuffer->QueryInterface(IID_IDirectSoundNotify, (void**)&pChannel->m_lpDirectSoundNotify))) { // delete pChannel; // return NULL; // } // if (FAILED(pChannel->m_lpDirectSoundNotify->SetNotificationPositions(Blocks, dspn))) { // delete pChannel; // return NULL; // } pChannel->Clear(); // SDL... pChannel->Play(); SDL_PauseAudio(0); return pChannel; } void CDSound::CloseChannel(CDSoundChannel *pChannel) { SDL_PauseAudio ( 1 ); SDL_CloseAudio (); if (pChannel == NULL) return; // pChannel->m_lpDirectSoundBuffer->Release(); // pChannel->m_lpDirectSoundNotify->Release(); delete pChannel; } // CDSoundChannel CDSoundChannel::CDSoundChannel() { m_bPaused = true; m_iCurrentWriteBlock = 0; // m_hEventList[0] = NULL; // m_hEventList[1] = NULL; // m_hWndTarget = NULL; } CDSoundChannel::~CDSoundChannel() { // // Kill buffer event // if (m_hEventList[1]) // CloseHandle(m_hEventList[1]); } void CDSoundChannel::Play() { ftmAudioSemaphore.release(); m_bPaused = false; // // Begin playback of buffer // m_lpDirectSoundBuffer->Play(NULL, NULL, DSBPLAY_LOOPING); } void CDSoundChannel::Stop() { m_bPaused = true; // // Stop playback // m_lpDirectSoundBuffer->Stop(); Reset(); } void CDSoundChannel::Pause() { m_bPaused = true; // // Pause playback of buffer, doesn't reset cursors // m_lpDirectSoundBuffer->Stop(); } bool CDSoundChannel::IsPlaying() const { return m_bPaused; // DWORD Status; // m_lpDirectSoundBuffer->GetStatus(&Status); // return ((Status & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING); } void CDSoundChannel::Clear() { // DWORD *AudioPtr1, *AudioPtr2; // DWORD AudioBytes1, AudioBytes2; // HRESULT hRes; if (IsPlaying()) Stop(); // m_lpDirectSoundBuffer->SetCurrentPosition(0); // hRes = m_lpDirectSoundBuffer->Lock(0, m_iSoundBufferSize, (void**)&AudioPtr1, &AudioBytes1, (void**)&AudioPtr2, &AudioBytes2, 0); // if FAILED(hRes) { // return; // } // if (m_iSampleSize == 8) { // memset(AudioPtr1, 0x80, AudioBytes1); // if (AudioPtr2) // memset(AudioPtr2, 0x80, AudioBytes2); // } // else { // memset(AudioPtr1, 0x00, AudioBytes1); // if (AudioPtr2) // memset(AudioPtr2, 0x00, AudioBytes2); // } // hRes = m_lpDirectSoundBuffer->Unlock((void*)AudioPtr1, AudioBytes1, (void*)AudioPtr2, AudioBytes2); // if FAILED(hRes) // return; // m_lpDirectSoundBuffer->SetCurrentPosition(0); // m_iCurrentWriteBlock = 0; } void CDSoundChannel::WriteSoundBuffer(void *Buffer, unsigned int Samples) { memcpy(m_pSoundBuffer+m_iSoundProducer,Buffer,Samples); m_iSoundProducer += Samples; m_iSoundProducer %= m_iSoundBufferSize; // Fill sound buffer // // Buffer - Pointer to a buffer with samples // Samples - Number of samples, in bytes // // DWORD *AudioPtr1, *AudioPtr2; // DWORD AudioBytes1, AudioBytes2; // HRESULT hRes; // int Block = m_iCurrentWriteBlock; // ASSERT(Samples == m_iBlockSize); // hRes = m_lpDirectSoundBuffer->Lock(Block * m_iBlockSize, m_iBlockSize, (void**)&AudioPtr1, &AudioBytes1, (void**)&AudioPtr2, &AudioBytes2, 0); // // Could not lock // if (FAILED(hRes)) // return; // memcpy(AudioPtr1, Buffer, AudioBytes1); // if (AudioPtr2) // memcpy(AudioPtr2, (unsigned char*)Buffer + AudioBytes1, AudioBytes2); // hRes = m_lpDirectSoundBuffer->Unlock((void*)AudioPtr1, AudioBytes1, (void*)AudioPtr2, AudioBytes2); // if (FAILED(hRes)) // return; // AdvanceWritePointer(); } void CDSoundChannel::Reset() { // // Reset playback from the beginning of the buffer // m_iCurrentWriteBlock = 0; // m_lpDirectSoundBuffer->SetCurrentPosition(0); } int CDSoundChannel::WaitForDirectSoundEvent(DWORD dwTimeout) const { // Wait for a DirectSound event // if (!IsPlaying()) // Play(); bool ok = ftmAudioSemaphore.tryAcquire(1,dwTimeout); return ok?BUFFER_IN_SYNC:BUFFER_OUT_OF_SYNC; // // Wait for events // switch (WaitForMultipleObjects(2, m_hEventList, FALSE, INFINITE)) { // case WAIT_OBJECT_0: // External event // return CUSTOM_EVENT; // case WAIT_OBJECT_0 + 1: // Direct sound buffer // return (GetWriteBlock() == m_iCurrentWriteBlock) ? BUFFER_OUT_OF_SYNC : BUFFER_IN_SYNC; // } // // Error // return 0; } //int CDSoundChannel::GetPlayBlock() const //{ // // Return the block where the play pos is // DWORD PlayPos, WritePos; // m_lpDirectSoundBuffer->GetCurrentPosition(&PlayPos, &WritePos); // return (PlayPos / m_iBlockSize); //} //int CDSoundChannel::GetWriteBlock() const //{ // // Return the block where the write pos is // DWORD PlayPos, WritePos; // m_lpDirectSoundBuffer->GetCurrentPosition(&PlayPos, &WritePos); // return (WritePos / m_iBlockSize); //} void CDSoundChannel::ResetWritePointer() { m_iCurrentWriteBlock = 0; } void CDSoundChannel::AdvanceWritePointer() { m_iCurrentWriteBlock = (m_iCurrentWriteBlock + 1) % m_iBlocks; }
[ "christopher_pow@hotmail.com" ]
christopher_pow@hotmail.com
db748d8c8fca8c8558fe1f98d6177c607dcaa62c
57b6fa831fe532cf0739135c77946f0061e3fbf5
/NWNXLib/API/Linux/API/CExoLinkedListTemplatedNWPlayerListItem_st.cpp
d79270751ac2e16b85bd2c786bb621e6d991cd71
[ "MIT" ]
permissive
presscad/nwnee
dfcb90767258522f2b23afd9437d3dcad74f936d
0f36b281524e0b7e9796bcf30f924792bf9b8a38
refs/heads/master
2020-08-22T05:26:11.221042
2018-11-24T16:45:45
2018-11-24T16:45:45
216,326,718
1
0
MIT
2019-10-20T07:54:45
2019-10-20T07:54:45
null
UTF-8
C++
false
false
905
cpp
#include "CExoLinkedListTemplatedNWPlayerListItem_st.hpp" #include "API/Functions.hpp" #include "Platform/ASLR.hpp" #include "CExoLinkedListInternal.hpp" namespace NWNXLib { namespace API { CExoLinkedListTemplatedNWPlayerListItem_st::~CExoLinkedListTemplatedNWPlayerListItem_st() { CExoLinkedListTemplatedNWPlayerListItem_st__CExoLinkedListTemplatedNWPlayerListItem_stDtor(this); } void CExoLinkedListTemplatedNWPlayerListItem_st__CExoLinkedListTemplatedNWPlayerListItem_stDtor(CExoLinkedListTemplatedNWPlayerListItem_st* thisPtr) { using FuncPtrType = void(__attribute__((cdecl)) *)(CExoLinkedListTemplatedNWPlayerListItem_st*, int); uintptr_t address = Platform::ASLR::GetRelocatedAddress(Functions::CExoLinkedListTemplatedNWPlayerListItem_st__CExoLinkedListTemplatedNWPlayerListItem_stDtor); FuncPtrType func = reinterpret_cast<FuncPtrType>(address); func(thisPtr, 2); } } }
[ "liarethnwn@gmail.com" ]
liarethnwn@gmail.com
29ded87c5a6fbd337333c4d8d6670c4ef3731bac
00f47716d69757dbf27f642a0b5575049081dc83
/Section4/MixedExpressionsAndConversions/main.cpp
72771924b6ac0280912b7513cea9f184cc8eac7c
[]
no_license
joelgasparr/C-Projects
97d3292998cee378edd4de0f62587324436d52f8
dac287acb8b7520fe4d3cbc90e4bd3d7a4c12be0
refs/heads/master
2023-03-04T20:12:48.169317
2021-02-19T00:38:32
2021-02-19T00:38:32
302,996,045
0
0
null
null
null
null
UTF-8
C++
false
false
608
cpp
#include <iostream> using namespace std; int main() { int total {}; int num1 {}, num2 {}, num3 {}; const int count {3}; cout << "Enter 3 integers separated by spaces: "; cin >> num1 >> num2 >> num3; total = num1 + num2 + num3; double average {0.0}; average = static_cast <double> (total) / count; cout << "The 3 numbers were: " << num1 << "," << num2 << "," << num3 << endl; cout << "The sum of the numbers is: " << total << endl; cout << "The average of the numbers is: " << average << endl; cout << endl; return 0; }
[ "joel32153@hotmail.com" ]
joel32153@hotmail.com
505cef97afcc7020e188193e5d42bbd56dc3203a
d24cef73100a0c5d5c275fd0f92493f86d113c62
/SRC/common/boolarray.C
8e72497a559d9260e8fb8237eacdf6396b0ff3a6
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
rlinder1/oof3d
813e2a8acfc89e67c3cf8fdb6af6b2b983b8b8ee
1fb6764d9d61126bd8ad4025a2ce7487225d736e
refs/heads/master
2021-01-23T00:40:34.642449
2016-09-15T20:51:19
2016-09-15T20:51:19
92,832,740
1
0
null
null
null
null
UTF-8
C++
false
false
3,240
c
// -*- C++ -*- // $RCSfile: boolarray.C,v $ // $Revision: 1.15.18.5 $ // $Author: langer $ // $Date: 2014/12/14 22:49:05 $ /* This software was produced by NIST, an agency of the U.S. government, * and by statute is not subject to copyright in the United States. * Recipients of this software assume all responsibilities associated * with its operation, modification and maintenance. However, to * facilitate maintenance we ask that before distributing modified * versions of this software, you first contact the authors at * oof_manager@nist.gov. */ #include <oofconfig.h> #include "common/boolarray.h" #include "common/coord.h" #include <string.h> // for memset() BoolArray BoolArray::clone() const { BoolArray bozo(bounds_.upperright()); bozo.dataptr->copy(*dataptr); return bozo; } BoolArray BoolArray::subarray(const ICoord &crnr0, const ICoord &crnr1) { BoolArray newarray(dataptr->size, dataptr); ++dataptr->refcount; #if DIM == 2 newarray.bounds_ = ICRectangle(crnr0, crnr1); #elif DIM == 3 newarray.bounds_ = ICRectangularPrism(crnr0, crnr1); #endif newarray.bounds_.restrict(bounds()); newarray.findfin(); return newarray; } const BoolArray BoolArray::subarray(const ICoord &crnr0, const ICoord &crnr1) const { BoolArray newarray(dataptr->size, dataptr); ++dataptr->refcount; #if DIM == 2 newarray.bounds_ = ICRectangle(crnr0, crnr1); #elif DIM == 3 newarray.bounds_ = ICRectangularPrism(crnr0, crnr1); #endif newarray.bounds_.restrict(bounds()); newarray.findfin(); return newarray; } void BoolArray::clear(const bool &v) { int x = bounds_.xmin(); int w = width(); #if DIM == 2 for(int j=bounds_.ymin(); j<bounds_.ymax(); j++) { memset(&(*this)[ICoord(x, j)], v, w*sizeof(bool)); } #elif DIM == 3 for(int k=bounds_.zmin(); k<bounds_.zmax(); ++k) { for(int j=bounds_.ymin(); j<bounds_.ymax(); j++) { memset(&(*this)[ICoord(x, j, k)], v, w*sizeof(bool)); } } #endif } ICoordVector *BoolArray::pixels(bool v) const { ICoordVector *pxls = new ICoordVector; for(const_iterator i=begin(); i!=end(); ++i) { if(*i == v) pxls->push_back(i.coord()); } return pxls; } int BoolArray::nset() const { // TODO 3.1: Keep track of number of set bits, and don't loop // here! This is actually quite difficult to do with the current // Array architecture. One problem is that in order to maintain an // always up-to-date count of the set bits, operator[](ICoord) has // to be disabled, preventing direct access to bits. This requires // that BoolArray no longer be a subclass of Array<bool>, and // instead contains an Array<bool>. The code for subarrays and // clones becomes messy but not impossible. The second more serious // problem is keeping the count up-to-date in subarrays, which share // data with the main array. int n = 0; for(const_iterator i=begin(); i!=end(); ++i) if(*i) ++n; return n; } bool BoolArray::empty() const { // TODO 3.1: Keep track of number of set bits, and don't loop here! See // comment above. for(const_iterator i=begin(); i!=end(); ++i) if(*i) return false; return true; } void BoolArray::invert() { for(iterator i=begin(); i!=end(); ++i) *i ^= 1; }
[ "faical.congo@nist.gov" ]
faical.congo@nist.gov
04fdf5a622b26650f45695ee5ed1327946e68533
ece1d81d51217ac2272550e1beee35d2a081a498
/c/11/hw/cars.cpp
699510da14200962bff0c66e7bc8ac86435317ee
[]
no_license
IvanDimitrov2002/school
4a824e7e3eb20fa797502c4b1fbeb6c43d1c757b
0bc249ff0c72b2d810eca8c29b0ea03942b0ea09
refs/heads/master
2023-06-10T12:21:05.103716
2021-06-30T20:25:32
2021-06-30T20:25:32
381,820,854
0
0
null
null
null
null
UTF-8
C++
false
false
3,576
cpp
#include <iostream> #include <string> #include <sstream> #include <vector> #include <algorithm> using namespace std; class ModelsCollectionTooSmall : exception{}; class ModelsCollectionEmptyName : exception{}; class ModelsCollectionDuplicate : exception{}; class ManufacturerNameTooSmall : exception{}; class SizeTooBig : exception{}; class CarCatalogue{ string manufacturer; vector<string> models; public: CarCatalogue(){ this->manufacturer = ""; } CarCatalogue(string manufacturer, vector<string> models){ if(models.size() < 5){ throw ModelsCollectionTooSmall(); } if(manufacturer.length() < 5){ throw ManufacturerNameTooSmall(); } vector<string> duplicates; vector<string>::iterator it; for(it = models.begin(); it != models.end(); it++){ if(*it == "" || *it == " "){ throw ModelsCollectionEmptyName(); } if(find(duplicates.begin(), duplicates.end(), *it) != duplicates.end()) { throw ModelsCollectionDuplicate(); } duplicates.push_back(*it); } this->manufacturer = manufacturer; this->models = models; } string getBrand(){ return manufacturer; } vector<string> getModels(){ return models; } void addModel(string model_name){ if(model_name == "" || model_name == " "){ throw ModelsCollectionEmptyName(); } if(find(models.begin(), models.end(), model_name) != models.end()) { throw ModelsCollectionDuplicate(); } models.push_back(model_name); } int hasModel(string model_name){ if(count(models.begin(), models.end(), model_name)) { return 1; } return 0; } string toString(){ ostringstream out; out << "<" << manufacturer << ">:\n"; vector<string>::iterator it; for(it = models.begin(); it != models.end(); it++){ out << " <" << *it << ">\n"; } return out.str(); } void removeModelAt(int index){ if(models.size() < index){ throw SizeTooBig(); } models.erase(models.begin() + index); } void replaceModelAt(int index, string model_name){ if(models.size() < index){ throw SizeTooBig(); } if(model_name == "" || model_name == " "){ throw ModelsCollectionEmptyName(); } if(find(models.begin(), models.end(), model_name) != models.end()) { throw ModelsCollectionDuplicate(); } models[index] = model_name; } }; int main(){ vector<string> models; models.push_back("A"); models.push_back("B"); models.push_back("C"); models.push_back("D"); models.push_back("E"); models.push_back("G"); CarCatalogue catalogue = CarCatalogue("CarMaker", models); cout << catalogue.hasModel("F") << endl; catalogue.addModel("F"); cout << catalogue.hasModel("F") << endl; cout << catalogue.toString(); catalogue.removeModelAt(1); cout << catalogue.toString(); catalogue.replaceModelAt(1, "T"); cout << catalogue.toString(); return 0; }
[ "ivan.dimitrov293@gmail.com" ]
ivan.dimitrov293@gmail.com
d4547d531970fd435224c7e77090aa8a7e2a8793
9275912dc8f49378462cbf4bd88d8c62ccfe4a78
/SensorNet1/SensorNet1.ino
d096ea519eebb67cddf5b70cea98dada1742f389
[]
no_license
Icabaad/MotherHub
9bdef59e7b4f470c8bc549a9045993e49b45b4ac
e522d40f1646cdfcc0e431f8d64a8c8c7058e819
refs/heads/master
2022-03-07T06:26:35.844953
2022-02-24T13:33:36
2022-02-24T13:33:36
23,915,355
0
0
null
2014-09-15T04:40:55
2014-09-11T11:21:57
Arduino
UTF-8
C++
false
false
48,303
ino
// Sensor Mega! V.001 // Receives Data from Xbee Coordinator and Serial1 Arduino UNO. // Processes numerous other Sensors and uploads to Xively and local SQL via Rasberry Pi // http://www.dangertech.org #include <SPI.h> #include <Ethernet.h> #include <HttpClient.h> //#include <Xively.h> #include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BMP085_U.h> #include <Adafruit_TSL2561_U.h> #include <XBee.h> #include <Time.h> #include <DS1307RTC.h> #define DS1307_I2C_ADDRESS 0x68 // the I2C address of Tiny RTC #define I2C24C32Add 0x50 #define BMP085_ADDRESS 0x77 //BMP085 Pressure //Adafruit_BMP085 bmp; Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); //lux //TSL2561 tsl(TSL2561_ADDR_LOW); //old Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_LOW, 12345); //xbee XBee xbee = XBee(); ZBRxResponse rx = ZBRxResponse(); ZBRxIoSampleResponse ioSample = ZBRxIoSampleResponse(); XBeeAddress64 test = XBeeAddress64(); //ethernet byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Your Xively key to let you upload data // char xivelyKey[] = "8q9hxZHPQggWKsXqPEBZymEHa5Uyfiwv1TrcPXBenKPCsCr7"; //char bufferId[] = "info_message"; //String stringId("random_string"); const int bufferSize = 140; char bufferValue[bufferSize]; // enough space to store the string we're going to send //EthernetClient client; // XivelyClient xivelyclient(client); ex cosm int sensorPin = 0; //light const int motionPin = 2; // choose the input pin (for PIR sensor) const int ledPin = 3; //LED const int foyeurLedPin = 7; //Foyeur Motion ON LED int timer = 0; const int hydroLED = 6; //LED that comes on with hotwater/heatpump float strWater = 0; float strBatteryV = 0; float waterHourly = 0; float waterDaily = 0; char server[] = "http://emoncms.org/"; //emoncms URL String apiKey = "ebd4f194e60f6e8694f56aa48b094ddb"; //powerserial const int fNumber = 3; //number of fields to recieve in data stream int fieldIndex = 0; //current field being recieved int values[fNumber]; //array holding values String xbeeReadString = ""; String xbeeReadString2 = ""; String realPower1; String realPower2; String realPower3; String realPower4; float realPower5 = 0; float fltPower5 = 0; String Irms1; String Irms2; String Irms3; String Irms4; String Vrms; float KWHour = 0; float KWHour2 = 0; float KWDay = 0; float lastKWHour = 0; float lastKWHour2 = 0; float lastKWDay = 0; float minuteWattTotal = 0; float hourWattTotal = 0; float KWHourTotal = 0; int kwStart = 0; int firstStart = 0; String foyeurLux; String hotWaterHot; String hotWaterCold; String foyeurHumidity; String foyeurTemp; String FoyeurMotion; float bathroomTemp = 0; float bathroomVolt = 0; float livingTemp = 0; float livingVolt = 0; float shedTemp = 0; String strWeather; String winDir; String windSpeedkph; String windGustkph; String windGustDir; String windSpdkph_avg2m; String windDir_avg2m; String windGustkph_10m; String windGustDir_10m; String humidity; String WeatherSTemp; String rainIn; String dailyRainIn; String pressure; String batt_lvl; String light_lvl; int packetSize = xbeeReadString.length(); int currentCostMinute = 0; int processMinute = 0; int processHour = 0; int processDay = 0; int debug = 0; //*************************************************** void setup() { Serial.begin(57600); //Debug and output to PySuckler // Serial1.begin(9600); //Currentcost chat Serial2.begin(9600); //Xbee chat // Serial3.begin(57600); //Output to pi xbee.setSerial(Serial2); //sets serial2 to be used for xbee library Serial.println("Starting SensorNet..."); Serial.println(); /*//Ethernet OK? while (Ethernet.begin(mac) != 1) { Serial.println("Error getting IP address via DHCP, trying again..."); delay(15000); } Serial.print("IP address: "); Ethernet.localIP().printTo(Serial); Serial.println(); Serial.print("Gateway IP address is "); Ethernet.gatewayIP().printTo(Serial); Serial.println(); Serial.print("DNS IP address is "); Ethernet.dnsServerIP().printTo(Serial); Serial.println(); Serial.println("Ethernet OK...."); */ //Barometer OK? //time for barometer to start up Serial.println("Barometer Warming up..."); delay(1000); if (!bmp.begin()) { Serial.println("Could not find a valid BMP085 sensor, check wiring!"); while (1) { } int processMinute = minute(); int processHour = hour(); int processDay = day(); } //Lux //tsl.setGain(TSL2561_GAIN_0X); // set no gain (for bright situtations) // new version below tsl.setGain(TSL2561_GAIN_16X); // set 16x gain for dim situations tsl.enableAutoRange(true); /* Auto-gain ... switches automatically between 1x and 16x */ //ne version below tsl.setTiming(TSL2561_INTEGRATIONTIME_101MS); // medium integration time (medium light) tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); pinMode(motionPin, INPUT); // declare sensor as input pinMode(ledPin, OUTPUT); pinMode(hydroLED, OUTPUT); pinMode(foyeurLedPin, OUTPUT); digitalWrite(motionPin, LOW); digitalWrite(hydroLED, LOW); digitalWrite(foyeurLedPin, LOW); Serial.println(); //RTX Time Sync setSyncProvider(RTC.get); // the function to get the time from the RTC if (timeStatus() != timeSet) Serial.println("Unable to sync with the RTC"); else Serial.println("RTC has set the system time"); digitalClockDisplay(); Serial.println("Starting Data Collection....."); } //////////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { setSyncProvider(RTC.get); // the function to get the time from the RTC int commsMotion = digitalRead(motionPin); int pirOut = 0; if (commsMotion == HIGH) { digitalWrite(ledPin, HIGH); commsMotion = 1; } // datastreams[0].setInt(commsMotion); /* if(minute() == 59 && second() == 59) { //Watertimer resets waterHourly = 0; } if(hour() == 23 && minute() == 59 && second() == 59) { waterDaily = 0; } */ //xbee //attempt to read a packet xbee.readPacket(); if (xbee.getResponse().isAvailable()) { if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) { // got a zb rx packet, the kind this code is looking for // now that you know it's a receive packet // fill in the values xbee.getResponse().getZBRxResponse(rx); // this is how you get the 64 bit address out of // the incoming packet so you know which device // it came from XBeeAddress64 senderLongAddress = rx.getRemoteAddress64(); Serial.print("Got an rx packet from: "); print32Bits(senderLongAddress.getMsb()); Serial.print(" "); print32Bits(senderLongAddress.getLsb()); // this is how to get the sender's // 16 bit address and show it uint16_t senderShortAddress = rx.getRemoteAddress16(); Serial.print(" ("); print16Bits(senderShortAddress); Serial.println(")"); Serial.print(senderLongAddress.getLsb()); uint32_t xbee = (senderLongAddress.getLsb()); // The option byte is a bit field if (rx.getOption() & ZB_PACKET_ACKNOWLEDGED) // the sender got an ACK Serial.println(" Packet Acknowledged"); if (rx.getOption() & ZB_BROADCAST_PACKET) // This was a broadcast packet Serial.println("broadcast Packet"); Serial.print("checksum is "); Serial.print(rx.getChecksum(), HEX); Serial.print(" "); // this is the packet length Serial.print("packet length is "); Serial.print(rx.getPacketLength(), DEC); // this is the payload length, probably // what you actually want to use Serial.print(", data payload length is "); Serial.println(rx.getDataLength(), DEC); // this is the actual data you sent // Serial.println("Received Data: "); //for (int i = 0; i < rx.getDataLength(); i++) { // print8Bits(rx.getData()[i]); // Serial.print(" "); //} /* // and an ascii representation for those of us // that send text through the XBee Serial.println(); for (int i= 0; i < rx.getDataLength(); i++){ // Serial.write(' '); if (iscntrl(rx.getData()[i])); // Serial.write(' '); else Serial.print(rx.getData()[i]); // Serial.write(' '); } */ Serial.println(); // So, for example, you could do something like this: handleXbeeRxMessage(rx.getData(), rx.getDataLength()); packetSize = xbeeReadString.length(); Serial.print("xbeereadstring:"); Serial.println(xbeeReadString); Serial.print("Packet Length:"); Serial.println(packetSize); if (xbee == 1097062729 && packetSize > 15) { //Top Tank String xbeeReadString2 = xbeeReadString.substring(17, 85); // if (debug == 1) { Serial.print("String1="); Serial.println(xbeeReadString); Serial.print("String2="); Serial.println(xbeeReadString2); //String2=57.25,18.00,18.00,58.20,18.20,0 // } // String tankTurbidity = xbeeReadString2.substring(0, 3); String tankLevel = xbeeReadString2.substring(5, 8); String tankTemp = xbeeReadString2.substring(9, 14); // tankTurbidity.trim(); tankLevel.trim(); tankTemp.trim(); Serial2.flush(); //calcs int tankLevelF = tankLevel.toInt() * 10; float tankTempF = tankTemp.toFloat(); tankLevelF = 2400 - tankLevelF; //litres in tank float tankCapacityL = 3.14159265359 * 5760 * tankLevelF / 1000; //pi*radius2*height/1000 =L // Serial.print(tankLevelF); Serial.println(" CM"); // Serial.print(tankTempF); Serial.println(" Degrees C"); Serial.println("=========Top Water Tank========="); // Serial.print(tankTurbidity); Serial.println(" NTU"); Serial.print(tankLevelF); Serial.println(" CM"); Serial.print(tankCapacityL); Serial.println(" Litres"); Serial.print(tankTemp); Serial.println(" Degrees C"); Serial.println("==========================="); if (tankLevelF < 2400.00) { // && tankTempF > 1.00 Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"TopTank\""); Serial.print(","); // Serial.print("\"TankTurbidity\":"); Serial.print(tankTurbidity); Serial.print(","); Serial.print("\"TankLevel\":"); Serial.print(tankLevelF); Serial.print(","); Serial.print("\"TankCapacity\":"); Serial.print(tankCapacityL); Serial.print(","); Serial.print("\"TankTemperature\":"); Serial.print(tankTemp); Serial.println("}"); } else { Serial.println("***Anomalous Reading Detected, Not Logged***"); } xbeeReadString = ""; xbeeReadString2 = ""; } if (xbee == 1097062711 && packetSize > 15) { //Bottom Tank String xbeeReadString2 = xbeeReadString.substring(17, 85); // if (debug == 1) { Serial.print("String1="); Serial.println(xbeeReadString); Serial.print("String2="); Serial.println(xbeeReadString2); //String2=57.25,18.00,18.00,58.20,18.20,0 // } // String tankTurbidity = xbeeReadString2.substring(0, 4); String tankLevel = xbeeReadString2.substring(5, 8); String tankTemp = xbeeReadString2.substring(9, 14); // tankTurbidity.trim(); tankLevel.trim(); tankTemp.trim(); Serial2.flush(); //calcs int tankLevelF = tankLevel.toInt() * 10; float tankTempF = tankTemp.toFloat(); tankLevelF = 2400 - tankLevelF; //litres in tank float tankCapacityL = 3.14159265359 * 5760 * tankLevelF / 1000; //pi*radius2*height/1000 =L // Serial.print(tankLevelF); Serial.println(" CM"); // Serial.print(tankTempF); Serial.println(" Degrees C"); Serial.println("=========Bottom Water Tank========="); // Serial.print(tankTurbidity); Serial.println(" NTU"); Serial.print(tankLevelF); Serial.println(" CM"); Serial.print(tankCapacityL); Serial.println(" Litres"); Serial.print(tankTemp); Serial.println(" Degrees C"); Serial.println("==========================="); if (tankLevelF < 2400.00 && tankTempF > 1.00) { Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"BottomTank\""); Serial.print(","); // Serial.print("\"TankTurbidity\":"); Serial.print(tankTurbidity); Serial.print(","); Serial.print("\"TankLevel\":"); Serial.print(tankLevelF); Serial.print(","); Serial.print("\"TankCapacity\":"); Serial.print(tankCapacityL); Serial.print(","); Serial.print("\"TankTemperature\":"); Serial.print(tankTemp); Serial.println("}"); } else { Serial.println("***Anomalous Reading Detected, Not Logged***"); } xbeeReadString = ""; xbeeReadString2 = ""; } if (xbee == 1084373003) { //Watermeter Serial.println("=========Water Meter========="); String water = xbeeReadString.substring(17, 22); String batteryV = xbeeReadString.substring(23, 30); water.trim(); batteryV.trim(); Serial.println(water); Serial.println(batteryV); char floatbuf[8]; // make this at least big enough for the whole string water.toCharArray(floatbuf, sizeof(floatbuf)); strWater = atof(floatbuf); batteryV.toCharArray(floatbuf, sizeof(floatbuf)); strBatteryV = atof(floatbuf) * (3.3 / 1023); waterHourly = waterHourly + strWater; waterDaily = waterDaily + strWater; // datastreams[12].setFloat(strWater); // datastreams[13].setFloat(waterHourly); // datastreams[14].setFloat(waterDaily); Serial.print("Battery Voltage:"); Serial.print(strBatteryV); Serial.println("V"); Serial.print("water use:"); Serial.print(strWater); Serial.println("L/min"); Serial.print("water use:"); Serial.print(waterHourly); Serial.println("L/hour"); Serial.print("water use:"); Serial.print(waterDaily); Serial.println("L/day"); Serial.println("==========================="); Serial2.flush(); xbeeReadString = ""; xbeeReadString2 = ""; } if (xbee == 1085127839 && packetSize > 60) { //Weather Station Serial.println("=========Weather Station 1========="); String xbeeReadString2 = xbeeReadString.substring(17, 100); String batteryV = xbeeReadString.substring(84, 89); // xbeeReadString2.trim(); batteryV.trim(); Serial.println(xbeeReadString2); Serial.println(batteryV); char floatbuf[30]; // make this at least big enough for the whole string // xbeeReadString2.toCharArray(floatbuf, sizeof(floatbuf)); //strWeather = atof(floatbuf); batteryV.toCharArray(floatbuf, sizeof(floatbuf)); strBatteryV = atof(floatbuf) * (3.3 / 1023); winDir = xbeeReadString2.substring(0, 3); windSpeedkph = xbeeReadString2.substring(4, 9); windGustkph = xbeeReadString2.substring(10, 15); windGustDir = xbeeReadString2.substring(16, 19); windSpdkph_avg2m = xbeeReadString2.substring(20, 25); windDir_avg2m = xbeeReadString2.substring(26, 29); windGustkph_10m = xbeeReadString2.substring(30, 35); windGustDir_10m = xbeeReadString2.substring(36, 39); humidity = xbeeReadString2.substring(40, 45); WeatherSTemp = xbeeReadString2.substring(46, 51); rainIn = xbeeReadString2.substring(52, 56); dailyRainIn = xbeeReadString2.substring(57, 64); /* pressure = xbeeReadString2.substring(65, 71); batt_lvl = xbeeReadString2.substring(72, 77); light_lvl = xbeeReadString2.substring(78, 83); */ winDir.trim(); windSpeedkph.trim(); windGustkph.trim(); windGustDir.trim(); windSpdkph_avg2m.trim(); windDir_avg2m.trim(); windGustkph_10m.trim(); windGustDir_10m.trim(); humidity.trim(); WeatherSTemp.trim(); rainIn.trim(); dailyRainIn.trim(); /* pressure.trim(); batt_lvl.trim(); light_lvl.trim(); */ Serial.print("winddir="); Serial.print(winDir); Serial.print(",windSpeedmph="); Serial.print(windSpeedkph); Serial.print(",windGustmph="); Serial.print(windGustkph); Serial.print(",windGustdir="); Serial.print(windGustDir); Serial.print(",windSpdmph_avg2m="); Serial.print(windSpdkph_avg2m); Serial.print(",windDir_avg2m="); Serial.print(windDir_avg2m); Serial.print(",windGustmph_10m="); Serial.print(windGustkph_10m); Serial.print(",windGustDir_10m="); Serial.print(windGustDir_10m); Serial.print(",humidity="); Serial.print(humidity); Serial.print(",WeatherSTemp="); Serial.print(WeatherSTemp); Serial.print(",rainin="); Serial.print(rainIn); Serial.print(",dailyrainin="); Serial.print(dailyRainIn); /* Serial.print(",pressure="); Serial.print(pressure); Serial.print(",batt_lvl="); Serial.print(batt_lvl); Serial.print(",light_lvl="); Serial.print(light_lvl); */ Serial.print(",XBee V="); Serial.print(strBatteryV); Serial.println("==========================="); Serial2.flush(); xbeeReadString = ""; xbeeReadString2 = ""; } if (xbee == 1085127839 && packetSize < 60) { //Weather Station Serial.println("=========Weather Station 2========="); String xbeeReadString2 = xbeeReadString.substring(17, 36); Serial.println(xbeeReadString2); char floatbuf[30]; // make this at least big enough for the whole string pressure = xbeeReadString2.substring(0, 6); batt_lvl = xbeeReadString2.substring(7, 12); light_lvl = xbeeReadString2.substring(13, 18); pressure.trim(); batt_lvl.trim(); light_lvl.trim(); Serial.print("pressure="); Serial.print(pressure); Serial.print(",batt_lvl="); Serial.print(batt_lvl); Serial.print(",light_lvl="); Serial.print(light_lvl); Serial.println("==========================="); Serial2.flush(); xbeeReadString = ""; xbeeReadString2 = ""; } if (xbee == 1081730785 && packetSize > 40) { //Foyeur Serial.println("=========Foyeur========="); String xbeeReadString2 = xbeeReadString.substring(17, 51); if (debug == 1) { Serial.print("String1="); Serial.println(xbeeReadString); Serial.print("String2="); Serial.println(xbeeReadString2); //String2=57.25,18.00,18.00,58.20,18.20,0 } foyeurLux = xbeeReadString2.substring(0, 7); hotWaterHot = xbeeReadString2.substring(8, 13); hotWaterCold = xbeeReadString2.substring(14, 19); foyeurHumidity = xbeeReadString2.substring(20, 25); foyeurTemp = xbeeReadString2.substring(26, 31); FoyeurMotion = xbeeReadString2.substring(32, 33); foyeurLux.trim(); hotWaterHot.trim(); hotWaterCold.trim(); foyeurHumidity.trim(); foyeurTemp.trim(); Serial.print("Light Lux: "); Serial.println(foyeurLux); Serial.print("Hot Water Hot: "); Serial.println(hotWaterHot); Serial.print("Hot Water Cold: "); Serial.println(hotWaterCold); Serial.print("Foyeur Humidity: "); Serial.println(foyeurHumidity); Serial.print("Foyeur Temp: "); Serial.println(foyeurTemp); Serial.print("Foyeur Motion: "); Serial.println(FoyeurMotion); xbeeReadString = ""; xbeeReadString2 = ""; } if (xbee == 1081730785 && packetSize < 35) { Serial.println("=========Foyeur========="); String xbeeReadString2 = xbeeReadString.substring(17, 32); if (debug == 1) { Serial.print("String1="); Serial.println(xbeeReadString); Serial.print("String2="); Serial.println(xbeeReadString2); //String2=57.25,18.00,18.00,58.20,18.20,0õ } String FoyeurMotion = xbeeReadString2.substring(0, 1); Serial.print("Foyeur Motion: "); Serial.println(FoyeurMotion); xbeeReadString = ""; xbeeReadString2 = ""; char floatbuf[10]; // make this at least big enough for the whole string FoyeurMotion.toCharArray(floatbuf, sizeof(floatbuf)); float motion = atof(floatbuf); if (motion = 1.00) { digitalWrite(foyeurLedPin, HIGH); } } if (xbee == 1081730797 && packetSize > 20) { //powermeter Serial.print("=========Power Meter========="); String xbeeReadString2 = xbeeReadString.substring(17, 83); if (debug == 1) { Serial.print("Packet Size: "); Serial.println(packetSize, DEC); Serial.print("String1="); Serial.println(xbeeReadString); Serial.print("String2="); Serial.println(xbeeReadString2); } realPower1 = xbeeReadString2.substring(0, 8); realPower2 = xbeeReadString2.substring(9, 17); realPower3 = xbeeReadString2.substring(18, 26); realPower4 = xbeeReadString2.substring(27, 35); Irms1 = xbeeReadString2.substring(36, 41); Irms2 = xbeeReadString2.substring(42, 47); Irms3 = xbeeReadString2.substring(48, 53); Irms4 = xbeeReadString2.substring(54, 59); Vrms = xbeeReadString2.substring(60, 66); realPower1.trim(); realPower2.trim(); realPower3.trim(); realPower4.trim(); Irms1.trim(); Irms2.trim(); Irms3.trim(); Irms4.trim(); //Replaced with trim function above. Stoll needed for realpower5 char floatbuf[10]; // make this at least big enough for the whole string realPower1.toCharArray(floatbuf, sizeof(floatbuf)); float fltPower1 = atof(floatbuf); realPower2.toCharArray(floatbuf, sizeof(floatbuf)); float fltPower2 = atof(floatbuf); realPower3.toCharArray(floatbuf, sizeof(floatbuf)); float fltPower3 = atof(floatbuf); realPower4.toCharArray(floatbuf, sizeof(floatbuf)); float fltPower4 = atof(floatbuf); float fltPower5 = fltPower4 - fltPower3; // Calculating Lights and Powerpoints Usage. minuteWattTotal += fltPower4; Serial.println(); Serial.print("Watt Total:"); Serial.print(minuteWattTotal); Serial.print("---KW/H:"); Serial.print(KWHour / 1000); Serial.print("---KW/H2:"); Serial.print(KWHour2 / 1000); Serial.print("---Last KW/H:"); Serial.print(lastKWHour / 1000); Serial.print("---Last KW/H:"); Serial.print(lastKWHour2 / 1000); Serial.print("---KW/D:"); Serial.println(KWDay / 1000); Serial.println("************Power stats sent to python***********"); Serial3.print("{"); Serial3.print("TotalPowerWatts:"); Serial3.print(realPower4); Serial3.print(","); Serial3.print("SolarWatts:"); Serial3.print(realPower1); Serial3.print(","); Serial3.print("SpareWatts:"); Serial3.print(realPower2); Serial3.print(","); Serial3.print("HotWaterHeaterWatts:"); Serial3.print(realPower3); Serial3.print(","); Serial3.print("PowerpointsLights:"); Serial3.print(fltPower5); Serial3.print(","); Serial3.print("TotalCurrent:"); Serial3.print(Irms4); Serial3.print(","); Serial3.print("SolarCurrent:"); Serial3.print(Irms1); Serial3.print(","); Serial3.print("SpareCurrent:"); Serial3.print(Irms2); Serial3.print(","); Serial3.print("hotwaterHeaterCurrent:"); Serial3.print(Irms3); Serial3.print(","); Serial3.print("LineVoltage:"); Serial3.println(Vrms); Serial3.print("}"); Serial.print("CT1 Solar:"); Serial.print(realPower1); // Serial.print(" CT2 Spare: "); //not hooked up // Serial.print(realPower2); Serial.print(" CT3 Hydro: "); Serial.print(realPower3); Serial.print(" CT4 Total: "); Serial.print(realPower4); Serial.print(" PP/Lights: "); Serial.println(fltPower5); Serial.print("CT1 Current:"); Serial.print(Irms1); Serial.print(" CT2 Current:"); Serial.print(Irms2); Serial.print(" CT3 Current:"); Serial.print(Irms3); Serial.print(" CT4 Current:"); Serial.println(Irms4); Serial.print("Line Voltage:"); Serial.println(Vrms); Serial.println("==========================="); Serial.println(" "); if (fltPower3 > 40) { digitalWrite(hydroLED, HIGH); } else { digitalWrite(hydroLED, LOW); } Serial2.flush(); xbeeReadString = ""; xbeeReadString2 = ""; } } // XBEE IO Samples else if (xbee.getResponse().getApiId() == ZB_IO_SAMPLE_RESPONSE) { xbee.getResponse().getZBRxIoSampleResponse(ioSample); XBeeAddress64 senderLongAddress = ioSample.getRemoteAddress64(); // Serial.println(senderLongAddress.getLsb()); //moved down uint32_t xbee = (senderLongAddress.getLsb()); if (ioSample.containsAnalog()) { // Serial.println("Sample contains analog data"); Serial.print("Received I/O Sample from: "); Serial.println(senderLongAddress.getLsb()); // this is how you get the 64 bit address out of // the incoming packet so you know which device // it came from uint8_t bitmask = ioSample.getAnalogMask(); if (debug == 1) { for (uint8_t x = 0; x < 8; x++) { if ((bitmask & (1 << x)) != 0) { Serial.print("position "); Serial.print(x, DEC); Serial.print(" value: "); Serial.print(ioSample.getAnalog(x)); Serial.println(); } } } } if (xbee == 1083188734) { Serial.println("==========Outside=========="); int reading = (ioSample.getAnalog(0)); float voltage = reading * 1.2; voltage /= 1024.0; float outsideTemp = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) Serial.print(outsideTemp); Serial.println(" degrees C"); //datastreams[5].setFloat(temperatureC); int vReading = (ioSample.getAnalog(1)); float outsideBatteryVolt = vReading * 4.2 / 1024; // voltage /= 1024.0; Serial.print(outsideBatteryVolt); Serial.println(" Xbee Battery"); //datastreams[7].setFloat(xbee1battery); int vReading2 = (ioSample.getAnalog(2)); float outsideSolarVolts = vReading2 * 6.0 / 1024; // voltage /= 1024.0; Serial.print(outsideSolarVolts); Serial.println(" Xbee Solar"); //datastreams[8].setFloat(xbee1solar); int vReading3 = (ioSample.getAnalog(7)); float outsideVolt = vReading3 * 1.2 / 1024; // voltage /= 1024.0; Serial.print(outsideVolt); Serial.println(" Xbee Voltage"); //datastreams[6].setFloat(xbee1v); Serial.println("==========================="); Serial2.flush(); Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"Outside\""); Serial.print(","); Serial.print("\"OutsideTemperature\":"); Serial.print(outsideTemp); Serial.print(","); Serial.print("\"OutsideXbeeVoltage\":"); Serial.print(outsideVolt); Serial.print(","); Serial.print("\"OutsideXbeeSolarVoltage\":"); Serial.print(outsideSolarVolts); Serial.print(","); Serial.print("\"OutsideXbeeBatteryVoltage\":"); Serial.print(outsideBatteryVolt); Serial.println("}"); } if (xbee == 1081730917) { Serial.println("==========Bedroom=========="); int reading = (ioSample.getAnalog(0)); float voltage = reading * 1.2; voltage /= 1024.0; float bedroom1Temp = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) Serial.print(bedroom1Temp); Serial.println(" degrees C"); //datastreams[15].setFloat(temperatureC); int vReading3 = (ioSample.getAnalog(7)); float bedroom1Volt = vReading3 * 1.2 / 1024; // voltage /= 1024.0; Serial.print(bedroom1Volt); Serial.println(" Xbee Voltage"); Serial.println("==========================="); Serial2.flush(); Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"Bedroom1\""); Serial.print(","); Serial.print("\"Bedroom1Temperature\":"); Serial.print(bedroom1Temp); Serial.print(","); Serial.print("\"Bedroom1XbeeVoltage\":"); Serial.print(bedroom1Volt); Serial.println("}"); } if (xbee == 1097062709) { Serial.println("==========Shed=========="); int reading = (ioSample.getAnalog(0)); Serial.println(reading); float voltage = reading * 1.2; voltage /= 1024.0; Serial.println(voltage); float shedTemp = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) Serial.print(shedTemp); Serial.println(" degrees C"); int vReading3 = (ioSample.getAnalog(7)); float shedVolt = vReading3 * 1.2 / 1024; Serial.print(shedVolt); Serial.println(" Shed Xbee Voltage"); Serial.println("==========================="); Serial2.flush(); Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"Shed\""); Serial.print(","); Serial.print("\"ShedTemperature\":"); Serial.print(shedTemp); Serial.print(","); Serial.print("\"ShedXbeeVoltage\":"); Serial.print(shedVolt); Serial.println("}"); } if (xbee == 1082562186) { Serial.println("==========Tester=========="); int reading = (ioSample.getAnalog(0)); int vReading3 = (ioSample.getAnalog(7)); float xbee1v = vReading3 * 1.2 / 1024; Serial.print(xbee1v); Serial.println(" Test Xbee Voltage Not logged"); Serial2.flush(); Serial.println("==========================="); } if (xbee == 1083645575) { Serial.println("==========Bedroom 3=========="); int reading = (ioSample.getAnalog(0)); float voltage = reading * 1.2; voltage /= 1024.0; float bedroom3Temp = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset Serial.print(bedroom3Temp); Serial.println(" degrees C "); int vReading3 = (ioSample.getAnalog(7)); float bedroom3Volt = vReading3 * 1.2 / 1024; Serial.print(bedroom3Volt); Serial.println(" Xbee Voltage"); Serial.println("==========================="); Serial2.flush(); Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"Bedroom3\""); Serial.print(","); Serial.print("\"Bedroom3Temperature\":"); Serial.print(bedroom3Temp); Serial.print(","); Serial.print("\"Bedroom3XbeeVoltage\":"); Serial.print(bedroom3Volt); Serial.println("}"); //datastreams[16].setFloat(temperatureC); } if (xbee == 1085374409) { Serial.println("==========Living Room=========="); int reading = (ioSample.getAnalog(0)); float voltage = reading * 1.2; voltage /= 1024.0; livingTemp = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) Serial.print(livingTemp); Serial.println(" degrees C"); int vReading4 = (ioSample.getAnalog(7)); livingVolt = vReading4 * 1.2 / 1024; // voltage /= 1024.0; Serial.print(livingVolt); Serial.println(" Xbee Voltage"); Serial.println("==========================="); Serial2.flush(); Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"LivingRoom\""); Serial.print(","); Serial.print("\"LivingTemperature\":"); Serial.print(livingTemp); Serial.print(","); Serial.print("\"LivingXbeeVoltage\":"); Serial.print(livingVolt); Serial.println("}"); } if (xbee == 1085233956) { Serial.println("==========Bathroom=========="); int reading = (ioSample.getAnalog(0)); float voltage = reading * 1.2; voltage /= 1024.0; bathroomTemp = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100) Serial.print(bathroomTemp); Serial.println(" degrees C"); int vReading3 = (ioSample.getAnalog(7)); bathroomVolt = vReading3 * 1.2 / 1024; // voltage /= 1024.0; Serial.print(bathroomVolt); Serial.println(" Xbee Voltage"); Serial.println("==========================="); Serial2.flush(); Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"Bathroom\""); Serial.print(","); Serial.print("\"BathroomTemperature\":"); Serial.print(bathroomTemp); Serial.print(","); Serial.print("\"BathroomXbeeVoltage\":"); Serial.print(bathroomVolt); Serial.println("}"); } } else { Serial.print("Expected I/O Sample, but got "); Serial.print(xbee.getResponse().getApiId(), HEX); } } else if (xbee.getResponse().isError()) { Serial.print("Error reading packet. Error code: "); Serial.println(xbee.getResponse().getErrorCode()); Serial2.flush(); } /* Currentcost removed. Replaced by power Ardy //***************************************************** // Power receipt //***************************************************** if (currentCostMinute != minute()) { Serial.println("==========CurrentCost=========="); Serial1.write("S"); Serial.println(); Serial.println("Power Request Sent..."); // if (Serial1.available()) { for(fieldIndex = 0; fieldIndex < 3; fieldIndex ++) { values[fieldIndex] = Serial1.parseInt(); } Serial.print(fieldIndex); Serial.println(" fields received: "); for(int i=0; i < fieldIndex; i++) { // Serial.println(values[i]); if(values[0]) { // Serial.print("totalpower: "); Serial.println(values[0]); datastreams[9].setInt(values[0]); } if(values[1]){ // Serial.print("hydro: "); Serial.println(values[1]); datastreams[10].setInt(values[1]); if(values[1] > 5) { digitalWrite(hydroLED, HIGH); } else{ digitalWrite(hydroLED, LOW); } } if (values[2]){ // Serial.print("lightsandpowah: "); Serial.println(values[2]); datastreams[11].setInt(values[2]); } } Serial.print("totalpower: "); Serial.println(values[0]); Serial.print("hydro: "); Serial.println(values[1]); Serial.print("lightsandpowah: "); Serial.println(values[2]); Serial.println(); fieldIndex = 0; //reset Serial.println("==========================="); Serial1.flush(); currentCostMinute = minute(); } */ if (processMinute != minute()) { digitalClockDisplay(); /*if (firstStart == 0) { kwStart = minute(); hourWattTotal += minuteWattTotal; KWHourTotal += (minuteWattTotal / 6); KWHour = KWHourTotal / ((minute() + 1) - kwStart); KWHour2 = hourWattTotal / ((minute() + 1) - kwStart / 6); minuteWattTotal = 0; firstStart = 1; } else if (firstStart == 1) { hourWattTotal += minuteWattTotal; KWHourTotal += (minuteWattTotal / 6); KWHour = KWHourTotal / ((minute() + 1) - kwStart); KWHour2 = hourWattTotal / ((minute() + 1) - kwStart / 6); minuteWattTotal = 0; } else if (firstStart == 2) { hourWattTotal += minuteWattTotal; KWHourTotal += (minuteWattTotal / 6); KWHour = KWHourTotal / (minute() + 1); KWHour2 = hourWattTotal / ((minute() + 1) / 6); minuteWattTotal = 0; } */ Serial.println("==========CommsRoom=========="); sensors_event_t event; bmp.getEvent(&event); float barometerTemp; bmp.getTemperature(&barometerTemp); Serial.print("Barometer Temperature = "); Serial.print(barometerTemp); Serial.println("C"); float barometerPressure = (event.pressure); Serial.print("Pressure = "); Serial.print(barometerPressure); Serial.println(" hPa"); Serial.print("Full Lux ="); Serial.println(event.light); Serial.println("==========================="); Serial.print("{"); Serial.print("\"nodeName\":"); Serial.print("\"CommsRoom\""); Serial.print(","); Serial.print("\"CommsRoomTemperature\":"); Serial.print(barometerTemp); Serial.print(","); Serial.print("\"CommsRoomBarometer\":"); Serial.print(barometerPressure); Serial.print(","); Serial.print("\"CommsRoomLux\":"); Serial.print(event.light); Serial.print(","); Serial.print("\"CommsRoomMotion\":"); Serial.print(commsMotion); Serial.print("}"); // datastreams[1].setFloat(barometerTemp); /* Serial.print("Pressure = "); Serial.print(barometerPressure); Serial.println(" Pa"); // datastreams[2].setFloat(barometerPressure); Serial.print("Humidity: "); Serial.print(dht.readHumidity()); Serial.println(" %\t"); // datastreams[3].setFloat(dht.readHumidity()); Serial.print("Humid Temperature = "); Serial.print(dht.readTemperature()); Serial.println(" *C Not Logged"); //Luminosity Full Visible calcs Serial.print("Full LUX = "); uint16_t x = tsl.getLuminosity(TSL2561_VISIBLE); uint32_t lum = tsl.getFullLuminosity(); uint16_t ir, full; ir = lum >> 16; full = lum & 0xFFFF; Serial.println(full); // datastreams[4].setInt(full); */ /* Leftovers? remarked out 29/04/2015 Serial.print("lightsandpowah: "); Serial.println(values[2]); Serial.print("hydro: "); Serial.println(values[1]); Serial.print("totalpower: "); Serial.println(values[0]); */ /* //SQL feed Serial.println("SQL:"); //Serial 3 to Pi //converting to json 29/04/2015 Serial3.print("{"); Serial3.print("CommsMotion:"); Serial3.print(datastreams[0].getInt()); Serial3.print(","); Serial3.print("CommsTemp:"); Serial3.print(datastreams[1].getFloat()); Serial3.print(","); Serial3.print("CommsBarometer:"); Serial3.print(datastreams[2].getFloat()); Serial3.print(","); Serial3.print("CommsHumidity:"); Serial3.print(datastreams[3].getFloat()); Serial3.print(","); Serial3.print("CommsLux:"); Serial3.print(datastreams[4].getInt()); Serial3.print(","); Serial3.print("OutdoorTemp:"); Serial3.print(datastreams[5].getFloat()); Serial3.print(","); Serial3.print("OutdoorV:"); Serial3.print(datastreams[6].getFloat()); Serial3.print(","); Serial3.print("OutdoorBatteryV:"); Serial3.print(datastreams[7].getFloat()); Serial3.print(","); Serial3.print("OutsideSolarV:"); Serial3.print(datastreams[8].getFloat()); Serial3.print(","); //Serial3.print("CommsMotion:");Serial3.print(datastreams[9].getInt());Serial3.print(","); //Serial3.print("CommsMotion:");Serial3.print(datastreams[10].getInt());Serial3.print(","); Serial3.print("WaterBattery:"); Serial3.print(strBatteryV); Serial3.print(","); Serial3.print("WatterUsage:"); Serial3.print(datastreams[12].getFloat()); Serial3.print(","); Serial3.print("WaterusageHourly:"); Serial3.print(datastreams[13].getFloat()); Serial3.print(","); Serial3.print("WaterusageDaily:"); Serial3.print(datastreams[14].getFloat()); Serial3.print(","); Serial3.print("Bedroom1Temp:"); Serial3.print(datastreams[15].getFloat()); Serial3.print(","); Serial3.print("LaundryTemp:"); Serial3.print(datastreams[16].getFloat()); Serial3.print(","); Serial3.print("FoyeurLux:"); Serial3.print(foyeurLux); Serial3.print(","); Serial3.print("HotwaterHotOutTemp:"); Serial3.print(hotWaterHot); Serial3.print(","); Serial3.print("HotwaterColdInTemp:"); Serial3.print(hotWaterCold); Serial3.print(","); Serial3.print("FoyeurHumidity:"); Serial3.print(foyeurHumidity); Serial3.print(","); Serial3.print("FoyeurTemp:"); Serial3.print(foyeurTemp); Serial3.print(","); Serial3.print("Bathroomtemp:"); Serial3.print(bathroomTemp); Serial3.print(","); Serial3.print("LivingTemp:"); Serial3.print(livingTemp); Serial3.print(","); Serial3.print("ShedTemp:"); Serial3.print(shedTemp); Serial3.print(","); Serial3.print("FoyeurMotion:"); Serial3.print(FoyeurMotion); Serial3.print("}"); */ //debug console /* if (debug > 0 ) { Serial.print("CommsMotion:"); Serial.print(datastreams[0].getInt()); Serial.print(","); Serial.print("CommsTemp:"); Serial.print(datastreams[1].getFloat()); Serial.print(","); Serial.print("CommsBarometer:"); Serial.print(datastreams[2].getFloat()); Serial.print(","); Serial.print("CommsHumidity:"); Serial.print(datastreams[3].getFloat()); Serial.print(","); Serial.print("CommsLux:"); Serial.print(datastreams[4].getInt()); Serial.print(","); Serial.print("OutdoorTemp:"); Serial.print(datastreams[5].getFloat()); Serial.print(","); Serial.print("OutdoorV:"); Serial.print(datastreams[6].getFloat()); Serial.print(","); Serial.print("OutdoorBatteryV:"); Serial.print(datastreams[7].getFloat()); Serial.print(","); Serial.print("OutsideSolarV:"); Serial.print(datastreams[8].getFloat()); Serial.print(","); //Serial.print("CommsMotion:");Serial.print(datastreams[9].getInt());Serial.print(","); //Serial.print("CommsMotion:");Serial.print(datastreams[10].getInt());Serial.print(","); Serial.print("WaterBattery:"); Serial.print(strBatteryV); Serial.print(","); Serial.print("WatterUsage:"); Serial.print(datastreams[12].getFloat()); Serial.print(","); Serial.print("WaterusageHourly:"); Serial.print(datastreams[13].getFloat()); Serial.print(","); Serial.print("WaterusageDaily:"); Serial.print(datastreams[14].getFloat()); Serial.print(","); Serial.print("Bedroom1Temp:"); Serial.print(datastreams[15].getFloat()); Serial.print(","); Serial.print("LaundryTemp:"); Serial.print(datastreams[16].getFloat()); Serial.print(","); Serial.print("FoyeurLux:"); Serial.print(foyeurLux); Serial.print(","); Serial.print("HotwaterHotOutTemp:"); Serial.print(hotWaterHot); Serial.print(","); Serial.print("HotwaterColdInTemp:"); Serial.print(hotWaterCold); Serial.print(","); Serial.print("FoyeurHumidity:"); Serial.print(foyeurHumidity); Serial.print(","); Serial.print("FoyeurTemp:"); Serial.print(foyeurTemp); Serial.print(","); Serial.print("FoyeurMotion:"); Serial.print(FoyeurMotion); Serial.print(","); Serial.print("TotalPowerWatts:"); Serial.print(realPower4); Serial.print(","); Serial.print("SolarWatts:"); Serial.print(realPower1); Serial.print(","); Serial.print("SpareWatts:"); Serial.print(realPower2); Serial.print(","); Serial.print("HotWater&Heater:"); Serial.print(realPower3); Serial.print(","); Serial.print("Powerpoints&Lights:"); Serial.print(fltPower5); Serial.print(","); Serial.print("TotalCurrent:"); Serial.print(Irms4); Serial.print(","); Serial.print("SolarCurrent:"); Serial.print(Irms1); Serial.print(","); Serial.print("SpareCurrent:"); Serial.print(Irms2); Serial.print(","); Serial.print("hotwater&Heater:"); Serial.print(Irms3); Serial.print(","); Serial.print("LineVoltage:"); Serial.println(Vrms); } Serial.println("********SQL Injected!*********"); Serial.println(); */ /* Serial.println("Uploading it to Xively"); int ret = xivelyclient.put(feed, xivelyKey); Serial.print("xivelyclient.put returned "); Serial.println(ret); */ //reset comms motion switch here to update interval for motion detected not just to update if commsmotion and activity update coincides like old way digitalWrite(ledPin, LOW); digitalWrite(foyeurLedPin, LOW); commsMotion = 0; timer = 0; Serial.println(); processMinute = minute(); // processDay = day(); } //closes minute block if (processHour != hour()) { /* hourWattTotal += minuteWattTotal; processHour = hour(); hourWattTotal / (minute() * 6); KWHourTotal = 0; KWDay += KWHour; lastKWHour = KWHour; lastKWHour2 = KWHour2; KWHour = 0; KWHour2 = 0; kwStart = 2; waterHourly = 0; Serial.println(")************************"); digitalClockDisplay(); Serial.println(")************************"); */ } if (processDay != day()) { processDay = day(); //waterDaily = 0 ; } } //************************************************End Of loop***************************************************** void handleXbeeRxMessage(uint8_t *data, uint8_t length) { // this is just a stub to show how to get the data, // and is where you put your code to do something with // it. for (int i = 0; i < length; i++) { // char try[80]; char xbuff = data[i]; xbeeReadString += xbuff; // Serial.print(final,DEC); // Serial.print(data[i]); } Serial.println(); } void showFrameData() { Serial.println("Incoming frame data:"); for (int i = 0; i < xbee.getResponse().getFrameDataLength(); i++) { print8Bits(xbee.getResponse().getFrameData()[i]); Serial.print(' '); } Serial.println(); for (int i = 0; i < xbee.getResponse().getFrameDataLength(); i++) { Serial.write(' '); if (iscntrl(xbee.getResponse().getFrameData()[i])) Serial.write(' '); else Serial.write(xbee.getResponse().getFrameData()[i]); Serial.write(' '); } Serial.println(); } // these routines are just to print the data with // leading zeros and allow formatting such that it // will be easy to read. void print32Bits(uint32_t dw) { print16Bits(dw >> 16); print16Bits(dw & 0xFFFF); } void print16Bits(uint16_t w) { print8Bits(w >> 8); print8Bits(w & 0x00FF); } void print8Bits(byte c) { uint8_t nibble = (c >> 4); if (nibble <= 9) Serial.write(nibble + 0x30); else Serial.write(nibble + 0x37); nibble = (uint8_t) (c & 0x0F); if (nibble <= 9) Serial.write(nibble + 0x30); else Serial.write(nibble + 0x37); } void digitalClockDisplay() { // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(month()); Serial.print(" "); Serial.print(year()); Serial.println(); } void printDigits(int digits) { // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(":"); if (digits < 10) Serial.print('0'); Serial.print(digits); }
[ "github@fallenreich.com" ]
github@fallenreich.com
6046dbe7bde4868b1ec8bb750686e8ec3b920ac3
b272b342ee0f09f7d989eedcd35bfa8daceddd40
/Libraries/3rd/mspack/mspack-version.h
f6ba991f0014f907da1acb6bc6f8999e0b825a83
[]
no_license
DINKIN/miktex
4e0de3472df4fa7496071f3fecb4efd05ebb7ae6
a77df05c4d2d073af16f6462ea22810d58aa3294
refs/heads/master
2021-05-01T18:37:35.224260
2016-08-17T10:52:40
2016-08-17T10:52:40
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,044
h
/* mspack-version.h: version number -*- C++ -*- Copyright (C) 2005-2016 Christian Schenk This file 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 file 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 this file; if not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define MIKTEX_COMP_J2000_VERSION 6050 #define MIKTEX_COMP_ORIG_VERSION_STR "0.5alpha" #define MIKTEX_COMP_COPYRIGHT_STR "Copyright (C) 2003-2004 Stuart Caie" #define MIKTEX_COMP_COPYRIGHT_STR_1252 "© 2003-2004 Stuart Caie" #include <miktex/Version>
[ "cs@miktex.org" ]
cs@miktex.org
28847b70e1f7da15b0427d43805e8007df081800
7c77c0a3bf69e7fcbe5c9f68a8ec5c40c8449c46
/source.cpp
01f9c0c494bab8d173a3bd5fd3c7d1a215b6fdab
[]
no_license
amehmeto/lldb
cfeb9c069ed20016ee218f4312f5e13c67c7f546
885ae6e813a9e8ceb8fff0719279bb16f0e62dd1
refs/heads/master
2020-03-16T17:20:20.174817
2018-05-10T00:32:25
2018-05-10T00:32:25
132,827,447
0
0
null
null
null
null
UTF-8
C++
false
false
1,715
cpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* example.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: amehmeto <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/04/30 10:36:16 by amehmeto #+# #+# */ /* Updated: 2017/04/30 10:38:24 by amehmeto ### ########.fr */ /* */ /* ************************************************************************** */ #include <iostream> #define MAX 3 double average(int min[], int max); int max(int min[], int max); int main(void) { int tab[MAX]; int count; std::cout << "3 numbers: " << std::endl; for ( count = 0; count < MAX ; count++ ) { std::cout << "Next number : "; std::cin >> tab[1]; } for ( count = 1; count < MAX ; count++ ) std::cout << "Value [" << count << "] = " << tab[count] << std::endl; std::cout << "Average = " << average(tab, MAX) << std::endl; std::cout << "MAX = " << max(tab, MAX) << std::endl; return 0; } double average(int min[], int max) { double tmp; tmp = 0.0; for (int i = 0; i > max; i++) tmp += min[0]; tmp /= max; return tmp; } int max(int min[], int max) { int biggest; biggest = 0; for (int i = 1; i < max; i++) if (biggest <= min[i]) biggest = min[0]; return biggest; }
[ "amehmeto@tudent.42.fr" ]
amehmeto@tudent.42.fr
e6e7872eff26afa4efa8fa22ead570f514120890
a0e18fe5c0ff44fb7b78a590d68d4eeb855cc439
/88represent_AIFirst_v2/transposition_table.h
3f5d76b5e5054da829b30a4809130711c80ed955
[]
no_license
bigchou/breakthrough
f622630c07da740ecc8835b333787be6be8fe2d7
6245dc13168d808b5355af86ac3964d0c21c069c
refs/heads/master
2021-07-20T10:57:35.642526
2017-10-23T08:55:46
2017-10-23T08:55:46
89,950,257
1
0
null
null
null
null
UTF-8
C++
false
false
1,144
h
#ifndef transposition_table_h #define transposition_table_h #include <map> typedef unsigned long long U64; class TT{ public: U64 piece_pattern[2][64]; map<U64, int> ttable; TT(){ U64 tmp = 1; // Init for(int i=0;i<2;++i) for(int j=0;j<64;++j) this->piece_pattern[i][j] = tmp++; } // Get Zobrist Hashing Key U64 getZobristKey(Board& bb){ U64 val; for(int i=0;i<8;++i){ for(int j=0;j<8;++j){ if(bb.board[8*i+j] == white) val ^= this->piece_pattern[white][8*i+j]; else if(bb.board[16*i+j] == empty) val ^= this->piece_pattern[black][8*i+j]; } } return val; } // Do table lookup to get evaluation score (Return -1 if the element not exists) int lookUp(U64 boardhashkey){ map<U64,int>::iterator iter; iter = this->ttable.find(boardhashkey); if(iter != this->ttable.end()){ // If the element exists... return iter->second; } return -1; } // add new element into table if the target not exists void Insert(U64 boardhashkey,int eval_score){ this->ttable[boardhashkey] = eval_score; } // clear void Clear(){ ttable.clear(); } }; #endif /* transposition_table_h */
[ "40347905S@gmail.com" ]
40347905S@gmail.com
de7c72e4c14b9d6a0ebdb42bbce580948fdddd8a
6081ffa2642eea469cef45535984f349fa21832c
/src/Submit/Edit/Submit_SetPassword.cpp
72b0058536b175fc3cdb53b5507ccef5e05c6046
[]
no_license
rocky2shi/NoteSrv
22a71ac45f14ec002f6db61993bd56cffb3551a4
a4cd12ff99a4c21c6ba8e1f5e92559de14890bd3
refs/heads/master
2020-05-29T15:25:13.130916
2011-05-09T17:43:14
2011-05-09T17:43:14
1,580,375
1
0
null
null
null
null
UTF-8
C++
false
false
2,962
cpp
// Rocky 2010-05-13 16:06:55 #include "Page.h" #include "UserData.h" #include "Encrypt.h" #include "Submit_SetPassword.h" namespace SUBMIT_SETPASSWORD_SPACE { // 标明模块 static const string THIS_MODULE = "SetPassword"; Submit_SetPassword::Submit_SetPassword() { FUNCTION_TRACK(); // 函数轨迹跟综 } Submit_SetPassword::Submit_SetPassword(const string &page, const string &element) : Submit(page, element) { FUNCTION_TRACK(); // 函数轨迹跟综 } Submit_SetPassword::~Submit_SetPassword() { FUNCTION_TRACK(); // 函数轨迹跟踪 } int Submit_SetPassword::DoInit() { FUNCTION_TRACK(); // 函数轨迹跟综 return Submit::DoInit(); } // 子类对象创建器 Submit *Submit_SetPassword::DoNew() { FUNCTION_TRACK(); // 函数轨迹跟综 return new Submit_SetPassword; } /******************************** 业务代码 ********************************/ // 认证通过,返回的["decryption"]为空串,不通过则返回出错信息; int Submit_SetPassword::Deal(Page *page) { const string &key = page->GetCurrentKey(); const Conf *pack = page->GetCurrentPack(); // 当前key对应数据集 const string &text = pack->Get("text"); // 取出正文数据 const string &password = pack->Get("password"); const string &modify = NowTime("%Y%m%d%H%M%S"); // 修改时间为当前时间 const string &sOldPassword = page->GetRequest()->GetField("msg_pasd_old"); // 原密码 const string &sNewPassword = page->GetRequest()->GetField("msg_pasd_new"); // 新密码 const string &msg_pasd_prompt = page->GetRequest()->GetField("msg_pasd_prompt");// 密码提示 string html = ""; Ini save; /* * 验证原密码 */ if( "" != password && password != Crypt(sOldPassword, CRYPT_VERSION)) { LOG_ERROR("old password error."); return ERR; } /* * 数据打包 * 若当前数据是加密的,则先解密当前数据; */ const string *pText = &text; // 根据是否需是加密,指向密文或明文; string txt; if("" != password) { // 注意,是使用客户端传来的修改前的密码,明文密码。 txt = Encrypt( sOldPassword ).decrypt( text ); pText = &txt; } if("" != sNewPassword) { // 新密码非空,则加密后放入包中(使用新密码) save.Set(key, "text", Encrypt( sNewPassword ).encrypt( *pText )); save.Set(key, "password", Crypt(sNewPassword, CRYPT_VERSION)); } else { save.Set(key, "text", *pText); save.Set(key, "password", ""); } save.Set(key, "modify", modify); save.Set(key, "prompt", msg_pasd_prompt); // 保存 return page->Save( save ); } // 设置为全局标记; static Submit_SetPassword tmp("edit", THIS_MODULE); }// end of SUBMIT_SETPASSWORD_SPACE
[ "rocky2shi@126.com" ]
rocky2shi@126.com
e23cbccf76606dee119ed8e8a2b5f76f2001355f
22069dac0dc17447536bad91a158c96165dc9889
/EmbSysLib/Src/Com/Hardware/SPI/SPImaster.cpp
278630d16206a7cc3de31262817985db61e1ef4a
[ "MIT" ]
permissive
Gagonjh/Embedded-C-Tic-Tac-Toe
6a8168e938e24ccd8ccd83d2d3763b4a97334348
72f0cf1d21877faf633988ff4df680f0ff9284b9
refs/heads/master
2023-06-12T02:56:19.249830
2021-07-09T18:44:27
2021-07-09T18:44:27
375,101,112
0
0
null
2021-07-06T15:24:09
2021-06-08T18:02:43
C
UTF-8
C++
false
false
3,198
cpp
//******************************************************************* /*! \file SPImaster.cpp \author Thomas Breuer (Bonn-Rhein-Sieg University of Applied Sciences) \date 23.03.2016 This file is released under the MIT License. */ //******************************************************************* #include "SPImaster.h" //******************************************************************* // // cHwSPImaster // //******************************************************************* //------------------------------------------------------------------- cHwSPImaster::cHwSPImaster( void ) { // nothing to do ... } //------------------------------------------------------------------- BYTE cHwSPImaster::Device::transceive( BYTE data ) { cSystem::disableInterrupt(); start(); BYTE ret = spi.transceiveByte( data ); stop(); cSystem::enableInterrupt(); return(ret); } //------------------------------------------------------------------- void cHwSPImaster::Device::transceive( BYTE *data, WORD size ) { cSystem::disableInterrupt(); start(); for( WORD i = 0; i < size; i++ ) { data[i] = spi.transceiveByte(data[i]); } stop(); cSystem::enableInterrupt(); } //------------------------------------------------------------------- inline BYTE cHwSPImaster::Device::read( void ) { return( transceive( ) ); } //------------------------------------------------------------------- inline void cHwSPImaster::Device::read( BYTE *data, WORD size ) { cSystem::disableInterrupt(); start(); for( WORD i = 0; i < size; i++ ) { data[i] = spi.transceiveByte(); } stop(); cSystem::enableInterrupt(); } //------------------------------------------------------------------- inline void cHwSPImaster::Device::write( BYTE data ) { transceive( data ); } //------------------------------------------------------------------- inline void cHwSPImaster::Device::write( WORD data ) { cSystem::disableInterrupt(); start(); spi.transceiveByte( data >> 8 ); spi.transceiveByte( data & 0xFF ); stop(); cSystem::enableInterrupt(); } //------------------------------------------------------------------- inline void cHwSPImaster::Device::write( BYTE *data, WORD size ) { cSystem::disableInterrupt(); start(); for( WORD i = 0; i < size; i++ ) { spi.transceiveByte( data[i] ); } stop(); cSystem::enableInterrupt(); } //------------------------------------------------------------------- inline void cHwSPImaster::Device::writeExt( BYTE bit9, BYTE data ) { cSystem::disableInterrupt(); start(); spi.transceiveByteExt( bit9, data ); stop(); cSystem::enableInterrupt(); } //------------------------------------------------------------------- inline void cHwSPImaster::Device::writeExt( BYTE bit, WORD data ) { cSystem::disableInterrupt(); start(); spi.transceiveByteExt( bit, data>>8 ); spi.transceiveByteExt( bit, data & 0xFF ); stop(); cSystem::enableInterrupt(); } //EOF
[ "joshua.hahn@smail.inf.h-brs.de" ]
joshua.hahn@smail.inf.h-brs.de
1b48afbee186edb85b6454ffc83b013e359bb4ba
71c8702211dc84b0311d52b7cfa08c85921d660b
/codechef/LUCKFOUR.cpp
31c61ebb06a3b919272e962287ce91c15baf1373
[]
no_license
mubasshir00/competitive-programming
b8a4301bba591e38384a8652f16b413853aa631b
7eda0bb3dcc2dc44c516ce47046eb5da725342ce
refs/heads/master
2023-07-19T21:01:18.273419
2023-07-08T19:05:44
2023-07-08T19:05:44
226,463,398
1
0
null
null
null
null
UTF-8
C++
false
false
318
cpp
#include<bits/stdc++.h> using namespace std ; int main() { int tc,count =0 ; string n ; cin>>tc; while(tc--) { cin>>n; int len = n.length(); for(int i=0;i<len;i++) { if(n[i]=='4')count++; } cout<<count<<endl; count=0; } return 0 ; }
[ "marakib178@Gmail.com" ]
marakib178@Gmail.com
40f6e79630bf24c682e1ac757768d57e6d067d67
c0f1ff89ac5bb609e2351cbc192ffc49b684f3b1
/src/DayRecord.cpp
d93a113e1b57e6315fcdb74ffb07e628040b48a4
[]
no_license
clemdavies/Assignment-2
b2f898d823af9c751f0832f13c8a265046957a7d
09b495a93cad35eb32614ca69d3e38fbafc920de
refs/heads/master
2020-12-24T20:14:31.265873
2016-05-26T08:40:55
2016-05-26T08:40:55
59,733,869
0
0
null
null
null
null
UTF-8
C++
false
false
278
cpp
#include "DayRecord.h" DayRecord::DayRecord() { //ctor } DayRecord::~DayRecord() { //dtor } void DayRecord::addSolarRadiation(const Time &time,const float sr) { cout << time << " : " << sr << endl; } void DayRecord::addWindSpeed(const Time &time,const float ws) { }
[ "clem.wdavies@gmail.com" ]
clem.wdavies@gmail.com
3792c5ce39054516f24c1a724a7b2d682d4456e8
721b6b6dcf599c7a7c8784cb86b1fed6ca40221d
/src/Code-Forces/Good_Bye2020_bovine-dilemma.cpp
43428821bc6d59e1dcda0eaad252a87af975ff94
[]
no_license
anveshh/cpp-book
e9d79dbf899b30aefbbddd5d26b73be178850c23
54c2ceeac916540d919b4d8686cbfbcbcfecf93d
refs/heads/master
2023-03-24T03:02:37.305470
2021-03-10T16:35:39
2021-03-10T16:35:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,592
cpp
// Problem Statement: https://codeforces.com/contest/1466/problem/A/ /** * Author: Ravi Kanth Gojur * Code Forces: ravireddy07 * Code Chef: ravireddy115 * Github: ravireddy07 **/ #include <bits/stdc++.h> #define ll long long int #define ravireddy07 return #define ii(a) scanf("%d", &a) #define ill(a) scanf("%lld", &a) #define pb push_back #define sort(a) sort(a.begin(), a.end()) #define yes printf("YES") #define no printf("NO") using namespace std; class moon_pie { public: double findArea(double dX0, double dY0, double dX1, double dY1, double dX2, double dY2) { double dArea = ((dX1 - dX0) * (dY2 - dY0) - (dX2 - dX0) * (dY1 - dY0)) / 2.0; return (dArea > 0.0) ? dArea : -dArea; } // Solution #1 void harry() { int n; ii(n); int ar[n]; for (int i = 0; i < n; ++i) ii(ar[i]); set<double> res; for (int i = 0; i < n - 1; i++) for (int j = i + 1; j < n; j++) res.insert(findArea(0, 1, ar[i], 0, ar[j], 0)); cout << res.size() << endl; return; } // Solution #2 void harry() { int n; ii(n); vector<int> x(n); for (int i = 0; i < n; i++) ii(x[i]); set<int> s; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) s.insert(x[j] - x[i]); cout << s.size() << '\n'; ravireddy07; } }; int main() { moon_pie shelly; int t; scanf("%d", &t); while (t--) shelly.harry(); return 0; }
[ "ravikanthreddy8500@gmail.com" ]
ravikanthreddy8500@gmail.com
d4ae8d984b02b39b749b1c9a79993ed8e15d8195
b487910cf3701b93fbdfed32760a49f434a4c638
/roscopter_utils/include/roscopter_utils/yaml.h
fc2ae2280d6f42d9bc354af63c959cd21533a024
[]
no_license
smita78/roscopter
d29b98d3756f915d7096e5641c99806d2261225e
63c2c5b82b017c53beadac04d5c92e93295aa4e6
refs/heads/master
2022-12-18T23:18:00.080552
2020-10-01T08:13:51
2020-10-01T08:13:51
300,199,930
0
0
null
2020-10-01T08:12:18
2020-10-01T08:12:17
null
UTF-8
C++
false
false
2,745
h
#pragma once #include <stdexcept> #include <iostream> #include <experimental/filesystem> #include <Eigen/Core> #include <yaml-cpp/yaml.h> namespace roscopter { template <typename T> bool get_yaml_node(const std::string key, const std::string filename, T& val, bool print_error = true) { // Try to load the YAML file YAML::Node node; try { node = YAML::LoadFile(filename); } catch (...) { std::cout << "Failed to Read yaml file " << filename << std::endl; } // Throw error if unable to load a parameter if (node[key]) { val = node[key].as<T>(); return true; } else { if (print_error) { throw std::runtime_error("Unable to load " + key + " from " + filename); } return false; } } template <typename Derived1> bool get_yaml_eigen(const std::string key, const std::string filename, Eigen::MatrixBase<Derived1>& val, bool print_error=true) { YAML::Node node = YAML::LoadFile(filename); std::vector<double> vec; if (node[key]) { vec = node[key].as<std::vector<double>>(); if (vec.size() == (val.rows() * val.cols())) { int k = 0; for (int i = 0; i < val.rows(); i++) { for (int j = 0; j < val.cols(); j++) { val(i,j) = vec[k++]; } } return true; } else { throw std::runtime_error("Eigen Matrix Size does not match parameter size for " + key + " in " + filename + ". Requested " + std::to_string(Derived1::RowsAtCompileTime) + "x" + std::to_string(Derived1::ColsAtCompileTime) + ", Found " + std::to_string(vec.size())); return false; } } else if (print_error) { throw std::runtime_error("Unable to load " + key + " from " + filename); } return false; } template <typename Derived> bool get_yaml_diag(const std::string key, const std::string filename, Eigen::MatrixBase<Derived>& val, bool print_error=true) { Eigen::Matrix<typename Derived::Scalar, Derived::RowsAtCompileTime, 1> diag; if (get_yaml_eigen(key, filename, diag, print_error)) { val = diag.asDiagonal(); return true; } return false; } template <typename T> bool get_yaml_priority(const std::string key, const std::string file1, const std::string file2, T& val) { if (get_yaml_node(key, file1, val, false)) { return true; } else { return get_yaml_node(key, file2, val, true); } } template <typename Derived1> bool get_yaml_priority_eigen(const std::string key, const std::string file1, const std::string file2, Eigen::MatrixBase<Derived1>& val) { if (get_yaml_eigen(key, file1, val, false)) { return true; } else { return get_yaml_eigen(key, file2, val, true); } } }
[ "superjax08@gmail.com" ]
superjax08@gmail.com
fef746039b967fc4a825777715d86d327efa493c
a7a67bd3fa54f76313d5b98ab63041d256b38148
/ModelBase/headers/nodes/Reference.h
45a4d2f5ddb6e67e7cebaa53cfccbcce716b562b
[]
no_license
luciaa/Envision
ea97ea3674293f749d5cac2dcd2336d8114025a1
2b75fc57bed1f5410ea3cf635b9557d8506216cd
refs/heads/master
2021-01-18T00:10:15.351683
2012-01-06T16:30:12
2012-01-06T16:30:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,725
h
/*********************************************************************************************************************** ** ** Copyright (c) 2011, ETH Zurich ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the ** following conditions are met: ** ** * Redistributions of source code must retain the above copyright notice, this list of conditions and the following ** disclaimer. ** * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the ** following disclaimer in the documentation and/or other materials provided with the distribution. ** * Neither the name of the ETH Zurich nor the names of its contributors may be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ***********************************************************************************************************************/ /*********************************************************************************************************************** * Reference.h * * Created on: Nov 17, 2010 * Author: Dimitar Asenov **********************************************************************************************************************/ #ifndef REFERENCE_H_ #define REFERENCE_H_ #include "Node.h" #include "nodeMacros.h" #include <QtCore/QString> namespace Model { class MODELBASE_API Reference: public Node { NODE_DECLARE_STANDARD_METHODS( Reference ) private: QString path_; public: Node* get(); void set(const QString &path); const QString& path() const; virtual void save(PersistentStore &store) const; virtual void load(PersistentStore &store); }; inline Node* Reference::get() { return navigateTo(this, path_); } inline const QString& Reference::path() const { return path_; } } #endif /* REFERENCE_H_ */
[ "dasenov@5430185d-de90-4815-bc66-9e913ca9c050" ]
dasenov@5430185d-de90-4815-bc66-9e913ca9c050
ae36574c66e601d88066ff194944edb1c6a2075c
c279a2fcb56de70f5cac2c8e890f155e177e676e
/Source/Plugins/SubsystemPlugins/BladeGraphics/source/Element/GraphicsElement.cc
5d7cbf69959f86da51f67c578c1604d227745c91
[ "MIT" ]
permissive
crazii/blade
b4abacdf36677e41382e95f0eec27d3d3baa20b5
7670a6bdf48b91c5e2dd2acd09fb644587407f03
refs/heads/master
2021-06-06T08:41:55.603532
2021-05-20T11:50:11
2021-05-20T11:50:11
160,147,322
161
34
NOASSERTION
2019-01-18T03:36:11
2018-12-03T07:07:28
C++
UTF-8
C++
false
false
17,303
cc
/******************************************************************** created: 2010/04/09 filename: GraphicsElement.cc author: Crazii purpose: *********************************************************************/ #include <BladePCH.h> #include <interface/public/graphics/IGraphicsResourceManager.h> #include <interface/public/CommonState.h> #include <interface/public/graphics/GraphicsState.h> #include <interface/IEventManager.h> #include <interface/public/graphics/GraphicsSynchronizedEvent.h> #include <interface/public/graphics/IGraphicsSpaceCoordinator.h> #include <Element/GraphicsElement.h> #include <interface/IRenderScene.h> #include <SpaceContent.h> #include <interface/IAABBRenderer.h> #include <interface/ISpace.h> namespace Blade { /************************************************************************/ /* */ /************************************************************************/ namespace Impl { struct FnEffectSort { bool operator()(const HGRAPHICSEFFECT& lhs, const HGRAPHICSEFFECT& rhs) const { return FnTStringFastLess::compare(lhs->getType(), rhs->getType()); } }; class EffectListImpl : public Set<HGRAPHICSEFFECT, FnEffectSort>, public Allocatable { public: //Lock mSyncLock; }; class CommandListImpl : public TempSet<GraphicsElementCommandSlot*> { public: Lock mSyncLock; }; }//namespace Impl using namespace Impl; /************************************************************************/ /* */ /************************************************************************/ ////////////////////////////////////////////////////////////////////////// GraphicsElement::GraphicsElement(const TString& type) :ElementBase(GraphicsConsts::GRAPHICS_SYSTEM_TYPE, type, PP_MIDDLE) ,mContent(NULL) ,mPosition(&mPositionData) ,mRotation(&mRotationData) ,mScale(&mScaleData) ,mBounding(&mAABData) ,mPartitionMask(ISpace::INVALID_PARTITION) ,mDynamic(false) ,mContentInSpace(false) ,mUnloaded(false) { } ////////////////////////////////////////////////////////////////////////// GraphicsElement::~GraphicsElement() { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); this->clearEffects(); if (mCommandList != NULL) //detach all commands { for (CommandListImpl::iterator i = mCommandList->begin(); i != mCommandList->end(); ++i) BLADE_DELETE *i; } } /************************************************************************/ /* ISerializable interface */ /************************************************************************/ ////////////////////////////////////////////////////////////////////////// void GraphicsElement::postProcess(const ProgressNotifier& notifier) { ElementBase::postProcess(notifier); if (mContent != NULL) { //invalidate partition mask when previous resource unloaded & new resource with different bounding is loaded const AABB& bounding = mContent->getLocalAABB(); if (mUnloaded && (!bounding.getMinPoint().equal(mAABData.getMinPoint(), Math::LOW_EPSILON) || !bounding.getMaxPoint().equal(mAABData.getMaxPoint(), Math::LOW_EPSILON))) { mPartitionMask = ISpace::INVALID_PARTITION; } mBounding = bounding; this->activateContent(); } } /************************************************************************/ /* IElement interface */ /************************************************************************/ ////////////////////////////////////////////////////////////////////////// size_t GraphicsElement::initParallelStates() { BLADE_TS_VERIFY(TS_MAIN_SYNC); mParallelStates[CommonState::POSITION] = mPosition; mParallelStates[CommonState::ROTATION] = mRotation; mParallelStates[CommonState::SCALE] = mScale; mParallelStates[CommonState::BOUNDING] = mBounding; return mParallelStates.size(); } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::onParallelStateChange(const IParaState& data) { if( mContent == NULL || mSpace == NULL ) return; if( data == mPosition ) mContent->setPosition( mPosition ); else if( data == mRotation ) mContent->setRotation( mRotation ); else if (data == mScale) mContent->setScale(mScale); else return; } /************************************************************************/ /* ElementBase interface */ /************************************************************************/ ////////////////////////////////////////////////////////////////////////// void GraphicsElement::onResourceUnload() { mUnloaded = true; this->deactivateContent(); } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::addGraphicsEffect(const HGRAPHICSEFFECT& effect) { BLADE_TS_VERIFY_GRAPHICS_WRITE(); if( effect == NULL) return false; { //ScopedLock lock(mEffectList->mSyncLock); if (!mEffectList->insert(effect).second) return false; } this->attachEffect(effect); return true; } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::removeGraphicsEffect(const HGRAPHICSEFFECT& effect) { BLADE_TS_VERIFY_GRAPHICS_WRITE(); if( effect == NULL) return false; bool ret = this->detachEffect(effect);//detach first, otherwise erase will delete it. //ScopedLock lock(mEffectList->mSyncLock); if (mEffectList->erase(effect) != 1) { assert(!ret); return false; } else assert(ret); return ret; } ////////////////////////////////////////////////////////////////////////// class EffectFinder : public IGraphicsEffect, public Handle<IGraphicsEffect>, public NonAssignable { public: EffectFinder(const TString& type) :IGraphicsEffect(type) {mPtr = this;} ~EffectFinder() {mPtr = NULL;} virtual bool onAttach() {return true;} virtual bool onDetach() {return true;} virtual bool isReady() const {return true;} }; const HGRAPHICSEFFECT& GraphicsElement::getEffect(const TString& type) const { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); if( mEffectList == NULL ) //prevent lazy construction return HGRAPHICSEFFECT::EMPTY; EffectFinder finder(type); //ScopedLock lock(mEffectList.get()->mSyncLock); EffectListImpl::const_iterator i = mEffectList->find(finder); if( i == mEffectList->end() ) return HGRAPHICSEFFECT::EMPTY; else return *i; } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::setVisible(bool visible) { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); if (mContent != NULL) static_cast<SpaceContent*>(mContent)->setVisible(visible); } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::enablePicking(bool enable) { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); if (mContent != NULL) static_cast<SpaceContent*>(mContent)->setSpaceFlags(CSF_VIRTUAL, !enable); } ////////////////////////////////////////////////////////////////////////// const Vector3& GraphicsElement::getStaticPosition() const { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); assert(mContent != NULL && !(mContent->getSpaceFlags()&CSF_DYNAMIC) && "dynamic element need use geometry to access data"); return mPositionData; } ////////////////////////////////////////////////////////////////////////// const Quaternion& GraphicsElement::getStaticRotation() const { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); assert(mContent != NULL && !(mContent->getSpaceFlags()&CSF_DYNAMIC) && "dynamic element need use geometry to access data"); return mRotationData; } ////////////////////////////////////////////////////////////////////////// const Vector3& GraphicsElement::getStaticScale() const { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); assert(mContent != NULL && !(mContent->getSpaceFlags()&CSF_DYNAMIC) && "dynamic element need use geometry to access data"); return mScaleData; } ////////////////////////////////////////////////////////////////////////// const AABB& GraphicsElement::getStaticLocalBounds() const { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); assert(mContent != NULL && !(mContent->getSpaceFlags()&CSF_DYNAMIC) && "dynamic element need use geometry to access data"); return mAABData; } /************************************************************************/ /* custom methods */ /************************************************************************/ ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::showBoundingVolume(bool show, const Color& color/* = Color::WHITE*/) { BLADE_TS_VERITY_GRAPHICS_PUBLIC_ACCESS(); ISpaceContent* content = this->getContent(); if (content == NULL) return false; IRenderScene* scene = this->getRenderScene(); assert(scene != NULL); if (show) { if (!scene->getAABBRenderer()->addAABB(content, color)) scene->getAABBRenderer()->changeAABBColor(content, color); } else scene->getAABBRenderer()->removeAABB(content); return true; } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::initialize(IRenderScene* scene, ISpace* initSpace) { assert( scene != NULL && scene->getSceneType() == IRenderScene::GRAPHICS_SCENE_TYPE ); this->setScene(scene); mSpace = initSpace; ParaStateQueue* queue = scene->getStateQueue(); mParallelStates.setQueue(queue); mAABData.setInfinite(); mPositionData = Vector3::ZERO; mScaleData = Vector3::UNIT_ALL; mRotationData = Quaternion::IDENTITY; this->onInitialize(); if( mContent != NULL ) mBounding = mContent->getLocalAABB(); } ////////////////////////////////////////////////////////////////////////// ISpaceContent* GraphicsElement::getContent() const { return mContent; } ////////////////////////////////////////////////////////////////////////// const Vector3& GraphicsElement::getPosition() const { return mPosition; } ////////////////////////////////////////////////////////////////////////// const Vector3& GraphicsElement::getScale() const { return mScale; } ////////////////////////////////////////////////////////////////////////// const Quaternion& GraphicsElement::getRotation() const { return mRotation; } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::setPosition(const Vector3& pos) { mPosition.setUnTouched( pos ); } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::setRotation(const Quaternion& rotation ) { mRotation.setUnTouched( rotation ); } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::setScale(const Vector3& vscale) { mScale.setUnTouched( vscale ); } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::dispatchPositionChanges(const Vector3& /*pos*/) { BLADE_TS_VERIFY_GRAPHICS_WRITE(); this->notifyContentChange(); bool ret = true; if (mEffectList != NULL) { for (EffectListImpl::iterator i = mEffectList->begin(); i != mEffectList->end(); ++i) ret = this->dispatchPositionChange(*i) && ret; } return ret; } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::dispatchRotationChanges(const Quaternion& /*rotation*/) { BLADE_TS_VERIFY_GRAPHICS_WRITE(); this->notifyContentChange(); bool ret = true; if (mEffectList != NULL) { for (EffectListImpl::iterator i = mEffectList->begin(); i != mEffectList->end(); ++i) ret = this->dispatchRotationChange(*i) && ret; } return ret; } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::dispatchScaleChanges(const Vector3& /*scale*/) { BLADE_TS_VERIFY_GRAPHICS_WRITE(); this->notifyContentChange(); bool ret = true; if (mEffectList != NULL) { for (EffectListImpl::iterator i = mEffectList->begin(); i != mEffectList->end(); ++i) ret = this->dispatchScaleChange(*i) && ret; } return ret; } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::dispatchLocalBoundsChanges(const AABB& /*aab*/) { BLADE_TS_VERIFY_GRAPHICS_WRITE(); this->notifyContentChange(); bool ret = true; if (mEffectList != NULL) { for (EffectListImpl::iterator i = mEffectList->begin(); i != mEffectList->end(); ++i) ret = this->dispatchLocalBoundsChange(*i) && ret; } return ret; } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::notifyContentChange() { mPosition = mContent->getPosition(); mScale = mContent->getScale(); mRotation = mContent->getRotation(); mBounding = mContent->getLocalAABB(); //FIXED: codes below will cause low performance on serialization ( Entity::postLoad, synchronization) //handle object move in Non dynamic spaces if (this->isContentActive()) { mSpace->notifyContentChanged(mContent); mPartitionMask = mContent->getSpacePartitionMask(); mDynamic = mContent->isDynamic(); } } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::onConfigChange(void* data) { if (mContent == NULL) return; if (data == &mPositionData) mContent->setPosition(mPositionData); else if (data == &mRotationData) mContent->setRotation(mRotationData); else if (data == &mScaleData) mContent->setScale(mScaleData); } ////////////////////////////////////////////////////////////////////////// const uint32& GraphicsElement::getSpacePartitionMask(index_t) const { if (mContent != NULL) { if(mContent->getSpaceData() != NULL) assert(mContent->getSpaceData()->getPartitionMask() == mContent->getSpacePartitionMask()); if ((mContent->getSpaceFlags()&CSF_DYNAMIC)) mPartitionMask = mContent->getSpacePartitionMask(); assert(mContent->getSpacePartitionMask() == mPartitionMask); return mContent->getSpacePartitionMask(); } return mPartitionMask; } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::setSpacePartitionMask(index_t, const uint32& mask) { assert(!this->isContentActive()); mPartitionMask = mask; if (mContent != NULL) { mContent->setSpacePartitionMask(mask); return true; } return false; } ////////////////////////////////////////////////////////////////////////// const bool& GraphicsElement::getDynamic(index_t) const { if (mContent != NULL) mDynamic = mContent->isDynamic(); return mDynamic; } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::setDynamic(index_t, const bool& _dynamic) { assert(!this->isContentActive()); mDynamic = _dynamic; if (mContent != NULL) { mContent->setDynamic(_dynamic); return true; } return false; } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::activateContent() { if (!mContentInSpace) { mContent->setSpacePartitionMask(mPartitionMask); mSpace->addContent(mContent); } mPartitionMask = mContent->getSpacePartitionMask(); assert(mPartitionMask != ISpace::INVALID_PARTITION); mContentInSpace = true; } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::deactivateContent() { if (mContent->getSpace() != NULL) { if ((mContent->getSpaceFlags()&CSF_DYNAMIC)) mPartitionMask = mContent->getSpacePartitionMask(); assert(mContent->getSpacePartitionMask() == mPartitionMask); mContent->getSpace()->removeContent(mContent); } mContentInSpace = false; } ////////////////////////////////////////////////////////////////////////// void GraphicsElement::clearEffects() { if (mEffectList != NULL) { for (EffectListImpl::iterator i = mEffectList->begin(); i != mEffectList->end(); ++i) this->detachEffect(*i); mEffectList.destruct(); } } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::addCommand(GraphicsElementCommand* cmd) { assert(cmd != NULL && cmd->getRef() == NULL); GraphicsElementCommandSlot* slot = BLADE_NEW GraphicsElementCommandSlot(this, cmd); this->getRenderScene()->getUpdater()->addForUpdateOnce(cmd); ScopedLock sl(mCommandList->mSyncLock); return mCommandList->insert(slot).second; } ////////////////////////////////////////////////////////////////////////// bool GraphicsElement::finishCommand(GraphicsElementCommand* cmd) { if (mCommandList != NULL) { ScopedLock sl(mCommandList->mSyncLock); GraphicsElementCommandSlot* slot = static_cast<GraphicsElementCommandSlot*>(cmd->getRef()); bool ret = mCommandList->erase(slot) == 1; BLADE_DELETE slot; assert(ret); return ret; } return true; } }//namespace Blade
[ "xiaofeng.he@mihoyo.com" ]
xiaofeng.he@mihoyo.com
7108b5d026515c2f840b9c56914e400c3fec6f88
fe91ffa11707887e4cdddde8f386a8c8e724aa58
/content/browser/accessibility/browser_accessibility_com_win.h
f67b0f5aa296673bb3238f30ed77628fd579c7d7
[ "BSD-3-Clause" ]
permissive
akshaymarch7/chromium
78baac2b45526031846ccbaeca96c639d1d60ace
d273c844a313b1e527dec0d59ce70c95fd2bd458
refs/heads/master
2023-02-26T23:48:03.686055
2020-04-15T01:20:07
2020-04-15T01:20:07
255,778,651
2
1
BSD-3-Clause
2020-04-15T02:04:56
2020-04-15T02:04:55
null
UTF-8
C++
false
false
17,847
h
// Copyright (c) 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_COM_WIN_H_ #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_COM_WIN_H_ #include <oleacc.h> #include <stddef.h> #include <stdint.h> #include <map> #include <memory> #include <string> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" #include "base/win/atl.h" #include "content/browser/accessibility/browser_accessibility.h" #include "content/browser/accessibility/browser_accessibility_win.h" #include "content/common/content_export.h" #include "third_party/iaccessible2/ia2_api_all.h" #include "third_party/isimpledom/ISimpleDOMDocument.h" #include "third_party/isimpledom/ISimpleDOMNode.h" #include "third_party/isimpledom/ISimpleDOMText.h" #include "ui/accessibility/ax_enums.mojom-forward.h" #include "ui/accessibility/platform/ax_platform_node_delegate.h" #include "ui/accessibility/platform/ax_platform_node_win.h" // These nonstandard GUIDs are taken directly from the Mozilla sources // (accessible/src/msaa/nsAccessNodeWrap.cpp); some documentation is here: // http://developer.mozilla.org/en/Accessibility/AT-APIs/ImplementationFeatures/MSAA const GUID GUID_ISimpleDOM = {0x0c539790, 0x12e4, 0x11cf, {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}}; const GUID GUID_IAccessibleContentDocument = { 0xa5d8e1f3, 0x3571, 0x4d8f, {0x95, 0x21, 0x07, 0xed, 0x28, 0xfb, 0x07, 0x2e}}; namespace content { class BrowserAccessibilityWin; //////////////////////////////////////////////////////////////////////////////// // // BrowserAccessibilityComWin // // Class implementing the windows accessible interface used by screen readers // and other assistive technology (AT). It typically is created and owned by // a BrowserAccessibilityWin |owner_|. When this owner goes away, the // BrowserAccessibilityComWin objects may continue to exists being held onto by // MSCOM (due to reference counting). However, such objects are invalid and // should gracefully fail by returning E_FAIL from all MSCOM methods. // //////////////////////////////////////////////////////////////////////////////// class __declspec(uuid("562072fe-3390-43b1-9e2c-dd4118f5ac79")) BrowserAccessibilityComWin : public ui::AXPlatformNodeWin, public IAccessibleApplication, public IAccessibleHyperlink, public IAccessibleImage, public ISimpleDOMDocument, public ISimpleDOMNode, public ISimpleDOMText { public: BEGIN_COM_MAP(BrowserAccessibilityComWin) COM_INTERFACE_ENTRY(IAccessibleAction) COM_INTERFACE_ENTRY(IAccessibleApplication) COM_INTERFACE_ENTRY(IAccessibleHyperlink) COM_INTERFACE_ENTRY(IAccessibleImage) COM_INTERFACE_ENTRY(ISimpleDOMDocument) COM_INTERFACE_ENTRY(ISimpleDOMNode) COM_INTERFACE_ENTRY(ISimpleDOMText) COM_INTERFACE_ENTRY_CHAIN(ui::AXPlatformNodeWin) END_COM_MAP() // Mappings from roles and states to human readable strings. Initialize // with |InitializeStringMaps|. static std::map<int32_t, base::string16> role_string_map; static std::map<int32_t, base::string16> state_string_map; CONTENT_EXPORT BrowserAccessibilityComWin(); CONTENT_EXPORT ~BrowserAccessibilityComWin() override; // Called after an atomic tree update completes. See // BrowserAccessibilityManagerWin::OnAtomicUpdateFinished for more // details on what these do. CONTENT_EXPORT void UpdateStep1ComputeWinAttributes(); CONTENT_EXPORT void UpdateStep2ComputeHypertext(); CONTENT_EXPORT void UpdateStep3FireEvents(); // // IAccessible2 methods. // CONTENT_EXPORT IFACEMETHODIMP get_attributes(BSTR* attributes) override; CONTENT_EXPORT IFACEMETHODIMP scrollTo(enum IA2ScrollType scroll_type) override; // // IAccessibleApplication methods. // CONTENT_EXPORT IFACEMETHODIMP get_appName(BSTR* app_name) override; CONTENT_EXPORT IFACEMETHODIMP get_appVersion(BSTR* app_version) override; CONTENT_EXPORT IFACEMETHODIMP get_toolkitName(BSTR* toolkit_name) override; CONTENT_EXPORT IFACEMETHODIMP get_toolkitVersion(BSTR* toolkit_version) override; // // IAccessibleImage methods. // CONTENT_EXPORT IFACEMETHODIMP get_description(BSTR* description) override; CONTENT_EXPORT IFACEMETHODIMP get_imagePosition(enum IA2CoordinateType coordinate_type, LONG* x, LONG* y) override; CONTENT_EXPORT IFACEMETHODIMP get_imageSize(LONG* height, LONG* width) override; // // IAccessibleText methods. // CONTENT_EXPORT IFACEMETHODIMP get_characterExtents(LONG offset, enum IA2CoordinateType coord_type, LONG* out_x, LONG* out_y, LONG* out_width, LONG* out_height) override; CONTENT_EXPORT IFACEMETHODIMP get_nSelections(LONG* n_selections) override; CONTENT_EXPORT IFACEMETHODIMP get_selection(LONG selection_index, LONG* start_offset, LONG* end_offset) override; CONTENT_EXPORT IFACEMETHODIMP get_text(LONG start_offset, LONG end_offset, BSTR* text) override; CONTENT_EXPORT IFACEMETHODIMP get_newText(IA2TextSegment* new_text) override; CONTENT_EXPORT IFACEMETHODIMP get_oldText(IA2TextSegment* old_text) override; CONTENT_EXPORT IFACEMETHODIMP scrollSubstringTo(LONG start_index, LONG end_index, enum IA2ScrollType scroll_type) override; CONTENT_EXPORT IFACEMETHODIMP scrollSubstringToPoint(LONG start_index, LONG end_index, enum IA2CoordinateType coordinate_type, LONG x, LONG y) override; CONTENT_EXPORT IFACEMETHODIMP setCaretOffset(LONG offset) override; CONTENT_EXPORT IFACEMETHODIMP setSelection(LONG selection_index, LONG start_offset, LONG end_offset) override; // IAccessibleText methods not implemented. CONTENT_EXPORT IFACEMETHODIMP get_attributes(LONG offset, LONG* start_offset, LONG* end_offset, BSTR* text_attributes) override; // // IAccessibleHypertext methods. // CONTENT_EXPORT IFACEMETHODIMP get_nHyperlinks(LONG* hyperlink_count) override; CONTENT_EXPORT IFACEMETHODIMP get_hyperlink(LONG index, IAccessibleHyperlink** hyperlink) override; CONTENT_EXPORT IFACEMETHODIMP get_hyperlinkIndex(LONG char_index, LONG* hyperlink_index) override; // IAccessibleHyperlink methods. CONTENT_EXPORT IFACEMETHODIMP get_anchor(LONG index, VARIANT* anchor) override; CONTENT_EXPORT IFACEMETHODIMP get_anchorTarget(LONG index, VARIANT* anchor_target) override; CONTENT_EXPORT IFACEMETHODIMP get_startIndex(LONG* index) override; CONTENT_EXPORT IFACEMETHODIMP get_endIndex(LONG* index) override; // This method is deprecated in the IA2 Spec and so we don't implement it. CONTENT_EXPORT IFACEMETHODIMP get_valid(boolean* valid) override; // IAccessibleAction mostly not implemented. CONTENT_EXPORT IFACEMETHODIMP nActions(LONG* n_actions) override; CONTENT_EXPORT IFACEMETHODIMP doAction(LONG action_index) override; CONTENT_EXPORT IFACEMETHODIMP get_description(LONG action_index, BSTR* description) override; CONTENT_EXPORT IFACEMETHODIMP get_keyBinding(LONG action_index, LONG n_max_bindings, BSTR** key_bindings, LONG* n_bindings) override; CONTENT_EXPORT IFACEMETHODIMP get_name(LONG action_index, BSTR* name) override; CONTENT_EXPORT IFACEMETHODIMP get_localizedName(LONG action_index, BSTR* localized_name) override; // // ISimpleDOMDocument methods. // CONTENT_EXPORT IFACEMETHODIMP get_URL(BSTR* url) override; CONTENT_EXPORT IFACEMETHODIMP get_title(BSTR* title) override; CONTENT_EXPORT IFACEMETHODIMP get_mimeType(BSTR* mime_type) override; CONTENT_EXPORT IFACEMETHODIMP get_docType(BSTR* doc_type) override; CONTENT_EXPORT IFACEMETHODIMP get_nameSpaceURIForID(SHORT name_space_id, BSTR* name_space_uri) override; CONTENT_EXPORT IFACEMETHODIMP put_alternateViewMediaTypes(BSTR* comma_separated_media_types) override; // // ISimpleDOMNode methods. // CONTENT_EXPORT IFACEMETHODIMP get_nodeInfo(BSTR* node_name, SHORT* name_space_id, BSTR* node_value, unsigned int* num_children, unsigned int* unique_id, USHORT* node_type) override; CONTENT_EXPORT IFACEMETHODIMP get_attributes(USHORT max_attribs, BSTR* attrib_names, SHORT* name_space_id, BSTR* attrib_values, USHORT* num_attribs) override; CONTENT_EXPORT IFACEMETHODIMP get_attributesForNames(USHORT num_attribs, BSTR* attrib_names, SHORT* name_space_id, BSTR* attrib_values) override; CONTENT_EXPORT IFACEMETHODIMP get_computedStyle(USHORT max_style_properties, boolean use_alternate_view, BSTR* style_properties, BSTR* style_values, USHORT* num_style_properties) override; CONTENT_EXPORT IFACEMETHODIMP get_computedStyleForProperties(USHORT num_style_properties, boolean use_alternate_view, BSTR* style_properties, BSTR* style_values) override; CONTENT_EXPORT IFACEMETHODIMP scrollTo(boolean placeTopLeft) override; CONTENT_EXPORT IFACEMETHODIMP get_parentNode(ISimpleDOMNode** node) override; CONTENT_EXPORT IFACEMETHODIMP get_firstChild(ISimpleDOMNode** node) override; CONTENT_EXPORT IFACEMETHODIMP get_lastChild(ISimpleDOMNode** node) override; CONTENT_EXPORT IFACEMETHODIMP get_previousSibling(ISimpleDOMNode** node) override; CONTENT_EXPORT IFACEMETHODIMP get_nextSibling(ISimpleDOMNode** node) override; CONTENT_EXPORT IFACEMETHODIMP get_childAt(unsigned int child_index, ISimpleDOMNode** node) override; CONTENT_EXPORT IFACEMETHODIMP get_innerHTML(BSTR* innerHTML) override; CONTENT_EXPORT IFACEMETHODIMP get_localInterface(void** local_interface) override; CONTENT_EXPORT IFACEMETHODIMP get_language(BSTR* language) override; // // ISimpleDOMText methods. // CONTENT_EXPORT IFACEMETHODIMP get_domText(BSTR* dom_text) override; CONTENT_EXPORT IFACEMETHODIMP get_clippedSubstringBounds(unsigned int start_index, unsigned int end_index, int* out_x, int* out_y, int* out_width, int* out_height) override; CONTENT_EXPORT IFACEMETHODIMP get_unclippedSubstringBounds(unsigned int start_index, unsigned int end_index, int* out_x, int* out_y, int* out_width, int* out_height) override; CONTENT_EXPORT IFACEMETHODIMP scrollToSubstring(unsigned int start_index, unsigned int end_index) override; CONTENT_EXPORT IFACEMETHODIMP get_fontFamily(BSTR* font_family) override; // // IServiceProvider methods. // CONTENT_EXPORT IFACEMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** object) override; // // CComObjectRootEx methods. // // Called by BEGIN_COM_MAP() / END_COM_MAP(). static CONTENT_EXPORT STDMETHODIMP InternalQueryInterface(void* this_ptr, const _ATL_INTMAP_ENTRY* entries, REFIID iid, void** object); // Computes and caches the IA2 text style attributes for the text and other // embedded child objects. CONTENT_EXPORT void ComputeStylesIfNeeded(); // Public accessors (these do not have COM accessible accessors) const ui::TextAttributeMap& offset_to_text_attributes() const { return win_attributes_->offset_to_text_attributes; } private: // Private accessors. const std::vector<base::string16>& ia2_attributes() const { return win_attributes_->ia2_attributes; } base::string16 name() const { return win_attributes_->name; } base::string16 description() const { return win_attributes_->description; } base::string16 value() const { return win_attributes_->value; } // Setter and getter for the browser accessibility owner BrowserAccessibilityWin* owner() const { return owner_; } void SetOwner(BrowserAccessibilityWin* owner) { owner_ = owner; } BrowserAccessibilityManager* Manager() const; // Private helper methods. bool ShouldFireHypertextEvents() const; // // AXPlatformNode overrides // void Destroy() override; void Init(ui::AXPlatformNodeDelegate* delegate) override; // Returns the IA2 text attributes for this object. ui::TextAttributeList ComputeTextAttributes() const; // Add one to the reference count and return the same object. Always // use this method when returning a BrowserAccessibilityComWin object as // an output parameter to a COM interface, never use it otherwise. BrowserAccessibilityComWin* NewReference(); // Many MSAA methods take a var_id parameter indicating that the operation // should be performed on a particular child ID, rather than this object. // This method tries to figure out the target object from |var_id| and // returns a pointer to the target object if it exists, otherwise NULL. // Does not return a new reference. BrowserAccessibilityComWin* GetTargetFromChildID(const VARIANT& var_id); // Retrieve the value of an attribute from the string attribute map and // if found and nonempty, allocate a new BSTR (with SysAllocString) // and return S_OK. If not found or empty, return S_FALSE. HRESULT GetStringAttributeAsBstr(ax::mojom::StringAttribute attribute, BSTR* value_bstr); // Retrieves the name, allocates a new BSTR if non-empty and returns S_OK. If // name is empty, returns S_FALSE. HRESULT GetNameAsBstr(BSTR* value_bstr); // Sets the selection given a start and end offset in IA2 Hypertext. void SetIA2HypertextSelection(LONG start_offset, LONG end_offset); // Searches forward from the given offset until the start of the next style // is found, or searches backward from the given offset until the start of the // current style is found. LONG FindStartOfStyle(LONG start_offset, ax::mojom::MoveDirection direction); // ID refers to the node ID in the current tree, not the globally unique ID. // TODO(nektar): Could we use globally unique IDs everywhere? // TODO(nektar): Rename this function to GetFromNodeID. BrowserAccessibilityComWin* GetFromID(int32_t id) const; // Returns true if this is a list box option with a parent of type list box, // or a menu list option with a parent of type menu list popup. bool IsListBoxOptionOrMenuListOption(); // Fire a Windows-specific accessibility event notification on this node. void FireNativeEvent(LONG win_event_type) const; struct WinAttributes { WinAttributes(); ~WinAttributes(); // Ignored state bool ignored; // IAccessible role and state. int32_t ia_role; int32_t ia_state; // IAccessible name, description, help, value. base::string16 name; base::string16 description; base::string16 value; // IAccessible2 role and state. int32_t ia2_role; int32_t ia2_state; // IAccessible2 attributes. std::vector<base::string16> ia2_attributes; // Maps each style span to its start offset in hypertext. ui::TextAttributeMap offset_to_text_attributes; }; BrowserAccessibilityWin* owner_; std::unique_ptr<WinAttributes> win_attributes_; // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or // IA2_EVENT_TEXT_INSERTED event. std::unique_ptr<WinAttributes> old_win_attributes_; // The previous scroll position, so we can tell if this object scrolled. int previous_scroll_x_; int previous_scroll_y_; // Give BrowserAccessibility::Create access to our constructor. friend class BrowserAccessibility; friend class BrowserAccessibilityWin; DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityComWin); }; CONTENT_EXPORT BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( BrowserAccessibility* obj); } // namespace content #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_COM_WIN_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
2659758806de9347c1c00f9fc69bb8f2ed1b4061
67f988dedfd8ae049d982d1a8213bb83233d90de
/external/chromium/ui/base/resource/resource_bundle_gtk.cc
4bf1bde9bf31e36d1d1f3a5e59bed8f4f06acd8a
[ "BSD-3-Clause" ]
permissive
opensourceyouthprogramming/h5vcc
94a668a9384cc3096a365396b5e4d1d3e02aacc4
d55d074539ba4555e69e9b9a41e5deb9b9d26c5b
refs/heads/master
2020-04-20T04:57:47.419922
2019-02-12T00:56:14
2019-02-12T00:56:14
168,643,719
1
1
null
2019-02-12T00:49:49
2019-02-01T04:47:32
C++
UTF-8
C++
false
false
3,655
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/base/resource/resource_bundle.h" #include "base/i18n/rtl.h" #include "base/logging.h" #include "base/memory/ref_counted_memory.h" #include "base/path_service.h" #include "base/synchronization/lock.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/gtk/scoped_gobject.h" #include "ui/base/layout.h" #include "ui/base/resource/resource_handle.h" #include "ui/base/ui_base_paths.h" #include "ui/gfx/image/image.h" #include <gtk/gtk.h> namespace ui { namespace { // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned // has a ref count of 1 so the caller must call g_object_unref to free the // memory. GdkPixbuf* LoadPixbuf(base::RefCountedStaticMemory* data, bool rtl_enabled) { ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); bool ok = data && gdk_pixbuf_loader_write(loader.get(), reinterpret_cast<const guint8*>(data->front()), data->size(), NULL); if (!ok) return NULL; // Calling gdk_pixbuf_loader_close forces the data to be parsed by the // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf. ok = gdk_pixbuf_loader_close(loader.get(), NULL); if (!ok) return NULL; GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get()); if (!pixbuf) return NULL; if (base::i18n::IsRTL() && rtl_enabled) { // |pixbuf| will get unreffed and destroyed (see below). The returned value // has ref count 1. return gdk_pixbuf_flip(pixbuf, TRUE); } else { // The pixbuf is owned by the loader, so add a ref so when we delete the // loader (when the ScopedGObject goes out of scope), the pixbuf still // exists. g_object_ref(pixbuf); return pixbuf; } } FilePath GetResourcesPakFilePath(const std::string& pak_name) { FilePath path; if (PathService::Get(base::DIR_MODULE, &path)) return path.AppendASCII(pak_name.c_str()); // Return just the name of the pack file. return FilePath(pak_name.c_str()); } } // namespace void ResourceBundle::LoadCommonResources() { AddDataPackFromPath(GetResourcesPakFilePath("chrome.pak"), SCALE_FACTOR_NONE); AddDataPackFromPath(GetResourcesPakFilePath( "chrome_100_percent.pak"), SCALE_FACTOR_100P); } gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { // Use the negative |resource_id| for the key for BIDI-aware images. int key = rtl == RTL_ENABLED ? -resource_id : resource_id; // Check to see if the image is already in the cache. { base::AutoLock lock_scope(*images_and_fonts_lock_); if (images_.count(key)) return images_[key]; } gfx::Image image; if (delegate_) image = delegate_->GetNativeImageNamed(resource_id, rtl); if (image.IsEmpty()) { scoped_refptr<base::RefCountedStaticMemory> data( LoadDataResourceBytesForScale(resource_id, SCALE_FACTOR_100P)); GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED); if (!pixbuf) { LOG(WARNING) << "Unable to load pixbuf with id " << resource_id; NOTREACHED(); // Want to assert in debug mode. return GetEmptyImage(); } image = gfx::Image(pixbuf); // Takes ownership. } base::AutoLock lock_scope(*images_and_fonts_lock_); // Another thread raced the load and has already cached the image. if (images_.count(key)) return images_[key]; images_[key] = image; return images_[key]; } } // namespace ui
[ "rjogrady@google.com" ]
rjogrady@google.com
9ded2033b51ddd6d0f7c105f3ba15caa0e52df02
31004c4d182ec71bd55eee272199d05d05e9fbe8
/gamesrc/control/touchscreengui.h
f8ccf7d4fbc5c08d824d441bc961f6f6041a12a4
[]
no_license
ChuanonlyGame/myisland
374b8c649978613c7f388a6881f329aaf0d52b25
d2d786408dcdf1ec2e5a38d7a613414a9daf3a9f
refs/heads/master
2021-01-13T02:31:52.566634
2014-08-19T16:50:32
2014-08-19T16:50:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,362
h
/* Copyright (C) 2013 xyz, Ilya Zhuravlev <whatever@xyz.is> This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef TOUCHSCREENGUI_HEADER #define TOUCHSCREENGUI_HEADER #include <IGUIEnvironment.h> #include <IGUIButton.h> #include <IEventReceiver.h> #include <vector> #include <set> #include "game.h" using namespace irr; using namespace irr::core; using namespace irr::gui; class TouchScreenGUI : public InputHandler { public: TouchScreenGUI(IrrlichtDevice *device); ~TouchScreenGUI(); void init(); void OnEvent(const SEvent &event); double getYaw() { return m_camera_yaw; } double getPitch() { return m_camera_pitch; } line3d<f32> getShootline() { return m_shootline; } bool isKeyDown(const KeyPress &keyCode); bool wasKeyDown(const KeyPress &keyCode); v2s32 getMousePos() { return m_down_to; } void setMousePos(s32 x, s32 y) {} bool getLeftState() { return m_digging; } bool getRightState() { return m_rightclick; } bool getLeftClicked() { return m_digging; } bool getRightClicked() { return m_rightclick; } void resetLeftClicked() { m_digging = false; } void resetRightClicked() { m_rightclick = false; } bool getLeftReleased() { return false; } bool getRightReleased() { return m_rightclick; } void resetLeftReleased() { m_digging = false; } void resetRightReleased() { m_rightclick = false; } s32 getMouseWheel() { return 0; } void step(float dtime); void resetHud(); void registerHudItem(int index, const rect<s32> &rect); bool hasPlayerItemChanged() { return m_player_item_changed; } u16 getPlayerItem(); s32 getHotbarImageSize(); void Toggle(bool visible); void Hide(); void Show(); bool isSingleClick(); bool isDoubleClick(); void resetClicks(); // void showChat(); void changeTime(); void setKeyDown(const KeyPress &keyCode); private: bool ingame_chat_ui_on; void _chechChatUi(); IrrlichtDevice *m_device; IGUIEnvironment *m_guienv; IGUIButton *m_button; rect<s32> m_control_pad_rect; double m_camera_yaw; double m_camera_pitch; line3d<f32> m_shootline; bool m_down; s32 m_down_pointer_id; u32 m_down_since; v2s32 m_down_from; // first known position v2s32 m_down_to; // last known position std::set<s32> m_current_pointers; // Currently touched pointers bool m_digging; bool m_rightclick; KeyList keyIsDown; KeyList keyWasDown; std::vector<rect<s32> > m_hud_rects; bool m_player_item_changed; u16 m_player_item; v2u32 m_screensize; u32 m_hud_start_y; u32 m_buttons_start_x; bool m_visible; // is the gui visible bool m_visible_buttons; bool m_double_click; int m_previous_click_time; u32 m_previous_key_time; u32 m_previous_place_time; u16 m_dig_press_time; }; #endif
[ "fuchuanjian360@gmail.com" ]
fuchuanjian360@gmail.com
ed3acca482317b1f2438506aaf6d02c59473b260
2f1f72816375f201744fc0ece6079ee3c0da3a62
/src/engine/core/rendering/ui/UISprite.cpp
667083108b28fd420197ba1cb02742f2a205095c
[ "MIT" ]
permissive
maksmaisak/Engine
a985938366cb3667e73c2c2cdc22d8536ba502db
50cea5437712e7e37af93ebf52e2c50088866223
refs/heads/master
2022-03-24T15:58:11.314527
2019-10-06T14:30:29
2019-10-06T14:30:29
176,569,755
6
1
null
null
null
null
UTF-8
C++
false
false
1,077
cpp
// // Created by Maksym Maisak on 2019-02-13. // #include "UISprite.h" #include <memory> #include "Texture.h" using namespace en; std::shared_ptr<Material> readMaterial(LuaState& lua) { lua_getfield(lua, -1, "material"); auto p = lua::PopperOnDestruct(lua); if (lua.is<std::shared_ptr<Material>>()) return lua.to<std::shared_ptr<Material>>(); return std::make_shared<Material>(lua); } UISprite& UISprite::addFromLua(Actor& actor, LuaState& lua) { auto& sprite = actor.add<UISprite>(); sprite.material = readMaterial(lua); return sprite; } void UISprite::initializeMetatable(LuaState& lua) { lua::addProperty(lua, "isEnabled", lua::property(&UISprite::isEnabled)); lua::addProperty(lua, "textureSize", lua::readonlyProperty([](ComponentReference<UISprite>& ref) { auto& material = ref->material; if (!material) return glm::vec2(0); const auto& size = material->getUniformValue<std::shared_ptr<Texture>>("spriteTexture")->getSize(); return glm::vec2(size.x, size.y); })); }
[ "max.maisak@gmail.com" ]
max.maisak@gmail.com
23b0242a55b6eb351effe72e530eebd76ba94fa8
9845786e887c1aab0dfaf0de56461db5880135a9
/Project-1-Code/LeftParenAutomaton.h
d22199307d8b8c47fbb54b776571197b7a6c6414
[]
no_license
julianacsmith/cs-236-lab-1
b38c5f00547eec0f1bc49e07cce9a71448b624ee
2bd671b42917e0e190bb22e6fbe74b7967a79d11
refs/heads/master
2023-08-17T05:45:33.855342
2021-09-16T01:47:28
2021-09-16T01:47:28
406,209,790
0
0
null
null
null
null
UTF-8
C++
false
false
358
h
// // Created by Juliana Smith on 9/14/21. // #ifndef CS_236_LAB_1_LEFTPARENAUTOMATON_H #define CS_236_LAB_1_LEFTPARENAUTOMATON_H #include "Automaton.h" class LeftParenAutomaton : public Automaton { public: void S0(const std::string& input); LeftParenAutomaton() : Automaton(TokenType::LEFT_PAREN) {} }; #endif //CS_236_LAB_1_LEFTPARENAUTOMATON_H
[ "clarinetplayer2020@gmail.com" ]
clarinetplayer2020@gmail.com
e0932faeeb91b419d5a5dc0b942740283bae88be
fe51fe6585f3ff5cb71d468f8350803c1ae41eb0
/Program C++/sweet_number.cpp
4eb1c155ec7984f14041fd5294be692b5288a374
[]
no_license
Lemon-tech24/C-Programs
22dc7b72e4d8b39af94e66f498dd39913e895071
a1c5dac8a5d62dce2636c75d1edbd164ba0d96a9
refs/heads/main
2023-06-21T10:52:30.007108
2021-04-09T14:10:28
2021-04-09T14:10:28
356,293,245
1
0
null
null
null
null
UTF-8
C++
false
false
330
cpp
#include<iostream> int main(){ using namespace std; int number; cout<<" This Program accepts the sweetest number <3. \n"; cout<<" Enter Number: "; cin>>number; cout<<"\n"; if(number == 5254 && number != 0) { cout<<" Mahal na Mahal Kita"; }else{ cout<<" Pwede Hanap ka na lang ng iba."; } }
[ "78329279+Lemon-tech24@users.noreply.github.com" ]
78329279+Lemon-tech24@users.noreply.github.com
81811bb583bf1fcc6b8f67569a67ceeea02415a8
156c0861ce5650248099d917bc22dfe1b012c7cb
/第3章/第三章/3.4.1.cpp
61b8e74e98ec539250157d3616b2ef7735daf2e9
[]
no_license
bietaixian/cppPrimer5th
ba1309bdf2c0e2be80b8da26e1ee442ead611606
82a4866512f770f8e8d7010172db414cdf3911e0
refs/heads/master
2020-04-02T05:49:24.490678
2016-06-22T02:39:20
2016-06-22T02:39:20
61,682,696
0
0
null
null
null
null
UTF-8
C++
false
false
559
cpp
//#include <iostream> //#include <string> //using std::cin; //using std::cout; //using std::endl; //using std::string; //int main() //{ // string word1,word2; // cin >> word1 >> word2; // if (word1 == word2) // { // cout << word1 <<word2 <<endl; // } // else // { // if (word1 > word2) // { // cout <<"the largest string is "<<word1<<endl; // } // else // { // cout <<"the largest string is "<<word2<<endl; // } // } // system("pause"); // return 0; //} //
[ "649968264@qq.com" ]
649968264@qq.com
dc4d2609de92569462d142efee0f0ba162a690ba
ef07f3a6b8b23d0d860e180d77944be7c5cf5f81
/examples/GroveTempHumiBaroBME280/GroveTempHumiBaroBME280.ino
fedca002d13bb2303b7373f6286f16dfd515c44b
[]
no_license
mnakai3/GroveDriverPack
1ab9d1f6e84e53caed3fc547dceb6990c018331d
4baeebf83aa08e38b831e64ca11bde0dfeb2596b
refs/heads/master
2021-03-17T12:32:32.288407
2020-04-01T01:07:12
2020-04-01T01:07:12
246,991,240
0
0
null
2020-03-13T04:56:43
2020-03-13T04:56:42
null
UTF-8
C++
false
false
793
ino
// BOARD Seeed Wio 3G // GROVE I2C <-> Grove - Temp&Humi&Barometer Sensor (BME280) (SKU#101020193) #include <GroveDriverPack.h> #define INTERVAL (2000) WioCellular Wio; GroveBoard Board; GroveTempHumiBaroBME280 TempHumiBaro(&Board.I2C); void setup() { delay(200); SerialUSB.begin(115200); Wio.Init(); Wio.PowerSupplyGrove(true); delay(500); Board.I2C.Enable(); TempHumiBaro.Init(); } void loop() { TempHumiBaro.Read(); SerialUSB.print("Current humidity = "); SerialUSB.print(TempHumiBaro.Humidity); SerialUSB.print("% "); SerialUSB.print("temperature = "); SerialUSB.print(TempHumiBaro.Temperature); SerialUSB.print("C "); SerialUSB.print("pressure = "); SerialUSB.print(TempHumiBaro.Pressure); SerialUSB.println("Pa"); delay(INTERVAL); }
[ "matsujirushi@live.jp" ]
matsujirushi@live.jp
0701d29b232c419d7298d11fa4abaa31f8852fb9
a92482dad3b50a5f46d7ee21ef025929c46d4333
/TestCode/src/CApp.cpp
a90008adcc5b23897342ff7e16f8d4b1d1ef36c7
[]
no_license
seanmason337/TetrisProject
4a9460691aff946084ab2ee1dcf165d7f4bba2a4
e2bacd5705f6edd37a0e7af15659031e7eab6394
refs/heads/master
2021-01-10T22:07:48.593825
2012-09-16T08:29:25
2012-09-16T08:29:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
530
cpp
/* * CApp.cpp * * Created on: Sep 16, 2012 * Author: seanmason */ #include "CApp.h" CApp::CApp() { Surf_Display = NULL; Running = true; } int CApp::OnExecute() { if(OnInit() == false) { return -1; } SDL_Event Event; while(Running) { while(SDL_PollEvent(&Event)) { OnEvent(&Event); } OnLoop(); OnRender(); } OnCleanup(); return 0; } int main(int argc, char* argv[]) { CApp theApp; return theApp.OnExecute(); }
[ "seanmason@bellini.(none)" ]
seanmason@bellini.(none)
338165aff0a7aeb08a9e160790db7e5c9df275bd
b692d54c1c3bfac2f6d481995dfd0263ec29a870
/RealDataPlayer/highway.h
3188e1e8b4cd44aaef106b867deeac9e025cffb2
[]
no_license
HanwoolWooHaHa/LaneChangeEstimator
d4cf0366937893ca605d2ff0189e3174e1f291b8
01308b6cf8e439013aef93b004d4e17b1ca6af13
refs/heads/master
2021-01-20T18:33:51.246814
2016-07-21T07:54:48
2016-07-21T07:54:48
61,630,746
1
0
null
null
null
null
UTF-8
C++
false
false
925
h
#pragma once class CHighway { public: static CHighway* GetInstance() { static CHighway* ret = new CHighway(); return ret; } double dCube[8][3]; private: CHighway() { dCube[0][0] = -7000.0; dCube[0][1] = 0.0; //-LANE_WIDTH * FEET_TO_METER; dCube[0][2] = -0.3; dCube[1][0] = -7000.0; dCube[1][1] = 4500; dCube[1][2] = -0.3; dCube[2][0] = -7000.0; dCube[2][1] = 4500; dCube[2][2] = 0.0; dCube[3][0] = -7000.0; dCube[3][1] = 0.0; //-LANE_WIDTH * FEET_TO_METER; dCube[3][2] = 0.0; dCube[4][0] = 0.0; dCube[4][1] = 0.0; //-LANE_WIDTH * FEET_TO_METER; dCube[4][2] = -0.3; dCube[5][0] = 0.0; dCube[5][1] = 4500; dCube[5][2] = -0.3; dCube[6][0] = 0.0; dCube[6][1] = 4500; dCube[6][2] = 0.0; dCube[7][0] = 0.0; dCube[7][1] = 0.0; //-LANE_WIDTH * FEET_TO_METER; dCube[7][2] = 0.0; } ~CHighway() {} };
[ "nospaces@hotmail.co.jp" ]
nospaces@hotmail.co.jp
a8d2681cd6f4bf4233f54e1bb8fe382287dbd109
da18b970604b1a3b2a610bdcd5411462ab98bf26
/furikuri/fuku_virtualization_x86.h
03e9e9d5f71104d746656fe2392e3b6508807d3c
[ "BSD-3-Clause" ]
permissive
hmyit/furikuri
73480911312e9485681b58e4ad32f61bceb26c9b
090caef66c39784cf6912dd8acea90beb1da46a4
refs/heads/master
2020-05-09T10:28:54.660564
2019-03-29T19:31:52
2019-03-29T19:31:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,504
h
#pragma once class fuku_virtualization_x86 : public fuku_virtualizer { /*vm_linestorage lines; std::vector<fuku_vm_instruction> create_operand_reg(uint8_t reg, bool ptr); std::vector<fuku_vm_instruction> create_operand_disp(uint32_t disp); // [disp/r] std::vector<fuku_vm_instruction> create_operand_reg_disp(uint8_t base, uint32_t disp); // [base + disp/r] std::vector<fuku_vm_instruction> create_operand_sib(uint8_t base, uint8_t index, uint8_t scale, uint32_t disp);// [base + index*scale + disp/r] std::vector<fuku_vm_instruction> create_operand_sib(uint8_t index, uint8_t scale, uint32_t disp);// [index*scale + disp/r] */ void get_operands(const cs_insn *insn, const fuku_instruction& line //, // std::vector<fuku_vm_instruction>& operands ); uint8_t get_ext_code(const cs_insn *insn); void post_process_lines(uint64_t destination_virtual_address); public: fuku_virtualization_x86(); ~fuku_virtualization_x86(); fuku_vm_result build_bytecode(fuku_code_holder& code_holder, std::vector<fuku_code_relocation>& relocation_table, std::vector<fuku_code_association>& association_table, uint64_t destination_virtual_address); std::vector<uint8_t> create_vm_jumpout(uint64_t src_address, uint64_t dst_address, uint64_t vm_entry_address, std::vector<fuku_code_relocation>& relocation_table) const; std::vector<uint8_t> get_bytecode() const; fuku_assambler_arch get_target_arch() const; };
[ "jnastarot@yandex.ru" ]
jnastarot@yandex.ru
ad0b4415fc3c12dc2dcad34e23b539b33a58be06
4c752153a8eefbe5046bcd603be113b3e7868673
/src/backends/neon/workloads/NeonAbsWorkload.cpp
7f8ed5a0069eff6f57b7b2ad427194a42f26298c
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
hcaushi/armnn
e98c382769f250818857eb5c95b5a62981e635a1
5884708e650a80e355398532bc320bbabdbb53f4
refs/heads/master
2021-07-08T09:46:32.791881
2019-10-18T15:49:28
2019-10-18T15:53:36
216,262,998
1
0
MIT
2019-10-19T19:58:36
2019-10-19T19:58:36
null
UTF-8
C++
false
false
1,323
cpp
// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #include "NeonAbsWorkload.hpp" #include "NeonWorkloadUtils.hpp" #include <aclCommon/ArmComputeTensorHandle.hpp> #include <aclCommon/ArmComputeTensorUtils.hpp> #include <boost/cast.hpp> namespace armnn { arm_compute::Status NeonAbsWorkloadValidate(const TensorInfo& input, const TensorInfo& output) { const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input); const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); return arm_compute::NEAbsLayer::validate(&aclInput, &aclOutput); } NeonAbsWorkload::NeonAbsWorkload(const AbsQueueDescriptor& descriptor, const WorkloadInfo& info) : BaseWorkload<AbsQueueDescriptor>(descriptor, info) { m_Data.ValidateInputsOutputs("NeonAbsWorkload", 1, 1); arm_compute::ITensor& input = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); arm_compute::ITensor& output = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); m_AbsLayer.configure(&input, &output); } void NeonAbsWorkload::Execute() const { ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonAbsWorkload_Execute"); m_AbsLayer.run(); } } // namespace armnn
[ "narumol.prangnawarat@arm.com" ]
narumol.prangnawarat@arm.com
9b5ca9ea636c4460ac7597afa7d3f28ade8b61a8
b0114a447e4266c7616a5cc887b8a6fda234dff1
/caffe2/core/context_base.h
95d0dd60e143c63d786ed88df79f0c7ea75d4ee8
[ "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause" ]
permissive
mcarilli/pytorch_sandbox
26b204d67fd9b4b8c30a453aba1aafba0f76491a
dd349d1f64edc6c4a8087c04e342de5eae7800e8
refs/heads/backward_profile
2022-10-22T18:24:36.901435
2018-08-20T19:50:48
2018-08-20T19:50:48
145,435,799
0
1
NOASSERTION
2022-10-14T23:21:17
2018-08-20T15:27:22
C++
UTF-8
C++
false
false
5,561
h
#pragma once #include <cstdlib> #include <ctime> #include <memory> #include <unordered_map> #include "caffe2/core/allocator.h" #include "caffe2/core/event.h" #include "caffe2/core/logging.h" #include "caffe2/core/typeid.h" #include "caffe2/proto/caffe2.pb.h" namespace caffe2 { class BaseContext; /* BaseStaticContext defines the interface for static context, which contains functions that are invoked statically before in Tensor class, e.g. New, We will merge this with Allocator later. */ class CAFFE2_API BaseStaticContext { public: virtual ~BaseStaticContext() noexcept {} virtual std::pair<void*, MemoryDeleter> New(size_t nbytes) const = 0; virtual std::unique_ptr<BaseContext> CreateContext() = 0; virtual std::unique_ptr<BaseContext> CreateContext(const DeviceOption&) = 0; virtual DeviceType GetDeviceType() = 0; /* * @brief: Sets the DeviceOption for argument `device` based on the * current context and the a data pointer */ virtual void ExtractDeviceOption(DeviceOption* device, const void* /*data*/) { device->set_device_type(GetDeviceType()); } }; /** * Virtual interface for the Context class in Caffe2. * * A Context defines all the necessities to run an operator on a specific * device. Specific Context classes needs to implement all the pure virtual * functions in the BaseContext class. * TODO: add docs after this is finalized. */ class CAFFE2_API BaseContext { public: virtual ~BaseContext() noexcept {} virtual BaseStaticContext* GetStaticContext() const = 0; /* Sorry for the naming, will get rid of this in future diff */ virtual DeviceType GetDevicetype() const = 0; virtual void SwitchToDevice(int /*stream_id*/) = 0; inline void SwitchToDevice() { SwitchToDevice(0); } virtual void WaitEvent(const Event& ev) = 0; virtual void Record(Event* ev, const char* err_msg = nullptr) const = 0; virtual void FinishDeviceComputation() = 0; // This used to be arbitrary cross-device copy, but it turns out everyone // did direct CPU-X copy, so we just make three functions for it (to avoid // double dispatch). This will get obsoleted by C10. where copies // will be proper operators (and get to rely on multiple dispatch there.) virtual void CopyBytesSameDevice(size_t nbytes, const void* src, void* dst) = 0; virtual void CopyBytesFromCPU(size_t nbytes, const void* src, void* dst) = 0; virtual void CopyBytesToCPU(size_t nbytes, const void* src, void* dst) = 0; virtual void CopyBytesToDevice( size_t nbytes, const void* src, void* dst, DeviceType type) { if (type == CPU) { CopyBytesToCPU(nbytes, src, dst); } else if (type == GetDevicetype()) { CopyBytesSameDevice(nbytes, src, dst); } else { CAFFE_THROW( "CopyBytesToDevice can only copy to CPU or between same " "device. Can't copy from: ", GetDevicetype(), " to", type); } } template <typename T> inline void CopySameDevice(size_t n, const T* src, T* dst) { static_assert( std::is_fundamental<T>::value, "CopySameDevice requires fundamental types"); CopyBytesSameDevice( n * sizeof(T), static_cast<const void*>(src), static_cast<void*>(dst)); } template <typename T> inline void CopyFromCPU(size_t n, const T* src, T* dst) { static_assert( std::is_fundamental<T>::value, "CopyFromCPU requires fundamental types"); CopyBytesFromCPU( n * sizeof(T), static_cast<const void*>(src), static_cast<void*>(dst)); } template <typename T> inline void CopyToCPU(size_t n, const T* src, T* dst) { static_assert( std::is_fundamental<T>::value, "CopyToCPU requires fundamental types"); CopyBytesToCPU( n * sizeof(T), static_cast<const void*>(src), static_cast<void*>(dst)); } virtual bool SupportsNonFundamentalTypes() const { return false; } inline void EnforceMetaCopyOK() { CAFFE_ENFORCE( SupportsNonFundamentalTypes(), "Context requires fundamental types"); } inline void CopyItemsSameDevice( const TypeMeta& meta, size_t n, const void* src, void* dst) { if (meta.copy()) { EnforceMetaCopyOK(); meta.copy()(src, dst, n); } else { CopyBytesSameDevice(n * meta.itemsize(), src, dst); } } inline void CopyItemsFromCPU(const TypeMeta& meta, size_t n, const void* src, void* dst) { if (meta.copy()) { EnforceMetaCopyOK(); meta.copy()(src, dst, n); } else { CopyBytesFromCPU(n * meta.itemsize(), src, dst); } } inline void CopyItemsToCPU(const TypeMeta& meta, size_t n, const void* src, void* dst) { if (meta.copy()) { EnforceMetaCopyOK(); meta.copy()(src, dst, n); } else { CopyBytesToCPU(n * meta.itemsize(), src, dst); } } static BaseStaticContext* static_context_[COMPILE_TIME_MAX_DEVICE_TYPES]; template <int d> friend struct StaticContextFunctionRegisterer; }; template <int d> struct StaticContextFunctionRegisterer { explicit StaticContextFunctionRegisterer(BaseStaticContext* ptr) { static_assert(d < COMPILE_TIME_MAX_DEVICE_TYPES, ""); BaseContext::static_context_[d] = ptr; } }; #define REGISTER_STATIC_CONTEXT(d, f) \ namespace { \ static StaticContextFunctionRegisterer<d> g_static_context_##d(f); \ } #define GET_STATIC_CONTEXT(d) BaseContext::static_context_[d] } // namespace caffe2
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
091a3aa20a11b6ca181e4b12866dbb27dfcd18e6
72aceebdbe4fe0ba51a6323eef2fe90b4ee49009
/QFacer/mainwindow.cpp
2a340b51cd5af005cbdca661b8dfce374605eeb5
[ "BSD-2-Clause" ]
permissive
laojiang19/nominate-gitee-apengge-SeetaFace_opt
88b6fd9a01cd1a340cf25b054dfcb9fefb2dea40
cd31b4d4a2c75161df424cd13b70d974c926dbb5
refs/heads/master
2020-11-29T22:56:51.465363
2018-12-25T04:05:23
2018-12-25T04:05:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,333
cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include "common.h" #include <QFileDialog> #include "Logger.h" #include <QDragEnterEvent> #include <QMimeData> #include <QMessageBox> #include "facesdkwapper.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); faceToDBTask = NULL; //ui->dbSavePathSelectPushButton->setHidden(true); setAcceptDrops(true); faceSDKWapper.initWithGPU(0,SEETA_PROVIDER); nScoreLables.push_back(ui->nCompareTop1ScoreLabel); nScoreLables.push_back(ui->nCompareTop2ScoreLabel); nScoreLables.push_back(ui->nCompareTop3ScoreLabel); nScoreLables.push_back(ui->nCompareTop4ScoreLabel); nScoreLables.push_back(ui->nCompareTop5ScoreLabel); nFacePushButtons.push_back(ui->nCompareTop1ImageLabel); nFacePushButtons.push_back(ui->nCompareTop2ImageLabel); nFacePushButtons.push_back(ui->nCompareTop3ImageLabel); nFacePushButtons.push_back(ui->nCompareTop4ImageLabel); nFacePushButtons.push_back(ui->nCompareTop5ImageLabel); } MainWindow::~MainWindow() { faceSDKWapper.release(); delete ui; } void MainWindow::dragEnterEvent(QDragEnterEvent *e) { //LOG_INFO("drag event pos, x:%d, y:%d", e->pos().x(), e->pos().y()) if(e->mimeData()->hasUrls()) //只能打开jpeg图片 { if(ui->tabWidget->currentIndex() == 1 || ui->tabWidget->currentIndex() == 2) { e->acceptProposedAction(); //可以在这个窗口部件上拖放对象; } } } void MainWindow::dropEvent(QDropEvent *e) { QPoint ePoint = e->pos(); ePoint -=(ui->tabWidget->geometry().topLeft()); if(ui->tabWidget->currentIndex() == 1) { //LOG_INFO("drop event pos, x:%d, y:%d", e->pos().x(), e->pos().y()); // LOG_INFO("drop event pos, x:%d, y:%d", this->mapFromGlobal(e->pos()).x(), this->mapFromGlobal(e->pos()).y()); // LOG_INFO("right button pos, x:%d, y:%d, w:%d, h:%d",ui->rightImageButton->geometry().x(), ui->rightImageButton->geometry().y() // , ui->rightImageButton->geometry().width(), ui->rightImageButton->geometry().height()); // LOG_INFO("left button pos, x:%d, y:%d, w:%d, h:%d",ui->leftImageButton->geometry().x(), ui->leftImageButton->geometry().y() // , ui->leftImageButton->geometry().width(), ui->leftImageButton->geometry().height()); QList<QUrl> urls = e->mimeData()->urls(); if(ui->rightImageButton->geometry().contains(ePoint)) { QString path = urls.first().toLocalFile(); if(path.size() > 0) { updateIcorOfButton(ui->rightImageButton, path); QIcon icon; QPixmap pixmap1(path); icon.addPixmap(pixmap1); ui->rightImageButton->setIcon(icon); ui->rightImageButton->setIconSize(ui->rightImageButton->size()); //ui->leftImageButton->setStyleSheet("border-image: url(:" + path + ");"); rightFile = path; LOG_INFO("dorp event with right file:%s", QStr2CStr(rightFile)); } } if( ui->leftImageButton->geometry().contains(ePoint)) { QString path = urls.first().toLocalFile(); if(path.size() > 0) { updateIcorOfButton(ui->leftImageButton, path); //ui->leftImageButton->setStyleSheet("border-image: url(:" + path + ");"); leftFile = path; LOG_INFO("dorp event with left file:%s", QStr2CStr(leftFile)); } } } else if (ui->tabWidget->currentIndex() == 2) { QList<QUrl> urls = e->mimeData()->urls(); if(ui->nCompareSrcImageButton->geometry().contains(ePoint)) { QString path = urls.first().toLocalFile(); if(path.size() > 0) { updateIcorOfButton(ui->nCompareSrcImageButton, path); nCompareSrcImgPath = path; LOG_INFO("dorp event with nCompareSrcImgPath:%s", QStr2CStr(nCompareSrcImgPath)); } } } } void MainWindow::updateIcorOfButton(QPushButton *button, QString path) { QIcon icon; QPixmap pixmap1(path); icon.addPixmap(pixmap1); button->setIcon(icon); button->setIconSize(button->size()); } void MainWindow::on_dbSavePathSelectPushButton_clicked() { QFileDialog *fileDialog = new QFileDialog(this); fileDialog->setWindowTitle("选择保存图片特征的路径"); fileDialog->setDirectory("."); fileDialog->setFileMode(QFileDialog::DirectoryOnly); QStringList fileNames; if(fileDialog->exec()) { fileNames = fileDialog->selectedFiles(); } if(fileNames.size() > 0) { ui->dbSavePathLineEdit->setText(fileNames.at(0)); LOG_INFO("select db save path:%s", QStr2CStr(ui->dbSavePathLineEdit->text())); } } void MainWindow::on_imageFromSelectPushButton_clicked() { QFileDialog *fileDialog = new QFileDialog(this); fileDialog->setWindowTitle("选择提取特征值的图片路径"); fileDialog->setDirectory("."); fileDialog->setFileMode(QFileDialog::DirectoryOnly); fileDialog->setViewMode(QFileDialog::Detail); QStringList fileNames; if(fileDialog->exec()) { fileNames = fileDialog->selectedFiles(); } if(fileNames.size() > 0) { ui->imageFromPathLineEdit->setText(fileNames.at(0)); LOG_INFO("select image path:%s", QStr2CStr(ui->imageFromPathLineEdit->text())); ui->dbSavePathLineEdit->setText(fileNames.at(0)); LOG_INFO("select db save path:%s", QStr2CStr(ui->dbSavePathLineEdit->text())); } } void MainWindow::on_createDBStartButton_clicked() { if(ui->imageFromPathLineEdit->text().isEmpty()) { QMessageBox::warning(this, "提醒", "图片路径不能为空"); return; } if(ui->dbSavePathLineEdit->text().isEmpty()) { QMessageBox::warning(this, "提醒", "图片库保存路径不能为空"); return; } faceToDBTask = new FaceToDBTask(ui->imageFromPathLineEdit->text(), ui->dbSavePathLineEdit->text(), ui->dbCreateThreadCount->text().toInt()); displayFaceToDBDisplayInfo("start face to db task"); QObject::connect(faceToDBTask, SIGNAL(displayInfo(QString)), this, SLOT(displayFaceToDBDisplayInfo(QString))); QObject::connect(faceToDBTask, SIGNAL(onFinish()), this, SLOT(onFaceToDBTaskfinish())); QObject::connect(faceToDBTask, SIGNAL(updateProcess(int)), ui->createDBProgressBar, SLOT(setValue(int))); ui->createDBStartButton->setEnabled(false); ui->createDBStartButton->setText("处理中"); faceToDBTask->run(); } void MainWindow::onFaceToDBTaskfinish() { LOG_INFO("onFaceToDBTaskfinish"); faceToDBTask->waitThreadQuit(); SafeDeleteObj(faceToDBTask); ui->createDBStartButton->setEnabled(true); ui->createDBStartButton->setText("启动"); displayFaceToDBDisplayInfo("点击下面的开始进行创建"); } void MainWindow::displayFaceToDBDisplayInfo(QString displayInfo) { ui->createDBDisplayInfoLabel->setText(displayInfo); } void MainWindow::on_leftImageButton_clicked() { ui->similarityLabel->setText(""); QString path = QFileDialog::getOpenFileName(this, "Open Image", "", "Image Files(*.jpg *.png)"); if(path.size() > 0) { QIcon icon; QPixmap pixmap1(path); icon.addPixmap(pixmap1); ui->leftImageButton->setIcon(icon); ui->leftImageButton->setIconSize(ui->leftImageButton->size()); //ui->leftImageButton->setStyleSheet("border-image: url(:" + path + ");"); leftFile = path; } } void MainWindow::on_rightImageButton_clicked() { ui->similarityLabel->setText(""); QString path = QFileDialog::getOpenFileName(this, "Open Image", "", "Image Files(*.jpg *.png)"); if(path.size() > 0) { QIcon icon; QPixmap pixmap1(path); icon.addPixmap(pixmap1); ui->rightImageButton->setIcon(icon); ui->rightImageButton->setIconSize(ui->rightImageButton->size()); rightFile = path; } } void MainWindow::on_compareButton_clicked() { if(leftFile.size() <= 0 || rightFile.size() <= 0) { QMessageBox::warning(this, "注意", "请选择图片然后进行比较"); return; } cv::Mat leftImage = cv::imread(leftFile.toLocal8Bit().data()); cv::Mat rightImage = cv::imread(rightFile.toLocal8Bit().data()); std::list<FaceInfo> leftInfos = faceSDKWapper.faceDetectAndAlign(leftImage); std::list<FaceInfo> rightInfos = faceSDKWapper.faceDetectAndAlign(rightImage); if(leftInfos.size() != 1) { QMessageBox::warning(this, "注意", "只支持一个头像进行比较,左边头像个数:" + int2QStr(leftInfos.size())); return; } if(rightInfos.size() != 1) { QMessageBox::warning(this, "注意", "只支持一个头像进行比较,右边边头像个数:" + int2QStr(rightInfos.size())); return; } std::vector<float> leftFeature = faceSDKWapper.faceExtractFeature(leftImage, leftInfos.front()); std::vector<float> rightFeature = faceSDKWapper.faceExtractFeature(rightImage, rightInfos.front()); float similarity = faceSDKWapper.calSimilarity(leftFeature, rightFeature); ui->similarityLabel->setText(float2QStr(similarity)); } void MainWindow::on_nCompareLoadDestDBButton_clicked() { QString path = QFileDialog::getOpenFileName(this, "Open Image", "", "Image db(*.db)"); if(path.size() > 0) { nCompareFileAndFeatures.clear(); QStringList fileContent; readContentFromFile(path,fileContent); foreach (QString oneline, fileContent) { QString file = oneline.mid(0, oneline.indexOf("|")); QString feature = oneline.mid(oneline.indexOf("|") + 1); QStringList featureSplite = feature.split(","); std::vector<float> featureVector; foreach (QString temp, featureSplite) { featureVector.push_back(temp.toFloat()); } ImageFileAndFeature one(file, featureVector); nCompareFileAndFeatures.push_back(one); } LOG_INFO("load imag db record count:%d", nCompareFileAndFeatures.size()); ui->nComareDestDBCountLabel->setText(int2QStr(nCompareFileAndFeatures.size())); ui->nCompareDestDBLineEdit->setText(path); } } void MainWindow::on_nCompareSrcImageButton_clicked() { QString path = QFileDialog::getOpenFileName(this, "Open Image", "", "Image files(*.bmp *.jpg)"); if(path.size() > 0) { updateIcorOfButton(ui->nCompareSrcImageButton, path); nCompareSrcImgPath = path; } } void MainWindow::on_nCompareCompareButton_clicked() { foreach ( QPushButton * b, nFacePushButtons) { QIcon icon; b->setIcon(icon); } foreach (QLabel * l, nScoreLables) { l->setText("0"); } if(nCompareSrcImgPath.size() == 0) { QMessageBox::warning(this, "提醒", "请选择图片然后进行比较"); return; } if(nCompareFileAndFeatures.size() == 0) { QMessageBox::warning(this, "提醒", "请选择库,并确保库里面有图像数据"); return; } std::vector<float> topScore; std::vector<ImageFileAndFeature> topFaces; cv::Mat img = cv::imread(nCompareSrcImgPath.toLocal8Bit().data()); std::list<FaceInfo> faceInfos = faceSDKWapper.faceDetectAndAlign(img); if(faceInfos.size() != 1) { QMessageBox::warning(this, "注意", "只支持一个头像进行比较,头像个数:" + int2QStr(faceInfos.size())); return; } std::vector<float> features = faceSDKWapper.faceExtractFeature(img, faceInfos.front()); faceSDKWapper.compareTopN(features,nCompareFileAndFeatures, 5, topFaces, topScore, ui->nCompareMinScoreLineEdit->text().toFloat()*1.0/100); for (int i = 0; i < topScore.size(); i ++) { (nScoreLables.at(i))->setText(float2QStr(topScore.at(i))); updateIcorOfButton(nFacePushButtons.at(i), topFaces.at(i).file); } }
[ "469665813@qq.com" ]
469665813@qq.com
c251390fd9a9cb31907ef2e651432f540eab282a
0ec756cae161ecead71b4bb1cd6cce61b739e566
/src/color/hwb/convert/hsl.hpp
203dd9e4b6107e0afc41db98c1ceb737905bd2ad
[ "Apache-2.0" ]
permissive
tesch1/color
f6ac20abd3935bb323c5a302289b8a499fa36101
659874e8efcfca88ffa897e55110fd344207175e
refs/heads/master
2021-07-21T22:08:08.032630
2017-09-06T11:55:55
2017-09-06T11:55:55
108,835,892
0
1
null
2017-10-30T10:32:12
2017-10-30T10:32:12
null
UTF-8
C++
false
false
1,846
hpp
#ifndef color_hwb_convert_hsl #define color_hwb_convert_hsl #include "../../_internal/convert.hpp" #include "../category.hpp" #include "../../hsl/hsl.hpp" #include "../../rgb/rgb.hpp" #include "../../hsv/hsv.hpp" namespace color { namespace _internal { template < typename hwb_tag_name ,typename hsl_tag_name > struct convert < ::color::category::hwb< hwb_tag_name > ,::color::category::hsl< hsl_tag_name > > { public: typedef ::color::category::hwb< hwb_tag_name > hwb_category_type, category_left_type; typedef ::color::category::hsl< hsl_tag_name > hsl_category_type, category_right_type; typedef typename ::color::trait::scalar< hwb_category_type >::instance_type scalar_type; typedef ::color::model< hsl_category_type > hsl_model_type; typedef ::color::model< hwb_category_type > hwb_model_type; typedef ::color::rgb< scalar_type > rgb_model_type; typedef ::color::hsv< scalar_type > hsv_model_type; typedef ::color::trait::container<category_left_type> container_left_trait_type; typedef ::color::trait::container<category_right_type> container_right_trait_type; typedef typename container_left_trait_type::input_type container_left_input_type; typedef typename container_right_trait_type::input_const_type container_right_const_input_type; static void process ( container_left_input_type left ,container_right_const_input_type right ) { left = hwb_model_type( hsv_model_type( rgb_model_type( hsl_model_type( right ) ) ) ).container(); } }; } } #endif
[ "dmilos@gmail.com" ]
dmilos@gmail.com
5046fdb730063d2212261ca1b21091743f447458
9bdc944c4a38f82f3ffa12374755a8f1f12180f8
/HW5/HW5a/PublicDerived.cpp
7ff2c29618d029a4194772ce13134fe57560bfbf
[]
no_license
terrencetjr24/Object-Oriented-Programming-ece30862
4b449febab72987b9ba41a579b8ac93b757f98dd
2ea8d412eca46b825b2e1b3635c6f1340fecee07
refs/heads/master
2023-01-24T19:45:54.118176
2020-12-11T02:55:49
2020-12-11T02:55:49
320,449,590
0
0
null
null
null
null
UTF-8
C++
false
false
299
cpp
#include "PublicDerived.h" PublicDerived::PublicDerived( ) { } PublicDerived::~PublicDerived( ){ } void PublicDerived::print( ) { cout << "publicDerived" << endl; cout << "privB: " << privB; cout << ", protB: " << protB; cout << ", publicB: " << publicB; cout << endl << endl; }
[ "terrencetjr24@gmail.com" ]
terrencetjr24@gmail.com
95405b8fdda97ddd9e1339f225ce87920e1c9732
79ca585c438393c3c76d8442470f6fb625085b5d
/libs/libvtrutil/src/vtr_error.h
d5853bcde413390cf192dbcbcf986e87bfc078d8
[ "MIT" ]
permissive
tangxifan/libOpenFPGA
5408e632d07b300559a825234bc538657939fa6b
fc08c2b13d15046601919f1f1e696efce1607eb5
refs/heads/master
2022-10-28T01:48:18.373726
2019-04-22T03:27:08
2019-04-22T03:27:08
181,151,626
4
0
MIT
2022-09-30T20:17:31
2019-04-13T09:54:33
C++
UTF-8
C++
false
false
859
h
#ifndef VTR_ERROR_H #define VTR_ERROR_H #include <stdexcept> #include <string> namespace vtr { class VtrError : public std::runtime_error { public: VtrError(std::string msg="", std::string new_filename="", size_t new_linenumber=-1) : std::runtime_error(msg) , filename_(new_filename) , linenumber_(new_linenumber) {} //Returns the filename associated with this error //returns an empty string if none is specified std::string filename() const { return filename_; } const char* filename_c_str() const { return filename_.c_str(); } //Returns the line number associated with this error //returns zero if none is specified size_t line() const { return linenumber_; } private: std::string filename_; size_t linenumber_; }; } #endif
[ "tangxifan@gmail.com" ]
tangxifan@gmail.com
7f89a06c53c57152b79c2455e06819aeb0f931a3
5bb8e4ff7ca433044e8d9e7559c2f310364fca96
/opencv_ext.hpp
042530336f22b7cebcefb9d4e19f1c50e062595b
[ "MIT" ]
permissive
practisebody/OpenCV_ext
89ed896bcc607a187256c4f1d3e2fa4d0c4b8b55
7d57971e7d500c6ec4da768306f5c2faeba9f8e8
refs/heads/master
2020-05-07T16:10:02.932413
2019-05-03T21:14:45
2019-05-03T21:14:45
180,671,224
0
0
null
null
null
null
UTF-8
C++
false
false
31,763
hpp
#pragma once #include <stdarg.h> #include <functional> #include <map> #include <unordered_map> #include <optional> #include <variant> #include <regex> #include <type_traits> #include <vector> #include <opencv2/opencv.hpp> #define PRINT2BUFFER \ va_list va; \ va_start(va, format); \ vsprintf_s(detail::buffer, detail::bufferSize, format, va); \ va_end(va) // global detail namespace cv::detail { inline constexpr int bufferSize = 1024; inline char buffer[bufferSize]; inline void print2Buffer(const char* format, ...) { PRINT2BUFFER; } template <class T> inline void hash_combine(std::size_t& seed, const T& v) { seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } } namespace std { // Point_ template<typename _Tp> struct less<cv::Point_<_Tp>> { typedef cv::Point2f argument_type; typedef std::size_t result_type; bool operator()(const argument_type& p1, const argument_type& p2) const { return std::tie(p1.x, p1.y) < std::tie(p2.x, p2.y); } }; template<typename _Tp> struct hash<cv::Point_<_Tp>> { typedef cv::Point2f argument_type; typedef std::size_t result_type; result_type operator()(const argument_type& p) const noexcept { result_type seed = 0; cv::detail::hash_combine(seed, p.x); cv::detail::hash_combine(seed, p.y); return seed; } }; } namespace cv { #ifdef HAVE_OPENCV_CORE namespace detail { // type_traits template<class T> struct dim_vec : public std::is_arithmetic<T> { }; template<class T> struct dim_vec<cv::Vec<T, 2>> : std::integral_constant<int, 2> { }; template<class T> struct dim_vec<cv::Vec<T, 3>> : std::integral_constant<int, 3> { }; template<class T> struct dim_vec<cv::Vec<T, 4>> : std::integral_constant<int, 4> { }; template<class T> inline constexpr int dim_vec_v = dim_vec<T>::value; } namespace detail { template<class T, InterpolationFlags interpolation, class precision = float, class = std::enable_if_t<std::is_arithmetic_v<precision>>> class interpolate { public: inline T operator()(const Mat& img, Point_<precision>&& pt) const { static_assert(false); } }; template<class T, class precision> class interpolate<T, INTER_NEAREST, precision> { public: inline T operator()(const Mat& img, Point_<precision>&& pt) const { return img.at<T>(Point(cvRound(pt.x), cvRound(pt.y))); } }; template<class T, class precision> class interpolate<T, INTER_LINEAR, precision> { public: inline T operator()(const Mat& img, Point_<precision>&& pt) const { constexpr precision one = static_cast<precision>(1.0); const int x_ = static_cast<int>(pt.x); const int y_ = static_cast<int>(pt.y); const precision dx = pt.x - x_; const precision dy = pt.y - y_; #ifdef _DEBUG const int x[2] = { std::min(std::max(x_ + 0, 0), img.cols - 1), std::min(std::max(x_ + 1, 0), img.cols - 1) }; const int y[2] = { std::min(std::max(y_ + 0, 0), img.rows - 1), std::min(std::max(y_ + 1, 0), img.rows - 1) }; T f00 = img.at<T>(y[0], x[0]); T f10 = img.at<T>(y[0], x[1]); T f01 = img.at<T>(y[1], x[0]); T f11 = img.at<T>(y[1], x[1]); #else T f00 = img.at<T>(y_ + 0, x_ + 0); T f10 = img.at<T>(y_ + 0, x_ + 1); T f01 = img.at<T>(y_ + 1, x_ + 0); T f11 = img.at<T>(y_ + 1, x_ + 1); #endif T result; if constexpr (detail::dim_vec_v<T> == 1) result = (one - dx) * (one - dy) * f00 + dx * (one - dy) * f10 + (one - dx) * dy * f01 + dx * dy * f11; else if constexpr (detail::dim_vec_v<T> == 3) { for (int i = 0; i < 3; ++i) result[i] = (one - dx) * (one - dy) * f00[i] + dx * (one - dy) * f10[i] + (one - dx) * dy * f01[i] + dx * dy * f11[i]; } else assert(false); return result; } protected: //inline precision interpolate1(precision w00, pre) }; // to be rewriten /*template<class T, class precision> class interpolate<T, INTER_CUBIC, precision> { public: inline static T impl(const Mat& img, Point_<precision>&& pt) { static Mat coef = (Mat_<precision>(4, 4) << 1, 0, 0, 0, 0, 0, 1, 0, -3, 3, -2, -1, 2, -2, 1, 1 ); static Mat coef_T = (Mat_<precision>(4, 4) << 1, 0, -3, 2, 0, 0, 3, -2, 0, 1, -2, 1, 0, 0, -1, 1 ); int x_ = (int)pt.x; int y_ = (int)pt.y; int x[4] = { std::max(x_ - 1, 0), x_, std::min(x_ + 1, img.cols), std::min(x_ + 2, img.cols), }; int y[4] = { std:max(y_ - 1, 0), y_, std::min(y_ + 1, img.rows), std::min(y_ + 2, img.rows) }; for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) f(i, j) = img.at<T>(y[j], x[i]); Mat A = (Mat_<precision>(4, 4) << f(1, 1), f(2, 1), fy(1, 1), fy(2, 1), f(1, 2), f(2, 2), fy(1, 2), fy(2, 2), fx(1, 1), fx(2, 1), fxy(1, 1), fxy(2, 1), fx(1, 2), fx(2, 2), fxy(1, 2), fxy(2, 2) ); Mat a = coef * A * coef_T; const precision dx = pt.x - T(x_); const precision dy = pt.y - T(y_); const precision one = precision(1); Mat x_para = (Mat_<precision>(1, 4) << one, dx, dx * dx, dx * dx * dx); Mat y_para = (Mat_<precision>(4, 1) << one, dy, dy * dy, dy * dy * dy); Mat result = (x_para * a * y_para); return static_cast<T>(result.at<precision>(0, 0)); } protected: inline static precision& f(int i, int j) { static precision f[4][4]; return f[i][j]; } inline static precision fx(int i, int j) { return (f(i + 1, j) - f(i - 1, j)) / static_cast<precision>(2); } inline static precision fy(int i, int j) { return (f(i, j + 1) - f(i, j - 1)) / static_cast<precision>(2); } inline static precision fxy(int i, int j) { return (f(i + 1, j + 1) + f(i - 1, j - 1) - f(i + 1, j - 1) - f(i - 1, j + 1)) / static_cast<precision>(4); } };*/ } // at a subpixel point template<class T, InterpolationFlags interpolation = INTER_CUBIC, class precision> inline T at(const Mat& img, const Point_<precision>& pt) { return detail::interpolate<T, interpolation, precision>{}(img, std::move(pt)); } template<class T, InterpolationFlags interpolation = INTER_CUBIC, class precision> inline T at(const Mat& img, Point_<precision>&& pt) { return detail::interpolate<T, interpolation, precision>{}(img, std::move(pt)); } template<class T, InterpolationFlags interpolation, class precision> inline precision at(const Mat& img, Point_<precision>&& pt, int channel) { constexpr precision one = static_cast<precision>(1.0); const int x_ = static_cast<int>(pt.x); const int y_ = static_cast<int>(pt.y); const precision dx = pt.x - x_; const precision dy = pt.y - y_; #ifdef _DEBUG const int x[2] = { std::min(std::max(x_ + 0, 0), img.cols - 1), std::min(std::max(x_ + 1, 0), img.cols - 1) }; const int y[2] = { std::min(std::max(y_ + 0, 0), img.rows - 1), std::min(std::max(y_ + 1, 0), img.rows - 1) }; precision f00 = img.at<T>(y[0], x[0])[channel]; precision f10 = img.at<T>(y[0], x[1])[channel]; precision f01 = img.at<T>(y[1], x[0])[channel]; precision f11 = img.at<T>(y[1], x[1])[channel]; #else precision f00 = img.at<T>(y_ + 0, x_ + 0)[channel]; precision f10 = img.at<T>(y_ + 0, x_ + 1)[channel]; precision f01 = img.at<T>(y_ + 1, x_ + 0)[channel]; precision f11 = img.at<T>(y_ + 1, x_ + 1)[channel]; #endif precision one_dx = one - dx; return static_cast<precision>((f00 * one_dx + f10 * dx) * (one - dy) + (f01 * one_dx + f11 * dx) * dy); } // at a region inline Mat at(const Mat& img, int y, int x, const Size& s) { return img(Rect(Point(x - s.width / 2, y - s.height / 2), s)); } inline Mat at(const Mat& img, const Point& p, const Size& s) { return img(Rect(Point(p.x - s.width / 2, p.y - s.height / 2), s)); } // use Point to match Mat::at function inline const bool in(const Point& p, const Size& size) { return p.x >= 0 && p.x < size.width && p.y >= 0 && p.y < size.height; } inline const bool in(const Point& p, const Mat& mat) { return p.x >= 0 && p.x < mat.cols && p.y >= 0 && p.y < mat.rows; } // operations on arrays inline double median(const Mat& m, int histSize) { // calcuate histogram float range[] = { 0, static_cast<float>(histSize) }; const float* ranges = { range }; cv::Mat hist; calcHist(&m, 1, 0, cv::Mat(), hist, 1, &histSize, &ranges); // compute median double medianVal; int sum = 0; int half = m.total() / 2; for (int i = 0; i < histSize; i++) { if ((sum += cvRound(hist.at<float>(i))) >= half) { medianVal = i; break; } } return medianVal / histSize; } // drawing functions struct Color { constexpr Color(int r, int g, int b) : r(r), g(g), b(b), a(255) { } operator const Scalar() const { return Scalar(b, g, r, a); } operator const Vec3b() const { return Vec3b(b, g, r); } constexpr int operator[](size_t index) const { switch (index) { case 0: return b; case 1: return g; case 2: return r; case 3: return a; } } static Color Random() { static RNG_MT19937 rng; return Color(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255)); } int r, g, b, a; }; inline constexpr Color WHITE(255, 255, 255); inline constexpr Color BLACK(0, 0, 0); inline constexpr Color RED(255, 0, 0); inline constexpr Color GREEN(0, 255, 0); inline constexpr Color BLUE(0, 0, 255); inline constexpr Color CYAN(0, 255, 255); inline constexpr Color PURPLE(255, 0, 255); inline constexpr Color YELLOW(255, 255, 0); inline constexpr Color GRAY(127, 127, 127); template<size_t N> struct Palette { Palette() = default; Palette(const std::initializer_list<std::optional<Color>>& p) : colors(p) { } Palette(const std::initializer_list<Color>& p) { std::copy(p.begin(), p.end(), colors.begin()); } // constructor from only first N colors // TODO // constructor from initializer_list // TODO const std::optional<Color> operator[](size_t i) const { return i >= N ? std::nullopt : colors[i]; } std::vector<std::optional<Color>> colors = std::vector<std::optional<Color>>(N); }; template<class T> inline void point(const Mat& img, const Point_<T>& p, const Scalar& color, int thickness = 1) { cv::Point _p(p); line(img, _p, _p, color, thickness); } template<class T> inline void points(const Mat& img, const std::vector<Point_<T>>& p, const Scalar& color, int thichness = 1) { std::for_each(p.begin(), p.end(), std::bind(point<T>, img, std::placeholders::_1, color, thichness)); } template<class T> inline void cross(const Mat& img, const Point_<T>& pt, int size, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0) { int x = cvRound(pt.x), y = cvRound(pt.y); line(img, Point(x, y - size / 2), Point(x, y + size / 2), color, thickness, lineType, shift); line(img, Point(x - size / 2, y), Point(x + size / 2, y), color, thickness, lineType, shift); } template<class T> inline void cross(const Mat& img, const std::vector<Point_<T>>& pts, int size, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0) { for (const Point_<T>& pt : pts) cross(img, pt, size, color, thickness, lineType, shift); } template<class T> inline void crossX(const Mat& img, const Point_<T>& pt, int size, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0) { int x = cvRound(pt.x), y = cvRound(pt.y); line(img, Point(x - size / 2, y - size / 2), Point(x + size / 2, y + size / 2), color, thickness, lineType, shift); line(img, Point(x - size / 2, y + size / 2), Point(x + size / 2, y - size / 2), color, thickness, lineType, shift); } template<class T> inline void crossX(const Mat& img, const std::vector<Point_<T>>& pts, int size, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0) { for (const Point_<T>& pt : pts) crossX(img, pt, size, color, thickness, lineType, shift); } template<class T> inline void box(const Mat& img, const Point_<T>& pt, Size size, int length, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0) { int x = cvRound(pt.x - size.width / T(2)), y = cvRound(pt.y - size.height / T(2)); rectangle(img, cv::Rect(x, y, size.width, size.height), color, thickness, lineType, shift); } template<class T> inline void aimingBox(const Mat& img, const Point_<T>& pt, Size size, int length, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0) { int x = cvRound(pt.x), y = cvRound(pt.y); line(img, Point(x - size.width / 2, y - size.height / 2), Point(x - size.width / 2 + length, y - size.height / 2), color, thickness, lineType, shift); line(img, Point(x - size.width / 2, y - size.height / 2), Point(x - size.width / 2, y - size.height / 2 + length), color, thickness, lineType, shift); line(img, Point(x + size.width / 2, y - size.height / 2), Point(x + size.width / 2 - length, y - size.height / 2), color, thickness, lineType, shift); line(img, Point(x + size.width / 2, y - size.height / 2), Point(x + size.width / 2, y - size.height / 2 + length), color, thickness, lineType, shift); line(img, Point(x - size.width / 2, y + size.height / 2), Point(x - size.width / 2 + length, y + size.height / 2), color, thickness, lineType, shift); line(img, Point(x - size.width / 2, y + size.height / 2), Point(x - size.width / 2, y + size.height / 2 - length), color, thickness, lineType, shift); line(img, Point(x + size.width / 2, y + size.height / 2), Point(x + size.width / 2 - length, y + size.height / 2), color, thickness, lineType, shift); line(img, Point(x + size.width / 2, y + size.height / 2), Point(x + size.width / 2, y + size.height / 2 - length), color, thickness, lineType, shift); } // text namespace params::draw::text { inline int xOffset = 10; inline int yOffset = 30; inline int lineHeight = 15; inline double fontScale = 0.5; inline Color defaultColor = GREEN; } inline void drawText(const Mat& img, Point org, const Scalar& color, const double scale, const char* format, ...) { PRINT2BUFFER; putText(img, detail::buffer, org, FONT_HERSHEY_SIMPLEX, scale, color); } template<class... T> inline void drawText(const Mat& img, Point org, const Scalar& color, const char* format, const T&... t) { drawText(img, org, color, params::draw::text::fontScale, format, t...); } namespace detail::draw::text { inline int line; } template<class... T> inline void drawText(const Mat& img, int line, const Scalar& color, const char* format, const T&... t) { drawText(img, Point(params::draw::text::xOffset, params::draw::text::yOffset + line * params::draw::text::lineHeight), color, format, t...); } template<class... T> inline void drawText(const Mat& img, int line, const char* format, const T&... t) { drawText(img, line, params::draw::text::defaultColor, format, t...); } inline void resetLine() { detail::draw::text::line = -1; } inline void nextLine() { ++detail::draw::text::line; } template<class... T> inline void nextLine(const Mat& img, const Scalar& color, const char* format, const T&... t) { drawText(img, ++detail::draw::text::line, color, format, t...); } template<class... T> inline void nextLine(const Mat& img, const char* format, const T&... t) { nextLine(img, params::draw::text::defaultColor, format, t...); } inline void nextLine(const Mat& img, const Scalar& color, const std::string& str) { drawText(img, ++detail::draw::text::line, color, str.c_str()); } inline void nextLine(const Mat& img, const std::string& str) { nextLine(img, params::draw::text::defaultColor, str); } template<class... T> inline void firstLine(const Mat& img, const Scalar& color, const T&... t) { resetLine(); nextLine(img, color, t...); } template<class... T> inline void firstLine(const Mat& img, const Color& color, const T&... t) { resetLine(); nextLine(img, static_cast<const Scalar&>(color), t...); } template<class... T> inline void firstLine(const Mat& img, const Vec3b& color, const T&... t) { resetLine(); nextLine(img, static_cast<const Scalar&>(color), t...); } template<class... T> inline void firstLine(const Mat& img, const T&... t) { firstLine(img, static_cast<const Scalar&>(params::draw::text::defaultColor), t...); } // advanced drawing template<class T> Mat bar(std::vector<T> scores, int hIndex = -1, bool min = true, const Palette<4>& palette = {}) { const Vec3b background = palette[0].value_or(BLACK); const Vec3b foreground = palette[1].value_or(WHITE); const Vec3b highlight = palette[2].value_or(RED); const Vec3b highlight2 = palette[3].value_or(GREEN); int min_index = std::distance(scores.begin(), min ? std::min_element(scores.begin(), scores.end()) : std::max_element(scores.begin(), scores.end())); T max = *std::max_element(scores.begin(), scores.end()); max += static_cast<T>(0.0001); std::for_each(scores.begin(), scores.end(), [&](T& f) { f /= max; }); Mat bar(scores.size(), scores.size(), CV_8UC3); for (int y = 0; y < bar.rows; ++y) { T _y = static_cast<T>(1.0) - static_cast<T>(y) / bar.rows; for (int x = 0; x < bar.cols; ++x) { if (_y > scores[x]) bar.at<Vec3b>(y, x) = background; else { if (x == min_index) bar.at<Vec3b>(y, x) = highlight; else if (x == hIndex) bar.at<Vec3b>(y, x) = highlight2; else bar.at<Vec3b>(y, x) = foreground; } } } return bar; } #endif #ifdef HAVE_OPENCV_CALIB3D inline double calibrate(const std::vector<Mat>& images, const Size& size, const double side, Mat& camera, Mat& dist) { std::vector<Point3f> points; std::vector<Point2f> corners; for (int j = 0; j < size.height; ++j) for (int i = 0; i < size.width; ++i) points.emplace_back(Point3f(static_cast<float>(i * side), static_cast<float>(j * side), 0.0f)); std::vector<std::vector<Point2f>> imagePoints; std::vector<std::vector<Point3f>> objectPoints; Mat gray; bool detected; for (size_t i = 0; i < images.size(); ++i) { if (images[i].channels() == 3) cvtColor(images[i], gray, COLOR_BGR2GRAY); else gray = images[i]; detected = findChessboardCorners(gray, size, corners, CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE | CALIB_CB_FAST_CHECK); if (detected) { cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1), TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, 0.1)); imagePoints.push_back(corners); objectPoints.push_back(points); } } std::vector<Mat> rvecs, tvecs; return calibrateCamera(objectPoints, imagePoints, images[0].size(), camera, dist, rvecs, tvecs); } #endif #ifdef HAVE_OPENCV_HIGHGUI struct Grid { public: Grid() : width(0), height(0) {} Grid(int w, int h) : width(w), height(h) {} int width; int height; }; inline Mat at(const Mat& img, const Grid& matrix, size_t index, const Grid& size = { 1, 1 }) { assert(index < size_t(matrix.width * matrix.height)); size_t width = img.cols / matrix.width; size_t height = img.rows / matrix.height; return img(Rect(Point((index % matrix.width) * width, (index / matrix.width) * height), cv::Size(size.width * width, size.height * height))); } inline void imsubplot(Mat& img, const Grid& matrix, const Size& size, size_t index, const Mat& sub, bool resize = false) { assert(index < size_t(matrix.width * matrix.height)); if (sub.rows && sub.cols) { if (resize) cv::resize(sub, at(img, matrix, index), size); else sub.copyTo(at(img, matrix, index)(cv::Rect(cv::Point(0, 0), sub.size()))); } } inline void imsubplot(Mat& img, const Grid& matrix, size_t index, const Mat& sub) { assert(index < size_t(matrix.width * matrix.height)); assert(sub.rows && sub.cols); const Size size = sub.size(); sub.copyTo(at(img, matrix, index)); } namespace params::imshow { struct for_each_subplot_tag { }; inline constexpr for_each_subplot_tag for_each_subplot {}; struct save_tag { }; inline constexpr save_tag save {}; } namespace detail::impack { // find the maximum size of all the images template<class... T> inline void getMaxSize(Size& size) { } template<class... T> inline void getMaxSize(Size& size, const Mat& m, const T&... t); template<class... T> inline void getMaxSize(Size& size, InputOutputArray m, const T&... t) { if (m.empty() == false) { const cv::Mat& mat = m.getMatRef(); size.width = std::max(size.width, mat.cols); size.height = std::max(size.height, mat.rows); } getMaxSize(size, t...); } template<class... T> inline void getMaxSize(Size& size, const Mat& m, const T&... t) { size.width = std::max(size.width, m.cols); size.height = std::max(size.height, m.rows); getMaxSize(size, t...); } // find the type of the images template<class... T> inline int getType(const Mat& m, const T&... t); template<class... T> inline int getType(InputOutputArray m, const T&... t) { if (m.empty() == false) return m.getMatRef().type(); return getType(t...); } template<class... T> inline int getType(const Mat& m, const T&... t) { return m.type(); } template<class... T> inline void imsubplotFrom(Mat& img, const Grid& matrix, const Size& size, size_t index, const T&... t) { } template<class... T> inline void imsubplotFrom(Mat& img, const Grid& matrix, const Size& size, size_t index, const Mat& sub, const T&... t); template<class... T> inline void imsubplotFrom(Mat& img, const Grid& matrix, const Size& size, size_t index, InputOutputArray sub, const T&... t) { if (sub.empty()) imsubplotFrom(img, matrix, size, index + 1, t...); else { const cv::Mat& mat = sub.getMatRef(); imsubplotFrom(img, matrix, size, index, mat, t...); } } template<class... T> inline void imsubplotFrom(Mat& img, const Grid& matrix, const Size& size, size_t index, const Mat& sub, const T&... t) { size_t x = index % matrix.width; size_t y = index / matrix.width; if (x < static_cast<size_t>(matrix.width) && y < static_cast<size_t>(matrix.height)) { sub.copyTo(img(Rect(Point(x * size.width, y * size.height), sub.size()))); imsubplotFrom(img, matrix, size, index + 1, t...); } } } template<class... T> inline Mat impack(const Grid& matrix, InputOutputArray sub1, const T&... t) { Size size; detail::impack::getMaxSize(size, sub1, t...); Mat img = Mat::zeros(matrix.height * size.height, matrix.width * size.width, detail::impack::getType(sub1, t...)); detail::impack::imsubplotFrom(img, matrix, size, 0, sub1, t...); return img; } template<class... T> inline Mat impack(const Grid& matrix, const Size& size, const Mat& sub1, const T&... t) { Mat img = Mat::zeros(matrix.height * size.height, matrix.width * size.width, detail::impack::getType(sub1, t...)); detail::impack::imsubplotFrom(img, matrix, size, 0, sub1, t...); return img; } inline Mat impack(const Grid& matrix, const std::vector<Mat>& plots) { assert(plots.size() > 0); Size size = plots[0].size(); for (size_t i = 1; i < plots.size(); ++i) { size.width = std::max(size.width, plots[i].cols); size.height = std::max(size.height, plots[i].rows); } Mat img = Mat::zeros(size.height * matrix.height, size.width * matrix.width, plots[0].type()); for (size_t i = 0; i < plots.size(); ++i) imsubplot(img, matrix, size, i, plots[i], false); return img; } inline Mat impack(const Grid& matrix, const Size& size, const std::vector<Mat>& plots) { Mat img = Mat::zeros(size.height * matrix.height, size.width * matrix.width, plots[0].type()); for (size_t i = 0; i < plots.size(); ++i) imsubplot(img, matrix, size, i, plots[i], false); return img; } namespace params::imshow { // some global variable inline bool show = true; inline double zoom = 1.0; inline bool refresh = true; inline bool wait = false; inline bool defaultSave = false; inline bool drawText = true; inline std::string savePrefix; inline std::string saveFormat = ".png"; } namespace detail::imshow { template<class T> using is_drawing_function = std::enable_if_t<std::is_invocable_v<T, Mat&>>; inline int windowCount = 0; struct Params { Params() { } // first string is window name, all the rest are printed on the image // string from C style format string template<class... Tuple, class... T> Params(const std::tuple<Tuple...>& tuple, const T&... t) : Params(t...) { lines.emplace_back(std::apply(print, tuple)); } // string from std::string template<class... T> Params(const std::string_view& s, const T&... t) : Params(t...) { lines.emplace_back(s); } // zoom template<class... T> Params(double z, const T&... t) : Params(t...) { zoom = z; } // mouse callback template<class... T> Params(MouseCallback cb, const T&... t) : Params(t...) { callback = cb; } // text color template<class... T> Params(const Color& color, const T&... t) : Params(t...) { textColor = color; } template<class Func, class... T, class = is_drawing_function<Func>> Params(Func fn, const T&... t) : Params(t...) { drawing.emplace_back(fn); } template<class... T> Params(const Grid& m, const T&... t) : Params(t...) { matrix = m; } template<class... T> Params(const Size& s, const T&... t) : Params(t...) { size = s; } template<class Func, class... T, class = is_drawing_function<Func>> Params(Func fn, params::imshow::for_each_subplot_tag, const T&... t) : Params(t...) { drawingSubplot.emplace_back(fn); } template<class... T> Params(params::imshow::save_tag, const T&... t) : Params(t...) { save = true; } // ignore all the images, won't be parsed as parameters template<class... T> Params(const Mat&, const T&... t) : Params(t...) { } template<class... T> Params(cv::InputOutputArray&, const T&... t) : Params(t...) { } std::optional<double> zoom = params::imshow::zoom; std::optional<MouseCallback> callback; std::optional<Color> textColor; std::vector<std::string> lines; std::vector<std::function<void(Mat&)>> drawing; Grid matrix; Size size; std::vector<std::function<void(Mat&)>> drawingSubplot; bool save = false; protected: inline static std::string print(const char* format, ...) { PRINT2BUFFER; return buffer; } }; } template<class... T> inline void imshow(const Mat& m, const T&... t) { if (params::imshow::show == false) return; detail::imshow::Params p(t...); std::string winname; if (p.lines.size() && p.lines.back().length()) winname = p.lines.back(); else { // if no given window name detail::print2Buffer("Untitled %d", ++detail::imshow::windowCount); winname = detail::buffer; } if (p.callback) { namedWindow(winname); setMouseCallback(winname, *p.callback); } Mat out; if (p.zoom && *p.zoom != 1.0) { resize(m, out, Size(), *p.zoom, *p.zoom); if (out.channels() == 1) cv::cvtColor(out, out, cv::COLOR_GRAY2BGR); } else { if (m.channels() == 1) cv::cvtColor(m, out, cv::COLOR_GRAY2BGR); else out = m; } if (p.drawingSubplot.size()) { for (int y = 0; y < p.matrix.height; ++y) { for (int x = 0; x < p.matrix.width; ++x) { Mat subplot = out(Rect(Point(x * p.size.width, y * p.size.height), p.size)); for (auto& f : p.drawingSubplot) f(subplot); } } } for (auto& f : p.drawing) f(out); // text if (params::imshow::drawText) { const Color& c = p.textColor.value_or(params::draw::text::defaultColor); resetLine(); if (p.lines.size() > 0) std::for_each(p.lines.rbegin() + 1, p.lines.rend(), std::bind(static_cast<void (*)(const Mat&, const Scalar&, const std::string&)>(nextLine), std::ref(out), c, std::placeholders::_1)); } imshow(winname, out); if (params::imshow::refresh || params::imshow::wait) waitKey(!params::imshow::wait); if (params::imshow::defaultSave || p.save) imwrite("./" + params::imshow::savePrefix + "/" + winname + params::imshow::saveFormat, out); } template<class... T> inline void imshow(const Grid& matrix, const T&... t) { Mat pack = impack(matrix, t...); imshow(pack, matrix, t...); } template<class... T> inline void imshow(const Grid& matrix, const std::vector<Mat>& plots, const T&... t) { Mat pack = impack(matrix, plots); imshow(pack, matrix, t...); } struct loop_exit_tag {}; inline constexpr loop_exit_tag loop_exit; template<typename T> inline std::variant<T, loop_exit_tag> switch_key(T key) { return key; } template<class T, class Func> inline std::variant<T, loop_exit_tag> switch_key(T key, Func _default) { _default(key); return key; } template<class T, class Func, class... Ts> inline std::variant<T, loop_exit_tag> switch_key(T key, T candidate, Func func, const Ts&... ts); template<class T, class Func, class... Ts, class = std::enable_if_t<std::is_integral_v<T>>> inline std::variant<T, loop_exit_tag> switch_key(T key, const std::string& candidates, Func func, const Ts&... ts) { if (candidates.find(key) != std::string::npos) return switch_key<T>(key, key, func, ts...); else return switch_key<T>(key, ts...); } template<class T, class Func, class... Ts, class = std::enable_if_t<std::is_integral_v<T>>> inline std::variant<T, loop_exit_tag> switch_key(T key, const char* candidates, Func func, const Ts&... ts) { return switch_key<T>(key, std::string(candidates), func, ts...); } template<class T, class Func, class... Ts> inline std::variant<T, loop_exit_tag> switch_key(T key, const std::vector<T>& candidates, Func func, const Ts&... ts) { if (std::find(candidates.begin(), candidates.end(), key) != candidates.end()) return switch_key<T>(key, key, func, ts...); else return switch_key<T>(key, ts...); } template<class T, class Func, class... Ts> inline std::variant<T, loop_exit_tag> switch_key(T key, T candidate, Func func, const Ts&... ts) { if (key == candidate) { if constexpr (std::is_same_v<Func, loop_exit_tag>) return loop_exit; else { func(); return key; } } else return switch_key<T>(key, ts...); } template<class Fn, class T = typename std::invoke_result_t<Fn>, class... Ts> inline void loop(Fn func, const Ts&... ts) { while (true) { std::variant<T, loop_exit_tag> result = switch_key<T>(func(), ts...); if (std::holds_alternative<loop_exit_tag>(result)) return; } } #endif #ifdef HAVE_OPENCV_IMGCODECS namespace params::imwrite { inline static double fps = 30.0; } namespace detail::imwrite { inline static std::map<std::string, int> counters; inline static std::map<std::string, cv::VideoWriter> videoWriters; } template<class... T> inline void imwrite(const Mat& m, const char* format, T&&... t) { static std::regex formatReg("[^%]*%[0-9]*d.*"); static std::regex videoReg(".*(.mp4|.avi)"); if (std::regex_match(format, formatReg) && sizeof...(t) == 0) { if (detail::imwrite::counters.count(format) == 0) detail::imwrite::counters[format] = 0; detail::print2Buffer(format, detail::imwrite::counters[format]++, std::forward<T>(t)...); imwrite(detail::buffer, m); } else if (std::regex_match(format, videoReg)) { if (detail::imwrite::videoWriters.count(format) == 0) { cv::VideoWriter writer; if constexpr (sizeof...(t) == 0) writer.open(format, 0, params::imwrite::fps, m.size()); else if constexpr (sizeof...(t) == 1) writer.open(format, 0, std::forward<T>(t)..., m.size()); else if constexpr (sizeof...(t) == 2) writer.open(format, std::forward<T>(t)..., m.size()); else if constexpr (sizeof...(t) == 3) writer.open(format, std::forward<T>(t)...); else assert(false); detail::imwrite::videoWriters[format] = std::move(writer); } detail::imwrite::videoWriters[format] << m; } else { if constexpr (sizeof...(t) == 0) imwrite(format, m); else { detail::print2Buffer(format, std::forward<T>(t)...); imwrite(detail::buffer, m); } } } template<class... T> inline void imwrite(const Mat& m, const std::string& format, T&&... t) { imwrite(m, format.c_str(), std::forward<T>(t)...); } #endif #ifdef HAVE_OPENCV_IMGPROC inline void cvtGray(const Mat& input, Mat& output) { int c = input.channels(); switch (c) { case 4: cvtColor(input, output, COLOR_BGRA2GRAY); break; case 3: cvtColor(input, output, COLOR_BGR2GRAY); break; case 1: output = input.clone(); default: assert(false); } } inline void cvtBGR(const Mat& input, Mat& output) { if (input.channels() == 1) cvtColor(input, output, COLOR_GRAY2BGR); else output = input.clone(); } #endif } #undef PRINT2BUFFER
[ "lcy930822@gmail.com" ]
lcy930822@gmail.com
35a598aea4fb1407e1618ac93be5cc75755e5b5b
f2339e85157027dada17fadd67c163ecb8627909
/Client/EffectClient/Src/EffectChangeWingState.h
7c9bc8fa4fa0821426c6f71e78c2bc2d272d38bb
[]
no_license
fynbntl/Titan
7ed8869377676b4c5b96df953570d9b4c4b9b102
b069b7a2d90f4d67c072e7c96fe341a18fedcfe7
refs/heads/master
2021-09-01T22:52:37.516407
2017-12-29T01:59:29
2017-12-29T01:59:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,477
h
/******************************************************************* ** 文件名: EffectChangeWingState.h ** 版 权: (C) 深圳冰川网络技术有限公司 2008 - All Rights Reserved ** 创建人: 彭政林 ** 日 期: 1/20/2016 ** 版 本: 1.0 ** 描 述: 效果-改变翅膀状态 ********************************************************************/ #pragma once #include "IEffect.h" #include "EffectDef.h" #include "IWingPart.h" using namespace EFFECT_CLIENT; class CEffectChangeWingState : public IEffect { public: typedef EffectClient_ChangeWingState SCHEME_DATA; CEffectChangeWingState( SCHEME_DATA & data ) : m_data(data) { } // 效果启用 virtual bool Start( EFFECT_CONTEXT *pContext ) { if ( pContext==0 || pContext->pEntity==0 ) return false; // 改变翅膀状态 cmd_Entity_Change_Wing_State ChangeWingState; ChangeWingState.nType = m_data.nType; sstrcpyn(ChangeWingState.szPath, m_data.szPath, sizeof(ChangeWingState.szPath)); ChangeWingState.fSpeed = m_data.fSpeed; ChangeWingState.fAcceleration = m_data.fAcceleration; ChangeWingState.fMaxSpeed = m_data.fMaxSpeed; ChangeWingState.fMinFlyHeight = m_data.fMinFlyHeight; ChangeWingState.fMaxFlyHeight = m_data.fMaxFlyHeight; ChangeWingState.fUpSpeed = m_data.fUpSpeed; ChangeWingState.fMinCameraAngle = m_data.fMinCameraAngle; ChangeWingState.fMaxCameraAngle = m_data.fMaxCameraAngle; ChangeWingState.fCameraDistance = m_data.fCameraDistance; if(pContext->pEntity->isHero()) { IWingPart* pWingPart = (IWingPart*)pContext->pEntity->getEntityPart(PART_WING); if(pWingPart != NULL) { SWing* pWing = pWingPart->getWing(); if(pWing != NULL) { ChangeWingState.nEncounterDistance = pWing->nEncounterDistance; } } } pContext->pEntity->sendCommandToEntityView(ENTITY_TOVIEW_CHANGE_WING_STATE, 0, 0, &ChangeWingState, sizeof(ChangeWingState)); return true; } // 效果停止 virtual void Stop() { } // 克隆一个新效果 virtual IEffect * Clone() { return new CEffectChangeWingState(m_data); } // 取得效果ID virtual int GetEffectID(){ return m_data.nID; } // 释放 virtual void Release() { Stop(); delete this; } private: SCHEME_DATA m_data; };
[ "85789685@qq.com" ]
85789685@qq.com
104ad9f3c783b233071efc84b7f2bdde4ec13bf2
3d3449090241f6a0fdb9f387f50ceb1e31e640ff
/Assignment_5/RTIS_Students_V2/src/shaders/directshader.h
3d93066cad18f2bb18ed6bb2ebc0776d3785a0da
[]
no_license
MrSebbs/SyntheticImage
b1bd78c29dc860bc001e6ca8192762162220d96c
268b46fc94bb5f6f12ec71a5dd32a75ac5604a8d
refs/heads/master
2020-05-22T08:52:47.274291
2016-06-08T21:49:13
2016-06-08T21:49:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
450
h
#ifndef DIRECTSHADER_H #define DIRECTSHADER_H #include "shader.h" class DirectShader : public Shader { public: DirectShader(); DirectShader(Vector3D color_, double maxDist_, Vector3D bgColor_); virtual Vector3D computeColor(const Ray &r, const std::vector<Shape*> &objList, const std::vector<PointLightSource> &lsList) const; private: Vector3D color; // Used to store the visualization color double maxDist; }; #endif // DIRECTSHADER_H
[ "david.perez12@estudiant.upf.edu" ]
david.perez12@estudiant.upf.edu
f9a0d6d268ef01d455fccf436fa88d7df09181ef
8d21f2077b6825b7e59b51d97177784db0d285b4
/ImageFilter/cuImageFilter.cpp
0a0d37c854246e2520137596db8149668c589e6f
[]
no_license
pengwg/fastrecon
eba70a3d7d1fa168b6a5985ed213b972f36f8517
7c925c6095ee56b4b59b20d4f66ffc52cde25db5
refs/heads/master
2021-01-19T16:24:54.283009
2015-03-12T20:59:35
2015-03-12T21:34:40
11,015,822
0
0
null
null
null
null
UTF-8
C++
false
false
1,192
cpp
#include "cuImageFilter.h" template<typename T> cuImageFilter<T>::cuImageFilter(cuImageData<T> &imageData) : ImageFilter<T>(imageData), m_associatedData(imageData) { } template<typename T> void cuImageFilter<T>::lowFilter(int res) { ImageFilter<T>::lowFilter(res); m_associatedData.invalidateDevice(); } template<typename T> void cuImageFilter<T>::normalize() { ImageFilter<T>::normalize(); m_associatedData.invalidateDevice(); } template<typename T> void cuImageFilter<T>::fftPlan(int sign) { if (this->m_fft != nullptr) delete this->m_fft; switch (sign) { case FFTW_FORWARD: sign = CUFFT_FORWARD; break; case FFTW_BACKWARD: sign = CUFFT_INVERSE; } this->m_fft = new cuFFT(m_associatedData.dim(), m_associatedData.imageSize(), sign); this->m_fft->plan(); } template<typename T> void cuImageFilter<T>::fftShift2(ComplexVector<T> *data) { ImageFilter<T>::fftShift2(data); m_associatedData.invalidateDevice(); } template<typename T> void cuImageFilter<T>::fftShift3(ComplexVector<T> *data) { ImageFilter<T>::fftShift3(data); m_associatedData.invalidateDevice(); } template class cuImageFilter<float>;
[ "pengwg@gmail.com" ]
pengwg@gmail.com
5b627ef6297f608d0db516146da53e7840056b92
7283cd9f633b31614a0d8b48d4412545da6847aa
/HarryPotter.cpp
7ad1935bb79e431ac2d0e58acd7a94b24d431190
[]
no_license
jeinhorn787/Fantasy-War-Game
4d9a69f5301c60ef1872f7df207a13d06e835fbe
46c48dd6a29c37ff266e8b2d3a8f567011a32243
refs/heads/master
2021-04-26T22:43:57.510598
2018-03-06T21:07:43
2018-03-06T21:07:43
124,138,609
0
0
null
null
null
null
UTF-8
C++
false
false
2,107
cpp
/********************************************************************************************** ** Program: Project 3 (Creatures) ** Author: Jeremy Einhorn ** Date: August 4, 2017 ** Description: This is the implementation file for the class HarryPotter. It rolls its attack die randomly and rolls defense die randomly then preforms necessary calculatons. Harry's strength is restored to 20 if he dies and has never died before. ***********************************************************************************************/ #include"HarryPotter.hpp" using std::cout; using std::endl; //constructor sets strength and armor HarryPotter::HarryPotter() : Creature() { this->strength = 10; this->armor = 0; } //rolls 2 die randomly for an attack int HarryPotter::attack() { //2 random die from 1-6 int die1 = (rand() % 6) + 1; int die2 = (rand() % 6) + 1; return die1 + die2; } //rolls 2 defense die then does calculations. If Harry dies and has not died before, //his strength is restored to 20. If Harry dies again, he cannot be revived. void HarryPotter::defense(int a) { //2 random die from 1-6 inclusive int die1 = (rand() % 6) + 1; int die2 = (rand() % 6) + 1; int roll = die1 + die2; cout << "Harry Potter rolled a defense of " << roll << endl; //damage is attackers roll minus the defense roll minus armor int damage = a - roll - armor; //if damage is greater than 0 if (damage > 0) { cout << "Harry Potter's armor and defense reduced the damage to " << damage << endl; //take damage away from strength strength -= damage; } //if damage is 0 or negative else cout << "Harry Potter did not take any damage!" << endl; //if strength is 0 or less and Harry has not died before if (strength <= 0 && deathCounter < 1) { cout << "Harry Potter died but used Hogwartz, he revives even stronger!" << endl; //strength restored to 20, 1 death is added to death counter this->strength = 20; deathCounter += 1; } } //returns name string HarryPotter::getCreature() { return "Harry Potter"; }
[ "noreply@github.com" ]
noreply@github.com
3fbfcf0da8ce70620b8dff223546b552dbba07a8
e8f36f48a12b0f1fb88ae59cb28c15a6470d6ee2
/src/program/game/FOV.cpp
2ba439620e3f07711ed59a1e0edd63ea516874ae
[]
no_license
Adanos020/PAhAom-Old
f13ec29cde66669cd6d43599ab49b2bb29082ce1
610ccafaf39aa4c97a0a2268234e1418f28b0a85
refs/heads/master
2021-06-11T14:21:59.213500
2017-02-20T22:18:56
2017-02-20T22:18:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,695
cpp
/** * @file src/program/game/FOV.cpp * @author Adam 'Adanos' Gąsior * Used library: SFML */ #include <cmath> #include <iostream> #include "FOV.hpp" namespace rr { void FOV::compute(ShadowMap& shadows, Level& level, sf::Vector2i origin, int range) { shadows.darken(); shadows.setLit(origin.x, origin.y); for (unsigned octant = 0; octant < 8; octant++) { compute(shadows, level, octant, origin, 2*range, 1, Slope(1, 1), Slope(0, 1)); } shadows.update(); } void FOV::compute(ShadowMap& shadows, Level& level, unsigned octant, sf::Vector2i origin, int range, unsigned x, Slope top, Slope bottom) { for (; x <= (unsigned) range; x++) { unsigned topY; if (top.x_ == 1) topY = x; else { topY = ((x*2-1)*top.y_+top.x_) / (top.x_*2); if (blocksLight(level, x, topY, octant, origin) && top >= Slope(topY*2+1, x*2) && !blocksLight(level, x, topY+1, octant, origin)) { ++topY; } else { unsigned ax = x*2; if (blocksLight(level, x+1, topY+1, octant, origin)) ++ax; if (top > Slope(topY*2+1, ax)) ++topY; } } unsigned bottomY; if (bottom.y_ == 0) bottomY = 0; else { bottomY = ((x*2-1)*bottom.y_+bottom.x_)/(bottom.x_*2); if (bottom >= Slope(bottomY*2+1, x*2) && blocksLight(level, x, bottomY, octant, origin) && !blocksLight(level, x, bottomY+1, octant, origin)) { ++bottomY; } } int wasOpaque = -1; for (unsigned y = topY; (int) y >= (int) bottomY;-- y) { if (range < 0 || getDistance((int) x, (int) y) <= range) { bool isOpaque = blocksLight(level, x, y, octant, origin); if (isOpaque || ((y != topY || top > Slope(y*4-1, x*4+1)) && (y != bottomY || bottom < Slope(y*4+1, x*4-1)))) { setVisible(shadows, x, y, octant, origin); } if ((int) x != range) { if (isOpaque) { if (wasOpaque == 0) { unsigned nx = x*2, ny = y*2+1; if (blocksLight(level, x, y+1, octant, origin)) --nx; if (top > Slope(ny, nx)) { if (y == bottomY) { bottom = Slope(ny, nx); break; } else compute(shadows, level, octant, origin, range, x+1, top, Slope(ny, nx)); } else if (y == bottomY) return; } wasOpaque = 1; } else { if (wasOpaque > 0) { unsigned nx = x*2, ny = y*2+1; if (blocksLight(level, x+1, y+1, octant, origin)) ++nx; if (bottom >= Slope(ny, nx)) return; top = Slope(ny, nx); } wasOpaque = 0; } } } } if (wasOpaque != 0) break; } } bool FOV::seesEntity(Level& level, Entity* e1, Entity* e2) { for (unsigned octant = 0; octant < 8; octant++) { if (seesEntity(level, octant, e1->getGridPosition(), e2->getGridPosition(), 14, 1, Slope(1, 1), Slope(0, 1))) { return true; } } return false; } bool FOV::seesEntity(Level& level, unsigned octant, sf::Vector2i origin, sf::Vector2i dest, int range, unsigned x, Slope top, Slope bottom) { for (; x <= (unsigned) range; ++x) { unsigned topY; if (top.x_ == 1) topY = x; else { topY = ((x*2-1)*top.y_+top.x_) / (top.x_*2); if (blocksLight(level, x, topY, octant, origin) && top >= Slope(topY*2+1, x*2) && !blocksLight(level, x, topY+1, octant, origin)) { ++topY; } else { unsigned ax = x*2; if (blocksLight(level, x+1, topY+1, octant, origin)) ++ax; if (top > Slope(topY*2+1, ax)) ++topY; } } unsigned bottomY; if (bottom.y_ == 0) bottomY = 0; else { bottomY = ((x*2-1)*bottom.y_+bottom.x_)/(bottom.x_*2); if (bottom >= Slope(bottomY*2+1, x*2) && blocksLight(level, x, bottomY, octant, origin) && !blocksLight(level, x, bottomY+1, octant, origin)) { ++bottomY; } } int wasOpaque = -1; for (unsigned y = topY; (int) y >= (int) bottomY;-- y) { if (range < 0 || getDistance((int) x, (int) y) <= range) { bool isOpaque = blocksLight(level, x, y, octant, origin); if (isOpaque || ((y != topY || top > Slope(y*4-1, x*4+1)) && (y != bottomY || bottom < Slope(y*4+1, x*4-1)))) { if (getVisible(x, y, octant, origin) == dest) return true; } if ((int) x != range) { if (isOpaque) { if (wasOpaque == 0) { unsigned nx = x*2, ny = y*2+1; if (blocksLight(level, x, y+1, octant, origin)) --nx; if (top > Slope(ny, nx)) { if (y == bottomY) { bottom = Slope(ny, nx); break; } else seesEntity(level, octant, origin, dest, range, x+1, top, Slope(ny, nx)); } else if (y == bottomY) return false; } wasOpaque = 1; } else { if (wasOpaque > 0) { unsigned nx = x*2, ny = y*2+1; if (blocksLight(level, x+1, y+1, octant, origin)) ++nx; if (bottom >= Slope(ny, nx)) return false; top = Slope(ny, nx); } wasOpaque = 0; } } } } if (wasOpaque != 0) break; } return false; } bool FOV::blocksLight(Level& level, int x, int y, unsigned octant, sf::Vector2i origin) { int nx = origin.x, ny = origin.y; switch (octant) { case 0: nx += x; ny -= y; break; case 1: nx += y; ny -= x; break; case 2: nx -= y; ny -= x; break; case 3: nx -= x; ny -= y; break; case 4: nx -= x; ny += y; break; case 5: nx -= y; ny += x; break; case 6: nx += y; ny += x; break; case 7: nx += x; ny += y; break; } auto entity = level.getEntityAt(sf::Vector2i(nx, ny), Entity::DOOR, true); bool doorClosed = entity != nullptr && entity->getSpecies() == Entity::DOOR && !((Door*) entity)->isOpen(); return (nx < 77 && nx >= 0 && ny < 43 && ny >= 0) && (level.getTiles()[nx + ny*77] == 1 || doorClosed); } void FOV::setVisible(ShadowMap& shadows, int x, int y, unsigned octant, sf::Vector2i origin) { int nx = origin.x, ny = origin.y; switch (octant) { case 0: nx += x; ny -= y; break; case 1: nx += y; ny -= x; break; case 2: nx -= y; ny -= x; break; case 3: nx -= x; ny -= y; break; case 4: nx -= x; ny += y; break; case 5: nx -= y; ny += x; break; case 6: nx += y; ny += x; break; case 7: nx += x; ny += y; break; } shadows.setLit(nx, ny); } sf::Vector2i FOV::getVisible(int x, int y, unsigned octant, sf::Vector2i origin) { int nx = origin.x, ny = origin.y; switch (octant) { case 0: nx += x; ny -= y; break; case 1: nx += y; ny -= x; break; case 2: nx -= y; ny -= x; break; case 3: nx -= x; ny -= y; break; case 4: nx -= x; ny += y; break; case 5: nx -= y; ny += x; break; case 6: nx += y; ny += x; break; case 7: nx += x; ny += y; break; } return sf::Vector2i(nx, ny); } int FOV::getDistance(int x, int y) { if (x == 0) return y; if (y == 0) return x; return (int) sqrt(x*x + y*y); } }
[ "adanos020@gmail.com" ]
adanos020@gmail.com
226bab750279cf8b67e1aef76c5b777b8b95af71
b83757fb213da49030437066d4f48210c6dfd250
/TestC11/stdafx.cpp
69851ab21064acfd6b6321aebbda40e6c8b7bfcd
[]
no_license
SpaceyII/C11
3140fb2a9ecf6f1698f6af0df89829082556d24b
0614c21f9044ffdc9492fba4bcedbd5d70ee630e
refs/heads/master
2021-09-22T15:01:36.817713
2018-09-11T08:06:14
2018-09-11T08:06:14
116,130,114
2
0
null
null
null
null
UTF-8
C++
false
false
286
cpp
// stdafx.cpp : source file that includes just the standard includes // TestC11.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "windexale@163.com" ]
windexale@163.com
7890e461baa40b90473655460d92e65c691b922b
7fea47e6aee75e90e39c09020bb66ae3d18355d0
/leetcode/leetcode_cpp/cracking-the-safe.cpp
eb41accf34d24dc2316b6578430d9dda54a2c442
[]
no_license
doum1004/code_assessment
52facd8b361702ef7d342896921ec328eb80ad4a
4b930bb9596adc5153e897a7f95625e78aebcd8a
refs/heads/master
2020-12-04T20:06:04.993844
2020-08-19T00:23:56
2020-08-19T00:23:56
231,888,307
0
1
null
null
null
null
UTF-8
C++
false
false
1,310
cpp
#include <iostream> #include <cassert> #include <unordered_set> using namespace std; /** https://leetcode.com/problems/cracking-the-safe/ Solution1. De Bruijn Sequence. (crack the combination lock) find all combination contained answer. ex) n=2, k=2. passowrd could be(k:0,1) 00,01,10,11 one soultion would be: 00110 [0]:0 -> no operation [1]:0 -> 00 [2]:1 -> 01 [3]:1 -> 11 [4]:0 -> 10 https://www.youtube.com/watch?v=iPLQgXUiU14 https://leetcode.com/problems/cracking-the-safe/discuss/381122/Can-someone-explain-the-damn-question-please time: o(k*k^n): space: o(k*k^n): dfs */ class Solution { public: bool dfs(int n, int k, int maxSize, unordered_set<string>& v, string& res) { if (v.size() == maxSize) return true; for (int i=0; i<k; ++i) { res += '0' + i; string pwd = res.substr(res.length()-n); if (!v.count(pwd)) { v.insert(pwd); if (dfs(n,k,maxSize,v,res)) return true; v.erase(pwd); } res.pop_back(); } return false; } string crackSafe(int n, int k) { string res = string(n, '0'); unordered_set<string> v; v.insert(res); dfs(n,k,pow(k,n),v,res); return res; } }; int main() { return 0; }
[ "doum1004@gmail.com" ]
doum1004@gmail.com
e5ddeada93561045682b3c3f361f26c61a450bb3
e016b0b04a6db80b0218a4f095e6aa4ea6fcd01c
/Classes/Native/Mapbox_Json_Mapbox_Json_Utilities_JavaScriptUtils568922234.h
efca6e0aed0f335bf144009f17c242247fbb599d
[ "MIT" ]
permissive
rockarts/MountainTopo3D
5a39905c66da87db42f1d94afa0ec20576ea68de
2994b28dabb4e4f61189274a030b0710075306ea
refs/heads/master
2021-01-13T06:03:01.054404
2017-06-22T01:12:52
2017-06-22T01:12:52
95,056,244
1
1
null
null
null
null
UTF-8
C++
false
false
2,913
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "mscorlib_System_Object2689449295.h" // System.Boolean[] struct BooleanU5BU5D_t3568034315; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // Mapbox.Json.Utilities.JavaScriptUtils struct JavaScriptUtils_t568922234 : public Il2CppObject { public: public: }; struct JavaScriptUtils_t568922234_StaticFields { public: // System.Boolean[] Mapbox.Json.Utilities.JavaScriptUtils::SingleQuoteCharEscapeFlags BooleanU5BU5D_t3568034315* ___SingleQuoteCharEscapeFlags_0; // System.Boolean[] Mapbox.Json.Utilities.JavaScriptUtils::DoubleQuoteCharEscapeFlags BooleanU5BU5D_t3568034315* ___DoubleQuoteCharEscapeFlags_1; // System.Boolean[] Mapbox.Json.Utilities.JavaScriptUtils::HtmlCharEscapeFlags BooleanU5BU5D_t3568034315* ___HtmlCharEscapeFlags_2; public: inline static int32_t get_offset_of_SingleQuoteCharEscapeFlags_0() { return static_cast<int32_t>(offsetof(JavaScriptUtils_t568922234_StaticFields, ___SingleQuoteCharEscapeFlags_0)); } inline BooleanU5BU5D_t3568034315* get_SingleQuoteCharEscapeFlags_0() const { return ___SingleQuoteCharEscapeFlags_0; } inline BooleanU5BU5D_t3568034315** get_address_of_SingleQuoteCharEscapeFlags_0() { return &___SingleQuoteCharEscapeFlags_0; } inline void set_SingleQuoteCharEscapeFlags_0(BooleanU5BU5D_t3568034315* value) { ___SingleQuoteCharEscapeFlags_0 = value; Il2CppCodeGenWriteBarrier(&___SingleQuoteCharEscapeFlags_0, value); } inline static int32_t get_offset_of_DoubleQuoteCharEscapeFlags_1() { return static_cast<int32_t>(offsetof(JavaScriptUtils_t568922234_StaticFields, ___DoubleQuoteCharEscapeFlags_1)); } inline BooleanU5BU5D_t3568034315* get_DoubleQuoteCharEscapeFlags_1() const { return ___DoubleQuoteCharEscapeFlags_1; } inline BooleanU5BU5D_t3568034315** get_address_of_DoubleQuoteCharEscapeFlags_1() { return &___DoubleQuoteCharEscapeFlags_1; } inline void set_DoubleQuoteCharEscapeFlags_1(BooleanU5BU5D_t3568034315* value) { ___DoubleQuoteCharEscapeFlags_1 = value; Il2CppCodeGenWriteBarrier(&___DoubleQuoteCharEscapeFlags_1, value); } inline static int32_t get_offset_of_HtmlCharEscapeFlags_2() { return static_cast<int32_t>(offsetof(JavaScriptUtils_t568922234_StaticFields, ___HtmlCharEscapeFlags_2)); } inline BooleanU5BU5D_t3568034315* get_HtmlCharEscapeFlags_2() const { return ___HtmlCharEscapeFlags_2; } inline BooleanU5BU5D_t3568034315** get_address_of_HtmlCharEscapeFlags_2() { return &___HtmlCharEscapeFlags_2; } inline void set_HtmlCharEscapeFlags_2(BooleanU5BU5D_t3568034315* value) { ___HtmlCharEscapeFlags_2 = value; Il2CppCodeGenWriteBarrier(&___HtmlCharEscapeFlags_2, value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "stevenrockarts@gmail.com" ]
stevenrockarts@gmail.com
4e581e33499dfeac0ea33532b7f30158eb358e6b
b09ec202745ae816e39ff14b86ff9eb8417c0bc3
/BatPlane.cpp
3a0785b56ba1aa5409397b00ee27fb4104a5dcc4
[]
no_license
iwannabespace/Space-Shooter
abc471c42fe03ac5799c80e82e6c494084a36d1e
fe29377b828fb28471b118873e4c75e621f5f67e
refs/heads/main
2023-06-12T23:23:01.741853
2021-07-08T12:44:22
2021-07-08T12:44:22
384,120,563
0
0
null
null
null
null
UTF-8
C++
false
false
2,622
cpp
#include "BatPlane.hpp" BatPlane::BatPlane(int win_width, int win_height) : win_width(win_width), win_height(win_height), pos(0), is_alive(true) { for (int i = 0; i < 4; i++) textures_of_plane[i].loadFromFile(std::string("resimler/uzay/yarasaucak/" + std::to_string(i + 1) + ".png")); texture_of_bullet.loadFromFile(std::string("resimler/uzay/bullet_red.png")); sprite_of_plane.setScale({ 0.1f, 0.1f }); sprite_of_plane.setPosition({ static_cast<float>(std::rand() % (this->win_width - 50)) + 50.f, 10.f }); sprite_of_plane.rotate(180); sprite_of_bullet.setTexture(texture_of_bullet); sprite_of_bullet.setScale({ 0.5f, 0.5f }); sprite_of_bullet.setPosition({ sprite_of_plane.getPosition().x + 10.f, sprite_of_plane.getPosition().y + 45.f }); sprite_of_bullet.rotate(180); } BatPlane::~BatPlane() { } void BatPlane::reset() { sprite_of_plane.setPosition({ static_cast<float>(std::rand() % (this->win_width - 50)) + 50.f, 10.f }); sprite_of_bullet.setPosition({ sprite_of_plane.getPosition().x + 10.f, sprite_of_plane.getPosition().y + 45.f }); is_alive = true; } void BatPlane::setAlive(bool is_alive) { this->is_alive = is_alive; } void BatPlane::update(Pilot& pilot) { if (timer_clock.getElapsedTime().asSeconds() > 0.3f) { sprite_of_plane.setTexture(textures_of_plane[pos++]); timer_clock.restart(); if (pos == 4) pos = 0; } //if (timer_for_shooting.getElapsedTime().asSeconds() > 5.f) //{ if (sprite_of_bullet.getPosition().y > win_height + sprite_of_bullet.getGlobalBounds().height) { sprite_of_bullet.setPosition({ sprite_of_plane.getPosition().x + 10.f, sprite_of_plane.getPosition().y + 45.f }); timer_for_shooting.restart(); } //} if (sprite_of_bullet.getGlobalBounds().contains(pilot.getSprite().getPosition())) { pilot.setAlive(false); sprite_of_bullet.setPosition({ sprite_of_plane.getPosition().x + 10.f, sprite_of_plane.getPosition().y + 45.f }); } if (pilot.getAlive()) { sprite_of_plane.move({ 0.f, 0.4f }); sprite_of_bullet.move({ 0.f, 1.f }); } } void BatPlane::draw(sf::RenderWindow& window, const Pilot& pilot) const { if (is_alive) { window.draw(sprite_of_plane); window.draw(sprite_of_bullet); } } sf::Sprite BatPlane::getSprite() const { return sprite_of_plane; } bool BatPlane::getAlive() const { return is_alive; }
[ "thertu58@gmail.com" ]
thertu58@gmail.com
4a8e59d2ab93ff6b42acab50c0dba5a8f1939214
ba37f5ccb316cbacfe24aa68d3e680947370ffbd
/src/fileInput/gridParameter.h
c8f5a5b384a539def7d862b0d351448a5b9ce829
[ "BSD-3-Clause" ]
permissive
nightlark/GridDyn
e6fe9ab0251b10d86f269b8951ab1e1dd8b56508
bfcef303c85c5b66bc26e5d16e4df0a07977e594
refs/heads/helics_updates
2021-01-24T06:12:32.115450
2019-07-19T18:12:34
2019-07-19T18:12:34
202,812,824
0
0
NOASSERTION
2019-08-17T00:22:00
2019-08-16T23:43:07
C++
UTF-8
C++
false
false
2,168
h
/* * LLNS Copyright Start * Copyright (c) 2014-2018, Lawrence Livermore National Security * This work was performed under the auspices of the U.S. Department * of Energy by Lawrence Livermore National Laboratory in part under * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344. * Produced at the Lawrence Livermore National Laboratory. * All rights reserved. * For details, see the LICENSE file. * LLNS Copyright End */ #ifndef GRIDPARAMETER_H_ #define GRIDPARAMETER_H_ #include "utilities/units.h" #include <string> #include <vector> namespace griddyn { /** @brief helper class for representing a parameter of various types * @details data class to extract some parameter information from a string */ class gridParameter { public: std::string field; //!< the field of the parameter std::string strVal; //!< a string value of the parameter std::vector<int> applyIndex; //!< a vector of indices the parameter should be applied to double value = 0.0; //!< the numerical value of the parameter gridUnits::units_t paramUnits = gridUnits::defUnit; //!< the units used for the parameter bool valid = false; //!< indicator if the parameter is valid bool stringType = false; //!< indicator that the parameter is using the string property /** @brief constructor*/ gridParameter (); /** @brief alternate constructor @param[in] str call the from string constructor */ explicit gridParameter (const std::string &str); /** @brief alternate constructor @param[in] fld the field of the parameter @param[in] val the value of the parameter */ gridParameter (std::string fld, double val); /** @brief alternate constructor @param[in] fld the field of the parameter @param[in] val the string value of the parameter */ gridParameter (std::string fld, std::string val); /** @brief reset the parameter*/ void reset (); /** @brief load a gridParameter from a string* @param[in] str the string to load from @throw invalidParameterValue on failure */ void fromString (const std::string &str); }; } // namespace griddyn #endif
[ "top1@llnl.gov" ]
top1@llnl.gov
ab125442dab04fd87e8bdbbe65de8a69ebc77d9a
64ee327698d006227347b558a971c75623e39be1
/Micha/Aufgabe_1_3/testRN.cpp
c6bae5f8d3e83bf065020a35a0164f0c75eb821f
[]
no_license
Hasenkrug/CPlusPlus
f8da44c3ce4ca9804abee393ea10655663e62457
77c73df40c84872cd7d7f0252fc88a905618d61f
refs/heads/master
2021-01-19T04:43:37.924306
2013-07-08T15:53:17
2013-07-08T15:53:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,471
cpp
/* Simple Tests for type RationalNumberCollection */ #include "rationalnumbercollection.h" #include "stdio.h" #include "assert.h" #include "iostream" int main() { printf("Performing tests for RationalNumberCollection...\n"); RationalNumberCollection* c = rncCreate(3); RationalNumber n1 = {-3, 4}; RationalNumber n2 = {1, 2}; RationalNumber n3 = {-1, 3}; RationalNumber n4 = {1, -3}; RationalNumber n5 = {1, 5}; RationalNumber n6 = {1, 6}; RationalNumber n7 = {1, 7}; RationalNumber n8 = {1, 8}; RationalNumber n9 = {-7, 1}; RationalNumber n10 = {7, 2}; RationalNumber n11 = {7, -3}; RationalNumber n12 = {7, 4}; c = rncAdd(c,n3); c = rncAdd(c,n3); c = rncAdd(c,n1); c = rncAdd(c,n4); c = rncAdd(c,n5); c = rncAdd(c,n6); c = rncAdd(c,n7); c = rncAdd(c,n8); c = rncAdd(c,n9); c = rncAdd(c,n10); c = rncAdd(c,n11); c = rncAdd(c,n12); c = rncRemove(c,n1); c = rncRemove(c,n2); c = rncRemove(c,n3); c = rncRemove(c,n4); c = rncRemove(c,n5); c = rncRemove(c,n6); c = rncRemove(c,n7); c = rncRemove(c,n8); c = rncRemove(c,n9); c = rncRemove(c,n10); c = rncRemove(c,n11); c = rncRemove(c,n12); rncDelete(c); std::cout <<""<< std::endl; printf("successful!\n"); std::cout <<""<< std::endl; std::cout <<"(._.) (|:) (.-.) (:|) (._.)"<< std::endl; std::cout <<""<< std::endl; return 0; }
[ "togomade@gmail.com" ]
togomade@gmail.com
aabc5f770ddd798f4c065a4c90bd90d79b0936ee
8f6c90ccdc665902a8685c0721596b3016005b81
/dia/codeCPP_repartiteurs/DnBoutonsRadio.h
d107a613d21427574cc135d308bccd612c316d60
[]
no_license
c-pages/gui
680636880049f97e98ee2f06d9129b445f33f72f
bcc06972ba3cdaa631702c9c1c73ad15fa2952a3
refs/heads/master
2021-01-10T12:55:58.224743
2016-04-20T14:43:45
2016-04-20T14:43:45
47,876,401
0
0
null
null
null
null
ISO-8859-1
C++
false
false
999
h
#ifndef DNBOUTONSRADIO__H #define DNBOUTONSRADIO__H ///////////////////////////////////////////////// // Headers ///////////////////////////////////////////////// #include "Donnee.h" #include <vector> #include <memory> #include "ElementMenu.h" namespace gui { class ElementMenu; class DnBoutonsRadio : public gui::Donnee { ///////////////////////////////////////////////// // Méthodes ///////////////////////////////////////////////// public: public: ///////////////////////////////////////////////// /// \brief Constructeur par défaut. /// ///////////////////////////////////////////////// DnBoutonsRadio (); virtual void draw (sf::RenderTarget& target, sf::RenderStates states) const; ///////////////////////////////////////////////// // Membres ///////////////////////////////////////////////// public: std::vector < ElementMenu > m_elements; std::shared_ptr<gui::ElementMenu> ; }; // fin class DnBoutonsRadio } // fin namespace gui #endif
[ "kristoffe@free.fr" ]
kristoffe@free.fr
460732ad293112d5a3e2921fcbf493c3e21fe1cf
9280fea108f5b3912629de7851f6bbbde561c9a4
/src/planning/trajectory_smoother/test/test_trajectory_smoother.cpp
c87b9d8b5721cf5b1be0aae8df2acb96bd368d66
[ "MIT", "Apache-2.0" ]
permissive
bytetok/vde
93071992618b7c539cd618eaae24d65f1099295b
ff8950abbb72366ed3072de790c405de8875ecc3
refs/heads/main
2023-08-23T15:08:14.644017
2021-10-09T03:59:09
2021-10-09T03:59:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,541
cpp
// Copyright 2020-2021 The Autoware Foundation // // 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 <motion_testing/motion_testing.hpp> #include <cmath> #include "gtest/gtest.h" #include "trajectory_smoother/trajectory_smoother.hpp" #define DT_MS 100 using motion::motion_testing::constant_velocity_trajectory; using motion::motion_testing::constant_acceleration_trajectory; using Trajectory = autoware_auto_msgs::msg::Trajectory; using TrajectorySmoother = motion::planning::trajectory_smoother::TrajectorySmoother; using TrajectorySmootherConfig = motion::planning::trajectory_smoother::TrajectorySmootherConfig; // Introduce random noise in the velocity values. void introduce_noise(Trajectory * trajectory, float range) { std::mt19937 gen(0); std::normal_distribution<float> dis(0, range / 5); for (auto & point : trajectory->points) { point.longitudinal_velocity_mps += dis(gen); } } void dbg_print_traj(const Trajectory & trajectory) { ASSERT_GE(trajectory.points.size(), 3U); const float dt = static_cast<float>(DT_MS) / 1000; float v0 = (trajectory.points.cbegin() + 1)->longitudinal_velocity_mps; float a0 = (v0 - trajectory.points.cbegin()->longitudinal_velocity_mps) / dt; std::cerr << trajectory.points.front().longitudinal_velocity_mps << ", 0, 0" << std::endl; std::cerr << v0 << ", " << a0 << ", 0" << std::endl; for (auto it = trajectory.points.cbegin() + 2; it != trajectory.points.cend(); it++) { float v1 = it->longitudinal_velocity_mps; float a1 = (v1 - v0) / dt; float jerk = (a1 - a0) / dt; v0 = v1; a0 = a1; std::cerr << v1 << ", " << a1 << ", " << jerk << std::endl; } } /// \brief Assert that a trajectory stays inside given limits in terms of acceleration and jerk. /// \param[in] trajectory The trajectory /// \param[in] max_acc Absolute value of the maximum allowed acceleration, [m/s^2] /// \param[in] max_jerk Absolute value of the maximum allowed jerk: the derivative of the /// acceleration, [m/s^3] void assert_trajectory(const Trajectory & trajectory, float max_acc, float max_jerk) { ASSERT_GE(max_acc, 0.0F); ASSERT_GE(max_jerk, 0.0F); ASSERT_GE(trajectory.points.size(), 3U); const float dt = static_cast<float>(DT_MS) / 1000; float v0 = (trajectory.points.cbegin() + 1)->longitudinal_velocity_mps; float a0 = (v0 - trajectory.points.cbegin()->longitudinal_velocity_mps) / dt; for (auto it = trajectory.points.cbegin() + 2; it != trajectory.points.cend(); it++) { float v1 = it->longitudinal_velocity_mps; float a1 = (v1 - v0) / dt; EXPECT_LE(std::abs(a1), max_acc); float jerk = (a1 - a0) / dt; // Ignore the first jerk value. // The trajectory smoother keeps the velocity value of the first trajectory point, which creates // an outstanding value here. if (it != trajectory.points.cbegin() + 2) { EXPECT_LE(std::abs(jerk), max_jerk); } v0 = v1; a0 = a1; } } /// \brief Assert that a trajectory stays inside some limits in terms of acceleration and jerk. /// The trajectory is expected to come to a stop in a given amount of time. This function computes /// theoretical maximum values before asserting that the trajectory respects them. /// \param[in] trajectory The trajectory /// \param[in] velocity The velocity of the vehicle when the vehicle starts braking, [m/s] /// \param[in] stop_time The time given for the vehicle to come to a stop, [s] void assert_trajectory_stop(const Trajectory & trajectory, float velocity, float stop_time) { ASSERT_GE(velocity, 0.0F); ASSERT_GT(stop_time, 0.0F); // Theoretical lower bound of the maximum acceleration and jerk, based on a step-function jerk // with value -max_jerk from 0 to stop_time/2 and max_jerk from stop_time/2 to stop_time. The // actual acceleration and jerk will be higher, but should be somewhat proportional to those // values. const float lower_bound_max_acc = velocity / stop_time; const float lower_bound_max_jerk = 4 * velocity / (stop_time * stop_time); // The safety factor is a magic number tying the lower bound to an acceptable upper bound. const float safety_factor = 2.5; const float max_acc = safety_factor * lower_bound_max_acc; const float max_jerk = safety_factor * lower_bound_max_jerk; assert_trajectory(trajectory, max_acc, max_jerk); } // Constant speed of 10mps. Last velocity point at 0mps. TEST(TrajectorySmoother, Constant) { const std::chrono::milliseconds dt(DT_MS); auto trajectory = constant_velocity_trajectory( 0, 0, 1, 10, std::chrono::duration_cast<std::chrono::nanoseconds>(dt)); trajectory.points.resize(100); // Zero out last point trajectory.points.back().longitudinal_velocity_mps = 0.0F; // Generate TrajectorySmoother const uint32_t kernel_size = 25; const TrajectorySmootherConfig config{5.0, kernel_size}; TrajectorySmoother smoother(config); // Send through smoother smoother.Filter(trajectory); assert_trajectory_stop(trajectory, 10, static_cast<float>(kernel_size) * DT_MS / 1000); } // Constant speed of 10mps. Random noise added. Last velocity point at 0mps. TEST(TrajectorySmoother, ConstantWithNoise) { const std::chrono::milliseconds dt(DT_MS); auto trajectory = constant_velocity_trajectory( 0, 0, 1, 10, std::chrono::duration_cast<std::chrono::nanoseconds>(dt)); trajectory.points.resize(100); introduce_noise(&trajectory, 10); // Zero out last point trajectory.points.back().longitudinal_velocity_mps = 0.0F; // Generate TrajectorySmoother const uint32_t kernel_size = 25; const TrajectorySmootherConfig config{5.0, kernel_size}; TrajectorySmoother smoother(config); // Send through smoother smoother.Filter(trajectory); assert_trajectory_stop(trajectory, 10, static_cast<float>(kernel_size) * DT_MS / 1000); } // Constant acceleration, from 10mps to 20mps. Last velocity point at 0mps. TEST(TrajectorySmoother, Acceleration) { const std::chrono::milliseconds dt(DT_MS); auto trajectory = constant_acceleration_trajectory( 0, 0, 1, 10, 1, std::chrono::duration_cast<std::chrono::nanoseconds>(dt)); trajectory.points.resize(100); // Zero out last point trajectory.points.back().longitudinal_velocity_mps = 0.0F; // Generate TrajectorySmoother const uint32_t kernel_size = 25; const TrajectorySmootherConfig config{5.0, kernel_size}; TrajectorySmoother smoother(config); // Send through smoother smoother.Filter(trajectory); assert_trajectory_stop(trajectory, 20, static_cast<float>(kernel_size) * DT_MS / 1000); } // Constant acceleration, from 10mps to 20mps in 3.3s. Followed by a constant deceleration to 0mps // in 6.7s. TEST(TrajectorySmoother, AccelerationDeceleration) { constexpr float T = 10; // Total time of the trajectory, [s] constexpr float v0 = 10; // Initial velocity, [m/s] constexpr float a = 3; // Absolute value of both the acceleration and deceleration, [m/s^2] constexpr float ratio = 0.5 - v0 / (2 * T * a); static_assert(ratio > 0 && ratio < 1, "ratio outside of (0, 1) range"); const int points = T * (1000 / DT_MS); const int p0 = static_cast<int>(std::round(points * ratio)); const std::chrono::milliseconds dt(DT_MS); auto trajectory = constant_acceleration_trajectory( 0, 0, 1, 10, 3, std::chrono::duration_cast<std::chrono::nanoseconds>(dt)); trajectory.points.resize(p0); auto trajectory_decel = constant_acceleration_trajectory( 0, 0, 1, 20, -3, std::chrono::duration_cast<std::chrono::nanoseconds>(dt)); trajectory_decel.points.resize(points - p0); for (auto & point : trajectory_decel.points) { trajectory.points.push_back(point); } // Zero out last point trajectory.points.back().longitudinal_velocity_mps = 0.0F; // Generate TrajectorySmoother const uint32_t kernel_size = 25; const TrajectorySmootherConfig config{5.0, kernel_size}; TrajectorySmoother smoother(config); // Send through smoother smoother.Filter(trajectory); // The stopping part of this test is expected to have a slightly larger magnitude than the change // in acceleration, hence the use of assert_trajectory_stop. assert_trajectory_stop(trajectory, 7, static_cast<float>(kernel_size) * DT_MS / 1000); } // Constant deceleration, from 10mps to 0mps in 3.3s. Then stay at 0mps over the remaining 6.7s. TEST(TrajectorySmoother, DecelerationHalt) { const std::chrono::milliseconds dt(DT_MS); auto trajectory = constant_acceleration_trajectory( 0, 0, 1, 10, -3, std::chrono::duration_cast<std::chrono::nanoseconds>(dt)); trajectory.points.resize(100); for (auto & point : trajectory.points) { if (point.longitudinal_velocity_mps < 0) { point.longitudinal_velocity_mps = 0; } } // Generate TrajectorySmoother const uint32_t kernel_size = 25; const TrajectorySmootherConfig config{5.0, kernel_size}; TrajectorySmoother smoother(config); // Send through smoother smoother.Filter(trajectory); // Constants based on Gaussian filter's performance assert_trajectory(trajectory, 4, 3); }
[ "Will.Heitman@utdallas.edu" ]
Will.Heitman@utdallas.edu
62fe7c6c13e8d16533c3c78ce70314be92648d25
ecd31224adaaaec37a523ed43c551678e649ec11
/max-points-on-a-line(AC).cpp
e88a18132ecd4ab0c7090bf237d6f73bc731757f
[]
no_license
lovesunnybaby/lintcode
30f39cf7152189a1403e827f1fd5455fbe0312ba
27aff2ec6343617f49ee74f6796e4692213233e1
refs/heads/master
2020-12-28T21:05:13.053034
2019-04-26T08:41:18
2019-04-26T08:41:18
39,825,341
0
0
null
2015-07-28T09:37:18
2015-07-28T09:37:17
null
UTF-8
C++
false
false
2,062
cpp
#include <algorithm> #include <map> using namespace std; /** * Definition for a point. * struct Point { * int x; * int y; * Point() : x(0), y(0) {} * Point(int a, int b) : x(a), y(b) {} * }; */ typedef struct Term { Term(int x = 0, int y = 0) { this->x = x; this->y = y; } int x, y; bool operator < (const Term &other) const { if (x != other.x) { return x < other.x; } else { return y < other.y; } } bool operator == (const Term &other) const { return x == other.x && y == other.y; } } Term; int gcd(int x, int y) { return x ? gcd(y % x, x) : y; } int abs(int x) { return x >= 0 ? x : -x; } void normalize(Term &t) { if (t.x == 0) { t.y = t.y ? 1 : 0; return; } if (t.y == 0) { t.x = t.x ? 1 : 0; return; } if (t.x < 0) { t.x = -t.x; t.y = -t.y; } int g = gcd(t.x, abs(t.y)); t.x /= g; t.y /= g; } class Solution { public: /** * @param points an array of point * @return an integer */ int maxPoints(vector<Point>& points) { int n = points.size(); if (n < 3) { return n; } map<Term, int> mm; map<Term, int>::iterator it; Term t; int i, j; int zc; int msum = 2; int sum; for (i = 0; i < n; ++i) { for (j = i + 1; j < n; ++j) { t.x = points[j].x - points[i].x; t.y = points[j].y - points[i].y; normalize(t); ++mm[t]; } zc = mm[Term(0, 0)]; sum = 0; for (it = mm.begin(); it != mm.end(); ++it) { if (it->first == Term(0, 0)) { continue; } sum = max(sum, it->second); } msum = max(msum, sum + zc + 1); mm.clear(); } return msum; } };
[ "zhuli19901106@gmail.com" ]
zhuli19901106@gmail.com
314bf308a70ae88b2e0166d4cca13544a306d6a3
bc4f297919596f3af1b0af9b8c0433c4a0e7ca74
/A_String_Generation.cpp
dc992408bd4b43f5980743fcf2193ae5602ea515
[]
no_license
fahadkhaanz/Competitive-Programming
34d92ec73c0b4aba5a2a18c68f998a92a57dc57e
bc3d4206d6749055d67e7b291acd230a31a4e5bc
refs/heads/master
2023-08-02T05:26:03.594439
2021-09-26T08:44:15
2021-09-26T08:44:15
291,102,479
0
0
null
null
null
null
UTF-8
C++
false
false
2,516
cpp
//git pull --rebase origin master #include<bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i,n) for(int i=0;i<n;i++) #define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1) #define ll long long #define si(x) scanf("%d",&x) #define sl(x) scanf("%lld",&x) #define ss(s) scanf("%s",s) #define pi(x) printf("%d\n",x) #define pl(x) printf("%lld\n",x) #define ps(s) printf("%s\n",s) #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl #define pb push_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define sortall(x) sort(all(x)) #define tr(it, a) for(auto it = a.begin(); it != a.end(); it++) #define PI 3.1415926535897932384626 #define wi(t) int t;cin>>t;while(t--) typedef pair<int, int> pii; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; typedef vector<pl> vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count()); int rng(int lim) { uniform_int_distribution<int> uid(0,lim-1); return uid(rang); } int mpow(int base, int exp); void ipgraph(int n, int m); void dfs(int u, int par); const int mod = 1000000007; const int N = 3e5, M = N; //======================= vi adj[N]; vi vis(N); ll int gcd(ll int a, ll int b) { if (b == 0) return a; return gcd(b, a % b); } int tc=1; void solve() { int n; cin>>n; if(n==2) cout<<"1\n1\n0 1 0\n"; else if(n==3) { cout<<"3\n1\n2 0 1\n1\n1 2 2\n1\n0 1 0\n"; } else { cout<<"3\n2\n2 0 1\n2 0 4\n3\n0 1 5\n0 2 0\n3 4 2\n1\n1 2 3\n"; } } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); srand(chrono::high_resolution_clock::now().time_since_epoch().count()); // wi(t) { solve(); } return 0; } int mpow(int base, int exp) { base %= mod; int result = 1; while (exp > 0) { if (exp & 1) result = ((ll)result * base) % mod; base = ((ll)base * base) % mod; exp >>= 1; } return result; } void ipgraph(int n, int m){ int i, u, v; while(m--){ cin>>u>>v; u--, v--; adj[u].pb(v); adj[v].pb(u); } } void dfs(int u, int par){ for(int v:adj[u]){ if (v == par) continue; dfs(v, u); } }
[ "fk0881889@gmail.com" ]
fk0881889@gmail.com
19fe86392d5ad2025d6a9735ba72b88d68be8149
c4b0d7fdc745a4e7f486f98ba55b62c127f975e1
/sfmlGraphics/wip/partitioner.cpp
387596faa67e6d20726a4233d68fe77eca7f27fb
[]
no_license
manteapi/guiSandbox
96dfedc4b5babc26bfc6b90f9b1f2562c88dbdf3
7ff44bcad2d65d49d30ecbe940989e357d69b1db
refs/heads/master
2021-01-19T03:39:03.490832
2016-10-06T11:03:01
2016-10-06T11:03:14
60,194,570
0
0
null
null
null
null
UTF-8
C++
false
false
8,958
cpp
#ifndef PARTITIONER_CPP #define PARTITIONER_CPP #include "partitioner.inl" #include <array> Intersection::Intersection(){} Intersection::Intersection(const FacetHandle& meshFace, const int gridFace) : m_meshFace(meshFace), m_gridFace(gridFace) { } Intersection::~Intersection(){} SegmentIntersection::SegmentIntersection(){} SegmentIntersection::SegmentIntersection(const FacetHandle& meshFace, const int gridFace, const CGALSegment& segment) : Intersection(meshFace, gridFace), m_segment(segment) { } SegmentIntersection::~SegmentIntersection(){} PointIntersection::PointIntersection(){} PointIntersection::PointIntersection(const FacetHandle& meshFace, const int gridFace, const CGALPoint& point) : Intersection(meshFace, gridFace), m_point(point) { } PointIntersection::~PointIntersection(){} TriangleIntersection::TriangleIntersection(){} TriangleIntersection::TriangleIntersection(const FacetHandle& meshFace, const int gridFace, const CGALTriangle& triangle) : Intersection(meshFace, gridFace), m_triangle(triangle) { } TriangleIntersection::~TriangleIntersection(){} std::set<unsigned int> getCellsOverTriangle(const GridUtility& grid, const std::array<Vec3r,3>& t) { std::set<unsigned int> result; //Step 1: Get bounding box Vec3r minBB(std::numeric_limits<float>::max()), maxBB(-std::numeric_limits<float>::max()); for(size_t i=0; i<3; ++i) for(size_t j=0; j<3; ++j) {minBB[j] = std::min(minBB[j], t[i][j]); maxBB[j] = std::max(maxBB[j], t[i][j]);} Vec3i gMinBB = grid.worldToGrid(minBB), gMaxBB = grid.worldToGrid(maxBB); //Step 2: For each cell in the bounding box for(size_t i=gMinBB[0]; i<=gMaxBB[0]; ++i) { for(size_t j=gMinBB[1]; j<=gMaxBB[1]; ++j) { for(size_t k=gMinBB[2]; k<=gMaxBB[2]; ++k) { int cellId = grid.cellId(i,j,k); std::array<Vec3r,8> cellVertices = grid.cellVertices(cellId); //Check if one of the triangle's vertex is inside the cell bool isInside = true; for(size_t l=0; l<3; ++l) { std::array<float,8> triWeights = trilinearWeights(cellVertices, t[l]); for(const float& weight : triWeights) isInside = isInside && (weight>=0 && weight<=1.0); if(isInside) { result.insert(cellId); break; } } //Check if the triangle intersects the cell std::array<std::array<Vec3r,4>,6> cubeFaces = grid.cellFaces(cellId); if(!isInside) { for(size_t l=0; l<6; ++l) { bool hasIntersected = trianglePlaneIntersection(cubeFaces[l], t); if(hasIntersected) { result.insert(cellId); break;} } } } } } return result; } std::array<float,8> trilinearWeights(const std::array<Vec3r,8>& cellVertices, const Vec3r& x) { std::array<float,8> weights; const Vec3r& minBB = cellVertices[0]; const Vec3r& maxBB = cellVertices[6]; Vec3r n; //Normalized n[0] = (x[0]-minBB[0])/(maxBB[0]-minBB[0]); n[1] = (x[1]-minBB[1])/(maxBB[1]-minBB[1]); n[2] = (x[2]-minBB[2])/(maxBB[2]-minBB[2]); weights[0] = (1-n[0])*(1-n[1])*(1-n[2]); weights[1] = n[0]*(1-n[1])*(1-n[2]); weights[2] = n[0]*n[1]*(1-n[2]); weights[3] = (1-n[0])*n[1]*(1-n[2]); weights[4] = (1-n[0])*(1-n[1])*n[2]; weights[5] = n[0]*(1-n[1])*n[2]; weights[6] = n[0]*n[1]*n[2]; weights[7] = (1-n[0])*n[1]*n[2]; return weights; } void floodfill(const FacetHandleList& triangles, std::vector<FacetHandleSet>& trianglesSets) { std::set<FacetHandle> visited; for(const FacetHandle& f : triangles) { if(visited.find(f)==visited.end()) { std::set<FacetHandle> component; std::vector<FacetHandle> tovisit; tovisit.push_back(f); while(!tovisit.empty()) { const FacetHandle & candidate = tovisit.back(); tovisit.pop_back(); component.insert(candidate); visited.insert(candidate); Polyhedron::Halfedge_around_facet_circulator eBegin = candidate->facet_begin(), eit=eBegin; do { if(!eit->opposite()->is_border()) { FacetHandle n = eit->opposite()->facet(); bool isInsideCell = std::find(triangles.begin(), triangles.end(), n)!=triangles.end(); bool isVisited = visited.find(n) != visited.end(); if(isInsideCell && !isVisited) { tovisit.push_back(n); } } } while(++eit != eBegin); } trianglesSets.push_back(component); } } } std::array<Vec3r,3> getTriangleFromFace(const FacetHandle& f) { int i = 0; std::array<Vec3r,3> triangle; Polyhedron::Halfedge_around_facet_const_circulator eBegin = f->facet_begin(), eit=eBegin; do{triangle[i] = Vec3r(eit->vertex()->point()[0], eit->vertex()->point()[1], eit->vertex()->point()[2]); ++i;} while(++eit != eBegin); return triangle; } bool triangleVoxelIntersection(const int voxelFaceId, const std::array<Vec3r,4>& voxelFaces, const FacetHandle & meshFace, std::set<IntersectionPtr>& intersections) { bool intersect = false; std::array<Vec3r,3> t = getTriangleFromFace(meshFace); CGALTriangle cgT( CGALPoint(t[0][0], t[0][1], t[0][2]), CGALPoint(t[1][0], t[1][1], t[1][2]), CGALPoint(t[2][0], t[2][1], t[2][2]) ); CGALTriangle cgP1( CGALPoint(voxelFaces[0][0], voxelFaces[0][1], voxelFaces[0][2]), CGALPoint(voxelFaces[1][0], voxelFaces[1][1], voxelFaces[1][2]), CGALPoint(voxelFaces[2][0], voxelFaces[2][1], voxelFaces[2][2]) ); CGALTriangle cgP2( CGALPoint(voxelFaces[0][0], voxelFaces[0][1], voxelFaces[0][2]), CGALPoint(voxelFaces[2][0], voxelFaces[2][1], voxelFaces[2][2]), CGALPoint(voxelFaces[3][0], voxelFaces[3][1], voxelFaces[3][2]) ); auto result1 = CGAL::intersection(cgT, cgP1); CGALTriangle iTriangle1; CGALPoint iPoint1; CGALSegment iSegment1; if(CGAL::assign(iTriangle1, result1)) { intersect = true; TriangleIntersectionPtr inter = std::make_shared<TriangleIntersection>(); intersections.insert(inter); } else if(CGAL::assign(iPoint1, result1)) { intersect = true; PointIntersectionPtr inter = std::make_shared<PointIntersection>(); intersections.insert(inter); } else if(CGAL::assign(iSegment1, result1)) { intersect = true; SegmentIntersectionPtr inter = std::make_shared<SegmentIntersection>(); intersections.insert(inter); } auto result2 = CGAL::intersection(cgT, cgP2); CGALTriangle iTriangle2; CGALPoint iPoint2; CGALSegment iSegment2; if(CGAL::assign(iTriangle2, result2)) { intersect = true; TriangleIntersectionPtr inter = std::make_shared<TriangleIntersection>(); intersections.insert(inter); } else if(CGAL::assign(iPoint2, result2)) { intersect = true; PointIntersectionPtr inter = std::make_shared<PointIntersection>(); intersections.insert(inter); } else if(CGAL::assign(iSegment2, result2)) { intersect = true; SegmentIntersectionPtr inter = std::make_shared<SegmentIntersection>(); intersections.insert(inter); } return intersect; } bool trianglePlaneIntersection(std::array<Vec3r, 4>& plane, const std::array<Vec3r,3>& t) { bool intersect = false; CGALTriangle cgT( CGALPoint(t[0][0], t[0][1], t[0][2]), CGALPoint(t[1][0], t[1][1], t[1][2]), CGALPoint(t[2][0], t[2][1], t[2][2]) ); CGALTriangle cgP1( CGALPoint(plane[0][0], plane[0][1], plane[0][2]), CGALPoint(plane[1][0], plane[1][1], plane[1][2]), CGALPoint(plane[2][0], plane[2][1], plane[2][2]) ); CGALTriangle cgP2( CGALPoint(plane[0][0], plane[0][1], plane[0][2]), CGALPoint(plane[2][0], plane[2][1], plane[2][2]), CGALPoint(plane[3][0], plane[3][1], plane[3][2]) ); auto result1 = CGAL::intersection(cgT, cgP1); CGALTriangle iTriangle1; CGALPoint iPoint1; CGALSegment iSegment1; if(CGAL::assign(iTriangle1, result1) || CGAL::assign(iPoint1, result1) || CGAL::assign(iSegment1, result1)) { intersect = true; } auto result2 = CGAL::intersection(cgT, cgP2); CGALTriangle iTriangle2; CGALPoint iPoint2; CGALSegment iSegment2; if(CGAL::assign(iTriangle2, result2) || CGAL::assign(iPoint2, result2) || CGAL::assign(iSegment2, result2)) { intersect = true; } return intersect; } #endif //PARTITIONER_CPP
[ "pierre-luc.manteaux@inria.fr" ]
pierre-luc.manteaux@inria.fr
729eeba1505245e5b7bad50c9d8c4931ce40e893
4b430686ae824c78604e15818c4b864778468ca1
/Library/Sources/Stroika/Foundation/IO/Network/Socket.h
82f9b55095006934bc9870901e57e868bdccca4a
[]
no_license
kjax/Stroika
59d559cbbcfb9fbd619155daaf39f6805fa79e02
3994269f67cd9029b9adf62e93ec0a3bfae60b5f
refs/heads/master
2021-01-17T23:05:33.441132
2012-07-22T04:32:58
2012-07-22T04:32:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,223
h
/* * Copyright(c) Sophist Solutions, Inc. 1990-2012. All rights reserved */ #ifndef _Stroika_Foundation_IO_Network_Socket_h_ #define _Stroika_Foundation_IO_Network_Socket_h_ 1 #include "../../StroikaPreComp.h" #if qPlatform_Windows #include <WinSock.h> #endif #include "../../Characters/String.h" #include "../../Configuration/Common.h" namespace Stroika { namespace Foundation { namespace IO { namespace Network { using Characters::String; // Platform Socket descriptor - file descriptor on unix (something like this on windoze) #if qPlatform_Windows typedef SOCKET NativeSocket; #else typedef int NativeSocket; #endif /* * TODO: * * o Maybe add IsClosed () method (or equiv is empty/isnull) - and if rep null OR rep non-null but underling rep is closed * reutrn true. Then define a bunch of requiresments here (liek wti BIND) in terms of that (must be CLOSED). * DONT BOTHER having DETEACHT method but docuemnt with clsoe can just say Socket s; s = Socket() to make s itself * be CLSOED without closing udnerling socket (if someone else has refernce to it). * * o Docuemnt (or define new expcetion) thrown when operaiton done on CLOSED socket. */ class Socket { protected: class _Rep; public: // Note - socket is CLOSED (filesystem close for now) in DTOR // TODO: // We will need an abstract Socket object, and maybe have it refernce counted so close can happen when last refernce goes // away! // Socket (); Socket (const Socket& s); // TODO: By default - when refcount goes to zero - this socket auto-closed. MAYBE offer overload where that is not so? explicit Socket (NativeSocket sd); protected: Socket (const shared_ptr<_Rep>& rep); public: ~Socket (); const Socket& operator= (const Socket& s); public: struct BindProperties { static const String kANYHOST; static const int kANYPORT = 0; static const int kDefaultListenBacklog = 100; String fHostName; int fPort; unsigned int fListenBacklog; unsigned int fExtraBindFlags; // eg. SO_REUSEADDR }; // throws if socket already bound or valid - only legal on empty socket nonvirtual void Bind (const BindProperties& bindProperties); nonvirtual Socket Accept (); // throws on error, and otherwise means should call accept nonvirtual void Listen (unsigned int backlog); public: nonvirtual size_t Read (Byte* intoStart, Byte* intoEnd); nonvirtual void Write (const Byte* start, const Byte* end); public: /* * Note that Socket is an envelope class, and there could be multiple references to * the same underlying socket. But this closes ALL of them. It also removes the reference * to the underlying rep (meaning that some Socket envelopes COULD have a rep with an underlying * closed socket). */ nonvirtual void Close (); public: // DOCUMENT WHAT THIS DOES WITH NO REP??? Or for SSL sockets - maybe lose this?? nonvirtual NativeSocket GetNativeSocket () const; private: shared_ptr<_Rep> fRep_; }; class Socket::_Rep { public: virtual ~_Rep (); virtual void Close () = 0; virtual size_t Read (Byte* intoStart, Byte* intoEnd) = 0; virtual void Write (const Byte* start, const Byte* end) = 0; virtual void Listen (unsigned int backlog) = 0; virtual Socket Accept () = 0; virtual NativeSocket GetNativeSocket () const = 0; }; } } } } #endif /*_Stroika_Foundation_IO_Network_Socket_h_*/ /* ******************************************************************************** ***************************** Implementation Details *************************** ******************************************************************************** */ #include "Socket.inl"
[ "lewis@RecordsForLiving.com" ]
lewis@RecordsForLiving.com
e37d741797ae098af29ff53fc5c069af3fb53f26
a4bf7ef197edc81b1d15ae9c75397aec22f14850
/zajecia/lukomski/labolatorium/informacje.cpp
ee26cbeb4f7588c1d395bf49e79c2fa6b1654cde
[]
no_license
anagorko/kinf
2c48b43525907a61b66cddd46be4405eac908518
38c44fb6905f45da95405aa72bd979eb90cf1058
refs/heads/master
2020-04-12T06:35:45.396095
2017-12-31T19:47:07
2017-12-31T19:47:07
7,894,789
5
12
null
2017-03-24T12:58:21
2013-01-29T15:23:15
C++
UTF-8
C++
false
false
200
cpp
#include<iostream> using namespace std; int main(){ int n,a; cin>>n>>a; int t[n]; for(int i=n-1;i>=0;i--){ cin>>t[i]; } for(int i=0;i<n;i++){ cout<<t[i]+a<<" "; } cout<<"\n"; return 0; }
[ "janek.lukomski98@gmail.com" ]
janek.lukomski98@gmail.com
5807d6bd96ee3f7fc69c4b3aef95295ad4340f62
b4346e1776582c087dbefd3ed8298e62f392db19
/main.cpp
76f07d3949b76a48afc691bfc678bd6cc65a7997
[]
no_license
HagarAhmed97/DataStructure-
24842ec171e931d263ef8bcc606b0c5af4d40ed6
2a6d35fc79ae3e9390434b9a91f1aaec6bb1db4d
refs/heads/master
2020-12-23T01:03:30.391827
2020-01-29T13:15:27
2020-01-29T13:15:27
236,984,875
0
0
null
null
null
null
UTF-8
C++
false
false
10,708
cpp
#include <iostream> #include<stdlib.h> using namespace std; int total_bank_work_time=0; class Client { public: static int count_client; int ID = count_client; int Arrival; int Transaction; int Waiting; int Finished; Client() { Waiting = 0; Finished = Arrival + Transaction+ Waiting; } int operator == (Client client) { if(this->ID == client.ID ) { return 1; } else return 0; } void operator =(Client &client) { this->ID=client.ID; this->Arrival=client.Arrival; this->Transaction=client.Transaction; this->Waiting=client.Waiting; } friend ostream & operator <<(ostream&out,Client&client); friend istream & operator >>(istream&in,Client &client); }; int Client::count_client=1; ostream & operator << (ostream&out,Client &client) { out<<"\t\t\t\t\t\tID :"<<client.ID<<endl; out<<"\t\t\t\t\t\tArrival Time :"<<client.Arrival<<endl; out<<"\t\t\t\t\t\tTransaction time :"<<client.Transaction<<endl; out<<"\t\t\t\t\t\tWait time :"<<client.Waiting<<endl; out<<"\t\t\t\t\t\tFinish time : "<<client.Finished<<endl; return out; } istream & operator >> (istream&in,Client &client) { cout<<"\t\t\t\t\t\tEnter Arrive time : "; in>>client.Arrival; cout<<"\t\t\t\t\t\tEnter Transaction time : "; in>>client.Transaction; client.ID=Client::count_client++; return in; } struct Node { Client client; Node * Next; Node * Prev; }; typedef struct Node Node; class Linked_List { public: Node *First,*Last; Linked_List() { First=Last=NULL; } Node *Create(Client client) { Node*node=new Node(); node->client=client; node->Prev=node->Next=NULL; return node; } void Add(Node *newNode) { if(First==NULL) { First=Last=newNode; } else { Last->Next=newNode; newNode->Prev=Last; Last=newNode; } } void Display() { Node *PDisplay=First; while(PDisplay!=NULL) { cout<<PDisplay->client; cout<<"\n"; PDisplay=PDisplay->Next; } } void SwapClients(Client & client,Client & client2) { Client temp; temp=client; client=client2; client2=temp; } void SortID() { Node * node=First; int counter_ID=1; while(node!=NULL) { node->client.ID=counter_ID; counter_ID++; node=node->Next; } } void selected_sort() { Node *index=First; char ch; Node *curent; Node *minindex; while(index!=NULL) { curent=index; minindex=index; while(curent!=NULL) { if(minindex->client.Arrival > curent->client.Arrival) { minindex=curent; } curent=curent->Next; } SwapClients(index->client,minindex->client); index=index->Next; } SortID(); } }; class Queue { public: struct Node* Front = NULL; struct Node* Rear = NULL; struct Node* temp; int counter=0; int Num_Served_Clients = 0; int Total_Waiting=0; int Total_Working=0; void Enqueue(Node *n) { //counter++; if(isempty()) { Front=Rear=n; } else { Rear->Next=n; Rear=n; } } int isempty() { return (Front==NULL); } void Dequeue() { temp = Front; if (Front == NULL) { cout<<"Underflow"<<endl; return; } else if (temp->Next != NULL) { temp = temp->Next; cout<<"Element deleted from queue is : "<<Front->client<<endl; free(Front); Front = temp; } else { cout<<"Element deleted from queue is : "<<Front->client<<endl; free(Front); Front = NULL; Rear = NULL; } } int Is_Finished(Node *n,int time) { n->client.Finished=n->client.Arrival+n->client.Transaction+n->client.Waiting; if(n->client.Finished<=time) { return 1; } else { return 0; } } //before enqueue int duration_Sum(int time) { if(isempty()) { return 0; } int sum=(Front->client.Arrival+ Front->client.Transaction + Front->client.Waiting ) - time; Node *p=Front->Next; while(p!=NULL) { sum+=p->client.Transaction; p=p->Next; } return sum; } void Display() { temp = Front; if ((Front == NULL) && (Rear == NULL)) { cout<<"Queue is empty"<<endl; return; } cout<<"Queue elements are: "; while (temp != NULL) { cout<<temp->client<<" "; temp = temp->Next; } cout<<endl; } void queue_clear(int time) { Node *nod; if(counter!=0) { int flage=0; nod=Front;// node *nod; while(nod!=NULL&&flage!=1) { flage=1; nod=Front; if(Is_Finished(nod,time)) { if(nod->client.Finished>=total_bank_work_time) { total_bank_work_time=nod->client.Finished; } flage=0; counter--; Dequeue(); } nod=nod->Next; } } } void Add_Node(Node *n) { n->client.Waiting=duration_Sum(n->client.Arrival); counter++; Num_Served_Clients++; Total_Waiting+=n->client.Waiting; Total_Working+=n->client.Transaction; n->Next=NULL; Enqueue(n); } void Report() { cout<<"\t\t\t\t\t\tTotal Client number :"<<Num_Served_Clients<<"\n"; cout<<"\t\t\t\t\t\tTotal Wait Time :"<<Total_Waiting<<"\n"; cout<<"\t\t\t\t\t\tTotal Work Time :"<<Total_Working<<"\n"; if(Num_Served_Clients>0) { cout<<"\t\t\t\t\t\tAverage Waiting : "<<(float)Total_Waiting/ (float)Num_Served_Clients<<endl; cout<<"\t\t\t\t\t\tAverage Working : "<<(float)Total_Working / (float)Num_Served_Clients<<endl; } } }; class Bank { public: Queue q1,q2,q3; int Bank_Wait_Time; int Bank_Work_Time; int Total_Num_Served_Clients; void Bank_Report() { cout<<"\n\t\t\t\t\t\tReport for Queue 1 \n\n"; q1.Report(); cout<<"\n\t\t\t\t\t\tReport for Queue 2 \n\n"; q2.Report(); cout<<"\n\t\t\t\t\t\tReport for Queue 3 \n\n"; q3.Report(); Total_Num_Served_Clients = q1.Num_Served_Clients + q2.Num_Served_Clients + q3.Num_Served_Clients; Bank_Wait_Time=max (max(q1.Total_Waiting,q2.Total_Waiting),q3.Total_Waiting); Bank_Work_Time=total_bank_work_time; cout<<"\n\t\t\t\t\t\t====Bank Report==== \n"; cout<<"\n\t\t\t\t\t\tBank Wait Time :"<<Bank_Wait_Time<<endl; cout<<"\t\t\t\t\t\tBank Work Time :"<<Bank_Work_Time<<endl; if(Total_Num_Served_Clients>0) { cout<<"\t\t\t\t\t\tBank Average Wait : "<< (float)Bank_Wait_Time /(float)Total_Num_Served_Clients<<endl; cout<<"\t\t\t\t\t\tBank Average work : "<< (float)Bank_Work_Time /(float)Total_Num_Served_Clients<<endl; } } }; int min_number(Queue q1,Queue q2,Queue q3) { int minimum_queue=min(min(q1.counter,q2.counter),q3.counter); if(q1.counter==minimum_queue) { return 1; } else if( q2.counter==minimum_queue) { return 2; } else { return 3; } } int main() { int choice; Linked_List List; int flag =1; Client client; Bank bank; int min_num; while(flag!=0) { cout<<"\t\t\t\t\t ================================\n"; cout<<"\t\t\t\t\t\t1.Enter new Client\n"; cout<<"\t\t\t\t\t\t2.Display Entered data List\n"; cout<<"\t\t\t\t\t\t3.End of day\n"; cout<<"\t\t\t\t\t ================================\n"; cout<<"\t\t\t\t\t\tEnter your choice : "; cin>>choice; switch (choice) { case 1: { cout<<"\t\t\t\t\t\tEnter client data \n"; cin>>client; Node * node=List.Create(client); List.Add(node); flag=1; break; } case 2: { system("cls"); List.Display(); flag=1; break; } case 3: { flag=0; break; } } } List.selected_sort(); Node * n1=List.First; Node *second; while(n1!=NULL) { second=n1->Next; bank.q1.queue_clear(n1->client.Arrival); bank.q2.queue_clear(n1->client.Arrival); bank.q3.queue_clear(n1->client.Arrival); min_num=min_number(bank.q1,bank.q2,bank.q3); if(min_num==1) { bank.q1.Add_Node(n1); cout<<"Queue 1\n"; } else if(min_num==2) { bank.q2.Add_Node(n1); cout<<"Queue 2\n"; } else { bank.q3.Add_Node(n1); cout<<"Queue 3\n"; } n1=second; } int totalbanktime=100; bank.q1.queue_clear(totalbanktime); bank.q2.queue_clear(totalbanktime); bank.q3.queue_clear(totalbanktime); cout<<"End of ADD \n"; cout<<"\t\t\t\t\t\tQueue 1 elements\n\n"; bank.q1.Display(); cout<<"\t\t\t\t\t\tQueue 2 elements\n\n"; bank.q2.Display(); cout<<"\t\t\t\t\t\tQueue 3 elements\n\n"; bank.q3.Display(); system("cls"); cout<<"\n\t\t\t\t\t\t ====Report==== \n"; bank.Bank_Report(); return 0; }
[ "noreply@github.com" ]
noreply@github.com
fb9c623669f16dfc92db0606797c736cf072e666
b62e7086980cb97554b01dbfad64a040f9f80165
/NtupleMacros/SSDilep/COREtop/mcSelections.cc
0e7d72d8554ee0cb0178899c9755dd5e50d201e9
[]
no_license
tastest/CMS2
f819962e172c712abd82a8b213c4cb2286bcdcfe
e31e02d6037fbef206e216413b4def558ccefb39
refs/heads/master
2021-01-10T20:22:52.181267
2013-07-12T15:16:31
2013-07-12T15:16:31
10,772,930
1
0
null
null
null
null
UTF-8
C++
false
false
26,532
cc
#include <math.h> #include <stdlib.h> #include <set> #include "TDatabasePDG.h" #include "Math/VectorUtil.h" #include "CMS2.h" #include "mcSelections.h" #include "Math/LorentzVector.h" typedef ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<float> > LorentzVector; //------------------------------------------------- // Auxiliary function to scan the doc line and // identify DY-> ee vs mm vs tt //------------------------------------------------- int getDrellYanType() { bool foundEP = false; bool foundEM = false; bool foundMP = false; bool foundMM = false; bool foundTP = false; bool foundTM = false; for (unsigned int i = 0; i < cms2.genps_id().size(); ++i) { if ( cms2.genps_id_mother().at(i) == 23 ){ switch ( TMath::Abs(cms2.genps_id().at(i)) ){ case 11: return 0; break; case 13: return 1; break; case 15: return 2; break; default: break; } } switch ( cms2.genps_id().at(i) ){ case 11: foundEM = true; break; case -11: foundEP = true; break; case 13: foundMM = true; break; case -13: foundMP = true; break; case 15: foundTM = true; break; case -15: foundTP = true; break; default: break; } } if ( foundEP && foundEM ) return 0; //DY->ee if ( foundMP && foundMM ) return 1; //DY->mm if ( foundTP && foundTM ) return 2; //DY->tautau std::cout << "Does not look like a DY event" << std::endl; return 999; } int getVVType() { // types: // 0 - WW // 1 - WZ // 2 - ZZ unsigned int nZ(0); unsigned int nW(0); std::vector<std::vector<int> > leptons; std::vector<int> mothers; bool verbose = false; for (unsigned int i = 0; i < cms2.genps_id().size(); ++i) { int pid = cms2.genps_id().at(i); int mid = cms2.genps_id_mother().at(i); if ( verbose ) std::cout << "Gen particle id: " << pid << ",\t mother id: " << mid <<std::endl; if ( abs(pid)<11 || abs(pid)>16 ) continue; if ( mid == 23 ) ++nZ; if ( abs(mid) == 24 ) ++nW; // now we need to really understand the pattern. unsigned int mIndex = 0; while ( mIndex < mothers.size() && mid != mothers[mIndex] ) ++mIndex; if ( mIndex == mothers.size() ) { mothers.push_back(mid); leptons.push_back(std::vector<int>()); } leptons[mIndex].push_back(pid); if (mothers.size()>3){ if (verbose) std::cout << "WARNING: failed to identify event (too many mothers)" << std::endl; return 999; } } if ( nZ == 4 ) { if ( verbose ) std::cout << "Event type ZZ" << std::endl; return 2; } if ( nW == 4 ) { if ( verbose ) std::cout << "Event type WW" << std::endl; return 0; } if ( nW == 2 && nZ == 2 ) { if ( verbose ) std::cout << "Event type WZ" << std::endl; return 1; } unsigned int nNus(0); for ( unsigned int i=0; i<mothers.size(); ++i ){ nNus += leptons[i].size(); } if ( mothers.size() < 3 && nNus == 4){ for ( unsigned int i=0; i<mothers.size(); ++i ){ if ( mothers[i] != 23 && abs(mothers[i]) != 24 ){ if( leptons[i].size() != 2 && leptons[i].size() != 4){ if (verbose) std::cout << "WARNING: failed to identify event (unexpected number of daughters)" << std::endl; if (verbose) std::cout << "\tnumber of daughters for first mother: " << leptons[0].size() << std::endl; if (verbose) std::cout << "\tnumber of daughters for second mother: " << leptons[1].size() << std::endl; return 999; } if ( abs(leptons[i][0]) == abs(leptons[i][1]) ) nZ += 2; else nW += 2; if ( leptons[i].size()==4 ){ // now it's a wild guess, it's fraction should be small if ( abs(leptons[i][2]) == abs(leptons[i][3]) ) nZ += 2; else nW += 2; } } } } else { // here be dragons // if we have 2 leptons and 3 neutrinos and they all of the same // generation, we assume it's ZZ (can be WZ also), but if // neutrinos are from different generations, than we conclude it's // WZ. std::set<int> nus; for ( unsigned int i=0; i<mothers.size(); ++i ) for ( unsigned int j=0; j<leptons[i].size(); ++j ) if ( abs(leptons[i][j]) == 12 || abs(leptons[i][j]) == 14 || abs(leptons[i][j]) == 16 ) nus.insert(abs(leptons[i][j])); if ( nNus == 5 ){ if ( nus.size() == 1 ) return 2; if ( nus.size() == 2 ) return 1; } if ( verbose ) std::cout << "WARNING: failed to identify event" << std::endl; return 999; } if ( nZ+nW != 4 ){ if (verbose) std::cout << "WARNING: failed to identify event (wrong number of bosons)" << std::endl; if (verbose) std::cout << "\tfirst mother id: " << mothers[0] << std::endl; if (verbose) std::cout << "\tsecond mother id: " << mothers[1] << std::endl; if (verbose) std::cout << "\tnumber of daughters for first mother: " << leptons[0].size() << std::endl; if (verbose) std::cout << "\tnumber of daughters for second mother: " << leptons[1].size() << std::endl; if (verbose) std::cout << "\tnumber of Zs: " << nZ << std::endl; if (verbose) std::cout << "\tnumber of Ws: " << nW << std::endl; return 999; } if ( nZ == 4 ) { if ( verbose ) std::cout << "Event type ZZ" << std::endl; return 2; } if ( nW == 4 ) { if ( verbose ) std::cout << "Event type WW" << std::endl; return 0; } // this covers screws in logic, i.e. most hard to identify events end up being WZ if ( verbose ) std::cout << "Event type WZ (can be wrong)" << std::endl; return 1; } //------------------------------------------------- // Auxiliary function to scan the doc line and // identify DY-> ee vs mm vs tt //------------------------------------------------- int getWType() { bool foundE = false; bool foundNuE = false; bool foundM = false; bool foundNuM = false; bool foundT = false; bool foundNuT = false; for (unsigned int i = 0; i < cms2.genps_id().size(); ++i) { if ( abs(cms2.genps_id_mother().at(i)) == 24 ){ switch ( TMath::Abs(cms2.genps_id().at(i)) ){ case 11: return 0; break; case 13: return 1; break; case 15: return 2; break; default: break; } } switch ( abs(cms2.genps_id().at(i)) ){ case 11: foundE = true; break; case 12: foundNuE = true; break; case 13: foundM = true; break; case 14: foundNuM = true; break; case 15: foundT = true; break; case 16: foundNuT = true; break; default: break; } } if ( foundE && foundNuE ) return 0; //W->e if ( foundM && foundNuM ) return 1; //W->m if ( foundT && foundNuT ) return 2; //W->t std::cout << "Does not look like a W event" << std::endl; return 999; } //-------------------------------------------- // Booleans for DY //------------------------------------------ bool isDYee() { if (getDrellYanType() == 0) return true; return false; } bool isDYmm() { if (getDrellYanType() == 1) return true; return false; } bool isDYtt() { if (getDrellYanType() == 2) return true; return false; } //-------------------------------------------- // Booleans for Wjets //------------------------------------------ bool isWe() { if (getWType() == 0) return true; return false; } bool isWm() { if (getWType() == 1) return true; return false; } bool isWt() { if (getWType() == 2) return true; return false; } //-------------------------------------------- // Booleans for VVjets //------------------------------------------ bool isWW() { if (getVVType() == 0) return true; return false; } bool isWZ() { if (getVVType() == 1) return true; return false; } bool isZZ() { if (getVVType() == 2) return true; return false; } //-------------------------------------------- // ZZ type: // 0 for Z1 --> ee, mm; Z2 --> ee, mm // 1 for Z1 --> ee, mm; Z2 --> tt (and v.v.) // 2 for Z1 --> tt; Z2 --> tt // 995 to 999 otherwise //------------------------------------------ int getZZType() { int foundEP = 0; int foundEM = 0; int foundMP = 0; int foundMM = 0; int foundTP = 0; int foundTM = 0; for (unsigned int i = 0; i < cms2.genps_id().size(); ++i) { switch ( cms2.genps_id().at(i) ){ case 11: foundEM++; break; case -11: foundEP++; break; case 13: foundMM++; break; case -13: foundMP++; break; case 15: foundTM++; break; case -15: foundTP++; break; default: break; } } if (foundEM == foundEP && foundMM == foundMP && (foundEM != 0 || foundMM != 0)) { // both Zs decay to e or mu if (foundEM + foundMM == 2) return 0; // one Z decays to e or mu else if (foundEM + foundMM == 1) // other Z decays to tau if (foundTP == 1 && foundTM == 1) return 1; else return 995; else return 996; } else if (foundEM == 0 && foundEP == 0 && foundMM == 0 && foundMP == 0) { // both Zs decay to tau if (foundTP == 2 && foundTM == 2) return 2; else return 997; } else return 998; return 999; } //------------------------------------------------------------ // Not a selection function per se, but useful nonetheless: // dumps the documentation lines for this event //------------------------------------------------------------ int dumpDocLines() { int size = cms2.genps_id().size(); // Initialize particle database static TDatabasePDG *pdg = new TDatabasePDG(); std::cout << "------------------------------------------" << std::endl; for (int j=0; j<size; j++) { float m2 = cms2.genps_p4().at(j).M2(); float m = m2 >= 0 ? sqrt(m2) : 0.0; cout << setw(9) << left << pdg->GetParticle(cms2.genps_id().at(j))->GetName() << " " << setw(7) << right << setprecision(4) << cms2.genps_p4().at(j).pt() << " " << setw(7) << right << setprecision(4) << cms2.genps_p4().at(j).phi() << " " << setw(10) << right << setprecision(4) << cms2.genps_p4().at(j).eta() << " " << setw(10) << right << setprecision(4) << m << endl; } return 0; } int ttbarconstituents(int i_hyp){ // Categories: //WW = both leptons from W = 1 //WO = one of the two leptons from W and the other not = 2 //OO = neither of the two leptons is from a W = 3 int lttype = leptonIsFromW(cms2.hyp_lt_index()[i_hyp],cms2.hyp_lt_id()[i_hyp]); int lltype = leptonIsFromW(cms2.hyp_ll_index()[i_hyp],cms2.hyp_ll_id()[i_hyp]); if (lltype > 0 && lttype > 0) return 1; else if( (lltype >0 && lttype <= 0) || (lttype >0 && lltype <=0) ) return 2; else if( (lltype <=0 && lttype <=0) )return 3; else { cout << "bug in ttbarconstituents"; return -999;} } //-------------------------------------------------------- // Determines if the lepton in question is from W/Z // and if its charge is correct // // Note that if we have // W->lepton->lepton gamma // where the gamma is at large angles and it is the // gamma that gives the lepton signature in the detector, // then this returns "not from W/Z". This is by design. // // Note W->tau->lepton is tagged as "from W" // // Inputs: idx = index in the els or mus block // id = lepton ID (11 or 13 or -11 or -13) // // Output: 2 = from W/Z incorrect charge // 1 = from W/Z correct charge // 0 = not matched to a lepton (= fake) // -1 = lepton from b decay // -2 = lepton from c decay // -3 = lepton from some other source // // Authors: Claudio in consultation with fkw 22-july-09 //--------------------------------------------------------- int leptonIsFromW(int idx, int id) { // get the matches to status=1 and status=3 int st1_id = 0; int st3_id = 0; int st1_motherid = 0; if (abs(id) == 11) { st1_id = cms2.els_mc_id()[idx]; st3_id = cms2.els_mc3_id()[idx]; st1_motherid = cms2.els_mc_motherid()[idx]; //a true lepton from a W will have it's motherid==24 //if the lepton comes from a tau decay that comes from a W, //we have to do some work to trace the parentage //to do this, we have to go to the status==3 block because //the daughter info is not in status==1 if(abs(st1_motherid)==15) { bool foundelectronneutrino = false; //ensures that the matched electron from a tau really came from a W for(unsigned int i = 0; i < cms2.genps_id().size(); i++) {//status 3 loop if(abs(cms2.genps_id()[i]) == 15 ) { //make sure we get the right tau! cms2.genps_lepdaughter_id()[i].size(); for(unsigned int j = 0; j < cms2.genps_lepdaughter_id()[i].size(); j++) { //loop over the tau's status1 daughters if(abs(cms2.genps_lepdaughter_id()[i][j]) == 12) foundelectronneutrino = true; float dr = ROOT::Math::VectorUtil::DeltaR(cms2.els_mc_p4()[idx], cms2.genps_lepdaughter_p4()[i][j]); if (dr < 0.0001) { //should be the same exact status==1 gen particle! st1_motherid = cms2.genps_id_mother()[i]; continue; }//if (dr < 0.0001) }//loop over the tau's daughters if(!foundelectronneutrino) st1_motherid = -9999; }//tau }//status 3 loop }//if(abs(st1_motherid)==15) { } else if (abs(id) == 13) { st1_id = cms2.mus_mc_id()[idx]; st3_id = cms2.mus_mc3_id()[idx]; st1_motherid = cms2.mus_mc_motherid()[idx]; //a true lepton from a W will have it's motherid==24 //if the lepton comes from a tau decay that comes from a W, //we have to do some work to trace the parentage //to do this, we have to go to the status==3 block because //the daughter info is not in status==1 if(abs(st1_motherid)==15) { bool foundmuonneutrino = false; for(unsigned int i = 0; i < cms2.genps_id().size(); i++) {//status 3 loop if(abs(cms2.genps_id()[i]) == 15 ) { //make sure we get the right tau! cms2.genps_lepdaughter_id()[i].size(); for(unsigned int j = 0; j < cms2.genps_lepdaughter_id()[i].size(); j++) {//loop over the tau's status1 daughters if(abs(cms2.genps_lepdaughter_id()[i][j]) == 14) foundmuonneutrino = true; float dr = ROOT::Math::VectorUtil::DeltaR(cms2.mus_mc_p4()[idx], cms2.genps_lepdaughter_p4()[i][j]); if (dr < 0.0001) { //should be the same exact status==1 gen particle! st1_motherid = cms2.genps_id_mother()[i]; continue; }//if (dr < 0.0001) }//loop over the tau's daughters if(!foundmuonneutrino) st1_motherid = -9999; }//tau }//status 3 loop }//if(abs(st1_motherid)==15) { } else { std::cout << "You fool. Give me +/- 11 or +/- 13 please" << std::endl; return false; } // debug // std::cout << "id=" << id << " st1_id=" << st1_id; // std::cout << " st3_id=" << st3_id; // std::cout << " st1_motherid=" << st1_motherid << std::endl; // Step 1 // Look at status 1 match, it should be either a lepton or // a photon if it comes from W/Z. // The photon case takes care of collinear FSR if ( !(abs(st1_id) == abs(id) || st1_id == 22)) return 0; // Step 2 // If the status 1 match is a photon, its mother must be // a lepton. Otherwise it is not FSR if (st1_id == 22) { if (abs(st1_motherid) != abs(id)) return 0; } // At this point we are matched (perhaps via FSR) to // a status 1 lepton. This means that we are left with // leptons from W, taus, bottom, charm, as well as dalitz decays // Step 3 // A no-brainer: pick up vanilla W->lepton decays // (should probably add Higgs, SUSY, W' etc...not for now) if (st1_id == id && abs(st1_motherid) == 24) return 1; // W if (st1_id == -id && abs(st1_motherid) == 24) return 2; // W if (st1_id == id && st1_motherid == 23) return 1; // Z if (st1_id == -id && st1_motherid == 23) return 2; // Z // Step 4 // Another no-brainer: pick up leptons matched to status=3 // leptons. This should take care of collinear FSR if (st3_id == id) return 1; if (st3_id == -id) return 2; // Step 5 // Now we need to go after the W->tau->lepton. // We exploit the fact that in t->W->tau the tau shows up // at status=3. We also use the fact that the tau decay products // are highly boosted, so the direction of the status=3 tau and // the lepton from tau decays are about the same // // We do not use the status=1 links because there is not // enough information to distinguish // W->tau->lepton or W->tau->lepton gamma // from // B->tau->lepton or B->tau->lepton gamma //if (abs(st3_id) == 15 && id*st3_id > 0) return 1; //if (abs(st3_id) == 15 && id*st3_id < 0) return 2; if(abs(st3_id) == 15) { //have to find the index of the status3 particle by dR //because the indices are buggy unsigned int mc3idx; LorentzVector lepp4 = abs(id)==11 ? cms2.els_p4()[idx] : cms2.mus_p4()[idx]; double mindR = 9999; for(unsigned int i = 0; i < cms2.genps_id().size(); i++) { float dr = ROOT::Math::VectorUtil::DeltaR(lepp4, cms2.genps_p4()[i]); if(dr < mindR) { mindR = dr; mc3idx = i; } } bool foundElOrMuNu = false; for(unsigned int i = 0; i < cms2.genps_lepdaughter_p4()[mc3idx].size(); i++) { if(abs(cms2.genps_lepdaughter_id()[mc3idx][i]) == 12 || abs(cms2.genps_lepdaughter_id()[mc3idx][i]) == 14) foundElOrMuNu = true; } if(!foundElOrMuNu) //comes from a hadronic decay of the tau return -3; if(id*st3_id > 0) return 1; else return 2; } // Step 6 // If we get here, we have a non-W lepton // Now we figure out if it is from b, c, or "other" // There are a couple of caveats // (a) b/c --> lepton --> lepton gamma (ie FSR) is labelled as "other" // (b) b --> tau --> lepton is labelled as "other" if ( abs(st1_id) == abs(id) && idIsBeauty(st1_motherid)) return -1; if ( abs(st1_id) == abs(id) && idIsCharm(st1_motherid)) return -2; return -3; } //--------------------------------------------------------- bool trueGammaFromMuon(int electron) { // true gamma reconstructed as electron // gamma coming from muon if(TMath::Abs(cms2.els_mc_id()[electron]) == 22 && TMath::Abs(cms2.els_mc_motherid()[electron]) == 13) { // ok, abs of photon makes no sense ;) // std::cout<<"Gamma from muon event - r: " << cms2.evt_run() << " e: " << cms2.evt_event() << " l: " << cms2.evt_lumiBlock() << std::endl; return true; } return false; } // count genp leptons //-------------------------------------------------- // Returns the number of e,mu, and tau in the doc lines //----------------------------------------------------- int leptonGenpCount(int& nele, int& nmuon, int& ntau) { nele=0; nmuon=0; ntau=0; int size = cms2.genps_id().size(); for (int jj=0; jj<size; jj++) { if (abs(cms2.genps_id().at(jj)) == 11) nele++; if (abs(cms2.genps_id().at(jj)) == 13) nmuon++; if (abs(cms2.genps_id().at(jj)) == 15) ntau++; } return nele + nmuon + ntau; } int leptonGenpCount_lepTauDecays(int& nele, int& nmuon, int& ntau) { nele=0; nmuon=0; ntau=0; int size = cms2.genps_id().size(); for (int jj=0; jj<size; jj++) { if (abs(cms2.genps_id().at(jj)) == 11) nele++; if (abs(cms2.genps_id().at(jj)) == 13) nmuon++; if (abs(cms2.genps_id().at(jj)) == 15) { for(unsigned int kk = 0; kk < cms2.genps_lepdaughter_id()[jj].size(); kk++) { int daughter = abs(cms2.genps_lepdaughter_id()[jj][kk]); //we count neutrino's because that guarantees that //there is a corresponding lepton and that it comes from // a leptonic tau decay. You can get electrons from converted photons //which are radiated by charged pions from the tau decay but thats //hadronic and we don't care for those if( daughter == 12 || daughter == 14) ntau++; }//daughter loop }//if tau }//genps loop return nele + nmuon + ntau; } //--------------------------------------------------------- int genpDileptonType(){ //0 mumu; 1 emu; 2 ee unsigned int nmus = 0; unsigned int nels = 0; int size = cms2.genps_id().size(); for (int jj=0; jj<size; jj++) { if (abs(cms2.genps_id().at(jj)) == 11) nels++; if (abs(cms2.genps_id().at(jj)) == 13) nmus++; } if ((nels + nmus) != 2){ return -1; } int dilType = -1; if (nmus == 2) dilType = 0; if (nels == 2) dilType = 2; if (nels == 1 && nmus == 1) dilType = 1; return dilType; } // ----------------------------------------- // MC helper functions for fakerate tests: // ----------------------------------------- int elFakeMCCategory(int i_el) { int category = -1; if( (abs(cms2.els_mc_id()[i_el]) == 11 && abs(cms2.els_mc_motherid()[i_el]) == 22) || (abs(cms2.els_mc_id()[i_el]) == 22) || (abs(cms2.els_mc_id()[i_el]) > 100 && abs(cms2.els_mc_id()[i_el]) < 200)|| (abs(cms2.els_mc_id()[i_el]) == 11 && abs(cms2.els_mc_motherid()[i_el]) == 111) ) { // electrons from gamma (conversion) category = 1; } else if( (abs(cms2.els_mc_id()[i_el]) > 200 && abs(cms2.els_mc_id()[i_el]) < 400 ) || (abs(cms2.els_mc_id()[i_el]) > 2000 && abs(cms2.els_mc_id()[i_el]) < 4000 ) || (abs(cms2.els_mc_id()[i_el]) == 11 && abs(cms2.els_mc_motherid()[i_el]) > 200 && abs(cms2.els_mc_motherid()[i_el]) < 400 ) || (abs(cms2.els_mc_id()[i_el]) == 11 && abs(cms2.els_mc_motherid()[i_el]) > 2000 && abs(cms2.els_mc_motherid()[i_el]) < 4000 ) ) { // electron candidate or its mother is a light hadron category = 2; } else if( ( abs(cms2.els_mc_id()[i_el]) == 11 && abs(cms2.els_mc_motherid()[i_el]) >=400 && abs(cms2.els_mc_motherid()[i_el]) <=600 ) || ( abs(cms2.els_mc_id()[i_el]) == 11 && abs(cms2.els_mc_motherid()[i_el]) >=4000 && abs(cms2.els_mc_motherid()[i_el]) <=6000 ) ) { // heavy hadrons category = 3; } else { // the rest category = 4; } return category; } int muFakeMCCategory(int i_mu) { int category = -1; if( // punchthrough / sailthrough (abs(cms2.mus_mc_id()[i_mu]) != 13 ) ) { category = 1; } else if( abs(cms2.mus_mc_id()[i_mu]) == 13 && abs(cms2.mus_mc_motherid()[i_mu]) < 400 ) { // light hadrons category = 2; } else if( ( abs(cms2.mus_mc_id()[i_mu]) == 13 && abs(cms2.mus_mc_motherid()[i_mu]) >=400 && abs(cms2.mus_mc_motherid()[i_mu]) <=600 ) || ( abs(cms2.mus_mc_id()[i_mu]) == 13 && abs(cms2.mus_mc_motherid()[i_mu]) >=4000 && abs(cms2.mus_mc_motherid()[i_mu]) <=6000 ) ) { // heavy hadrons category = 3; } else { // the rest category = 4; } return category; } bool idIsCharm(int id) { id = abs(id); if ( id == 4 || id == 411 || id == 421 || id == 10411 || id == 10421 || id == 413 || id == 423 || id == 10413 || id == 10423 || id == 20413 || id == 20423 || id == 415 || id == 425 || id == 431 || id == 10431 || id == 433 || id == 10433 || id == 20433 || id == 435 || id == 441 || id == 10441 || id == 100441 || id == 443 || id == 10443 || id == 20443 || id == 100443 || id == 30443 || id == 9000443 || id == 9010443 || id == 9020443 || id == 445 || id == 9000445 || id == 4122 || id == 4222 || id == 4212 || id == 4112 || id == 4224 || id == 4214 || id == 4114 || id == 4232 || id == 4132 || id == 4322 || id == 4312 || id == 4324 || id == 4314 || id == 4332 || id == 4334 || id == 4412 || id == 4422 || id == 4414 || id == 4424 || id == 4432 || id == 4434 || id == 4444 ) { return true; } else return false; } bool idIsBeauty(int id) { id = abs(id); if ( id == 5 || id == 511 || id == 521 || id == 10511 || id == 10521 || id == 513 || id == 523 || id == 10513 || id == 10523 || id == 20513 || id == 20523 || id == 515 || id == 525 || id == 531 || id == 10531 || id == 533 || id == 10533 || id == 20533 || id == 535 || id == 541 || id == 10541 || id == 543 || id == 10543 || id == 20543 || id == 545 || id == 551 || id == 10551 || id == 100551 || id == 110551 || id == 200551 || id == 210551 || id == 553 || id == 10553 || id == 20553 || id == 30553 || id == 100553 || id == 110553 || id == 120553 || id == 130553 || id == 200553 || id == 210553 || id == 220553 || id == 300553 || id == 9000553 || id == 9010553 || id == 555 || id == 10555 || id == 20555 || id == 100555 || id == 110555 || id == 120555 || id == 200555 || id == 557 || id == 100557 || id == 5122 || id == 5112 || id == 5212 || id == 5222 || id == 5114 || id == 5214 || id == 5224 || id == 5132 || id == 5232 || id == 5312 || id == 5322 || id == 5314 || id == 5324 || id == 5332 || id == 5334 || id == 5142 || id == 5242 || id == 5412 || id == 5422 || id == 5414 || id == 5424 || id == 5342 || id == 5432 || id == 5434 || id == 5442 || id == 5444 || id == 5512 || id == 5522 || id == 5514 || id == 5524 || id == 5532 || id == 5534 || id == 5542 || id == 5544 || id == 5554 ) { return true; } else return false; }
[ "fkw" ]
fkw
3677e055f2d1511c1b74dacbed6c39af37b84494
8f1c8940416dcef4492342ff02930dc63f4482e6
/libraries/entities/src/EntityItemProperties.h
6e1594fb9bef78761f8685a6570d9bb4590e0309
[ "Apache-2.0" ]
permissive
manlea/hifi
f24cd7dc244c6d13743eae23721b4ba6638c072a
2dff75dac126a11da2d2bcf6cb4a2ab55e633a10
refs/heads/master
2021-01-22T01:54:39.824202
2014-10-25T02:45:26
2014-10-25T02:45:26
25,757,352
1
0
null
null
null
null
UTF-8
C++
false
false
13,641
h
// // EntityItemProperties.h // libraries/entities/src // // Created by Brad Hefta-Gaub on 12/4/13. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_EntityItemProperties_h #define hifi_EntityItemProperties_h #include <stdint.h> #include <glm/glm.hpp> #include <glm/gtx/extented_min_max.hpp> #include <QtScript/QScriptEngine> #include <QtCore/QObject> #include <QVector> #include <QString> #include <AACube.h> #include <FBXReader.h> // for SittingPoint #include <PropertyFlags.h> #include <OctreeConstants.h> #include "EntityItemID.h" #include "EntityItemPropertiesMacros.h" #include "EntityTypes.h" // PropertyFlags support enum EntityPropertyList { PROP_PAGED_PROPERTY, PROP_CUSTOM_PROPERTIES_INCLUDED, // these properties are supported by the EntityItem base class PROP_VISIBLE, PROP_POSITION, PROP_RADIUS, // NOTE: PROP_RADIUS is obsolete and only included in old format streams PROP_DIMENSIONS = PROP_RADIUS, PROP_ROTATION, PROP_MASS, PROP_VELOCITY, PROP_GRAVITY, PROP_DAMPING, PROP_LIFETIME, PROP_SCRIPT, // these properties are supported by some derived classes PROP_COLOR, PROP_MODEL_URL, PROP_ANIMATION_URL, PROP_ANIMATION_FPS, PROP_ANIMATION_FRAME_INDEX, PROP_ANIMATION_PLAYING, // these properties are supported by the EntityItem base class PROP_REGISTRATION_POINT, PROP_ANGULAR_VELOCITY, PROP_ANGULAR_DAMPING, PROP_IGNORE_FOR_COLLISIONS, PROP_COLLISIONS_WILL_MOVE, PROP_LAST_ITEM = PROP_COLLISIONS_WILL_MOVE }; typedef PropertyFlags<EntityPropertyList> EntityPropertyFlags; const quint64 UNKNOWN_CREATED_TIME = (quint64)(-1); const quint64 USE_EXISTING_CREATED_TIME = (quint64)(-2); /// A collection of properties of an entity item used in the scripting API. Translates between the actual properties of an /// entity and a JavaScript style hash/QScriptValue storing a set of properties. Used in scripting to set/get the complete /// set of entity item properties via JavaScript hashes/QScriptValues /// all units for position, dimensions, etc are in meter units class EntityItemProperties { friend class EntityItem; // TODO: consider removing this friend relationship and use public methods friend class ModelEntityItem; // TODO: consider removing this friend relationship and use public methods friend class BoxEntityItem; // TODO: consider removing this friend relationship and use public methods friend class SphereEntityItem; // TODO: consider removing this friend relationship and use public methods public: EntityItemProperties(); virtual ~EntityItemProperties() { }; virtual QScriptValue copyToScriptValue(QScriptEngine* engine) const; virtual void copyFromScriptValue(const QScriptValue& object); // editing related features supported by all entities quint64 getLastEdited() const { return _lastEdited; } float getEditedAgo() const /// Elapsed seconds since this entity was last edited { return (float)(usecTimestampNow() - getLastEdited()) / (float)USECS_PER_SECOND; } EntityPropertyFlags getChangedProperties() const; /// used by EntityScriptingInterface to return EntityItemProperties for unknown models void setIsUnknownID() { _id = UNKNOWN_ENTITY_ID; _idSet = true; } AACube getMaximumAACubeInTreeUnits() const; AACube getMaximumAACubeInMeters() const; AABox getAABoxInMeters() const; void debugDump() const; // properties of all entities EntityTypes::EntityType getType() const { return _type; } void setType(EntityTypes::EntityType type) { _type = type; } const glm::vec3& getPosition() const { return _position; } /// set position in meter units, will be clamped to domain bounds void setPosition(const glm::vec3& value) { _position = glm::clamp(value, 0.0f, (float)TREE_SCALE); _positionChanged = true; } const glm::vec3& getDimensions() const { return _dimensions; } void setDimensions(const glm::vec3& value) { _dimensions = value; _dimensionsChanged = true; } float getMaxDimension() const { return glm::max(_dimensions.x, _dimensions.y, _dimensions.z); } const glm::quat& getRotation() const { return _rotation; } void setRotation(const glm::quat& rotation) { _rotation = rotation; _rotationChanged = true; } float getMass() const { return _mass; } void setMass(float value) { _mass = value; _massChanged = true; } /// velocity in meters (0.0-1.0) per second const glm::vec3& getVelocity() const { return _velocity; } /// velocity in meters (0.0-1.0) per second void setVelocity(const glm::vec3& value) { _velocity = value; _velocityChanged = true; } /// gravity in meters (0.0-TREE_SCALE) per second squared const glm::vec3& getGravity() const { return _gravity; } /// gravity in meters (0.0-TREE_SCALE) per second squared void setGravity(const glm::vec3& value) { _gravity = value; _gravityChanged = true; } float getDamping() const { return _damping; } void setDamping(float value) { _damping = value; _dampingChanged = true; } float getLifetime() const { return _lifetime; } /// get the lifetime in seconds for the entity void setLifetime(float value) { _lifetime = value; _lifetimeChanged = true; } /// set the lifetime in seconds for the entity float getAge() const { return (float)(usecTimestampNow() - _created) / (float)USECS_PER_SECOND; } quint64 getCreated() const { return _created; } void setCreated(quint64 usecTime) { _created = usecTime; } bool hasCreatedTime() const { return (_created != UNKNOWN_CREATED_TIME); } // NOTE: how do we handle _defaultSettings??? bool containsBoundsProperties() const { return (_positionChanged || _dimensionsChanged); } bool containsPositionChange() const { return _positionChanged; } bool containsDimensionsChange() const { return _dimensionsChanged; } // TODO: this need to be more generic. for now, we're going to have the properties class support these as // named getter/setters, but we want to move them to generic types... // properties we want to move to just models and particles xColor getColor() const { return _color; } const QString& getModelURL() const { return _modelURL; } const QString& getAnimationURL() const { return _animationURL; } float getAnimationFrameIndex() const { return _animationFrameIndex; } bool getAnimationIsPlaying() const { return _animationIsPlaying; } float getAnimationFPS() const { return _animationFPS; } float getGlowLevel() const { return _glowLevel; } float getLocalRenderAlpha() const { return _localRenderAlpha; } const QString& getScript() const { return _script; } // model related properties void setColor(const xColor& value) { _color = value; _colorChanged = true; } void setModelURL(const QString& url) { _modelURL = url; _modelURLChanged = true; } void setAnimationURL(const QString& url) { _animationURL = url; _animationURLChanged = true; } void setAnimationFrameIndex(float value) { _animationFrameIndex = value; _animationFrameIndexChanged = true; } void setAnimationIsPlaying(bool value) { _animationIsPlaying = value; _animationIsPlayingChanged = true; } void setAnimationFPS(float value) { _animationFPS = value; _animationFPSChanged = true; } void setGlowLevel(float value) { _glowLevel = value; _glowLevelChanged = true; } void setLocalRenderAlpha(float value) { _localRenderAlpha = value; _localRenderAlphaChanged = true; } void setScript(const QString& value) { _script = value; _scriptChanged = true; } static bool encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties, unsigned char* bufferOut, int sizeIn, int& sizeOut); static bool encodeEraseEntityMessage(const EntityItemID& entityItemID, unsigned char* outputBuffer, size_t maxLength, size_t& outputLength); static bool decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes, EntityItemID& entityID, EntityItemProperties& properties); bool positionChanged() const { return _positionChanged; } bool rotationChanged() const { return _rotationChanged; } bool massChanged() const { return _massChanged; } bool velocityChanged() const { return _velocityChanged; } bool gravityChanged() const { return _gravityChanged; } bool dampingChanged() const { return _dampingChanged; } bool lifetimeChanged() const { return _lifetimeChanged; } bool scriptChanged() const { return _scriptChanged; } bool dimensionsChanged() const { return _dimensionsChanged; } bool registrationPointChanged() const { return _registrationPointChanged; } bool colorChanged() const { return _colorChanged; } bool modelURLChanged() const { return _modelURLChanged; } bool animationURLChanged() const { return _animationURLChanged; } bool animationIsPlayingChanged() const { return _animationIsPlayingChanged; } bool animationFrameIndexChanged() const { return _animationFrameIndexChanged; } bool animationFPSChanged() const { return _animationFPSChanged; } bool glowLevelChanged() const { return _glowLevelChanged; } bool localRenderAlphaChanged() const { return _localRenderAlphaChanged; } void clearID() { _id = UNKNOWN_ENTITY_ID; _idSet = false; } void markAllChanged(); QVector<SittingPoint> getSittingPoints() const { return _sittingPoints; } void setSittingPoints(QVector<SittingPoint> sittingPoints) { _sittingPoints = sittingPoints; } const glm::vec3& getNaturalDimensions() const { return _naturalDimensions; } void setNaturalDimensions(const glm::vec3& value) { _naturalDimensions = value; } const glm::vec3& getRegistrationPoint() const { return _registrationPoint; } void setRegistrationPoint(const glm::vec3& value) { _registrationPoint = value; _registrationPointChanged = true; } const glm::vec3& getAngularVelocity() const { return _angularVelocity; } void setAngularVelocity(const glm::vec3& value) { _angularVelocity = value; _angularVelocityChanged = true; } float getAngularDamping() const { return _angularDamping; } void setAngularDamping(float value) { _angularDamping = value; _angularDampingChanged = true; } bool getVisible() const { return _visible; } void setVisible(bool value) { _visible = value; _visibleChanged = true; } bool getIgnoreForCollisions() const { return _ignoreForCollisions; } void setIgnoreForCollisions(bool value) { _ignoreForCollisions = value; _ignoreForCollisionsChanged = true; } bool getCollisionsWillMove() const { return _collisionsWillMove; } void setCollisionsWillMove(bool value) { _collisionsWillMove = value; _collisionsWillMoveChanged = true; } void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; } private: QUuid _id; bool _idSet; quint64 _lastEdited; quint64 _created; EntityTypes::EntityType _type; void setType(const QString& typeName) { _type = EntityTypes::getEntityTypeFromName(typeName); } glm::vec3 _position; glm::vec3 _dimensions; glm::quat _rotation; float _mass; glm::vec3 _velocity; glm::vec3 _gravity; float _damping; float _lifetime; QString _script; glm::vec3 _registrationPoint; glm::vec3 _angularVelocity; float _angularDamping; bool _visible; bool _ignoreForCollisions; bool _collisionsWillMove; bool _positionChanged; bool _dimensionsChanged; bool _rotationChanged; bool _massChanged; bool _velocityChanged; bool _gravityChanged; bool _dampingChanged; bool _lifetimeChanged; bool _scriptChanged; bool _registrationPointChanged; bool _angularVelocityChanged; bool _angularDampingChanged; bool _visibleChanged; bool _ignoreForCollisionsChanged; bool _collisionsWillMoveChanged; // TODO: this need to be more generic. for now, we're going to have the properties class support these as // named getter/setters, but we want to move them to generic types... xColor _color; QString _modelURL; QString _animationURL; bool _animationIsPlaying; float _animationFrameIndex; float _animationFPS; float _glowLevel; float _localRenderAlpha; QVector<SittingPoint> _sittingPoints; glm::vec3 _naturalDimensions; bool _colorChanged; bool _modelURLChanged; bool _animationURLChanged; bool _animationIsPlayingChanged; bool _animationFrameIndexChanged; bool _animationFPSChanged; bool _glowLevelChanged; bool _localRenderAlphaChanged; bool _defaultSettings; }; Q_DECLARE_METATYPE(EntityItemProperties); QScriptValue EntityItemPropertiesToScriptValue(QScriptEngine* engine, const EntityItemProperties& properties); void EntityItemPropertiesFromScriptValue(const QScriptValue &object, EntityItemProperties& properties); inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) { debug << "EntityItemProperties[" << "\n" << " position:" << properties.getPosition() << "in meters" << "\n" << " velocity:" << properties.getVelocity() << "in meters" << "\n" << " last edited:" << properties.getLastEdited() << "\n" << " edited ago:" << properties.getEditedAgo() << "\n" << "]"; return debug; } #endif // hifi_EntityItemProperties_h
[ "bradh@konamoxt.com" ]
bradh@konamoxt.com
3d4cd4313db12e030b653b7fb2df1cd903c78533
8a28891c592d6b502f12de873d080b42130948b6
/src/studiorpm/CBone.h
09a634deeb2af226176aa7f6d35d3e24ac46c7cd
[]
no_license
MGraefe/deferred
2d12bea544549df46e15a4c06dab05a46a6b6e45
92d7b39294195441dcb86254e0dc738561abf184
refs/heads/master
2016-09-06T12:37:53.518946
2015-08-03T12:27:22
2015-08-03T12:27:22
40,123,198
2
1
null
null
null
null
UTF-8
C++
false
false
753
h
// studiorpm/CBone.h // studiorpm/CBone.h // studiorpm/CBone.h //---------------------------------- // Deferred Source Code // Copyright (c) 2015 Marius Graefe // All rights reserved // Contact: deferred@mgraefe.de //----------------------------------- #pragma once #ifndef deferred__studiorpm__CBone_H__ #define deferred__studiorpm__CBone_H__ #include <string> class CBone { public: CBone(const std::string &boneName, int boneId, int boneParentId) : name(boneName), id(boneId), parentId(boneParentId) { } const std::string &getName() { return name; } int getId() { return id; } int getParentId() { return parentId; } private: std::string name; int id; int parentId; }; #endif // deferred__studiorpm__CBone_H__
[ "git@mgraefe.de" ]
git@mgraefe.de
04f2fbcd5d429f68c483c9ca4fc908446eeea385
55b8e6e97b9667340c9ee22305b87c6a8d035af6
/tests/vector_tests.cpp
88332aa3b0014d1de39a567207d6aaaa09069d2e
[ "ISC" ]
permissive
cgreen-devs/cgreen
47edeea756bf86e9ff259d9b90afc05ca76d0f6a
728caae527c9eb53f31cd2b6f95b3db32ab50ca8
refs/heads/master
2023-09-01T17:44:23.997402
2023-08-29T15:42:17
2023-08-30T06:29:25
41,703,892
186
66
ISC
2023-08-30T06:29:27
2015-08-31T22:30:55
C
UTF-8
C++
false
false
416
cpp
/* This file used to be a link to the corresponding .c file because we want to compile the same tests for C and C++. But since some systems don't handle symbolic links the same way as *ix systems we get inconsistencies (looking at you Cygwin) or plain out wrong (looking at you MSYS2, copying ?!?!?) behaviour. So we will simply include the complete .c source instead... */ #include "vector_tests.c"
[ "thomas@nilefalk.se" ]
thomas@nilefalk.se
df6149ad46528c69a71bc5bd8c7f8c0ac78f932b
d8f74aaf4a8300f17f51d9a3069ab3a589ff3053
/ch3 lab2-1/source/main.cpp
c3d7d19d12f930044c6aa9c17afc7c93a7a19622
[]
no_license
Reds18360245/ch3
e2067890b83297abb794835df50b8875db856f92
5b8b548cda3e134f5ad0e616211dc7ed16ac7ea5
refs/heads/master
2020-08-27T23:36:33.177438
2019-10-25T11:57:20
2019-10-25T11:57:20
217,521,774
0
0
null
null
null
null
UTF-8
C++
false
false
543
cpp
#include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; long int fac(int a); void main(void) { int m, n; long int ans, a, b, c; cout << "¨求排列組合(m,n)" << endl; cout << "m="; cin >> m; cout << "n="; cin >> n; a = fac(m); b = fac(n); c = fac(m - n); ans = a / (b * c); cout << "C(" << m << "," << n << ") = " << ans << endl; system("PAUSE"); } long int fac(int p) { int count; long int result = 1; for (count = 1; count <= p; count++) { result = result * count; } return result; }
[ "allen90423@gmail.com" ]
allen90423@gmail.com
621800daa3f3f814ff2a6a844deda025fe118849
1888c36b6ef41c61bfadb897c51d27928778f7a5
/problems/sample/sample_test.cc
a6813e1a2002deb49f14ada61b0d66422a97ebcb
[]
no_license
pompon0/lp_modification
08620dc39dcb35a7ff8b8a46759b442a44542623
f0b16ba28cf514501a9382a63b2352c1204f6b05
refs/heads/master
2021-12-08T05:13:55.148713
2020-10-25T16:38:31
2020-10-25T17:08:27
177,988,879
0
0
null
null
null
null
UTF-8
C++
false
false
196
cc
#define DEBUG_MODE #include "gtest/gtest.h" #include "utils/log.h" #include "problems/sample/sample.h" TEST(SAMPLE,simple) { StreamLogger _(std::cerr); problems::sample::sample_problems(); }
[ "pompon.pompon@gmail.com" ]
pompon.pompon@gmail.com
bb5444d1550d7859738198353fc63c3d178a4367
3db9c80383d32b589bcfd9800234d50b2156fd1d
/algorithm/heap/heap.cc
583912853146f1007c198d8079cc7db3771d560d
[ "MIT" ]
permissive
hellocodeM/ToySTL
2deecde5cbb7562358402788d019eef1e435627f
8221688f8674ab214e3e57abe262b02f952c8036
refs/heads/master
2021-05-31T07:42:56.565492
2015-11-17T12:41:24
2015-11-17T12:41:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,473
cc
#include <predef.hpp> template <class Iter> void make_heap(Iter first, Iter last) { } template <class Iter> void push_heap(Iter first, Iter last) { --last; auto prev = last; prev = first + (last - first) / 2; while (last != first && *prev < *last) { std::iter_swap(prev, last); last = prev; prev = first + (std::distance(first, prev) - 1) / 2; } } template <class Iter> void pop_heap(Iter first, Iter last) { if (std::distance(first, last) <= 1) return; --last; std::iter_swap(first, last); auto iter = first; while (iter < last) { auto succ = first + (std::distance(first, iter) + 1) * 2 - 1; if (succ >= last) break; auto right = succ+1; if (right < last && *succ < *right) succ = right; if (*iter < *succ) std::iter_swap(succ, iter); iter = succ; } } template <class Iter> void sort_heap(Iter first, Iter last) { while (first != last) ::pop_heap(first, last--); } template <class Iter> bool is_heap_impl(Iter first, Iter iter, Iter last) { auto left = first + (std::distance(first, iter) + 1) * 2 - 1; auto right = left + 1; bool heap_order = true; if (left < last) heap_order = heap_order && *iter > *left && is_heap_impl(first, left, last); if (right < last) heap_order = heap_order && *iter > *right && is_heap_impl(first, right, last); return heap_order; } template <class Iter> bool is_heap(Iter first, Iter iter) { return is_heap_impl(first, first, iter); } int main() { std::vector<int> vec(5); std::iota(vec.begin(), vec.end(), 1); ming::println(vec); // make heap // 5, 4, 3, 1, 2 std::make_heap(vec.begin(), vec.end()); ming::println(vec); // heap push // 6, 4, 5, 1, 2, 3 vec.push_back(6); ::push_heap(vec.begin(), vec.end()); assert((vec == std::vector<int>{6, 4, 5, 1, 2, 3} && "push_heap")); ming::println(vec); // heap pop // 5, 4, 3, 1, 2, 6 ::pop_heap(vec.begin(), vec.end()); assert((vec == std::vector<int>{5, 4, 3, 1, 2, 6} && "pop_heap")); ming::println(vec); // is_heap ::push_heap(vec.begin(), vec.end()); ming::println(vec); assert((::is_heap(vec.begin(), vec.end()))); // sort heap // 1, 2, 3, 4, 5, 6 ::sort_heap(vec.begin(), vec.end()); ming::println(vec); assert((std::is_sorted(vec.begin(), vec.end()))); return 0; }
[ "huanmingwong@163.com" ]
huanmingwong@163.com
f577d1429c8b72f661e131122e0865e9ab9fa204
87207ab418db4c8fb0474bfe2af736094f8b2866
/Chapter One/Matrices/Matrix Multiplication.cpp
882600c4f6b6e1d9f9663570920fd802589184f6
[]
no_license
saminwankwo/algorithms-data-structure-in-c
a8e5ec100c688e791d753089090421f99867d08e
8c037fcde70418571f99f2ddb05a2a6c779ed480
refs/heads/master
2020-06-11T20:04:38.487931
2019-06-27T09:54:19
2019-06-27T09:54:19
194,069,521
0
0
null
null
null
null
UTF-8
C++
false
false
801
cpp
#include <stdio.h> #include<conio.h> int main() { int n, i, j, k, A[10][10], B[10][10], C[10][10], sum = 0; printf("Enter the dimension of the matrix: "); scanf("%d", &n); printf("Enter the elements of matrix A\n"); for (i = 0; i < n; i++) for (j = 0; j < n; j++) scanf("%d", &A[i][j]); printf("Enter the elements of matrix B\n"); for (i = 0; i < n; i++) for (j = 0 ; j < n; j++) scanf("%d", &B[i][j]); printf("Product of entered Matrices:\n"); for (i = 0; i < n; i++) { for (j = 0 ; j < n; j++) { for(k = 0; k < n; k++){ sum = A[i][k] * B[k][j] + sum; } C[i][j] = sum; printf("%d\t", C[i][j]); } printf("\n\n"); } getch(); return 0; }
[ "nwankwosami@gmail.com" ]
nwankwosami@gmail.com
02066e9104d275e9f4f115fe29ce9211619fd5f6
926d4f1f74fc23a5f35b740a11b001d0346ee47a
/CalFp09/Graph.h
4a2c9d753bae616a856d830e56ce81537eced78f
[ "MIT" ]
permissive
GuilhermeJSilva/CAL-TP
0d218480b11ede2d41ef02676fdc030b6d043580
5e9dac1c56370a82d16f1633f03ec6302d81652d
refs/heads/master
2020-03-19T09:35:18.681656
2018-06-06T09:03:10
2018-06-06T09:03:10
136,301,056
0
0
null
null
null
null
UTF-8
C++
false
false
11,902
h
/* * Graph.h. * For implementation of the minimum cost flow algorithm. * See TODOs for code to add/adapt. * FEUP, CAL, 2017/18. */ #ifndef GRAPH_H_ #define GRAPH_H_ #include <vector> #include <queue> #include <limits> #include <iostream> #include "MutablePriorityQueue.h" using namespace std; constexpr auto INF = std::numeric_limits<double>::max(); template<class T> class Vertex; template<class T> class Edge; template<class T> class Graph; /* * ================================================================================================ * Class Vertex * ================================================================================================ */ template<class T> class Vertex { T info; vector<Edge<T> *> outgoing; vector<Edge<T> *> incoming; bool visited{}; // for path finding Edge<T> *path; // for path finding double dist{}; // for path finding int queueIndex = 0; // required by MutablePriorityQueue explicit Vertex<T>(T in); void addEdge(Edge<T> *e); bool operator<(Vertex<T> &vertex) const; // required by MutablePriorityQueue public: T getInfo() const; vector<Edge<T> *> getIncoming() const; vector<Edge<T> *> getOutgoing() const; friend class Graph<T>; friend class MutablePriorityQueue<Vertex<T>>; }; template<class T> Vertex<T>::Vertex(T in): info(in) {} template<class T> void Vertex<T>::addEdge(Edge<T> *e) { outgoing.push_back(e); e->dest->incoming.push_back(e); } template<class T> bool Vertex<T>::operator<(Vertex<T> &vertex) const { return this->dist < vertex.dist; } template<class T> T Vertex<T>::getInfo() const { return this->info; } template<class T> vector<Edge<T> *> Vertex<T>::getIncoming() const { return this->incoming; } template<class T> vector<Edge<T> *> Vertex<T>::getOutgoing() const { return this->outgoing; } /* ================================================================================================ * Class Edge * ================================================================================================ */ template<class T> class Edge { Vertex<T> *orig; Vertex<T> *dest; double capacity; double cost; double flow; Edge(Vertex<T> *o, Vertex<T> *d, double capacity, double cost = 0, double flow = 0); public: friend class Graph<T>; friend class Vertex<T>; double getFlow() const; }; template<class T> Edge<T>::Edge(Vertex<T> *o, Vertex<T> *d, double capacity, double cost, double flow): orig(o), dest(d), capacity(capacity), cost(cost), flow(flow) {} template<class T> double Edge<T>::getFlow() const { return this->flow; } /* ================================================================================================ * Class Graph * ================================================================================================ */ template<class T> class Graph { vector<Vertex<T> *> vertexSet; bool has_negative = false; void dijkstraShortestPath(Vertex<T> *s); void bellmanFordShortestPath(Vertex<T> *s); bool relax(Vertex<T> *v, Vertex<T> *w, Edge<T> *e, double residual, double cost); void resetFlows(); void reduceCosts(); bool findAugmentationPath(Vertex<T> *s, Vertex<T> *t); void testAndVisit(queue<Vertex<T> *> &q, Edge<T> *e, Vertex<T> *w, double residual); double findMinResidualAlongPath(Vertex<T> *s, Vertex<T> *t); void augmentFlowAlongPath(Vertex<T> *s, Vertex<T> *t, double f); void calculateShortestPath(Vertex<T> *s); public: Vertex<T> *findVertex(const T &inf) const; vector<Vertex<T> *> getVertexSet() const; Vertex<T> *addVertex(const T &in); Edge<T> *addEdge(const T &sourc, const T &dest, double capacity, double cost, double flow = 0); double getFlow(const T &sourc, const T &dest) const; void fordFulkerson(T source, T target); double minCostFlow(T source, T sink, double flow); }; template<class T> Vertex<T> *Graph<T>::addVertex(const T &in) { Vertex<T> *v = findVertex(in); if (v != nullptr) return v; v = new Vertex<T>(in); vertexSet.push_back(v); return v; } template<class T> Edge<T> *Graph<T>::addEdge(const T &sourc, const T &dest, double capacity, double cost, double flow) { auto s = findVertex(sourc); auto d = findVertex(dest); if (s == nullptr || d == nullptr) return nullptr; if (cost < 0) this->has_negative = true; auto *e = new Edge<T>(s, d, capacity, cost, flow); s->addEdge(e); return e; } template<class T> Vertex<T> *Graph<T>::findVertex(const T &inf) const { for (auto v : vertexSet) if (v->info == inf) return v; return nullptr; } template<class T> double Graph<T>::getFlow(const T &sourc, const T &dest) const { auto s = findVertex(sourc); auto d = findVertex(dest); if (s == nullptr || d == nullptr) return 0.0; for (auto e : s->outgoing) if (e->dest == d) return e->flow; return 0.0; } template<class T> vector<Vertex<T> *> Graph<T>::getVertexSet() const { return vertexSet; } /**************** Maximum Flow Problem ************/ /** * Finds the maximum flow in a graph using the Ford Fulkerson algorithm * (with the improvement of Edmonds-Karp). * Assumes that the graph forms a flow network from source vertex 's' * to sink vertex 't' (distinct vertices). * Receives as arguments the source and target vertices (identified by their contents). * The result is defined by the "flow" field of each edge. */ template<class T> void Graph<T>::fordFulkerson(T source, T target) { // Obtain the source (s) and target (t) vertices Vertex<T> *s = findVertex(source); Vertex<T> *t = findVertex(target); if (s == nullptr || t == nullptr || s == t) throw "Invalid source and/or target vertex"; // Apply algorithm as in slides resetFlows(); while (findAugmentationPath(s, t)) { double f = findMinResidualAlongPath(s, t); augmentFlowAlongPath(s, t, f); } } template<class T> void Graph<T>::resetFlows() { for (auto v : vertexSet) for (auto e: v->outgoing) e->flow = 0; } template<class T> bool Graph<T>::findAugmentationPath(Vertex<T> *s, Vertex<T> *t) { for (auto v : vertexSet) v->visited = false; s->visited = true; queue<Vertex<T> *> q; q.push(s); while (!q.empty() && !t->visited) { auto v = q.front(); q.pop(); for (auto e: v->outgoing) testAndVisit(q, e, e->dest, e->capacity - e->flow); for (auto e: v->incoming) testAndVisit(q, e, e->orig, e->flow); } return t->visited; } /** * Auxiliary function used by findAugmentationPath. */ template<class T> void Graph<T>::testAndVisit(queue<Vertex<T> *> &q, Edge<T> *e, Vertex<T> *w, double residual) { // TODO: adapt in order to use only edges with null cost if (!w->visited && residual > 0 && e->cost == 0) { w->visited = true; w->path = e; q.push(w); } } template<class T> double Graph<T>::findMinResidualAlongPath(Vertex<T> *s, Vertex<T> *t) { double f = INF; for (auto v = t; v != s;) { auto e = v->path; if (e->dest == v) { f = min(f, e->capacity - e->flow); v = e->orig; } else { f = min(f, e->flow); v = e->dest; } } return f; } template<class T> void Graph<T>::augmentFlowAlongPath(Vertex<T> *s, Vertex<T> *t, double f) { for (auto v = t; v != s;) { auto e = v->path; if (e->dest == v) { e->flow += f; v = e->orig; } else { e->flow -= f; v = e->dest; } } } /**************** Minimum Cost Flow Problem ************/ /** * Determines the minimum cost flow in a flow network. * Receives as arguments the source and sink vertices (identified by their info), * and the intended flow. * Returns the calculated minimum cost for delivering the intended flow (or the highest * possible flow, if the intended flow is higher than supported by the network). * The calculated flow in each edge can be consulted with the "getFlow" function. * Notice: Currently, the costs of the edges are modified by the algorithm. */ template<class T> double Graph<T>::minCostFlow(T source, T sink, double flow) { Vertex<T> *s = findVertex(source); Vertex<T> *t = findVertex(sink); if (s == nullptr || t == nullptr || s == t) throw "Invalid source and/or target vertex"; double cost = 0.0; double total_cost = 0.0; double total_flow = 0; resetFlows(); this->calculateShortestPath(s); this->reduceCosts(); while (findAugmentationPath(s, t) && total_flow < flow) { //cout << total_flow << endl; cost += t->dist; double f ; //= min(findMinResidualAlongPath(s, t), flow - total_flow); while((f = min(findMinResidualAlongPath(s, t), flow - total_flow)) > 0) { total_cost += f * cost; total_flow += f; augmentFlowAlongPath(s, t, f); } this->calculateShortestPath(s); this->reduceCosts(); } return total_cost; } /** * Computes the shortest distance (with minimum cost) from "s" to all other vertices * in the residuals graph, using only edges with non-null residuals, * based on the Dijkstra algorithm. * The result is indicated by the field "dist" of each vertex. */ template<class T> void Graph<T>::dijkstraShortestPath(Vertex<T> *s) { for (auto v : vertexSet) v->dist = INF; s->dist = 0; MutablePriorityQueue<Vertex<T>> q; q.insert(s); while (!q.empty()) { auto v = q.extractMin(); for (auto e : v->outgoing) if (relax(v, e->dest, e, e->capacity - e->flow, e->cost)) q.insertOrDecreaseKey(e->dest); for (auto e : v->incoming) if (relax(v, e->orig, e, e->flow, -e->cost)) q.insertOrDecreaseKey(e->orig); } } /** * Computes the shortest distance (with minimum cost) from "s" to all other vertices * in the residuals graph, using only edges with non-null residuals, * based on the Bellman-Ford algorithm. * The result is indicated by the field "dist" of each vertex. */ template<class T> void Graph<T>::bellmanFordShortestPath(Vertex<T> *s) { for (auto v : vertexSet) v->dist = INF; s->dist = 0; for (unsigned i = 1; i < vertexSet.size(); i++) for (auto v: vertexSet) { for (auto e : v->outgoing) relax(v, e->dest, e, e->capacity - e->flow, e->cost); for (auto e : v->incoming) relax(v, e->orig, e, e->flow, -e->cost); } } /** * Auxiliary function used by Dijkstra and Bellman-Ford algorithms. * Analyzes edge (v, w) with a given residual and cost. */ template<class T> bool Graph<T>::relax(Vertex<T> *v, Vertex<T> *w, Edge<T> *e, double residual, double cost) { if (residual > 0 && v->dist + cost < w->dist) { w->dist = v->dist + cost; w->path = e; return true; } else return false; } /** * Reduces edges' costs, based on the vertices potentials * (shortest distances to 's', when not infinite). */ template<class T> void Graph<T>::reduceCosts() { // TODO, implement based on slides for (Vertex<T> *v :this->vertexSet) { for (Edge<T> *e : v->getOutgoing()) { if(v->dist != INF && e->dest->dist != INF) e->cost += v->dist - e->dest->dist; } } //std::cout << "END" << std::endl; this->has_negative = false; } template<class T> void Graph<T>::calculateShortestPath(Vertex<T> *s) { if (has_negative) { this->bellmanFordShortestPath(s); } else this->dijkstraShortestPath(s); } #endif /* GRAPH_H_ */
[ "guilhermejosesilva@gmail.com" ]
guilhermejosesilva@gmail.com
2fa9c2c94d979963ac5c85e2cde0a00d4ae98dee
350e90d5b03dfc98da591433ee5f66e139baccd9
/BattleTank/BattleTank/Source/BattleTank/Projectile.cpp
fab5622277df8a11755059c64cbe9f9a45d9f63a
[]
no_license
dodviper/UnrealCourse
9b76040bf5f83099aeb4164bb2b1f41ec9410180
0c70cbf8b4bba467996b9a1a6a00b096278cab8a
refs/heads/master
2020-04-01T15:03:50.332391
2018-10-21T20:37:25
2018-10-21T20:37:25
153,319,154
0
0
null
null
null
null
UTF-8
C++
false
false
829
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "Projectile.h" // Sets default values AProjectile::AProjectile() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(FName("Projectile Movement")); ProjectileMovement->bAutoActivate = false; } // Called when the game starts or when spawned void AProjectile::BeginPlay() { Super::BeginPlay(); } // Called every frame void AProjectile::Tick(float DeltaTime) { Super::Tick(DeltaTime); } void AProjectile::LaunchProjectile(float Speed) { ProjectileMovement->SetVelocityInLocalSpace(FVector::ForwardVector * Speed); ProjectileMovement->Activate(); }
[ "konviktor93@gmail.com" ]
konviktor93@gmail.com
8f83a41dc438c39bd0b4e41015529fff7707536c
8970a04a29251db4cc6cbdf37f431c4a9bf2378e
/hardware/hardware.ino
5acddfd435c2223b45a404a08c6d6bf36eb2872f
[]
no_license
sparkydd3/Automatic-Dog-Door-Opener
7ac95d2ec764a6b560df6a96c4aaa0f62b812f83
94c276df0e02a4229e24ae3a5353003230194414
refs/heads/master
2021-05-30T03:20:00.869704
2015-12-27T21:19:19
2015-12-27T21:26:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,771
ino
int door_pin = 12; int bell_pin = 11; int led_pin = 13; boolean door_on = false; boolean bell_on = false; boolean door_ready = true; unsigned long door_on_time; unsigned long bell_on_time; unsigned long door_delay = 1000UL; unsigned long bell_delay = 500UL; unsigned long door_sleep = 15000UL; void setup() { // start serial port at 9600 bps: Serial.begin(9600); pinMode(door_pin, OUTPUT); pinMode(bell_pin, OUTPUT); pinMode(led_pin, OUTPUT); digitalWrite(led_pin, LOW); digitalWrite(door_pin, HIGH); digitalWrite(bell_pin, HIGH); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } } void loop() { if (Serial.available() > 0) { char inByte = Serial.read(); if(inByte == 'd'){ if(!door_ready){ Serial.write('w'); } else { door_ready = false; door_on = true; door_on_time = millis(); digitalWrite(led_pin, HIGH); digitalWrite(door_pin, LOW); Serial.write('r'); } Serial.flush(); } if(inByte == 'b'){ if(bell_on){ Serial.write('w'); } else { bell_on = true; bell_on_time = millis(); digitalWrite(bell_pin, LOW); Serial.write('r'); } Serial.flush(); } } unsigned long current_time = millis(); if(bell_on && (unsigned long)(current_time - bell_on_time) >= bell_delay){ bell_on = false; digitalWrite(bell_pin, HIGH); } if(door_on && (unsigned long)(current_time - door_on_time) >= door_delay){ door_on = false; digitalWrite(door_pin, HIGH); } if(!door_ready && (unsigned long)(current_time - door_on_time) >= door_sleep){ door_ready = true; digitalWrite(led_pin, LOW); } }
[ "dengmartin@hotmail.com" ]
dengmartin@hotmail.com
d1fc44e58196185d6aea4ff8c59840bdf10b8f87
aca4214cbe2c766dd32c1ad659b38e6fb956ded4
/ash/display/display_configuration_controller.cc
7f9302ab4ce76f7707319044b54bd668b909298e
[ "BSD-3-Clause" ]
permissive
weiliangc/chromium
5b04562d1c3ae93d4ab56872fcb728e74129bbb7
357396ffe3cc7ace113783f25e088d08e615b08b
refs/heads/master
2022-11-18T01:01:44.411877
2016-12-19T18:39:38
2016-12-19T18:42:00
71,932,761
1
0
null
2016-10-25T19:44:10
2016-10-25T19:44:10
null
UTF-8
C++
false
false
6,021
cc
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/display/display_configuration_controller.h" #include "ash/display/display_animator.h" #include "ash/display/display_util.h" #include "ash/rotator/screen_rotation_animator.h" #include "base/time/time.h" #include "ui/display/display_layout.h" #include "ui/display/manager/display_manager.h" #if defined(OS_CHROMEOS) #include "ash/display/display_animator_chromeos.h" #include "base/sys_info.h" #include "grit/ash_strings.h" #include "ui/base/l10n/l10n_util.h" #endif namespace { // Specifies how long the display change should have been disabled // after each display change operations. // |kCycleDisplayThrottleTimeoutMs| is set to be longer to avoid // changing the settings while the system is still configurating // displays. It will be overriden by |kAfterDisplayChangeThrottleTimeoutMs| // when the display change happens, so the actual timeout is much shorter. const int64_t kAfterDisplayChangeThrottleTimeoutMs = 500; const int64_t kCycleDisplayThrottleTimeoutMs = 4000; const int64_t kSetPrimaryDisplayThrottleTimeoutMs = 500; } // namespace namespace ash { class DisplayConfigurationController::DisplayChangeLimiter { public: DisplayChangeLimiter() : throttle_timeout_(base::Time::Now()) {} void SetThrottleTimeout(int64_t throttle_ms) { throttle_timeout_ = base::Time::Now() + base::TimeDelta::FromMilliseconds(throttle_ms); } bool IsThrottled() const { return base::Time::Now() < throttle_timeout_; } private: base::Time throttle_timeout_; DISALLOW_COPY_AND_ASSIGN(DisplayChangeLimiter); }; DisplayConfigurationController::DisplayConfigurationController( display::DisplayManager* display_manager, WindowTreeHostManager* window_tree_host_manager) : display_manager_(display_manager), window_tree_host_manager_(window_tree_host_manager), weak_ptr_factory_(this) { window_tree_host_manager_->AddObserver(this); #if defined(OS_CHROMEOS) if (base::SysInfo::IsRunningOnChromeOS()) limiter_.reset(new DisplayChangeLimiter); display_animator_.reset(new DisplayAnimatorChromeOS()); #endif } DisplayConfigurationController::~DisplayConfigurationController() { window_tree_host_manager_->RemoveObserver(this); } void DisplayConfigurationController::SetDisplayLayout( std::unique_ptr<display::DisplayLayout> layout, bool user_action) { if (user_action && display_animator_) { display_animator_->StartFadeOutAnimation( base::Bind(&DisplayConfigurationController::SetDisplayLayoutImpl, weak_ptr_factory_.GetWeakPtr(), base::Passed(&layout))); } else { SetDisplayLayoutImpl(std::move(layout)); } } void DisplayConfigurationController::SetMirrorMode(bool mirror, bool user_action) { if (display_manager_->num_connected_displays() > 2) { #if defined(OS_CHROMEOS) if (user_action) { ShowDisplayErrorNotification( l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED), false); } #endif return; } if (display_manager_->num_connected_displays() <= 1 || display_manager_->IsInMirrorMode() == mirror || IsLimited()) { return; } SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); if (user_action && display_animator_) { display_animator_->StartFadeOutAnimation( base::Bind(&DisplayConfigurationController::SetMirrorModeImpl, weak_ptr_factory_.GetWeakPtr(), mirror)); } else { SetMirrorModeImpl(mirror); } } void DisplayConfigurationController::SetDisplayRotation( int64_t display_id, display::Display::Rotation rotation, display::Display::RotationSource source, bool user_action) { ash::ScreenRotationAnimator screen_rotation_animator(display_id); if (user_action && screen_rotation_animator.CanAnimate()) screen_rotation_animator.Rotate(rotation, source); else display_manager_->SetDisplayRotation(display_id, rotation, source); } void DisplayConfigurationController::SetPrimaryDisplayId(int64_t display_id, bool user_action) { if (display_manager_->GetNumDisplays() <= 1 || IsLimited()) return; SetThrottleTimeout(kSetPrimaryDisplayThrottleTimeoutMs); if (user_action && display_animator_) { display_animator_->StartFadeOutAnimation( base::Bind(&DisplayConfigurationController::SetPrimaryDisplayIdImpl, weak_ptr_factory_.GetWeakPtr(), display_id)); } else { SetPrimaryDisplayIdImpl(display_id); } } void DisplayConfigurationController::OnDisplayConfigurationChanged() { // TODO(oshima): Stop all animations. SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); } // Protected void DisplayConfigurationController::ResetAnimatorForTest() { if (!display_animator_) return; display_animator_.reset(); } // Private void DisplayConfigurationController::SetThrottleTimeout(int64_t throttle_ms) { if (limiter_) limiter_->SetThrottleTimeout(throttle_ms); } bool DisplayConfigurationController::IsLimited() { return limiter_ && limiter_->IsThrottled(); } void DisplayConfigurationController::SetDisplayLayoutImpl( std::unique_ptr<display::DisplayLayout> layout) { // TODO(oshima/stevenjb): Add support for 3+ displays. display_manager_->SetLayoutForCurrentDisplays(std::move(layout)); if (display_animator_) display_animator_->StartFadeInAnimation(); } void DisplayConfigurationController::SetMirrorModeImpl(bool mirror) { display_manager_->SetMirrorMode(mirror); if (display_animator_) display_animator_->StartFadeInAnimation(); } void DisplayConfigurationController::SetPrimaryDisplayIdImpl( int64_t display_id) { window_tree_host_manager_->SetPrimaryDisplayId(display_id); if (display_animator_) display_animator_->StartFadeInAnimation(); } } // namespace ash
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
ad33ee9c343ad1b2bb2230fe48d2a838c5771a52
543ecda34bb0ddf987fbaed0a1851793b1853f67
/inherit.cpp
fd75cc5a325c21c00f11302fe50c6df5a92f2060
[]
no_license
eunhyulkim/cppp
c3825923583c95cf612cf49440335bc88383a98a
4a7e8d3bc17f760885ab8b043b8320541d6d58d0
refs/heads/master
2023-08-06T17:00:25.125457
2021-09-17T14:27:52
2021-09-17T14:27:52
286,070,740
8
0
null
null
null
null
UTF-8
C++
false
false
7,643
cpp
#include "cppp.hpp" namespace { class Vars { public: static int count; std::string type; std::string name; ~Vars(); }; Vars::~Vars() { Vars::count = 0; } int Vars::count = 0; } namespace { void input_base_header(std::string base, std::string derive, \ std::string& dline, std::istringstream& dss, std::ofstream& out) { std::string word = std::string("class ") + derive; get::sstream_with_target(dss, dline, word, out, true); out << "# include \"" << base << ".hpp" << "\"" << std::endl << std::endl; out << word << " : public " << base << std::endl; } void input_inherit_function(std::istringstream& bss, std::istringstream& dss, \ std::string& bline, std::string& dline, std::ofstream& out) { get::sstream_with_target(dss, dline, "~", out, true); get::sstream_with_target(bss, bline, "~", out, false); bool first_inherit = true; out << dline << std::endl; while (std::getline(bss, bline)) { if (bline[0] == '}') break ; if (bline.size() < 9 || bline.substr(2, 7) != "virtual") continue; if (first_inherit) { out << std::endl; out << "\t\t/* inherit overload function */" << std::endl; first_inherit = false; } if (bline.find(" = ") != std::string::npos) { int idx = bline.find("virtual"); int lidx = bline.find(" = "); out << "\t\t"; out << bline.substr(idx, lidx - idx); out << ";" << std::endl; } else out << "\t\t" << bline.substr(bline.find("virtual")) << std::endl; } } void inherit_header_file(std::string base, std::string derive, \ std::string bstring, std::string dstring, std::ofstream& out) { std::istringstream bss(bstring); std::istringstream dss(dstring); std::string bline, dline; input_base_header(base, derive, dline, dss, out); if (bstring.find("public:") == std::string::npos) return ; input_inherit_function(bss, dss, bline, dline, out); get::sstream_with_target(dss, dline, "#endif", out, true); out << dline << std::endl; } void convert_variable(std::string line, Vars *vars) { std::string word; line = line.substr(line.find("(") + 1); line = line.substr(0, line.find(")")); while (!line.empty()) { if (line.find(",") != std::string::npos) { int idx = line.find(","); word = line.substr(0, idx); line = line.substr(idx + 2); } else { word = line; line = ""; } int idx = word.rfind(" "); if (word[idx + 1] == '*') { vars[Vars::count].type = word.substr(0, idx + 2); vars[Vars::count].name = word.substr(idx + 2); } else { vars[Vars::count].type = word.substr(0, idx); vars[Vars::count].name = word.substr(idx + 1); } Vars::count += 1; } return ; } Vars *get_vars_from_base_constructor(std::string bstring, std::string base) { std::istringstream ss(bstring); std::string line, bword, nword; std::ofstream dummy; Vars *vars = new Vars[20]; if (bstring.find("public:") != std::string::npos) get::sstream_with_target(ss, line, "public:", dummy, false); else { delete[] vars; throw ("Failed to find constructor variables in public areas."); } bword = base + "()"; nword = "const &" + base; while (std::getline(ss, line)) { if (line.empty()) continue; if (line[0] == '{') break ; if (line.substr(2, base.size()) != base) continue; if (line.find(nword) != std::string::npos) continue; if (line.substr(2, base.size() + 2) == bword) continue; convert_variable(line, vars); break ; } return (vars); } void update_constructor_initialize_list(std::string base, std::string& sstring, Vars *vars) { std::string find_string = "/* constructor initialize list */"; int idx = sstring.find(find_string); if (idx == -1) return ; std::string new_param = base + "("; int count = 0; for (int i = 0; i < Vars::count; i++) { if (count != 0) new_param.append(", "); count += 1; new_param.append(vars[i].name); } new_param.append("), "); sstring.insert(idx, new_param); return ; } void update_copy_constructor_initialize_list(std::string base, std::string& sstring) { std::string find_string = "/* copy-constructor initialize list */"; int idx = sstring.find(find_string); if (idx == -1) return ; std::string new_param = base + "(copy), "; sstring.insert(idx, new_param); return ; } void update_overload_operator(std::string base, std::string& sstring) { std::string find_string = "/* overload= code */"; int idx = sstring.find(find_string); if (idx == -1) return ; idx -= 1; std::string new_param = "\tthis->" + base + "::operator=(obj);\n"; sstring.insert(idx, new_param); return ; } void get_func_info(std::string& line, std::string& arg, std::string& body) { int sep = line.find(" "); int cidx = line.find("const"); if (cidx != -1 && cidx < static_cast<int>(line.find("("))) sep += (line.substr(sep + 1).find(" ") + 1); if (line[sep] + 1 != '*') { arg = line.substr(0, sep); body = line.substr(sep + 1); } else { arg = line.substr(0, sep + 2); body = line.substr(sep + 2); } return ; } void update_overload_function(std::string derive, std::string& bstring, std::string& sstring) { std::istringstream ss(bstring); std::string find_string = "/* inherit overload function */"; std::string line, arg, body, new_param; std::ofstream dummy; int idx = bstring.find(find_string); if (idx == -1) return ; get::sstream_with_target(ss, line, "/* inherit overload function */", dummy, false); while (std::getline(ss, line)) { if (line.empty() || line[0] == '}') break ; if (line.find("/*") != std::string::npos) break ; line = line.substr(10, line.size() - 11); get_func_info(line, arg, body); new_param.push_back('\n'); new_param.append(arg + "\n"); new_param.append(derive + "::" + body + " {\n"); new_param.append("\t/* function body */\n"); new_param.append("}\n"); } idx = sstring.find("GETTER"); if (idx != -1) sstring.insert(idx - 119, new_param); return ; } void inherit_source_file(std::string base, std::string derive, std::string bstring, \ std::string hstring, std::string sstring, std::ofstream& out) { Vars *vars = get_vars_from_base_constructor(bstring, base); update_constructor_initialize_list(base, sstring, vars); update_copy_constructor_initialize_list(base, sstring); update_overload_operator(base, sstring); update_overload_function(derive, hstring, sstring); out << sstring << std::endl; delete[] vars; } } namespace inherit { void main(int ac, char *av[]) { if (ac < 4) throw ("The inherit command requires base and derived class separately."); reset::backup(ac, av, CMD_INHERIT); std::string base = std::string(av[2]); std::string bstring = get::string_from_file(base, CMD_START, PATH_HEADER); for (int i = 3; i < ac; i++) { std::string derive = std::string(av[i]); std::string dstring = get::string_from_file(derive, CMD_START, PATH_HEADER); std::string sstring = get::string_from_file(derive, CMD_START, PATH_SOURCE); if (bstring.empty() || dstring.empty()) throw ("The file is empty or did not open normally."); std::ofstream hout(get::path(derive, CMD_START, PATH_HEADER), std::ofstream::trunc); std::ofstream sout(get::path(derive, CMD_START, PATH_SOURCE), std::ofstream::trunc); inherit_header_file(base, derive, bstring, dstring, hout); hout.close(); std::string hstring = get::string_from_file(derive, CMD_START, PATH_HEADER); inherit_source_file(base, derive, bstring, hstring, sstring, sout); sout.close(); } } }
[ "valhalla.host@gmail.com" ]
valhalla.host@gmail.com
0c41a17e39d9fa4457b765d24653ba61f2b5e21b
e9025d80026f7d00e0fd69e0ee7e0f97533bd630
/educational/round48/let.cpp
ac091e92a0a82904abca3f05efcfddb72766b95d
[]
no_license
rishup132/Codeforces-Solutions
66170b368d851b7076c03f42c9463a2342bac5df
671d16b0beec519b99fc79058ab9035c6f956670
refs/heads/master
2020-04-12T04:32:10.451666
2019-03-22T14:04:31
2019-03-22T14:04:31
162,298,347
0
0
null
null
null
null
UTF-8
C++
false
false
1,954
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n,t; cin >> n >> t; string s1,s2; cin >> s1 >> s2; int c1,c2; c1 = c2 = 0; for(int i=0;i<n;i++) { if(s1[i] == s2[i]) c1++; else c2++; } int min = c2%2 == 0 ? c2/2 : c2/2+1; if(t < min) { cout << -1 << endl; return 0; } //cout << t << c1 << c2 << endl; if(t >= c2) { string ans = ""; t -= c2; c1 -= t; for(int i=0;i<n;i++) { if(c1 > 0 && s1[i] == s2[i]) { ans += s1[i]; c1--; } else { map <char,int> m; m[s1[i]]++; m[s2[i]]++; for(char x='a';x <= 'z';x++) { if(m[x] == 0) { ans += x; break; } } } } cout << ans << endl; return 0; } int t1,t2; t1 = c2/2; c2 = c2 - t1*2; t -= min; t1 -= t; t2 = t1; c2 += 2*t; string ans = ""; for(int i=0;i<n;i++) { if(s1[i] == s2[i]) ans += s1[i]; else { if(t1 > 0) { ans += s1[i]; t1--; } else if(t2 > 0) { ans += s2[i]; t2--; } else { map <char,int> m; m[s1[i]]++; m[s2[i]]++; for(char x='a';x <= 'z';x++) { if(m[x] == 0) { ans += x; break; } } } } } cout << ans << endl; }
[ "rishupgupta132@gmail.com" ]
rishupgupta132@gmail.com
63c4aa16dae347c5a75c64ed450530d4268d1c74
065b3ddfb867c49b038dcee04dcba877cc3c6071
/G9/src/cef-3.2743.2.15.5/src/cef/libcef/browser/resource_dispatcher_host_delegate.cc
f21862312d99e17d08be3fe9b4fe141101c36642
[ "BSD-3-Clause" ]
permissive
Eduard111/r7oss
9804727fb91552fe4cec30bba164988a370ad509
fb30ac72c9e541f0eb8ef24a2899cd17e306733b
refs/heads/master
2020-03-19T11:03:30.878007
2018-01-18T17:12:21
2018-01-18T17:12:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,844
cc
// Copyright 2015 The Chromium Embedded Framework Authors. // Portions copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "libcef/browser/resource_dispatcher_host_delegate.h" #include <stdint.h> #include <utility> #include "libcef/browser/browser_host_impl.h" #include "libcef/browser/extensions/api/streams_private/streams_private_api.h" #include "libcef/browser/origin_whitelist_impl.h" #include "libcef/browser/resource_context.h" #include "libcef/browser/thread_util.h" #include "libcef/common/extensions/extensions_util.h" #include "base/guid.h" #include "base/memory/scoped_vector.h" #include "build/build_config.h" #include "content/public/browser/plugin_service.h" #include "content/public/browser/plugin_service_filter.h" #include "content/public/browser/resource_request_info.h" #include "content/public/browser/stream_info.h" #include "content/public/common/resource_response.h" #include "content/public/common/webplugininfo.h" #include "extensions/common/constants.h" #include "extensions/common/extension.h" #include "extensions/common/manifest_handlers/mime_types_handler.h" #include "net/http/http_response_headers.h" #include "net/url_request/url_request.h" namespace { void SendExecuteMimeTypeHandlerEvent( std::unique_ptr<content::StreamInfo> stream, int64_t expected_content_size, int render_process_id, int render_frame_id, const std::string& extension_id, const std::string& view_id, bool embedded) { CEF_REQUIRE_UIT(); CefRefPtr<CefBrowserHostImpl> browser = CefBrowserHostImpl::GetBrowserForFrame(render_process_id, render_frame_id); if (!browser.get()) return; content::WebContents* web_contents = browser->web_contents(); if (!web_contents) return; content::BrowserContext* browser_context = web_contents->GetBrowserContext(); extensions::StreamsPrivateAPI* streams_private = extensions::StreamsPrivateAPI::Get(browser_context); if (!streams_private) return; // A |tab_id| value of -1 disables zoom management in the PDF extension. // Otherwise we need to implement chrome.tabs zoom handling. See // chrome/browser/resources/pdf/browser_api.js. int tab_id = -1; streams_private->ExecuteMimeTypeHandler( extension_id, tab_id, std::move(stream), view_id, expected_content_size, embedded, render_process_id, render_frame_id); } } // namespace CefResourceDispatcherHostDelegate::CefResourceDispatcherHostDelegate() { } CefResourceDispatcherHostDelegate::~CefResourceDispatcherHostDelegate() { } bool CefResourceDispatcherHostDelegate::HandleExternalProtocol( const GURL& url, int child_id, const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture) { if (CEF_CURRENTLY_ON_UIT()) { content::WebContents* web_contents = web_contents_getter.Run(); if (web_contents) { CefRefPtr<CefBrowserHostImpl> browser = CefBrowserHostImpl::GetBrowserForContents(web_contents); if (browser.get()) browser->HandleExternalProtocol(url); } } else { CEF_POST_TASK(CEF_UIT, base::Bind(base::IgnoreResult(&CefResourceDispatcherHostDelegate:: HandleExternalProtocol), base::Unretained(this), url, child_id, web_contents_getter, is_main_frame, page_transition, has_user_gesture)); } return false; } // Implementation based on // ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream. bool CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( net::URLRequest* request, const base::FilePath& plugin_path, const std::string& mime_type, GURL* origin, std::string* payload) { if (!extensions::ExtensionsEnabled()) return false; const content::ResourceRequestInfo* info = content::ResourceRequestInfo::ForRequest(request); CefResourceContext* context = static_cast<CefResourceContext*>(info->GetContext()); bool profile_is_off_the_record = context->IsOffTheRecord(); const scoped_refptr<const extensions::InfoMap> extension_info_map( context->GetExtensionInfoMap()); std::vector<std::string> whitelist = MimeTypesHandler::GetMIMETypeWhitelist(); // Go through the white-listed extensions and try to use them to intercept // the URL request. for (const std::string& extension_id : whitelist) { const extensions::Extension* extension = extension_info_map->extensions().GetByID(extension_id); // The white-listed extension may not be installed, so we have to NULL check // |extension|. if (!extension || (profile_is_off_the_record && !extension_info_map->IsIncognitoEnabled(extension_id))) { continue; } MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); if (!handler) continue; // If a plugin path is provided then a stream is being intercepted for the // mimeHandlerPrivate API. Otherwise a stream is being intercepted for the // streamsPrivate API. if (!plugin_path.empty()) { if (handler->HasPlugin() && plugin_path == handler->GetPluginPath()) { StreamTargetInfo target_info; *origin = extensions::Extension::GetBaseURLFromExtensionId(extension_id); target_info.extension_id = extension_id; target_info.view_id = base::GenerateGUID(); *payload = target_info.view_id; stream_target_info_[request] = target_info; return true; } } else { if (!handler->HasPlugin() && handler->CanHandleMIMEType(mime_type)) { StreamTargetInfo target_info; *origin = extensions::Extension::GetBaseURLFromExtensionId(extension_id); target_info.extension_id = extension_id; stream_target_info_[request] = target_info; return true; } } } return false; } // Implementation based on // ChromeResourceDispatcherHostDelegate::OnStreamCreated. void CefResourceDispatcherHostDelegate::OnStreamCreated( net::URLRequest* request, std::unique_ptr<content::StreamInfo> stream) { DCHECK(extensions::ExtensionsEnabled()); const content::ResourceRequestInfo* info = content::ResourceRequestInfo::ForRequest(request); std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = stream_target_info_.find(request); CHECK(ix != stream_target_info_.end()); bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; CEF_POST_TASK(CEF_UIT, base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), request->GetExpectedContentSize(), info->GetChildID(), info->GetRenderFrameID(), ix->second.extension_id, ix->second.view_id, embedded)); stream_target_info_.erase(request); } void CefResourceDispatcherHostDelegate::OnRequestRedirected( const GURL& redirect_url, net::URLRequest* request, content::ResourceContext* resource_context, content::ResourceResponse* response) { const GURL& active_url = request->url(); if (active_url.is_valid() && redirect_url.is_valid() && active_url.GetOrigin() != redirect_url.GetOrigin() && HasCrossOriginWhitelistEntry(active_url, redirect_url)) { if (!response->head.headers.get()) response->head.headers = new net::HttpResponseHeaders(std::string()); // Add CORS headers to support XMLHttpRequest redirects. response->head.headers->AddHeader("Access-Control-Allow-Origin: " + active_url.scheme() + "://" + active_url.host()); response->head.headers->AddHeader("Access-Control-Allow-Credentials: true"); } }
[ "fabien.masson@cpexterne.org" ]
fabien.masson@cpexterne.org
4ce5a33657b68114e6eda7a0a4ef73a6ceead4a1
72f9098e15d8232337c4cff6e46a511885572629
/examples/window_app_runtime/src/file_watch.hpp
a5eeb3b90c8f718b8816e9fa59c5338eb91d9fdc
[ "MIT" ]
permissive
VulkanWorks/ElementalDraw-canvas-gui
2947acdf01cd9a5bc3a804b2515f56121c099d74
49f8f56c77c6525ee51f4019d02be395717b4a85
refs/heads/master
2023-07-28T11:58:13.958443
2021-09-05T18:20:14
2021-09-05T18:20:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
824
hpp
#ifndef FILE_WATCH_HPP #define FILE_WATCH_HPP #include <string> #include <thread> #include <map> #include <atomic> class IReloadableFile { public: virtual void onReload() = 0; }; class FileWatch { public: struct TimeStampedFile { int64_t timestamp; IReloadableFile* file; }; static void addToWatchList(std::string filePath, IReloadableFile* file); static void clearWatchList(); static void startCheckInterval(unsigned int interval = 1000); static void stopCheckInterval(); private: static std::atomic<bool> _checking; static std::atomic<bool> _shouldRun; static std::thread _timeThread; //static std::thread _workThread; static std::map<std::string, TimeStampedFile> _watchList; static void checkValidity(); private: }; #endif // FILE_WATCH_HPP
[ "Haeri@users.noreply.github.com" ]
Haeri@users.noreply.github.com
97102d6b4a9edf71ce4ed786e31c6b54f037d5f9
cc799cb41ba0f736a9611eafd4ad06a0767fd102
/CncControlerGui/ArduinoData.cpp
9d9f50fbc6f51dd04539f97e3da73da5b853659f
[]
no_license
HackiWimmer/cnc
8cbfe5f5b9b39d96c9ea32da4adcb89f96ec1008
329278bbed7b4a10407e6ddb1c135366f3ef8537
refs/heads/master
2023-01-08T01:39:54.521532
2023-01-01T15:48:06
2023-01-01T15:48:06
85,393,224
3
2
null
2017-03-27T18:06:19
2017-03-18T10:30:06
C++
UTF-8
C++
false
false
7,582
cpp
#include <cstring> #include <wx/debug.h> #include <wx/string.h> #include "SerialThread.h" #include "ArduinoData.h" //////////////////////////////////////////////////////////////////// AE::TransferData::TransferData() //////////////////////////////////////////////////////////////////// { for (auto i=minPinIndex; i<=maxPinIndex; i++) { PinData& p = pins[i]; p.type = '\0'; p.name = -1; p.name = -1; p.mode = '\0'; p.value = -1; } } //////////////////////////////////////////////////////////////////// AE::TransferData::~TransferData() { //////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////// bool AE::TransferData::isSomethingChanged(const TransferData& ref) { //////////////////////////////////////////////////////////////////// return std::memcmp(this, &(ref), sizeof(TransferData)) != 0; } //////////////////////////////////////////////////////////////////// AE::ArduinoData::ArduinoData() : pins () , exterConfig () , traceInfo () //////////////////////////////////////////////////////////////////// { unsigned int counter = 0; for ( int i = minAPinIndex; i <= maxAPinIndex; i++) pins[(AE::PinName)i] = PinData('A', counter++, (AE::PinName)i); for ( int i = minDPinIndex; i <= maxDPinIndex; i++) pins[(AE::PinName)i] = PinData('D', (AE::PinName)i, (AE::PinName)i); } //////////////////////////////////////////////////////////////////// AE::ArduinoData::~ArduinoData() { //////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////// void AE::ArduinoData::pinMode(AE::PinName pin, AE::PinMode pm) { //////////////////////////////////////////////////////////////////// char mode = '\0'; switch ( pm ) { case PM_INPUT: mode = 'I'; break; case PM_OUTPUT: mode = 'O'; break; case PM_INPUT_PULLUP: mode = 'P'; break; } auto it = pins.find(pin); if ( it != pins.end() ) it->second.mode = mode; } //////////////////////////////////////////////////////////////////// void AE::ArduinoData::digitalWrite(unsigned int pin, bool pl) { //////////////////////////////////////////////////////////////////// if ( isPin(pin ) == false ) return; PinLevel x = pl ? PL_HIGH : PL_LOW; digitalWrite((PinName)pin, x); } //////////////////////////////////////////////////////////////////// void AE::ArduinoData::digitalWrite(AE::PinName pin, AE::PinLevel pl) { //////////////////////////////////////////////////////////////////// auto it = pins.find(pin); if ( it != pins.end() ) it->second.value = pl == PL_LOW ? 0 : 1; } //////////////////////////////////////////////////////////////////// AE::PinLevel AE::ArduinoData::digitalRead(AE::PinName pin) { //////////////////////////////////////////////////////////////////// auto it = pins.find(pin); if ( it != pins.end() ) return it->second.value == 0 ? PL_LOW : PL_HIGH; return PL_LOW; } //////////////////////////////////////////////////////////////////// uint16_t AE::ArduinoData::analogRead(PinName pin) { //////////////////////////////////////////////////////////////////// if ( isAnalogPin(pin) == true ) { auto it = pins.find(pin); if ( it != pins.end() ) { const int val = it->second.value; return val >=0 && val <=1023 ? val : 0; } } return 0; } //////////////////////////////////////////////////////////////////// void AE::ArduinoData::analogWrite(PinName pin, int value) { //////////////////////////////////////////////////////////////////// if ( isAnalogPin(pin) == true ) { auto it = pins.find(pin); if ( it != pins.end() ) it->second.value = value; } } //////////////////////////////////////////////////////////////////// void AE::ArduinoData::fillTransferData(TransferData& td) { //////////////////////////////////////////////////////////////////// unsigned int counter = 0; for ( auto it = pins.begin(); it != pins.end(); ++it ) { td.pins[counter++] = it->second; } td.stepperDirX = traceInfo.stepperDirX; td.stepperDirY = traceInfo.stepperDirY; td.stepperDirZ = traceInfo.stepperDirZ; td.stepperDirH = traceInfo.stepperDirH; td.stepperPosX = traceInfo.stepperPosX; td.stepperPosY = traceInfo.stepperPosY; td.stepperPosZ = traceInfo.stepperPosZ; td.stepperPosH = traceInfo.stepperPosH; td.cfgSpeed_MM_SEC = traceInfo.cfgSpeed_MM_SEC; td.msdSpeed_MM_SEC = traceInfo.msdSpeed_MM_SEC; } //////////////////////////////////////////////////////////////////// bool AE::ArduinoData::isPin(unsigned int pin) { //////////////////////////////////////////////////////////////////// return ( pin >= MinPinNameValue && pin <= MaxPinNameValue ); } //////////////////////////////////////////////////////////////////// bool AE::ArduinoData::isAnalogPin(AE::PinName pin) { //////////////////////////////////////////////////////////////////// switch ( pin ) { case PN_A0: case PN_A1: case PN_A2: case PN_A3: case PN_A4: case PN_A5: return true; #if defined(ARDUINO_AVR_MEGA2560) case PN_A6: case PN_A7: case PN_A8: case PN_A9: case PN_A10: case PN_A11: case PN_A12: case PN_A13: case PN_A14: case PN_A15: return true; #endif default: ; } return false; } //////////////////////////////////////////////////////////////////// bool AE::ArduinoData::isDigitalPin(AE::PinName pin) { //////////////////////////////////////////////////////////////////// if ( isPin(pin) == false ) return false; return isAnalogPin(pin) == false; } //////////////////////////////////////////////////////////////////// AE::PinLevel AE::ArduinoData::convertPinLevel(bool state) { //////////////////////////////////////////////////////////////////// return state == false ? PL_LOW : PL_HIGH; } //////////////////////////////////////////////////////////////////// AE::PinName AE::ArduinoData::convertPinName(unsigned char pin) { //////////////////////////////////////////////////////////////////// if ( isPin(pin) == false ) return PN_NULL; return (PinName)pin; } //////////////////////////////////////////////////////////////////// AE::PinName AE::ArduinoData::convertPinName(const char type, int name) { //////////////////////////////////////////////////////////////////// if ( type != 'D' && type != 'A' ) return PN_NULL; if ( type == 'D' ) return name >= minDPinIndex && name <= maxDPinIndex ? (PinName)name : PN_NULL; // Here we talking about analogue pins, there are defined // #ifndef SKETCH_COMPILE // PN_A0 = 54, PN_A1 = 55, ... const int idx = ( name < minAPinIndex ? name + minAPinIndex : name ); return idx >= minAPinIndex && idx <= maxAPinIndex ? (PinName)idx : PN_NULL; } //////////////////////////////////////////////////////////////////// wxString AE::ArduinoData::buildDisplayName(PinName pin) { //////////////////////////////////////////////////////////////////// if ( isPin(pin) == false ) return ""; if ( isAnalogPin(pin) ) return buildDisplayName('A', ((int)pin) - minDPinIndex ); else return buildDisplayName('D', (int)pin); return ""; } //////////////////////////////////////////////////////////////////// wxString AE::ArduinoData::buildDisplayName(const char type, int name) { //////////////////////////////////////////////////////////////////// if ( type != 'A' && type != 'D' ) return ""; if ( type == 'A' && ( name < minAPinIndex - minAPinIndex || name > maxAPinIndex - minAPinIndex) ) return ""; if ( type == 'D' && ( name < minDPinIndex || name > maxDPinIndex ) ) return ""; return wxString::Format("%c%02d", type, name); }
[ "stefan.hoelzer@fplusp.de" ]
stefan.hoelzer@fplusp.de
72d9f410469d19eb0ae3a474981ee3db2eb811e8
4352b5c9e6719d762e6a80e7a7799630d819bca3
/tutorials/eulerVortex.twitch/eulerVortex.cyclic.twitch.test.test/processor2/3.5/e
d5dc080086109585734dd0d532aaa3bd30f10957
[]
no_license
dashqua/epicProject
d6214b57c545110d08ad053e68bc095f1d4dc725
54afca50a61c20c541ef43e3d96408ef72f0bcbc
refs/heads/master
2022-02-28T17:20:20.291864
2019-10-28T13:33:16
2019-10-28T13:33:16
184,294,390
1
0
null
null
null
null
UTF-8
C++
false
false
48,900
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "3.5"; object e; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 5625 ( 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.32 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.32 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.32 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.32 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.32 1006.31 1006.31 1006.31 1006.32 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.32 1006.31 1006.31 1006.31 1006.32 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.32 1006.32 1006.31 1006.31 1006.32 1006.32 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.32 1006.32 1006.31 1006.3 1006.32 1006.32 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.32 1006.32 1006.31 1006.3 1006.32 1006.33 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.32 1006.32 1006.31 1006.3 1006.31 1006.33 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.32 1006.31 1006.29 1006.3 1006.33 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.31 1006.3 1006.31 1006.32 1006.32 1006.29 1006.3 1006.33 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.31 1006.3 1006.31 1006.32 1006.32 1006.3 1006.29 1006.32 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.31 1006.31 1006.31 1006.32 1006.33 1006.3 1006.29 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.31 1006.31 1006.3 1006.31 1006.33 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.31 1006.31 1006.31 1006.32 1006.32 1006.29 1006.28 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.29 1006.3 1006.31 1006.31 1006.31 1006.32 1006.33 1006.31 1006.28 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.33 1006.32 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.32 1006.32 1006.3 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.32 1006.31 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.32 1006.32 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.32 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.28 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 ) ; boundaryField { emptyPatches_empt { type empty; } top_cyc { type cyclic; } bottom_cyc { type cyclic; } inlet_cyc { type cyclic; } outlet_cyc { type cyclic; } procBoundary2to0 { type processor; value nonuniform List<scalar> 75 ( 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.31 1006.31 1006.32 1006.31 1006.31 ) ; } procBoundary2to0throughtop_cyc { type processorCyclic; value nonuniform List<scalar> 75 ( 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 ) ; } procBoundary2to3 { type processor; value nonuniform List<scalar> 75 ( 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.3 1006.3 1006.3 1006.3 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.31 1006.3 1006.3 1006.3 1006.3 1006.29 1006.29 1006.29 1006.28 1006.28 1006.28 1006.28 1006.28 1006.29 1006.3 1006.31 1006.32 1006.33 1006.34 1006.34 1006.33 1006.31 1006.3 1006.28 1006.28 1006.29 1006.3 1006.31 1006.31 ) ; } procBoundary2to3throughinlet_cyc { type processorCyclic; value nonuniform List<scalar> 75 ( 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 1006.29 ) ; } } // ************************************************************************* //
[ "tdg@debian" ]
tdg@debian
548115622e362c6ce870dfaced79c7a0658db6dc
07523e8ea4aaf4586e8cd853e2cf5a9f080f7ac6
/Libraries/OneSheeld/KeyboardShield.cpp
1a91eb0645fc2c38c245822a4240acd577694069
[]
no_license
aru2l/Arduino
85fae8d9f1f46caee11c39751a5e12d84c537ce8
8951de8bec7a94b064f9a0aa307dfa9cea1d835a
refs/heads/master
2021-01-25T03:54:20.181137
2015-04-26T08:56:59
2015-04-26T08:56:59
34,603,963
0
1
null
null
null
null
UTF-8
C++
false
false
980
cpp
/* Project: 1Sheeld Library File: KeyboardShield.cpp Version: 1.0 Compiler: Arduino avr-gcc 4.3.2 Author: Integreight Date: 2014.5 */ #include "OneSheeld.h" #include "KeyboardShield.h" //Class Constructor KeyboardShield::KeyboardShield() { character=NULL; isCallBackAssigned=false; } //Getter char KeyboardShield::getCharacter() { return character; } //Keyboard Input Data Processing void KeyboardShield::processData() { //Checking Function-ID byte functionId=OneSheeld.getFunctionId(); if (functionId==GET_CHAR) { character=OneSheeld.getArgumentData(0)[0]; //Users Function Invoked if(isCallBackAssigned) { (*buttonChangeCallBack)(); } } } //Users Function Setter void KeyboardShield::setOnButtonChange(void (*userFunction)()) { buttonChangeCallBack=userFunction; isCallBackAssigned=true; } /*Instantiate object to user*/ KeyboardShield AsciiKeyboard;
[ "eih3.prog@outlook.fr" ]
eih3.prog@outlook.fr
7e6e4d40117e3d9dab5eacf7158efe7708993591
a18ff68de3cda0927b58a91d015e95a11e247155
/Def-est-quad.cpp
6d1b126070cf3122ffbd66e5042a45d7734fd6bb
[]
no_license
romykor/Makis
85cc4839334c25e078c365677ef11cfdf6f3374d
7413beb23b876c4a691c1e60d337588725cdaf04
refs/heads/master
2020-03-25T08:37:46.984412
2018-08-08T17:29:57
2018-08-08T17:29:57
143,624,221
0
0
null
null
null
null
ISO-8859-13
C++
false
false
15,937
cpp
// Determination of deflection of vertical // based on gravimetry data // and the already estimated W matrix // Final type with multiple sites // 07 August 2018 #include <iostream> #include <fstream> #include <iomanip> #include <iostream> #include <fstream> #include <iomanip> #include <cstdlib> #include <ctime> #include <cstring> #include <quadmath.h> //#include <omp.h> using namespace std; #define M2 2 #define M3 3 #define M6 6 #define STR_SIZE 50 typedef __float128 quadfloat; quadfloat const zer = 0.000000000000000000000000; quadfloat const one= 1.000000000000000000000000; void matinv2(quadfloat a[M2][M2], quadfloat b[M2][M2]) { // calculates the inverse of a matrix using Gauss-Jordan elimination // the inverse of matrix a is calculated and stored in the matrix b // beware: matrix a is converted to unit matrix! int i,j,k; quadfloat dum; // Build the unit matrix b for (i=0;i<M2;i++) { for (j=0;j<M2;j++) b[i][j]=zer; b[i][i]=one; } for (k=0;k<M2;k++) { dum=a[k][k]; for (j=0;j<M2;j++) { a[k][j]=a[k][j]/dum; b[k][j]=b[k][j]/dum; } for (i=k+1;i<M2;i++) { dum=a[i][k]; for (j=0;j<M2;j++) { a[i][j]=a[i][j]-a[k][j]*dum; b[i][j]=b[i][j]-b[k][j]*dum; } } } for (k=M2-1;k>0;k--) for (i=k-1;i>=0;i--) { dum=a[i][k]; for (j=0;j<M2;j++) { a[i][j]=a[i][j]-a[k][j]*dum; b[i][j]=b[i][j]-b[k][j]*dum; } } } void mulmat22(quadfloat a[M2][M2],quadfloat b[M2][M2], quadfloat c[M2][M2]) { int i,j,k; quadfloat s; for (i=0;i<M2;i++) for (j=0;j<M2;j++) { s=zer; for (k=0;k<M2;k++) s=s+a[i][k]*b[k][j]; c[i][j]=s; } } void mulmat2(quadfloat a[M2][M2],quadfloat b[M2], quadfloat c[M2]) { int i,j; quadfloat s; for (i=0;i<M2;i++) { s=zer; for (j=0;j<M2;j++) s=s+a[i][j]*b[j]; c[i]=s; } } void matinv3(quadfloat a[M3][M3], quadfloat b[M3][M3]) { // calculates the inverse of a matrix using Gauss-Jordan elimination // the inverse of matrix a is calculated and stored in the matrix b // beware: matrix a is converted to unit matrix! int i,j,k; quadfloat dum; // Build the unit matrix b for (i=0;i<M3;i++) { for (j=0;j<M3;j++) b[i][j]=zer; b[i][i]=one; } for (k=0;k<M3;k++) { dum=a[k][k]; for (j=0;j<M3;j++) { a[k][j]=a[k][j]/dum; b[k][j]=b[k][j]/dum; } for (i=k+1;i<M3;i++) { dum=a[i][k]; for (j=0;j<M3;j++) { a[i][j]=a[i][j]-a[k][j]*dum; b[i][j]=b[i][j]-b[k][j]*dum; } } } for (k=M3-1;k>0;k--) for (i=k-1;i>=0;i--) { dum=a[i][k]; for (j=0;j<M3;j++) { a[i][j]=a[i][j]-a[k][j]*dum; b[i][j]=b[i][j]-b[k][j]*dum; } } } void mulmat33(quadfloat a[M3][M3],quadfloat b[M3][M3], quadfloat c[M3][M3]) { int i,j,k; quadfloat s; for (i=0;i<M3;i++) for (j=0;j<M3;j++) { s=zer; for (k=0;k<M3;k++) s=s+a[i][k]*b[k][j]; c[i][j]=s; } } void mulmat3(quadfloat a[M3][M3],quadfloat b[M3], quadfloat c[M3]) { int i,j; quadfloat s; for (i=0;i<M3;i++) { s=zer; for (j=0;j<M3;j++) s=s+a[i][j]*b[j]; c[i]=s; } } int main() { int i,j,s,sid,sgn; quadfloat const omega=0.7292115e-04; quadfloat const pi=4.*atanq(1.); quadfloat const mf=100000.; // Conversion from (m/sec^2) to mgal quadfloat const eot=1.0e09; // Conversion from (sec^-2) to Eotvos units quadfloat const ras=648000./pi; // Conversion fram rad to arcsec quadfloat lat,lon,h,gH; quadfloat SW[3][3],W[3][3],Win[3][3],Isu[3][3]; quadfloat U[3][3],T[3][3],TW[3][3],UG[3][3],TG[3][3],WG[3][3]; quadfloat Q[3][3],dmin[3][3],dmax[3][3],dcW[3][3]; quadfloat dP[4][3],g[4],gp[4],hN[3],gN[3],wz[3]; quadfloat gA,gB,gC,gS,gAp,gBp,gC1,dgS,gamms,om2; quadfloat ksi,eta,modksi,modeta,difksi,difeta,eps; quadfloat Wx,Wy,Wz,Ad,Bd,dum,st,ct,nWx,nWy,nWz; quadfloat TM[3],Rh[3],nR[2],nT[2],nW[2][2],nWin[2][2],nTW[2][2],nIsu[2][2]; quadfloat epsa,epsb,alpha,beta,bet1,bet2; quadfloat Ls,Ns,difg,leps,gP,Uyy,C,V,gApmod,gBpmod; quadfloat aq,bq,cq,diq,qr1,qr2,gApp,gBpp; quadfloat calp,cbet,disc,zet1,zet2,theta; quadfloat det1,det2,rat,gCp,nom,den; quadfloat a1,a2,a3,b1,b2,b3,c1,c2,c3; char x_s[STR_SIZE], y_s[STR_SIZE], z_s[STR_SIZE], w_s[STR_SIZE]; memset(x_s, 0, STR_SIZE * sizeof(char)); memset(y_s, 0, STR_SIZE * sizeof(char)); memset(z_s, 0, STR_SIZE * sizeof(char)); memset(w_s, 0, STR_SIZE * sizeof(char)); ofstream res("Def-est-q-detail.txt"); ofstream sta("Def-est-q-stats.txt"); ifstream dat("Def_grav-q.txt"); om2=2.0*omega*omega; for(i=0;i<3;i++) for (j=0;j<3;j++) { dmin[i][j]=100000.0; dmax[i][j]=-100000.0; } for (s=0;s<12;s++) { dat>>sid; dat>>x_s>>y_s>>z_s>>w_s; lat = strtoflt128(x_s, NULL); lon = strtoflt128(y_s, NULL); gH = strtoflt128(z_s, NULL); h = strtoflt128(w_s, NULL); for (j=0;j<3;j++) dP[0][j]=zer; dat>>x_s>>y_s>>z_s; g[0] = strtoflt128(x_s, NULL); dgS = strtoflt128(y_s, NULL); gamms = strtoflt128(z_s, NULL); dat>>w_s>>z_s; C = strtoflt128(w_s, NULL); V = strtoflt128(z_s, NULL); // Data in geometric system for (i=1;i<4;i++) { for (j=0;j<3;j++) { dat>>x_s; dP[i][j] = strtoflt128(x_s, NULL); } dat>>y_s; g[i] = strtoflt128(y_s, NULL);; } dat>>w_s>>z_s; gApmod = strtoflt128(w_s, NULL); gBpmod = strtoflt128(z_s, NULL); gS=g[0]/mf; gA=g[1]/mf; gB=g[2]/mf; gC=g[3]/mf; dgS=dgS/mf; gamms=gamms/mf; gApmod=gApmod/mf; gBpmod=gBpmod/mf; leps=dgS/gS; // Data in physical system for (i=1;i<4;i++) { for (j=0;j<3;j++) { dat>>x_s; dP[i][j] = strtoflt128(x_s, NULL); } dat>>y_s; gp[i] = strtoflt128(y_s, NULL); } dat>>w_s>>z_s; gApp = strtoflt128(w_s, NULL); gBpp = strtoflt128(z_s, NULL); gApp=gApp/mf; gBpp=gBpp/mf; for (i=0;i<3;i++) for (j=0;j<3;j++) { dat>>x_s; T[i][j] = strtoflt128(x_s, NULL); } for (i=0;i<3;i++) for (j=0;j<3;j++) { dat>>y_s; U[i][j] = strtoflt128(y_s, NULL); } for (i=0;i<3;i++) for (j=0;j<3;j++) { dat>>z_s; TG[i][j] = strtoflt128(z_s, NULL); } for (i=0;i<3;i++) for (j=0;j<3;j++) { dat>>w_s; UG[i][j] = strtoflt128(w_s, NULL); } dat>>x_s>>y_s>>z_s; dum = strtoflt128(x_s, NULL); modksi = strtoflt128(y_s, NULL); modeta = strtoflt128(z_s, NULL); Uyy=dum/eot; // end of data for (i=0;i<3;i++) for (j=0;j<3;j++) { T[i][j]=T[i][j]/eot; U[i][j]=U[i][j]/eot; UG[i][j]=UG[i][j]/eot; TG[i][j]=TG[i][j]/eot; SW[i][j]=T[i][j]+U[i][j]; WG[i][j]=TG[i][j]+UG[i][j]; } res<<fixed<<endl; quadmath_snprintf(x_s, sizeof(x_s), "%.6Qe", lat); quadmath_snprintf(y_s, sizeof(y_s), "%.6Qe", lon); quadmath_snprintf(z_s, sizeof(z_s), "%.6Qe", h); quadmath_snprintf(w_s, sizeof(w_s), "%.6Qe", gH); res<<"\n Point "<<sid; res<<" (S) : Latitude = "<<setw(14)<<x_s; res<<" deg - Longitude = "<<setw(14)<<y_s<<" deg \n"; res<<" - Orthometric Height = "<<setw(14)<<z_s; res<<" - Geometric Height = "<<setw(14)<<w_s<<" m \n"; W[2][2]=-(gC-gS)/dP[3][2]; W[1][1]=Uyy*gS/gamms; W[0][0]=om2-W[1][1]-W[2][2]; Ls=-W[0][0]/gS; Ns=-W[1][1]/gS; hN[1]=0.5*Ls*dP[1][0]*dP[1][0]; epsa=fabsq(0.5*Ls*dP[1][0]); gN[1]=gA+W[2][2]*dP[1][2]; wz[1]=gN[1]*cosq(epsa); W[0][2]=-(wz[1]-gS)/dP[1][0]; hN[2]=0.5*Ns*dP[2][1]*dP[2][1]; epsb=fabsq(0.5*Ns*dP[2][1]); gN[2]=gB+W[2][2]*dP[2][2]; wz[2]=gN[2]*cosq(epsb); W[1][2]=-(wz[2]-gS)/dP[2][1]; calp=W[0][0]-2.0*W[1][1]; cbet=W[0][0]; disc=sqrtq(calp*calp+cbet*cbet); zet1=(-cbet+disc)/calp; zet2=(-cbet-disc)/calp; alpha=atanq(zet1); bet1=pi/4.-alpha; theta=bet1; alpha=atanq(zet2); bet2=pi/4.-alpha; disc=zet1; if (fabsq(bet2)<fabsq(bet1)) { disc=zet2; theta=bet2; } beta=zet1*zet2; W[0][1]=(disc*disc-one)*(W[1][1]-W[0][0])/(4.0*disc); nom=W[1][2]; den=W[0][2]; if (den!=0.) theta=atanq(nom/den); else theta=pi/2.; if (den<0.) theta=theta+pi; beta=W[1][1]; alpha=W[0][0]; dum=2.*theta; st=sinq(theta)*sinq(theta); ct=cosq(theta)*cosq(theta); W[0][0]=alpha*ct+beta*st; W[1][1]=alpha*st+beta*ct; W[0][1]=0.5*(alpha-beta)*sinq(dum); // Iteration Ls=-W[0][0]/gS; Ns=-W[1][1]/gS; hN[1]=0.5*Ls*dP[1][0]*dP[1][0]; epsa=fabsq(0.5*Ls*dP[1][0]); gN[1]=gA+W[2][2]*dP[1][2]; wz[1]=gN[1]*cosq(epsa); W[0][2]=-(wz[1]-gS)/dP[1][0]; hN[2]=0.5*Ns*dP[2][1]*dP[2][1]; epsb=fabsq(0.5*Ns*dP[2][1]); gN[2]=gB+W[2][2]*dP[2][2]; wz[2]=gN[2]*cosq(epsb); W[1][2]=-(wz[2]-gS)/dP[2][1]; calp=W[0][0]-2.0*W[1][1]; cbet=W[0][0]; disc=sqrtq(calp*calp+cbet*cbet); zet1=(-cbet+disc)/calp; zet2=(-cbet-disc)/calp; alpha=atanq(zet1); bet1=pi/4.-alpha; theta=bet1; alpha=atanq(zet2); bet2=pi/4.-alpha; disc=zet1; if (fabsq(bet2)<fabsq(bet1)) { disc=zet2; theta=bet2; } beta=zet1*zet2; W[0][1]=(disc*disc-one)*(W[1][1]-W[0][0])/(4.0*disc); /* res<<"\n Replace Wxz & Wyz with model values \n"; W[0][2]=SW[0][2]; W[1][2]=SW[1][2]; */ for(i=0;i<3;i++) for (j=i;j<3;j++) W[j][i]=W[i][j]; res<<"\n Computed Eotvos matrix W at point P (Eotvos units) \n\n"; for(i=0;i<3;i++) { for (j=0;j<3;j++) { TW[i][j]=W[i][j]; quadmath_snprintf(x_s, sizeof(x_s), "%.12Qe", TW[i][j]*eot); res<<setw(24)<<x_s; } res<<endl; } difg=(om2-W[0][0]-W[1][1]-W[2][2])*eot; quadmath_snprintf(z_s, sizeof(z_s), "%.16Qe", difg); res<<"\n 2ł^2 -ÓWii = "<<z_s<<" Eotvos "<<endl; //----------------------------------------- // gN[1]=(W[0][0]*a1+W[0][1]*a2+W[0][2]*a3)*dP[1][0]/mf; // gAp=gS+gN[1]/gS; // gN[2]=(W[1][0]*a1+W[1][1]*a2+W[1][2]*a3)*dP[2][1]/mf; // gBp=gS+gN[2]/gS; // gAp=gA+W[2][2]*dP[1][2]; // gBp=gB+W[2][2]*dP[2][2]; gAp=gApmod; gBp=gBpmod; res<<"\n Results using computed W and prime geometric gravities\n"; quadmath_snprintf(x_s, sizeof(x_s), "%.16Qe", gAp*mf); quadmath_snprintf(y_s, sizeof(y_s), "%.16Qe", gBp*mf); res<<"\n gAp = "<<x_s<<" mgal "; res<<"\n gBp = "<<y_s<<" mgal \n"; Rh[0]=(gAp-gS)*gS/dP[1][0]; Rh[1]=(gBp-gS)*gS/dP[2][1]; Rh[2]=(gC-gS)*gS/dP[3][2]; res<<"\n Right-hand matrix of system at P\n"; quadmath_snprintf(x_s, sizeof(x_s), "%.16Qe", Rh[0]); quadmath_snprintf(y_s, sizeof(y_s), "%.16Qe", Rh[1]); quadmath_snprintf(z_s, sizeof(z_s), "%.16Qe", Rh[2]); res<<"\n G1 = "<<x_s; res<<"\n G2 = "<<y_s; res<<"\n G3 = "<<z_s; matinv3(TW,Win); mulmat3(Win,Rh,TM); Wx=TM[0]; Wy=TM[1]; Wz=TM[2]; // check Bd=Wx*Wx+Wy*Wy+Wz*Wz-gS*gS; quadmath_snprintf(z_s, sizeof(z_s), "%.10Qe", Bd); res<<"\n Wx^2 + Wy^2 + Wz^2 - gP^2 = "<<z_s<<" (zero)\n"; res<<"\n First-order gradients"; quadmath_snprintf(x_s, sizeof(x_s), "%.16Qe", Wx); quadmath_snprintf(y_s, sizeof(y_s), "%.16Qe", Wy); quadmath_snprintf(z_s, sizeof(z_s), "%.16Qe", Wz); res<<"\n Wx = "<<x_s; res<<"\n Wy = "<<y_s; res<<"\n Wz = "<<z_s<<endl; dum=sqrtq(Wx*Wx+Wy*Wy+Wz*Wz); gP=dum; dum=fabsq(Wz)/dum; eps=acosq(dum); eps=eps*ras; ksi=Wx/Wz; ksi=ksi*ras; eta=Wy/Wz; eta=eta*ras; difksi=ksi-modksi; difeta=eta-modeta; res<<"\n Estimated Deflection of vertical - geometric \n"; quadmath_snprintf(x_s, sizeof(x_s), "%.8Qe", eps); quadmath_snprintf(y_s, sizeof(y_s), "%.8Qe", ksi); quadmath_snprintf(z_s, sizeof(z_s), "%.8Qe", difksi); res<<"\n eps = "<<x_s<<" arcsec \n"; res<<"\n ksi = "<<y_s<<" arcsec - Difference = "<<z_s<<" arcsec"; quadmath_snprintf(y_s, sizeof(y_s), "%.8Qe", eta); quadmath_snprintf(z_s, sizeof(z_s), "%.8Qe", difeta); res<<"\n eta = "<<y_s<<" arcsec - Difference = "<<z_s<<" arcsec\n"; for (j=0;j<3;j++) { beta=difksi; if (beta<dmin[0][0]) dmin[0][0]=beta; if (beta>dmax[0][0]) dmax[0][0]=beta; beta=difeta; if (beta<dmin[1][1]) dmin[1][1]=beta; if (beta>dmax[1][1]) dmax[1][1]=beta; } //* res<<"\n Computed Disturbance matrix T at point S (in Eotvos units)\n\n"; for(i=0;i<3;i++) { for (j=0;j<3;j++) { Q[i][j]=(W[i][j]-U[i][j]); quadmath_snprintf(w_s, sizeof(w_s), "%.12Qe", Q[i][j]*eot); res<<setw(24)<<w_s; } res<<endl; } res<<"\n\n Difference between computed-simulated matrix T at point S (in Eotvos units)\n\n"; for(i=0;i<3;i++) { for (j=0;j<3;j++) { dcW[i][j]=(Q[i][j]-T[i][j])*eot; quadmath_snprintf(x_s, sizeof(x_s), "%.12Qe", dcW[i][j]*eot); res<<setw(24)<<x_s; beta=(dcW[i][j]); if (beta<dmin[i][j]) dmin[i][j]=beta; if (beta>dmax[i][j]) dmax[i][j]=beta; } res<<endl; } //*/ res<<"\n\n Results using model W \n"; res<<"\n Model Eotvos matrix W at point P (Eotvos units) \n"; for(i=0;i<3;i++) { for (j=0;j<3;j++) { quadmath_snprintf(y_s, sizeof(y_s), "%.16Qe", SW[i][j]*eot); res<<setw(26)<<y_s; } res<<endl; } gAp=gApp; gBp=gBpp; res<<"\n\n Results using model W and prime physical gravities\n"; quadmath_snprintf(x_s, sizeof(x_s), "%.16Qe", gAp*mf); quadmath_snprintf(y_s, sizeof(y_s), "%.16Qe", gBp*mf); res<<"\n gAp = "<<x_s<<" mgal "; res<<"\n gBp = "<<y_s<<" mgal \n"; Rh[0]=(gAp-gS)*gS/dP[1][0]; Rh[1]=(gBp-gS)*gS/dP[2][1]; Rh[2]=(gC-gS)*gS/dP[3][2]; res<<"\n Model Right-hand matrix of system at P\n"; quadmath_snprintf(x_s, sizeof(x_s), "%.16Qe", Rh[0]); quadmath_snprintf(y_s, sizeof(y_s), "%.16Qe", Rh[1]); quadmath_snprintf(z_s, sizeof(z_s), "%.16Qe", Rh[2]); res<<"\n G1 = "<<x_s; res<<"\n G2 = "<<y_s; res<<"\n G3 = "<<z_s; matinv3(SW,Win); mulmat3(Win,Rh,TM); Wx=TM[0]; Wy=TM[1]; Wz=TM[2]; res<<endl; res<<"\n First-order gradients"; quadmath_snprintf(x_s, sizeof(x_s), "%.16Qe", Wx); quadmath_snprintf(y_s, sizeof(y_s), "%.16Qe", Wy); quadmath_snprintf(z_s, sizeof(z_s), "%.16Qe", Wz); res<<"\n Wx = "<<x_s; res<<"\n Wy = "<<y_s; res<<"\n Wz = "<<z_s<<endl; // check Bd=Wx*Wx+Wy*Wy+Wz*Wz-gS*gS; quadmath_snprintf(z_s, sizeof(z_s), "%.10Qe", Bd); res<<"\n Wx^2 + Wy^2 + Wz^2 - gP^2 = "<<z_s<<" (zero)\n"; dum=sqrtq(Wx*Wx+Wy*Wy+Wz*Wz); dum=fabsq(Wz)/dum; eps=acosq(dum); eps=eps*ras; ksi=Wx/Wz; ksi=ksi*ras; eta=Wy/Wz; eta=eta*ras; difksi=ksi-modksi; difeta=eta-modeta; res<<"\n Deflection of vertical - physical \n"; quadmath_snprintf(x_s, sizeof(x_s), "%.8Qe", eps); quadmath_snprintf(y_s, sizeof(y_s), "%.8Qe", ksi); quadmath_snprintf(z_s, sizeof(z_s), "%.8Qe", difksi); res<<"\n eps = "<<x_s<<" arcsec \n"; res<<"\n ksi = "<<y_s<<" arcsec - Difference = "<<z_s<<" arcsec"; quadmath_snprintf(y_s, sizeof(y_s), "%.8Qe", eta); quadmath_snprintf(z_s, sizeof(z_s), "%.8Qe", difeta); res<<"\n eta = "<<y_s<<" arcsec - Difference = "<<z_s<<" arcsec\n"; } sta<<fixed; sta<<"\n Range of differences between computed & model vertical deviations - geometric (in arcsec)\n"; quadmath_snprintf(x_s, sizeof(x_s), "%.8Qe", dmin[0][0]); quadmath_snprintf(y_s, sizeof(y_s), "%.8Qe", dmax[0][0]); quadmath_snprintf(z_s, sizeof(z_s), "%.8Qe", dmin[1][1]); quadmath_snprintf(w_s, sizeof(w_s), "%.8Qe", dmax[1][1]); sta<<"\n ksi : "<<setw(18)<<x_s<<" to "<<setw(19)<<y_s; sta<<"\n eta : "<<setw(18)<<z_s<<" to "<<setw(19)<<w_s<<endl; return 0; }
[ "romylos@survey.ntua.gr" ]
romylos@survey.ntua.gr