blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
0f8a5dd70dfd15e457ea7a3f35205dfd6490657a
71219ed2748798595af6890258d2f48e1fe63056
/04-Trees-And-Graphs/0408-First-Common-Ancestor/solution.hpp
1fd0308258819e0632358571c0207f282c827243
[]
no_license
KoaLaYT/Cracking-The-Code-Interview-Question
ae95a483515eefb18827ecb9eac63e59632a780c
b2fb271ada1b32ffabf985259639671999844137
refs/heads/master
2023-04-05T22:45:26.118542
2021-04-07T06:25:58
2021-04-07T06:25:58
334,376,322
0
0
null
null
null
null
UTF-8
C++
false
false
533
hpp
solution.hpp
#ifndef FIRST_COMMON_ANCESTOR_20210330 #define FIRST_COMMON_ANCESTOR_20210330 struct Node { int key; Node* p; Node* left; Node* right; }; /** * Design an algorithm and write code to find the first common ancestor * of two nodes in a binary tree. Avoid storing additional nodes in a * data structure. */ class Tree { public: void set_root(Node* node) { m_root = node; } Node* first_common_ancestor(Node* a, Node* b); // for easy test Node* find(int key); private: Node* m_root; }; #endif
986a57ab7a1465deaaa39e360be35ed5e157dca9
8b7772d0cdacfc86c58a0b391e292927ad2dc685
/Divide & Conquer/6.Given a sorted array of distinct integers find the index such that a[i] = i .cpp
67df4718363fbc822356d9fb9d927d5dd10aaf6e
[ "Apache-2.0" ]
permissive
shauryauppal/Algo-DS-StudyMaterial
62e0f37a899496a44a9a672c6315cf42554b6595
1c481f066d21b33ec2533156e75f45fa9b6a7606
refs/heads/master
2021-09-21T22:40:41.399365
2018-09-02T04:21:36
2018-09-02T04:21:36
147,053,567
3
0
null
null
null
null
UTF-8
C++
false
false
547
cpp
6.Given a sorted array of distinct integers find the index such that a[i] = i .cpp
//this is giving error /*#include <bits/stdc++.h> using namespace std; int search_ele(int arr[],int n) { int l=0,h=n-1; while (l <= h) { int mid = (l + h)/2; if (arr[mid] == mid) return mid; if (arr[mid] < mid) l = mid + 1; else h= mid - 1; } return -1; } int main() { int n; cin>>n; int A[n]; for(int i=0;i<n;i++) cin>>A[i]; int pos=search_ele(A,n); cout<<"Position->"<<pos; return 0; } */
6f663ddd38bedae449fb77d9210b434cb5fe82f7
d09782b5cd1770c76a3bf86351447cdea47026e6
/coin change with dp.cpp
c44666889a1894b9d8df75ddfe31567189d80604
[]
no_license
PrashantThakurNitP/cpp-code
bc6d377916d9901be63492469629ea8f81c17cea
8d7e1cc177eff13f7195f2f33f070be7657e0a51
refs/heads/master
2020-09-30T16:23:58.035846
2019-12-11T09:21:49
2019-12-11T09:21:49
227,324,167
0
0
null
null
null
null
UTF-8
C++
false
false
1,483
cpp
coin change with dp.cpp
#include <iostream> #include<vector> using namespace std; int get_change(int m) { //write your code here return m / 4; } int get_change_d(int m) { //write your code here int coin[3]={1,3,4}; vector<int>money;//no of coin for(int i=0;i<=m;i++) money.push_back(0); for(int j=1;j<=m;j++)//j is money to change { cout<<"j = "<<j<<endl; int flag=1; int num=9999; int no=99999; for( int k=0;k<j;k++) { cout<<"k = "<<k<<endl; int temp=9999; //if(!flag) //break; for(int i=2;i>=0 ;i--)//coin[i] contain coin denomination { if((j-k)/coin[i]<1) continue; cout<<"i= "<<i<<endl; if((j-k)%coin[i]!=0) continue; //if(j>money[k]) temp=(j-k)/coin[i]; if(temp==0) { // flag=0; //break; continue; } if(temp+money[k]<=no) { no=temp+money[k]; cout<<"temp = "<<temp; cout<<"money = "<<money[k]; cout<<"no = "<<no<<endl; } } if(no<num) num=no; } money[j]=num; cout<<"j = "<<j<<" money[i] = "<<money[j]<<endl; } return money[m]; } int main() { int m; std::cin >> m; std::cout << get_change_d(m) << '\n'; }
de0722efa491410b58ade400a3f75558c9f999ed
08c5fa6bf070ebb1633583f8ac528f199bc6b609
/src/caffe/test/test_python_layer.cpp
b1b4bd3b3f0f84a9a81c54f9eda9a21fa114ebe2
[ "LicenseRef-scancode-generic-cla", "BSD-2-Clause", "LicenseRef-scancode-public-domain", "BSD-3-Clause" ]
permissive
eagleman110/caffe_pp2
b15f31e85d58640b960d92a8beb8ea051f779753
26a23920f001514157430d18c6bada5093592b25
refs/heads/master
2021-05-11T02:44:02.837609
2018-01-21T20:45:05
2018-01-21T20:45:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,859
cpp
test_python_layer.cpp
#include <cstring> #include <vector> #include "gtest/gtest.h" #include "caffe/blob.hpp" #include "caffe/common.hpp" #include "caffe/filler.hpp" //#include "caffe/vision_layers.hpp" #include "caffe/layers/python_layer.hpp" #include "caffe/test/test_caffe_main.hpp" #include "caffe/test/test_gradient_check_util.hpp" namespace caffe { template <typename TypeParam> class PythonLayerTest : public MultiDeviceTest<TypeParam> { typedef typename TypeParam::Dtype Dtype; protected: PythonLayerTest() : blob_bottom_feats_(new Blob<Dtype>()), blob_bottom_locs_(new Blob<Dtype>()), blob_top_(new Blob<Dtype>()) {} virtual void SetUp() { // conv feature input FillerParameter filler_param; filler_param.set_value(1.); GaussianFiller<Dtype> filler(filler_param); vector<int> blob_shape(4); blob_shape[0] = 256; blob_shape[1] = 1; blob_shape[2] = 10; blob_shape[3] = 2; this->blob_bottom_feats_->Reshape(blob_shape); filler.Fill(this->blob_bottom_feats_); blob_bottom_vec_.push_back(blob_bottom_feats_); // part location blob vector<int> blob_shape2(4); blob_shape2[0] = 256; blob_shape2[1] = 256; blob_shape2[2] = 6; blob_shape2[3] = 6; this->blob_bottom_locs_->Reshape(blob_shape2); filler.Fill(this->blob_bottom_locs_); blob_bottom_vec_.push_back(blob_bottom_locs_); blob_top_vec_.push_back(blob_top_); } virtual ~PythonLayerTest() { delete blob_bottom_feats_; delete blob_bottom_locs_; delete blob_top_; } Blob<Dtype>* const blob_bottom_feats_; Blob<Dtype>* const blob_bottom_locs_; Blob<Dtype>* const blob_top_; vector<Blob<Dtype>*> blob_bottom_vec_; vector<Blob<Dtype>*> blob_top_vec_; }; TYPED_TEST_CASE(PythonLayerTest, TestDtypesAndDevices); TYPED_TEST(PythonLayerTest, TestGradientExpansion) { typedef typename TypeParam::Dtype Dtype; //if (sizeof(Dtype) != 4) { return; } LayerParameter layer_param; layer_param.set_type("Python"); //this->blob_bottom_vec_.push_back(this->blob_bottom_); //this->blob_top_vec_.push_back(this->blob_top_); layer_param.mutable_python_param()->set_module("part_layers"); layer_param.mutable_python_param()->set_layer("CroppingLayerV2"); //std::string param_string = "{'vocab': '/home/lisaanne/caffe-LSTM/examples/captions_add_new_word/for_debugging/mini_vocab.txt', 'batch_size': 2, 'top_names': ['expanded_labels'], 'lexical_classes': '/home/lisaanne/caffe-LSTM/examples/captions_add_new_word/for_debugging/mini_classifiers.txt'}"; //layer_param.mutable_python_param()->set_param_str(param_string); shared_ptr<Layer<Dtype> > layer(LayerRegistry<Dtype>::CreateLayer(layer_param)); GradientChecker<Dtype> checker(1e-2, 1e-3); checker.CheckGradientExhaustive(layer.get(), this->blob_bottom_vec_, this->blob_top_vec_); } } // namespace caffe
72fa8ea9b8f60457ab265bd62de4cc1926b83400
932c0e7ce8201248383c9aac70cfd01bc8e4c4a7
/3-两个栈实现一个队列.cpp
76a2474936dc8571e553045ac655c400fcdb5488
[]
no_license
ckl666/leetcode
da03ccb0a48bcdbfd604bf9475a2b903107dd78b
7060076403877cfedda9675a08bacd97ec442013
refs/heads/master
2020-06-13T19:51:23.711321
2019-07-02T02:25:46
2019-07-02T02:25:46
194,771,044
1
0
null
null
null
null
UTF-8
C++
false
false
795
cpp
3-两个栈实现一个队列.cpp
#include <iostream> #include <stack> using namespace std; bool Pop(stack<int> &st1,stack<int> &st2,int &val) { if(st2.empty()) { if(st1.empty()) { return false; } else { int tmp = 0; while(!st1.empty()) { tmp = st1.top(); st2.push(tmp); st1.pop(); } } } val = st2.top(); st2.pop(); return true; } bool Push(stack<int> &st1,int val) { st1.push(val); return true; } int main() { stack<int> st1; stack<int> st2; int val = 0; int i = 0; for(i = 0; i < 10; i++) { Push(st1,i); } while(Pop(st1,st2,val)) { cout<<"val = "<<val<<endl; } return 0; }
8a470fa38c4623035fe02bf789a83f8ac081915a
da51040b8702d7908ed31608a91daa37d6a9ed37
/CNesEventFrameStart.cpp
be4b081dc5da781458d74657f4a58c47ea0e0975
[]
no_license
TheCatNose/PurrFX
0f140a88b65f9c9db31b21d6e62c25794efa309c
a040e0490dcbfe03bf89ac58ec1bbebb015b0ec3
refs/heads/master
2022-12-23T06:39:07.244548
2020-09-21T16:35:07
2020-09-21T16:35:07
286,448,239
1
1
null
2020-08-12T12:51:13
2020-08-10T10:46:12
C++
UTF-8
C++
false
false
324
cpp
CNesEventFrameStart.cpp
#include "CNesEventFrameStart.h" namespace PurrFX { CNesEventFrameStart::CNesEventFrameStart(int i_nFrame): m_nFrame(i_nFrame) { assert(m_nFrame >= 0); } int CNesEventFrameStart::newFrame() const { return m_nFrame; } ENesEventType CNesEventFrameStart::type() const { return ENesEventType::FrameStart; } }
4dd0f8c9cb46bf5b35c35caf3c50f4ed335f24ee
435633d9a1bd03ad1c3ce537c654494f1820d084
/core/EnvironmentHandler.cpp
175fcb3fc5e779acabd6a0582bfb397b72a98fdf
[]
no_license
gsm1011/cppweka
518e6086cf352b24b4b74ec12960b20c5fc2b5a6
ad26add3ef96ec266e4b0982de1987a15c16f7f2
refs/heads/master
2020-05-29T19:05:25.823897
2014-06-26T00:42:40
2014-06-26T00:42:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,506
cpp
EnvironmentHandler.cpp
/* * 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * EnvironmentHandler.cpp * Copyright (C) 2009 University of Waikato, Hamilton, New Zealand */ // package weka.core; // import weka.core.Environment; /** * Interface for something that can utilize environment * variables. NOTE: since environment variables should * be transient, the implementer needs to be careful * of state after de-serialization. Default system-wide * environment variables can be got via a call to * <code>weka.core.Environment.getSystemWide()</code> * * @author mhall (mhall{[at]}pentaho{[dot]}com) * @version $Revision: 5562 $ */ class EnvironmentHandler { /** * Set environment variables to use. * * @param env the environment variables to * use */ virtual void setEnvironment(Environment env) = 0; };
aef62ce7bc6e299fce986f0a73bb4a67d3ad127a
c7c73566784a7896100e993606e1bd8fdd0ea94e
/panda/src/androiddisplay/p3androiddisplay_composite1.cxx
091a172a6e32c6f996cf7b01409ef0dfbda49f50
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
panda3d/panda3d
c3f94df2206ff7cfe4a3b370777a56fb11a07926
160ba090a5e80068f61f34fc3d6f49dbb6ad52c5
refs/heads/master
2023-08-21T13:23:16.904756
2021-04-11T22:55:33
2023-08-06T06:09:32
13,212,165
4,417
1,072
NOASSERTION
2023-09-09T19:26:14
2013-09-30T10:20:25
C++
UTF-8
C++
false
false
231
cxx
p3androiddisplay_composite1.cxx
#include "config_androiddisplay.cxx" //#include "androidGraphicsBuffer.cxx" #include "androidGraphicsPipe.cxx" //#include "androidGraphicsPixmap.cxx" #include "androidGraphicsStateGuardian.cxx" #include "androidGraphicsWindow.cxx"
98004ec2e77b0a98befa8ee2a4bf6198ba5dc43a
64d7cc6e293d9f06f4f31f444a64d74420ef7b65
/inet/src/networklayer/ipv4/IPv4Datagram.h
53cc4d5f54c1383022cda197c4d6f9ab4ffd5599
[]
no_license
floxyz/veins-lte
73ab1a1034c4f958177f72849ebd5b5ef6e5e4db
23c9aa10aa5e31c6c61a0d376b380566e594b38d
refs/heads/master
2021-01-18T02:19:59.365549
2020-11-16T06:05:49
2020-11-16T06:05:49
27,383,107
19
12
null
2016-10-26T06:05:52
2014-12-01T14:31:19
C++
UTF-8
C++
false
false
2,195
h
IPv4Datagram.h
// // Copyright (C) 2011 Andras Varga // // 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 // 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, see <http://www.gnu.org/licenses/>. // #ifndef _IPv4DATAGRAM_H_ #define _IPv4DATAGRAM_H_ #include "INETDefs.h" #include "IPv4Datagram_m.h" /** * Represents an IPv4 datagram. More info in the IPv4Datagram.msg file * (and the documentation generated from it). */ class INET_API IPv4Datagram : public IPv4Datagram_Base { public: IPv4Datagram(const char *name = NULL, int kind = 0) : IPv4Datagram_Base(name, kind) {} IPv4Datagram(const IPv4Datagram& other) : IPv4Datagram_Base(other) {} IPv4Datagram& operator=(const IPv4Datagram& other) {IPv4Datagram_Base::operator=(other); return *this;} virtual IPv4Datagram *dup() const {return new IPv4Datagram(*this);} /** * Returns bits 0-5 of the Type of Service field, a value in the 0..63 range */ virtual int getDiffServCodePoint() const { return getTypeOfService() & 0x3f; } /** * Sets bits 0-5 of the Type of Service field; expects a value in the 0..63 range */ virtual void setDiffServCodePoint(int dscp) { setTypeOfService( (getTypeOfService() & 0xc0) | (dscp & 0x3f)); } /** * Returns bits 6-7 of the Type of Service field, a value in the range 0..3 */ virtual int getExplicitCongestionNotification() const { return (getTypeOfService() >> 6) & 0x03; } /** * Sets bits 6-7 of the Type of Service; expects a value in the 0..3 range */ virtual void setExplicitCongestionNotification(int ecn) { setTypeOfService( (getTypeOfService() & 0x3f) | ((ecn & 0x3) << 6)); } }; #endif
561580b35cc05c52988cce207c6afdfc1397efba
157c6d025a705fb5c778f05ec3fcc9d00b71b947
/timus2018/sol.cpp
469bb74e1e412cd04f8f2b736811075aa096db80
[]
no_license
laraconda/cp
2c3a43bb9002db827cd473ce0fdd9125c806597e
4b0f237317a319f1c7c20fb87d3653478cf94f92
refs/heads/master
2023-04-12T08:56:06.999485
2023-04-06T19:52:57
2023-04-06T19:52:57
273,814,626
0
0
null
null
null
null
UTF-8
C++
false
false
950
cpp
sol.cpp
#include <bits/stdc++.h> using namespace std; const int MAXN = (1e4 * 5) + 3; const int MOD = 1e9 + 7; int c[MAXN], aa[MAXN], bb[MAXN]; int n, a, b; int A(int i); int B(int i); long long C(int i) { if (i <= 0) return 1; if (c[i] == -1) c[i] = ((long long)A(i) + B(i)) % MOD; return c[i]; } int A(int i) { if (i <= 1) aa[i] = 1; else if (i <= a) aa[i] = C(i - 1); else if (aa[i] == -1) aa[i] = (MOD + ((C(i - 1) - B(i - a - 1)) % MOD)) % MOD; return aa[i]; } int B(int i) { if (i <= 1) bb[i] = 1; else if (i <= b) bb[i] = C(i - 1); else if (bb[i] == -1) bb[i] = (MOD + ((C(i - 1) - A(i - b - 1)) % MOD)) % MOD; return bb[i]; } int main() { cin >> n >> a >> b; for (int i=0; i<MAXN; i++) { c[i] = -1; aa[i] = -1; bb[i] = -1; } for (int i=1; i<=n; i++) C(i); cout << c[n] << endl; }
61355f63df54ca042461ea9ca99f9a3d76e0cabf
61a3b61cbbfe209d5636dca99630da8ba1f749b4
/app/src/main/cpp/header/Video.h
1c890506c577e9c83320bc0e8cfa76dd05656ca5
[]
no_license
NicoleCN/ShowMeCode
3f908c3a5e78a73effffcb0bd1439814ed53e798
3043283846b0cb1a663fc6c41a5571bb23550720
refs/heads/master
2020-07-17T06:53:30.712577
2019-09-05T01:31:31
2019-09-05T01:31:31
205,962,113
0
0
null
null
null
null
UTF-8
C++
false
false
147
h
Video.h
// // Created by Nicole on 2019-08-29. // #ifndef SHOWMECODE_VIDEO_H #define SHOWMECODE_VIDEO_H class Video { }; #endif //SHOWMECODE_VIDEO_H
61d38455604d0bb8d231ff957e67b2be4cbc49dc
2c802d6c3615fef45a6a56857a647742caa8a763
/thrift/lib/cpp2/async/HTTPClientChannel.h
cc74c2171f380fe0581ef6910b761d076fba0a1f
[ "Apache-2.0" ]
permissive
alexandruionita-gyg/fbthrift
6b4a57b6bcee5b01e2e2e34cb3950953dc39fac4
633928feccc80d8b963b6ce2d313b35d89512d67
refs/heads/master
2020-06-16T22:39:22.708442
2015-12-04T09:43:32
2015-12-04T09:43:32
75,061,452
0
0
null
2016-11-29T08:47:59
2016-11-29T08:47:59
null
UTF-8
C++
false
false
9,015
h
HTTPClientChannel.h
/* * Copyright 2015 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef THRIFT_ASYNC_THTTPCLIENTCHANNEL_H_ #define THRIFT_ASYNC_THTTPCLIENTCHANNEL_H_ 1 #include <folly/io/async/HHWheelTimer.h> #include <proxygen/lib/http/codec/HTTPCodec.h> #include <thrift/lib/cpp2/async/ChannelCallbacks.h> #include <thrift/lib/cpp2/async/MessageChannel.h> #include <thrift/lib/cpp2/async/ClientChannel.h> #include <thrift/lib/cpp2/async/Cpp2Channel.h> #include <folly/io/async/DelayedDestruction.h> #include <folly/io/async/Request.h> #include <thrift/lib/cpp/transport/THeader.h> #include <folly/io/async/EventBase.h> #include <memory> #include <unordered_map> #include <deque> namespace apache { namespace thrift { /** * HTTPClientChannel * * This is a channel implementation that reads and writes * messages encoded using THttpProtocol. */ class HTTPClientChannel : public ClientChannel, public MessageChannel::RecvCallback, public ChannelCallbacks, virtual public folly::DelayedDestruction { protected: ~HTTPClientChannel() override {} public: explicit HTTPClientChannel( const std::shared_ptr<apache::thrift::async::TAsyncTransport>& transport, const std::string& host, const std::string& url, std::unique_ptr<proxygen::HTTPCodec> codec); explicit HTTPClientChannel( const std::shared_ptr<apache::thrift::async::TAsyncTransport>& transport, const std::string& host, const std::string& url); explicit HTTPClientChannel(const std::shared_ptr<Cpp2Channel>& cpp2Channel, const std::string& host, const std::string& url); explicit HTTPClientChannel(const std::shared_ptr<Cpp2Channel>& cpp2Channel, const std::string& host, const std::string& url, std::unique_ptr<proxygen::HTTPCodec> codec); typedef std::unique_ptr< HTTPClientChannel, folly::DelayedDestruction::Destructor> Ptr; static Ptr newChannel( const std::shared_ptr<apache::thrift::async::TAsyncTransport>& transport, const std::string& host, const std::string& url) { return Ptr(new HTTPClientChannel(transport, host, url)); } virtual void sendMessage(Cpp2Channel::SendCallback* callback, std::unique_ptr<folly::IOBuf> buf, apache::thrift::transport::THeader* header) { cpp2Channel_->sendMessage(callback, std::move(buf), header); } void closeNow() override; // DelayedDestruction methods void destroy() override; apache::thrift::async::TAsyncTransport* getTransport() override { return cpp2Channel_->getTransport(); } void setReadBufferSize(uint32_t readBufferSize) { cpp2Channel_->setReadBufferSize(readBufferSize); } // Client interface from RequestChannel using RequestChannel::sendRequest; uint32_t sendRequest( RpcOptions&, std::unique_ptr<RequestCallback>, std::unique_ptr<apache::thrift::ContextStack>, std::unique_ptr<folly::IOBuf>, std::shared_ptr<apache::thrift::transport::THeader>) override; using RequestChannel::sendOnewayRequest; uint32_t sendOnewayRequest( RpcOptions&, std::unique_ptr<RequestCallback>, std::unique_ptr<apache::thrift::ContextStack>, std::unique_ptr<folly::IOBuf>, std::shared_ptr<apache::thrift::transport::THeader>) override; void setCloseCallback(CloseCallback*) override; // Interface from MessageChannel::RecvCallback void messageReceived( std::unique_ptr<folly::IOBuf>&&, std::unique_ptr<apache::thrift::transport::THeader>&&, std::unique_ptr<MessageChannel::RecvCallback::sample>) override; void messageChannelEOF() override; void messageReceiveErrorWrapped(folly::exception_wrapper&&) override; // Client timeouts for read, write. // Servers should use timeout methods on underlying transport. void setTimeout(uint32_t ms) override; uint32_t getTimeout() override { return getTransport()->getSendTimeout(); } // If a Close Callback is set, should we reregister callbacks for it // alone? Basically, this means that loop() will return if the only thing // outstanding is close callbacks. void setKeepRegisteredForClose(bool keepRegisteredForClose) { keepRegisteredForClose_ = keepRegisteredForClose; setBaseReceivedCallback(); } bool getKeepRegisteredForClose() { return keepRegisteredForClose_; } folly::EventBase* getEventBase() override { return cpp2Channel_->getEventBase(); } // event base methods void attachEventBase(folly::EventBase*) override; void detachEventBase() override; bool isDetachable() override; uint16_t getProtocolId() override { return protocolId_; } void setProtocolId(uint16_t protocolId) { protocolId_ = protocolId; } bool expireCallback(uint32_t seqId); bool isSecurityActive() override { return false; } class ClientFramingHandler : public FramingHandler { public: explicit ClientFramingHandler(HTTPClientChannel& channel) : channel_(channel) {} std::tuple<std::unique_ptr<folly::IOBuf>, size_t, std::unique_ptr<apache::thrift::transport::THeader>> removeFrame(folly::IOBufQueue* q) override; std::unique_ptr<folly::IOBuf> addFrame( std::unique_ptr<folly::IOBuf> buf, apache::thrift::transport::THeader* header) override; private: HTTPClientChannel& channel_; }; // Remove a callback from the recvCallbacks_ map. void eraseCallback(uint32_t seqId, TwowayCallback<HTTPClientChannel>* cb); CLIENT_TYPE getClientType() override { return THRIFT_HTTP_CLIENT_TYPE; } private: class HTTPCodecCallback : public proxygen::HTTPCodec::Callback { public: explicit HTTPCodecCallback(HTTPClientChannel* channel) : channel_(channel) {} virtual void onMessageBegin(proxygen::HTTPCodec::StreamID stream, proxygen::HTTPMessage* msg) override {} virtual void onHeadersComplete( proxygen::HTTPCodec::StreamID stream, std::unique_ptr<proxygen::HTTPMessage> msg) override { channel_->streamIDToMsg_[stream] = std::move(msg); channel_->streamIDToBody_[stream] = folly::make_unique<folly::IOBufQueue>(); } virtual void onBody(proxygen::HTTPCodec::StreamID stream, std::unique_ptr<folly::IOBuf> chain, uint16_t padding) override { channel_->streamIDToBody_[stream]->append(std::move(chain)); } virtual void onTrailersComplete( proxygen::HTTPCodec::StreamID stream, std::unique_ptr<proxygen::HTTPHeaders> trailers) override { channel_->streamIDToMsg_[stream]->setTrailers(std::move(trailers)); } virtual void onMessageComplete(proxygen::HTTPCodec::StreamID stream, bool upgrade) override { channel_->completedStreamIDs_.push_back(stream); } virtual void onError(proxygen::HTTPCodec::StreamID stream, const proxygen::HTTPException& error, bool newTxn = false) override { // TODO } private: HTTPClientChannel* channel_; }; void setRequestHeaderOptions(apache::thrift::transport::THeader* header); // Set the base class callback based on current state. void setBaseReceivedCallback(); std::unique_ptr<HTTPCodecCallback> httpCallback_; const std::unique_ptr<proxygen::HTTPCodec> httpCodec_; const std::string httpHost_; const std::string httpUrl_; uint32_t sendSeqId_; std::unordered_map<proxygen::HTTPCodec::StreamID, uint32_t> streamIDToSeqId_; std::unordered_map<proxygen::HTTPCodec::StreamID, std::unique_ptr<proxygen::HTTPMessage>> streamIDToMsg_; std::unordered_map<proxygen::HTTPCodec::StreamID, std::unique_ptr<folly::IOBufQueue>> streamIDToBody_; std::deque<proxygen::HTTPCodec::StreamID> completedStreamIDs_; std::unordered_map<uint32_t, TwowayCallback<HTTPClientChannel>*> recvCallbacks_; std::deque<uint32_t> recvCallbackOrder_; CloseCallback* closeCallback_; uint32_t timeout_; bool keepRegisteredForClose_; std::shared_ptr<Cpp2Channel> cpp2Channel_; folly::HHWheelTimer::UniquePtr timer_; uint16_t protocolId_; }; } } // apache::thrift #endif // THRIFT_ASYNC_THTTPCLIENTCHANNEL_H_
761be603c3b7ae59298ae6fb7b198f0e5082e9b4
02b4e557cc3514b94be16928035ed2725cc798b9
/drtm-dst/src/core/common.h
ee5d54e624a0d1a0e0652c2b45317539aa9d3e49
[ "Apache-2.0" ]
permissive
yanghaomai/dst
b0286d04bd76b7c30d2d065a5f84033c5ca69000
897b929a692642cbf295c105d9d6e64090abb673
refs/heads/main
2023-04-06T19:59:11.487927
2021-04-12T13:19:10
2021-04-12T13:19:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
612
h
common.h
#ifndef NOCC_COMMON_H #define NOCC_COMMON_H #define NOCC_DECLARE_typed_var(type, name) \ namespace nocc { \ extern type FLAGS_##name; \ } // namespace nocc namespace nocc { #define DISABLE_COPY_AND_ASSIGN(classname) \ private: \ classname(const classname&) = delete; \ classname& operator=(const classname&) = delete #define unlikely(x) __builtin_expect(!!(x), 0) #define likely(x) __builtin_expect(!!(x), 1) #define ALWAYS_INLINE __attribute__((always_inline)) }; #endif
829f41984b5f024b97d1818f16f02b8fe7f44f25
ab81ae0e5c03d5518d535f4aa2e3437081e351af
/OCCT.Foundation.NetHost/ModelingData/TKGeomBase/gce/xgce_MakeLin2d.h
9c90cee7011db1d222b87936508e1e366970624a
[]
no_license
sclshu3714/MODELWORX.CORE
4f9d408e88e68ab9afd8644027392dc52469b804
966940b110f36509e58921d39e8c16b069e167fa
refs/heads/master
2023-03-05T23:15:43.308268
2021-02-11T12:05:41
2021-02-11T12:05:41
299,492,644
1
1
null
null
null
null
WINDOWS-1252
C++
false
false
4,345
h
xgce_MakeLin2d.h
// Created on: 1992-08-26 // Created by: Remi GILET // Copyright (c) 1992-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifndef _xgce_MakeLin2d_HeaderFile #define _xgce_MakeLin2d_HeaderFile #pragma once #include <gce_MakeLin2d.hxx> #include <xgce_Root.h> #include <xgp_Ax2d.h> #include <xgp_Pnt2d.h> #include <xgp_Dir2d.h> #include <xgp_Lin2d.h> #include <Standard.hxx> #include <Standard_DefineAlloc.hxx> #include <Standard_Handle.hxx> #include <gp_Lin2d.hxx> #include <gce_Root.hxx> #include <Standard_Real.hxx> class StdFail_NotDone; class gp_Ax2d; class gp_Pnt2d; class gp_Dir2d; class gp_Lin2d; using namespace TKMath; namespace TKGeomBase { ref class TKMath::xgp_Ax2d; ref class TKMath::xgp_Pnt2d; ref class TKMath::xgp_Dir2d; ref class TKMath::xgp_Lin2d; //! This class implements the following algorithms used //! to create Lin2d from gp. //! //! * Create a Lin2d parallel to another and passing //! through a point. //! * Create a Lin2d parallel to another at the distance //! Dist. //! * Create a Lin2d passing through 2 points. //! * Create a Lin2d from its axis (Ax1 from gp). //! * Create a Lin2d from a point and a direction. //! * Create a Lin2d from its equation. public ref class xgce_MakeLin2d : public xgce_Root { public: //DEFINE_STANDARD_ALLOC xgce_MakeLin2d(); !xgce_MakeLin2d() { IHandle = NULL; }; ~xgce_MakeLin2d() { IHandle = NULL; }; xgce_MakeLin2d(gce_MakeLin2d* pos); void SetMakeLin2d(gce_MakeLin2d* pos); virtual gce_MakeLin2d* GetMakeLin2d(); virtual gce_Root* GetRoot() Standard_OVERRIDE; //! Creates a line located with A. xgce_MakeLin2d(xgp_Ax2d^ A); //! <P> is the location point (origin) of the line and //! <V> is the direction of the line. xgce_MakeLin2d(xgp_Pnt2d^ P, xgp_Dir2d^ V); //! Creates the line from the equation A*X + B*Y + C = 0.0 //! the status is "NullAxis"if Sqrt(A*A + B*B) <= Resolution from gp. xgce_MakeLin2d(Standard_Real A, Standard_Real B, Standard_Real C); //! Make a Lin2d from gp <TheLin> parallel to another //! Lin2d <Lin> at a distance <Dist>. //! If Dist is greater than zero the result is on the //! right of the Line <Lin>, else the result is on the //! left of the Line <Lin>. xgce_MakeLin2d(xgp_Lin2d^ Lin, Standard_Real Dist); //! Make a Lin2d from gp <TheLin> parallel to another //! Lin2d <Lin> and passing through a Pnt2d <Point>. xgce_MakeLin2d(xgp_Lin2d^ Lin, xgp_Pnt2d^ Point); //! Make a Lin2d from gp <TheLin> passing through 2 //! Pnt2d <P1>,<P2>. //! It returns false if <P1> and <P2> are confused. //! Warning //! If an error occurs (that is, when IsDone returns //! false), the Status function returns: //! - gce_NullAxis if Sqrt(A*A + B*B) is less //! than or equal to gp::Resolution(), or //! - gce_ConfusedPoints if points P1 and P2 are coincident. xgce_MakeLin2d(xgp_Pnt2d^ P1, xgp_Pnt2d^ P2); //! Returns theructed line. //! Exceptions StdFail_NotDone if no line isructed. xgp_Lin2d^ Value(); xgp_Lin2d^ Operator(); operator xgp_Lin2d^(); //! Returns true if the construction is successful. virtual Standard_Boolean IsDone() Standard_OVERRIDE; //! Returns the status of the construction: //! - gce_Done, if the construction is successful, or //! - another value of the gce_ErrorType enumeration //! indicating why the construction failed. virtual xgce_ErrorType Status() Standard_OVERRIDE; /// <summary> /// ±¾µØ¾ä±ú /// </summary> property gce_MakeLin2d* IHandle { gce_MakeLin2d* get() { return NativeHandle; } void set(gce_MakeLin2d* handle) { NativeHandle = handle; } } private: gce_MakeLin2d* NativeHandle; }; } #endif // _xgce_MakeLin2d_HeaderFile
0407cf9dc76397bb85dbb3ffb38e97b9df5aad80
a614262ec7646c0529955b45e7a3b6ce2bb2ee99
/pHmetro.ino
aaad29aebed44a67ac6d6663c1098d2e94018ebc
[]
no_license
AlmirFill/inex_iot
08ddc2c0f60cc02c83bf3d8f2829148d40664205
4c05dadd229210d333d118bdee08f574f897d247
refs/heads/master
2023-02-24T17:45:42.708145
2021-01-27T02:08:35
2021-01-27T02:08:35
250,412,869
0
0
null
null
null
null
UTF-8
C++
false
false
7,952
ino
pHmetro.ino
// #include <SoftwareSerial.h> // #include <LiquidCrystal_I2C.h> #include <EEPROM.h> #include <SPI.h> #include <SD.h> #include <Wire.h> #include "RTClib.h" RTC_DS1307 rtc; //Pino CS do modulo cartao SD const int chipSelect = 10; File dataFile; DateTime now = rtc.now(); // // //LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // select the pins used on the LCD panel // LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE); // Inicializa o display no endereco 0x27 // // // define some values used by the panel and buttons // #define btnFood 6 #define btnSymptom 7 #define btnLye 5 #define TIMER_LONG 5000 #define TIMER_LITLE 500 long timerInit; bool exameOn = false; // const int NumReadings = 10; // number of reading // int Index_1 = 0; // index // int Index_2 = 0; // index // int Ph1Readings[NumReadings]; // array for store PH1 readings // double ph_ch1[NumReadings]; // double Ph1Total = 0; // PH1 running total // double Ph1Average = 0; // PH1 average reading // int Ph2Readings[NumReadings]; // array for store PH2 readings // double ph_ch2[NumReadings]; // double Ph2Total = 0; // PH2 running total // double Ph2Average = 0; // PH2 average reading // double Ph7Buffer = 7; // For PH7 buffer solution's PH value , 7 or 6.86 // double Ph4Buffer = 1; // For PH4 buffer solution's PH value , 4 or 4.01 // double Ph7Ch1Reading = 373; // PH7 Buffer Solution Reading. // double Ph7Ch2Reading = 291; // PH7 Buffer Solution Reading. // double Ph4Ch1Reading = 428; // PH4 Buffer Solution Reading. // double Ph4Ch2Reading = 441; // PH4 Buffer Solution Reading. // double Ph1Ratio = 0; // PH1 Step // double Ph1Value = 0; // Ph1 Value in Human Reading Format after calculation // double Ph2Ratio = 0; // PH2 Step // double Ph2Value = 0; // Ph2 Value in Human Reading Format after calculation // long previousMillis = 0; // Variável de controle do tempo // long Interval = 4000; // Tempo em ms do intervalo a ser executado // boolean setDisplay = true; int reading_1(){ // Reading PH Data // Samplin PH Value Ph1Total = Ph1Total - Ph1Readings[Index_1]; // subtract the last reading: Ph1Readings[Index_1] = analogRead(3); // read from the sensor : PH1 Ph1Total = Ph1Total + Ph1Readings[Index_1]; // add the reading to the ph1 total: Index_1 = Index_1 + 1; // advance to the next position in the array: if (Index_1 >= NumReadings){ // if we're at the end of the array... Index_1 = 0; // ...wrap around to the beginning: Ph1Average = Ph1Total / NumReadings; // calculate the average1: for(int i = 0; i<NumReadings; i++){ ph_ch1[i] = (Ph7Ch1Reading - Ph1Readings[i]) / Ph1Ratio + Ph7Buffer; } } Ph1Value = (Ph7Ch1Reading - Ph1Average) / Ph1Ratio + Ph7Buffer; // Calculate PH ch1 } int reading_2(){ // Reading PH Data // Samplin PH Value Ph2Total = Ph2Total - Ph2Readings[Index_2]; Ph2Readings[Index_2] = analogRead(2); // read from the sensor : PH2 Ph2Total = Ph2Total + Ph2Readings[Index_2]; // add the reading to the ph2 total: Index_2 = Index_2 + 1; // advance to the next position in the array: if (Index_2 >= NumReadings){ // if we're at the end of the array... Index_2 = 0; // ...wrap around to the beginning: Ph1Average = Ph1Total / NumReadings; // calculate the average1: Ph2Average = Ph2Total / NumReadings; // calculate the average2: for(int i = 0; i<NumReadings; i++){ ph_ch2[i] = (Ph7Ch2Reading - Ph2Readings[i]) / Ph1Ratio + Ph7Buffer; } } Ph2Value = (Ph7Ch2Reading - Ph2Average) / Ph2Ratio + Ph7Buffer; // Calculate PH ch2 } void setup(){ initialize(); } void loop(){ reading_1(); reading_2(); showData(); if(getExameOn()){ saveData(); handleBtnLye(); handleBtnFood(); handleBtnSymptom(); } delay(1); } void initialize(){ lcd.begin(16, 2); // start LCD library Serial.begin(9600); // Serial Monitor pinMode(btnFood, INPUT); pinMode(btnLye, INPUT); pinMode(btnSymptom, INPUT); //----------------Inicializa o RTC------------------- if (! rtc.isrunning()) { Serial.println("RTC is NOT running!"); // This will reflect the time that your sketch was compiled rtc.adjust(DateTime(__DATE__, __TIME__)); } rtc.adjust(DateTime(__DATE__, __TIME__)); //--------------------------------------------------- //----------Inicializa o Modulo SD Card-------------- Serial.println("Inicializando SD card..."); if (!SD.begin(chipSelect)) { Serial.println("Inicializacao falhou!"); return; } Serial.println("Inicializacao finalizada."); //--------------------------------------------------- for (int PhThisReading = 0; PhThisReading < NumReadings; PhThisReading++){ // initialize all the Ph readings to 0: Ph1Readings[PhThisReading] = 0; Ph2Readings[PhThisReading] = 0; } Ph1Ratio = (Ph4Ch1Reading - Ph7Ch1Reading) / (Ph7Buffer - Ph4Buffer); // Calculate Ph1 Ratio Ph2Ratio = (Ph4Ch2Reading - Ph7Ch2Reading) / (Ph7Buffer - Ph4Buffer); // Calculate Ph2 Ratio } bool getExameOn(){ bool stateReturn; stateReturn = exameOn; return stateReturn; } void showData(){ if(getExameOn()){ lcd.clear(); lcd.setCursor(3,0); // set the LCD cursor position lcd.print("Ch1"); lcd.setCursor(10,0); lcd.print("Ch2"); // Display PH Data lcd.setCursor(3,1); lcd.print(Ph1Value,1); // display PH1 value // Display PH Data lcd.setCursor(10,1); lcd.print(Ph2Value,1); }else{ lcd.clear(); lcd.setCursor(9,0); lcd.print(now.hour(), DEC); lcd.print(':'); lcd.print(now.minute(), DEC); lcd.setCursor(15,0); lcd.print("*"); lcd.setCursor(1,1); // set the LCD cursor position lcd.print("|inicia exame|"); delay(500); } // display PH2 value } void saveData(){ //Send do SDCard dataFile = SD.open("dataPH.txt", FILE_WRITE); //define // if the file opened okay, write to it: // if the file opened okay, write to it: if (dataFile && getExameOn()) { //Send to data.txt dataFile.print(now.hour(), DEC); dataFile.print(':'); dataFile.print(now.minute(), DEC); dataFile.print(':'); dataFile.print(now.second(), DEC); dataFile.print(";"); dataFile.print(Ph1Value); dataFile.print(";"); dataFile.println(Ph2Value); //Send to Serial Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.print("; "); Serial.print(Ph1Value); Serial.print("; "); Serial.println(Ph2Value); // close the file data.txt: dataFile.close(); } } void calibrarPh7(){ Ph7Ch1Reading = Ph1Average; Ph7Ch2Reading = Ph2Average; }
41ccb7674939da333b945678fb1ac65bb6ae72e6
98f9f977a39843e5f7719062f43011ebfd169e42
/Libs/Visualization/VTK/Widgets/ctkVTKRenderViewEventTranslator.h
312934bb2203bb2c5c996c115ec3ba1e061bd8b2
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
txdy077345/CTK
71cab2d77193d09340afe7a50e5dddc3ea66a06d
7cd253376139ea73f0450e1bad75bab41aa1b507
refs/heads/master
2023-05-27T19:20:21.825916
2023-04-29T16:35:03
2023-04-29T16:35:03
276,658,777
1
0
Apache-2.0
2020-07-02T13:50:30
2020-07-02T13:50:29
null
UTF-8
C++
false
false
1,635
h
ctkVTKRenderViewEventTranslator.h
/*========================================================================= Library: CTK Copyright (c) Kitware Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =========================================================================*/ #ifndef __ctkVTKRenderViewEventTranslator_h #define __ctkVTKRenderViewEventTranslator_h // QT includes #include <QMouseEvent> // QtTesting includes #include <pqWidgetEventTranslator.h> // CTK includes #include <ctkPimpl.h> #include "ctkVisualizationVTKWidgetsExport.h" class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKRenderViewEventTranslator : public pqWidgetEventTranslator { Q_OBJECT public: typedef pqWidgetEventTranslator Superclass; ctkVTKRenderViewEventTranslator(const QByteArray& Classname, QObject* Parent=0); ~ctkVTKRenderViewEventTranslator(); using Superclass::translateEvent; virtual bool translateEvent(QObject *Object, QEvent *Event, bool &Error); protected: QByteArray mClassType; QMouseEvent lastMoveEvent; QMouseEvent oldMoveEvent; QMouseEvent lastMouseEvent; private: Q_DISABLE_COPY(ctkVTKRenderViewEventTranslator); }; #endif
3de688aefbe04f628210a9212e8298162d7b7320
0fda8a4559773c8aebc235e82c6dc625eb6e3cd9
/BrickBreaker/Level.h
ab855a221bc2216a64d8553f5c92538719999746
[]
no_license
lkomanetz/BrickBreaker
6c24408ce0485249d0dc328a681e071d7c74d75d
77680049d704a91733d204fc535a6a30cd92adbf
refs/heads/master
2021-01-11T08:02:50.052370
2016-11-03T21:11:54
2016-11-03T21:11:54
70,110,763
0
0
null
null
null
null
UTF-8
C++
false
false
664
h
Level.h
#pragma once #ifndef _LEVEL_H #define _LEVEL_H #include <string> #include "Brick.h" #include "Engine/Graphics.h" class Level { private: std::string _name; int _id; std::string _layoutString; Graphics* p_graphics; void construct(); public: Level(); Level(Graphics* pGraphics); Level(const Level& obj); virtual ~Level(); Level& operator=(const Level& rightObj); void setName(std::string newName) { _name = newName; } void setId(int newId) { _id = newId; } void setLayoutString(std::string newContent); std::string getName() { return _name; } int getId() const { return _id; } std::string getLayoutString() { return _layoutString; } }; #endif
84a091e5e9538646397fba2adac9252e5e1d20ab
91babf20eaef63cf1813abbeb851572383d29d56
/nera/include/nera/memory.h
a042897b7c3c2f9dd99f35b91e3be4fb1bc48f87
[]
no_license
r-neal-kelly/nera
58efe93568390ca9d9ff224af978b702d9369e62
235bc8128caf867cb8357c309fec8a700ab9bcd2
refs/heads/master
2022-12-23T03:52:41.614152
2020-09-15T03:15:24
2020-09-15T03:15:24
275,288,248
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,637
h
memory.h
/* Copyright © 2020 r-neal-kelly, aka doticu */ #pragma once #include "nera/allocator.h" #include "nera/pointer.h" namespace nera { template <typename data_t> class manual_memory_t { public: pointer_t<data_t> pointer; manual_memory_t(); manual_memory_t(const allocator_t& allocator, size_t count); manual_memory_t(const manual_memory_t<data_t>& to_copy) = default; manual_memory_t(manual_memory_t<data_t>&& to_move); manual_memory_t<data_t>& operator=(const manual_memory_t<data_t>& to_copy) = default; manual_memory_t<data_t>& operator=(manual_memory_t<data_t>&& to_move); ~manual_memory_t(); bool hold(const allocator_t& allocator, size_t count); bool free(const allocator_t& allocator); size_t count(); data_t& operator [](size_t index); }; template <typename data_t> class auto_memory_t { public: pointer_t<data_t> pointer; const allocator_t& allocator; auto_memory_t(); auto_memory_t(const allocator_t& allocator); auto_memory_t(const allocator_t& allocator, size_t count); auto_memory_t(const auto_memory_t<data_t>& to_copy); auto_memory_t(auto_memory_t<data_t>&& to_move) noexcept; auto_memory_t<data_t>& operator=(const auto_memory_t<data_t>& to_copy); auto_memory_t<data_t>& operator=(auto_memory_t<data_t> && to_move) noexcept; ~auto_memory_t(); bool hold(size_t count); bool free(); size_t count(); data_t& operator [](size_t index); }; } #include "nera/memory.inl"
60413b9ad8c2af6bef9b989e473d9c9ff5c99920
01d6feb157226d01ffd19d52fe3927cc80bbf718
/packages/plugin_library/URRealTimeDriver/RealTimeAdapter/CobotUrRealTimeComm.h
9d125253be402ba8990ab069266780b455a13f54
[]
no_license
jackros1022/UrRobotControllerInTCP
3dda2d17d4bbc120bcd5b29bdc753f3df084790c
3dd388c58b21d909b6c69c4d6160e631ab306a7a
refs/heads/master
2020-03-25T16:52:10.601581
2018-02-13T12:30:26
2018-02-13T12:30:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,033
h
CobotUrRealTimeComm.h
// // Created by 潘绪洋 on 17-3-28. // Copyright (c) 2017 Wuhan Collaborative Robot Technology Co.,Ltd. All rights reserved. // #ifndef PROJECT_COBOTURREALTIMECOMM_H #define PROJECT_COBOTURREALTIMECOMM_H #include <QObject> #include <QString> #include <QTcpSocket> #include <QTcpServer> #include <memory> #include <thread> #include <QSemaphore> #include "../URDriver/robot_state_RT.h" class CobotUrRealTimeComm : public QObject { Q_OBJECT public: CobotUrRealTimeComm(std::condition_variable& cond_msg, const QString& hostIp, QObject* parent = nullptr); ~CobotUrRealTimeComm(); void start(); void readData(); void onConnected(); void onDisconnected(); std::shared_ptr<RobotStateRT> getRobotState(){ return m_robotState; } /** * 发送给UR的即时脚本命令。 * @param ba */ void writeLine(const QByteArray& ba); void servoj(const std::vector<double>& j); void stopProg(); /** * 这个函数是专门写来用于异步线程发送命令的,可以直接调用 * @param positions */ void asyncServoj(const std::vector<double>& positions); Q_SIGNALS: void connected(); void disconnected(); void connectFail(); void realTimeProgConnected(); void realTimeProgDisconnect(); void asyncServojFlushRequired(); protected: void urProgConnect(); void onRealTimeDisconnect(); void asyncServojFlush(); void onSocketError(QAbstractSocket::SocketError socketError); void onRealTimeData(); protected: QString m_hostIp; std::shared_ptr<RobotStateRT> m_robotState; QTcpSocket* m_SOCKET; std::condition_variable& m_msg_cond; QTcpServer* m_tcpServer; QTcpSocket* m_rtSOCKET; std::mutex m_rt_res_mutex; std::vector<double> m_rt_q_required; std::vector<double> m_qTarget; public: const int MULT_JOINTSTATE_ = 1000000; const int MULT_TIME_ = 1000000; const unsigned int REVERSE_PORT_ = 50007; int keepalive; }; #endif //PROJECT_COBOTURREALTIMECOMM_H
b71e499a59a327aaed17012bf1e72f30cc9ebbb5
e751287beae87a8a7c494240583c4c785418534b
/prime/1152/main.cpp
4e86ee3c6d30b92fe1e69469ebe8d6ae2c293b23
[]
no_license
zhongyj1999/pat
2750ec4924696e86d716dd66b57b196aa7c36b1b
a4cafd45d2661ff8e5c914c223ce86b6ae68725e
refs/heads/master
2021-02-03T21:12:03.702921
2020-03-14T12:39:19
2020-03-14T12:39:19
243,539,065
0
0
null
null
null
null
UTF-8
C++
false
false
587
cpp
main.cpp
#include <iostream> #include <string> using namespace std; bool isprim(int a){ if(a == 1 || a == 0) return false; for(int i = 2; i * i <= a; i++) if(a % i == 0) return false; return true; } int main() { int n, m; scanf("%d %d", &n, &m); string s; cin >> s; for(int i = 0; i <= n - m; i++){ string temp = s.substr(i, m); //cout << temp <<endl; int ans = stoi(temp); //cout << ans<<endl; if(isprim(ans)){ cout << temp; return 0; } } printf("404\n"); return 0; }
eec281c407729ecb046acc236f20878246d6bcde
176986455dfeeca37515ff3c7041fc152af8bb1b
/modules/commands/os_kick.cpp
933757ce6fa0a1ce327a9d4efaf151e8ef8f989f
[]
no_license
anope/anope
bda831995dccd78acc2fc1d3071dd69df53c6af5
0a3ddef3151ef4258e529f5850be08810fa146d3
refs/heads/2.0
2023-09-03T07:25:54.572371
2023-08-31T06:17:56
2023-08-31T06:19:00
909,217
284
176
null
2023-08-31T06:19:54
2010-09-14T06:25:30
C++
UTF-8
C++
false
false
2,132
cpp
os_kick.cpp
/* OperServ core functions * * (C) 2003-2023 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. */ #include "module.h" class CommandOSKick : public Command { public: CommandOSKick(Module *creator) : Command(creator, "operserv/kick", 3, 3) { this->SetDesc(_("Kick a user from a channel")); this->SetSyntax(_("\037channel\037 \037user\037 \037reason\037")); } void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override { const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; const Anope::string &s = params[2]; Channel *c; User *u2; if (!(c = Channel::Find(chan))) { source.Reply(CHAN_X_NOT_IN_USE, chan.c_str()); return; } if (c->bouncy_modes) { source.Reply(_("Services is unable to change modes. Are your servers' U:lines configured correctly?")); return; } if (!(u2 = User::Find(nick, true))) { source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); return; } if (!c->Kick(source.service, u2, "%s (%s)", source.GetNick().c_str(), s.c_str())) { source.Reply(ACCESS_DENIED); return; } Log(LOG_ADMIN, source, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")"; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { this->SendSyntax(source); source.Reply(" "); source.Reply(_("Allows staff to kick a user from any channel.\n" "Parameters are the same as for the standard /KICK\n" "command. The kick message will have the nickname of the\n" "IRCop sending the KICK command prepended; for example:\n" " \n" "*** SpamMan has been kicked off channel #my_channel by %s (Alcan (Flood))"), source.service->nick.c_str()); return true; } }; class OSKick : public Module { CommandOSKick commandoskick; public: OSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandoskick(this) { } }; MODULE_INIT(OSKick)
eeb3528dfeddab9f101b0feb90e4cd6c38897ccb
463ccbc7b19822e3695e02d27e255ce64eacb627
/ie3D-Demo/Sources/CDemoGameScene.cpp
435588c4f01d05988b29218206092527213eb4d3
[]
no_license
codeoneclick/ie3D
8abd318361ff80fbbfe5273943183fe158bf40af
46f109a520c6d813c3994b5cf2b12e2de5625371
refs/heads/master
2021-01-24T06:37:41.615380
2014-05-23T14:02:12
2014-05-23T14:02:12
9,913,979
10
2
null
null
null
null
UTF-8
C++
false
false
2,729
cpp
CDemoGameScene.cpp
// // CDemoGameScene.cpp // indie2dEngine // // Created by Sergey Sergeev on 7/22/13. // Copyright (c) 2013 Sergey Sergeev. All rights reserved. // #include "CDemoGameScene.h" #include "IGameTransition.h" #include "IGameObject.h" #include "CCommonOS.h" #include "CLight.h" #include "CModel.h" #include "COcean.h" #include "CLandscape.h" #include "CSkyBox.h" #include "CParticleEmitter.h" #include "CCamera.h" #include "CMapDragController.h" CDemoGameScene::CDemoGameScene(IGameTransition* root) : IScene(root) { } CDemoGameScene::~CDemoGameScene(void) { } void CDemoGameScene::load(void) { assert(m_root != nullptr); m_camera = m_root->CreateCamera(90.0f, 0.1f, 1024.0f, glm::ivec4(0, 0, m_root->getWindowWidth(), m_root->getWindowHeight())); m_camera->Set_Position(glm::vec3(0.0f, 0.0f, 0.0f)); m_camera->Set_LookAt(glm::vec3(12.0f, 4.0f, 12.0f)); m_camera->Set_Distance(32.0f); m_camera->Set_Height(32.0f); m_root->Set_Camera(m_camera); std::shared_ptr<COcean> ocean = m_root->CreateOcean("gameobject.ocean.xml"); m_root->InsertOcean(ocean); ocean->setPosition(glm::vec3(0.0f, 0.0f, 0.0f)); m_skyBox = m_root->createSkyBox("gameobject.skybox.xml"); m_root->InsertSkyBox(m_skyBox); std::shared_ptr<CParticleEmitter> particleEmitter = m_root->CreateParticleEmitter("gameobject.particle.emitter.xml"); particleEmitter->setPosition(glm::vec3(12.0f, 2.0f, 12.0f)); m_particles.push_back(particleEmitter); m_root->InsertParticleEmitter(particleEmitter); std::shared_ptr<CLandscape> landscape = m_root->CreateLandscape("gameobject.landscape.xml"); m_root->InsertLandscape(landscape); /*for(ui32 i = 0; i < landscape->getChunks().size(); ++i) { m_colliders.push_back(landscape->getChunks().at(i)); }*/ m_root->addCollisionHandler(shared_from_this()); m_mapDragController = std::make_shared<CMapDragController>(m_camera, 0.1, glm::vec3(0.0, 0.0, 0.0), glm::vec3(512.0, 0.0, 512.0)); m_root->addGestureRecognizerHandler(m_mapDragController); } void CDemoGameScene::update(f32 deltatime) { m_mapDragController->update(deltatime); static f32 angle = 0.0; angle += 0.1; m_skyBox->setRotation(glm::vec3(0.0, angle, 0.0)); } void CDemoGameScene::onCollision(const glm::vec3& position, ISharedGameObjectRef gameObject) { }
bcb693bebfddfa08e80d05a8161b4b7653863456
69cfdcc5dc78ffe2cedb6f952261eab1044f8787
/tokens/InitializationToken.cpp
b6a7ef576c53809aafdedaecf666702bea006902
[]
no_license
asm2015coursework/the_best_compilator_ever
53cfdaa92cf3ba6e4f69ccbd33bcea1788ee0671
eed0c3f277885e5189f5f6c04ae5c59892705d1c
refs/heads/master
2020-06-04T04:23:04.422740
2015-06-29T08:00:50
2015-06-29T08:00:50
35,106,026
7
1
null
null
null
null
UTF-8
C++
false
false
537
cpp
InitializationToken.cpp
#include "InitializationToken.h" InitializationToken::InitializationToken(string type, string name, Token *expr, Token* size) { this->_name = name; this->_type = type; this->_expr = expr; this->_size = size; } string InitializationToken::toString() { string ans = _type + " " + _name; if (_size != nullptr) ans += "[" + _size->toString() + "]"; if (_expr != nullptr) ans += " = " + _expr->toString(); else ans += ""; return ans; } string InitializationToken::getType() { return "Initialization"; }
09f7a137c159b62beb5614ff3ee69e7455124d69
3d4f601fee634723f25f739f755bd0aca2b3a489
/cf3/ui/graphics/GraphicalInt.hpp
9676bc268d88a9f7bbb349b80bcaefedd9246957
[]
no_license
barche/coolfluid3
69d8701a840377e83bb46b158300da6d4d8f3bc5
688173daa1a7cf32929b43fc1a0d9c0655e20660
refs/heads/master
2021-07-16T18:09:42.818240
2020-08-06T11:55:11
2020-08-06T11:55:11
2,173,454
2
7
null
2020-09-20T20:57:29
2011-08-08T13:37:11
C++
UTF-8
C++
false
false
1,311
hpp
GraphicalInt.hpp
// Copyright (C) 2010-2011 von Karman Institute for Fluid Dynamics, Belgium // // This software is distributed under the terms of the // GNU Lesser General Public License version 3 (LGPLv3). // See doc/lgpl.txt and doc/gpl.txt for the license text. #ifndef cf3_ui_Graphics_GraphicalInt_hpp #define cf3_ui_Graphics_GraphicalInt_hpp //////////////////////////////////////////////////////////////////////////// #include "ui/graphics/GraphicalValue.hpp" class QDoubleSpinBox; //////////////////////////////////////////////////////////////////////////// namespace cf3 { namespace ui { namespace graphics { ////////////////////////////////////////////////////////////////////////// class Graphics_API GraphicalInt : public GraphicalValue { Q_OBJECT public: GraphicalInt(bool isUint, QVariant value = 0, QWidget * parent = 0); ~GraphicalInt(); virtual bool set_value(const QVariant & value); virtual QVariant value() const; private slots: void integer_changed(double value); private: QDoubleSpinBox * m_spin_box; bool m_isUint; }; // class GraphicalInt ////////////////////////////////////////////////////////////////////////// } // Graphics } // ui } // cf3 //////////////////////////////////////////////////////////////////////////// #endif // cf3_ui_Graphics_GraphicalInt_hpp
a8b997b09ae0cf157c7ce7d3b8846a50bd6aa595
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5688567749672960_1/C++/taobingxue/ALarge.cpp
6071830cbcf95ffcfdabefa02921bcab7af281cd
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
2,048
cpp
ALarge.cpp
#include <iostream> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> #include <algorithm> using namespace std; int f[1000005]; int T; long long N; long long get(long long n) { if (n <= 1000000) return f[n]; int len = 0; int a[20]; long long num = n; for (; n > 0; len ++) { a[len] = n%10; n/=10; } int numlen = len >> 1; int reslen = len - numlen; bool check = true; for (int i=0; i<reslen; i++) if (a[i]) { check = false; break;} if (check) { int nowp = reslen; while (a[nowp] == 0) { a[nowp] = 9; nowp += 1; } a[nowp] -= 1; if (nowp == len-1 && a[nowp] == 0 && numlen != reslen) { a[reslen-1] = 9; len -= 1; reslen -= 1; } } check = true; for (int i=reslen; i < len-1; i++) { if (a[i]) {check = false; break; } } if (check && a[len-1] == 1) { a[len-1] = 0; len -= 1; if (reslen == numlen) numlen -= 1; else reslen -= 1; for (int i=reslen; i<len; i++) a[i] = 9; } long long newnum = 0; for (int i=0; i<numlen; i++) newnum = newnum * 10 + a[len-1-i]; for (int i=0; i<reslen; i++) newnum *= 10; newnum += 1; long long resnum = 0, newnumc = newnum; while (newnumc > 0) { resnum = resnum * 10 + newnumc%10; newnumc /= 10; } //printf("%I64d ", resnum); return get(resnum) + 1 + num - newnum; } int main(int argc, char** argv) { freopen("aL.in", "r", stdin); freopen("aL.out", "w", stdout); f[1] = 1; for (int i=2; i<=1000000; i++) { f[i] = f[i-1] + 1; if (i%10) { int j = i, s = 0; for ( ; j>0; j /= 10) s = s*10 + j % 10; if (s < i && f[i] > f[s] +1) { f[i] = f[s] + 1; // printf("%d\n", i); } } } scanf("%d", &T); for (int times=1; times<=T; times++) { scanf("%lld", &N); long long result = get(N); printf("Case #%d: %lld\n", times, result); // if (result != f[N]) printf("QAQ"); } /* for (int i=1; i < 1000000; i++) { printf("%d ", f[i]); if (i%5 == 0) printf("\n"); }*/ return 0; }
38fb9f02d58227c3a1d91cb923a4f6983d48935a
934372e2034e93b8220eab745486ab079c225dd6
/part8/MyDirect.cpp
3f7ae864b3d7492f6c07c60132f1e7a38c27e6fb
[]
no_license
luckyan315/imsvr
f3aa96cb5575d40b500214eaebca33795d87c4d8
24babadb2cc2ec7a3c061758453f13068cc25168
refs/heads/master
2021-01-18T12:16:54.468662
2013-05-19T04:35:12
2013-05-19T04:35:12
9,259,236
1
0
null
null
null
null
GB18030
C++
false
false
5,619
cpp
MyDirect.cpp
#include "StdAfx.h" #include "MyDirect.h" #include <mmsystem.h> #include <stdio.h> #include <cassert> #include "AcquireExecutionTime.h" CMyDirect::CMyDirect(HWND hWnd, UINT adapterID) :m_adapterID(adapterID) ,m_hWnd(hWnd) ,m_pD3D(NULL) ,m_pd3dDevice(NULL) { ZeroMemory( &m_d3dpp, sizeof( m_d3dpp ) ); } CMyDirect::~CMyDirect(void) { this->CleanupMe(); this->Cleanup(); } HRESULT CMyDirect::InitD3D(BOOL defaultWindowed) { if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) { //LOG_ERROR("Direct Create Error!"); return E_FAIL; } //Presentation Setting == render method m_d3dpp.Windowed = defaultWindowed; m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; m_d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; //m_d3dpp.BackBufferFormat = D3DFMT_R5G6B5; m_d3dpp.BackBufferCount = 1; m_d3dpp.BackBufferHeight = SCREEN_HEIGHT; m_d3dpp.BackBufferWidth = SCREEN_WIDTH; m_d3dpp.hDeviceWindow = m_hWnd; m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; //这个可以提高速度 // 创建D3D设备 if( FAILED( m_pD3D->CreateDevice( m_adapterID, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &m_d3dpp, &m_pd3dDevice ) ) ) { //LOG_ERROR("Create Device Error!"); return E_FAIL; } this->SetState(); OnDeviceInited(); return S_OK; } void CMyDirect::SetState() { // 设置设备状态 // 设置渲染格式 m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); // 关闭光照 m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); } void CMyDirect::Cleanup() { if( m_pd3dDevice != NULL ) { m_pd3dDevice->Release(); m_pd3dDevice = NULL; } if( m_pD3D != NULL ) { m_pD3D->Release(); m_pD3D = NULL; } } void CMyDirect::ToggleFullScreen() { m_d3dpp.Windowed = !m_d3dpp.Windowed; // Notify objects if needed OnDeviceLost(); // Reset device HRESULT hResult = m_pd3dDevice->Reset(&m_d3dpp); if(FAILED(hResult)) { //LOG_ERROR("Reset Device Error!"); return ; } // Update window style if(m_d3dpp.Windowed) { SetWindowLong(m_d3dpp.hDeviceWindow, GWL_STYLE, WS_OVERLAPPEDWINDOW); SetWindowPos(m_d3dpp.hDeviceWindow, HWND_TOP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); } else { SetWindowLong(m_d3dpp.hDeviceWindow, GWL_STYLE, WS_POPUPWINDOW); SetWindowPos(m_d3dpp.hDeviceWindow, HWND_TOP, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); } // Reset render states, etc SetState(); } void CMyDirect::Render() { assert(m_pd3dDevice); // 清除场景背景 m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // 场景开始渲染 if( SUCCEEDED( m_pd3dDevice->BeginScene() ) ) { OnRender2D(); // 场景结束渲染 m_pd3dDevice->EndScene(); } // 提交缓冲 m_pd3dDevice->Present( NULL, NULL, NULL, NULL ); } double CMyDirect::FPS(double elapseMS) { static double fps = 0.0f; static int num = 0; ++num; static AcquireExecutionTime t; double ts = t.GetTimeSpanMS(false); if( ts > elapseMS) { fps = (double)(num) * 1000 / ts; num = 0; t.Reset(); } return fps; } //Body -- Only For Test void CMyDirect::OnDeviceInited() { /* ::CreateTexture9(m_pd3dDevice); D3DXCreateSprite(m_pd3dDevice, &g_Sprite); */ } //Body -- Only For Test void CMyDirect::OnDeviceLost() { /* g_Sprite->OnLostDevice(); */ } //Body -- Only For Test void CMyDirect::OnRender2D() { /* D3DXVECTOR2 Translation; Translation.x = 0; Translation.y = 0; D3DXVECTOR2 Scaling; Scaling.x = 1.0f; Scaling.y = 1.0f; D3DXMATRIX Mat; D3DXMatrixTransformation2D(&Mat, NULL, 0, &Scaling, NULL, 0, &Translation); g_Sprite->Begin(0); g_Sprite->SetTransform(&Mat); static int i = 0; static AcquireExecutionTime t; double ts = t.GetTimeSpanMS(); if( ts >= 50) { ++i; i %= MAX_BMP_LEN; t.Reset(); } m_pd3dDevice->SetTexture(0, g_pTextures[i]); g_Sprite->Draw(g_pTextures[i], NULL, NULL, NULL, 0xFFFFFFFF ); g_Sprite->End(); char str[128]; sprintf(str, "%.3f", CMyDirect::FPS()); SetWindowText(m_hWnd, str); */ } //Body -- Only For Test void CMyDirect::CleanupMe() { /* for(int i = 0 ; i < MAX_BMP_LEN; ++i) { if(g_pTextures[i] != NULL) { g_pTextures[i]->Release(); g_pTextures[i] = NULL; } } if(g_Sprite != NULL) { g_Sprite->Release(); g_Sprite = NULL; }*/ }
8482b070288ad8b3ddf618c8dc83ad9ba5ea7c07
05c9e8f9b2d753f963bf34fe22a52977ce564f95
/maze-arizona/controls.h
3cee07d4981a15b91ce7cfa322b99ddecffe00bd
[]
no_license
INMihaylov19/Maze-Game
410d4dca94bb7f9014ae6ed9b3164dc265a8b720
1573b144b75e73c928e8321b200d9bee5d41370e
refs/heads/main
2023-08-26T08:28:26.636638
2021-11-08T19:09:58
2021-11-08T19:09:58
417,808,387
1
1
null
null
null
null
UTF-8
C++
false
false
227
h
controls.h
#pragma once #include <iostream> #include <conio.h> #include <windows.h> int SetColor[]; int SetColor2[]; extern const char Player; void color(int color); void gotoxy(int x, int y); void controls(char **arr, int size);
ed9cb14d523f653227e88fc7f31ebc5007e10f29
23d6af0bed1677e59916fbba4ecab8256db79fbf
/Drawing/Shape.h
710b600948540598dada26e064d29d016ed5e90a
[]
no_license
OC-MCS/program6-02-drawing-JamesR0e
c6ec6b122dab3215876f237ea2cccf3943df16ae
361aa22065e9bae26f837c5daee7895e2dddf98b
refs/heads/master
2020-05-02T10:07:41.673638
2019-04-11T01:45:29
2019-04-11T01:45:29
177,888,987
0
0
null
null
null
null
UTF-8
C++
false
false
853
h
Shape.h
#pragma once #include <SFML/Graphics.hpp> #include <string> #include "SettingsMgr.h" using namespace std; using namespace sf; //struct used for writing data to and from binary file struct shapedata { ShapeEnum shape; int color; Vector2f position; }; //abstract base class for shapes class DrawingShape { public: virtual void draw(RenderWindow & win) = 0; virtual shapedata getFileRecord() = 0; }; //class circle is derived from DrawingShape class Circle : public DrawingShape { private: CircleShape c; public: Circle(Color color, Vector2f position); void draw(RenderWindow & win); shapedata getFileRecord(); }; //class square is derived from DrawingShape class Square : public DrawingShape { private: RectangleShape s; public: Square(Color color, Vector2f position); void draw(RenderWindow & win); shapedata getFileRecord(); };
fe216dc2e3be96972528cc298046f2a33356abaf
88ae8695987ada722184307301e221e1ba3cc2fa
/buildtools/third_party/libc++abi/trunk/test/catch_array_02.pass.cpp
f92749adba18bad8c16718852afaf402579b00a6
[ "NCSA", "MIT", "Apache-2.0", "LLVM-exception", "BSD-3-Clause" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
780
cpp
catch_array_02.pass.cpp
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // Can you have a catch clause of array type that catches anything? // UNSUPPORTED: no-exceptions #include <cassert> int main(int, char**) { typedef char Array[4]; Array a = {'H', 'i', '!', 0}; try { throw a; // converts to char* assert(false); } catch (Array b) // equivalent to char* { } catch (...) { assert(false); } return 0; }
63cc7f56f1c1a40c4d7416eee176a6c6f17bdfe5
7f0a0660cc25e4a61172170b8e57f15f19417b48
/2021-22-2/monday10-12/09gy/linked_list.cpp
5dd29b43f34a7aa18c5d6e3ac207beb4458a30b3
[]
no_license
Szelethus/cpp_courses
f1e38b477b6d81cb4563b6829ecdf0c8bd14c346
6673a62f5bda4d4d81dfb9478b0098fde90e826c
refs/heads/master
2023-08-18T03:59:28.960836
2023-05-23T07:43:00
2023-05-23T07:43:00
171,329,370
1
0
null
null
null
null
UTF-8
C++
false
false
1,466
cpp
linked_list.cpp
#include <iostream> struct Node { int data; Node *next; }; class LinkedList { Node *head; public: LinkedList() : head(nullptr) {} LinkedList(const LinkedList &other) : head(nullptr) { if (other.head == nullptr) return; Node *ptr = other.head; while (ptr != nullptr) { this->push_back(ptr->data); ptr = ptr->next; } } LinkedList &operator=(const LinkedList &other) { // clear out the existing list deallocate(); head = nullptr; Node *ptr = other.head; while (ptr != nullptr) { this->push_back(ptr->data); ptr = ptr->next; } return *this; } ~LinkedList() { deallocate(); } private: void deallocate() { Node *ptr = head; while (ptr != nullptr) { Node *nextNode = ptr->next; delete ptr; ptr = nextNode; } } public: void push_back(int data) { // A lista üres! if (head == nullptr) { head = new Node{data, nullptr}; return; } Node *ptr = head; while (ptr->next != nullptr) { ptr = ptr->next; } ptr->next = new Node{data, nullptr}; } void display() const { Node *ptr = head; while (ptr != nullptr) { std::cout << ptr->data << ' '; ptr = ptr->next; } std::cout << '\n'; } }; int main() { LinkedList l; l.push_back(2); l.push_back(3); l.push_back(4); l.push_back(5); LinkedList l2 = l; l2 = l; l.display(); l2.display(); }
0dba8bd1ea4dd866f71b40c792775edee5c012ff
b04e71b13e659929815c64282e1a56928e2b355b
/Brown/first_week/first_week/main.cpp
c76785c98468f243dbd92e9e478a344c584ccef6
[]
no_license
momsspaghettti/coursera-c-plus-plus-modern-development
98f0ef39dcec90cc96b3178d1fec492fe87be1c7
f38464dc422e2e6891972dff5a0e576d7a41bc9f
refs/heads/master
2020-05-26T03:00:58.262528
2019-11-06T18:51:04
2019-11-06T18:51:04
188,082,349
86
70
null
null
null
null
UTF-8
C++
false
false
322
cpp
main.cpp
#include "priority_collection.h" #include "hash_set.h" #include "set_iterator_next.h" #include "hash_point.h" #include "hash_person.h" #include "secondary_index.h" int main() { TestPriorityCollection(); TestHashSet(); TestSetIteratorNext(); TestHashPoint(); TestHashPerson(); TestSecondaryIndex(); return 0; }
ff1ea0ea883acd0c5610d690909bcb61a8f759f9
13011306e96a0eea103421ae739d08c475699b09
/libSLR/Texture/voronoi_textures.cpp
c6c956491ce0c4f0231226bc37f9a5c42db8aa2d
[]
no_license
SmallGame/SLR
8b047104c259f5bb87c44c24c4c3600a737e6ce0
841cbdde03ffb43c8c118fe78f81261dd8f4ddea
refs/heads/master
2021-01-21T14:13:28.834366
2017-05-30T18:17:22
2017-05-30T18:17:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,044
cpp
voronoi_textures.cpp
// // voronoi_textures.cpp // // Created by 渡部 心 on 2016/06/17. // Copyright (c) 2016年 渡部 心. All rights reserved. // #include "voronoi_textures.h" #include "../Core/distributions.h" #include "../Core/geometry.h" #include "../RNG/LinearCongruentialRNG.h" namespace SLR { static const uint32_t FNV_OFFSET_BASIS_32 = 2166136261U; static const uint64_t FNV_OFFSET_BASIS_64 = 14695981039346656037U; static const uint32_t FNV_PRIME_32 = 16777619U; static const uint64_t FNV_PRIME_64 = 1099511628211LLU; static inline uint32_t getFNV1Hash32(uint8_t *bytes, size_t length) { uint32_t hash = FNV_OFFSET_BASIS_32; for (int i = 0; i < length; ++i) hash = (FNV_PRIME_32 * hash) ^ (bytes[i]); return hash; } static inline uint64_t getFNV1Hash64(uint8_t *bytes, size_t length) { uint64_t hash = FNV_OFFSET_BASIS_64; for (int i = 0; i < length; ++i) hash = (FNV_PRIME_64 * hash) ^ (bytes[i]); return hash; } static void evaluateVoronoi(const Point3D &p, float* closestDistance, uint32_t* hashOfClosest, uint32_t* closestFPIdx) { int32_t iEvalCoord[3]; iEvalCoord[0] = std::floor(p.x); iEvalCoord[1] = std::floor(p.y); iEvalCoord[2] = std::floor(p.z); int32_t rangeBaseX = -1 + std::round(p.x - iEvalCoord[0]); int32_t rangeBaseY = -1 + std::round(p.y - iEvalCoord[1]); int32_t rangeBaseZ = -1 + std::round(p.z - iEvalCoord[2]); *closestDistance = INFINITY; for (int iz = rangeBaseZ; iz < rangeBaseZ + 2; ++iz) { for (int iy = rangeBaseY; iy < rangeBaseY + 2; ++iy) { for (int ix = rangeBaseX; ix < rangeBaseX + 2; ++ix) { int32_t iCoord[3] = {iEvalCoord[0] + ix, iEvalCoord[1] + iy, iEvalCoord[2] + iz}; uint32_t hash = getFNV1Hash32((uint8_t*)iCoord, sizeof(iCoord)); LinearCongruentialRNG rng(hash); uint32_t numFeaturePoints = 1 + std::min(int32_t(8 * rng.getFloat0cTo1o()), 8); for (int i = 0; i < numFeaturePoints; ++i) { Point3D fp = Point3D(iCoord[0] + rng.getFloat0cTo1o(), iCoord[1] + rng.getFloat0cTo1o(), iCoord[2] + rng.getFloat0cTo1o()); float dist = distance(p, fp); if (dist < *closestDistance) { *closestDistance = dist; *hashOfClosest = hash; *closestFPIdx = i; } } } } } } SampledSpectrum VoronoiSpectrumTexture::evaluate(const Point3D &p, const WavelengthSamples &wls) const { float closestDistance; uint32_t hash; uint32_t fpIdx; evaluateVoronoi(p, &closestDistance, &hash, &fpIdx); LinearCongruentialRNG rng(hash + fpIdx); float rgb[3] = { rng.getFloat0cTo1o() * m_brightness, rng.getFloat0cTo1o() * m_brightness, rng.getFloat0cTo1o() * m_brightness }; #ifdef SLR_Use_Spectral_Representation UpsampledContinuousSpectrum spectrum(SpectrumType::Reflectance, ColorSpace::sRGB_NonLinear, rgb[0], rgb[1], rgb[2]); return spectrum.evaluate(wls); #else return SampledSpectrum(rgb[0], rgb[1], rgb[2]); #endif } float VoronoiSpectrumTexture::evaluateLuminance(const Point3D &p) const { float closestDistance; uint32_t hash; uint32_t fpIdx; evaluateVoronoi(p, &closestDistance, &hash, &fpIdx); LinearCongruentialRNG rng(hash + fpIdx); float rgb[3] = { rng.getFloat0cTo1o() * m_brightness, rng.getFloat0cTo1o() * m_brightness, rng.getFloat0cTo1o() * m_brightness }; return sRGB_to_Luminance(rgb[0], rgb[1], rgb[2]); } const ContinuousDistribution2D* VoronoiSpectrumTexture::createIBLImportanceMap() const { SLRAssert_NotImplemented(); return nullptr; } Normal3D VoronoiNormalTexture::evaluate(const Point3D &p) const { float closestDistance; uint32_t hash; uint32_t fpIdx; evaluateVoronoi(p, &closestDistance, &hash, &fpIdx); LinearCongruentialRNG rng(hash + fpIdx); return uniformSampleCone(rng.getFloat0cTo1o(), rng.getFloat0cTo1o(), m_cosThetaMax); } float VoronoiFloatTexture::evaluate(const Point3D &p) const { float closestDistance; uint32_t hash; uint32_t fpIdx; evaluateVoronoi(p, &closestDistance, &hash, &fpIdx); if (m_flat) { LinearCongruentialRNG rng(hash + fpIdx); return m_valueScale * rng.getFloat0cTo1o(); } else { return (closestDistance / (1.414213562 * m_scale)) * m_valueScale; } } }
a48efc805dd48b0dd61c50a98354c2a090af7262
4352b5c9e6719d762e6a80e7a7799630d819bca3
/tutorials/oldd/eulerVortex.twitch/eulerVortex.cyclic.twitch/1.5/T
4d3115e22bbf85238b5c444955237c157b644b90
[]
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
29,780
T
/*--------------------------------*- 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 "1.5"; object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 1 0 0 0]; internalField nonuniform List<scalar> 10000 ( 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 0.999999 0.999998 0.999996 0.999995 0.999995 0.999994 0.999994 0.999994 0.999995 0.999996 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999998 0.999996 0.999994 0.999991 0.999988 0.999986 0.999984 0.999983 0.999984 0.999987 0.999989 0.999992 0.999995 0.999997 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999998 0.999996 0.999992 0.999986 0.999979 0.999972 0.999966 0.999961 0.999959 0.999961 0.999966 0.999972 0.999979 0.999986 0.999991 0.999995 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999998 0.999995 0.99999 0.999981 0.999968 0.999953 0.999936 0.99992 0.999909 0.999905 0.999908 0.999919 0.999934 0.99995 0.999965 0.999978 0.999987 0.999993 0.999996 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999996 0.999989 0.999977 0.999957 0.999929 0.999894 0.999856 0.999821 0.999795 0.999784 0.999792 0.999815 0.999848 0.999885 0.99992 0.999948 0.999969 0.999982 0.999991 0.999996 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.999991 0.999976 0.99995 0.999908 0.999849 0.999774 0.999692 0.999615 0.999557 0.999533 0.999547 0.999597 0.999669 0.999749 0.999824 0.999885 0.999931 0.999961 0.999979 0.99999 0.999995 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999994 0.99998 0.99995 0.999897 0.999811 0.999688 0.999535 0.999366 0.999205 0.999084 0.99903 0.999057 0.999158 0.999308 0.999475 0.999632 0.99976 0.999854 0.999917 0.999956 0.999978 0.99999 0.999995 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.999987 0.999959 0.999901 0.999794 0.999624 0.999382 0.99908 0.998744 0.998422 0.998176 0.998063 0.998111 0.99831 0.998612 0.998949 0.999264 0.999521 0.999709 0.999834 0.999911 0.999955 0.999979 0.999991 0.999996 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999994 0.999973 0.99992 0.999806 0.999602 0.99928 0.998825 0.998249 0.997606 0.996986 0.996508 0.996284 0.996372 0.996753 0.997333 0.997983 0.99859 0.999084 0.999444 0.999684 0.999831 0.999914 0.999959 0.999982 0.999992 0.999997 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999988 0.999948 0.999849 0.99964 0.999266 0.998677 0.997845 0.996794 0.995613 0.994471 0.993588 0.99317 0.993329 0.994031 0.995101 0.9963 0.997418 0.998326 0.998986 0.999424 0.999692 0.999845 0.999926 0.999966 0.999986 0.999994 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999977 0.999907 0.999727 0.999355 0.998696 0.99766 0.996202 0.994355 0.99228 0.990275 0.988732 0.988011 0.9883 0.989534 0.991412 0.993519 0.995482 0.997075 0.998231 0.998996 0.999464 0.99973 0.999871 0.999941 0.999975 0.99999 0.999996 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999996 0.999959 0.999836 0.999527 0.998892 0.997773 0.996025 0.993568 0.990465 0.986987 0.983653 0.981117 0.97996 0.980473 0.982537 0.985664 0.989174 0.992452 0.995115 0.997048 0.998327 0.999107 0.999549 0.999785 0.999902 0.999958 0.999983 0.999993 0.999997 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999992 0.99993 0.999725 0.999214 0.998173 0.99635 0.993518 0.989558 0.984577 0.979045 0.973809 0.969895 0.968165 0.969023 0.972284 0.977207 0.982754 0.987957 0.992199 0.995286 0.997329 0.998574 0.999281 0.999656 0.999844 0.999933 0.999972 0.999989 0.999996 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999987 0.999888 0.999562 0.99875 0.99711 0.994264 0.989877 0.98378 0.976177 0.967844 0.960092 0.954401 0.951948 0.953272 0.958117 0.965451 0.973773 0.981634 0.98808 0.99279 0.995913 0.997818 0.9989 0.999475 0.999762 0.999897 0.999958 0.999983 0.999994 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999978 0.999829 0.999331 0.998097 0.995626 0.991379 0.984887 0.975949 0.964939 0.95307 0.94222 0.934359 0.931001 0.932856 0.939632 0.949988 0.961865 0.97319 0.982549 0.989425 0.994 0.996796 0.998384 0.999228 0.99965 0.99985 0.999938 0.999976 0.999991 0.999997 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999968 0.999755 0.999029 0.997237 0.993679 0.987627 0.978474 0.966018 0.950907 0.934897 0.920467 0.91007 0.90557 0.907924 0.916879 0.930783 0.946938 0.962514 0.975506 0.985117 0.991544 0.995484 0.997723 0.998913 0.999507 0.999788 0.999913 0.999966 0.999987 0.999995 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1 0.999958 0.999667 0.998661 0.996179 0.991293 0.983071 0.970784 0.954293 0.934613 0.914088 0.895765 0.882528 0.876634 0.87938 0.890622 0.90842 0.92938 0.949824 0.96705 0.979904 0.988555 0.993881 0.996915 0.998528 0.999334 0.999713 0.999883 0.999954 0.999983 0.999994 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999947 0.999576 0.998254 0.994982 0.988584 0.977939 0.962235 0.941467 0.917076 0.891972 0.869677 0.85347 0.846022 0.849028 0.862525 0.884305 0.910256 0.935823 0.95759 0.973999 0.985139 0.99204 0.995985 0.998085 0.999134 0.999628 0.999848 0.999941 0.999978 0.999992 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1 1 0.999938 0.999493 0.997854 0.993752 0.985769 0.972625 0.953481 0.928535 0.899665 0.87027 0.844253 0.825229 0.816256 0.819433 0.835028 0.860591 0.891288 0.921739 0.947899 0.967837 0.98152 0.99007 0.994985 0.997608 0.99892 0.999537 0.999811 0.999927 0.999973 0.99999 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1 0.999996 0.999932 0.999438 0.997519 0.992639 0.983144 0.967635 0.945323 0.916647 0.88389 0.850844 0.821698 0.800323 0.790057 0.793363 0.81079 0.839685 0.874503 0.909118 0.939025 0.96205 0.97804 0.988142 0.993996 0.997135 0.998707 0.999446 0.999774 0.999912 0.999968 0.999989 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1 0.999989 0.999926 0.999421 0.997318 0.991815 0.981036 0.96352 0.938578 0.906918 0.871162 0.835385 0.803975 0.780926 0.769714 0.773105 0.791984 0.823569 0.861632 0.899385 0.932033 0.957339 0.975111 0.986474 0.993124 0.996715 0.998517 0.999365 0.999742 0.9999 0.999964 0.999987 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 0.99998 0.999917 0.999446 0.9973 0.991431 0.979754 0.960779 0.933963 0.90028 0.86261 0.825195 0.792511 0.768533 0.756715 0.760094 0.779937 0.81341 0.853704 0.893454 0.927698 0.954292 0.973118 0.985286 0.992483 0.996399 0.998374 0.999305 0.999718 0.999891 0.99996 0.999986 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1.00001 1.00001 0.999972 0.999901 0.999501 0.997481 0.991587 0.979528 0.959791 0.932006 0.897388 0.858977 0.821069 0.788122 0.763931 0.751798 0.75503 0.775295 0.809738 0.851117 0.891669 0.926367 0.953235 0.972315 0.984745 0.992165 0.996234 0.998297 0.999272 0.999705 0.999887 0.999959 0.999986 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 0.999969 0.999879 0.999561 0.997826 0.992293 0.980456 0.960756 0.932985 0.898556 0.860576 0.823291 0.791052 0.767333 0.755178 0.758161 0.778323 0.812748 0.853943 0.894021 0.928034 0.954217 0.972786 0.984927 0.992222 0.996249 0.998301 0.999274 0.999706 0.999887 0.999959 0.999986 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00002 0.999975 0.999858 0.9996 0.998249 0.993444 0.982471 0.963656 0.936897 0.903749 0.867295 0.831664 0.801037 0.778452 0.766626 0.769358 0.788927 0.822329 0.862011 0.900281 0.932477 0.957078 0.974448 0.985805 0.992649 0.996444 0.998386 0.99931 0.999721 0.999893 0.999961 0.999987 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00002 0.99999 0.999852 0.99961 0.998645 0.994829 0.985315 0.968221 0.943443 0.912585 0.878624 0.845543 0.817308 0.796462 0.785375 0.787936 0.806459 0.837839 0.874731 0.909937 0.939272 0.961499 0.977097 0.987263 0.993391 0.996796 0.998543 0.999376 0.999748 0.999903 0.999965 0.999988 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1 0.999873 0.999612 0.998932 0.996175 0.988551 0.973916 0.952009 0.924337 0.893691 0.863893 0.83865 0.820003 0.810029 0.812527 0.829588 0.85805 0.89104 0.92214 0.947776 0.967023 0.980431 0.989125 0.994352 0.997258 0.998751 0.999465 0.999783 0.999917 0.99997 0.99999 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 0.999913 0.999641 0.999109 0.997257 0.991647 0.979976 0.961662 0.93792 0.911261 0.885316 0.863444 0.84725 0.838637 0.841139 0.856398 0.88124 0.909513 0.935782 0.957187 0.973099 0.984092 0.991176 0.995418 0.997773 0.998985 0.999564 0.999824 0.999933 0.999976 0.999992 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1.00001 0.999953 0.99971 0.999242 0.998007 0.994181 0.985566 0.971241 0.951926 0.929745 0.908046 0.889713 0.876033 0.868884 0.871404 0.884623 0.905423 0.928544 0.949663 0.966652 0.979156 0.987723 0.993206 0.996474 0.998285 0.999217 0.999664 0.999864 0.999948 0.999982 0.999994 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999978 0.999798 0.999392 0.998513 0.996007 0.990092 0.979649 0.964854 0.947373 0.930083 0.915266 0.904055 0.898405 0.900932 0.91199 0.928614 0.946562 0.962634 0.975393 0.984694 0.991017 0.995039 0.997428 0.998748 0.999427 0.999753 0.9999 0.999962 0.999987 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999987 0.999874 0.99956 0.9989 0.997253 0.9934 0.986255 0.9756 0.96265 0.949603 0.938104 0.929301 0.925178 0.927694 0.936569 0.949158 0.962288 0.973803 0.98283 0.989359 0.993772 0.996566 0.998219 0.999133 0.999603 0.999829 0.999931 0.999974 0.999991 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 0.999992 0.999925 0.999711 0.999226 0.998129 0.995684 0.991017 0.983788 0.974796 0.965476 0.956968 0.950498 0.947875 0.950289 0.957028 0.965958 0.97494 0.982666 0.988669 0.992992 0.995904 0.997742 0.998829 0.999429 0.999739 0.999887 0.999955 0.999983 0.999995 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999994 0.999956 0.999823 0.999492 0.998772 0.997236 0.994288 0.989658 0.983784 0.977464 0.971547 0.96724 0.965902 0.968017 0.972746 0.978603 0.984311 0.989161 0.992916 0.995618 0.997439 0.998589 0.999268 0.999643 0.999836 0.99993 0.999972 0.99999 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.999975 0.999896 0.99969 0.999236 0.998285 0.996494 0.993691 0.990051 0.986001 0.982231 0.97971 0.979229 0.980827 0.983825 0.987346 0.990716 0.993573 0.995793 0.997395 0.998477 0.999161 0.999565 0.999788 0.999903 0.999959 0.999984 0.999994 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999987 0.999942 0.999823 0.999551 0.998987 0.997953 0.99634 0.9942 0.991798 0.989648 0.988355 0.988265 0.989272 0.990972 0.992919 0.994783 0.996374 0.99762 0.998525 0.999137 0.999525 0.999754 0.99988 0.999945 0.999977 0.999991 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999993 0.99997 0.999904 0.999751 0.999438 0.998872 0.99799 0.996816 0.995526 0.994426 0.993814 0.993815 0.994351 0.995225 0.996232 0.997208 0.998051 0.998717 0.999204 0.999535 0.999744 0.999868 0.999936 0.999971 0.999988 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999986 0.999952 0.999872 0.999708 0.999416 0.998963 0.998371 0.99774 0.997217 0.996928 0.996926 0.997175 0.997594 0.998089 0.998576 0.999002 0.999342 0.999592 0.999761 0.999869 0.999933 0.999968 0.999985 0.999994 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999994 0.999978 0.999939 0.999859 0.999717 0.999501 0.999226 0.998935 0.998694 0.998556 0.998546 0.998654 0.998845 0.999077 0.999309 0.999515 0.99968 0.999801 0.999884 0.999937 0.999967 0.999985 0.999994 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 1 1 1 1 1 1 1 0.999998 0.999991 0.999973 0.999936 0.999872 0.999777 0.999656 0.999528 0.99942 0.999355 0.999346 0.99939 0.999474 0.999576 0.999683 0.999776 0.999852 0.999909 0.999947 0.999971 0.999985 0.999993 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.99999 0.999975 0.999948 0.999907 0.999857 0.999803 0.999757 0.999727 0.999722 0.999739 0.999773 0.999817 0.999862 0.999903 0.999937 0.999961 0.999977 0.999988 0.999994 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.999992 0.999981 0.999965 0.999945 0.999923 0.999905 0.999892 0.999889 0.999895 0.999909 0.999926 0.999944 0.999961 0.999974 0.999984 0.999991 0.999995 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 0.999999 0.999998 0.999995 0.999989 0.999981 0.999973 0.999966 0.999961 0.999959 0.999961 0.999966 0.999972 0.999979 0.999985 0.999991 0.999994 0.999996 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999997 0.999994 0.999992 0.999989 0.999987 0.999987 0.999987 0.999989 0.999991 0.999993 0.999995 0.999996 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999998 0.999997 0.999997 0.999996 0.999996 0.999997 0.999998 0.999998 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ) ; boundaryField { emptyPatches_empt { type empty; } top_cyc { type cyclic; } bottom_cyc { type cyclic; } inlet_cyc { type cyclic; } outlet_cyc { type cyclic; } } // ************************************************************************* //
02f95a1f01fc2a782d53cfd1a2effe56aa6d6732
f18d84f7754232ddc8665ccc041f55085341e2ae
/ElementLib/P4.hpp
c9bc74c950af80bc3637ee1e502f775d6e1987c1
[]
no_license
garanga/OrpheusInverse
fe6465581913a8748a827ec2395cf2181d2628ab
8054ece2abd0cb403ff4492b00a24c96be27aaea
refs/heads/master
2020-03-07T14:42:59.911197
2018-05-05T07:20:48
2018-05-05T07:20:48
127,533,589
0
0
null
null
null
null
UTF-8
C++
false
false
2,537
hpp
P4.hpp
/* * P4.hpp * * Created on: Jan 19, 2017 * Author: pavel */ #ifndef ELEMENTLIB_P4_HPP_ #define ELEMENTLIB_P4_HPP_ #include "ElementType.hpp" #include <Eigen/Dense> using namespace Eigen; class Material; class P4 : public ElementType { public: P4(Material*, bool=false); ~P4(); // A method returns a stiffness matrix K: // the integral over the domain occupied by an element of // a quantity B(i,...).transpose()*D*B(j,...) void modfMaterial(Material*); Material* getMaterial() const; Matrix<double,2,2> calcLocK(int,int, Matrix<double,2,4>&) const; // A method returns an elastic matrix D Matrix<double,3,3> getD() const; private: Material* _material; bool _isPlainStrain; double* _alpha; double* _beta ; double* _gamma; double* _delta; Matrix<double,3,3> _D; Matrix<double,2,4> _quadraturePoints ; Matrix<double,1,4> _quadratureWeights; void updateD(); // A method returns a shape function corresponded to node \f$ I \f$ // calculated in a point \f$ (\xi,\eta) \f$ in the local coordinates double calcShapeFuncLoc(int, double, double) const; // A method returns a shape function of node <<i>> local derivatives // calculated in a local point (xi,eta): ||dNi/d(xi),dNi/d(eta)||(xi,eta) Matrix<double,1,2> calcShapeFuncLocDerLoc(int, double, double) const; // A method returns the Jacobian matrix d(x,y)/d(xi,eta) // calculated in a local point (xi,eta): ||dx/dxi,dx/deta|| // ||dy/dxi,dy/deta||(xi,eta) // nodesCoordGlob is a matrix containing element nodes global coordinates: // || x1,x2,x3,x4 // y1,y2,y3,y4 || Matrix<double,2,2> calcJacobianMatrix(double, double, Matrix<double,2,4>&) const; // A method returns a shape function of node <<i>> global derivatives // calculated in a local point (xi,eta): ||dNi/d(x),dNi/d(y)||(xi,eta) Matrix<double,1,2> calcShapeFuncGlobDerLoc(int, double, double, Matrix<double,2,4>&) const; // A method returns a matrix \f$ \bm{B}_I \f$ composed of // global derivatives of a shape function \f$ N_I \f$ Matrix<double,3,2> calcBi(int, double, double, Matrix<double,2,4>&) const; // A method returns a matrix \f$ \bm{B} \f$ composed of // global derivatives of shape functions \f$ N_I, I=1,\ldots,4 \f$ Matrix<double,3,8> calcB(double, double, Matrix<double,2,4>&) const; }; #endif /* ELEMENTLIB_P4_HPP_ */
af1347a19aebba0682e1e0b2d4b0d622be5dac32
5d96829594b3510ffd2eb164e5e00a372e60d895
/Year 1/Sem 2/SDA/Lab 1/SetIterator.cpp
14e462d37e98279ea2c3056ba001d717902445ea
[]
no_license
iuliabenyi/UBB-Labs
8db156431b3e3776e4c4cb85d03b6d25c0148b0e
0fb4304b908b3e83c11149f67335bddf13d4a57e
refs/heads/master
2023-03-09T14:33:11.807934
2021-02-03T11:50:09
2021-02-03T11:50:09
245,664,436
1
0
null
2023-03-03T08:12:51
2020-03-07T16:11:57
JavaScript
UTF-8
C++
false
false
562
cpp
SetIterator.cpp
#include "SetIterator.h" SetIterator::SetIterator(const Set & set) : set{ set } { currentIndex = 0; } void SetIterator::first() { currentIndex = 0; } void SetIterator::next() { if (!valid()) throw exception(); ++currentIndex; } bool SetIterator::valid() const { return currentIndex >= 0 && currentIndex < set.size(); } TElem SetIterator::getCurrent() const { if (!valid()) throw new exception(); else return set.da.getElement(currentIndex); } void SetIterator::previous() { if (currentIndex == -1) throw exception(); currentIndex -= 1; }
0014a15443835bc35f5acc3a93d5bec32615f58b
047600ca8efa01dd308f4549793db97e6ddcec20
/Src/HLSDK/gameui/UI_GameEnd.cpp
ce7f6d04e3918b0791c6de322c47989dc42676f4
[]
no_license
crskycode/Mind-Team
cbb9e98322701a5d437fc9823dd4c296a132330f
ceab21c20b0b51a2652c02c04eb7ae353b82ffd0
refs/heads/main
2023-03-16T10:34:31.812155
2021-03-02T02:23:40
2021-03-02T02:23:40
343,616,799
6
1
null
null
null
null
WINDOWS-1252
C++
false
false
2,149
cpp
UI_GameEnd.cpp
#include "UI_GameEnd.h" #include "CF_Base.h" #include "EngineInterface.h" #include "UserSystem.h" #include <keyvalues.h> UIGameEnd::UIGameEnd(vgui::Panel *parent) : vgui::CFDialog(parent, "GameEnd") { SetProportional(true); LoadControlSettings("UI/Scripts/GameEnd.txt"); m_cButtonGameEnd = FIND_CONTROL_BUTTON("ButtonGameEnd"); m_cButtonMoveServer = FIND_CONTROL_BUTTON("ButtonMoveServer"); m_cButtonCancel = FIND_CONTROL_BUTTON("ButtonCancel"); m_cStaticNameComment = FIND_CONTROL_STATIC("StaticNameComment"); m_cStaticMoreGameComment = FIND_CONTROL_STATIC("StaticMoreGameComment"); m_cStaticMoreRound = FIND_CONTROL_STATIC("StaticMoreRound"); m_cStaticNextClass = FIND_CONTROL_STATIC("StaticNextClass"); m_cStaticNoEP = FIND_CONTROL_STATIC("StaticNoEP"); m_cStaticTodayEP = FIND_CONTROL_STATIC("StaticTodayEP"); m_cStaticTotalEP = FIND_CONTROL_STATIC("StaticTotalEP"); m_cStaticTodayGP = FIND_CONTROL_STATIC("StaticTodayGP"); m_cStaticTotalGP = FIND_CONTROL_STATIC("StaticTotalGP"); m_cStaticWinLose = FIND_CONTROL_STATIC("StaticWinLose"); m_cStaticKill = FIND_CONTROL_STATIC("StaticKill"); m_cStaticDeath = FIND_CONTROL_STATIC("StaticDeath"); m_cStaticKillDeath = FIND_CONTROL_STATIC("StaticKillDeath"); m_cStaticHeadShot = FIND_CONTROL_STATIC("StaticHeadShot"); m_cButtonGameEnd->SetCommand("GameEnd"); m_cButtonMoveServer->SetCommand("ServerList"); m_cButtonCancel->SetCommand("Cancel"); m_pOwnerPanel = NULL; } void UIGameEnd::Activate(vgui::Panel *pOwnerPanel) { BaseClass::Activate(); m_pOwnerPanel = pOwnerPanel; m_cStaticNameComment->SetText( L"'%s'µÄ ½ñÈÕÕ½¼¨", g_User.GetName() ); } void UIGameEnd::OnCommand(const char *szCommand) { if (!strcmp(szCommand, "GameEnd")) { gEngfuncs.pfnClientCmd("exit\n"); } else if (!strcmp(szCommand, "ServerList")) { if (m_pOwnerPanel) { PostMessage(m_pOwnerPanel, new KeyValues("Command", "command", szCommand)); } Close(); } else if (!strcmp(szCommand, "Cancel")) { Close(); } } void UIGameEnd::OnKeyCodePressed(vgui::KeyCode code) { if (code == vgui::KEY_ESCAPE) { Close(); return; } BaseClass::OnKeyCodePressed(code); }
d74203b086717959ff8ae2e303215e38e4697fb3
61b553131747350941d801f02c9c6e887b35df62
/CPP/virtual_func.cpp
2e09755a2b70d35168e219e49e2e57e99de6aa42
[]
no_license
edipesh19/cpp_repo
a9498edb8f1aa5ef2166206a1344fe18de1f4cc0
d619751908dbab91114cadbd6e5676b1167fdf22
refs/heads/master
2020-12-24T17:08:13.298755
2013-08-05T10:28:29
2013-08-05T10:28:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,234
cpp
virtual_func.cpp
#include <iostream> using namespace std; class base { protected: int i; public: base(int x = 0):i(x){cout<<"Base class constructor"<<endl;} virtual void func(); }; void base::func() { cout<<"Base Func i = "<<i<<endl; } //When virtual function is not overriden in derive class the vtable of derive class will hold the addess of //base class virtual function. class derive1:public base { int j; public: derive1(int y = 0)//:base(y) { cout<<"Derive1 class constructor"<<endl; j = y; } }; class derive2:public base { int j; public: derive2(int y = 0)//:base(y) { cout<<"Derive2 class constructor"<<endl; j = y; } void func(); }; void derive2::func() { cout<<"Derive2 Func i = "<<i<<" j = "<<j<<endl; } int main() { base *bptr1 = new derive1(10); base *bptr2 = new derive2(20); bptr1->func(); bptr2->func(); return 0; } /* output Base class constructor Derive1 class constructor Base class constructor Derive2 class constructor Base Func i = 10 Derive2 Func i = 20 j = 20 */ // When the base constructor call is commented in derive classes //output will be /* Base class constructor Derive1 class constructor Base class constructor Derive2 class constructor Base Func i = 0 Derive2 Func i = 0 j = 20 */
bc066582a6f2823ce3a2f247ada93a47f408e15f
b5d80b64b6f4b4124de171761d854a9d14f851bb
/hdu-5068.cpp
f146ef3e76d9429b3938f68a5574d0fd27427550
[]
no_license
forty-twoo/acm-code-record
73af81481134b8d47424def25a78d7bb43d490ea
7b9a6d602f83a7fb373586b567eca35c8a8a0d31
refs/heads/master
2020-07-05T20:09:29.138584
2019-10-11T13:58:18
2019-10-11T13:58:18
202,759,932
1
0
null
null
null
null
UTF-8
C++
false
false
2,395
cpp
hdu-5068.cpp
/* * @Don't panic: Allons-y! * @Author: forty-twoo * @LastEditTime: 2019-09-14 00:24:19 * @Description: 线段树维护矩阵乘法+dp * @Source: http://acm.hdu.edu.cn/showproblem.php?pid=5068 */ #include<bits/stdc++.h> #define mst(a,x) memset(a,x,sizeof(a)) #define debug freopen("data.txt","r",stdin) #define lowbit(x) x&-x #define prique priority_queue #define INF 0x3f3f3f3f #define eps 1e-8 #define pb push_back typedef long long ll; const int MAX=5e4+10; const int MOD=1e9+7; using namespace std; int a[MAX][10],n,m,Q; struct mat{ ll a[5][5]; }; mat X; mat cun[MAX<<2]; void getmat(mat&c,int x){ mst(c.a,0); for(int i=1;i<=2;i++){ c.a[i][1]=a[x][i]; } for(int i=3;i<=4;i++){ c.a[i-2][2]=a[x][i]; } } mat matmul(mat A,mat B){ mat ans; mst(ans.a,0); for(int i=1;i<=2;i++){ for(int k=1;k<=2;k++){ for(int j=1;j<=2;j++){ ans.a[i][j]=(ans.a[i][j]+A.a[i][k]*B.a[k][j]%MOD)%MOD; } } } return ans; } struct SEGT{ #define lc rt<<1 #define rc rt<<1|1 #define lson lc,l,mid #define rson rc,mid+1,r mat tmp; void init(){ mst(tmp.a,0); for(int i=1;i<=2;i++){ tmp.a[i][i]=1; } } void pushup(int rt){ cun[rt]=matmul(cun[lc],cun[rc]); } void build(int rt,int l,int r){ if(l==r){ getmat(cun[rt],l); return; } int mid=(l+r)>>1; build(lson);build(rson); pushup(rt); } void change(int rt,int l,int r,int x){ if(l==r){ getmat(cun[rt],x); return; } int mid=(l+r)>>1; if(x<=mid) change(lson,x); else change(rson,x); pushup(rt); } void query(int rt,int l,int r,int L,int R){ if(L<=l && r<=R){ tmp=matmul(tmp,cun[rt]); return; } int mid=(l+r)>>1; if(L<=mid) query(lson,L,R); if(R>mid) query(rson,L,R); } }T; int main(){ #ifndef ONLINE_JUDGE debug; #endif while(~scanf("%d%d",&n,&Q)){ for(int i=1;i<=n;i++){ for(int j=1;j<=4;j++){ a[i][j]=1; } } T.build(1,1,n-1); int op,x,y,z; for(int i=1;i<=Q;i++){ scanf("%d",&op); if(op==1){ scanf("%d%d%d",&x,&y,&z); if(y==1){ if(z==1) a[x][1]^=1; if(z==2) a[x][3]^=1; } if(y==2){ if(z==1) a[x][2]^=1; if(z==2) a[x][4]^=1; } T.change(1,1,n-1,x); } else{ scanf("%d%d",&x,&y); T.init(); T.query(1,1,n-1,x,y-1); ll ans=0; for(int i=1;i<=2;i++){ for(int j=1;j<=2;j++){ ans=(ans+T.tmp.a[i][j])%MOD; } } printf("%lld\n",ans); } } } return 0; }
62fd8852050181615793064493903c0d251840d1
8924ba7719164c962b49c36c05d81d393915d456
/volumes/SphereUtilities.h
a87f818ff84fc494805763f0beed4f74b21b4c03
[]
no_license
carlosal1015/VecGeom
23525ff91567d58cfde1aa7c66f9cc508a3b5bbf
12512cd7f67b89f7619a64474080ad24077aba10
refs/heads/master
2020-09-13T17:16:12.770167
2015-06-02T07:26:54
2015-06-02T07:57:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,218
h
SphereUtilities.h
#ifndef VECGEOM_VOLUMES_SPHEREUTILITIES_H_ #define VECGEOM_VOLUMES_SPHEREUTILITIES_H_ #include "base/Global.h" #ifndef VECGEOM_NVCC #include "base/RNG.h" #include <cassert> //#include <iostream> //#include <fstream> //#include <limits> #include <cmath> ////#include <cfloat> //#include <vector> //#include <algorithm> #endif namespace vecgeom { inline namespace VECGEOM_IMPL_NAMESPACE { VECGEOM_CUDA_HEADER_BOTH Precision sqr(Precision x) {return x*x;}; /* template <class Backend> VECGEOM_CUDA_HEADER_BOTH void fabs(typename Backend::precision_v &v) { typedef typename Backend::precision_v Double_t; Double_t mone(-1.); MaskedAssign( (v<0), mone*v , &v ); } */ #ifndef VECGEOM_NVCC Precision GetRadiusInRing(Precision rmin, Precision rmax) { // Generate radius in annular ring according to uniform area // if (rmin <= 0.) { return rmax * std::sqrt(RNG::Instance().uniform(0. , 1.)); } if (rmin != rmax) { return std::sqrt(RNG::Instance().uniform(0. , 1.) * (sqr(rmax) - sqr(rmin)) + sqr(rmin)); } return rmin; } #endif } } // End global namespace #endif //VECGEOM_VOLUMES_SPHEREUTILITIES_H_
3e0d9f5b171df6d304a64c6a925cdc2aa490048d
5aa99fec0b2f1c5ce907b98966c1162733df221a
/ASIOGameServer/Component/Component.cpp
f6644e57c70dea8860a6141d297b555fca28be07
[]
no_license
qkfdjq451/ASIOGameServer
ac908d71ee4218864d1f945cdb1122331a660d2e
af3a69da5db94d8667036b5dddb800fb2f69c867
refs/heads/master
2020-03-18T11:17:15.637775
2018-07-24T06:09:50
2018-07-24T06:09:50
134,662,233
1
1
null
null
null
null
UHC
C++
false
false
3,171
cpp
Component.cpp
#include "../Global.h" #include "Component.h" int Component::count = 0; std::map<int, std::shared_ptr<Component>> Component::Components; std::map<std::string, std::map<int, std::shared_ptr<Component>>> Component::TagComponents; Component::Component() : parent(nullptr), workerGroup(nullptr), state(ComponentState::Create) { id = count++; } Component::~Component() { } void Component::Run() { if (parent != nullptr) return; while (true) { Update(); } } bool Component::Attach(std::shared_ptr<Component> component) { if (component->parent==nullptr) { component->parent = shared_from_this(); component->SetWorkerGroup(workerGroup); children.push_back(component); return true; } return false; } bool Component::Detach(std::shared_ptr<Component> component) { for (auto iter = children.begin(); iter != children.end(); iter++) { if (component == *iter) { (*iter)->parent = nullptr; component->SetWorkerGroup(nullptr); children.erase(iter); return true; } } return false; } void Component::Distroy() { state = ComponentState::Destroy; for (auto com : children) { com->Distroy(); } int a = 10; } void Component::Update() { auto self = shared_from_this(); if (state == ComponentState::Alive) { Tick(); } else if (state == ComponentState::Create) { BeginPlay(); state = ComponentState::Alive; } else if (state == ComponentState::Destroy) { EndPlay(); Remove(); } for (auto iter = children.begin();iter!=children.end();) { auto com = (*iter); ++iter; com->Update(); } } void Component::Remove() { if (parent) { //printf("테스트!!\n"); parent->Detach(shared_from_this()); Components.erase(id); //printf("테스트!23423!\n"); } //for (auto com : children) //{ // com->Remove(); //} for (auto t : tag) { RemoveTag(t); } } bool Component::SetTag(string _tag) { auto result = tag.insert(_tag); //태그 설정이 완료됐다면? if (result.second) { //기존에 같은 테그의 객체가 있는지 찾아본다. auto result = TagComponents.find(_tag); //만일 있다면? if (result != TagComponents.end()) { result->second.insert(make_pair(id, shared_from_this())); } //없다면? else { std::map<int, std::shared_ptr<Component>> newMap; newMap.insert(make_pair(id, shared_from_this())); TagComponents.insert(make_pair(_tag, move(newMap))); } return true; } return false; } bool Component::RemoveTag(string _tag) { auto result = tag.find(_tag); if (result != tag.end()) { auto tagresult = TagComponents.find(_tag); if (tagresult != TagComponents.end()) { tagresult->second.erase(id); return true; } } return false; } std::shared_ptr<Component> Component::GetComponent_For_ID(int _id) { auto result = Components.find(_id); if (result != Components.end()) { return result->second; } return nullptr; } bool Component::GetComponents_For_Tag(string _tag, std::vector<std::shared_ptr<Component>>& vec) { auto result = TagComponents.find(_tag); if (result != TagComponents.end()) { for (auto com : result->second) { vec.push_back(com.second); } return true; } return false; }
717fb15ca5c639d7af605ad514ff266d62a154d4
bb0cb5934a9b1fb1bc792cd6927fc70bf9d0a58a
/cpp/3.5_2Drowcol.cpp
45ef52a2935078c9aa27bb56ccd3f2f9883a91f3
[]
no_license
cactiglitch/C-C-exercises
340ed74e2165a37cbf4f35591669378dd03099e9
37467bbd02ba6aa29e352c7485b0a0cf6a4649ab
refs/heads/main
2023-06-15T04:26:45.823650
2021-07-04T04:29:41
2021-07-04T04:29:41
371,581,008
0
0
null
null
null
null
UTF-8
C++
false
false
627
cpp
3.5_2Drowcol.cpp
/* Integer[0] [0] = 34 Integer[0] [1] = -1 Integer[0] [2] = 879 Integer[0] [3] = 22 Integer[1] [0] = 24 Integer[1] [1] = 365 Integer[1] [2] = -101 Integer[1] [3] = -1 Integer[2] [0] = -20 Integer[2] [1] = 40 Integer[2] [2] = 90 Integer[2] [3] = 97 */ #include <iostream> using namespace std; int main() { const int NUM_ROWS = 3; const int NUM_COLS = 4; int MyInts[NUM_ROWS][NUM_COLS] ={ {34,-1,879,22}, {24,365,-101,-1}, {-20,40,90,97} }; for(int i =0; i < NUM_ROWS; ++i) for (int j =0; j < NUM_COLS; ++j) cout <<"Integer[" << i << "] [" << j << "] = " << MyInts[i][j] <<endl; return 0; }
44a8d2914ebbdb45ca0e52e44e0faec3bf0a1396
e815f3acb9c58e9ffe9234fcc5c1bcf3db505f76
/quol/flume/src/regex.h
7015163f71be9e08d1ffc228c8d3538fdacd2a65
[ "MIT" ]
permissive
zezax/one
7605400cf365706c60c95890f8f21e70f05be2bb
4d46d2324a7bfc024ae740785af48d6c9133cf5e
refs/heads/master
2023-08-31T22:06:25.080378
2023-08-30T22:53:05
2023-08-30T22:53:05
252,308,249
1
0
MIT
2023-09-04T04:32:15
2020-04-01T23:21:42
C++
UTF-8
C++
false
false
914
h
regex.h
// regex.h #pragma once #include <sys/types.h> #include <regex.h> #include <memory> #include <string> namespace flume { class MatchT { public: MatchT() : src_(nullptr) { } size_t size() const { return sizeof(ary_) / sizeof(ary_[0]); } std::string operator[](size_t idx) const; private: void setSrc(const char *src) { src_ = src; } const char *src_; regmatch_t ary_[10]; friend class RegexT; }; class RegexRecT { public: RegexRecT(const char *pat, int cflags); ~RegexRecT() { regfree(&prog_); } // no copying or moving RegexRecT(const RegexRecT &other) = delete; RegexRecT &operator=(const RegexRecT &rhs) = delete; const regex_t *get() const { return &prog_; } private: regex_t prog_; }; class RegexT { public: void assign(const std::string &pat, int cflags); bool search(const std::string &str, MatchT &mat); private: std::shared_ptr<RegexRecT> rec_; }; }
64d8f5ed595a43d6a6a8949ec7e6fb499a0855b0
b99df5b558c9e4224fe9e4d10507aeb5b2fa3ae0
/StudentID/header.hpp
29c8c24d2e1f1725baf910e2b1e77265b3763e5f
[]
no_license
tdickon/Intro-to-CS
9073077c4faa26f8bc4d9f1aee2541c15438a9f7
235406b221e06ced66535f54d621916f66729417
refs/heads/master
2021-01-22T19:54:22.388470
2017-03-17T02:13:59
2017-03-17T02:13:59
85,255,952
0
0
null
null
null
null
UTF-8
C++
false
false
289
hpp
header.hpp
#include <iostream> #include<string> using std::cout; using std::cin; using std::endl; using std::string; #ifndef test_h_ #define test_h_ class studentId { public: void get(); void print() const; private: string firstName; string lastName; double ID; }; #endif //test_h_
0dd536735c6c8404e1dabfda19ab29719b5f4138
f16d9ef62086aa59619ded6e1fbf8c0d97098e60
/Point.cpp
ca0390194ad34b18acc79d8cf1e5cbd0ffa4158e
[]
no_license
sibendav/foresightAssignment123
7ec0af53bcb7184f34b5123beb8752c00233c802
6b82799bb73e4b5f47a91b6da2feae008718f27a
refs/heads/main
2022-12-23T08:50:21.563356
2020-10-06T08:02:03
2020-10-06T08:02:03
301,477,581
0
0
null
null
null
null
UTF-8
C++
false
false
829
cpp
Point.cpp
//******** BALL-FILTER ******** //Author: Simha Ben-David //The Point.cpp class //The file is detailing the functions from Point class #include "Point.h" //ctr functions Point::Point(double X, double Y, double Z) :x(X), y(Y), z(Z) { } Point::Point(const Point& p){ x = p.x; y = p.y; z = p.z; } //Getters double Point::getX() const{ return x; } double Point::getY() const{ return y; } double Point::getZ() const{ return z; } //Setters void Point::setX(double X){ x = X; } void Point::setY(double Y){ y = Y; } void Point::setZ(double Z){ y = Z; } //Prints point' value void Point::print() const{ cout << '(' << x << ',' << y << ',' << z <<")\n"; } //Overloading operator= Point& Point::operator=(const Point& p1) { x = p1.x; y = p1.y; z = p1.z; return *this; }
f5fafd8abc819a6404af6c6fcda11902a77dec68
52c96c707172d0d6c7bfb3b672b2eb86a76473fc
/src/TravelAuthForm/TravelAuthtorizationForm.h
3110047d69c36205a1f7e163aed58f0efdbaa9e4
[]
no_license
Naify/Transport
9bc428549da408dbcbbd9b5c7e85343beca2f9ee
b9be3740882fdb7f097f42a04f4546f76574369e
refs/heads/main
2023-04-24T18:50:06.904708
2021-05-12T13:57:43
2021-05-12T13:57:43
366,734,389
0
0
null
null
null
null
UTF-8
C++
false
false
795
h
TravelAuthtorizationForm.h
#ifndef TRAVELAUTHTORIZATIONFORM_H #define TRAVELAUTHTORIZATIONFORM_H #include <QWidget> #include "ui_TravelAuthtorizationForm.h" class TravelAuthtorizationModel; namespace ODS{ class OdsInterface; } class TravelAuthtorizationForm : public QWidget, public Ui::TravelAuthtorizationForm { Q_OBJECT public: TravelAuthtorizationForm(int order_id, ODS::OdsInterface* iface, QWidget *parent = 0); ~TravelAuthtorizationForm(); private: TravelAuthtorizationModel* m_model; ODS::OdsInterface* m_iface; int m_order_id; int m_id; // void init(); // void initCompleter(); void initOrders(); private slots: void save(); void closeForm(); void orderChanged(int order); signals: void msgToStatus(QString); }; #endif // TRAVELAUTHTORIZATIONFORM_H
285ceacce3dccb398ec9731d24ed617a2af8600f
b7538269600c05afe22a5bea0d403f3ec0837fe8
/system/back/PlutoBackend/AbstractRequest.cpp
e7e9abaa98424dfa7497e1e9773c2136b3d4bd89
[]
no_license
SanjanaSrabanti16/urban-chronicles
8085885e939c4c6b1b3483c4dc04778b565d2a60
4a7f1a0055e112a88281e29f88495a05c8b52c50
refs/heads/main
2023-07-02T20:41:34.362182
2021-08-12T17:12:17
2021-08-12T17:12:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
422
cpp
AbstractRequest.cpp
#include "AbstractRequest.h" AbstractRequest::AbstractRequest() { m_jumpLayer = false; } AbstractRequest::~AbstractRequest() { } DatasetType AbstractRequest::parserDatasetType(const QString& polygon) { if (polygon.contains("neighborhoods", Qt::CaseInsensitive)) { return DatasetType::NTA; } if (polygon.contains("community", Qt::CaseInsensitive)) { return DatasetType::CD; } return DatasetType::Unknown; }
db4ffa03db43887546668f9fe9733ec97f5c74a5
925f70976371fa7ea51037cc61932c1c3d3f2403
/src/subt/subt_gazebo/include/subt_gazebo/GameLogicPlugin.hh
6d9402d2bf631324f978dad6452884f7e881c790
[ "Apache-2.0" ]
permissive
arjo129/darpasubt
811228872cccc6075e49250b70769a44330da686
6f90b70bd397b6fbedf6193c2714e808c5fecc91
refs/heads/master
2020-04-02T17:24:49.977337
2019-11-27T14:45:42
2019-11-27T14:45:42
154,656,645
4
3
null
2020-03-07T00:17:47
2018-10-25T11:05:30
C
UTF-8
C++
false
false
7,303
hh
GameLogicPlugin.hh
/* * Copyright (C) 2018 Open Source Robotics 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. * */ #ifndef SUBT_GAZEBO_GAMELOGICPLUGIN_HH_ #define SUBT_GAZEBO_GAMELOGICPLUGIN_HH_ #include <ros/ros.h> #include <std_srvs/SetBool.h> #include <std_srvs/Trigger.h> #include <subt_msgs/PoseFromArtifact.h> #include <array> #include <chrono> #include <map> #include <memory> #include <mutex> #include <string> #include <utility> #include <gazebo/common/Event.hh> #include <gazebo/common/Plugin.hh> #include <gazebo/physics/physics.hh> #include <gazebo/transport/Node.hh> #include <ignition/math/Pose3.hh> #include <sdf/sdf.hh> #include "subt_gazebo/CommonTypes.hh" // Forward declarations. namespace subt { namespace msgs { class Artifact; } } namespace ignition { namespace msgs { class Pose; } } namespace gazebo { /// \brief A plugin that takes care of all the SubT challenge logic. class GameLogicPlugin : public WorldPlugin { /// \brief Mapping between enum types and strings. const std::array< const std::pair<subt::ArtifactType, std::string>, 8> kArtifactTypes { { {subt::ArtifactType::TYPE_BACKPACK , "TYPE_BACKPACK"}, {subt::ArtifactType::TYPE_DUCT , "TYPE_DUCT"}, {subt::ArtifactType::TYPE_ELECTRICAL_BOX, "TYPE_ELECTRICAL_BOX"}, {subt::ArtifactType::TYPE_EXTINGUISHER , "TYPE_EXTINGUISHER"}, {subt::ArtifactType::TYPE_PHONE , "TYPE_PHONE"}, {subt::ArtifactType::TYPE_RADIO , "TYPE_RADIO"}, {subt::ArtifactType::TYPE_TOOLBOX , "TYPE_TOOLBOX"}, {subt::ArtifactType::TYPE_VALVE , "TYPE_VALVE"} } }; // Documentation inherited public: virtual void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf); /// \brief Callback for World Update events. private: void OnUpdate(); /// \brief Callback triggered when a pair of links collide. It starts the /// timer if a specified start area is collided by some object. /// \param[in] _msg The message containing a list of collision information. private: void OnStartCollision(ConstIntPtr &_msg); /// \brief ROS service callback triggered when the service is called. /// \param[in] _req The message containing a flag telling if the game is to /// be finished. /// \param[out] _res The response message. private: bool OnFinishCall(std_srvs::SetBool::Request &_req, std_srvs::SetBool::Response &_res); /// \brief ROS service callback triggered when the service is called. /// \param[in] _req The message containing the robot name. /// \param[out] _res The response message. private: bool OnPoseFromArtifact(subt_msgs::PoseFromArtifact::Request &_req, subt_msgs::PoseFromArtifact::Response &_res); /// \brief Parse all the artifacts. /// \param[in] _sdf The SDF element containing the artifacts. private: void ParseArtifacts(sdf::ElementPtr _sdf); /// \brief Callback executed to process a new artifact request /// sent by a team. /// \param[in] _req The service request. private: void OnNewArtifact(const subt::msgs::Artifact &_req); /// \brief Calculate the score of a new artifact request. /// \param[in] _type The object type. See ArtifactType. /// \param[in] _pose The object pose. /// \return The score obtained for this object. private: double ScoreArtifact(const subt::ArtifactType &_type, const ignition::msgs::Pose &_pose); /// \brief Publish the score. /// \param[in] _event Unused. private: void PublishScore(const ros::TimerEvent &_event); /// \brief Create an ArtifactType from a string. /// \param[in] _name The artifact in string format. /// \param[out] _type The artifact type. /// \return True when the conversion succeed or false otherwise. private: bool ArtifactFromString(const std::string &_name, subt::ArtifactType &_type); /// \brief Create an ArtifactType from an integer. /// \param[in] _typeInt The artifact in int format. /// \param[out] _type The artifact type. /// \return True when the conversion succeed or false otherwise. private: bool ArtifactFromInt(const uint32_t &_typeInt, subt::ArtifactType &_type); /// \brief Write a simulation timestamp to a logfile. /// \return A file stream that can be used to write additional /// information to the logfile. private: std::ofstream &Log(); /// \brief World pointer. private: physics::WorldPtr world; /// \brief Connection to World Update events. private: event::ConnectionPtr updateConnection; /// \brief Ignition Transport node. private: ignition::transport::Node node; /// \brief Gazebo Transport node. private: gazebo::transport::NodePtr gzNode; /// \brief ROS service server to receive a call to finish the game. private: ros::ServiceServer finishService; /// \brief ROS service server to receive the location of a robot relative to /// the origin artifact. private: ros::ServiceServer poseFromArtifactService; /// \brief Gazebo Transport Subscriber to check the collision. private: gazebo::transport::SubscriberPtr startCollisionSub; /// \brief Whether the task has started. private: bool started = false; /// \brief Whether the task has finished. private: bool finished = false; /// \brief Start time used for scoring. private: std::chrono::steady_clock::time_point startTime; /// \brief Finish time used for scoring. private: std::chrono::steady_clock::time_point finishTime; /// \brief Store all artifacts. /// The key is the object type. See ArtifactType for all supported values. /// The value is another map, where the key is the model name and the value /// is a Model pointer. private: std::map<subt::ArtifactType, std::map<std::string, physics::ModelPtr>> artifacts; /// \brief The ROS node handler used for communications. private: std::unique_ptr<ros::NodeHandle> rosnode; /// \brief Publish the score. private: ros::Publisher scorePub; /// \brief Total score. private: double totalScore = 0.0; /// \brief A timer to publish the score at a given frequency. private: ros::Timer scoreTimer; /// \brief A mutex. private: std::mutex mutex; /// \brief Log file output stream. private: std::ofstream logStream; /// \brief The pose of the object marking the origin of the artifacts. private: ignition::math::Pose3d artifactOriginPose; }; } #endif
64357d360e9059ab1a339f69403397d4a40838f8
34d39f6449e0ebc8b5fa27425a2179a10eb71314
/CommandePeser.h
43d588312e3952376c848f37e9681e8e83adf0a4
[]
no_license
skidlucas/sim-robot
422effd2fb022025179a23431216f6e9bd0579d3
7c530213c060f540ec8ad50c9b51f8a4f245d327
refs/heads/master
2021-01-10T03:21:28.621072
2015-12-03T16:28:14
2015-12-03T16:28:14
44,597,303
0
1
null
null
null
null
UTF-8
C++
false
false
492
h
CommandePeser.h
#ifndef _COMMANDE_PESER_ #define _COMMANDE_PESER_ #include <string> #include <iostream> #include "CommandeRobot.h" using namespace std; class CommandePeser : public CommandeRobot { private: public: CommandePeser(Robot* r = nullptr, Invocateur * inv = nullptr):CommandeRobot("PESER"){ robot = r; invocateur = inv; } bool reversible(){ return false; } void executer(); void desexecuter(); Commande * constructeurVirtuel(Invocateur * inv); }; #endif
dbffbee4d3cf7cbe8f0f71289956fc0646032fc0
b22819d39a788b046e9a475f655b005ac478b1ef
/src/475.Heaters.cpp
4ac833baca26ae891c5f08d2002a1e59ffbd5204
[]
no_license
chouchoudiudiu/LeetCode
81424dd12c6ec7ff0c801b6c4786a6e567b1cdec
a5af14f948db04a2e5a1adfefe033a872fd8f0ed
refs/heads/master
2021-01-11T07:45:53.672062
2019-05-14T21:26:35
2019-05-14T21:26:35
72,676,179
1
0
null
null
null
null
UTF-8
C++
false
false
1,316
cpp
475.Heaters.cpp
class Solution { public: //每一个house找和他最近位置比它大的heater,找不到就用heaters最大的,这样保证每个house都能cover到 int findRadius(vector<int>& houses, vector<int>& heaters) { sort(heaters.begin(), heaters.end()); int radius = 0; for (auto house : houses) { auto pos = lower_bound(heaters.begin(), heaters.end(), house); //basically binary search, lowerbound >=; upperbound > int dist1 = (pos == heaters.end()) ? INT_MAX : *pos - house; int dist2 = (pos == heaters.begin()) ? INT_MAX : house - *(--pos); //house一定大于它,因为后一个是第一个大等于house的 radius = max(radius, min(dist1, dist2)); } return radius; } }; //1234 [1,4];1 好理解,2先算到 *pos = 4,再看 *(--pos) == 1 /* 用二分查找法来快速找到第一个大于等于当前house位置的数,如果这个数存在,那么我们可以算出其和house的差值, 并且如果这个数不是heater的首数字,我们可以算出house和前面一个数的差值,这两个数中取较小的为cover当前house的最小半径, 然后我们每次更新结果res即可 用STL中的lower_bound来代替二分查找的代码来快速找到第一个大于等于目标值的位置 */
6901d7aa89122e880e34837e07cf234dd2ac7c04
55281c04f08114b12ec037daaa43c5970f8185c4
/src/perspective_transformer.h
fe04d4fd3a1ab364875f22b9670518526ed28cff
[]
no_license
SpiderUnicorn/sudoku-irl
365c0b973f369b68649f673ff441b1e004604733
fc18f272e6e01d0ab93c5356905674391a98d18f
refs/heads/master
2021-05-14T11:16:02.328674
2018-01-14T19:26:58
2018-01-14T19:26:58
116,257,819
0
0
null
null
null
null
UTF-8
C++
false
false
544
h
perspective_transformer.h
#ifndef SUDOKU_PERSPECTIVE_TRANSFORMER #define SUDOKU_PERSPECTIVE_TRANSFORMER #include <stdio.h> #include <opencv2/opencv.hpp> namespace sudoku { class PerspectiveTransformer { public: PerspectiveTransformer(cv::Mat img) : original(img) {} cv::Mat extract_straightened_board(int size); cv::Mat project_onto_unstraightened(cv::Mat projection); // unextract(); private: cv::Mat original; cv::Point2f corners[4]; cv::Point2f destinationCorners[4]; }; } #endif
f544cdda497e5c066d0910b541e1730578b4cda3
38616fa53a78f61d866ad4f2d3251ef471366229
/3rdparty/RobustGNSS/gtsam/gtsam/nonlinear/NonlinearOptimizer.cpp
e1efa20615c55acec35d748cba5ce3372711e2ba
[ "MIT", "BSD-3-Clause", "LGPL-2.1-only", "MPL-2.0", "LGPL-2.0-or-later", "BSD-2-Clause" ]
permissive
wuyou33/Enabling-Robust-State-Estimation-through-Measurement-Error-Covariance-Adaptation
3b467fa6d3f34cabbd5ee59596ac1950aabf2522
2f1ff054b7c5059da80bb3b2f80c05861a02cc36
refs/heads/master
2020-06-08T12:42:31.977541
2019-06-10T15:04:33
2019-06-10T15:04:33
193,229,646
1
0
MIT
2019-06-22T12:07:29
2019-06-22T12:07:29
null
UTF-8
C++
false
false
8,888
cpp
NonlinearOptimizer.cpp
/* ---------------------------------------------------------------------------- * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) * See LICENSE for the license information * -------------------------------------------------------------------------- */ /** * @file NonlinearOptimizer.cpp * @brief Convergence functions not dependent on graph types * @author Frank Dellaert * @date Jul 17, 2010 */ #include <gtsam/nonlinear/NonlinearOptimizer.h> #include <gtsam/nonlinear/internal/NonlinearOptimizerState.h> #include <gtsam/linear/GaussianEliminationTree.h> #include <gtsam/linear/VectorValues.h> #include <gtsam/linear/SubgraphSolver.h> #include <gtsam/linear/PCGSolver.h> #include <gtsam/linear/GaussianFactorGraph.h> #include <gtsam/linear/VectorValues.h> #include <gtsam/inference/Ordering.h> #include <boost/algorithm/string.hpp> #include <boost/shared_ptr.hpp> #include <stdexcept> #include <iostream> #include <iomanip> using namespace std; namespace gtsam { /* ************************************************************************* */ // NOTE(frank): unique_ptr by-value takes ownership, as discussed in // http://stackoverflow.com/questions/8114276/ NonlinearOptimizer::NonlinearOptimizer(const NonlinearFactorGraph& graph, std::unique_ptr<internal::NonlinearOptimizerState> state) : graph_(graph), state_(std::move(state)) {} /* ************************************************************************* */ NonlinearOptimizer::~NonlinearOptimizer() {} /* ************************************************************************* */ double NonlinearOptimizer::error() const { return state_->error; } size_t NonlinearOptimizer::iterations() const { return state_->iterations; } const Values& NonlinearOptimizer::values() const { return state_->values; } /* ************************************************************************* */ void NonlinearOptimizer::defaultOptimize() { const NonlinearOptimizerParams& params = _params(); double currentError = error(); // check if we're already close enough if (currentError <= params.errorTol) { if (params.verbosity >= NonlinearOptimizerParams::ERROR) cout << "Exiting, as error = " << currentError << " < " << params.errorTol << endl; return; } // Maybe show output if (params.verbosity >= NonlinearOptimizerParams::VALUES) values().print("Initial values"); if (params.verbosity >= NonlinearOptimizerParams::ERROR) cout << "Initial error: " << currentError << endl; // Return if we already have too many iterations if (iterations() >= params.maxIterations) { if (params.verbosity >= NonlinearOptimizerParams::TERMINATION) { cout << "iterations: " << iterations() << " >? " << params.maxIterations << endl; } return; } // Iterative loop do { // Do next iteration currentError = error(); iterate(); tictoc_finishedIteration(); // Maybe show output if (params.verbosity >= NonlinearOptimizerParams::VALUES) values().print("newValues"); if (params.verbosity >= NonlinearOptimizerParams::ERROR) cout << "newError: " << error() << endl; } while (iterations() < params.maxIterations && !checkConvergence(params.relativeErrorTol, params.absoluteErrorTol, params.errorTol, currentError, error(), params.verbosity)); // Printing if verbose if (params.verbosity >= NonlinearOptimizerParams::TERMINATION) { cout << "iterations: " << iterations() << " >? " << params.maxIterations << endl; if (iterations() >= params.maxIterations) cout << "Terminating because reached maximum iterations" << endl; } } /* ************************************************************************* */ const Values& NonlinearOptimizer::optimizeSafely() { static const Values empty; try { defaultOptimize(); return values(); } catch (...) { // uncaught exception, returning empty result return empty; } } /* ************************************************************************* */ VectorValues NonlinearOptimizer::solve(const GaussianFactorGraph& gfg, const NonlinearOptimizerParams& params) const { // solution of linear solver is an update to the linearization point VectorValues delta; boost::optional<const Ordering&> optionalOrdering; if (params.ordering) optionalOrdering.reset(*params.ordering); // Check which solver we are using if (params.isMultifrontal()) { // Multifrontal QR or Cholesky (decided by params.getEliminationFunction()) delta = gfg.optimize(optionalOrdering, params.getEliminationFunction()); } else if (params.isSequential()) { // Sequential QR or Cholesky (decided by params.getEliminationFunction()) delta = gfg.eliminateSequential(optionalOrdering, params.getEliminationFunction(), boost::none, params.orderingType)->optimize(); } else if (params.isIterative()) { // Conjugate Gradient -> needs params.iterativeParams if (!params.iterativeParams) throw std::runtime_error("NonlinearOptimizer::solve: cg parameter has to be assigned ..."); if (boost::shared_ptr<PCGSolverParameters> pcg = boost::dynamic_pointer_cast<PCGSolverParameters>(params.iterativeParams)) { delta = PCGSolver(*pcg).optimize(gfg); } else if (boost::shared_ptr<SubgraphSolverParameters> spcg = boost::dynamic_pointer_cast<SubgraphSolverParameters>(params.iterativeParams)) { if (!params.ordering) throw std::runtime_error("SubgraphSolver needs an ordering"); delta = SubgraphSolver(gfg, *spcg, *params.ordering).optimize(); } else { throw std::runtime_error( "NonlinearOptimizer::solve: special cg parameter type is not handled in LM solver ..."); } } else { throw std::runtime_error("NonlinearOptimizer::solve: Optimization parameter is invalid"); } // return update return delta; } /* ************************************************************************* */ bool checkConvergence(double relativeErrorTreshold, double absoluteErrorTreshold, double errorThreshold, double currentError, double newError, NonlinearOptimizerParams::Verbosity verbosity) { if (verbosity >= NonlinearOptimizerParams::ERROR) { if (newError <= errorThreshold) cout << "errorThreshold: " << newError << " < " << errorThreshold << endl; else cout << "errorThreshold: " << newError << " > " << errorThreshold << endl; } if (newError <= errorThreshold) return true; // check if diverges double absoluteDecrease = currentError - newError; if (verbosity >= NonlinearOptimizerParams::ERROR) { if (absoluteDecrease <= absoluteErrorTreshold) cout << "absoluteDecrease: " << setprecision(12) << absoluteDecrease << " < " << absoluteErrorTreshold << endl; else cout << "absoluteDecrease: " << setprecision(12) << absoluteDecrease << " >= " << absoluteErrorTreshold << endl; } // calculate relative error decrease and update currentError double relativeDecrease = absoluteDecrease / currentError; if (verbosity >= NonlinearOptimizerParams::ERROR) { if (relativeDecrease <= relativeErrorTreshold) cout << "relativeDecrease: " << setprecision(12) << relativeDecrease << " < " << relativeErrorTreshold << endl; else cout << "relativeDecrease: " << setprecision(12) << relativeDecrease << " >= " << relativeErrorTreshold << endl; } bool converged = (relativeErrorTreshold && (relativeDecrease <= relativeErrorTreshold)) || (absoluteDecrease <= absoluteErrorTreshold); if (verbosity >= NonlinearOptimizerParams::TERMINATION && converged) { if (absoluteDecrease >= 0.0) cout << "converged" << endl; else cout << "Warning: stopping nonlinear iterations because error increased" << endl; cout << "errorThreshold: " << newError << " <? " << errorThreshold << endl; cout << "absoluteDecrease: " << setprecision(12) << absoluteDecrease << " <? " << absoluteErrorTreshold << endl; cout << "relativeDecrease: " << setprecision(12) << relativeDecrease << " <? " << relativeErrorTreshold << endl; } return converged; } /* ************************************************************************* */ GTSAM_EXPORT bool checkConvergence(const NonlinearOptimizerParams& params, double currentError, double newError) { return checkConvergence(params.relativeErrorTol, params.absoluteErrorTol, params.errorTol, currentError, newError, params.verbosity); } }
969c7dcd8f066e5eee7b503c402f2140a01a2d05
3b28ce5f9f1a7e671ba1f8dc0abaf458959d0c43
/MyTask/MyTask/MyButton.cpp
69f914cf5d31913037e19b9cfa6c622ddee9a6a5
[]
no_license
cnsuhao/MyTask12138
9712234b0e35ba6dc41c7e263335ccfe0d1ce204
4892ca47f99be8ea236acb323990b4940d6ab071
refs/heads/master
2021-08-23T13:42:38.238520
2016-12-26T02:37:43
2016-12-26T02:37:43
null
0
0
null
null
null
null
GB18030
C++
false
false
2,052
cpp
MyButton.cpp
// MyButton.cpp : implementation file // #include "stdafx.h" #include "MyButton.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMyButton CMyButton::CMyButton() { } CMyButton::~CMyButton() { } BEGIN_MESSAGE_MAP(CMyButton, CButton) //{{AFX_MSG_MAP(CMyButton) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMyButton message handlers void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CDC *pDC=CDC::FromHandle(lpDrawItemStruct->hDC); pDC->SelectClipRgn(&m_rgn); CRect rect=lpDrawItemStruct->rcItem;//得到按键区域 CString sCaption; VERIFY(lpDrawItemStruct->CtlType==ODT_BUTTON); GetWindowText(sCaption);//得到按键的标题 CBitmapButton::SetWindowRgn(m_rgn, FALSE); CBitmapButton::DrawItem(lpDrawItemStruct); pDC->SetBkMode(TRANSPARENT); pDC->DrawText(sCaption,rect,DT_CENTER|DT_VCENTER|DT_SINGLELINE); pDC->SelectClipRgn(NULL); } void CMyButton::PreSubclassWindow() { CButton::PreSubclassWindow(); // // ModifyStyle(0, BS_OWNERDRAW); // CRect rect; // GetClientRect(rect); // m_rgn.DeleteObject(); // SetWindowRgn(NULL, FALSE); // m_rgn.CreateEllipticRgnIndirect(rect); // //m_rgn.CreateEllipticRgn(0, 0, 200, 100); // SetWindowRgn(m_rgn, TRUE); // // // Convert client coords to the parents client coords // ClientToScreen(rect); // CWnd* pParent = GetParent(); // if (pParent) pParent->ScreenToClient(rect); // // // Resize the window // MoveWindow(rect.left, rect.top, rect.Width(), rect.Height(), TRUE); // // Resize the window to make it square // // // Get the vital statistics of the window // // rect.left+=5; // // rect.right -=5; // // rect.top+=3; // // rect.bottom -=3; }
a6b5d24a7afddaceaa85c6e70c453971d8ad10d5
c338f9b1c20141ede9905e23971487808ab90b58
/tinyUI/src/pagemanager.cpp
3f146c18b807ca20e493cfe81f45ae0cbafddf63
[]
no_license
HappyGod158/tinyUI
b7b11a4a2731daca0ab29218eead12b0641f0b56
5d8326aa0659e17ea255af3c62ffe6bb5b0c5f62
refs/heads/master
2021-01-12T09:47:28.230670
2016-12-12T09:03:37
2016-12-12T09:03:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,447
cpp
pagemanager.cpp
#include "pagemanager.h" PageManager* PageManager::pageManager{nullptr}; PageManager& PageManager::getInstance() { if(!pageManager) pageManager = new PageManager(); return *pageManager; } void PageManager::destoryInstance() { delete pageManager; pageManager = nullptr; } PageManager::PageManager(QObject *parent) : QObject(parent) { } void PageManager::registerPageInfo(const QString& url, PageInfo* pageInfo) { pageHash.insert(url, pageInfo); } void PageManager::unregisterPageInfo(const QString& url) { pageHash.remove(url); } bool PageManager::isPageInfoRegistered(const QString& url) { return pageHash.contains(url); } PageInfo* PageManager::getPageInfo(const QString& url) { if(pageHash.contains(url)) return pageHash.value(url); else return nullptr; } QWidget* PageManager::getPage(const QString& url) { PageInfo *pageInfo = getPageInfo(url); if(!pageInfo){ return nullptr; }else{ return pageInfo->getPage(); } } QString PageManager::getUrl(QWidget* widget) { if(!widget) return QString(); else{ auto i = pageHash.constBegin(); while (i != pageHash.constEnd()) { PageInfo* pageInfo = i.value(); if(pageInfo->getPage() == widget) return i.key(); i++; } return QString(); } } bool PageManager::isPageOpened(const QString& url) { QWidget* page = getPage(url); if(!page) return false; else return true; } bool PageManager::linkPage(const QString& url, QWidget* page) { PageInfo* pageInfo = getPageInfo(url); if(!pageInfo) return false; else{ pageInfo->setPage(page); return true; } } bool PageManager::unlinkPage(const QString& url) { PageInfo* pageInfo = getPageInfo(url); if(!pageInfo) return false; else{ pageInfo->setPage(nullptr); return true; } } bool PageManager::constructPage(const QString& url, QWidget* &constructedPage) { if(!isPageInfoRegistered(url)){ constructedPage = nullptr; return false; } PageInfo* pageInfo = getPageInfo(url); QWidget* page = pageInfo->getPage(); if(page){ constructedPage = page; return true; }else{ constructedPage = pageInfo->getConstructor()(); linkPage(url, constructedPage); return true; } }
7f28fa06e0c879173c998426a28ba2fbc4c350a5
0e308a2e6e1f3a5d7e3ae11ec8842f815ba38559
/lib/malloy/html/form.hpp
2c720406e0a7ed776b1b67428c836d8b86190178
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
darkomenz/malloy
d0430b67f5b7fa25a1e0eaacf3bf2b89396402aa
69e383d319d4d090888cab21b0c33e3c1499d8ab
refs/heads/main
2023-04-25T23:55:58.577468
2021-05-12T08:41:30
2021-05-12T08:41:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,584
hpp
form.hpp
#pragma once #include <optional> #include <string> #include <unordered_map> namespace malloy::http { class request; } namespace malloy::html { /** * Class for handling HTML forms. * * This class can be used to parse an HTML form. * Form data is represented as key-value pairs where both `key` and * `value` are of type `std::string`. */ class form { public: form() = default; virtual ~form() = default; /** * Parse a request into this form. * * @param req The request. * @return Whether the parsing was successful. */ bool parse(const malloy::http::request& req); /** * Checks whether a specific key-value pair is present. * * @param key The key. * @return Whether the key-value pair is present. */ [[nodiscard]] bool has_value(const std::string& key) const; /** * Get the value associated with a specified key (if any). * * @param key The key. * @return The matching value (if any). */ [[nodiscard]] std::optional<std::string> value(const std::string& key) const; /** * Get all key-value pairs. * * @return The key-value pairs. */ [[nodiscard]] std::unordered_map<std::string, std::string> values() const noexcept { return m_values; } private: std::unordered_map<std::string, std::string> m_values; }; }
ff25450e6c19a81e60c8bccdecd3b1a95ab80125
1eda0bf020ddc4481c19bfd43e081152743ebb15
/code/Calculate.h
f2a46ea4ca3e6531469c1e3290f8427eff110a57
[]
no_license
whumashuai/QTcalgen
ee3c2618cf2046d9cc452a1898e764726efe77eb
7309389d72cadc8d4ef11ef6118712c9b331569f
refs/heads/master
2021-07-10T17:04:48.231120
2017-10-12T01:24:22
2017-10-12T01:24:22
106,253,032
0
0
null
null
null
null
UTF-8
C++
false
false
852
h
Calculate.h
#ifndef CALCULATE_H #define CALCULATE_H #include"Fraction.h" #include<stack> #include<deque> using namespace std; class Calculate { public: Calculate(); bool isBracket(char c);//Determine whether it is brackets int getPri(char c);//Get the priority of the symbol int checkzero(Fraction op1); //Check whether the divisor is zero void check(Fraction c, stack<Fraction>& space2, deque<Fraction>& space3);//Determine the priority of the symbol //Remove the element from space1 and assign the element to space2 and space3 void allocate(deque<Fraction>& space1, stack<Fraction>& space2, deque<Fraction>& space3); //Calculate the suffix expression Fraction calculateExpression(deque<Fraction> &space1); }; #endif // CALCULATE_H
ddb9f22b68cfc73323bc69d11f0ea0f7d75a92b6
2371abc6f3dff895ee810a6ea356a8a49ace44b6
/Soloteam V2/Temp/StagingArea/Data/il2cppOutput/AssemblyU2DCSharpU2Dfirstpass_character_select2004000448.h
168c1ca820f45482db8b9803d795b4dacdf67c16
[]
no_license
System3748/ChefCouponpon_Source
a1d7eb3ae0b170e33cea4a1f054abb6dce578d85
c6f4585d40a030a34d0b7ce519bbb38fdc82f9d1
refs/heads/master
2020-03-15T12:58:53.160961
2018-05-04T16:26:56
2018-05-04T16:26:56
132,155,944
0
0
null
null
null
null
UTF-8
C++
false
false
1,565
h
AssemblyU2DCSharpU2Dfirstpass_character_select2004000448.h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "UnityEngine_UnityEngine_MonoBehaviour1158329972.h" // UnityEngine.Sprite struct Sprite_t309593783; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // character_select struct character_select_t2004000448 : public MonoBehaviour_t1158329972 { public: // UnityEngine.Sprite character_select::_west Sprite_t309593783 * ____west_2; // UnityEngine.Sprite character_select::_east Sprite_t309593783 * ____east_3; public: inline static int32_t get_offset_of__west_2() { return static_cast<int32_t>(offsetof(character_select_t2004000448, ____west_2)); } inline Sprite_t309593783 * get__west_2() const { return ____west_2; } inline Sprite_t309593783 ** get_address_of__west_2() { return &____west_2; } inline void set__west_2(Sprite_t309593783 * value) { ____west_2 = value; Il2CppCodeGenWriteBarrier(&____west_2, value); } inline static int32_t get_offset_of__east_3() { return static_cast<int32_t>(offsetof(character_select_t2004000448, ____east_3)); } inline Sprite_t309593783 * get__east_3() const { return ____east_3; } inline Sprite_t309593783 ** get_address_of__east_3() { return &____east_3; } inline void set__east_3(Sprite_t309593783 * value) { ____east_3 = value; Il2CppCodeGenWriteBarrier(&____east_3, value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
ec96244dff00f30107cfe04ca424d4f6f815e668
10549922d157ce67b6a32759b09a8dee78aebe9c
/calendarui/regionalplugins/KoreanLunar/inc/CalenLunarLocalizer.h
7c1c9e460b5b87efaf50ae36693c18891038a077
[]
no_license
SymbianSource/oss.FCL.sf.app.organizer
c8be5fbc1c5d8fc7d54a63bb1793f8db823fa3d7
e15734d1943a012120b188fe3ffd5dd7594d145f
refs/heads/master
2021-01-10T22:41:15.449986
2010-11-03T11:42:22
2010-11-03T11:42:22
70,369,523
0
0
null
null
null
null
UTF-8
C++
false
false
2,332
h
CalenLunarLocalizer.h
/* * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description : Class looking after alarm fields for forms. * */ #ifndef __CALENLUNARLOCALIZER_H__ #define __CALENLUNARLOCALIZER_H__ // INCLUDES #include <e32base.h> #include <badesca.h> #include "CalenLunarLocalizedInfo.h" #include "calendarvariant.hrh" // FORWARD DECLARATION class CEikonEnv; class TCalenLunarInfo; class TChineseDate; class CFont; class CCalenExtraRowFormatter; /** * Class declaration for Lunar localizer */ class CCalenLunarLocalizer : public CBase { public: // public API static CCalenLunarLocalizer* NewL(); virtual ~CCalenLunarLocalizer(); virtual CCalenLunarLocalizedInfo* LocalizeL( TCalenLunarInfo& aInfo ); virtual TPtrC GetExtraRowTextL( CCalenLunarLocalizedInfo& aLocInfo, TInt aMaxWidth, const CFont& aFont #ifdef RD_CALENDAR_PREVIEW , TBool aTwoLines #endif // RD_CALENDAR_PREVIEW ); protected: CCalenLunarLocalizer(); void ConstructL(); TBool TryToFitL( const TDesC& aStr ); virtual void LocalizeMonthAndDayL(CCalenLunarLocalizedInfo* aLocInfo, TCalenLunarInfo& aInfo); private: protected: // data CEikonEnv* iEikEnv; /** * Localized names of lunar festivals * Own. */ CDesCArray* iLunarFestivalNames; /** * Localized names of solar festivals * Own. */ CDesCArray* iSolarFestivalNames; /** * Localized names of solar terms * Own. */ CDesCArray* iSolarTermNames; /** * Format string for western date. * Own. */ HBufC* iGregorianDateFormat; TBuf<1000> iLunarExtraRowText; /** * Language independent formatter of extra row information. */ CCalenExtraRowFormatter* iRowFormatter; }; #endif // __CALENLUNARLOCALIZER_H__
6522163f2ebd563c6daeb6f20a9f06d7050c4725
2061648aa02b9939e2de5f98566bac7385c02d30
/this指针.cpp
5a137683022ac4b38beb0a78b316f01a46e870f7
[]
no_license
MasterMaxLi/CLearn
28091dd0e413d87bc7b55982e90785b2a25fd1b0
180572e2996c1e0e2ab2a59ff543ec09c79e2ca5
refs/heads/main
2023-04-01T10:16:39.103743
2021-04-06T10:37:23
2021-04-06T10:37:23
352,920,683
0
0
null
null
null
null
GB18030
C++
false
false
674
cpp
this指针.cpp
#include<iostream> using namespace std; //this指针指向被调用的成员函数所属的对象 class Person { public: int age; //解决名称冲突 Person(int age) { this->age = age; } Person& PersonAddAge(Person& p) { this->age += p.age; //this指向对象的指针,*指向对象本体 return *this; //返回对象本身 } }; void test01() { Person p1(19); cout << "p1年龄:" << p1.age << endl; } //返回对象本身 *this void test02() { Person p1(28); Person p2(12); //链式编程 p2.PersonAddAge(p1).PersonAddAge(p1).PersonAddAge(p1); cout << "p2的年龄为" << p2.age << endl; } int main() { //test01(); test02(); return 0; }
b162e8a897968ab59b0af2914ac0a4b7396566f7
8e77e058d1f60642cd505e1b8058d6606cf63ca8
/include/Myconf.h
c0d003fc6830e03a99cac27436f3899bf9cccdfa
[]
no_license
cachefish/Smartdict
4116ea51d5889f958a1f2eae108f8eccb908a940
866cd614591d54cde9de17f28b35808ccd68b9f0
refs/heads/master
2022-09-24T14:16:23.071469
2020-06-03T02:32:35
2020-06-03T02:32:35
268,440,067
1
0
null
null
null
null
UTF-8
C++
false
false
2,028
h
Myconf.h
#ifndef __MYCONF_H__ #define __MYCONF_H__ #include<iostream> #include<fstream> #include<sstream> #include<stdexcept> #include<set> #include<map> #include<utility> #include<vector> class MyConf { friend class MyTask; friend class MySocket; friend class ThreadPool; public: MyConf(const std::string&name):_infile(name.c_str()) { if(!_infile){ std::cout<<__DATE__<<" "<<__TIME__<<" "<<__FILE__<<" "<<__LINE__<<" "<<"open failed!"<<std::endl; exit(-1); } std::string line; while(getline(_infile,line)){ std::istringstream instream(line); std::string key,value; instream>>key>>value; _mapConf.insert(make_pair(key,value)); } _infile.close(); //一次设置每个单词的每个字母所对应的索引 for(int vecDictidx=0;vecDictidx!=vecDict.size();++vecDictidx) { setIndex(vecDictidx); } } void setIndex(int vecDictidx) { std::string word,letter; //单词以及单词中的每一个字母 word = vecDict[vecDictidx].first; //根据词典的下标来找每一个单词 //遍历单词的每一个字母,制作索引 for(int i = 0;i!=word.size();++i) { if(word[i]&(1<<7)){ letter = word.substr(i,2); i++; }else{ letter = word.substr(i,1); } mapIndex[letter].insert(vecDictidx); //将包含这个字母的单词 所在vector的下标放入set中 } } std::map<std::string,std::string> &getMapConf() { return _mapConf; } private: std::ifstream _infile; std::map<std::string,std::string> _mapConf; //配置文件 std::vector<std::pair<std::string,int>> vecDict; //词频 std::map<std::string,std::set<int>> mapIndex; //字母索引 }; #endif
22e0cd9165b9e855f60a57166e4a7bc1963eb6f6
0941905ba3c5aae17a70b3b998ea4e1afc5de286
/app/of_colorOscSender/src/scenes/ballScene.cpp
7a25cbb410272464b2642b9894f77e2af205db93
[]
no_license
imclab/spark-OF-UDP
3fbfaa1e2795ae74b2f930b8777e7991abd4c554
46d31b4ee8c4716bc37586411ff2ace11b202997
refs/heads/master
2020-03-30T23:13:43.599315
2014-07-03T17:40:36
2014-07-03T17:40:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,325
cpp
ballScene.cpp
// // noiseScene.cpp // of_colorOscSender // // Created by Firm Read on 6/11/14. // // #include "ballScene.h" void ballScene::setup(){ for (int i = 0 ; i< 1000; i++) { simpleParticle temp; temp.setup(); temp.x = ofRandom(ofGetWidth()); temp.y = ofRandom(ofGetHeight()); temp.xspeed = ofRandom(0.50); temp.yspeed = ofRandom(0.50); // temp.c.set(255); temp.c.setHsb(ofRandom(255), 255, 255); sp.push_back(temp); sineAlphaSpeed = 0.005; minAlpha = 20; } } void ballScene::update(){ for (int i = 0 ; i<sp.size(); i++) { sp[i].update(); sp[i].jumpsToTheOtherSide(); float sine = sin(ofGetElapsedTimef() * i * sineAlphaSpeed + i); minAlpha = ofMap(mousePos.x , 0, ofGetWidth(), 0, 255); sine = ofMap(sine, -1, 1, minAlpha, 255); sp[i].setAlpha(sine); } } void ballScene::draw(){ for (int i = 0; i< sp.size(); i++) { sp[i].draw(); } ofDrawBitmapStringHighlight("ball scene", 20, 60); } void ballScene::mouseDragged(int x, int y, int button){ for (int i = 0 ; i< sp.size(); i++) { sp[i].addAttractionForce(x, y, 10000, 1.0); } } void ballScene::mouseMoved(int x, int y){ mousePos.set(x,y); }
844883087da311fdbc2095a233c7ddd27a75d884
1c42ffc8bcf325ea16326d635d931048ed068077
/Image_Process parts/Refc_vison/Incmp_refrences etc/img_obkj.h
5f01a033d34485accdfea92cda650a487e7f5b6e
[]
no_license
zeplaz/SIDRN
964cf9ce2d3441b3b2b938c3c21dbc02f1ca0ec3
cbf34dfc17c52c40ffbb1b77f15f29fbd3fdba7a
refs/heads/master
2020-04-15T01:05:40.215449
2020-01-05T19:55:38
2020-01-05T19:55:38
164,263,335
0
0
null
2019-05-24T18:59:28
2019-01-06T00:45:49
C++
UTF-8
C++
false
false
954
h
img_obkj.h
//class img_obkj.h #pragma once #include <utility> #include <vector> //3rdparty sfml lib for displays #include <SFML/Graphics.hpp> #include <SFML/Window.hpp> // class img_obkj { private : int be_id; static int be_NextValidID; void set_id(int val); img_objk_prop.obj_id= label; public : std::vector<int[2]> obj_pixel_pars //std::vector<std::pair<int,int[2]>> object_pixel_; img_obkj(int label) {set_id(label);} ~img_obkj(){} // std::list<int[2]> // std::list<int[2]>::iterator it; struct obj_propertiez { int obj_id; int Arra_size; std::vector<int> centrod; long circularity; uint8_t bbox2[2][3]; double second_momnent; double perimeter; uint8_t[4] lagest_4_rowsvalue; uint8_t[4] smallest_4_rowsvalue; uint8_t[4] lagest_4_columvalue; uint8_t[4] smallest_4_columvalue; char type; }img_objk_prop;
28de8444ba4d7386ddb87c23945923d44098cd02
b810c256b146cb83f54342c4c2f81eccb91d2867
/euler/6.cpp
8afbbb820ebc5c307a129293066437da3643f6d4
[]
no_license
ps-kostikov/puzzles
0dde7452a04d5823591e6657e354433879d1b6d6
7618558d808b2f65c8914cea4efa999ed2cca438
refs/heads/master
2021-05-04T11:33:08.007597
2016-09-02T17:47:21
2016-09-02T17:47:21
47,068,496
0
0
null
null
null
null
UTF-8
C++
false
false
258
cpp
6.cpp
#include "common.h" #include <iostream> int main() { Natural n = 100; Natural s1 = 0; Natural s2 = 0; for (Natural k = 0; k <= n; ++k) { s1 += k; s2 += k * k; } std::cout << s1 * s1 - s2 << std::endl; return 0; }
573730636f00343c9233b40dac2b69240f5d243e
d5834f969200160f4ff7119cb517945770735f76
/Battle.cpp
38dc3a9bbc9781cfebbfe628b6443b0b696574b4
[]
no_license
mrj1m0thy/conquest
548595a61f70059bca9c796d72e3a83b420a4212
8deb5713afaba8ae1d48fbb08f6910b390f8ab55
refs/heads/master
2021-01-15T07:57:10.843628
2015-04-15T01:50:40
2015-04-15T01:50:54
29,751,306
1
1
null
null
null
null
UTF-8
C++
false
false
6,164
cpp
Battle.cpp
/* February 1, 2015 Nicholas Sabelli COMP 345 Section SI Assignement #1 This file implements the Battle class along with the Die structure. It is used to define the battle phase of risk. */ #include <iostream> #include <ctime> #include "Battle.h" #include "Country.h" using namespace std; Battle::Battle(Country* attack, Country* defend) { allIn = false; cout << "Battle!!!" << endl << endl; cout << attack->name << " Vs. " << defend->name << endl << endl; cout << "Player " << attack->occupiedBy->name << " Vs. Player " << defend->occupiedBy->name << endl << endl; cout << attack->numberOfPieces << " Armies Vs. " << defend->numberOfPieces << " Armies" << endl << endl; if (CanBattle(attack, defend)) { if (attack->occupiedBy->isComputer) allIn = true; else allIn = AllIn(); //Are you all in? } while (CanBattle(attack, defend)) //Verifies if both have enough armies to continue battling. { Roll(attack, defend); if (!allIn) { if (attack->occupiedBy->isComputer || WillContinue()) //Continue fight? { if (attack->occupiedBy->isComputer) allIn = true; else allIn = AllIn(); //Are you all in? } else { break; } } } if (IsVictory(attack, defend)) //Did attacker win? { Conquer(attack, defend); } else { cout << "Attacking Player Was Defeated!" << endl << endl; } } bool Battle::AllIn() { char ans; do { cout << "Are You All In? (Y/N): "; cin >> ans; cout << endl; if (toupper(ans) == 'Y') { return true; } else if (toupper(ans) == 'N') { return false; } } while (true); } bool Battle::CanBattle(Country* attack, Country* defend) { if (attack->numberOfPieces > 1 && defend->numberOfPieces > 0) { return true; } else { return false; } } bool Battle::WillContinue() { char ans; do { cout << "Would You Like To Continue? (Y/N): "; cin >> ans; cout << endl; if (toupper(ans) == 'Y') { return true; } else if (toupper(ans) == 'N') { return false; } } while (true); } bool Battle::IsVictory(Country* attack, Country* defend) { if (defend->numberOfPieces == 0) { return true; } else { return false; } } void Battle::Roll(Country* attack, Country* defend) { int attackRoll = 0; int defendRoll = 0; int tempRoll = 0; switch (attack->numberOfPieces) //Depending on the attackers number of pieces he/she get a max amount of die. { case 2: attackRoll = 1; break; case 3: attackRoll = 2; break; default: attackRoll = 3; } switch (defend->numberOfPieces) //Depending on the defends number of pieces he/she get a max amount of die. { case 1: defendRoll = 1; break; default: defendRoll = 2; } if (!allIn) //Not all in? How many die do I roll then? { do { cout << attack->occupiedBy->name << " Player How Many Die Would You Like To Roll? (1"; for (int i = 1; i < attackRoll; i++) { cout << ", " << i + 1; } cout << "): "; cin >> tempRoll; cout << endl; } while (tempRoll < 1 || tempRoll > attackRoll); attackRoll = tempRoll; do { cout << defend->occupiedBy->name << " Player How Many Die Would You Like To Roll? (1"; for (int i = 1; i < defendRoll; i++) { cout << ", " << i + 1; } cout << "): "; cin >> tempRoll; cout << endl; } while (tempRoll < 1 || tempRoll > defendRoll); defendRoll = tempRoll; } srand(static_cast<int>(time(0))); Die att; Die def; for (int i = 0; i < attackRoll; i++) //Rolls attackers die. { att.roles[i] = rand() % 6 + 1; } for (int i = 0; i < defendRoll; i++) //Rolls defenders die. { def.roles[i] = rand() % 6 + 1; } attack->diesRolled = attackRoll; defend->diesRolled = defendRoll; int attWin = 0; int attLoss = 0; Compare(att, def, attackRoll, defendRoll, attWin, attLoss); Casualties(attack, defend, attWin, attLoss); Report(attack, defend, attWin, attLoss); } void Battle::Compare(Die& att, Die& def, int attackRoll, int defendRoll, int& attWin, int& attLoss) { for (int i = 0; i < attackRoll; i++) //Sort attackers die, highest to lowest. { for (int j = 1; j < attackRoll; j++) { if (att.roles[i] < att.roles[j]) { swap(att.roles[i], att.roles[j]); } } } for (int i = 0; i < defendRoll; i++) //Sort defenders die, highest to lowest. { for (int j = 1; j < defendRoll; j++) { if (def.roles[i] < def.roles[j]) swap(def.roles[i], def.roles[j]); } } for (int i = 0; i < defendRoll; i++) //Compare pairs of die. { if (att.roles[i] > def.roles[i]) { attWin++; //Attack die higher. } else { attLoss++; //Defend die higher or equal. } } } void Battle::Report(Country* attack, Country* defend, int attWin, int attLoss) { cout << "Attacking Player Destroyed " << attWin << " Of The Defending Players Armies And Lost " << attLoss << " Armies!" << endl << endl; } void Battle::Casualties(Country* attack, Country* defend, int attWin, int attLoss) { //Losses from the attack are subtracted. defend->numberOfPieces -= attWin; attack->numberOfPieces -= attLoss; } void Battle::Conquer(Country* attack, Country* defend) { int ans; cout << "Congratulations Attacking Player You Have Defeated Your Opponent!" << endl << endl; if (attack->numberOfPieces > 2) { if (attack->occupiedBy->isComputer) ans = attack->numberOfPieces - 1; else{ do { cout << "How many armies would you like to move? (min " << attack->diesRolled << ", max " << attack->numberOfPieces - 1 << "): "; cin >> ans; cout << endl; } while (ans < attack->diesRolled || ans > attack->numberOfPieces - 1); //Range min and max of pieces to move. } //Transfer of ownership. attack->numberOfPieces -= ans; defend->numberOfPieces += ans; defend->occupiedBy->RemoveCountry(defend); attack->occupiedBy->AddCountry(defend); defend->occupiedBy = attack->occupiedBy; } else //Attacker only has 2 pieces. One stays the other captures. { //Transfer of ownership. attack->numberOfPieces -= 1; defend->numberOfPieces += 1; attack->occupiedBy->AddCountry(defend); defend->occupiedBy->RemoveCountry(defend); defend->occupiedBy = attack->occupiedBy; } }
38be2b8dcf1a6fae292d9b7a3ba78e064ca76c9a
20274b4c306e6dc1cb64366eb56888c238cdb47a
/jni/fnaf/common/Entity/foxy/FoxyRenderer.cpp
67833fc3362cc487aed341a69a88efc9d71542de
[]
no_license
TrinityDevelopers/FNAF-PE
f689e5ff46fb529b4e62f9e260367c69b42af883
aef0c04fcb6a7a5018a5943d810886b6ec34ba25
refs/heads/master
2021-04-26T16:52:23.692051
2015-10-02T22:24:12
2015-10-02T22:24:12
42,960,265
3
0
null
null
null
null
UTF-8
C++
false
false
269
cpp
FoxyRenderer.cpp
#include "FoxyRenderer.h" std::string FoxyRenderer::textureName = "mob/foxy.png" FoxyRenderer::FoxyRenderer(Model* model, float f) : MobRenderer(model, f) { } FoxyRenderer::~FoxyRenderer() { } FoxyRenderer::bindMobTexture(Mob* mob) { bindTexture(textureName, 0) }
1b64e6c1c594a10ac6869feeb16ee7ff8fb9b21c
889de8ff2883bae85ffbfb5e4bf0cabdbe09a3c7
/src/TargetAlgorithm.cpp
9e41a1e7f038e92097dc5c20aca3555494cf4c90
[]
no_license
JavierVillegas/JustMirrors
7f07cff79dbb78b3e57b6c255a036d482722cc1a
6e2fe4b9d45701f8def5dddc184a1628b92ed237
refs/heads/master
2020-05-09T11:56:19.758563
2013-11-14T16:40:26
2013-11-14T16:40:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,885
cpp
TargetAlgorithm.cpp
// // TargetAlgorithm.cpp // Defense // // Created by Javier Villegas on 6/6/12. // Copyright (c) 2012 UCSB. All rights reserved. // #include <iostream> #include "defense.h" void defense::TargetAlgorithmUpdate(int TMode){ float ThDis =13.4; KtarTgDemo = 19.25; KdamTgDemo = 1.05; float dt = 0.25; // for(int i =0;i< NTARTargDemo;i++){ // TargIndTargDemo[i]=-1; // } for (int kt=0; kt<NTARTargDemo; kt++) { float MinDis =10000000; int MinIndi =-5; for (int ko=0; ko<NOBJTargDemo; ko++) { ofVec2f ErrorVec; ErrorVec = TheTargetsTargDemo[kt]-TheObjectsTargDemo[ko]; float dis = ErrorVec.length(); if ((dis < MinDis)&&(TargIndTargDemo[ko]==-1)){ MinIndi = ko; MinDis = dis; } } TargIndTargDemo[MinIndi] = kt; } for (int ko=0; ko<NOBJTargDemo; ko++) { ofVec2f UpdateVec; float MinDis =10000000; int MinIndi =-5; if (TargIndTargDemo[ko]==-1) { MinDis =100000; for (int kt=0; kt<NTARTargDemo; kt++) { ofVec2f ErrorVec; ErrorVec = TheTargetsTargDemo[kt]-TheObjectsTargDemo[ko]; float dis = ErrorVec.length(); if (dis < MinDis){ MinDis = dis; MinIndi = kt; } } TargIndTargDemo[ko] = MinIndi; } UpdateVec = TheTargetsTargDemo[TargIndTargDemo[ko]]-TheObjectsTargDemo[ko]; float newDis = UpdateVec.length(); UpdateVec.normalize(); ofVec2f acc; if (newDis < ThDis){ acc = (newDis/10.0)*(KtarTgDemo*UpdateVec) - KdamTgDemo*TheVelocitiesTargDemo[ko]; } else{ acc = (KtarTgDemo*UpdateVec) - KdamTgDemo*TheVelocitiesTargDemo[ko]; } if (TMode==0) { acc=ofVec2f(0.0, 0.0); } TheVelocitiesTargDemo[ko] = TheVelocitiesTargDemo[ko] - (-dt)*acc; TheObjectsTargDemo[ko] = TheObjectsTargDemo[ko] - (-dt)*TheVelocitiesTargDemo[ko]; } } void defense::TargetAlgorithmDraw(){ ofRectangle RectOut; RectOut = OneBigRect(); ofSetColor(0, 0, 0); // temp for video Fuentes[1].drawString("Temporal Coherence Algorithms", RectOut.x,RectOut.y + RectOut.height*.1); Fuentes[3].drawString("The Attractors Based Algorithm:", RectOut.x,RectOut.y + RectOut.height*.2); Fuentes[3].drawString("Black dots are attracted by the red stars", RectOut.x,RectOut.y + RectOut.height*.3); ofRectangle RectLimits; RectLimits.x =(RectOut.getCenter()).x - 1.4*RectOut.width/4.0; RectLimits.y=(RectOut.getCenter()).y - .8*RectOut.height/4.0; RectLimits.width=1.4*RectOut.width/2.0; RectLimits.height=1.4*RectOut.height/2.0; glPushMatrix(); ofTranslate(RectLimits.x, RectLimits.y); ofScale(RectLimits.width/Nx,RectLimits.height/Ny); // ploting the Targets ofSetColor(200, 0, 0); for (int k=0;k<NTARTargDemo;k++){ PlotStar(TheTargetsTargDemo[k].x, TheTargetsTargDemo[k].y, 5, 5,10); //ofRect(TheTargetsTargDemo[k].x -5, TheTargetsTargDemo[k].y-5,10,10); } ofSetColor(0, 0, 0); for (int k=0;k<NOBJTargDemo;k++){ ofCircle(TheObjectsTargDemo[k].x , TheObjectsTargDemo[k].y,3); } glPopMatrix(); }
48a706ef55d6690872c557e0b425fcd32b36c37a
1f52b006116e39311ab3887a04f79b9652756935
/Sorts/SelectionSort.cpp
436752e8f6bedb4222b05bcd8dc042e7aeeaa184
[]
no_license
SaurabhDhage/DSA
4c0c573d29ee654aed039de9d159cd385521d629
6bdc326983c8b83741757878a38f233b9e4adb70
refs/heads/main
2023-08-24T21:27:14.917848
2021-10-21T07:57:59
2021-10-21T07:57:59
418,953,821
0
0
null
null
null
null
UTF-8
C++
false
false
687
cpp
SelectionSort.cpp
#include<iostream> using namespace std; int main() { int i,j,min1,temp; int a[5]; cout<<"Enter Element to Sort:"<<endl; for(i=0;i<5;i++) { cin>>a[i]; //getting list } for(i=0; i<5-1; i++) //for starting element { min1=i; for(j=i+1;j<5;j++)//for smallest element in list { if(a[min1]>a[j]) { min1=j; cout<<min1; } } temp=a[i]; //swapping a[i]=a[min1]; a[min1]=temp; } cout<<"Sorted List:"; for(i=0;i<5;i++) { cout<<a[i]<<endl; //displaying list } }
15e562b7101779f520fd729cd42467b04f7eaddf
b53bd365307e1e13cd00473cc373c6ba8df1ba7f
/src/CCA/Components/Wasatch/Coal/CharOxidation/CCK/ThermalAnnealing.h
9ca5d8c14943d99cacc07980183b9fd5066cdcab
[ "MIT" ]
permissive
Uintah/Uintah
b7c55757cac1f919ac70fa5ffb1d6ea421b2069d
5678018f6d237faad6aff1c0bcc4791d6af2f61e
refs/heads/master
2023-09-01T05:27:36.000893
2023-07-27T17:18:28
2023-07-27T17:18:28
206,165,649
47
25
null
2022-10-17T19:14:44
2019-09-03T20:22:50
C++
UTF-8
C++
false
false
4,961
h
ThermalAnnealing.h
/* * The MIT License * * Copyright (c) 2015-2023 The University of Utah * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #ifndef ThermalAnnealing_Expr_h #define ThermalAnnealing_Expr_h #include <expression/Expression.h> #include "CCKData.h" #include <stdexcept> #include <sstream> namespace CCK{ /** * \class ThermalAnnealing * \author Josh McConnell * \date June 2015 * * \brief Calculates A_i/A_i0 according to eq 8 of [1]. Evaluation uses the trapezoid rule * for integration over a lognormal distribution. */ template< typename FieldT > class ThermalAnnealing : public Expr::Expression<FieldT> { DECLARE_VECTOR_OF_FIELDS( FieldT, logDist_ ) const CCKData& cckData_; ThermalAnnealing( const Expr::TagList& logFreqDistTags, const CCKData& cckData ) : Expr::Expression<FieldT>(), cckData_ ( cckData ) { this->set_gpu_runnable( true ); this->template create_field_vector_request<FieldT>( logFreqDistTags, logDist_ ); } public: class Builder : public Expr::ExpressionBuilder { public: /** * @brief Build a ThermalAnnealing expression * @param resultTag the tag for the value that this expression computes */ Builder( const Expr::Tag& resultTag, const Expr::TagList& logFreqDistTags, const CCKData& cckData, const int nghost = DEFAULT_NUMBER_OF_GHOSTS ) : ExpressionBuilder( resultTag, nghost ), logFreqDistTags_( logFreqDistTags ), cckData_ ( cckData ) {} Expr::ExpressionBase* build() const { return new ThermalAnnealing<FieldT>( logFreqDistTags_, cckData_ ); } private: const Expr::TagList logFreqDistTags_; const CCKData& cckData_; }; ~ThermalAnnealing(){}; void evaluate(); }; // ################################################################### // // Implementation // // ################################################################### //-------------------------------------------------------------------- template< typename FieldT > void ThermalAnnealing<FieldT>:: evaluate() { FieldT& result = this->value(); const CHAR::Vec edVec = cckData_.get_eD_vec(); if( logDist_.size() != edVec.size() ){ std::ostringstream msg; msg << __FILE__ << " : " << __LINE__ << std::endl << " Number oElements in logDistags does not match" << " that in vector of Activation energies" << std::endl << std::endl << " logDist_.size(): "<<logDist_.size() << " EdVec.size() : "<<edVec.size() << std::endl << std::endl; throw std::runtime_error( msg.str() ); } const FieldT& lnf_0 = logDist_[0]->field_ref(); /* Calculate the first segment of the distribution. The lower bound for * Ed is zero and f(t, Ed = 0) = 0 for all t>0; */ result <<= 0.5 * exp(lnf_0) * edVec[0]; /* Calculate the remaining segments of the distribution. using the trapezoid * rule for integration. */ for( size_t i = 0; i<logDist_.size() - 1; ++i ){ const FieldT& lnf_i = logDist_[i ]->field_ref(); const FieldT& lnf_ip1 = logDist_[i+1]->field_ref(); result <<= result + 0.5*( exp(lnf_i) + exp(lnf_ip1) ) *( edVec[i+1] - edVec[i] ); } result <<= sqrt(result); } //-------------------------------------------------------------------- }// namespace CCK #endif // ThermalAnnealing_Expr_h /* [1] Robert Hurt, Jian-Kuan Sun, and Melissa Lunden. A Kinetic Model * of Carbon Burnout in Pulverized Coal Combustion. Combustion and * Flame 113:181-197 (1998). * * [2] Randy C. Shurtz. Effects of Pressure on the Properties of Coal * Char Under Gasification Conditions at High Initial Heating Rates. * (2011). All Theses and Dissertations. Paper 2877. * http://scholarsarchive.byu.edu/etd/2877/ * */
5b6b657c2b63779d0c6ebd1eabf96c2848f221ca
9b4b0c3faa5f3002ed85c3054164e0b9fb427f56
/Codes/2200/2250.cpp
cafe730d6db955a5d6127272f632dae15dbc08ad
[]
no_license
calofmijuck/BOJ
246ae31b830d448c777878a90e1d658b7cdf27f4
4b29e0c7f487aac3186661176d2795f85f0ab21b
refs/heads/master
2023-04-27T04:47:11.205041
2023-04-17T01:53:03
2023-04-17T01:53:03
155,859,002
2
0
null
null
null
null
UTF-8
C++
false
false
1,215
cpp
2250.cpp
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; pii tree[10101], widthrange[10101]; int level[10101], width[10101]; bool hasparent[10101]; int dfs(int v, int lev, int offset) { if(v == -1) return 0; level[v] = lev; int left = dfs(tree[v].first, lev + 1, offset); width[v] = offset + left + 1; int right = dfs(tree[v].second, lev + 1, width[v]); if(widthrange[lev].first == 0) widthrange[lev].first = width[v]; if(width[v] > widthrange[lev].second) widthrange[lev].second = width[v]; return left + right + 1; } int findroot() { for(int i = 1; i <= 10101; ++i) if(!hasparent[i]) return i; } int main() { int n, v, lc, rc; scanf("%d", &n); for(int i = 0; i < n; ++i) { scanf("%d", &v); scanf("%d %d", &lc, &rc); tree[v].first = lc; tree[v].second = rc; hasparent[lc] = hasparent[rc] = true; } int root = findroot(); dfs(root, 1, 0); int maxr = 0, lev = 0; for(int i = 1; i <= n; ++i) { int r = widthrange[i].second - widthrange[i].first + 1; if(r > maxr) { maxr = r; lev = i; } } printf("%d %d", lev, maxr); return 0; }
323cae84fca8ad5ccea36191d0b031bdab0fc39d
2f17a48bda15a68d7531d79154f29d3c432a0708
/ProgrammingPupilDetection/pupil_detection.cpp
35e0b2e72f1d7534b4a4fb40f363cacac5bdb0a8
[]
no_license
Nilay27/Pupil_Detection_And_Pupil_Pose_Estimation
5ba1de3c39686a91bc619aa9e77a3011bf094cb6
1adccb864dc5b9bffecdc45a119e8d30cc7e1c97
refs/heads/master
2022-09-18T05:35:26.471644
2022-08-31T10:04:41
2022-08-31T10:04:41
129,446,348
0
0
null
null
null
null
UTF-8
C++
false
false
2,372
cpp
pupil_detection.cpp
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <cmath> #include <bits/stdc++.h> using namespace std; using namespace cv; int main(int argc, char** argv) { // Load image Mat src = imread("TestData/Real/01.jpg"); if (src.empty()) return -1; // Invert the source image and convert to grayscale Mat gray; cvtColor(src, gray, CV_BGR2GRAY); GaussianBlur( gray, gray, Size( 5, 5 ), 0, 0 ); // Convert to binary image by thresholding it Mat binary; threshold(gray, binary, 50, 255, CV_THRESH_BINARY_INV ); //erosion is applied to remove the unneccesay smaller contours that and also to ensure that there is not connected contour with the pupil erode(binary, binary, Mat(), Point(-1, -1), 5, 1, 1); //dilation is applied to regain the approximate shape of the target contour dilate(binary, binary, Mat(), Point(-1, -1), 5, 1, 1); ///imshow("binary",binary); // Find all contours vector<vector<Point> > contours; findContours(binary, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); // Fill holes in each contour drawContours(binary, contours, -1, CV_RGB(255,255,0), -1); vector<vector<Point> > approx; approx.resize(contours.size()); vector<RotatedRect> minEllipse( contours.size() ); Mat drawing(src.rows,src.cols,CV_8UC1,Scalar(0)); for( int i = 0; i < contours.size(); i++ ) { if( contours[i].size() > 100 ) { minEllipse[i] = fitEllipse( Mat(contours[i]) ); } } vector<Moments> mu(contours.size() ); vector<Moments> mc(contours.size() ); for( int i = 0; i< contours.size(); i++ ) { Mat drawing1(src.rows,src.cols,CV_8UC1,Scalar(0)); if(contours[i].size()>100) { ellipse( drawing1, minEllipse[i], Scalar( 255, 0, 0 ), -1 ); mu[i] = moments( drawing1, false ); float x,y; x=mu[i].m10/mu[i].m00; y=mu[i].m01/mu[i].m00; if(x>150 and x<550 and y>50 and y<400) { ellipse( drawing, minEllipse[i], Scalar( 255, 0, 0 ), -1 ); } //cout<<mc[i]<<endl; } //cout<<minEllipse[i]<<endl; // rotated rectangle } imshow( "Contours", drawing ); ///imshow("image", binary); imshow("original",src); imwrite("contour.png",drawing); waitKey(0); return 0; }
60a9a43dfdb34e05784d6590ac5f20d12591f160
765de512168b3145562ef6a892805751a562dc24
/Bool.h
f2628dd46216336f674971b2dd17cb4af27d5708
[]
no_license
sumsv50/Matrix-Calculator
ae71e8fcd8219934d1e285c7a5787a75e610a4c4
2a7a826d95a85eeec37e4d64135749da6e898a7c
refs/heads/master
2022-08-30T17:15:57.670455
2019-11-10T16:53:01
2019-11-10T16:53:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,700
h
Bool.h
#pragma once #ifndef Bool_h #define Bool_h #include<iostream> #include"stdlib.h" #include<string> #include<vector> using namespace std; class Tokenizer { public: // Hàm lấy ra các đơn thức static vector<string> Parse(string s, string seperator) { vector<string> tokens; int startpos = 0; // vị trí bắt đầu tìm size_t foundpos = s.find(seperator, startpos); while (foundpos != string::npos) { // vẫn còn tìm thấy int count = foundpos - startpos; string token = s.substr(startpos, count); tokens.push_back(token); //cập nhật vị trí bắt đầu tìm lại startpos = foundpos + seperator.length(); //tiếp tục tìm foundpos = s.find(seperator, startpos); } //phần sót lại chính là phần tử cuối int count = s.length() - startpos; string token = s.substr(startpos, count); tokens.push_back(token); return tokens; } }; class Bool { private: vector<vector<int>> Data; // Công thức hàm Bool ban đầu(Dạng nhị phân) vector<vector<int>> Datav2; // Lưu các tổ hợp biến/mintern không xác định (Dạng nhị phân) vector<vector<int>> cData; // Vùng dữ liệu để lưu trữ các kết quả trong quá trình tính, các tổ hợp biến bắt buộc(Dạng nhị phân) vector<vector<vector<int>>> Option; // Vùng dữ liệu lưu trữ các tổ hợp biến không bắt buộc(Dạng nhị phân) public: // Hàm nhập công thức đa thức hàm Bool(Nhập các tổ hợp biến) void Inputv1(); // Hàm nhập công thức đa thức hàm Bool(Nhập các mintern) void Inputv2(); //Hàm xuất ra các công thức đa thức tối tiểu hàm Bool void OutMin(); ~Bool(); //Hàm tìm công thức đa thức tối tiểu và in ra màn hình void MinBool(); //Hàm rút ra các công thức tối tiểu từ các tổ hợp biến không bắt buộc, trả về số công thức đã được rút int SetMin(vector<vector<int>>, vector<vector<int>> Data, int& step);//input: Các tổ hợp biến không bắt buộc(Dạng nhị phân) và hệ 10 của nó //Hàm chuyển mã nhị phân sang hệ 10 friend int He10(vector<int>); //Hàm kiểm tra xem 2 vector có khác nhau tại 1 phần tử hay không, pos dùng để giữ vị trí khác nhau friend bool other1(vector<int>, vector<int>, int& pos); //Hàm kiểm tra n có bằng phần tử nào trong vector Data không, pos dùng để giữ vị trí phần tử giống friend bool Isrepeat(int n, vector<int> Data, int& pos); //Kiểm tra xem các vetor trong vector lớn có bằng nhau hay không, tham số int& dùng để trả về số lượng vector trường hợp đặc biệt friend bool Islike(vector<vector<int>>, int&); //Kiểm tra xem 2 vector có các phần tử giống nhau hay không(các phần tử giống có thể khác vị trí) friend bool Islike(vector<vector<int>>, vector<vector<int>>); //Hàm tìm phần tử có số lượng phần tử lớn nhất friend vector<int> Posmax(vector<vector<int>>); //Hàm xuất các tổ hợp biến; friend void OutCom(vector<vector<int>>); //Hàm xóa dòng vector, nếu các phần tử cùng bậc có phần tử giống với vector line thì xóa luôn phần tử đó. //Trả về vị trí nhưng phần tử vector bị xóa(khi nó rỗng thì xóa) friend vector<int> Delline(vector<vector<int>>& v, int line); //Hàm tính tổng số vị trí được rút gọn trong vector các tổ hợp biến friend int NumShort(vector<vector<int>>); ////Hàm tính tổng số vị trí được rút gọn của 1 tổ hợp biến friend int NumShort(vector<int>); }; #endif
7b723df16979e9ffb379c264d1d8825bd25a3424
77cab51d8312710b22907c787b0357aef46a710a
/DP/CombinationSumIV.cpp
71d50680cbec1e97486290235616cbf4da8d1f12
[]
no_license
rockieCao/LeetCodeSolution
994b82bd62b29953fa888a8bdf6b8932093971a7
0a4279a78669fd0c8c56a3ea0da7452f6494f8cb
refs/heads/master
2021-01-19T02:54:36.990712
2016-09-26T15:55:43
2016-09-26T15:55:43
47,871,071
1
0
null
null
null
null
UTF-8
C++
false
false
1,729
cpp
CombinationSumIV.cpp
#include <iostream> #include <cstdlib> #include <string> #include <vector> #include <set> #include <algorithm> using namespace std; class Solution { public: vector<int> cn; int combinationSum4(vector<int>& nums, int target) { vector<int> dp(target+1, 0); dp[0]=1; sort(nums.begin(), nums.end()); for (int i = 1; i <= target; i++) { for (int x : nums) { if (x > i) break; dp[i] += dp[i - x]; } } return dp[target]; } int combinationSum4_2(vector<int>& nums, int target) { sort(nums.begin(), nums.end()); cn.push_back(1); for (int i = 1; i <= target; ++i) cn.push_back(cn.back()*i); int res = 0; vector<pair<int, int> > path; dfs2(nums, 0, target, res, path); return res; } void dfs2(vector<int> &nums, int ith, int left, int &res, vector<pair<int,int> >& path) { //RunTime Error: stack overflow //cout << ith << "," << left << endl; if (left < 0) return; if (left == 0) { //cout << "path "; long long tmp = 1LL; long long sum = 0; for (auto it : path) { sum += it.second; } tmp *= cn[sum]; for (auto it : path) { sum /= cn[it.second]; } res += sum; return; } if (ith >= nums.size()) return; if (left < nums[ith]) return; dfs2(nums, ith + 1, left, res, path); int sum = left; for (int i = 1; sum >= nums[ith]; ++i) { path.push_back(pair<int, int>(nums[ith], i)); sum -= nums[ith]; dfs2(nums, ith + 1, sum, res, path); path.pop_back(); } } static void test() { Solution sol; int x, n, target; while (cin >> n >> target) { vector<int> nums; for (int i = 0; i < n; ++i) { cin >> x; nums.push_back(x); } cout << "res=" << sol.combinationSum4(nums, target) << endl; } } };
7047127dc0048786846ae8d91022c732a396dc98
d5e10a16f1fc896209571b52185ac7a1fe831670
/Raytracer/Raytracer/src/Camera.h
885e7bd4748751022705d23d2fa4d3f527ac4ea7
[]
no_license
balakumaranpalanivel/RaytracerComputeShader
b0777b5f9363b30b5e67c9e17a0f5186bd795f8c
ef3307b91986fda2d29187369bbd935d576ad296
refs/heads/master
2021-05-15T06:08:19.583748
2018-02-15T11:31:12
2018-02-15T11:31:12
115,292,968
0
0
null
null
null
null
UTF-8
C++
false
false
3,222
h
Camera.h
#pragma once #define GLM_FORCE_RADIANS #include "glm/glm.hpp" #include "glm/gtx/rotate_vector.hpp" #include <GL/glew.h> class CCamera { public: CCamera(); CCamera(glm::vec3 pos, glm::vec3 dir, float scrWidth, float scrHeight, float fovy, float nearPlane, float farPlane); glm::mat4 getViewMatrix(); glm::mat4 getProjectionMatrix(); glm::vec3 worldToScreenCoordinates(glm::vec3 p); glm::vec3 getPosition(); glm::vec3 castRayFromScreen(double mx, double my); glm::vec3 position; glm::vec3 direction; glm::vec3 up; // assume <0,1,0> on initialization float screenWidth; float screenHeight; float getFieldOfView(); float getAspectRatio(); void set(); void unset(); void resize(float width, float height); void moveForward(float val); // move along direction vector void moveBackward(float val); void moveRight(float val); // move side to side void moveLeft(float val); void moveUp(float val); // move along up vector void moveDown(float val); void rotateRight(float rad); // rotaties about up vector void rotateLeft(float rad); void rotateUp(float rad); // rotate about right/left vector void rotateDown(float rad); void rollRight(float rad); // roll about direction vector void rollLeft(float rad); void initializeOrientation(); void setRotation(glm::mat4 rotMatrix); void setPosition(glm::vec3 pos); private: float fov; float nearDist; float farDist; }; class CCamera1 { private: float fn = 0.001f; float ff = 10.0f; float fl = -0.05f; float fr = 0.05f; float ft = 0.05f; float fb = -0.05f; bool refreshViewMatrix = true; bool refreshProjectionMatrix = true; bool refreshInverseProjectionViewMatrix = true; glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f); glm::vec3 direction = glm::vec3(0.0f, 0.0f, -1.0f); glm::vec3 up = glm::vec3(0.0f, 1.0f, 0.0f); glm::vec3 right = glm::vec3(1.0f, 0.0f, 0.0f); glm::mat4 projectionMatrix; glm::mat4 viewMatrix; glm::mat4 invViewProjectionMatrix; /** * Orthographic projection is inherently different from perspective * projection. */ bool orthographic; glm::vec3 tmp0; glm::vec3 tmp1; glm::vec3 tmp2; glm::vec4 tmp3; public: CCamera1(); void SetFrustumPerspective(float fovY, float aspect, float near, float far); void SetFrustumPerspective(float fovY, float aspect, float near, float far, int tilesX, int tilesY, int tileX, int tileY); void SetOrthographic(bool value); void SetDirection(glm::vec3 direction); void SetFrustumLeft(float left); void SetFrustumRight(float right); void SetFrustumBottom(float bottom); void SetFrustumTop(float top); void SetFrustumNear(float near); void SetFrustumFar(float far); void SetLookAt(glm::vec3 position, glm::vec3 lookAt, glm::vec3 up); void DoRefreshViewMatrix(); inline glm::vec3 GetPosition() { return position; } void SetPosition(glm::vec3 pos); inline glm::vec3 GetUp() { return up; } void SetUp(glm::vec3 pos); inline glm::vec3 GetRight() { return right; } glm::mat4 GetProjectionMatrix(); void DoRefreshProjectionMatrix(); glm::mat4 GetViewMatrix(); void DoRefreshInverseProjectionViewMatrix(); glm::mat4 GetInverseProjectionViewMatrix(); glm::vec3 GetEyeRay(float x, float y); };
cb31546c1186eae7383391bca74a3df612a5fdc1
da540288cc194baf0dc4731e6bf621d20def4a10
/7. Bridge/ShapeOut/Shape.h
1f3f66f3db4377198d76e5c90236c0178df0092f
[]
no_license
Serhiy-Boyko/Design_patterns
3df7dbe0dda3bc0cf97970c70d2b3980500ebe36
09dab45ad4990844b8364017253951c9345d3818
refs/heads/master
2021-07-15T17:07:59.570396
2020-10-19T10:17:55
2020-10-19T10:17:55
217,768,599
2
0
null
null
null
null
UTF-8
C++
false
false
912
h
Shape.h
#pragma once #include "Header.h" class Point { double x, y; public: Point(double ax, double ay) : x(ax), y(ay) {} double getx() { return x; } double gety() { return y; } std::string str() { char s[50]; sprintf(s, " x: %0.2f y: %0.2f ", x, y); return s; } }; // --------------------------------------------------------------------- class Shape { protected: std::string name; Point LeftUp; Point RightDown; public: Shape(Point LU, Point RD) : LeftUp(LU), RightDown(RD), name("Shape") {} void consoleOut(); void messageOut(); void logfileOut(); std::string getname() { return name; } std::string getKoords() { return LeftUp.str() + "\n" + RightDown.str(); } }; class Oval : public Shape { public: Oval(Point LU, Point RD) : Shape(LU, RD) { name = "Oval"; } }; class Rectangle : public Shape { public: Rectangle(Point LU, Point RD) : Shape(LU, RD) { name = "Rectangle"; } };
edfbff31f66e1d30e27b46cbc5089ae6e3fa200c
bc77d161baff2a5e2f1fbebc5d51c8322e2b69e4
/34/main.cpp
8ece09f4b547b35ac588c1313e898eb8753de683
[]
no_license
ianzapolsky/project-euler
c64a662d8dc486d405fe2c06b5c09991767509a3
736d240e5f70ab4f0df455cedbed0504c6293271
refs/heads/master
2021-01-19T07:50:51.084634
2015-03-05T21:09:09
2015-03-05T21:09:09
27,849,888
0
0
null
null
null
null
UTF-8
C++
false
false
460
cpp
main.cpp
#include <iostream> #include <string> #include <vector> int factorial(int num) { int sum = 1; while (num > 0) sum *= num--; return sum; } int main() { int result = 0; for (int i = 10; i < 2540161; i++) { int fact_sum = 0; int number = i; while (number > 0) { int d = number % 10; number /= 10; fact_sum += factorial(d); } if (fact_sum == i) { result += i; } } std::cout << result << "\n"; }
99587d51a07bb54c09c23ffb631f26f3ed6198e8
74fabd81d659b37e084721f031ce69bbeca0c8c7
/Source/Resource.cpp
a068dba169d5a38f144f2cbe6eb92a7c00bb4377
[]
no_license
Crant/Mastermind-Remake
010352afb1626947de676817d0d5e7ba2c33f106
8fab846437ef202716cad7629c38eddb9764a708
refs/heads/master
2021-01-23T15:55:50.398469
2015-04-18T13:04:17
2015-04-18T13:04:17
30,552,945
0
0
null
null
null
null
UTF-8
C++
false
false
1,907
cpp
Resource.cpp
#include "Resource.h" #include "IwResManager.h" CDECLARE_SINGLETONS(Resource) void Resource::Init() { IwGetResManager()->LoadGroup("Resources.group"); CIwResGroup* group = IwGetResManager()->GetGroupNamed("Resources"); IwGetResManager()->SetCurrentGroup(group); this->zMarble = Iw2DCreateImageResource("Marble"); this->zMarble_Selected = Iw2DCreateImageResource("marble_selected"); this->zMarbleBG = Iw2DCreateImageResource("marble_bg"); this->zHelpButton = Iw2DCreateImageResource("HelpButton"); this->zBackButton = Iw2DCreateImageResource("BackButton"); this->zCheckButton = Iw2DCreateImageResource("check"); this->zArrow = Iw2DCreateImageResource("arrow"); this->zPin = Iw2DCreateImageResource("pin"); this->zPinBG = Iw2DCreateImageResource("pin_bg"); this->zBlankButton = Iw2DCreateImageResource("Button"); this->zButtonSmall = Iw2DCreateImageResource("ButtonSmall"); this->zHelpBG = Iw2DCreateImageResource("bkg3"); this->zHighscoreBG = Iw2DCreateImageResource("bkg2"); this->zGameBG = Iw2DCreateImageResource("bkg1"); this->zBG = Iw2DCreateImageResource("bkg"); // Load fonts this->zFontNormal = Iw2DCreateFontResource("arial10"); this->zFontBold = Iw2DCreateFontResource("arial10_bold"); this->zFontLarge = Iw2DCreateFontResource("arial14"); } void Resource::Release() { SAFE_DELETE(this->zPin); SAFE_DELETE(this->zPinBG); SAFE_DELETE(this->zArrow); SAFE_DELETE(this->zBG); SAFE_DELETE(this->zHelpBG); SAFE_DELETE(this->zGameBG); SAFE_DELETE(this->zHighscoreBG); SAFE_DELETE(this->zMarble); SAFE_DELETE(this->zMarbleBG); SAFE_DELETE(this->zMarble_Selected); SAFE_DELETE(this->zHelpButton); SAFE_DELETE(this->zBackButton); SAFE_DELETE(this->zCheckButton); SAFE_DELETE(this->zBlankButton); SAFE_DELETE(this->zButtonSmall); SAFE_DELETE(this->zFontBold); SAFE_DELETE(this->zFontLarge); SAFE_DELETE(this->zFontNormal); }
f0f740950e3864ebdd0df4fc50418e55894c8f9f
a0cd9f1059684285faa248c875aa4bd1e58a854d
/자료구조/솔루션 및 과제/Lab06-HeterogeneousLists-solution/DS-Lab06-HeterogeneousLists-solution (Ver. Console)/DiffTypeDLinkInherit.cpp
2f36db0276a2531e3c53b242cd1ee12a4101ee94
[]
no_license
Flare-k/Programming
f169e691fc2bde3c1478c5b9adcbc27d84e1cc9d
50dfa4c5f375a59790cc2f4a96b358ba8bfc073d
refs/heads/master
2020-06-14T16:30:56.759063
2019-11-18T18:12:00
2019-11-18T18:12:00
195,055,125
0
1
null
null
null
null
UHC
C++
false
false
6,053
cpp
DiffTypeDLinkInherit.cpp
#include "DiffTypeDLinkInherit.h" //////////////////////////////////////////////////////////////////////////////////// // BaseNode의 member function /////////////////////////////////////////////////////////////////////////////////// //<<수정>> BaseNode::BaseNode() { rlink = 0; llink = 0; } //////////////////////////////////////////////////////////////////////////////////// // List member function //////////////////////////////////////////////////////////////////////////////////// List::List() { first = new RectangleNode(); first->rlink = first->llink = first; //자신을 가리키는 doubly linked로 만듬 } // List에 연결된 모든 노드의 메모리를 해제시킨다. List::~List() { DeleteAllNode(); delete first; } // List에 연결된 모든 노드의 메모리를 해제시킨다. void List::DeleteAllNode() { BaseNode *tmp, *p; for(p = first->rlink; p != first; ) { tmp = p; p = p->rlink; delete tmp; } first->llink = first->rlink = first; // empty list로 만듬 } // list 뒤에 newNode를 추가 void List::Attach(BaseNode *newNode) { BaseNode *lastNode = first->llink; // lastNode newNode->llink = lastNode; newNode->rlink = first; lastNode->rlink = newNode; first->llink = newNode; } //?? 과제, assignment // 모든 primitive를 draw 한다. void List::drawAll() { // this포인터를 넘겨서 iterator 객체를 하나 선언한다. // iterator를 이용하여 작성하라. ListIterator iterator(*this); while (iterator.NotHeader()) { iterator.current->display(); iterator.Next(); } } /////////////////////////////////////////////////////////////////////////////////////// //=================ListIterator Member Function ======================== /////////////////////////////////////////////////////////////////////////////////////// // list의 현재 원소가 Header가 아닌지 검사 Boolean ListIterator::NotHeader() { if(current != list.first) //header가 아닌지 확인 return TRUE; else return FALSE; } // current 자료를 리턴하고 current 포인터를 오른쪽으로 이동 BaseNode* ListIterator:: Next() { current = current->rlink; return current->llink; } //?? 과제 : 변수 초기화 하시오. //?? assignment : define creator. intialize a variables // 하나의 원과 attribute를 정의 // deife a circle and attribute CircleNode::CircleNode(Point center,Point boundary,int attrib) { this->center = center; this->boundary = boundary; this->curNum = attrib; } CircleNode::~CircleNode() { } //?? 과제 : 원 노드의 정보를 출력하시오. //?? assignment : print out the circle information on the screen. void CircleNode:: display() { cout << "원 노드의 정보를 출력합니다." << endl; cout << "center좌표 : " << "(" << center.x << ", " << center.y << ")" << endl; cout << "boundary좌표 : " << "(" << boundary.x << ", " << boundary.y << ")" << endl; cout << "curNum : " << this->curNum << endl; } //?? 과제 : 원노드에서 필요한 중심점과 경계점을 입력 받아 저장하시오. //?? assignment : input the two point defining a circle from keyboard void CircleNode:: draw() { cout << "원의 중심점의 x좌표값과 y좌표값을 입력하세요 : " << endl; cout << "x좌표값 : "; cin >> center.x; cout << "y좌표값 : "; cin >> center.y; cout << "원의 경계점의 x좌표값과 y좌표값을 입력하세요 : " << endl; cout << "x좌표값 : "; cin >> boundary.x; cout << "y좌표값 : "; cin >> boundary.y; } //?? 과제 //?? assignment : intialize a rectangle object RectangleNode::RectangleNode(Point start, Point end,int attrib) // rectangle을 정의 { this->start = start; this->end = end; this->curNum = attrib; } RectangleNode::~RectangleNode() { } //?? 과제 //?? assignment : display the two points defining the current rectangle void RectangleNode:: display() { cout << "직사각형 노드의 정보를 출력합니다." << endl; cout << "start좌표 : " << "(" << start.x << ", " << start.y << ")" << endl; cout << "end좌표 : " << "(" << end.x << ", " << end.y << ")" << endl; cout << "curNum : " << this->curNum << endl; } //?? 과제 //?? assignment : read in the two points definding a rectagnle void RectangleNode:: draw() { cout << "직사각형의 중심점의 x좌표값과 y좌표값을 입력하세요 : " << endl; cout << "x좌표값 : "; cin >> start.x; cout << "y좌표값 : "; cin >> start.y; cout << "원의 경계점의 x좌표값과 y좌표값을 입력하세요 : " << endl; cout << "x좌표값 : "; cin >> end.x; cout << "y좌표값 : "; cin >> end.y; } PolygonNode::PolygonNode(Point vert[], int NumOfP,int attrib) { if (NumOfP < MAXPOINTS) NumOfPoints = NumOfP; else NumOfPoints = MAXPOINTS - 1; attribute = attrib; for (int i = 0; i < NumOfPoints; i++) vertex[i] = vert[i]; } void PolygonNode:: display() { cout<<"<< Polygon >>\n"; for (int i = 0; i < NumOfPoints; i++) cout << " Vertex " << i << " : ( " << vertex[i] << " )\n"; cout << endl; } //?? 과제 : 폴리곤 노드에서 점을 추가하는 함수를 작성하시오. //?? assignment : write a function adding a point to the polygon object. Boolean PolygonNode:: AddPoints(Point t) { if (NumOfPoints < MAXPOINTS) { vertex[NumOfPoints].Init(t.x, t.y); return TRUE; } else { cout << "더 이상 점을 추가할 수 없습니다." << endl; return FALSE; } } //?? 과제 :폴리곤노드 에서 필요한 정보를 입력 받는 함수를 작성하시오. //?? assignment : display the points defining the current polygon void PolygonNode:: draw() { cout << "다각형을 이루는 점의 x좌표값과 y좌표값을 입력하세요 : " << endl; cout << "x좌표값 : "; cin >> vertex[NumOfPoints].x; cout << "y좌표값 : "; cin >> vertex[NumOfPoints].y; }
adf5e5c7b3d1ab746b4d789480f35763579aadbe
07c49de6b02000f53d944926a3c3e02131b5979a
/coding/parallelPhylo/util/mutationMap.h
fd53fb397a1eecea62d1ce745a6abadf5eb48bdb
[]
no_license
terryschhoracverni/Phylogenetic_comps
76acc110551ce80ed12f157f88525f846e884d47
4b9341819ec106be8f6f81e9ffdd097582650fbd
refs/heads/master
2023-03-15T19:10:57.334838
2014-12-29T03:55:41
2014-12-29T03:55:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
447
h
mutationMap.h
//mutationMap.h //This file constructs a 2 layer map to hold the conversion rates for each nucleic acid. #ifndef MUTMAP #define MUTMAP #include <map> using namespace std; class MutationMap { public: //constructor MutationMap(); //mutation maps map<char,float> adenineRates; map<char,float> thymineRates; map<char,float> guanineRates; map<char,float> cytosineRates; map<char,map<char,float> > mutationRates; }; #endif
83e71c2f82d6d9988ba8a01ae1aa56995a2981c6
2c32342156c0bb00e3e1d1f2232935206283fd88
/tech/libsrc/namedres/Start/defstfct.cpp
e6e48ed83088ab91c46934b3227677a507ddc0ed
[]
no_license
infernuslord/DarkEngine
537bed13fc601cd5a76d1a313ab4d43bb06a5249
c8542d03825bc650bfd6944dc03da5b793c92c19
refs/heads/master
2021-07-15T02:56:19.428497
2017-10-20T19:37:57
2017-10-20T19:37:57
106,126,039
7
2
null
null
null
null
UTF-8
C++
false
false
4,559
cpp
defstfct.cpp
//Empty file #include <windows.h> #include <lg.h> #include <comtools.h> //----- (008EF0F0) -------------------------------------------------------- int __stdcall cDefaultStorageFactory::QueryInterface(cDefaultStorageFactory *this, _GUID *id, void **ppI) { int result; // eax@5 if (id != &IID_IStoreFactory && id != &IID_IUnknown && memcmp(id, &IID_IStoreFactory, 0x10u) && memcmp(id, &IID_IUnknown, 0x10u)) { *ppI = 0; result = -2147467262; } else { *ppI = this; this->baseclass_0.baseclass_0.vfptr->AddRef((IUnknown *)this); result = 0; } return result; } //----- (008EF15D) -------------------------------------------------------- unsigned int __stdcall cDefaultStorageFactory::AddRef(cDefaultStorageFactory *this) { return cDefaultStorageFactory::cRefCount::AddRef(&this->__m_ulRefs); } //----- (008EF16F) -------------------------------------------------------- unsigned int __stdcall cDefaultStorageFactory::Release(cDefaultStorageFactory *this) { unsigned int result; // eax@2 if (cDefaultStorageFactory::cRefCount::Release(&this->__m_ulRefs)) { result = cDefaultStorageFactory::cRefCount::operator unsigned_long(&this->__m_ulRefs); } else { cDefaultStorageFactory::OnFinalRelease(this); result = 0; } return result; } //----- (008EF19C) -------------------------------------------------------- void __stdcall cDefaultStorageFactory::EnumerateTypes(cDefaultStorageFactory *this, void(__cdecl *__formal)(const char *, IStoreFactory *, void *), void *a3) { ; } //----- (008EF1A3) -------------------------------------------------------- IStore *__stdcall cDefaultStorageFactory::CreateStore(cDefaultStorageFactory *this, IStore *pParent, const char *pName, const char *pExt) { void *v4; // eax@4 int v6; // eax@10 void *v7; // [sp+0h] [bp-1Ch]@4 void *v8; // [sp+4h] [bp-18h]@3 int pDataStream; // [sp+8h] [bp-14h]@11 signed int needsData; // [sp+Ch] [bp-10h]@2 void *pHier; // [sp+10h] [bp-Ch]@13 void *pParentHier; // [sp+14h] [bp-8h]@8 IStore *pStore; // [sp+18h] [bp-4h]@6 if (strcmp(pExt, "zip")) { v8 = j__new(0x2Cu, "x:\\prj\\tech\\libsrc\\namedres\\defstfct.cpp", 42); if (v8) { cDirectoryStorage::cDirectoryStorage((cDirectoryStorage *)v8, pName); v7 = v4; } else { v7 = 0; } pStore = (IStore *)v7; needsData = 0; } else { needsData = 1; } if (pParent) { if (pParent->baseclass_0.vfptr->QueryInterface((IUnknown *)pParent, &IID_IStoreHierarchy, &pParentHier) < 0) { _CriticalMsg("Couldn't QI a StoreHierarchy!", "x:\\prj\\tech\\libsrc\\namedres\\defstfct.cpp", 0x33u); pStore->baseclass_0.vfptr->Release((IUnknown *)pStore); return 0; } v6 = ((int(__stdcall *)(IStore *))pStore->baseclass_0.vfptr[1].QueryInterface)(pStore); (*(void(__stdcall **)(void *, IStore *, int))(*(_DWORD *)pParentHier + 16))(pParentHier, pStore, v6); (*(void(__stdcall **)(void *))(*(_DWORD *)pParentHier + 8))(pParentHier); if (needsData) { pDataStream = pParent->baseclass_0.vfptr[4].QueryInterface((IUnknown *)pParent, (_GUID *)pName, 0); if (!pDataStream) { pStore->baseclass_0.vfptr->Release((IUnknown *)pStore); return 0; } if (pStore->baseclass_0.vfptr->QueryInterface((IUnknown *)pStore, &IID_IStoreHierarchy, &pHier) < 0) { _CriticalMsg("Couldn't QI a StoreHierarchy!", "x:\\prj\\tech\\libsrc\\namedres\\defstfct.cpp", 0x44u); pStore->baseclass_0.vfptr->Release((IUnknown *)pStore); return 0; } (*(void(__stdcall **)(void *, int))(*(_DWORD *)pHier + 24))(pHier, pDataStream); (*(void(__stdcall **)(int))(*(_DWORD *)pDataStream + 8))(pDataStream); (*(void(__stdcall **)(void *))(*(_DWORD *)pHier + 8))(pHier); } } return pStore; } //----- (008EF320) -------------------------------------------------------- unsigned int __thiscall cDefaultStorageFactory::cRefCount::AddRef(cDefaultStorageFactory::cRefCount *this) { ++this->ul; return this->ul; } //----- (008EF340) -------------------------------------------------------- unsigned int __thiscall cDefaultStorageFactory::cRefCount::Release(cDefaultStorageFactory::cRefCount *this) { --this->ul; return this->ul; } //----- (008EF360) -------------------------------------------------------- unsigned int __thiscall cDefaultStorageFactory::cRefCount::operator unsigned_long(cDefaultStorageFactory::cRefCount *this) { return this->ul; } //----- (008EF370) -------------------------------------------------------- void __thiscall cDefaultStorageFactory::OnFinalRelease(cDefaultStorageFactory *this) { operator delete(this); }
5b3b2f6876e992305054b2dd412d13eb363e29d6
401aa02f1b23d451c856e038bb71b91baec13eb4
/NeoMathEngine/src/GPU/Vulkan/VulkanDll.cpp
5454cdd5401ffa3a689b8296505ac84d05084f89
[ "Apache-2.0", "NCSA", "BSD-3-Clause", "LLVM-exception", "LicenseRef-scancode-generic-cla", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-protobuf", "LicenseRef-scancode-arm-llvm-sga", "MIT", "Intel" ]
permissive
neoml-lib/neoml
fb189a74e0ce1474fdbe8c01d73fcb08d28d601c
b77ff503c8838d904f8db5f482eafb41de61c794
refs/heads/master
2023-08-18T13:28:19.727210
2023-08-17T12:49:49
2023-08-17T12:49:49
272,252,323
788
141
Apache-2.0
2023-09-14T11:59:19
2020-06-14T17:37:36
C++
UTF-8
C++
false
false
11,368
cpp
VulkanDll.cpp
/* Copyright © 2017-2020 ABBYY Production LLC 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 <common.h> #pragma hdrstop #include <NeoMathEngine/NeoMathEngineDefs.h> #ifdef NEOML_USE_VULKAN #include <NeoMathEngine/CrtAllocatedObject.h> #include <VulkanDll.h> #include <string> #include <memory> using namespace std; namespace NeoML { #define LOAD_VULKAN_FUNC_PROC_NAME(Type, Name, NameStr) if((Name = CDll::GetProcAddress<Type>(NameStr)) == 0) return false #define LOAD_VULKAN_FUNC_PROC(Name) LOAD_VULKAN_FUNC_PROC_NAME(PFN_##Name, Name, #Name) #define LOAD_VULKAN_INSTANCE_FUNC_PROC_NAME(Type, Name, NameStr) \ if((Name = (Type)vkGetInstanceProcAddr(instance, NameStr)) == 0) return false #define LOAD_VULKAN_INSTANCE_FUNC_PROC(Name) LOAD_VULKAN_INSTANCE_FUNC_PROC_NAME(PFN_##Name, Name, #Name) #if FINE_PLATFORM(FINE_WINDOWS) static const char* VulkanDllName = "vulkan-1.dll"; #elif FINE_PLATFORM(FINE_ANDROID) || FINE_PLATFORM(FINE_LINUX) static const char* VulkanDllName = "libvulkan.so"; #else #error Platform not supported! #endif //------------------------------------------------------------------------------------------------------------ static VkApplicationInfo applicationInfo = { VK_STRUCTURE_TYPE_APPLICATION_INFO, 0, "NeoMachineLearning", VK_MAKE_VERSION(1, 0, 0), "NeoMathEngine", VK_MAKE_VERSION(1, 0, 0), VK_API_VERSION_1_0 }; static VkInstanceCreateInfo instanceCreateInfo = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, 0, 0, &applicationInfo, 0, 0, 0, 0 }; //------------------------------------------------------------------------------------------------------------ typedef basic_string<char, char_traits<char>, CrtAllocator<char> > fstring; // Gets the vulkan device type static TVulkanDeviceType defineDeviceType( const VkPhysicalDeviceProperties& props ) { fstring name( (const char*)props.deviceName ); std::transform( name.begin(), name.end(), name.begin(), ::tolower ); // Mali const char* MaliName = "mali"; size_t pos = name.find( MaliName ); if( pos != std::string::npos ) { size_t curPos = pos + strlen(MaliName); while( curPos < name.length() && !isalpha(name[curPos]) && !isdigit(name[curPos]) ) { ++curPos; } if( curPos < name.length() && ( isdigit(name[curPos]) || name[curPos] == 't' ) ) { // Mali old version return VDT_Undefined; } else { // Mali new version return VDT_MaliBifrost; } return VDT_Regular; } // Adreno const char* AdrenoName = "adreno"; pos = name.find( AdrenoName ); if( pos != std::string::npos ) { return VDT_Adreno; } pos = name.find( "geforce" ); if (pos != std::string::npos) { return VDT_Nvidia; } if(name.find( "intel" ) != std::string::npos ) { return VDT_Intel; } return VDT_Regular; } //------------------------------------------------------------------------------------------------------------ CVulkanDll::CVulkanDll() : instance( VK_NULL_HANDLE ), vkGetInstanceProcAddr( nullptr ), vkGetDeviceProcAddr( nullptr ), vkCreateInstance( nullptr ), vkDestroyInstance( nullptr ), vkEnumeratePhysicalDevices( nullptr ), vkGetPhysicalDeviceProperties( nullptr ), vkGetPhysicalDeviceQueueFamilyProperties( nullptr ), vkGetPhysicalDeviceMemoryProperties( nullptr ), vkCreateDevice( nullptr ) { } CVulkanDll::~CVulkanDll() { Free(); } bool CVulkanDll::Load() { if( IsLoaded() ) { return true; } if( !CDll::Load( VulkanDllName ) ) { return false; } if( !loadFunctions() ) { CDll::Free(); return false; } if( !enumDevices() ) { vkDestroyInstance( instance, 0 ); instance = VK_NULL_HANDLE; CDll::Free(); return false; } return true; } const CVulkanDevice* CVulkanDll::CreateDevice( const CVulkanDeviceInfo& info ) const { VkDeviceQueueCreateInfo queueInfo = {}; queueInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; queueInfo.queueFamilyIndex = info.Family; queueInfo.queueCount = 1; queueInfo.flags = 0; float priority = 1; queueInfo.pQueuePriorities = &priority; VkPhysicalDeviceFeatures features = {}; // no special features needed VkDeviceCreateInfo deviceInfo = {}; deviceInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; deviceInfo.pQueueCreateInfos = &queueInfo; deviceInfo.queueCreateInfoCount = 1; deviceInfo.pEnabledFeatures = &features; VkDevice handle; if( vkCreateDevice(info.PhysicalDevice, &deviceInfo, 0, &handle) != VK_SUCCESS ) { return nullptr; } std::unique_ptr<CVulkanDevice> result( new CVulkanDevice( handle, info ) ); #define LOAD_VULKAN_DEVICE_FUNC_PROC_NAME(Type, Name, NameStr) \ if((result->Name = (Type)vkGetDeviceProcAddr(result->device, NameStr)) == 0) return nullptr #define LOAD_VULKAN_DEVICE_FUNC_PROC(Name) LOAD_VULKAN_DEVICE_FUNC_PROC_NAME(PFN_##Name, Name, #Name) #define LOAD_VULKAN_DEVICE_FUNC_PROC_NAME1(Type, Name, NameStr) \ Type _##Name = (Type)vkGetDeviceProcAddr(result->device, NameStr); \ if((_##Name) == nullptr) return nullptr; \ result->Name = {result->device, _##Name}; #define LOAD_VULKAN_DEVICE_FUNC_PROC1(Name) LOAD_VULKAN_DEVICE_FUNC_PROC_NAME1(PFN_##Name, Name, #Name) // Load functions LOAD_VULKAN_DEVICE_FUNC_PROC(vkDestroyDevice); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkGetDeviceQueue); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateBuffer); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateImage); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateImageView); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateSampler); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyBuffer); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyImage); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyImageView); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroySampler); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkGetBufferMemoryRequirements); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkGetImageMemoryRequirements); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkAllocateMemory); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkFreeMemory); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkBindBufferMemory); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkBindImageMemory); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateCommandPool); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyCommandPool); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateComputePipelines); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyPipeline); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkAllocateCommandBuffers); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkFreeCommandBuffers); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateFence); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyFence); LOAD_VULKAN_DEVICE_FUNC_PROC(vkBeginCommandBuffer); LOAD_VULKAN_DEVICE_FUNC_PROC(vkEndCommandBuffer); LOAD_VULKAN_DEVICE_FUNC_PROC(vkQueueSubmit); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkWaitForFences); LOAD_VULKAN_DEVICE_FUNC_PROC(vkCmdCopyBuffer); LOAD_VULKAN_DEVICE_FUNC_PROC(vkCmdPipelineBarrier); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkResetFences); LOAD_VULKAN_DEVICE_FUNC_PROC(vkCmdUpdateBuffer); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkMapMemory); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkUnmapMemory); LOAD_VULKAN_DEVICE_FUNC_PROC(vkCmdFillBuffer); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateDescriptorPool); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyDescriptorPool); LOAD_VULKAN_DEVICE_FUNC_PROC(vkCmdBindPipeline); LOAD_VULKAN_DEVICE_FUNC_PROC(vkCmdBindDescriptorSets); LOAD_VULKAN_DEVICE_FUNC_PROC(vkCmdDispatch); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkAllocateDescriptorSets); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkFreeDescriptorSets); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateDescriptorSetLayout); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyDescriptorSetLayout); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkUpdateDescriptorSets); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreatePipelineLayout); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyPipelineLayout); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkCreateShaderModule); LOAD_VULKAN_DEVICE_FUNC_PROC1(vkDestroyShaderModule); LOAD_VULKAN_DEVICE_FUNC_PROC(vkCmdPushConstants); LOAD_VULKAN_DEVICE_FUNC_PROC(vkQueueWaitIdle); return result.release(); } void CVulkanDll::Free() { if( IsLoaded() ) { devices.clear(); devices.shrink_to_fit(); if( vkDestroyInstance != nullptr ) { vkDestroyInstance( instance, 0 ); } instance = VK_NULL_HANDLE; CDll::Free(); } } // Loads all necessary functions bool CVulkanDll::loadFunctions() { LOAD_VULKAN_FUNC_PROC(vkGetInstanceProcAddr); LOAD_VULKAN_FUNC_PROC(vkGetDeviceProcAddr); LOAD_VULKAN_INSTANCE_FUNC_PROC(vkCreateInstance); if( vkCreateInstance( &instanceCreateInfo, 0, &instance ) == VK_SUCCESS ) { LOAD_VULKAN_INSTANCE_FUNC_PROC(vkDestroyInstance); return true; } return false; } // Gets the information about available devices bool CVulkanDll::enumDevices() { LOAD_VULKAN_INSTANCE_FUNC_PROC(vkEnumeratePhysicalDevices); LOAD_VULKAN_INSTANCE_FUNC_PROC(vkGetPhysicalDeviceProperties); LOAD_VULKAN_INSTANCE_FUNC_PROC(vkGetPhysicalDeviceQueueFamilyProperties); LOAD_VULKAN_INSTANCE_FUNC_PROC(vkGetPhysicalDeviceMemoryProperties); LOAD_VULKAN_INSTANCE_FUNC_PROC(vkCreateDevice); uint32_t devCount = 0; if( vkEnumeratePhysicalDevices( instance, &devCount, 0 ) != VK_SUCCESS ) { return false; } std::vector< VkPhysicalDevice, CrtAllocator<VkPhysicalDevice> > physicalDevices; physicalDevices.resize( devCount ); if( vkEnumeratePhysicalDevices( instance, &devCount, physicalDevices.data() ) != VK_SUCCESS ) { return false; } for( int i = 0; i < static_cast<int>( devCount ); i++ ) { VkPhysicalDeviceProperties props = {}; vkGetPhysicalDeviceProperties( physicalDevices[i], &props ); // Look for a suitable queue family uint32_t familyCount = 0; vkGetPhysicalDeviceQueueFamilyProperties( physicalDevices[i], &familyCount, 0 ); std::vector< VkQueueFamilyProperties, CrtAllocator<VkQueueFamilyProperties> > families; families.resize( familyCount ); vkGetPhysicalDeviceQueueFamilyProperties( physicalDevices[i], &familyCount, families.data() ); for( int familyNum = 0; familyNum < static_cast<int>( families.size() ); ++familyNum ) { if( families[familyNum].queueCount != 0 && ( families[familyNum].queueFlags & VK_QUEUE_COMPUTE_BIT ) != 0 && defineDeviceType( props ) != VDT_Undefined ) { TVulkanDeviceType deviceType = defineDeviceType( props ); if( deviceType != VDT_Undefined ) { CVulkanDeviceInfo info; info.Type = deviceType; info.PhysicalDevice = physicalDevices[i]; info.DeviceID = static_cast<int>( devices.size() ); info.Family = familyNum; info.AvailableMemory = 0; info.Properties = props; vkGetPhysicalDeviceMemoryProperties( physicalDevices[i], &info.MemoryProperties ); for( int h = 0; h < static_cast<int>( info.MemoryProperties.memoryHeapCount ); ++h ) { if( ( info.MemoryProperties.memoryHeaps[h].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT ) != 0 ) { info.AvailableMemory += static_cast<size_t>( info.MemoryProperties.memoryHeaps[h].size ); } } devices.push_back( info ); break; } } } } return true; } } // namespace NeoML #endif // NEOML_USE_VULKAN
ff932e632f71c6a7fc29e29efc70146b177e3cbe
e66134519c2a71a5b26c000646977b278a6b1fd5
/integration/cocos2d-x-v2/src/bee/acme/Color.h
178037302bc551192045be346d5d03ebe465fa6f
[ "Apache-2.0" ]
permissive
gelldur/Bee
17f307a6e6ea80bc0ce66a9a007ccf1e5237a45b
a126d4f6254f1b367e5c1bed2677d9c8b0924072
refs/heads/master
2021-05-04T18:42:50.783589
2018-01-05T16:21:32
2018-01-05T16:21:32
106,039,815
0
1
null
null
null
null
UTF-8
C++
false
false
2,085
h
Color.h
// // Created by Dawid Drozd aka Gelldur on 10.10.17. // // Source from: https://github.com/gelldur/common-cpp #pragma once namespace Acme { namespace Color { /*** * Color format is AARRGGBB in hex * eg. red = 0xffff0000 * eg. green = 0xff00ff00 * eg. blue = 0xff0000ff */ namespace ARGB { /** * @param color format is AARRGGBB * @return RR */ inline unsigned char getRed(const int colorARGB) { return static_cast<unsigned char>((colorARGB & 0xFF0000) >> 16); } /** * @param color format is AARRGGBB * @return GG */ inline unsigned char getGreen(const int colorARGB) { return static_cast<unsigned char>((colorARGB & 0x00FF00) >> 8); } /** * @param color format is AARRGGBB * @return BB */ inline unsigned char getBlue(const int colorARGB) { return static_cast<unsigned char>(colorARGB & 0x0000FF); } /** * @param color format is AARRGGBB * @return AA */ inline unsigned char getAlpha(const int colorARGB) { return static_cast<unsigned char>((colorARGB & 0xFF000000) >> 24); } inline int setAlpha(const int colorARGB, unsigned char alpha) { return (colorARGB & 0x00FFFFFF) | (alpha << 24); } } } } namespace Bee { namespace Color { inline cocos2d::ccColor3B convertTo3B(const int color) { cocos2d::ccColor3B converted; converted.r = Acme::Color::ARGB::getRed(color); converted.g = Acme::Color::ARGB::getGreen(color); converted.b = Acme::Color::ARGB::getBlue(color); return converted; } inline cocos2d::ccColor4F convertTo4F(const int color) { cocos2d::ccColor4F converted; converted.r = Acme::Color::ARGB::getRed(color) / 255.F; converted.g = Acme::Color::ARGB::getGreen(color) / 255.F; converted.b = Acme::Color::ARGB::getBlue(color) / 255.F; converted.a = Acme::Color::ARGB::getAlpha(color) / 255.F; return converted; } inline cocos2d::ccColor4B convertTo4B(const int color) { cocos2d::ccColor4B converted; converted.r = Acme::Color::ARGB::getRed(color); converted.g = Acme::Color::ARGB::getGreen(color); converted.b = Acme::Color::ARGB::getBlue(color); converted.a = Acme::Color::ARGB::getAlpha(color); return converted; } } }
4d2194028f07fae1a2d0b5f24b5f0083360cbad4
ff1f8e352bcbf059e2c1c0aaafff120c56f3cf49
/SOJ/SOJ641/sanae.h
4c72b8e0eb16e2814ead5a68b6fce947f3d760db
[]
no_license
keywet06/code
040bc189fbabd06fc3026525ae3553cd4f395bf3
fe0d570144e580f37281b13fd4106438d3169ab9
refs/heads/master
2022-12-19T12:12:16.635994
2022-11-27T11:39:29
2022-11-27T11:39:29
182,518,309
6
1
null
null
null
null
UTF-8
C++
false
false
143
h
sanae.h
#ifndef __SANAE_HEADER_INCLUDED__ #define __SANAE_HEADER_INCLUDED__ #include <vector> int query(int i); std::vector<int> solve(int n); #endif
703927dc7ff2ab12865cf7a7d6725e555faee38f
e7209a5cb12250ae052ca882a3570c874b4c7dcf
/src/EditorRuntime/Extensions/Property/PropertyOperation.h
3b1462d0315217c41cd7a339cb6c94ed91512717
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
akumetsuv/flood
3af52fc3934c289f72b4ca7828b90ce3a054dcda
e0d6647df9b7fac72443a0f65c0003b0ead7ed3a
refs/heads/master
2020-12-25T10:50:21.301224
2013-03-24T06:05:56
2013-03-24T06:05:56
8,084,980
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
847
h
PropertyOperation.h
/************************************************************************ * * Flood Project © (2008-201x) * Licensed under the simplified BSD license. All rights reserved. * ************************************************************************/ #pragma once #include "UndoOperation.h" #include "PropertyPage.h" #ifdef ENABLE_PLUGIN_PROPERTY NAMESPACE_EDITOR_BEGIN //-----------------------------------// REFLECT_DECLARE_CLASS(PropertyOperation) class PropertyOperation : public UndoOperation { REFLECT_DECLARE_OBJECT(PropertyOperation) public: Class* type; Field* field; void* object; wxAny oldValue; wxAny newValue; PropertyPage* grid; void undo(); void redo(); void setFieldValue(const wxAny& value); }; //-----------------------------------// NAMESPACE_EDITOR_END #endif
2c36899e3354cb4f89147ce26d7aa91ee644548b
62cdbad0da52d4777732e60099eeac3a82ab963e
/Remote-PC-Monitoring-Tool/server/NativeLoader.hpp
9ce5db0a2a0bb503ce9b7e953e1b00a6e50e6b81
[ "MIT" ]
permissive
profezzional/Remote-PC-Monitoring-Tool
34edf31ae7ef1f6b08e20fa7c547d5c9583e5c9f
1c583edbeb6b9844f12979e4dfe121f4aa97a5a9
refs/heads/master
2022-12-17T02:55:48.124807
2020-09-20T09:39:18
2020-09-20T09:39:18
282,722,650
8
1
MIT
2020-09-20T08:32:58
2020-07-26T19:53:29
C++
UTF-8
C++
false
false
995
hpp
NativeLoader.hpp
#pragma once #include "target.hpp" // todo: add native dll/sl loader depending on arch #include <functional> #include <filesystem> #include <string> #include <string_view> #ifdef TARGET_WINDOWS #include <Windows.h> #define EXTENSION ".dll" #endif #ifdef TARGET_UNIX #include <dlfcn.h> #define EXTENSION ".so" #endif class NativeLoader { #ifdef TARGET_WINDOWS HMODULE hModule = NULL; #endif #ifdef TARGET_UNIX void* hModule = nullptr; #endif public: NativeLoader(const std::string& moduleName) { #ifdef TARGET_WINDOWS this->hModule = LoadLibraryA(std::string(moduleName + EXTENSION).c_str()); #endif #ifdef TARGET_UNIX this->hModule = dlopen(std::string(moduleName + EXTENSION).c_str(), RTLD_GLOBAL); #endif } void* getFunctionAddress(std::string_view functionName) { #ifdef TARGET_WINDOWS return GetProcAddress(this->hModule, functionName.data()); #endif #ifdef TARGET_UNIX return dlsym(this->hModule, functionName.data()); #endif } }; #undef EXTENSION
dd783da761adf0d579efc3ce9b324a77d810cc5f
191e4ebe408563445e966313a26e9a069e8d90b2
/src/views/voicetotextedit.cpp
0371fd4c6ed3f86f9add2ee5d4e96db60180f557
[]
no_license
martyr-deepin/deepin-voice-note-old
8368979b94ecdc7184be8653766b590e36d2ca4f
5e8d7cf633285d635075393c2f4f6417c649de51
refs/heads/master
2022-11-12T04:20:30.403883
2020-06-28T20:00:53
2020-07-09T06:31:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,510
cpp
voicetotextedit.cpp
#include "voicetotextedit.h" #include "uiutil.h" #include "intancer.h" #include <QDebug> VoiceToTextEdit::VoiceToTextEdit(QWidget *parent) : DTextEdit(parent) { initConnection(); } QString VoiceToTextEdit::getText() { QString tmp = this->toPlainText(); return tmp; } void VoiceToTextEdit::setTextAndLineheight(QString str) { this->setText(str); //this->setText(UiUtil::getHtmlText(str, 12, "", BLUE)); this->setLineHeight(24); } int VoiceToTextEdit::getLineHeight() { int documentHeight = 0; // QTimer::singleShot(0, this, [=]{ // documentHeight = static_cast<int>(this->document()->size().height()); // qDebug()<<"documentHeight:"<<documentHeight; // }); // documentHeight = static_cast<int>(this->document()->size().height()); // qDebug()<<"documentHeight_2:"<<documentHeight; return documentHeight; } void VoiceToTextEdit::textAreaChanged() { QTimer::singleShot(0, this, [=]{ int documentHeight = static_cast<int>(this->document()->size().height()); emit sigTextHeightChanged(documentHeight); qDebug()<<"documentHeight:"<<documentHeight; }); // QTextDocument *document=qobject_cast<QTextDocument*>(sender()); // if(document){ // QTextEdit *editor=qobject_cast<QTextEdit*>(document->parent()->parent()); // if (editor){ // int newheight = document->size().rheight(); // //qDebug()<<"newheight:"<<newheight; // UiUtil::writeLog(1, __FILE__, __LINE__, Q_FUNC_INFO, QString("newheight:"), QString::number(newheight,10)); // emit sigTextHeightChanged(newheight); // } // } } void VoiceToTextEdit::wheelEvent(QWheelEvent *e) { //qDebug() << "VoiceToTextEdit::wheelEvent()"; UiUtil::writeLog(1, __FILE__, __LINE__, Q_FUNC_INFO, QString("VoiceToTextEdit::wheelEvent():"), QString("VoiceToTextEdit::wheelEvent():")); if(!Intancer::get_Intancer()->getWantScrollRightListFlag()) { DTextEdit::wheelEvent(e); } } void VoiceToTextEdit::focusInEvent(QFocusEvent *e) { Intancer::get_Intancer()->setWantScrollRightListFlag(false); DTextEdit::focusInEvent(e); } void VoiceToTextEdit::focusOutEvent(QFocusEvent *e) { Intancer::get_Intancer()->setWantScrollRightListFlag(true); DTextEdit::focusOutEvent(e); } void VoiceToTextEdit::resizeEvent(QResizeEvent * event) { DTextEdit::resizeEvent(event); QTimer::singleShot(0, this, [=]{ int documentHeight = static_cast<int>(this->document()->size().height()); emit sigTextHeightChanged(documentHeight); }); } //void VoiceToTextEdit::onTextChanged() //{ // QTimer::singleShot(0, this, [=]{ // int textEditHeight = this->height(); // int documentHeight = static_cast<int>(this->document()->size().height()); // if (textEditHeight < documentHeight - 3) { // emit sigDetailButtonChanged(true); // } // else { // emit sigDetailButtonChanged(false); // } // }); //} void VoiceToTextEdit::initConnection() { connect(this->document(), &QTextDocument::modificationChanged, this, &VoiceToTextEdit::textAreaChanged); } void VoiceToTextEdit::setLineHeight(int value) { QTextCursor textCursor = this->textCursor(); QTextBlockFormat textBlockFormat; textBlockFormat.setLineHeight(value, QTextBlockFormat::FixedHeight);//设置固定行高 textCursor.setBlockFormat(textBlockFormat); this->setTextCursor(textCursor); }
08382fd29de9fa56a99e41e0fd5857e1e3a3adea
2a6cf9758ea625c3a6f2cdfabb84acfa5f98d81b
/coset.cc
1ffd58b46b8d05e4695749e984a01dd8c8b2e5be
[ "MIT" ]
permissive
MadPidgeon/Graph-Isomorphism
c392794ee32ea921d087945658678f470a59a173
30fb35a6faad8bda0663d49aff2fca1f2f69c56d
refs/heads/master
2021-05-01T04:57:43.639506
2016-05-08T10:15:27
2016-05-08T10:15:27
52,746,331
0
0
null
null
null
null
UTF-8
C++
false
false
1,707
cc
coset.cc
#include <stdexcept> #include <iostream> #include "coset.h" #include "group.h" #include "permutation.h" #include "ext.h" Group Coset::supergroup() const { return _G; } Group Coset::subgroup() const { return _H; } bool Coset::isRightCoset() const { return _right; } const Permutation& Coset::representative() const { return _sigma; } bool Coset::operator==( const Coset& other ) const { if( subgroup()->hasSubgroup(other.subgroup()) && other.subgroup()->hasSubgroup( subgroup() ) && isRightCoset() == other.isRightCoset() ) return subgroup()->contains( representative().inverse() * other.representative() ); throw std::range_error( "Cosets are incomparable" ); } Coset::Coset( Group G, Group H, Permutation sigma, bool right ) : _sigma( std::move( sigma ) ) { _G = std::move( G ); _H = std::move( H ); if( _H == nullptr or !_G->hasSubgroup( _H ) ) throw std::range_error( "Can't construct coset since argument is not a subgroup" ); _right = right; } std::ostream& operator<<( std::ostream& os, const Coset& c ) { if( c.isRightCoset() ) return os << c.subgroup()->generators() << c.representative(); else return os << c.representative() << c.subgroup()->generators(); } bool Iso::isEmpty() const { return isSecond(); } const Coset& Iso::coset() const { return getFirst(); } Coset operator*( const Permutation& sigma, const Coset& tauH ) { // std::cout << tauH << std::endl; assert( not tauH.isRightCoset() ); Permutation sigmatau = sigma * tauH.representative(); return Coset( tauH.supergroup(), tauH.subgroup(), sigmatau, false ); } Iso operator*( const Permutation& sigma, const Iso& tauH ) { if( tauH.isEmpty() ) return tauH; else return sigma * tauH.coset(); }
e0c29d19019aa7b43c304652770f9dd495591817
c591b56220405b715c1aaa08692023fca61f22d4
/Megha/Milestone-20(bitmasking)/basic/Get and set ith bits.cp
267af92305c09f3d3f79130fe5f0fa243d31d4b9
[]
no_license
Girl-Code-It/Beginner-CPP-Submissions
ea99a2bcf8377beecba811d813dafc2593ea0ad9
f6c80a2e08e2fe46b2af1164189272019759935b
refs/heads/master
2022-07-24T22:37:18.878256
2021-11-16T04:43:08
2021-11-16T04:43:08
263,825,293
37
105
null
2023-06-05T09:16:10
2020-05-14T05:39:40
C++
UTF-8
C++
false
false
392
cp
Get and set ith bits.cp
#include <iostream> using namespace std; int GetIthBit(int n,int i){ return n&(1<<i)!=0?1:0; //to make it 0 we will and or operator } int SetIthBit(int n,int i){ n=n|(1<<i); //to make it 1 we will use or operator return n; } int main() { int n,i; cin>>n,i; cout<<GetIthBit(n,i)<<endl; cout<<SetIthBit(n,i)<<endl; return 0; } //input 13 2 //output 15
c6c4fcc906a0aba1a5c75260678db821bdbfe23f
f5af91b9188b2c0b99cf11fb0ba87ecc30aaa7be
/PostLight.cpp
7ffe22bdb6a6336786454b5b1399a69582eecf20
[]
no_license
teacup42729/BedLight
58378e9c4b74ca7d92ed95c07515844a5d6e8ecb
f3ae9ae5e0e4c5a4186e8e1e1ac030ffe30bcc4f
refs/heads/master
2021-01-22T13:13:52.286114
2015-08-04T20:41:08
2015-08-04T20:41:08
40,207,579
0
0
null
null
null
null
UTF-8
C++
false
false
4,914
cpp
PostLight.cpp
// // // #include "PostLight.h" #define LONG_PRESS 1000 PostLight::PostLight(int rPin, int gPin, int bPin, int buttonPin) : pwm(rPin, gPin, bPin, true), button(buttonPin, true, true, 20) { } void PostLight::begin(HSV _lightColour, HSV *_overrideColour) { pwm.begin(); currentState = off; lightColour.copy(_lightColour); overrideColour = _overrideColour; } void PostLight::update() { button.update(); switch (currentState) { case off: if (button.wasReleased()) //short press { changeState(fadeOn); } else if (button.pressedFor(LONG_PRESS)) //long press { fadeUp = true; changeState(cycleBrightness); } break; case fadeOn: if (button.wasReleased()) //pressed while fading in { changeState(fadeOut); } else { uint32_t currentTime = millis(); float progress = (currentTime - startFadeTime) / (float)fadeDuration; //Serial.print("Progress = "); //Serial.println(progress); if (progress > 1) { currentColour.copy(lightColour); changeState(on); } else { RGB.lerp(startFadeColour, lightColour, progress, &currentColour); } } break; case fadeOut: if (button.wasReleased()) //pressed while fading out { changeState(fadeOn); } else { uint32_t currentTime = millis(); float progress = (currentTime - startFadeTime) / (float)fadeDuration; //Serial.print("Progress = "); //Serial.println(progress); if (progress > 1) { currentColour.copy(&black); changeState(off); } else { RGB.lerp(startFadeColour, black, progress, &currentColour); } } break; case on: if (button.wasReleased()) //short press { changeState(fadeOut); } currentColour.copy(lightColour); break; case cycleBrightness: if (button.wasReleased()) { lightColour.copy(&currentColour); changeState(on); } else { uint32_t currentTime = millis(); float progress = (currentTime - startFadeTime) / (float)fadeDuration; if (progress > 1) { fadeUp = !fadeUp; changeState(cycleBrightness); } else { if (fadeUp) { lightColour.value = RGB.lerp(0, 1, progress); currentColour.value = lightColour.value; } else { lightColour.value = RGB.lerp(1, 0, progress); currentColour.value = lightColour.value; } } } break; case fadeOnOverride: { uint32_t currentTime = millis(); float progress = (currentTime - startFadeTime) / (float)fadeDuration; //Serial.print("Progress = "); //Serial.println(progress); if (progress > 1) { currentColour.copy(overrideColour); changeState(override); } else { RGB.lerp(startFadeColour, *overrideColour, progress, &currentColour); } } break; case fadeOutOverride: { uint32_t currentTime = millis(); float progress = (currentTime - startFadeTime) / (float)fadeDuration; //Serial.print("Progress = "); //Serial.println(progress); if (progress > 1) { currentColour.copy(&black); if (lightOn) { changeState(on); } else { changeState(off); } } else { RGB.lerp(startFadeColour, black, progress, &currentColour); } } break; case override: currentColour.copy(overrideColour); break; } pwm.setValueHSV(currentColour); } void PostLight::changeState(state newState) { Serial.print("newState = "); Serial.println(newState); switch (newState) { case off: lightOn = false; break; case fadeOn: startFadeTime = millis(); fadeDuration = 1000; startFadeColour.copy(&currentColour); lightOn = true; break; case on: lightOn = true; break; case fadeOut: startFadeTime = millis(); fadeDuration = 500; startFadeColour.copy(&currentColour); black.copy(&startFadeColour); black.value = 0; lightOn = true; break; case cycleBrightness: startFadeTime = millis(); fadeDuration = 5000; lightOn = true; break; case fadeOnOverride: startFadeTime = millis(); fadeDuration = 1000; startFadeColour.copy(&currentColour); break; case fadeOutOverride: startFadeTime = millis(); fadeDuration = 1000; startFadeColour.copy(&currentColour); if (lightOn) { black.copy(lightColour); } else { black.copy(&currentColour); black.value = 0; } break; } currentState = newState; } void PostLight::setLightColour(HSV *hsv) { //store colour in rtc lightColour.copy(hsv); //lightColour.print(); switch (currentState) { case off: currentColour.copy(hsv); currentColour.value = 0; break; case on: currentColour.copy(hsv); break; } } void PostLight::setOverride(bool overridden) { if (overridden && (currentState != fadeOnOverride || currentState != override)) { changeState(fadeOnOverride); } else if (!overridden && (currentState == fadeOnOverride || currentState == override)) { changeState(fadeOutOverride); } } void PostLight::setOverrideColour(HSV *hsv) { overrideColour->copy(hsv); }
9a7f50d5387d89df9c5c5fea7f3c13045621645e
f7ec55b7a179a0e238b1d2287824e0e151ec8e41
/JPEG_compare/JPEG_compare.cpp
eb3f869e1c08fb5e0705575ce36d310ee8b056f1
[]
no_license
JiaWeiLiou/JPEG_compare
f716e286de0881396f0c204a63cbebeac675fc83
284678af5cd5c629c054d1aa9e100b938c319881
refs/heads/master
2020-12-03T02:30:37.861105
2017-07-01T06:57:08
2017-07-01T06:57:08
95,947,827
0
0
null
null
null
null
UTF-8
C++
false
false
2,970
cpp
JPEG_compare.cpp
// test.cpp : 定義主控台應用程式的進入點。 // #include "stdafx.h" #include <iostream> #include <cmath> #include <string> #include <vector> #include <stdlib.h> #include <opencv2/opencv.hpp> using namespace std; using namespace cv; int main() { string file; string name; cout << "Please enter the file directory :"; cin >> file; cout << "Please enter the file name :"; cin >> name; string fname1 = file + "\\" + name + "_gray.bmp"; string fname2 = file + "\\" + name + ".jpg"; string fname3 = file + "\\" + name + "_compare_color.bmp"; string fname4 = file + "\\" + name + "_compare_gray.bmp"; string fname5 = file + "\\" + name + "_compare_combine.bmp"; Mat image1 = imread(fname1,0); Mat image2 = imread(fname2,0); Mat image3(image1.rows, image1.cols, CV_8UC3, Scalar(0, 0, 0)); Mat image4(image1.rows, image1.cols, CV_8UC1, Scalar(0, 0, 0)); int d1 = 0; int d2 = 0; int posdpeak = 0; int negdpeak = 0; for (int i = 0; i < image1.rows; ++i) { for (int j = 0; j < image1.cols; ++j) { if (image1.at<uchar>(i, j) - image2.at<uchar>(i, j) > 0) { image3.at<Vec3b>(i, j)[0] = 0; image3.at<Vec3b>(i, j)[1] = 0; image3.at<Vec3b>(i, j)[2] = (image1.at<uchar>(i, j) - image2.at<uchar>(i, j))*10; /*image3.at<Vec3b>(i, j)[2] = 255;*/ image4.at<uchar>(i, j) = image1.at<uchar>(i, j) - image2.at<uchar>(i, j); d1 += image1.at<uchar>(i, j) - image2.at<uchar>(i, j); d2 += pow(image1.at<uchar>(i, j) - image2.at<uchar>(i, j), 2); if (image1.at<uchar>(i, j) - image2.at<uchar>(i, j) > posdpeak) posdpeak = image1.at<uchar>(i, j) - image2.at<uchar>(i, j); } else if (image1.at<uchar>(i, j) - image2.at<uchar>(i, j) < 0) { image3.at<Vec3b>(i, j)[0] = (-image1.at<uchar>(i, j) + image2.at<uchar>(i, j))*10; /*image3.at<Vec3b>(i, j)[0] = 255;*/ image3.at<Vec3b>(i, j)[1] = 0; image3.at<Vec3b>(i, j)[2] = 0; image4.at<uchar>(i, j) = -image1.at<uchar>(i, j) + image2.at<uchar>(i, j); d1 += -image1.at<uchar>(i, j) + image2.at<uchar>(i, j); d2 += pow(-image1.at<uchar>(i, j) + image2.at<uchar>(i, j), 2); if (image1.at<uchar>(i, j) - image2.at<uchar>(i, j) < negdpeak) negdpeak = image1.at<uchar>(i, j) - image2.at<uchar>(i, j); } } } Mat image5(image1.rows, image1.cols, CV_8UC3, Scalar(0, 0, 0)); for (int i = 0; i < image1.rows; ++i) { for (int j = 0; j < image1.cols; ++j) { image5.at<Vec3b>(i, j)[0] = image1.at<uchar>(i, j); image5.at<Vec3b>(i, j)[1] = image1.at<uchar>(i, j); image5.at<Vec3b>(i, j)[2] = image1.at<uchar>(i, j); if (abs(image1.at<uchar>(i, j) - image2.at<uchar>(i, j)) >= 10) image5.at<Vec3b>(i, j)[2] = 255; } } cout << "d1\t=\t" << d1 << endl; cout << "d2\t=\t" << d2 << endl; cout << "positive dpeak\t=\t" << posdpeak << endl; cout << "negative dpeak\t=\t" << negdpeak << endl; imwrite(fname3, image3); imwrite(fname4, image4); imwrite(fname5, image5); system("pause"); return 0; }
6d13966bf7d4c59e773ae3604d65b1dc8d241376
087a23e688f773cbd5468021a1ae4eb218597260
/test/file_reader_test.cpp
12e47f4e86cabd24e67f2c1a4b64211560c37ea6
[]
no_license
andrewgazelka/Cpp-raytracer
fc81c3b2d0e08f9b9e70cb85bfd68b4330fcadf2
22b101933f5d2433fcc3d0e340d102a2b31c77cf
refs/heads/master
2023-03-27T15:20:39.925450
2021-03-30T16:10:26
2021-03-30T16:10:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
132
cpp
file_reader_test.cpp
#include <climits> #include "gtest/gtest.h" namespace { TEST(FileReader, Yes) { EXPECT_EQ(1,1); } } // namespace
9d314d45c323fd623423ae45937cf4999bf78484
d6cb41ad36365244e7ba8eadcd09a5823b095354
/7-segment-clock-neopixel-LED.ino
9a483899a1ceb46cd78f54f83ec859723ad2177c
[]
no_license
snooth/7-Segment-Countdown-Clock
fac8f985d4f8dd2521255fa4d3f2474e9b05990b
ae392ffdf902456f2ff7ba97ab8a3c43bb639bdc
refs/heads/main
2023-04-14T07:17:41.263437
2021-05-06T10:54:18
2021-05-06T10:54:18
360,779,305
1
0
null
null
null
null
UTF-8
C++
false
false
11,984
ino
7-segment-clock-neopixel-LED.ino
// The Dogg 2021 // 7 segment digit. #include <Adafruit_NeoPixel.h> #include <Wire.h> #include <TimeLib.h> #include <DS1307RTC.h> #define PIXELS_PER_SEGMENT 3 // Number of LEDs in each Segment #define PIXELS_DIGITS 4 // Number of connected Digits #define PIXELS_PIN 2 // GPIO Pin #define PIXELS_TOTAL 84 // total strip led #define LOGO_PIN 6 // GPIO Pin for logo #define LOGO_NUMBER_PIXEL 60 // Number of LED for logo #define TWODOT_PIN 4 // Two dots to make the time pin #define TWODOT_PIXEL 2 // Number of LED for two dots Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXELS_PER_SEGMENT * 7 * PIXELS_DIGITS, PIXELS_PIN, NEO_GRB + NEO_KHZ800); // for main time Adafruit_NeoPixel logostrip = Adafruit_NeoPixel(LOGO_NUMBER_PIXEL, LOGO_PIN, NEO_GRB + NEO_KHZ800); // for logobox Adafruit_NeoPixel twodot = Adafruit_NeoPixel(TWODOT_PIXEL, TWODOT_PIN, NEO_GRB + NEO_KHZ800); // for two dots to make up a time. //Pixel Arrangement /* b a c g f d e */ // Segment array byte segments[7] = { //abcdefg 0b0000001, // Segment g 0b0000010, // Segment f 0b0000100, // Segment e 0b0001000, // Segment d 0b0010000, // Segment c 0b0100000, // Segment b 0b1000000 // Segment a }; //Digits array byte digits[10] = { //abcdefg 0b1111110, // 0 0b0011000, // 1 0b0110111, // 2 0b0111101, // 3 0b1011001, // 4 0b1101101, // 5 0b1101111, // 6 0b0111000, // 7 0b1111111, // 8 0b1111001 // 9 }; // initiate everything void setup() { strip.begin(); strip.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255) logostrip.begin(); logostrip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255) twodot.begin(); readTime(); } // loop the clock void loop() { // display LED in logo strip //logoStrip(); //logoStripRainbow(2); // logoRainbow(10); // display LED in the twodots box twodots(); //twoDotsRainbow(10); // test display on all digits //testDigits(2); // GET AND DISPLAY HOURS // get hour and split two digits into single digits int newHour = getHour(); int hourOne = newHour / 10; int hourTwo = newHour % 10; // if hours is zero then don't display Serial.print("hourOne = "); Serial.println(hourOne); Serial.print("hourTwo = "); Serial.println(hourTwo); if (hourOne != 0) { // display LED digits clearDisplay2(); // clear all the pixels first disp_Digit1(hourOne); // display LED digits 2nd hour digit. disp_Digit2(hourTwo); }else { clearDisplay2(); // clear all the pixels first // display LED digits 2nd hour digit. disp_Digit2(hourTwo); } /* // for loop testing purposes ONLY for (int i = 15; i > 0; i--) { int a = i / 10; int b = i % 10; if (a != 0) { // display LED digits clearDisplay2(); // clear all the pixels first disp_Digit1(a); disp_Digit2(b); }else { clearDisplay2(); // clear all the pixels first disp_Digit2(b); } delay(1000); clearDisplay2(); } */ // GET AND DISPLAY MINUTES // get minute and split two digits into single digits int newMinute = getMinute(); int minOne = newMinute / 10; int minTwo = newMinute % 10; disp_Digit3(minOne); disp_Digit4(minTwo); } //Clear all the Pixels void clearDisplay2() { for (int i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, strip.Color(0, 0, 0)); } strip.show(); } // Rainbow cycle along whole strip. Pass delay time (in ms) between frames. void logoRainbow(int wait) { // Hue of first pixel runs 5 complete loops through the color wheel. // Color wheel has a range of 65536 but it's OK if we roll over, so // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time // means we'll make 5*65536/256 = 1280 passes through this outer loop: for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { for(int i=0; i<logostrip.numPixels(); i++) { // For each pixel in strip... // Offset pixel hue by an amount to make one full revolution of the // color wheel (range of 65536) along the length of the strip // (strip.numPixels() steps): int pixelHue = firstPixelHue + (i * 65536L / logostrip.numPixels()); // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or // optionally add saturation and value (brightness) (each 0 to 255). // Here we're using just the single-argument hue variant. The result // is passed through strip.gamma32() to provide 'truer' colors // before assigning to each pixel: logostrip.setPixelColor(i, logostrip.gamma32(logostrip.ColorHSV(pixelHue))); } logostrip.show(); // Update strip with new contents delay(wait); // Pause for a moment } } // Rainbow cycle along whole strip. Pass delay time (in ms) between frames. void twoDotsRainbow(int wait) { // Hue of first pixel runs 5 complete loops through the color wheel. // Color wheel has a range of 65536 but it's OK if we roll over, so // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time // means we'll make 5*65536/256 = 1280 passes through this outer loop: for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { for(int i=0; i<twodot.numPixels(); i++) { // For each pixel in strip... // Offset pixel hue by an amount to make one full revolution of the // color wheel (range of 65536) along the length of the strip // (strip.numPixels() steps): int pixelHue = firstPixelHue + (i * 65536L / twodot.numPixels()); // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or // optionally add saturation and value (brightness) (each 0 to 255). // Here we're using just the single-argument hue variant. The result // is passed through strip.gamma32() to provide 'truer' colors // before assigning to each pixel: twodot.setPixelColor(i, logostrip.gamma32(twodot.ColorHSV(pixelHue))); } twodot.show(); // Update strip with new contents delay(wait); // Pause for a moment } } // Rainbow cycle along whole strip. Pass delay time (in ms) between frames. void testDigits(int wait) { // Hue of first pixel runs 5 complete loops through the color wheel. // Color wheel has a range of 65536 but it's OK if we roll over, so // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time // means we'll make 5*65536/256 = 1280 passes through this outer loop: for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip... // Offset pixel hue by an amount to make one full revolution of the // color wheel (range of 65536) along the length of the strip // (strip.numPixels() steps): int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or // optionally add saturation and value (brightness) (each 0 to 255). // Here we're using just the single-argument hue variant. The result // is passed through strip.gamma32() to provide 'truer' colors // before assigning to each pixel: strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); } strip.show(); // Update strip with new contents //delay(wait); // Pause for a moment } } // debug to test if RTC time is connected, display to serial monior void readTime() { Serial.begin(9600); while (!Serial) ; // wait for serial delay(200); Serial.println("DS1307RTC Read Test"); Serial.println("-------------------"); } // powers the logo battery box. 18 is the number of LED's powering the branding box. void logoStrip() { for (int i = 0; i < LOGO_NUMBER_PIXEL; i++) { logostrip.setPixelColor(i, 50, 250, 50); } logostrip.show(); //delay(1000); } //display single and double digits, this is for the first digit. void disp_Digit1(int num) { clearDisplay2(); // clear all the pixels first writeDigit(0, num); strip.show(); } //display single and double digits, this is for the second digit, add more for each additional digit. void disp_Digit2(int num) { //clearDisplay(); writeDigit(1, num); strip.show(); } //display single and double digits, this is for the first digit. void disp_Digit3(int num) { //clearDisplay(); writeDigit(2, num); strip.show(); } //display single and double digits, this is for the second digit, add more for each additional digit. void disp_Digit4(int num) { //clearDisplay(); writeDigit(3, num); strip.show(); } // gets hour and RTC int getHour() { tmElements_t tm; RTC.read(tm); int currentHour = tm.Hour; //int currentHour = 1; int currentMinute = tm.Minute; int todayDay = tm.Day; int todayMonth = tm.Month; Serial.print("Hours is "); Serial.println(currentHour); if (currentHour == 13) { Serial.print("It's 1PM "); int newHour = 1; return newHour; } else if (currentHour == 14) { Serial.print("It's 2PM "); int newHour = 2; return newHour; } else if (currentHour == 15) { Serial.print("It's 3PM "); int newHour = 3; return newHour; } else if (currentHour == 16) { Serial.print("It's 4PM "); int newHour = 4; return newHour; } else if (currentHour == 17) { Serial.print("It's 5PM "); int newHour = 5; return newHour; } else if (currentHour == 18) { Serial.print("It's 6PM "); int newHour = 6; return newHour; } else if (currentHour == 19) { Serial.print("It's 7PM "); int newHour = 7; return newHour; } else if (currentHour == 20) { Serial.print("It's 8PM "); int newHour = 8; return newHour; } else if (currentHour == 21) { Serial.print("It's 9PM "); int newHour = 9; return newHour; } else if (currentHour == 22) { Serial.print("It's 10PM "); int newHour = 10; return newHour; } else if (currentHour == 23) { Serial.print("It's 11PM "); int newHour = 11; return newHour; } else if (currentHour == 24) { Serial.print("It's midnight "); int newHour = 01; return newHour; } else if (currentHour == 00) { Serial.print("It's midnight "); int newHour = 12; return newHour; } else { return currentHour; } } // gets minute and RTC int getMinute() { tmElements_t tm; RTC.read(tm); int currentMinute = tm.Minute; //int currentMinute = 18; // debug to test digit Serial.print("Minute is "); Serial.println(currentMinute); return currentMinute; } // colors for the time and twodots int r = 60; int g = 179; int b = 113; // powers the twodots box. 2 is the number of LED's powering the branding box, and had two LEDS void twodots() { for (int i = 0; i < TWODOT_PIXEL; i++) { twodot.setPixelColor(i, r, g, b); } twodot.show(); //delay(1000); } // power each digit void writeDigit(int index, int val) { byte digit = digits[val]; for (int i = 6; i >= 0; i--) { int offset = index * (PIXELS_PER_SEGMENT * 7) + i * PIXELS_PER_SEGMENT; uint32_t color; if (digit & 0x01 != 0) { if (val == 1) color = strip.Color(r, g, b); if (val == 2) color = strip.Color(r, g, b); if (val == 3) color = strip.Color(r, g, b); if (val == 4) color = strip.Color(r, g, b); if (val == 5) color = strip.Color(r, g, b); if (val == 6) color = strip.Color(r, g, b); if (val == 7) color = strip.Color(r, g, b); if (val == 8) color = strip.Color(r, g, b); if (val == 9) color = strip.Color(r, g, b); if (val == 0) color = strip.Color(r, g, b); } else color = strip.Color(0, 0, 0); for (int j = offset; j < offset + PIXELS_PER_SEGMENT; j++) { strip.setPixelColor(j, color); } digit = digit >> 1; } }
7e4f9e8b10d2672e3f3dea9bb6c36c1310ad5074
7f6a94de2bbe920205cdc99f3e57a2f320513dc5
/controllers/epuck_environment_classification/myci_epuck_range_and_bearing_actuator.h
b4cd87095a50f34aa56f578f4ee847d7931f83f8
[]
no_license
Pold87/robot-swarms-need-blockchain-classical
cdb90d6c6d470344f5df1885c91bdbc3f2816a05
dd4cf8bc538b6d652449a8ad20e341ee5b760d1a
refs/heads/master
2020-03-26T00:28:21.066204
2019-10-25T20:42:31
2019-10-25T20:42:31
144,321,846
3
0
null
null
null
null
UTF-8
C++
false
false
2,159
h
myci_epuck_range_and_bearing_actuator.h
/** * @file <argos3/plugins/robots/e-puck/control_interface/ci_range_and_bearing_actuator.h> * * @author Gianpiero Francesca <gianpiero.francesca@ulb.ac.be> * @author Lorenzo Garattoni <lgaratto@ulb.ac.be> */ #ifndef MYCCI_EPUCK_RANGE_AND_BEARING_ACTUATOR_H #define MYCCI_EPUCK_RANGE_AND_BEARING_ACTUATOR_H namespace argos { class MYCCI_EPuckRangeAndBearingActuator; } #include <argos3/core/control_interface/ci_actuator.h> namespace argos { class MYCCI_EPuckRangeAndBearingActuator : public CCI_Actuator { public: /* the number of bytes authorized by the RAB board */ static const UInt32 MAX_BYTES_SENT = 4; /* struct to store the data to send */ typedef UInt8 TData[MAX_BYTES_SENT]; public: enum EEmitterState { STATE_ALL_EMITTERS_DISABLED = 0, STATE_ALL_EMITTERS_SAME_DATA, STATE_EMITTERS_DIFFERENT }; struct SEmitter{ bool Enabled; TData Data; }; struct SDataToSend { EEmitterState State; SEmitter Emitter[12]; SDataToSend(); SDataToSend(const SDataToSend& s_data); SDataToSend& operator=(const SDataToSend& s_data); }; public: virtual ~MYCCI_EPuckRangeAndBearingActuator() {} virtual void Init(TConfigurationNode& t_tree); /** * Sets a message to be broadcast by all emitters. * This method also implicitly enables all emitters. */ virtual void SetData(const TData t_data); /** * Sets a message to be broadcast by a specific emitter. * This method also implicitly enables the emitter. */ virtual void SetDataForEmitter(size_t un_idx, const TData t_data); /** * Disables all emitters. */ virtual void Disable(); /** * Disables a specific emitter. */ virtual void DisableEmitter(size_t un_idx); /** * Reset. */ virtual void Reset(){ Disable(); } protected: /** this is the maximum data size */ UInt8 m_uDataSize; /** This structure stores what the controllers wants to send */ SDataToSend m_sDesiredData; }; } #endif
1169c060a4934446ebad27a08d22a9364cbb427d
65b0cde0a37c3d478b6be35891e5d52e413580db
/UpCore/MidasBank.cxx
39e1909d37262734310d8a8020105c1038769012
[]
no_license
moukaddam/Unpacker
262dab631c42c27c667831928476d32b686f4f80
8127ab9a19f90c64b0111e3ed79b0df5e5ee8cbe
refs/heads/master
2021-01-01T19:09:42.654529
2017-07-26T17:04:42
2017-07-26T17:04:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,595
cxx
MidasBank.cxx
#include"MidasBank.h" #include"VUserPoint.h" #include"UnpackerOptionManager.h" #include<cstdlib> #include<bitset> MidasBank* MidasBank::instance = NULL; //////////////////////////////// MidasBank* MidasBank::getInstance(){ // A new instance of RootInput is created if it does not exist: if (instance == NULL) { instance = new MidasBank(); } // The instance of RootInput is returned: return instance; } //////////////////////////////// void MidasBank::Destroy(){ delete MidasBank::instance ; } //////////////////////////////// MidasBank::MidasBank(){ m_Offset =1; m_BankSize=0; fill_fspc_list(); m_CurrentEvent = new TMidasEvent(3000); m_RootFile = NULL; m_RootTree = NULL; string infile = UnpackerOptionManager::getInstance()->GetInputFileName(); MidasFile* myMidasFile = new MidasFile(); myMidasFile->Open(infile.c_str()); SetMidasFile(myMidasFile); if(!UnpackerOptionManager::getInstance()->GetNoBankTree()) SetRootFile(infile); TH1::AddDirectory(kFALSE); } //////////////////////////////// MidasBank::~MidasBank(){ MidasBank::instance = NULL; if(m_RootFile!=NULL){ m_RootTree->AutoSave(); } } //////////////////////////////// void MidasBank::Build(unsigned int NumberOfFragment){ unsigned int i=0; for (i = 0 ; i< NumberOfFragment; i++) { if(i%1000==0){ cout << "\r Initial Loading : " << i/1000. << "k fragments" << flush; } PushBackFragment(); } cout << "\r Initial Loading : " << i/1000. << "k fragment" << endl; } //////////////////////////////// void MidasBank::Clear(){ m_FragmentBank.clear(); m_BankSize=0; } //////////////////////////////// void MidasBank::PushBackFragment(){ MidasEventFragment* myFragment = new MidasEventFragment(); if(m_MidasFile->Read(myFragment)){ if(myFragment->GetEventId()==1){ UnPackMidasBank(myFragment); } } delete myFragment; } //////////////////////////////// list<EventFragment*>::iterator MidasBank::PopElementFragment(list<EventFragment*>::iterator it){ m_eventfragment.push_back((*it)); // The pointer is placed to the next fragment it=m_FragmentBank.erase(it); // return to the previous fragment (current fragment) --it; --m_BankSize; return it; } //////////////////////////////// void MidasBank::Process(unsigned int NumberOfFragment){ VUserPoint* user_point=VUserPoint::getInstance(); user_point->BeginOfRunAction(); InitTree(); // build the initial fragment bank Build(NumberOfFragment); bool check_end = false; cout << "Starting Bank Processing " << endl; list<EventFragment*>::iterator it; int NumberFragment = 0 ; int currentID = 0; int position = 0; int EventNumber = 0; double average_fragment = 0; double average_pushback = 0; int sizeBefore= 0 ; int sizeAfter=0 ; int NumberOfPushBack=0; unsigned int LastPosition = 0 ; // Loop over the rest of the element while(m_BankSize!=0){ EventNumber++; // Took the first fragment and considere it belong to the current event it=m_FragmentBank.begin(); currentID = (*it)->eventId; PopElementFragment(it); PushBackFragment(); // Clear the event from previous value LastPosition=0; for (it=m_FragmentBank.begin() , position = 1; it!=m_FragmentBank.end(); ++it , ++position) { LastPosition++; if((*it)->eventId==currentID){ it = PopElementFragment(it); NumberFragment++; // Take the longest distance between two fragment so far and add 10% as a safety offset if(LastPosition>m_Offset/1.1) m_Offset=LastPosition*1.1; /* every time a fragment belonging to the current event is found, we check how many fragments are ahead and load the appropriate number of fragments */ while(!check_end && (m_BankSize - position) < m_Offset){ if(!check_end){ if(UnpackerOptionManager::getInstance()->GetMaximumBankLoad()>0 && m_BankSize>UnpackerOptionManager::getInstance()->GetMaximumBankLoad()) break; sizeBefore = m_BankSize; PushBackFragment(); NumberOfPushBack++; sizeAfter = m_BankSize; average_pushback +=(1./(NumberOfPushBack))*((sizeAfter-sizeBefore)-average_pushback); } if(!check_end && string(m_MidasFile->GetLastError())=="EOF"){ cout << endl << "\t Reaching end of file " << endl; check_end=true; } } } if(NumberFragment%100000==0){ cout << "\r " << NumberFragment/1000000. << "M frag. treated |" <<" Build: " << EventNumber <<" Avg. size: " << average_fragment << " Avg.PB: " << average_pushback <<" | " <<"Bank Status: size : " << m_BankSize << " , " <<"Offset : " << m_Offset << " " << flush; } } average_fragment+=(1./(EventNumber))*(m_eventfragment.size()-average_fragment); // Clear the Fragment from precedent stuff m_CurrentEvent->Clear(); // Fill the event with the new fragment unsigned int size = m_eventfragment.size(); for(unsigned int g = 0 ; g < size ; g++){ m_CurrentEvent->tig_num_chan=size; m_CurrentEvent->tig_event_id= currentID; m_CurrentEvent->tig_midas_id.push_back( m_eventfragment[g]->midasId); if(m_eventfragment[g]->tig10) m_CurrentEvent->tig_type.push_back(0); else if(m_eventfragment[g]->tig64) m_CurrentEvent->tig_type.push_back(1); else cout <<"type unknown!" << endl ; m_CurrentEvent->channel_number.push_back(m_eventfragment[g]->channel); m_CurrentEvent->channel_raw.push_back(m_eventfragment[g]->channel_raw); m_CurrentEvent->cfd_value.push_back(m_eventfragment[g]->cfd); m_CurrentEvent->led_value.push_back(m_eventfragment[g]->led); m_CurrentEvent->charge_raw.push_back(m_eventfragment[g]->charge); m_CurrentEvent->charge_cal.push_back(m_eventfragment[g]->charge); m_CurrentEvent->timestamp_low.push_back(m_eventfragment[g]->timestamp_low); m_CurrentEvent->timestamp_high.push_back(m_eventfragment[g]->timestamp_high); m_CurrentEvent->timestamp_live.push_back(m_eventfragment[g]->timestamp_live); m_CurrentEvent->timestamp_tr.push_back(m_eventfragment[g]->timestamp_tr); m_CurrentEvent->timestamp_ta.push_back(m_eventfragment[g]->timestamp_ta); int name_offset = 0; while(gDirectory->FindObjectAny(Form("wf_%i",name_offset))){ name_offset++; } name_offset++; if(m_eventfragment[g]->samplesfound>0){ TH1F h = TH1F(Form("wf_%i",name_offset),Form("wf_%i",name_offset),m_eventfragment[g]->samplesfound,0,m_eventfragment[g]->samplesfound); h.SetDirectory(0); for(int wl = 0 ; wl<m_eventfragment[g]->samplesfound ;wl++){ h.Fill(wl,m_eventfragment[g]->wave[wl]); } m_CurrentEvent->waveform.push_back(h); } else{ TH1F h = TH1F(Form("wf_%i",name_offset),Form("wf_%i",name_offset),1,0,1); m_CurrentEvent->waveform.push_back(h); } delete m_eventfragment[g]; } user_point->EventAction(m_CurrentEvent); if(m_RootFile!=NULL) m_RootTree->Fill(); m_eventfragment.clear(); } cout << endl << "\r Processing terminated: " << NumberFragment<< " fragments treated" <<", " << EventNumber << " Events reconstructed " << endl ; cout << "Missing " << m_FragmentBank.size() << endl ; user_point->EndOfRunAction(); } //////////////////////////////// void MidasBank::SetMidasFile(MidasFile* FileName){ m_MidasFile = FileName; } //////////////////////////////// MidasFile* MidasBank::GetMidasFile(){ return m_MidasFile; } //////////////////////////////// void MidasBank::SetBankOffset(unsigned int Offset){ m_Offset = Offset ; } ///////////////////////// void MidasBank::UnPackMidasBank(MidasEventFragment* fragment) { int NumberOfBanks = fragment->SetBankList(); Bank32_t* banks = new Bank32_t[NumberOfBanks]; void** d_ptr = new void*[NumberOfBanks]; int *bank_name = new int[NumberOfBanks]; int *bank_type = new int[NumberOfBanks]; int *bank_size = new int[NumberOfBanks]; for(int k=0;k<NumberOfBanks;k++) { bank_name[k]=*(int*)(fragment->GetBankList()+k*4); memcpy(banks[k].fName,fragment->GetBankList()+k*4,4); }; int temp1, temp2; for(int k=0;k<NumberOfBanks;k++) { fragment->FindBank(banks[k].fName,&temp1,&temp2,d_ptr+k); bank_size[k] = temp1; banks[k].fDataSize = temp1; bank_type[k] = temp2; //datatype_counter[bank_type[k]]++; banks[k].fType = temp2; } for(int k=0;k<NumberOfBanks;k++) UnpackTigress((int*)(d_ptr[k]),bank_size[k]); delete[] bank_size; delete[] bank_type; delete[] bank_name; delete[] d_ptr; delete[] banks; } ///////////////////////// void MidasBank::UnpackTigress(int *data, int size) { int error =0; int current_eventId = -1; EventFragment* eventfragment = new EventFragment; for(int x=0; x<size ;x++) { int dword = *(data+x); unsigned int type = (dword & 0xf0000000); //>> 28; int slave = (dword & 0x0ff00000) >> 20; int value = (dword & 0x0fffffff); // int value = (dword & 0x00ffffff); switch(type) { case 0x00000000: // waveform data if (value & 0x00002000) { int temp = value & 0x00003fff; temp = ~temp; temp = (temp & 0x00001fff) + 1; eventfragment->wave[eventfragment->samplesfound++] = -temp; } else { eventfragment->wave[eventfragment->samplesfound++] = value & 0x00001fff; } if ((value >> 14) & 0x00002000) { int temp = (value >> 14) & 0x00003fff; temp = ~temp; temp = (temp & 0x00001fff) + 1; eventfragment->wave[eventfragment->samplesfound++] = -temp; } else { eventfragment->wave[eventfragment->samplesfound++] = (value >> 14) & 0x00001fff; } //print = false; break; case 0x10000000: // trapeze data //currently not used. break; case 0x40000000: // CFD Time //time = true; eventfragment->found_time = true; eventfragment->slowrisetime = value & 0x08000000; eventfragment->cfd = value & 0x07ffffff; break; case 0x50000000: // Charge eventfragment->found_charge = true; if(eventfragment->tig10) { // eventfragment->pileup = value & 0x00010000; //eventfragment->charge = (value & 0x0000ffff); eventfragment->charge = (value & 0x0fffffff); } else if(eventfragment->tig64) { eventfragment->charge = value; //(value & 0x0fffffff); } else{ printf("%i problem extracting charge.\n", error++); eventfragment->found_charge = false; } break; case 0x60000000: // led ?? leading edge! eventfragment->led = value & 0x07ffffff; break; case 0x80000000: // Event header current_eventId = value; break; case 0xa0000000:{ // timestamp int time[5]; time[0] = *(data + x); x += 1; time[1] = *(data + x); //& 0x0fffffff; if( (time[1] & 0xf0000000) != 0xa0000000) { if( ( (time[1] & 0xf0000000) == 0xc0000000) && ( ((time[1] & 0x000000ff) == 0x0000003f) || ((time[1] & 0x000000ff) == 0x0000001f) ) ) { x-=1; break;} eventfragment->IsBad = true; //printf("timestamp probelm 1.\t%08x\t%08x\t%08x\t%i\n",time[0],time[1], 0xa0000000,x ); //PrintBank(data,size); break; } if( ((time[0] & 0x0f000000)==0) && ((time[1] & 0x0f000000)==0) ) { //tig64 eventfragment->timestamp_low = time[0] & 0x00ffffff; eventfragment->timestamp_high = time[1] & 0x00ffffff; } else { //tig10 eventfragment->timestamp_low = time[0] & 0x00ffffff; eventfragment->timestamp_high = time[1] & 0x00ffffff; x += 1; time[2] = *(data+x);// & 0x0fffffff; if( (time[2] & 0xf0000000) != 0xa0000000) { x = x-1; /// If a tig10 is missing some timestamp words. break; } x += 1; time[3] = *(data+x);// & 0x0fffffff; if( (time[3] & 0xf0000000) != 0xa0000000) { //printf("timestamp probelm 3.\t%08x\t%08x\t%08x\t%i\n",time[0],time[3], 0xa0000000,x ); break;} x += 1; time[4] = *(data+x);// & 0x0fffffff; if( (time[4] & 0xf0000000) != 0xa0000000) { //printf("timestamp probelm 4.\t%08x\t%08x\t%08x\t%i\n",time[0],time[4], 0xa0000000,x ); break;} for(int nstamp =0; nstamp<5; nstamp++) { int subtype = (time[nstamp] & 0x0f000000); switch(subtype) { case 0x00000000: eventfragment->timestamp_low = (time[nstamp] & 0x00ffffff); break; case 0x01000000: eventfragment->timestamp_high = (time[nstamp] & 0x00ffffff); break; case 0x02000000: eventfragment->timestamp_live = (time[nstamp] & 0x00ffffff); break; case 0x04000000: eventfragment->timestamp_tr = (time[nstamp] & 0x00ffffff); break; case 0x08000000: eventfragment->timestamp_ta = (time[nstamp] & 0x00ffffff); break; default: //printf("timestamp probelm default.\t%08x\t%08x\t%i\n",time[1], 0xa0000000,x ); break; }; } } } //has_timestamp = true; break; case 0xb0000000: // Trigger Pattern eventfragment->triggerpattern = value; break; case 0xc0000000: // port info, New Channel // if(eventfragment->found_channel) //cout<<"reaching new event before first one finnish" << endl ; eventfragment->found_channel = true; eventfragment->channel = FSPC_to_channel(dword & 0x00ffffff); eventfragment->channel_raw = dword & 0x00ffffff ; // cout << "eee " <<std::hex<< value << " " << std::dec <<value<< endl; if(slave<3) {eventfragment->tig64 = true;} else{eventfragment->tig10 = true;} break; case 0xe0000000: // Event Trailer break; case 0xf0000000: // EventBuilder Timeout printf("Event builder error, builder timed out ,found type: %08x\n", type); break; default: printf("Unpacking error: found unknown type.\t%08x\t%i\n",type,x); break; }; if(eventfragment->found_time && eventfragment->found_charge && eventfragment->found_channel&&current_eventId>-1){ eventfragment->eventId = current_eventId; m_FragmentBank.push_back(eventfragment); ++m_BankSize; eventfragment = new EventFragment; } } if(!(eventfragment->found_time && eventfragment->found_charge && eventfragment->found_channel&&eventfragment->found_eventID)) delete eventfragment; } ////////////// void MidasBank::fill_fspc_list() { fstream infile; infile.open("fspc2ch.h"); int index = 0; if(infile.is_open() ) { string line; while( getline(infile,line) ) { fspc_list[index] = (int)strtol(line.c_str(),NULL,16); index++; } } if(index < 2048) { while(index<2048) { fspc_list[index++] = 0; } } } ////////////// int MidasBank::FSPC_to_channel(int fspc) { for(int i=0;i<2048;i++) { if(fspc==fspc_list[i]){return i;} } return -1; } ////////////// void MidasBank::SetRootFile(string infile){ if(infile=="") return; if(infile.find(".mid") == infile.npos) { printf("can't read midas file\n"); return ; } string outfile(infile,(infile.find(".mid")-5),infile.find(".mid")-(infile.find(".mid")-5)); outfile += ".root"; string temp = UnpackerOptionManager::getInstance()->GetBankOutputPath()+"raw"; outfile = temp+outfile; printf("Bank tree: %s\n",outfile.c_str()); m_RootFile = new TFile(outfile.c_str(),"RECREATE"); if(!m_RootFile->IsOpen()) { printf("issues opening the root output file....\n");exit(1); } } ////////////// void MidasBank::InitTree(){ if(m_RootFile!=NULL){ m_RootTree = new TTree(UnpackerOptionManager::getInstance()->GetBankOutputName().c_str(),UnpackerOptionManager::getInstance()->GetBankOutputName().c_str()); m_RootTree->Branch( "MidasEvent" , "TMidasEvent" , &m_CurrentEvent ); } }
c8aff43fecc8e78f7394f9f994b8e8c5d8e0a4dc
56a77194fc0cd6087b0c2ca1fb6dc0de64b8a58a
/applications/SolidMechanicsApplication/custom_constitutive/linear_elastic_plastic_plane_strain_2D_law.cpp
f685d8459cbf1f191a2bd6852c380c247224687d
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
KratosMultiphysics/Kratos
82b902a2266625b25f17239b42da958611a4b9c5
366949ec4e3651702edc6ac3061d2988f10dd271
refs/heads/master
2023-08-30T20:31:37.818693
2023-08-30T18:01:01
2023-08-30T18:01:01
81,815,495
994
285
NOASSERTION
2023-09-14T13:22:43
2017-02-13T10:58:24
C++
UTF-8
C++
false
false
5,429
cpp
linear_elastic_plastic_plane_strain_2D_law.cpp
// // Project Name: KratosSolidMechanicsApplication $ // Created by: $Author: JMCarbonell $ // Last modified by: $Co-Author: $ // Date: $Date: July 2015 $ // Revision: $Revision: 0.0 $ // // // System includes // External includes // Project includes #include "custom_constitutive/linear_elastic_plastic_plane_strain_2D_law.hpp" #include "solid_mechanics_application_variables.h" namespace Kratos { //******************************CONSTRUCTOR******************************************* //************************************************************************************ LinearElasticPlasticPlaneStrain2DLaw::LinearElasticPlasticPlaneStrain2DLaw() : LinearElasticPlastic3DLaw() { } //******************************CONSTRUCTOR******************************************* //************************************************************************************ LinearElasticPlasticPlaneStrain2DLaw::LinearElasticPlasticPlaneStrain2DLaw(FlowRulePointer pFlowRule, YieldCriterionPointer pYieldCriterion, HardeningLawPointer pHardeningLaw) : LinearElasticPlastic3DLaw(pFlowRule,pYieldCriterion,pHardeningLaw) { } //******************************COPY CONSTRUCTOR************************************** //************************************************************************************ LinearElasticPlasticPlaneStrain2DLaw::LinearElasticPlasticPlaneStrain2DLaw(const LinearElasticPlasticPlaneStrain2DLaw& rOther) : LinearElasticPlastic3DLaw(rOther) { } //********************************CLONE*********************************************** //************************************************************************************ ConstitutiveLaw::Pointer LinearElasticPlasticPlaneStrain2DLaw::Clone() const { return Kratos::make_shared<LinearElasticPlasticPlaneStrain2DLaw>(*this); } //*******************************DESTRUCTOR******************************************* //************************************************************************************ LinearElasticPlasticPlaneStrain2DLaw::~LinearElasticPlasticPlaneStrain2DLaw() { } //************* COMPUTING METHODS //************************************************************************************ //************************************************************************************ //***********************COMPUTE TOTAL STRAIN***************************************** //************************************************************************************ void LinearElasticPlasticPlaneStrain2DLaw::CalculateGreenLagrangeStrain( const Matrix & rRightCauchyGreen, Vector& rStrainVector ) { //E= 0.5*(FT*F-1) rStrainVector[0] = 0.5 * ( rRightCauchyGreen( 0, 0 ) - 1.00 ); rStrainVector[1] = 0.5 * ( rRightCauchyGreen( 1, 1 ) - 1.00 ); rStrainVector[2] = rRightCauchyGreen( 0, 1 ); } //***********************COMPUTE TOTAL STRAIN***************************************** //************************************************************************************ void LinearElasticPlasticPlaneStrain2DLaw::CalculateAlmansiStrain( const Matrix & rLeftCauchyGreen, Vector& rStrainVector ) { // e= 0.5*(1-invbT*invb) Matrix InverseLeftCauchyGreen ( rLeftCauchyGreen.size1() , rLeftCauchyGreen.size2() ); double det_b=0; MathUtils<double>::InvertMatrix( rLeftCauchyGreen, InverseLeftCauchyGreen, det_b); rStrainVector.clear(); rStrainVector[0] = 0.5 * ( 1.0 - InverseLeftCauchyGreen( 0, 0 ) ); rStrainVector[1] = 0.5 * ( 1.0 - InverseLeftCauchyGreen( 1, 1 ) ); rStrainVector[2] = -InverseLeftCauchyGreen( 0, 1 ); } //********************* COMPUTE LINEAR ELASTIC CONSTITUTIVE MATRIX ******************* //************************************************************************************ void LinearElasticPlasticPlaneStrain2DLaw::CalculateLinearElasticMatrix( Matrix& rLinearElasticMatrix, const double& YoungModulus, const double& PoissonCoefficient ) { rLinearElasticMatrix.clear(); // Plane strain constitutive matrix rLinearElasticMatrix ( 0 , 0 ) = (YoungModulus*(1.0-PoissonCoefficient)/((1.0+PoissonCoefficient)*(1.0-2.0*PoissonCoefficient))); rLinearElasticMatrix ( 1 , 1 ) = rLinearElasticMatrix ( 0 , 0 ); rLinearElasticMatrix ( 2 , 2 ) = rLinearElasticMatrix ( 0 , 0 )*(1.0-2.0*PoissonCoefficient)/(2.0*(1.0-PoissonCoefficient)); rLinearElasticMatrix ( 0 , 1 ) = rLinearElasticMatrix ( 0 , 0 )*PoissonCoefficient/(1.0-PoissonCoefficient); rLinearElasticMatrix ( 1 , 0 ) = rLinearElasticMatrix ( 0 , 1 ); } //*************************CONSTITUTIVE LAW GENERAL FEATURES ************************* //************************************************************************************ void LinearElasticPlasticPlaneStrain2DLaw::GetLawFeatures(Features& rFeatures) { //Set the type of law rFeatures.mOptions.Set( PLANE_STRAIN_LAW ); rFeatures.mOptions.Set( INFINITESIMAL_STRAINS ); rFeatures.mOptions.Set( ISOTROPIC ); //Set strain measure required by the consitutive law rFeatures.mStrainMeasures.push_back(StrainMeasure_Infinitesimal); rFeatures.mStrainMeasures.push_back(StrainMeasure_Deformation_Gradient); //Set the strain size rFeatures.mStrainSize = GetStrainSize(); //Set the spacedimension rFeatures.mSpaceDimension = WorkingSpaceDimension(); } } // Namespace Kratos
0c7ce7c08101dd16cc555998d65d7bdcd0f60ee9
6f999bdade8805307fb4dfc2cb397209a0212556
/core/DBInternal.h
d7edd433d5195990243e0dc354bb5fce7a672e50
[]
no_license
poseidon1214/PageDB
5b72ade3bc319dbd63eda9b5d4eedac89fdb4715
8c9296563dcef174ecd734fcb7ff42186dfc056e
refs/heads/master
2021-01-18T06:31:27.594697
2014-08-16T09:30:05
2014-08-16T09:30:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,342
h
DBInternal.h
// Copyright (c) 2014 The PageDB1 Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. #ifndef _DB_INT_H #define _DB_INT_H #include "Log.h" #include "Slice.h" #include "Noncopyable.h" using namespace utils; #include "Batch.h" #define PAGESIZE 100 #define CACHESIZE 20 #define SINT sizeof(int) #define SINT64 sizeof(uint64_t) /** ** DBInternal is the second layer of db. ** DBInternal is the base class of PageDB1 **/ namespace pagedb { typedef uint32_t (*HashFunc)(const Slice & key); class DBInternal : public Noncopyable { public: DBInternal() : m_log(Log::GetInstance()) { } public: /** ** Layer 1 **/ virtual bool open(const string &filename) = 0; virtual bool close(); virtual bool put(const Slice & key,const Slice & value) = 0; virtual Slice get(const Slice & key) = 0; virtual bool remove(const Slice & key) = 0; /** ** Layer 2 **/ virtual bool put(WriteBatch * pbatch) = 0; /** ** Layer 3 **/ virtual void sync() = 0; virtual void dump(ostream&os) = 0; virtual void compact() = 0; protected: Log * m_log; }; }; #endif
7ac77c95a0b8d0e60f4d5975c7d06a736d3e8907
735297d0e7d44733fe6a05bf17bca3516fde03dd
/STL And DS & Algo/Stack/Programs/Stack class with min-max functions/main.cpp
247e758f67c7085156b709a09d39b4e5e302e2b2
[]
no_license
saswatsk/Comprehensive-C
741fb1ddfd238be10d474330af1e02ef1ed220bc
a250170c5743ec938028e6a4aac46c7d8a538e22
refs/heads/main
2023-08-17T13:19:31.789637
2021-09-17T15:57:29
2021-09-17T15:57:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,541
cpp
main.cpp
// Stack class with push, pop, top and MIN-MAX functions // Will be done using 3 stacks #include<iostream> #include<vector> using namespace std; class Stack { private: vector<int> stack; vector<int> minStack; vector<int> maxStack; public: Stack() = default; void push(int data) { stack.push_back(data); if (maxStack.empty() && minStack.empty()) { // means the min and max stack are empty // means we are inserting the first element maxStack.push_back(data); minStack.push_back(data); } else { // means the stacks have at least one element maxStack.push_back(max(data, maxStack[maxStack.size() - 1])); minStack.push_back(min(data, minStack[minStack.size() - 1])); } } void pop() { stack.pop_back(); minStack.pop_back(); maxStack.pop_back(); } bool empty() { return stack.empty(); } int getMin() { return minStack[minStack.size() - 1]; } int getMax() { return maxStack[maxStack.size() - 1]; } int top() { return stack[stack.size() - 1]; } }; int main() { Stack s; s.push(1); s.push(5); s.push(3); s.push(8); cout << "Max: " << s.getMax() << endl; s.pop(); cout << "Min: " << s.getMin() << endl; cout << "Max: " << s.getMax() << endl; s.pop(); s.pop(); cout << "Top: " << s.top() << endl; cout << "Max: " << s.getMax() << endl; return 0; }
327b76717a0ab3ffa892926621e3a445cfd89a4e
a6f7a5fac6ee01cd62c1f7e5d277b29b82e4f3b2
/src/backend.hpp
b08bebc31743d5dfe46f7cf38f9b8744931c6ed8
[]
no_license
prajjwalm/game_of_life
0caeb8f820f717ec49e7d97b2b0e0cd2d43e4fa1
347e1c73f1b777610e0e10a5c0b321864d625e94
refs/heads/master
2021-09-14T09:14:56.889819
2018-05-11T05:52:26
2018-05-11T05:52:26
103,138,492
0
0
null
null
null
null
UTF-8
C++
false
false
1,423
hpp
backend.hpp
/* * backend.hpp * * Created on: 16-Oct-2017 * Author: Prajjwal Mishra */ #ifndef SRC_BACKEND_HPP_ #define SRC_BACKEND_HPP_ #include "globalvar.hpp" namespace backend { enum state {dead, live}; class cell { state curr, prev; int n; // no of live neighbours public: cell(); cell(state, int); //developed exclusively for testing int getn(); state getstate(); // gives current state, meant for universe::display void set_prev(); // assigns curr to prev, meant for universe::next_gen int set_n(int); // assigning of n state init_state(state); // forced assigning of state, meant for universe::initialize state setstate(); // sets the current state based on prev, n and returns it, // meant for universe::next_gen }; class universe { int gen; //generation number, increments at call of next_gen cell matrix[size][size]; public: universe(); int getgen() {return gen;} void update_n(); // sets n for each cell, based on current states, for next_gen state getstatexy(int x, int y); int getnxy (int x, int y ); void setstatexy(int x, int y, state S); void initialize(bool [size][size]); void next_gen(); //based on n and the previous states of the cells, generates the //current state of all the cells of the matrix, increments gen }; } #endif /* SRC_BACKEND_HPP_ */
8e7027b777221f9dcffc298f7817443d58f781ac
18307580b7f955a48fce511f943d1dfbe30a18f8
/sensor.ino
39c46f606f7db3bc57459b9baa1906a7d7ed96a2
[]
no_license
mahmoudyusof/code-for-catalysis
adf08a8d2d17dfc5abef086fc819c93d2f845880
32f689ef3ed53d6454b089ca407448b15d8624ec
refs/heads/master
2021-09-09T21:16:44.764090
2018-03-19T18:58:29
2018-03-19T18:58:29
111,325,781
0
0
null
null
null
null
UTF-8
C++
false
false
1,289
ino
sensor.ino
double R = 100; // this is a current limitting resistance double K = 30; // this is the springs constant double f = 50; // this is the used frequency double S = 10; // this is a resitor at which the voltage will be measured double r = 0.2; // this is the resistance of the coil double u = 1; // this is the magnetic permeability double N = 5; // this is the number of windings double A = 0.0001; // this is the area of the windings double Rt = R + S + r; double c = 2*3.14*f*u*sq(N)*A; int pin = A0; double v0; double dom0; double nom0; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(pin, INPUT); v0 = map(analogRead(pin), 0, 1024, 0, 5); dom0 = sqrt(25*sq(S) + sq(v0)*sq(Rt)); nom0 = sq(v0); } void loop() { // put your main code here, to run repeatedly: double v = map(analogRead(pin), 0, 1024, 0, 5); double dom = sqrt(25*S*S + sq(v)*sq(Rt)); double nom = sq(v); double force = c*(nom/dom - nom0/dom0); Serial.println(force); Serial.println(v0); Serial.println(v); Serial.println(nom); Serial.println(nom0); Serial.println(dom); Serial.println(dom0); Serial.println(c); Serial.println("----------------------"); delay(1000); }
32615832e396a5d30ac87f93e7b0b23db7468b55
b27090ab20e0da82fa7e92b3baef0b5e3db74806
/DP/Minimum Path Sum.cpp
37e351b63f81b63f55aa67bb826e3d9f1c39bc95
[]
no_license
iam-aniket/Interview-Prep
693a8c0f11eee20bd80a7a21569dcab99a316694
44bc84e65fa0baa2769853ccc54028543b85f60e
refs/heads/main
2023-04-01T14:52:29.445012
2021-04-08T15:27:29
2021-04-08T15:27:29
306,826,957
0
0
null
null
null
null
UTF-8
C++
false
false
380
cpp
Minimum Path Sum.cpp
#define rep(i,a,n) for(int i = a; i < n; i++) class Solution { public: int minPathSum(vector<vector<int>>& a) { int m = a.size(); int n = m ? a[0].size() : 0; rep(i, 1, n) a[0][i] += a[0][i - 1]; rep(i, 1, m) a[i][0] += a[i - 1][0]; rep(i, 1, m) { rep(j, 1, n) { a[i][j] += min(a[i - 1][j] , a[i][j - 1]); } } return a[m - 1][n - 1]; } };
9e766e775ff15ed424e86d21d5402227d0c70108
0d466c823015789e2df1c792af23b41b4f569f6a
/src/cerata/signal.h
ba81ffc01c3fda50c35f7f044d511b1cda992523
[ "Apache-2.0" ]
permissive
abs-tudelft/cerata
44a760b32e99c4d97c83fff51f8d9666b170839d
2ae66df995910429f51fed68c95f4823bba5dae8
refs/heads/develop
2020-12-20T07:07:13.229223
2020-11-24T13:16:37
2020-11-24T13:16:37
235,993,608
3
2
Apache-2.0
2023-02-27T15:40:28
2020-01-24T11:50:47
C++
UTF-8
C++
false
false
1,753
h
signal.h
// Copyright 2018-2019 Delft University of Technology // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include <vector> #include <string> #include <memory> #include "cerata/node.h" namespace cerata { /** * @brief A Signal Node. * * A Signal Node can have a single input and multiple outputs. */ class Signal : public NormalNode, public Synchronous { public: /// @brief Signal constructor. Signal(std::string name, std::shared_ptr<Type> type, std::shared_ptr<ClockDomain> domain = default_domain()); /// @brief Create a copy of this Signal. std::shared_ptr<Object> Copy() const override; std::string ToString() const override; }; /// @brief Create a new Signal and return a smart pointer to it. std::shared_ptr<Signal> signal(const std::string &name, const std::shared_ptr<Type> &type, const std::shared_ptr<ClockDomain> &domain = default_domain()); /// @brief Create a new Signal and return a smart pointer to it. The Signal name is derived from the Type name. std::shared_ptr<Signal> signal(const std::shared_ptr<Type> &type, const std::shared_ptr<ClockDomain> &domain = default_domain()); } // namespace cerata
8973cde5840921b55b4e39bf39193e45be2c9a04
74c4472454beff8378ad20282eab83cde2bacea2
/operations.h
de812d24309f52020451091f4dbf307dbd683044
[]
no_license
Visorak/MathProject
dfb4a8b76fa5d18b93ea72ba2e856a6d5d1888d3
2145c3b9fa4c319ee48ff2c318dbd1de6e29e40a
refs/heads/master
2020-04-14T19:51:17.014265
2016-09-12T08:44:33
2016-09-12T08:44:33
67,986,940
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
3,232
h
operations.h
#ifndef OPERATIONS_H_INCLUDED #define OPERATIONS_H_INCLUDED /*class Matrix; class Vector;*/ #include"C:\VisoGor\MyMath.h" class SystemOfEquations; class Operations { private: enum WayIntegration{Trapezoid=1,Simpson=2,Int3D8=3,Gauss=4}; double der(double **u,int i,int j,double h);///производная double IntegrationTrapezoid(double*y,double h,int n); double RatingTrapezoid(double *x,double h,int n,double b,double a,double (*eq2)(double)); double IntegrationSimpson(double*y,double h,int n); double RatingSimpson(double *x,double h,int n,double b,double a,double (*eq4)(double)); double Integration3D8(double*y,double h,int n); double Rating3D8(double *x,double h,int n,double b,double a,double (*eq4)(double)); double IntegrationGauss(double a,double b,double (*eq)(double)); double IntegrationLeftRectangle(double*y,double h,int n); double RatingLeftRectangle(double *x,double h,int n,double b,double a,double (*eq1)(double)); double IntegrationRightRectangle(double*y,double h,int n); double RatingRightRectangle(double *x,double h,int n,double b,double a,double (*eq1)(double)); double IntegrationCentralRectangle(double*y,double h,int n); double RatingCentralRectangle(double *x,double h,int n,double b,double a,double (*eq2)(double)); double ratingIntegration; bool marker; SystemOfEquations*func; public: Operations(){marker=false;}; Operations(double (*eq)(double,double)); Operations(double (*eq)(double)); double DerivativePoint(double**u,int i,int j,int dN,double h,int n,int m);///матрица производных dN-го порядка(двумерный массив) double DerivativePoint(Matrix*u,int i,int j,int dN,double h);///матрица производных dN-го порядка(класс) void DerivativeMatrix(double**u,double**du,int dN,double h,int n,int m); double DerivativeBorder(double X,double*x,double*y,int n); double Integration(double a,double b,int n,double (*eq)(double),double (*eqd)(double),int WI); //double Integration(double a,double b,double (*eq)(double),double (*eqd)(double)); double RatingIntegration(); //double Integration(double a,double b,Function*eq,WayIntegration WI); //double Integration(double a,double b,Function*eq); //double Evalf(Matrix*u,int i,int j,int dN,double h); double A(double**u,int i,int j,double h);///оператор Лапласса(матрица вторых произвдных) double Norm(int n,int m,double**rn,double h);///норма матрицы /*template <int n, int m> double Norm(double (&rn)[n][m],double h);*/ double DerivativePoint(double*u,int i,int dN,double h);///вектор производных dN-го порядка(двумерный массив) double DerivativePoint(Vector*u,int i,int dN,double h);///вектор производных dN-го порядка(класс) virtual~Operations(){}; }; #endif // OPERATIONS_H_INCLUDED