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
b34b8f80c272c4f669a4f4037f7f388a7c0374c4
95362b04a313e50fc9bd123e71a45ed3a7616193
/GUI_Babel/slidingstackedwidget.h
cec9712a434acb85cf3b31ba58cf95459cbe6315
[]
no_license
yousuvic/cpp_babel
0557cb4686bb75c1b87da94aa0cab17fd2026ab9
bad263b5fd9bd327b6cec090e4f175146cf7525e
refs/heads/master
2021-01-24T17:50:32.683494
2015-11-17T10:48:20
2015-11-17T10:48:20
44,957,314
0
0
null
null
null
null
UTF-8
C++
false
false
1,630
h
slidingstackedwidget.h
#ifndef SLIDINGSTACKEDWIDGET_H #define SLIDINGSTACKEDWIDGET_H #include <QStackedWidget> #include <QEasingCurve> #include <QPropertyAnimation> #include <QParallelAnimationGroup> class SlidingStackedWidget : public QStackedWidget { Q_OBJECT public: //! This enumeration is used to define the animation direction enum t_direction { LEFT2RIGHT, RIGHT2LEFT, TOP2BOTTOM, BOTTOM2TOP, AUTOMATIC }; SlidingStackedWidget(QWidget *parent); ~SlidingStackedWidget(void); public slots: //! Some basic settings API void setSpeed(int speed); //animation duration in milliseconds void setAnimation(enum QEasingCurve::Type animationtype); //check out the QEasingCurve documentation for different styles void setVerticalMode(bool vertical = true); void setWrap(bool wrap); //wrapping is related to slideInNext/Prev;it defines the behaviour when reaching last/first page //! The Animation / Page Change API void slideInNext(); void slideInPrev(); void slideInIdx(int idx, enum t_direction direction = AUTOMATIC); signals: //! this is used for internal purposes in the class engine void animationFinished(void); protected slots: //! this is used for internal purposes in the class engine void animationDoneSlot(void); protected: //! this is used for internal purposes in the class engine void slideInWgt(QWidget * widget, enum t_direction direction = AUTOMATIC); QWidget *m_mainwindow; int m_speed; enum QEasingCurve::Type m_animationtype; bool m_vertical; int m_now; int m_next; bool m_wrap; QPoint m_pnow; bool m_active; QList<QWidget*> blockedPageList; }; #endif // SLIDINGSTACKEDWIDGET_H
40e5f19dc814f8e6651556b6811dae7ad59ed817
fd4bf36d93abfceea2d9947017902757535a2940
/protocol/jsonprotocol.cpp
46f3169fb8dca58f82142ed87398cbe64254cbf2
[]
no_license
samcrow/ColonyServer-v2
cd81d07e8048e3d59661e627742e0858d6833edd
20326334aa01e4093b08b32a19839d9af576bd29
refs/heads/master
2021-01-22T06:54:49.983222
2012-08-17T02:47:18
2012-08-17T02:47:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,273
cpp
jsonprotocol.cpp
#include "jsonprotocol.hpp" JSONProtocol::JSONProtocol(QObject *parent) : Protocol(parent) { } void JSONProtocol::respondTo(QByteArray request) { bool ok; QJson::Parser parser; QVariant json = parser.parse(request, &ok); if(!ok) { printError("Request was not valid JSON"); return; } QVariantMap jsonMap = json.toMap(); respondToRequest(jsonMap); } void JSONProtocol::respondToRequest(QVariantMap request) { QString requestString = request.value("request").toString(); if(requestString.isEmpty()) { printError("No request specified."); return; } if(requestString == "get colonies") { printColonies(); return; } else if(requestString == "update colony") { QVariantMap colonyJson = request.value("colony").toMap(); updateColony(colonyJson); } else { printError("Unrecognized request \""+requestString+"\""); } } void JSONProtocol::printColonies() { QVariantMap json; QVariantList colonyList; for(int i = 0, max = model->length(); i < max; i++) { Colony *colony = model->at(i); QVariant colonyJson = colony->toVariant(); colonyList.append(colonyJson); } json.insert("colonies", colonyList); json.insert("status", "success"); printJSON(json); } void JSONProtocol::updateColony(QVariantMap colonyJson) { int id = colonyJson.value("id").toInt(); Colony *colonyWithId = model->getColonyById(id); if(colonyWithId != NULL) { //Colony with this ID exists; update it //Change only the values that were given colonyWithId->setX(colonyJson.value("x", colonyWithId->getX()).toDouble()); colonyWithId->setY(colonyJson.value("y", colonyWithId->getY()).toDouble()); colonyWithId->setVisited(colonyJson.value("visited", colonyWithId->isVisited()).toBool()); colonyWithId->setActive(colonyJson.value("active", colonyWithId->isActive()).toBool()); } else { //Add a new colony Colony *colony = new Colony(colonyJson.value("id", 0).toInt(), 0, 0, false); //Ensure that everything's set to zero colony->setX(0); colony->setY(0); colony->setVisited(false); colony->setActive(false); colony->setX(colonyJson.value("x", colony->getX()).toDouble()); colony->setY(colonyJson.value("y", colony->getY()).toDouble()); colony->setVisited(colonyJson.value("visited", colony->isVisited()).toBool()); colony->setActive(colonyJson.value("active", colony->isActive()).toBool()); model->appendColony(colony); } } void JSONProtocol::printSuccess() { QVariantMap json; json.insert("status", "success"); printJSON(json); } void JSONProtocol::printError(QString message) { qWarning() << "JSON protocol error:" << message; QVariantMap json; json.insert("status", "failure"); json.insert("message", message); printJSON(json); } void JSONProtocol::printJSON(QVariantMap json) { QJson::Serializer serializer; serializer.setIndentMode(QJson::IndentCompact); QByteArray jsonText = serializer.serialize(json); io->write(jsonText); io->write("\n");//Print a newline to finish it }
a2bf658d3a54d200d9802f8132dfbca3644f4e28
5d76218fc8ec450c416b592e0390b0ea3e425501
/include/PriorityScheduler.h
9f8cf348a6ce01f720a810a185a387d43fcd2308
[]
no_license
darioushs/OS_P1
998ba60b30068f631806a35ad3ce61a2dff2262f
d15db0abe92f4665cbacbc2788bf6fadeb4e50cf
refs/heads/master
2021-09-12T17:52:36.953128
2018-04-19T13:29:47
2018-04-19T13:29:47
126,091,541
0
0
null
null
null
null
UTF-8
C++
false
false
578
h
PriorityScheduler.h
#ifndef PIORITYSCHEDULER_H #define PIORITYSCHEDULER_H #include "IScheduler.h" #include "PCB.h" #include "Dispatcher.h" class PriorityScheduler { private: vector<PCB*> readyQueue; CPU* cpu; int getHighestPriorityProcessIndex(); Dispatcher dispatcher; public: PriorityScheduler(); PriorityScheduler(RAM* ram, HDD* hdd, CPU* cpu); void addPcb(PCB* pcb); int loadNextProcess(); // Return a program counter to tell CPU where to start executing code from void signalProcessEnd(); void printAllPcbs(); int getNumberOfPcbs(); }; #endif
510f223f6a53c9c9103ece826c3c2d7c5f9b0f93
3f8b288711bb5adc2394171507f54c62dc60c601
/atcoder/abc/132b.cpp
261e0993de611efe504ce493e9ee75f7927c144a
[]
no_license
pontsuyo/procon
65df6356f0ea1cfb619898d9e8cc6e326c0586e7
804aaeb526946172a8f41e0619712f5989b6b613
refs/heads/master
2021-06-15T15:13:04.441761
2021-03-20T05:26:54
2021-03-20T05:26:54
175,234,672
1
0
null
null
null
null
UTF-8
C++
false
false
447
cpp
132b.cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i,n) for(int i=0;i<n;++i) #define MOD 1000000007 int main(){ int n; cin >> n; vector<int> p(n); rep(i, n){ cin >> p[i]; } int cnt= 0; rep(i, n-2){ int a = p[i],b=p[i+1],c=p[i+2]; if((a>b && b>c) || (a<b && b<c)){ cnt++; } } printf("%d\n", cnt); return 0; }
c3da30a11d9d12243904f5a7f531fd4f804652b2
bedcaf173259517ebb4ec24e50c972d0521dce49
/include/PCU.h
231b2eb7d0b4e0d1ad71c45731ad4707d2d109c9
[]
no_license
AbhayG27/RTSim
f1b9926d6c89f37d03a68f890623cf8e841d1b8d
4a50a8a2c79892c0480e83ef1ed3eb4f3a0bc855
refs/heads/master
2021-01-13T12:53:49.647222
2016-04-06T07:31:41
2016-04-06T07:31:41
54,589,240
0
0
null
null
null
null
UTF-8
C++
false
false
218
h
PCU.h
#pragma once #include <entities.h> #define RAY_PRECOMPUTE_LATENCY 10 class PCU { public: PCU(); ~PCU(); int precompute(ray r,precomputedRay& pr); int precompute(ray r[], precomputedRay pr[],int size); private: };
cb7de8ca303abba50ae512287ae512a4cf66e677
85ca451735cddc7205ac4c939f05cd6a5de50d76
/src/impl/RowStore.cpp
c0afd8eb3cc4729f4c60d928d53ba5f5cb8b24c3
[]
no_license
pay632006/database
86d6c03b1fed5844cd583130766cf5716a17bb5f
1d278c1a5f50fb27ac6f9e8ae888ab5c8f97464e
refs/heads/master
2021-08-15T08:04:31.508671
2017-11-14T14:02:01
2017-11-14T14:02:01
111,126,242
0
0
null
null
null
null
UTF-8
C++
false
false
2,600
cpp
RowStore.cpp
#include "impl/RowStore.hpp" using namespace dbms; std::size_t get_alignment_requirement(const Attribute &attr) { switch (attr.type) { case Attribute::TY_Int: case Attribute::TY_Float: case Attribute::TY_Double: return attr.size; case Attribute::TY_Char: return 1; case Attribute::TY_Varchar: return sizeof(Varchar); default: dbms_unreachable("unknown attribute type"); } } RowStore::~RowStore() { free(data_); free(offsets_); } RowStore RowStore::Create_Naive(const Relation &relation) { RowStore row_store; row_store.num_attributes_ = relation.size(); row_store.offsets_ = static_cast<decltype(offsets_)>(malloc(relation.size() * sizeof(*offsets_))); /* Compute the required size of a row. Remember that there can be padding. */ std::size_t row_size = 0; std::size_t max_alignment = 0; for (auto attr : relation) { std::size_t elem_size; std::size_t elem_alignment; switch (attr.type) { case Attribute::TY_Int: case Attribute::TY_Float: case Attribute::TY_Double: elem_size = elem_alignment = attr.size; break; case Attribute::TY_Char: elem_size = attr.size; elem_alignment = 1; break; case Attribute::TY_Varchar: elem_size = elem_alignment = sizeof(void*); break; default: dbms_unreachable("unknown attribute type"); } max_alignment = std::max(elem_alignment, max_alignment); if (row_size % elem_alignment) { // add padding bytes for alignment std::size_t padding = elem_alignment - row_size % elem_alignment; row_size += padding; } row_store.offsets_[attr.offset()] = row_size; row_size += elem_size; } if (row_size % max_alignment) row_size += max_alignment - row_size % max_alignment; row_store.row_size_ = row_size; return row_store; } RowStore RowStore::Create_Optimized(const Relation &relation) { /* TODO 1.2.3 */ dbms_unreachable("Not implemented."); } RowStore RowStore::Create_Explicit(const Relation &relation, std::size_t *order) { /* TODO 1.2.3 */ dbms_unreachable("Not implemented."); } void RowStore::reserve(std::size_t new_cap) { /* TODO 1.2.1 */ dbms_unreachable("Not implemented."); } RowStore::iterator RowStore::append(std::size_t n_rows) { /* TODO 1.2.2 */ dbms_unreachable("Not implemented."); }
0008270d11bc3cf0f64633da18dcd9abc5da1524
af4c4428640b4b73177cdad56ce30af4fc9eaf87
/ExtendedPage/ExtendedPage.h
1a04fed38f16c73911d69c19b28b8a5a2cddd8ea
[]
no_license
geminik23/LabWRL
1fa9df9a5200187a7550da8c6ba884b0b53e8721
19dfa20830edff7d9d945d09ff7c001b050754c0
refs/heads/master
2021-01-11T15:04:11.883502
2017-03-11T03:43:55
2017-03-11T03:43:55
80,291,343
0
0
null
null
null
null
UTF-8
C++
false
false
6,628
h
ExtendedPage.h
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 8.01.0620 */ /* at Tue Jan 19 12:14:07 2038 */ /* Compiler settings for C:\Users\gemin\AppData\Local\Temp\ExtendedPage.idl-a6da0596: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0620 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ /* @@MIDL_FILE_HEADING( ) */ #pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 475 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif /* __RPCNDR_H_VERSION__ */ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __ExtendedPage_h__ #define __ExtendedPage_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef ____x_ABI_CExtendedPage_CIExtendedPage_FWD_DEFINED__ #define ____x_ABI_CExtendedPage_CIExtendedPage_FWD_DEFINED__ typedef interface __x_ABI_CExtendedPage_CIExtendedPage __x_ABI_CExtendedPage_CIExtendedPage; #ifdef __cplusplus namespace ABI { namespace ExtendedPage { interface IExtendedPage; } /* end namespace */ } /* end namespace */ #endif /* __cplusplus */ #endif /* ____x_ABI_CExtendedPage_CIExtendedPage_FWD_DEFINED__ */ /* header files for imported files */ #include "inspectable.h" #include "windows.ui.xaml.controls.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_ExtendedPage_0000_0000 */ /* [local] */ #if defined(__cplusplus) } #endif // defined(__cplusplus) #include <Windows.Foundation.h> #if !defined(__windows2Eui2Examl2Econtrols_h__) #include <Windows.UI.Xaml.Controls.h> #endif // !defined(__windows2Eui2Examl2Econtrols_h__) #if defined(__cplusplus) extern "C" { #endif // defined(__cplusplus) #if !defined(____x_ABI_CExtendedPage_CIExtendedPage_INTERFACE_DEFINED__) extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_ExtendedPage_IExtendedPage[] = L"ExtendedPage.IExtendedPage"; #endif /* !defined(____x_ABI_CExtendedPage_CIExtendedPage_INTERFACE_DEFINED__) */ /* interface __MIDL_itf_ExtendedPage_0000_0000 */ /* [local] */ extern RPC_IF_HANDLE __MIDL_itf_ExtendedPage_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_ExtendedPage_0000_0000_v0_0_s_ifspec; #ifndef ____x_ABI_CExtendedPage_CIExtendedPage_INTERFACE_DEFINED__ #define ____x_ABI_CExtendedPage_CIExtendedPage_INTERFACE_DEFINED__ /* interface __x_ABI_CExtendedPage_CIExtendedPage */ /* [uuid][object] */ /* interface ABI::ExtendedPage::IExtendedPage */ /* [uuid][object] */ EXTERN_C const IID IID___x_ABI_CExtendedPage_CIExtendedPage; #if defined(__cplusplus) && !defined(CINTERFACE) } /* end extern "C" */ namespace ABI { namespace ExtendedPage { MIDL_INTERFACE("1ee430d8-6ca2-4d6f-ba58-da40df9f12d2") IExtendedPage : public IInspectable { public: }; extern const __declspec(selectany) IID & IID_IExtendedPage = __uuidof(IExtendedPage); } /* end namespace */ } /* end namespace */ extern "C" { #else /* C style interface */ typedef struct __x_ABI_CExtendedPage_CIExtendedPageVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( __x_ABI_CExtendedPage_CIExtendedPage * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( __x_ABI_CExtendedPage_CIExtendedPage * This); ULONG ( STDMETHODCALLTYPE *Release )( __x_ABI_CExtendedPage_CIExtendedPage * This); HRESULT ( STDMETHODCALLTYPE *GetIids )( __x_ABI_CExtendedPage_CIExtendedPage * This, /* [out] */ ULONG *iidCount, /* [size_is][size_is][out] */ IID **iids); HRESULT ( STDMETHODCALLTYPE *GetRuntimeClassName )( __x_ABI_CExtendedPage_CIExtendedPage * This, /* [out] */ HSTRING *className); HRESULT ( STDMETHODCALLTYPE *GetTrustLevel )( __x_ABI_CExtendedPage_CIExtendedPage * This, /* [out] */ TrustLevel *trustLevel); END_INTERFACE } __x_ABI_CExtendedPage_CIExtendedPageVtbl; interface __x_ABI_CExtendedPage_CIExtendedPage { CONST_VTBL struct __x_ABI_CExtendedPage_CIExtendedPageVtbl *lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CExtendedPage_CIExtendedPage_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define __x_ABI_CExtendedPage_CIExtendedPage_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define __x_ABI_CExtendedPage_CIExtendedPage_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define __x_ABI_CExtendedPage_CIExtendedPage_GetIids(This,iidCount,iids) \ ( (This)->lpVtbl -> GetIids(This,iidCount,iids) ) #define __x_ABI_CExtendedPage_CIExtendedPage_GetRuntimeClassName(This,className) \ ( (This)->lpVtbl -> GetRuntimeClassName(This,className) ) #define __x_ABI_CExtendedPage_CIExtendedPage_GetTrustLevel(This,trustLevel) \ ( (This)->lpVtbl -> GetTrustLevel(This,trustLevel) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* ____x_ABI_CExtendedPage_CIExtendedPage_INTERFACE_DEFINED__ */ /* interface __MIDL_itf_ExtendedPage_0000_0001 */ /* [local] */ #ifdef __cplusplus namespace ABI { namespace ExtendedPage { class ExtendedPage; } /*ExtendedPage*/ } #endif #ifndef RUNTIMECLASS_ExtendedPage_ExtendedPage_DEFINED #define RUNTIMECLASS_ExtendedPage_ExtendedPage_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_ExtendedPage_ExtendedPage[] = L"ExtendedPage.ExtendedPage"; #endif /* interface __MIDL_itf_ExtendedPage_0000_0001 */ /* [local] */ extern RPC_IF_HANDLE __MIDL_itf_ExtendedPage_0000_0001_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_ExtendedPage_0000_0001_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
1f93c79f34e572a7f9736291658e49326d85262e
9b1ad74d4aeddffe57df71b550fa1075eb980808
/pausewindow.cpp
9ea0187059d485ffc69b3174f6b929141da8afac
[]
no_license
TwinIsland-CCC/RhythmGame_Project_1_00
85f99d9167af08b5ecc29cdd47d881c7becceed6
cbf2e06e89fe53e8a4a190fdefac2822ed073b1c
refs/heads/main
2023-04-24T02:31:35.979145
2021-05-09T17:07:49
2021-05-09T17:07:49
359,840,823
2
0
null
null
null
null
UTF-8
C++
false
false
1,301
cpp
pausewindow.cpp
#include "pausewindow.h" #include "ui_pausewindow.h" PauseWindow::PauseWindow(QWidget *parent) : QWidget(parent), ui(new Ui::PauseWindow) { ui->setupUi(this); movie.setFileName(":/test/cat.gif");//已经在类中声明了movie ui->label->setMovie(&movie); movie.start(); meow = new QMediaPlayer; QMediaPlaylist* list2 = new QMediaPlaylist; list2->addMedia(QUrl("qrc:/mus/sounds/sounds/meow.mp3")); list2->setPlaybackMode(QMediaPlaylist::CurrentItemOnce); meow->setPlaylist(list2); meow->setVolume(100); connect(ui->label,&mylabel::clicked,[=](){ meow->stop(); meow->play(); }); connect(ui->ContinueBtn,&QPushButton::clicked,[=](){ emit game_continue(); }); connect(ui->ExitBtn,&QPushButton::clicked,[=](){ emit game_exit(); }); connect(ui->RestartBtn,&QPushButton::clicked,[=](){ emit game_restart(); }); } PauseWindow::~PauseWindow() { delete ui; } void PauseWindow::keyPressEvent(QKeyEvent *event) { if(!event->isAutoRepeat()) { if(event->key() == Qt::Key_Return) { emit ui->ContinueBtn->clicked(); } else if(event->key() == Qt::Key_Escape) { emit ui->ContinueBtn->clicked(); } } }
11cdac8dbef716cbc3c62ffcac3e7ab0efd677ec
111c460e6a2f4dd6508845dcb24da498bcf6e2a0
/AT&BT/BT/BT.ino
4ec3b51c9925251e7747ef1c068877d840763858
[]
no_license
jameshuang304/MakeNTU2017_MedCube
ea4f2ba84dcb19ad4c6001d140759d4455b73252
fa10be03483203cbcd3b9d7a81595910c91d943a
refs/heads/master
2020-03-15T04:24:17.242625
2017-02-28T06:29:26
2017-02-28T06:29:26
131,964,273
0
1
null
null
null
null
UTF-8
C++
false
false
2,768
ino
BT.ino
#include <SoftwareSerial.h> // 引用程式庫 #define PRINT // 定義連接藍牙模組的序列埠 SoftwareSerial BT(8, 9); // 接收腳, 傳送腳 char val; // 儲存接收資料的變數 const int xPin = A0; const int yPin = A1; const int buttonPin = 5; const int xThreshold[7] = { 147, 294, 441, 589, 736, 883, 1030 }; void setup() { Serial.begin(9600); // 與電腦序列埠連線 Serial.println("BT is ready!"); pinMode(3, OUTPUT); pinMode(xPin, INPUT); pinMode(yPin, INPUT); pinMode(buttonPin, INPUT); digitalWrite(3, HIGH); // 設定藍牙模組的連線速率 // 如果是HC-05,請改成38400 BT.begin(115200); } void loop() { // 若收到「序列埠監控視窗」的資料,則送到藍牙模組 int xVal = analogRead(xPin); int yVal = analogRead(yPin); bool fire = digitalRead(buttonPin); #ifdef PRINT Serial.print("X: "); Serial.println(xVal); Serial.print("Y: "); Serial.println(yVal); Serial.print("Fire: "); Serial.println(fire); Serial.println("----------------"); #endif uint8_t sendByte = 0; if (fire == 1) sendByte = 0b10000000; if (xVal <= xThreshold[3]) { //0xx if (xVal <= xThreshold[1]) { //00x if (xVal >= xThreshold[0]) //001 sendByte = sendByte | 0b00010000; } else { //01x sendByte = sendByte | 0b00100000; if (xVal >= xThreshold[2]) //011 sendByte = sendByte | 0b00010000; } } else { //1xx sendByte = sendByte | 0b01000000; if (xVal <= xThreshold[5]) { //10x if (xVal >= xThreshold[4]) //101 sendByte = sendByte | 0b00010000; } else { //11x sendByte = sendByte | 0b00100000; if (xVal >= xThreshold[6]) //111 sendByte = sendByte | 0b00010000; } } if (yVal >= 512) sendByte = sendByte | 0b00001000; yVal = abs(yVal - 512); //sendByte = sendByte | ((yVal + 73) / 36); if (yVal <= xThreshold[3] / 2) { //0xx if (yVal <= xThreshold[1] / 2) { //00x if (yVal >= xThreshold[0] / 2) //001 sendByte = sendByte | 0b00000001; } else { //01x sendByte = sendByte | 0b00000010; if (yVal >= xThreshold[2] / 2) //011 sendByte = sendByte | 0b00000001; } } else { //1xx sendByte = sendByte | 0b00000100; if (yVal <= xThreshold[5] / 2) { //10x if (yVal >= xThreshold[4] / 2) //101 sendByte = sendByte | 0b00000001; } else { //11x sendByte = sendByte | 0b00000010; if (yVal >= xThreshold[6] / 2) //111 sendByte = sendByte | 0b00000001; } } BT.write(sendByte); Serial.println(sendByte); delay(50); // 若收到藍牙模組的資料,則送到「序列埠監控視窗」 while (BT.available()) { val = BT.read(); Serial.print(val); } }
43844f5581a132a61b1220e3ec7458b8ab7c6a22
e72f7d9e44e258495c04969cbcc50aeee437169a
/widget.cpp
a868c4bb380d2c1ccfc413e2a83c774277c87334
[]
no_license
metaluga/Circle
510e9ecadd2ec9caed9b493a3b84c5326a1adae4
3f81a505c1dbbe9aa34ca8963ba001486795ee94
refs/heads/master
2020-03-09T17:32:06.306921
2018-04-10T09:55:01
2018-04-10T09:55:01
128,910,773
0
0
null
null
null
null
UTF-8
C++
false
false
1,501
cpp
widget.cpp
#include "widget.h" #include "ui_widget.h" #include <QThread> #include <iostream> Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); } Widget::~Widget() { delete ui; } void Widget::setPosition(int x, int y) { this->x = x; this->y = y; // paintEvent(x,y); } /* Метод, в котором происходит рисование * */ void Widget::paintEvent(int x, int y) { QPainter painter(this); // Создаём объект отрисовщика // Устанавливаем кисть абриса painter.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap)); // Если ничего не выбрано, то отрисовываем белый круг painter.setBrush(QBrush(Qt::white, Qt::SolidPattern)); painter.drawEllipse(100+x, 80+y, 150, 150); } void Widget::paintEvent(QPaintEvent *event) { Q_UNUSED(event); QPainter painter(this); // Создаём объект отрисовщика // Устанавливаем кисть абриса painter.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap)); // Если ничего не выбрано, то отрисовываем белый круг painter.setBrush(QBrush(Qt::white, Qt::SolidPattern)); painter.drawEllipse(100, 50, 150, 150); painter.drawEllipse(100, 60, 150, 150); painter.drawEllipse(100, 80, 150, 150); }
a56cfb646b75f82fdb22ebc3560f937fcb81e74c
0280d3e052ac227d778f6a1dbee1b0bdd1678407
/A2OJ Code Battle 2017/Round 2/B. Merge Grids.cpp
7df80d0bf29dc1fb2df8c9001cf897a51952665e
[]
no_license
oknashar/Problem-Solving
5d9da159ab5190fcdcff9fc229a25c0f4090801c
07656a0ace44d1933f1212ecc4dc99d7813de2bf
refs/heads/master
2022-08-15T12:34:18.820659
2020-05-24T23:28:41
2020-05-24T23:28:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,205
cpp
B. Merge Grids.cpp
/* You are given two grids of size 3 × 3. In both grids, each cell either is empty (denoted by '.') or it contains a sloping line '\' or '/'. The two grids are transparent. Their only visible parts are sloping lines in some cells, mentioned in the previous paragraph. We put one grid on the other, obtaining a new grid of size 3 × 3, where we see only sloping lines from the two initial grids. Your task is to print the new grid to the output. If both corresponding cells in the initial grids were empty, the new cell is empty as well (we don't see any lines there, you print a '.' character). If only one of two cells contained a line, we see that line now in the new cell - the same if both cells contained the same line (e.g. both contained '\'). But if the two cells contained lines with different slopes ('\' and '/'), now we see them both in the new grid, so you should print 'X' for that cell (an uppercase 'X' character). Input The input starts with the description of the first grid, which is 3 consecutive lines, each line contains exactly 3 characters, each character will be either '.', '/' or '\'. Followed by an empty line, then 3 more lines in the exact same format like the above, which are the description of the second grid. Output Print 3 lines, with exactly 3 characters in each line, which are the description of the output grid as described above. Each character should be either '.', '/', '\' or 'X'. Example Input //. ./. /./ /.\ ./. \/\ Output //\ ./. X/X */ #include<bits/stdc++.h> using namespace std; #define solved first #define timeP second.first #define id second.second int main(){ string g1[3],g2[3]; for(int i=0; i<3; i++) cin>>g1[i]; for(int i=0; i<3; i++) cin>>g2[i]; for(int i=0; i<3; i++){for(int j=0; j<3; j++){ if(g1[i][j] == g2[i][j]){ cout<<g1[i][j]; } else{ if(g1[i][j] == '.') cout<<g2[i][j]; else if(g2[i][j] == '.') cout<<g1[i][j]; else if((g1[i][j] == '/' && g2[i][j] == '\\') || (g2[i][j] == '/' && g1[i][j] == '\\')) cout<<'X'; } } cout<<endl; } return 0; }
7349e323ffe5d1dc446b0f2b3d46aed1076b8f5b
da86d9f9cf875db42fd912e3366cfe9e0aa392c6
/2019/solutions/D/BIG-Sofia/sequence.cpp
b324744446d46bd988211c07b63f73d02667e288
[]
no_license
Alaxe/noi2-ranking
0c98ea9af9fc3bd22798cab523f38fd75ed97634
bb671bacd369b0924a1bfa313acb259f97947d05
refs/heads/master
2021-01-22T23:33:43.481107
2020-02-15T17:33:25
2020-02-15T17:33:25
85,631,202
2
4
null
null
null
null
UTF-8
C++
false
false
833
cpp
sequence.cpp
#include<bits/stdc++.h> using namespace std; long long chislaDoToziRed(long long b){ long long ans=0,o=1; for(int i=1;i<b;i++){ ans+=o; o+=2; } return ans; } int main(){ long long chislo,sresht,red,a,i; bool n=false,c=false; cin>>chislo>>sresht; a=sresht; if(a%2==0){ n=true; }else{ c=true; } a--; for(red=chislo+1;;red++){ if(a==0 && red==chislo+1){ red--; n=true; c=false; break; } a-=2; if(a<=0){ break; } } if(c){ cout<<chislaDoToziRed(red)+chislo+2<<"\n"; }else if(n){ cout<<chislaDoToziRed(red)+chislo<<"\n"; } return 0; }
bdd4d0f8dbbcc4dc4350a60f8d965f660926e2fc
caa7e2c4f2ee37cc41ac0e63e31be68400ca434c
/Sequence/Base.h
8e255788d6c2b0acd4febd4f42cbd64bb6adfc02
[]
no_license
13jk092koizumi/MyDxLibGame
203759adf2ad2f68c068565aa95df2ce3fe343ad
2dbb37279cc10c7842a1531bddde13fd5ead83e0
refs/heads/master
2021-01-19T00:54:57.891518
2016-05-12T00:00:23
2016-05-12T00:00:23
60,909,976
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
273
h
Base.h
#ifndef INCLUDED_SEQUENCE_BASE_H #define INCLUDED_SEQUENCE_BASE_H namespace Sequence { class Base { public: virtual ~Base() {} //何もしない //TODO:共通の関数を書く virtual Base* update( Base* ) = 0; //描画関数 }; } //namespace Sequence #endif
7547e117111fd525b9fd1c8084220c90d372abd7
4ad841857e74b1a018c0bbb668c3a9901cfe3293
/96. Unique Binary Search Trees.cpp
5409ea547a32794fcb21ab9e6fd5e646dbf50527
[]
no_license
MuVen/LeetCode
978ccdf434d7de5d9200c1d376a24b9d80fe1582
bef228fe298da3fe1c337d6b7e7f0947989cc9e3
refs/heads/master
2020-08-05T06:03:07.519901
2019-12-04T20:45:19
2019-12-04T20:45:19
212,422,736
0
0
null
null
null
null
UTF-8
C++
false
false
498
cpp
96. Unique Binary Search Trees.cpp
class Solution { vector<unsigned long long int> cache; public: int catalan(unsigned long long int n){ if(n <= 1) return 1; if(cache[n] != 0) return cache[n]; unsigned long long int res = 0; for(int i = 0; i < n; i++) res += catalan(i)*catalan(n-i-1); return cache[n] = res; } int numTrees(int n) { cache.resize(n+1, 0); return catalan(n); } };
c73c1402e6f3beffbae53686d3af60d5b699991f
2e0472397ec7145d50081d4890eb0af2323eb175
/Code/src/OE/Graphics/3D/Light.cpp
30cf7857b9136b39b543887221566db97b8e0dd6
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
mlomb/OrbitEngine
5c471a853ea555f0738427999dd9cef3a1c90a01
41f053626f05782e81c2e48f5c87b04972f9be2c
refs/heads/master
2021-09-09T01:27:31.097901
2021-08-28T16:07:16
2021-08-28T16:07:16
99,012,019
26
3
null
null
null
null
UTF-8
C++
false
false
404
cpp
Light.cpp
#include "OE/Graphics/3D/Light.hpp" namespace OrbitEngine { namespace Graphics { /* Point Light */ ShaderDefinitions PointLight::getRequiredDefinitions() { // TODO concat with Light::getRequiredDefinitions return { "LIGHT_POINT" }; } ShaderDefinitions DirectionalLight::getRequiredDefinitions() { // TODO concat with Light::getRequiredDefinitions return { "LIGHT_DIRECTIONAL" }; } } }
5e95317e9d05f85b443f7b664385779521ed8f8a
c558a52d26afb8abcab5ab58925574391d14d981
/inc/TicTac.h
27811efeec39d9dc5e3fed86c4d52295280aa3ac
[]
no_license
ChristianChaumette-Brown/tictactoe
643c8d06af4fd1e3758546ebc7100ba49e67e7c3
3ed494bdcd3266d3a0205421c9446d2ec2c2790b
refs/heads/master
2021-01-14T03:53:08.283375
2020-08-21T18:59:27
2020-08-21T18:59:27
242,591,638
0
0
null
null
null
null
UTF-8
C++
false
false
575
h
TicTac.h
#ifndef MYLIB #define MYLIB #include <string> #include <server.h> #include <Cell.h> #include <random> class TicTac{ public: TicTac(); //constructor TicTac(const TicTac&); //copy constructor int dim; int counter; int winner; bool computerP; //int col; void start(); std::vector<Cell> Board; std::vector<int> oBoard; void neighborhood(); ucm::json getBoard(); ucm::json cellCheck(int, int); ucm::json winCon(); ucm::json reset(); ucm::json aiPs(); int aiPlay(); // ~TicTac(); //destructor }; #endif
5a83a19bcfa5a98fd08e5fb794627fc64a9857c3
fdf9c824976bafb805a0f33dc35f8689893d2f20
/examples/wip/main4.cpp
58913e7972bcdf2d635fcce69650c0ee0750769b
[ "CC0-1.0" ]
permissive
ThePhD/embed
99319d2328900588e70089508af4fd63363b932a
5413c81ea33063233941ed88aa4667f3457433e0
refs/heads/main
2022-05-17T14:00:36.374780
2022-05-01T16:13:05
2022-05-01T16:13:05
218,390,512
105
8
null
null
null
null
UTF-8
C++
false
false
122
cpp
main4.cpp
#include <phd/embed.hpp> int main () { constexpr std::span<const char> data = std::embed("foo.txt"); return data[0]; }
148cde306b84c28c4063cdb9551c4a1d792252b1
69bb6c6945680394ca7200fe25490817bb382faa
/test.cpp
9700ac44384725d136a16c1e8f75bc5d9109490e
[]
no_license
Bossones/StPrataPLC
22d6068e7e0d2ce03570f90400daa80264be2ef4
9fa1c6f39d08cdd3d1149936f8c4d23c415eeb23
refs/heads/master
2020-06-24T07:50:17.735918
2019-11-10T18:39:10
2019-11-10T18:39:10
198,902,358
0
0
null
null
null
null
UTF-8
C++
false
false
1,761
cpp
test.cpp
//prgramm from Steven Prata's book "Programming language C++" #include <iostream> #include <string> #include <vector> #include <cstring> #include <ctime> #include <fstream> #include <cstdlib> #include <cctype> #include <array> using namespace std; const short SIZE = 300; struct bop { string fullname; string title; string bopname; short preference; }; void showmenu() { cout << "please, choose yor choise: " << endl; cout << "a. display by name b. display by title" << endl; cout << "c. display by bopname d. display by preference" << endl; cout << "q. quit" << endl; } int main() { bop hui[3]; char ch; for (int i = 0; i < 3; i++){ cout << "Please, enter fullname: "; getline(cin, hui[i].fullname); cout << "Please, enter title: "; getline(cin, hui[i].title); cout << "Please, enter bopname: "; getline(cin, hui[i].bopname); cout << "Please, enter preference 1 or 2 or 3: "; cin >> hui[i].preference; cin.get(); } showmenu(); while (cin.get(ch)) { if (ch == 'a') for (int i = 0; i < 3; i++) {cout << hui[i].fullname << endl;} else if (ch == 'b') for (int i = 0; i < 3; i++) {cout << hui[i].title << endl;} else if (ch == 'c') for (int i = 0; i < 3; i++) {cout << hui[i].bopname << endl;} else if (ch == 'd') { for (int i = 0; i < 3; i++) { if (hui[i].preference == 0) cout << hui[i].fullname << endl; else if (hui[i].preference == 1) cout << hui[i].title << endl; else cout << hui[i].bopname << endl; } } else if (ch == 'q') { cout << "Thanks for using this shit" << endl; break; } if (ch != '\n') { cout << "Try again :)" << endl; showmenu(); } } return 0; }
a1c13066f8a1939036ee5ea351b3a0ed4362b85c
9c875e2e2a425a62ee0ffb148e701342c142a029
/src/Saurobyte/Lua/LuaEnv_Engine.cpp
34bd1d1a477b1e2807f50b50bf5b4b0ac48cee0c
[ "MIT" ]
permissive
Symphonym/Saurobyte
4b80e587517d8108a7ac4d60f17ec7518a693c48
c4bc5afd4ac4353ed6cd9a201454fd14aa3aced2
refs/heads/master
2016-08-05T13:26:18.701701
2014-07-13T00:46:06
2014-07-13T00:46:06
17,995,418
19
2
null
null
null
null
UTF-8
C++
false
false
5,864
cpp
LuaEnv_Engine.cpp
/* The MIT License (MIT) Copyright (c) 2014 by Jakob Larsson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <Saurobyte/Lua/LuaEnv_Engine.hpp> #include <Saurobyte/LuaEnvironment.hpp> #include <Saurobyte/Engine.hpp> namespace Saurobyte { int LuaEnv_Engine::ChangeScene(LuaEnvironment &env) { // First arg is self if(env.readGlobal("SAUROBYTE_GAME")) { Engine *engine = env.readStack<Engine*>("Saurobyte_Engine"); std::string sceneName = env.readArg<std::string>(); engine->changeScene(sceneName.c_str()); } //Engine* engine = env.toObject<Engine*>(state, 1, "jl.Engine"); // Second argument is scene name //std::string sceneName = luaL_checkstring(state, 2); return 0; } int LuaEnv_Engine::DeleteScene(LuaEnvironment &env) { // First arg is self if(env.readGlobal("SAUROBYTE_GAME")) { Engine *engine = env.readStack<Engine*>("Saurobyte_Engine"); std::string sceneName = env.readArg<std::string>(); engine->getScenePool().deleteScene(sceneName.c_str()); } //Engine* engine = LuaEnvironment::convertUserdata<Engine>(state, 1, "jl.Engine"); /// Second argument is scene name //std::string sceneName = luaL_checkstring(state, 2); //lua_settop(state, 0); return 0; } int LuaEnv_Engine::GetActiveScene(LuaEnvironment &env) { // First arg is self if(env.readGlobal("SAUROBYTE_GAME")) { Engine *engine = env.readStack<Engine*>("Saurobyte_Engine"); Scene *activeScene = engine->getScenePool().getActiveScene(); if(activeScene == nullptr) env.pushNil(); else env.pushObject<Scene*>(activeScene, "Saurobyte_Scene"); } //Engine* engine = LuaEnvironment::convertUserdata<Engine>(state, 1, "jl.Engine"); //Scene *activeScene = engine->getScenePool().getActiveScene(); return 1; } int LuaEnv_Engine::GetTotalEntityCount(LuaEnvironment &env) { // First arg is self //Engine* engine = LuaEnvironment::convertUserdata<Engine>(state, 1, "jl.Engine"); if(env.readGlobal("SAUROBYTE_GAME")) { Engine *engine = env.readStack<Engine*>("Saurobyte_Engine"); env.pushArgs(engine->getEntityPool().getEntityCount()); } //lua_pushnumber(state, engine->getEntityPool().getEntityCount()); return 1; } int LuaEnv_Engine::MoveCamera(LuaEnvironment &env) { // First arg is self //Engine* engine = LuaEnvironment::convertUserdata<Engine>(state, 1, "jl.Engine"); if(env.readGlobal("SAUROBYTE_GAME")) { Engine *engine = env.readStack<Engine*>("Saurobyte_Engine"); // 2nd arg is X offset, 3rd arg is Y offset, 4th arg is Z offset float xOff = env.readArg<float>(); float yOff = env.readArg<float>(); float zOff = env.readArg<float>(); } //engine->getScenePool().getActiveScene()->getCamera().move(glm::vec3(xOff, yOff, zOff)); return 0; } int LuaEnv_Engine::GetWindowWidth(LuaEnvironment &env) { // First arg is self //Engine* engine = LuaEnvironment::convertUserdata<Engine>(state, 1, "jl.Engine"); if(env.readGlobal("SAUROBYTE_GAME")) { Engine *engine = env.readStack<Engine*>("Saurobyte_Engine"); env.pushArgs(engine->getWindow().getSize().x); } //lua_pushnumber(state, engine->getWindow().getSize().x); return 1; } int LuaEnv_Engine::GetWindowHeight(LuaEnvironment &env) { // First arg is self if(env.readGlobal("SAUROBYTE_GAME")) { Engine *engine = env.readStack<Engine*>("Saurobyte_Engine"); env.pushArgs(engine->getWindow().getSize().y); } //Engine* engine = LuaEnvironment::convertUserdata<Engine>(state, 1, "jl.Engine"); //lua_settop(state, 0); //lua_pushnumber(state, engine->getWindow().getSize().y); return 1; } void LuaEnv_Engine::exposeToLua(Engine *engine) { /*const luaL_Reg engineFuncs[] = { { "ChangeScene", ChangeScene }, { "DeleteScene", DeleteScene }, { "GetActiveScene", GetActiveScene }, { "GetTotalEntityCount", GetTotalEntityCount }, { "MoveCamera", MoveCamera }, { "GetWindowWidth", GetWindowWidth }, { "GetWindowHeight", GetWindowHeight }, { NULL, NULL } };*/ //engine->getLua().createClass("jl.Engine", engineFuncs); // LuaEnvironment &env = engine->getLua(); env.registerFunction({ "ChangeScene", ChangeScene }); env.registerFunction({ "DeleteScene", DeleteScene }); env.registerFunction({ "GetActiveScene", GetActiveScene }); env.registerFunction({ "GetTotalEntityCount", GetTotalEntityCount }); env.registerFunction({ "MoveCamera", MoveCamera }); env.registerFunction({ "GetWindowWidth", GetWindowWidth }); env.registerFunction({ "GetWindowHeight", GetWindowHeight }); env.pushObject<Engine*>(engine, "Saurobyte_Engine"); env.writeGlobal("SAUROBYTE_GAME"); // Create global engine object in Lua environment //LuaEnvironment &env = engine->getLua().getRaw(); //LuaEnvironment::pushObject<Engine>(state, engine, "jl.Engine"); //lua_setglobal(state, "engine"); } };
3ac486f7a416e7f035f95f3dc226f066aba88837
b6c985bd9f493135c4de109f3ad78d38a3059c65
/src/libgvar/Block1or2.cpp
6356120b61930ad2998e3d38c2991c2158b67476
[]
no_license
qjhart/qjhart.geostreams
4a80d85912cb6cdfb004017c841e3902f898fad5
7d5ec6a056ce43d2250553b99c7559f15db1d5fb
refs/heads/master
2021-01-10T18:46:48.653526
2015-03-19T00:13:33
2015-03-19T00:13:33
32,489,398
1
0
null
null
null
null
UTF-8
C++
false
false
1,434
cpp
Block1or2.cpp
/** * This file defines the functions for the class. */ #include "Gvar.h" namespace Gvar { Block1or2::Block1or2 (Block* block) { this->block = block ; Header* gvarHeader = block->getHeader() ; uint16 blockID = gvarHeader->blockId() ; int wordcount = gvarHeader->wordCount() ; uint16* unpacked = new uint16[MAX_BLOCK_SZ] ; unpack10(block->getData(), ((wordcount - 2) * 10)/8, unpacked) ; int Pixels = 0; int temp = 0; if(blockID == 1) { numOfLineDocs = 4 ; } else { numOfLineDocs = 3 ; } lineDoc = new LineDoc*[numOfLineDocs] ; for(int i = 0; i < numOfLineDocs; ++i) { lineDoc[i] = new LineDoc(unpacked, temp) ; Pixels = lineDoc[i]->lwords() ; temp += Pixels ; } delete [] unpacked ; }//Block1or2(Block*) Block1or2::~Block1or2 () { int blockID = block->getHeader()->blockId() ; for (int lineDocNo=0; lineDocNo<numOfLineDocs; lineDocNo++) { delete lineDoc[lineDocNo] ; } delete[] lineDoc ; }//~Block1or2() uint16* Block1or2::getData(int i) { return lineDoc[i]->getData(); } // uint16** Block1or2::getData() { // uint16** data; // data = new (uint16*)[numOfLineDocs]; // for(int i=0; i<numOfLineDocs; i++) { // data[i] = lineDoc[i]->getData(); // } // return data; // } int Block1or2::getDataLen(int i) { return lineDoc[i]->lpixls(); } }//namespace Gvar
fe58bdb509e1c5acc8666315fe5c5b6d988464ef
f7dc806f341ef5dbb0e11252a4693003a66853d5
/thirdparty/msdfgen/core/sdf-error-estimation.cpp
7c00c449a932ae6a90c7ed88063b00cc9ccab0bf
[ "LicenseRef-scancode-free-unknown", "MIT", "CC-BY-4.0", "OFL-1.1", "Bison-exception-2.2", "CC0-1.0", "LicenseRef-scancode-nvidia-2002", "LicenseRef-scancode-other-permissive", "GPL-3.0-only", "LicenseRef-scancode-unknown-license-reference", "Unlicense", "BSL-1.0", "Apache-2.0", "BSD-3-Clau...
permissive
godotengine/godot
8a2419750f4851d1426a8f3bcb52cac5c86f23c2
970be7afdc111ccc7459d7ef3560de70e6d08c80
refs/heads/master
2023-08-21T14:37:00.262883
2023-08-21T06:26:15
2023-08-21T06:26:15
15,634,981
68,852
18,388
MIT
2023-09-14T21:42:16
2014-01-04T16:05:36
C++
UTF-8
C++
false
false
8,703
cpp
sdf-error-estimation.cpp
#include "sdf-error-estimation.h" #include <cmath> #include "arithmetics.hpp" namespace msdfgen { void scanlineSDF(Scanline &line, const BitmapConstRef<float, 1> &sdf, const Projection &projection, double y, bool inverseYAxis) { if (!(sdf.width > 0 && sdf.height > 0)) return line.setIntersections(std::vector<Scanline::Intersection>()); double pixelY = clamp(projection.projectY(y)-.5, double(sdf.height-1)); if (inverseYAxis) pixelY = sdf.height-1-pixelY; int b = (int) floor(pixelY); int t = b+1; double bt = pixelY-b; if (t >= sdf.height) { b = sdf.height-1; t = sdf.height-1; bt = 1; } bool inside = false; std::vector<Scanline::Intersection> intersections; float lv, rv = mix(*sdf(0, b), *sdf(0, t), bt); if ((inside = rv > .5f)) { Scanline::Intersection intersection = { -1e240, 1 }; intersections.push_back(intersection); } for (int l = 0, r = 1; r < sdf.width; ++l, ++r) { lv = rv; rv = mix(*sdf(r, b), *sdf(r, t), bt); if (lv != rv) { double lr = double(.5f-lv)/double(rv-lv); if (lr >= 0 && lr <= 1) { Scanline::Intersection intersection = { projection.unprojectX(l+lr+.5), sign(rv-lv) }; intersections.push_back(intersection); } } } #ifdef MSDFGEN_USE_CPP11 line.setIntersections((std::vector<Scanline::Intersection> &&) intersections); #else line.setIntersections(intersections); #endif } template <int N> void scanlineMSDF(Scanline &line, const BitmapConstRef<float, N> &sdf, const Projection &projection, double y, bool inverseYAxis) { if (!(sdf.width > 0 && sdf.height > 0)) return line.setIntersections(std::vector<Scanline::Intersection>()); double pixelY = clamp(projection.projectY(y)-.5, double(sdf.height-1)); if (inverseYAxis) pixelY = sdf.height-1-pixelY; int b = (int) floor(pixelY); int t = b+1; double bt = pixelY-b; if (t >= sdf.height) { b = sdf.height-1; t = sdf.height-1; bt = 1; } bool inside = false; std::vector<Scanline::Intersection> intersections; float lv[3], rv[3]; rv[0] = mix(sdf(0, b)[0], sdf(0, t)[0], bt); rv[1] = mix(sdf(0, b)[1], sdf(0, t)[1], bt); rv[2] = mix(sdf(0, b)[2], sdf(0, t)[2], bt); if ((inside = median(rv[0], rv[1], rv[2]) > .5f)) { Scanline::Intersection intersection = { -1e240, 1 }; intersections.push_back(intersection); } for (int l = 0, r = 1; r < sdf.width; ++l, ++r) { lv[0] = rv[0], lv[1] = rv[1], lv[2] = rv[2]; rv[0] = mix(sdf(r, b)[0], sdf(r, t)[0], bt); rv[1] = mix(sdf(r, b)[1], sdf(r, t)[1], bt); rv[2] = mix(sdf(r, b)[2], sdf(r, t)[2], bt); Scanline::Intersection newIntersections[4]; int newIntersectionCount = 0; for (int i = 0; i < 3; ++i) { if (lv[i] != rv[i]) { double lr = double(.5f-lv[i])/double(rv[i]-lv[i]); if (lr >= 0 && lr <= 1) { float v[3] = { mix(lv[0], rv[0], lr), mix(lv[1], rv[1], lr), mix(lv[2], rv[2], lr) }; if (median(v[0], v[1], v[2]) == v[i]) { newIntersections[newIntersectionCount].x = projection.unprojectX(l+lr+.5); newIntersections[newIntersectionCount].direction = sign(rv[i]-lv[i]); ++newIntersectionCount; } } } } // Sort new intersections if (newIntersectionCount >= 2) { if (newIntersections[0].x > newIntersections[1].x) newIntersections[3] = newIntersections[0], newIntersections[0] = newIntersections[1], newIntersections[1] = newIntersections[3]; if (newIntersectionCount >= 3 && newIntersections[1].x > newIntersections[2].x) { newIntersections[3] = newIntersections[1], newIntersections[1] = newIntersections[2], newIntersections[2] = newIntersections[3]; if (newIntersections[0].x > newIntersections[1].x) newIntersections[3] = newIntersections[0], newIntersections[0] = newIntersections[1], newIntersections[1] = newIntersections[3]; } } for (int i = 0; i < newIntersectionCount; ++i) { if ((newIntersections[i].direction > 0) == !inside) { intersections.push_back(newIntersections[i]); inside = !inside; } } // Consistency check float rvScalar = median(rv[0], rv[1], rv[2]); if ((rvScalar > .5f) != inside && rvScalar != .5f && !intersections.empty()) { intersections.pop_back(); inside = !inside; } } #ifdef MSDFGEN_USE_CPP11 line.setIntersections((std::vector<Scanline::Intersection> &&) intersections); #else line.setIntersections(intersections); #endif } void scanlineSDF(Scanline &line, const BitmapConstRef<float, 3> &sdf, const Projection &projection, double y, bool inverseYAxis) { scanlineMSDF(line, sdf, projection, y, inverseYAxis); } void scanlineSDF(Scanline &line, const BitmapConstRef<float, 4> &sdf, const Projection &projection, double y, bool inverseYAxis) { scanlineMSDF(line, sdf, projection, y, inverseYAxis); } template <int N> double estimateSDFErrorInner(const BitmapConstRef<float, N> &sdf, const Shape &shape, const Projection &projection, int scanlinesPerRow, FillRule fillRule) { if (sdf.width <= 1 || sdf.height <= 1 || scanlinesPerRow < 1) return 0; double subRowSize = 1./scanlinesPerRow; double xFrom = projection.unprojectX(.5); double xTo = projection.unprojectX(sdf.width-.5); double overlapFactor = 1/(xTo-xFrom); double error = 0; Scanline refScanline, sdfScanline; for (int row = 0; row < sdf.height-1; ++row) { for (int subRow = 0; subRow < scanlinesPerRow; ++subRow) { double bt = (subRow+.5)*subRowSize; double y = projection.unprojectY(row+bt+.5); shape.scanline(refScanline, y); scanlineSDF(sdfScanline, sdf, projection, y, shape.inverseYAxis); error += 1-overlapFactor*Scanline::overlap(refScanline, sdfScanline, xFrom, xTo, fillRule); } } return error/((sdf.height-1)*scanlinesPerRow); } double estimateSDFError(const BitmapConstRef<float, 1> &sdf, const Shape &shape, const Projection &projection, int scanlinesPerRow, FillRule fillRule) { return estimateSDFErrorInner(sdf, shape, projection, scanlinesPerRow, fillRule); } double estimateSDFError(const BitmapConstRef<float, 3> &sdf, const Shape &shape, const Projection &projection, int scanlinesPerRow, FillRule fillRule) { return estimateSDFErrorInner(sdf, shape, projection, scanlinesPerRow, fillRule); } double estimateSDFError(const BitmapConstRef<float, 4> &sdf, const Shape &shape, const Projection &projection, int scanlinesPerRow, FillRule fillRule) { return estimateSDFErrorInner(sdf, shape, projection, scanlinesPerRow, fillRule); } // Legacy API void scanlineSDF(Scanline &line, const BitmapConstRef<float, 1> &sdf, const Vector2 &scale, const Vector2 &translate, bool inverseYAxis, double y) { scanlineSDF(line, sdf, Projection(scale, translate), y, inverseYAxis); } void scanlineSDF(Scanline &line, const BitmapConstRef<float, 3> &sdf, const Vector2 &scale, const Vector2 &translate, bool inverseYAxis, double y) { scanlineSDF(line, sdf, Projection(scale, translate), y, inverseYAxis); } void scanlineSDF(Scanline &line, const BitmapConstRef<float, 4> &sdf, const Vector2 &scale, const Vector2 &translate, bool inverseYAxis, double y) { scanlineSDF(line, sdf, Projection(scale, translate), y, inverseYAxis); } double estimateSDFError(const BitmapConstRef<float, 1> &sdf, const Shape &shape, const Vector2 &scale, const Vector2 &translate, int scanlinesPerRow, FillRule fillRule) { return estimateSDFError(sdf, shape, Projection(scale, translate), scanlinesPerRow, fillRule); } double estimateSDFError(const BitmapConstRef<float, 3> &sdf, const Shape &shape, const Vector2 &scale, const Vector2 &translate, int scanlinesPerRow, FillRule fillRule) { return estimateSDFError(sdf, shape, Projection(scale, translate), scanlinesPerRow, fillRule); } double estimateSDFError(const BitmapConstRef<float, 4> &sdf, const Shape &shape, const Vector2 &scale, const Vector2 &translate, int scanlinesPerRow, FillRule fillRule) { return estimateSDFError(sdf, shape, Projection(scale, translate), scanlinesPerRow, fillRule); } }
e00c2cbb57b73e08d9c382337012a0c1a1822044
247764dd458df0e2ee843cfa4b3450e838296052
/OpencvLn/VideoShow.hpp
596eadd13d7116fbdba16c72d892b03c916fe24e
[]
no_license
FanDoubleLucky/OpencvLN
4907f22392957090ee16722ece2a3de6b9b95b93
48f1c88a3410e87ec9f9fd040608a114ba7f374f
refs/heads/master
2020-04-28T05:19:35.452911
2019-04-03T06:50:42
2019-04-03T06:50:42
175,015,391
0
0
null
null
null
null
UTF-8
C++
false
false
337
hpp
VideoShow.hpp
// // VideoShow.hpp // OpencvLn // // Created by FanYizhe on 2019/2/17. // Copyright © 2019年 FanYizhe. All rights reserved. // #ifndef VideoShow_hpp #define VideoShow_hpp #include <opencv2/opencv.hpp> #include <stdio.h> using namespace std; class VideoShow{ public: VideoShow(string VideoName); }; #endif /* VideoShow_hpp */
bd948e1a2065de5ace4b14ee98953c32fca2f932
adc19f9d2d75cc1d6dfc41d75fd207f1405558db
/RTSystems/RTMaster/RTMaster.cpp
ba48e808220e75c4d1c507bd67dae75d57ac46a4
[]
no_license
logogin/CoursesWorks
d84dd8dadb5526991f0313766ed2bb953e46f64a
0f6e1e05299b44986dcbc8622185d9ddcdff95d4
refs/heads/master
2021-01-12T08:26:49.266891
2017-01-21T18:41:31
2017-01-21T18:41:31
76,579,562
0
0
null
null
null
null
UTF-8
C++
false
false
5,713
cpp
RTMaster.cpp
#include <tchar.h> #include <windows.h> #include <stdio.h> #define MAX_FRAGMENT 1024 #define HEAP_INITSIZE 512 void usage(void) { _tprintf(_T("Usage: RTMaster <filename> <procnumber>\n\n")); } void _tmain(int argn,TCHAR *argv[]) { DWORD dwSlavesNumber; TCHAR fileName[MAX_PATH]; if (argn!=3) { usage(); return; } HANDLE hFile; HANDLE hMapping; LPVOID pMappingData; HANDLE hHeap; LPVOID pData; HANDLE hStartEvent; HANDLE hGuardMutex; HANDLE hMasterEvent; HANDLE hSlaveEvent; HANDLE hStdOut; CopyMemory(fileName,argv[1],(_tcslen(argv[1])+1)*sizeof(TCHAR)); dwSlavesNumber=_ttoi(argv[2])-1; /********* Get file handler ********/ hFile=CreateFile(fileName,GENERIC_READ,0,NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if (hFile==INVALID_HANDLE_VALUE) { LPTSTR lpvSysMsg=NULL; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpvSysMsg,0,NULL); _tprintf(_T("%s\n\n"),lpvSysMsg); return; } hStartEvent=CreateEvent(NULL,TRUE,FALSE,_T("START_SLAVES_EVENT")); if (hStartEvent==INVALID_HANDLE_VALUE) { LPTSTR lpvSysMsg=NULL; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpvSysMsg,0,NULL); _tprintf(_T("%s\n\n"),lpvSysMsg); return; } LARGE_INTEGER liMappingSize; liMappingSize.QuadPart=MAX_FRAGMENT*sizeof(TCHAR); /******** Get shared memory handle **********/ hMapping=CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, liMappingSize.HighPart,liMappingSize.LowPart,_T("RT Course FM ASS1")); if (hMapping==NULL) { LPTSTR lpvSysMsg=NULL; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpvSysMsg,0,NULL); _tprintf(_T("%s\n\n"),lpvSysMsg); return; } pMappingData=MapViewOfFile(hMapping,FILE_MAP_ALL_ACCESS,0,0,0); DWORD dwDataSize; /********* Read data from file**********/ ReadFile(hFile,(PDWORD)pMappingData+1,GetFileSize(hFile,NULL),&dwDataSize,NULL); /******* Write data size first*************/ CopyMemory(pMappingData,&dwDataSize,sizeof(dwDataSize)); /********** Get heap handler **********/ hHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE, MAX_FRAGMENT*sizeof(TCHAR),0); if (hHeap==NULL) { LPTSTR lpvSysMsg=NULL; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpvSysMsg,0,NULL); _tprintf(_T("%s\n\n"),lpvSysMsg); return; } pData=HeapAlloc(hHeap,HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE, MAX_FRAGMENT*sizeof(TCHAR)); CopyMemory(pData,(PDWORD)pMappingData+1,dwDataSize); hGuardMutex=CreateMutex(NULL,FALSE,_T("GUARD_MUTEX")); if (hGuardMutex==INVALID_HANDLE_VALUE) { LPTSTR lpvSysMsg=NULL; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpvSysMsg,0,NULL); _tprintf(_T("%s\n\n"),lpvSysMsg); return; } hMasterEvent=CreateEvent(NULL,FALSE,FALSE,_T("MASTER_EVENT")); if (hMasterEvent==INVALID_HANDLE_VALUE) { LPTSTR lpvSysMsg=NULL; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpvSysMsg,0,NULL); _tprintf(_T("%s\n\n"),lpvSysMsg); return; } hSlaveEvent=CreateEvent(NULL,TRUE,TRUE,_T("SLAVE_EVENT")); if (hSlaveEvent==INVALID_HANDLE_VALUE) { LPTSTR lpvSysMsg=NULL; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpvSysMsg,0,NULL); _tprintf(_T("%s\n\n"),lpvSysMsg); return; } /********** Slaves can now start their job ***********/ SetEvent(hStartEvent); hStdOut=GetStdHandle(STD_OUTPUT_HANDLE); if (hStdOut==INVALID_HANDLE_VALUE) { LPTSTR lpvSysMsg=NULL; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpvSysMsg,0,NULL); _tprintf(_T("%s\n\n"),lpvSysMsg); return; } DWORD dwCount; _tprintf(_T("============ Part 1 ==============\n")); WriteFile(hStdOut,pData,dwDataSize,&dwCount,NULL); _tprintf(_T("\n==================================\n")); for (int i=0; i<dwSlavesNumber; i++) { _tprintf(_T("Waiting...\n")); /********* Waiting for signal from slaves *********/ WaitForSingleObject(hMasterEvent,INFINITE); CopyMemory(&dwDataSize,pMappingData,sizeof(DWORD)); CopyMemory(pData,(PDWORD)pMappingData+1,dwDataSize); /********* Slaves can now continue **************/ SetEvent(hSlaveEvent); _tprintf(_T("============ Part %d ==============\n"),i+2); WriteFile(hStdOut,pData,dwDataSize,&dwCount,NULL); _tprintf(_T("\n==================================\n")); } UnmapViewOfFile(pMappingData); CloseHandle(hMapping); CloseHandle(hFile); HeapDestroy(hHeap); CloseHandle(hStartEvent); CloseHandle(hGuardMutex); CloseHandle(hMasterEvent); CloseHandle(hSlaveEvent); CloseHandle(hFile); CloseHandle(hStdOut); }
cc55f94de89b0776f3dc5032094f9daced8a78a2
cab4a9c36c0fa6543c3afe62a40df92e45d20edf
/level3_네트워크.cpp
da489f2bd5c6f247c3d1bd49bcc985cee9b94456
[]
no_license
asy0217/programmers_algorithm
7d274e08df35783cff940e76f188cf05e6d76c80
e1f0b2576ef17b09cda646cd364ad68261f12324
refs/heads/master
2023-02-15T04:22:28.313219
2021-01-12T16:14:40
2021-01-12T16:14:40
313,518,526
0
0
null
null
null
null
UHC
C++
false
false
2,406
cpp
level3_네트워크.cpp
/*1.bfs는 방문했거나, 방문하지 않은 노드의 개수를 세는 문제에 사용되는 알고리즘이다. bfs알고리즘을 푸는 과정에서 queue를 사용한다. 2.dfs는 재귀를 사용한다(bfs는 재귀를 사용하지 않는다). 3.vector는 stack 자료구조로 LIFO이고, queue는 FIFO이다.*/ #include <string> #include <vector> #include <queue> using namespace std; const int MAX = 200; //컴퓨터 개수(노드의 개수) n의 최대값 bool check[MAX] = { 0, };//각 노드 방문했는지 체크함. 방문했으면1, 방문안했으면 0. void bfs(int start, int n, vector<vector<int>> computers) { queue<int> q; check[start] = true;//방문했으므로, 1로 바꿔줌 for (int i = 0; i < n; i++) { int connected = computers[start][i]; //다른 노드와의 연결 여부 파악 if (connected == 1 && check[i] == 0) {//연결되었는데, 아직 방문하지 않은 노드라면 check[i] = true;//check하는 노드와 연결된 노드 중 방문하지 않은 노드는 방문체크 후 큐에 푸시 q.push(i); } } while (q.empty() == 0) { //queue가 안 비었으면 int x = q.front(); q.pop();//선입선출 for (int i = 0; i < n; i++) { int connected = computers[x][i]; if (connected == 1 && check[i] == 0) { check[i] = true;//check하는 노드와 연결된 노드 중 방문하지 않은 노드는 방문체크 후 큐에 푸시 q.push(i); } } } } int solution(int n, vector<vector<int>> computers) { int answer = 0; for (int i = 0; i < n; i++) { if (check[i] == 0) { //첫번째 노드는 무조건 만족 //i=0에서, bfs함수를 통해 첫번째 노드와 연결되있는 노드들을 모두 check[i]=1로 만듬->첫번째 노드와 연결 안된 노드가, bfs함수를 통해 연결되있는 노드들을 모두 check[i]=1로 만듬->... bfs(i, n, computers); //bfs를 통해 첫번째 노드와 연결된 네트워크들을 모두 check[i]=1로 만들어서, 방문한 것을 표시함 answer += 1; //이전까지 순회 중 방문하지 않은 노드는 이전 네트워크에 포함되지 않기 때문에 새로운 네트워크의 등장으로 보고, answer+1 } } return answer; }
9ca1ac74072193b6c5d13455f89cce9b9a023121
491c0b66305a2964fe778460b6b95826920eb9a4
/KnapsackProblem/RecursiveSolver.cpp
32fe3b5d73f421310386c4dd48e817b91cdcb37b
[]
no_license
OlegZuev/KnapsackProblem
e106cf5ef44c1d2c2dcb1f859cc4e153b5708d01
b09d5b9c7112cbc2065b850e5da07b058d85f367
refs/heads/master
2023-01-08T17:54:32.550720
2020-11-13T05:39:02
2020-11-13T05:39:02
311,566,190
0
0
null
null
null
null
UTF-8
C++
false
false
674
cpp
RecursiveSolver.cpp
#include "RecursiveSolver.h" void RecursiveSolver::Solver(std::vector<Item> items, double M, int i, Variant curItems) { if (curItems.sum_weight > M) return; if (curItems.sum_value >= result.sum_value) result = curItems; if (i == items.size()) return; Solver(items, M, i + 1, curItems); curItems.items.push_back(items[i]); curItems.sum_weight += items[i].weight; curItems.sum_value += items[i].value; Solver(items, M, i + 1, curItems); } Variant RecursiveSolver::solve(std::vector<Item> items, double M) { Variant a; result = a; Solver(items, M, 0, Variant()); return result; } std::string RecursiveSolver::get_name() { return "Recursive method"; }
1aac8b8a8439e72776ad72120003159ecbb483ab
a7d04d22af187763b62bd8f3ea57dfa19b4cf0be
/raptor/aggregation/par_mis.hpp
8d86f910c13078b228b93e449de1eaadeabc692a
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
lwhZJU/raptor
132299162532f29e652b2d7240e6424d04c0cd3a
cc8a68f1998c180dd696cb4c6b5fb18987fa60df
refs/heads/master
2020-04-09T18:05:47.526658
2018-12-04T20:13:38
2018-12-04T20:13:38
160,501,551
1
0
BSD-2-Clause
2018-12-05T10:30:22
2018-12-05T10:30:22
null
UTF-8
C++
false
false
521
hpp
par_mis.hpp
// Copyright (c) 2015, Raptor Developer Team, University of Illinois at Urbana-Champaign // License: Simplified BSD, http://opensource.org/licenses/BSD-2-Clause #ifndef RAPTOR_AGGREGATION_PAR_MIS_HPP #define RAPTOR_AGGREGATION_PAR_MIS_HPP #include "core/types.hpp" #include "core/par_matrix.hpp" using namespace raptor; int mis2(const ParCSRMatrix* A, aligned_vector<int>& states, aligned_vector<int>& off_proc_states, bool tap_comm = false, double* rand_vals = NULL, data_t* comm_t = NULL); #endif
fe7a72103df635eda585058a33dfb8d01c08c21e
274e1169a03062140871e4fddaf4836e30cce503
/src/CursATE/Screen/detail/Marks.ut.cpp
8db47ea0d84c274ce2853bd303b72fbae609647c
[ "BSD-2-Clause" ]
permissive
el-bart/LogATE
38df676a9874c42d9ec862cf3090e0e31bc134f2
88569417c0758318a049205bb69f3ecee4d13a32
refs/heads/master
2023-08-29T14:45:26.924602
2023-07-25T17:55:13
2023-07-25T17:55:13
152,469,962
3
3
null
null
null
null
UTF-8
C++
false
false
3,175
cpp
Marks.ut.cpp
#include <doctest/doctest.h> #include "CursATE/Screen/detail/Marks.hpp" #include "LogATE/Tree/Filter/AcceptAll.hpp" #include "LogATE/TestHelpers.ut.hpp" using CursATE::Screen::detail::Marks; using LogATE::makeKey; namespace { TEST_SUITE("CursATE::Screen::detail::Marks") { struct Fixture { auto makeNode() const { using LogATE::Tree::Filter::AcceptAll; return But::makeSharedNN<AcceptAll>(workers_, AcceptAll::Name{"united states of whatever"}); } const LogATE::Utils::WorkerThreadsShPtr workers_{ But::makeSharedNN<LogATE::Utils::WorkerThreads>() }; Marks m_; }; TEST_CASE_FIXTURE(Fixture, "empy by default") { CHECK( m_.size() == 0u ); CHECK_FALSE( m_.find('x') ); } TEST_CASE_FIXTURE(Fixture, "caching and getting") { const auto key1 = makeKey(); const auto node1 = makeNode(); m_.insert( 'a', Marks::Entry{key1, node1} ); { const auto e = m_.find('a'); REQUIRE(static_cast<bool>(e) == true); CHECK( e->key_ == key1 ); const auto node = e->node_.lock(); CHECK( node.get() == node1.get() ); } { const auto e = m_.find('b'); REQUIRE(static_cast<bool>(e) == false); } const auto key2 = makeKey(); const auto node2 = makeNode(); m_.insert( 'b', Marks::Entry{key2, node2} ); { const auto e = m_.find('a'); REQUIRE(static_cast<bool>(e) == true); CHECK( e->key_ == key1 ); const auto node = e->node_.lock(); CHECK( node.get() == node1.get() ); } { const auto e = m_.find('b'); REQUIRE( static_cast<bool>(e) == true); CHECK( e->key_ == key2 ); const auto node = e->node_.lock(); CHECK( node.get() == node2.get() ); } } TEST_CASE_FIXTURE(Fixture, "insertiuon for existing key overrides") { const auto key1 = makeKey(); const auto node1 = makeNode(); m_.insert( 'a', Marks::Entry{key1, node1} ); const auto key2 = makeKey(); const auto node2 = makeNode(); m_.insert( 'a', Marks::Entry{key2, node2} ); const auto e = m_.find('a'); REQUIRE(static_cast<bool>(e) == true); CHECK( e->key_ == key2 ); const auto node = e->node_.lock(); CHECK( node.get() == node2.get() ); } TEST_CASE_FIXTURE(Fixture, "getting invalidated entry") { auto key1 = makeKey(); auto node1 = makeNode().underlyingPointer(); m_.insert( 'a', Marks::Entry{key1, node1} ); node1.reset(); const auto e = m_.find('a'); REQUIRE(static_cast<bool>(e) == true); CHECK( e->key_ == key1 ); const auto node = e->node_.lock(); CHECK( node.get() == nullptr ); } TEST_CASE_FIXTURE(Fixture, "prunning removes invalidated entries") { auto key1 = makeKey(); auto node1 = makeNode().underlyingPointer(); m_.insert( 'a', Marks::Entry{key1, node1} ); auto key2 = makeKey(); auto node2 = makeNode(); m_.insert( 'x', Marks::Entry{key2, node2} ); CHECK( m_.size() == 2u ); node1.reset(); CHECK( m_.size() == 2u ); m_.prune(); CHECK( m_.size() == 1u ); { const auto e = m_.find('a'); CHECK(static_cast<bool>(e) == false); } { const auto e = m_.find('x'); REQUIRE(static_cast<bool>(e) == true); CHECK( e->key_ == key2 ); const auto node = e->node_.lock(); CHECK( node.get() == node2.get() ); } } } }
31f1964a0ddfda49ada471520700d74af1c58842
697443cd09e041fffed3b3a0d9d39d0dd3811cc0
/Udoo/light_sensor_march_22_19_30/light_sensor_march_22_19_30.ino
19ca621ae138c99d06926dd60f28cff46d1790a3
[]
no_license
CTIS-SP-Team5/greenAgent
7c79449031fe64a57d12b03ddce4af98b03cc574
1350e0a1543dbc1826c7bc51b2d9b593af12f5a8
refs/heads/master
2021-01-19T11:21:55.494269
2014-05-07T12:12:17
2014-05-07T12:12:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
915
ino
light_sensor_march_22_19_30.ino
#define ANALOG_SENSOR_PIN A0 #define DIGITAL_SENSOR_PIN 3 #define LEDPIN 3 //Onboard led int switch_state; // Holds the last digital value int light_analog_value; // Holds the last analog value void setup() { // put your setup code here, to run once: delay(3000); pinMode(LEDPIN, OUTPUT); Serial.begin(9600); delay(3000); Serial.println("Light Sensor Test begin..."); } void loop() { // put your main code here, to run repeatedly: delay(500); switch_state = digitalRead(DIGITAL_SENSOR_PIN); if (switch_state == LOW) { digitalWrite(LEDPIN, HIGH); Serial.println("Digital Signal on"); } else { digitalWrite(LEDPIN, LOW); Serial.println("Digital Signal off"); } light_analog_value = analogRead(ANALOG_SENSOR_PIN); // Read the voltage from sensor Serial.print("Analog value(0 - 1023): "); Serial.println(1023 - light_analog_value, DEC); }
154c4bca21e8efa48f2056abb6fe8a9d0fcbdcfe
c4aa2346a3405ac998153c9691a4af210f0a3794
/main.cpp
404c29f272fe6b153ff4bff5a952ee100f4cab8c
[ "Unlicense" ]
permissive
ManDeJan/kvasir-toolchain-hwlib-example
c2f670c49e527a740ca449e5b6e0c9b8aef0bb61
2f6ba858db77d0c053479aea1f1f2285c2e7e655
refs/heads/master
2021-01-22T10:56:06.940618
2017-02-16T09:48:41
2017-02-16T09:48:41
82,053,086
4
0
null
null
null
null
UTF-8
C++
false
false
279
cpp
main.cpp
#include "hwlib-arduino-due.hpp" int main(void) { // kill the watchdog WDT->WDT_MR = WDT_MR_WDDIS; auto led = hwlib::target::pin_out(1, 27); for(;;){ led.set( 1 ); hwlib::wait_ms( 500 ); led.set( 0 ); hwlib::wait_ms( 500 ); } }
43a80af1d5740ed6e41eeb08ce1e911e55fe77f9
0aaf2bcc185717310133f4141d8615af69308ee0
/client/client.cpp
614aadad3c665aad24bd50525752d0571babf44d
[ "Apache-2.0" ]
permissive
mefest/net
fd1b3b35f1873c4cdc3ac52b44800561bd950eef
87b62eaa0179bbeae2e177066be236b85305480b
refs/heads/master
2021-01-21T13:41:33.992725
2016-04-24T19:53:46
2016-04-24T19:53:46
54,844,971
0
0
null
null
null
null
UTF-8
C++
false
false
3,344
cpp
client.cpp
#include "client.h" #include "QAbstractSocket" #include "package/packagecommand.h" #include "package/packagemessage.h" #include "package/packageauth.h" #include "package/packagefilehandler.h" Client::Client(QObject *parent) : QObject(parent), state(Closed) { compres=0; sok=nullptr; setSocked(new QTcpSocket(this)); _blockSize=0; auth=false; } bool Client::connectTo(QHostAddress addr, quint16 port) { sok->connectToHost(addr, port); state=Client_State::SYN; return true; } bool Client::connectTo(QString addr, quint16 port) { sok->connectToHost(addr, port); state=Client_State::SYN; return true; } void Client::send(QByteArray &block) { if(compres){ sok->write(qCompress(block,compres)); }else{ sok->write(block); } } void Client::setSocked(QTcpSocket *soked) { if(sok!=nullptr){ sok->deleteLater(); } sok= soked; descriptor=sok->socketDescriptor(); connect(sok, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(onSokError(QAbstractSocket::SocketError))); connect(sok,SIGNAL(connected()), this, SLOT(onConnected())); connect(sok,SIGNAL(readyRead()),this,SLOT(onRead())); connect(sok,SIGNAL(disconnected()),this,SLOT(onDisconnect())); } void Client::onSokError(QAbstractSocket::SocketError sError) { qDebug()<<sError; } void Client::onConnected() { QTcpSocket *socket= qobject_cast<QTcpSocket*>(QObject::sender()); descriptor=socket->socketDescriptor(); state=Client_State::Estabilished; // QByteArray block; // QDataStream out(&block, QIODevice::WriteOnly); } void Client::onRead() { qDebug()<<"onRead"; QDataStream in(sok); Package *package; while(!in.atEnd()) { if(_blockSize==0){ if (sok->bytesAvailable() < (int)sizeof(quint16)) return; in >> _blockSize; qDebug()<<"Полученно--------------"; qDebug()<<"размер"<<_blockSize<<"\t\t|"; } if (sok->bytesAvailable() < _blockSize) return; else _blockSize = 0; quint16 type; in>>type; qDebug()<<"Тип "<<type<<"\t\t|"; switch (type) { case Package::Unknow: return; break; case Package::Command: { package= new PackageCommand(); break; } case Package::Message: { package= new PackageMessage(); break; } case Package::Auth: { package= new PackageAuth(); break; } case Package::FileHandler: { package= new PackageFileHandler(); break; } default: qDebug()<<"Необъявленный пакет"; return; break; } package->user=sok->socketDescriptor(); qDebug()<<"from\t"<<package->user<<"\t|"; package->fromStream(in); package->dump(); qDebug()<<"-----------------------"; emit recivPackage(package); } } void Client::sendPackage(Package *package) { QByteArray block=package->serialize(); send(block); } void Client::onDisconnect() { state=Client_State::Closed; emit disconnect(); } bool Client::authorization() { }
d777a79595ff5213148e8ef508c03febeeb8150d
bc5377f1143f529c091a8bade0d7f63ed067f8fa
/11-yacc_examples/compiler.cpp
aa407dd4939c95ffac3f89d33e5b762a51614bd5
[ "MIT" ]
permissive
puma3/compilers
f744ee871119937638ce5ba3b0607eabdb1afdb6
b0b845db7f81b75182c0c01e7255a2fe758a9475
refs/heads/master
2021-08-31T14:53:58.699139
2017-12-21T19:42:55
2017-12-21T19:42:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,045
cpp
compiler.cpp
#include <bits/stdc++.h> // # include <stdio.h> // # include <math.h> // // # include <conio.h> // # include <ctype.h> // # include <string> #define FLOAT 256 #define MAX 257 #define MAS '+' #define MENOS '-' #define MUL '*' #define DIV '/' #define PARI '(' #define PARD ')' #define FIN '-1' #define COMA ',' using namespace std; int ERROR; int Leertoken; float val; //val, es el valor del token FLOAT char lexema [80]; float E(), T(), F(); int scanner(); int main() { float result; ERROR = 0; Leertoken = 1; // clrscr(); result = E(); if (ERROR) printf("Error de sintaxis\n"); else printf("valor = %g\n", result); // getch(); } float E() { float v1, v2; int tok; v1 = T(); tok = scanner(); while (tok == MAS || tok == MENOS) { v2 = T(); if (tok == MAS) v1 = v1 + v2; else v1 = v1 - v2; tok = scanner(); } Leertoken = 0; return v1; } float T() { float f1, f2; int tok; f1 = F(); tok = scanner(); while (tok == MUL || tok == DIV) { f2 = F(); if (tok == MUL) f1 = f1 * f2; else f1 = f1 / f2; tok = scanner(); } Leertoken = 0; return f1; } float F() { float V, V1; int tok; tok = scanner(); if (tok == FLOAT) return val; if (tok == PARI) { V = E(); tok = scanner(); if (tok != PARD) { ERROR++; return 0; } return V; } if (tok == MAX) { tok = scanner(); if (tok != PARI) { ERROR++; return 0; } V = E(); tok = scanner(); if (tok != COMA) { ERROR++; return 0; } V1 = E(); tok = scanner(); if (tok != PARD) { ERROR++; return 0; } return (V > V1) ? V : V1; } Leertoken = 0; } int scanner() { static int token; int c, i; if (Leertoken == 0) { Leertoken = 1; return token; } do c = getchar(); while (c == ' ' || c == '\t'); if (c == '\n') return token = FIN; if (isdigit(c)) { ungetc(c, stdin); scanf("%f", &val); return token = FLOAT; } if (c == MAS || c == MENOS) return token = c; if (c == MUL || c == DIV) return token = c; if (c == PARI || c == PARD) return token = c; if (c == COMA) return token = c; if (isalpha(c)) { i = 0; do { lexema[i++] = c; c = getchar(); } while (isalpha(c)); lexema[i] = 0; ungetc(c, stdin); if (strcmp(lexema, "MAX") == 0) return token = MAX; } }
b7f8d8ed73892b4bd4c3058714c16fcaa4eafc5e
92e67b30497ffd29d3400e88aa553bbd12518fe9
/assignment2/part6/Re=110/41.4/phi
b399230fbb441038624966d44f78fad7546dfa21
[]
no_license
henryrossiter/OpenFOAM
8b89de8feb4d4c7f9ad4894b2ef550508792ce5c
c54b80dbf0548b34760b4fdc0dc4fb2facfdf657
refs/heads/master
2022-11-18T10:05:15.963117
2020-06-28T15:24:54
2020-06-28T15:24:54
241,991,470
0
0
null
null
null
null
UTF-8
C++
false
false
42,956
phi
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class surfaceScalarField; location "41.4"; object phi; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 3 -1 0 0 0 0]; internalField nonuniform List<scalar> 3880 ( 1.84865e-05 0.000390363 -0.000408849 0.000242499 0.000156292 -0.000380305 0.000702625 -0.000198894 -0.000261232 0.00139953 -0.000350181 -0.000346729 0.00232456 -0.000146663 -0.00077836 0.00346532 0.000471529 -0.0016123 0.00480493 0.00151496 -0.00285456 0.00631928 0.00296572 -0.00448007 0.00797463 0.00478769 -0.00644303 0.00693234 0.00972305 -0.00868076 4.54313e-05 0.000344932 0.000320069 -0.000118346 0.000834204 -0.000713029 0.00157624 -0.00109222 0.00253232 -0.00110275 0.00369149 -0.000687637 0.00504383 0.000162619 0.00657563 0.00143392 0.0082644 0.00309892 0.0051257 0.010071 8.08866e-05 0.000264045 0.000421323 -0.000458783 0.00100714 -0.00129884 0.00181069 -0.00189577 0.00280952 -0.00210158 0.0039914 -0.00186952 0.00535206 -0.00119804 0.00688892 -0.000102947 0.00859358 0.00139426 0.00327887 0.0104404 0.000125545 0.0001385 0.000548458 -0.000881697 0.00122622 -0.0019766 0.00211182 -0.00278137 0.00317095 -0.00316071 0.00438688 -0.00308545 0.00575834 -0.0025695 0.00729277 -0.00163737 0.00899709 -0.000310061 0.00141205 0.0108639 0.00017958 -4.10804e-05 0.000701682 -0.0014038 0.00149201 -0.00276693 0.00248165 -0.00377102 0.00362204 -0.00430111 0.00488913 -0.00435253 0.00628147 -0.00396183 0.00781367 -0.00316958 0.00950686 -0.00200324 -0.000455996 0.0113749 0.000242374 -0.000283455 0.000878278 -0.0020397 0.00179852 -0.00368717 0.00291067 -0.00488317 0.00415092 -0.00554135 0.00548653 -0.00568815 0.00691338 -0.00538869 0.00844988 -0.00470607 0.0101281 -0.00368142 -0.00231096 0.011983 0.000312406 -0.000595861 0.00107212 -0.00279942 0.00213204 -0.00474709 0.00337542 -0.00612655 0.00472392 -0.00688985 0.00613683 -0.00710105 0.00760659 -0.00685845 0.00915272 -0.00625221 0.0108144 -0.00534307 -0.00414074 0.0126441 0.000387269 -0.00098313 0.0012738 -0.00368595 0.0024715 -0.00594479 0.00383945 -0.0074945 0.00528709 -0.00833749 0.00676839 -0.00858235 0.00827359 -0.00836364 0.00982199 -0.00780061 0.0114564 -0.00697745 -0.0059252 0.0132408 0.000463795 -0.00144693 0.00147117 -0.00469332 0.00279034 -0.00726396 0.0042576 -0.00896177 0.00577397 -0.00985386 0.00729211 -0.0101005 0.00880232 -0.00987385 0.0103231 -0.00932137 0.0118978 -0.00855214 -0.00762128 0.0135939 0.000538154 -0.00198508 0.00165023 -0.00580539 0.00305932 -0.00867305 0.00458237 -0.0104848 0.00611753 -0.011389 0.00762121 -0.0116042 0.00908619 -0.0113388 0.0105276 -0.0107628 0.0119815 -0.0100061 0.0135385 -0.00917821 0.0131677 0.0462122 -0.0496569 0.0150508 0.0836625 -0.0855456 0.0148892 0.116991 -0.116829 0.0133756 0.144381 -0.142868 0.0112389 0.168713 -0.166577 0.00888176 0.192835 -0.190478 0.0065051 0.220378 -0.218001 0.00415104 0.253644 -0.25129 0.00189971 0.294836 -0.292585 0.341008 -0.339108 0.0138121 0.0424712 0.0162853 0.0811893 0.0166409 0.116635 0.0153973 0.145625 0.0133099 0.170801 0.010839 0.195306 0.00822542 0.222992 0.0054995 0.25637 0.00268616 0.297649 0.343694 0.0143633 0.0385483 0.0174006 0.078152 0.0183114 0.115724 0.017391 0.146545 0.0153873 0.172805 0.0128189 0.197874 0.00996231 0.225848 0.00685453 0.259478 0.00347616 0.301028 0.34717 0.0148153 0.0345969 0.0183576 0.0746097 0.0198498 0.114232 0.0193062 0.147089 0.017428 0.174683 0.0147849 0.200517 0.011698 0.228935 0.00821578 0.26296 0.00426892 0.304974 0.351439 0.0151797 0.0307921 0.0191273 0.0706621 0.0212106 0.112149 0.0211006 0.147199 0.0194002 0.176383 0.0167124 0.203205 0.0134089 0.232238 0.00955821 0.266811 0.0050517 0.309481 0.356491 0.015478 0.0272971 0.0196937 0.0664464 0.0223522 0.10949 0.0227184 0.146833 0.021246 0.177856 0.0185572 0.205894 0.0150712 0.235724 0.0108766 0.271005 0.0058234 0.314534 0.362314 0.0157274 0.0242138 0.0200545 0.0621193 0.023256 0.106289 0.0241546 0.145934 0.0229743 0.179036 0.0203216 0.208547 0.0166712 0.239375 0.0121462 0.27553 0.00656834 0.320112 0.368883 0.0159158 0.0215388 0.0202148 0.0578203 0.0238683 0.102635 0.0252894 0.144513 0.0244543 0.179871 0.0219145 0.211087 0.0181678 0.243122 0.013363 0.280335 0.00728897 0.326186 0.376172 0.0159451 0.0191876 0.0201959 0.0535695 0.024312 0.0985193 0.0263183 0.142507 0.0258619 0.180327 0.0234301 0.213518 0.0195841 0.246968 0.0145053 0.285414 0.00796802 0.332723 0.38414 0.0155719 0.0171542 0.019819 0.0493224 0.0242581 0.0940802 0.0268541 0.139911 0.0269515 0.18023 0.0247932 0.215677 0.0209863 0.250775 0.0156513 0.290749 0.00869548 0.339679 0.392835 0.040884 0.026662 -0.0503918 0.0338108 0.0563956 0.0301979 0.0976931 0.028502 0.141607 0.0263689 0.182363 0.0224948 0.219551 0.0169718 0.256298 0.0106884 0.297032 0.00455344 0.345814 0.397389 0.0330448 0.0364162 -0.042799 0.0251341 0.0643063 0.0212923 0.101535 0.0203244 0.142574 0.0196953 0.182992 0.0177008 0.221545 0.0138258 0.260173 0.00881672 0.302041 0.00365681 0.350974 0.401045 0.0240264 0.045101 -0.0327112 0.0160375 0.0722952 0.0115009 0.106071 0.010361 0.143714 0.0107671 0.182586 0.0106718 0.22164 0.00905616 0.261788 0.00606363 0.305034 0.0024787 0.354559 0.403524 0.0140743 0.0529802 -0.0219534 0.00631129 0.0800582 0.00161994 0.110763 0.000610034 0.144724 0.00205374 0.181143 0.00362436 0.22007 0.00414958 0.261263 0.00300267 0.306181 0.00109317 0.356469 0.404617 0.00539731 0.0599761 -0.0123933 -0.00207161 0.0875271 -0.00724441 0.115936 -0.00880579 0.146286 -0.00718241 0.179519 -0.00404931 0.216937 -0.00131479 0.258528 -0.000256646 0.305123 -0.000359013 0.356571 0.404258 -0.00149303 0.0660945 -0.00462532 -0.00822606 0.0942601 -0.0130023 0.120712 -0.0145759 0.147859 -0.0129827 0.177926 -0.00934051 0.213294 -0.00547747 0.254665 -0.00286247 0.302508 -0.00154697 0.355255 0.402711 -0.00608949 0.0716552 0.000528774 -0.0126799 0.100851 -0.0178726 0.125905 -0.0198703 0.149857 -0.0183623 0.176418 -0.0142119 0.209144 -0.00923963 0.249693 -0.00524715 0.298515 -0.00266212 0.35267 0.400049 -0.00748599 0.075818 0.00332322 -0.0126262 0.105991 -0.0171788 0.130457 -0.0194978 0.152176 -0.0188298 0.17575 -0.015457 0.205771 -0.0108189 0.245055 -0.00654114 0.294237 -0.00335661 0.349486 0.396693 -0.00841375 0.0799655 0.00426622 -0.0137613 0.111338 -0.0186398 0.135336 -0.0211567 0.154693 -0.0205957 0.175189 -0.0171533 0.202329 -0.0122653 0.240167 -0.0075639 0.289536 -0.00387863 0.345801 0.392814 -0.00450799 0.00201341 -0.0086082 -0.0132171 -0.0164419 -0.0171629 -0.0152709 -0.0115155 -0.00753821 -0.00381813 0.0125696 -0.050061 -0.0129004 0.0117872 -0.0420166 0.0111513 -0.0320753 0.0110378 -0.0218399 0.0114977 -0.0128532 0.012369 -0.00549662 0.013406 -0.00050818 0.0144875 0.00224175 0.0156329 0.00312077 0.00126886 0.0114418 -0.0494508 -0.012052 0.0104382 -0.041013 0.00977522 -0.0314124 0.0096358 -0.0217005 0.0100018 -0.0132192 0.0107083 -0.0062031 0.0115773 -0.00137716 0.0124424 0.00137656 0.0133284 0.00223479 0.000758505 0.00998714 -0.0486146 -0.0108233 0.00887581 -0.0399016 0.00817778 -0.0307143 0.00798396 -0.0215066 0.00824842 -0.0134837 0.0088188 -0.00677348 0.00951583 -0.00207419 0.0102145 0.000677884 0.0108943 0.00155502 0.000425938 0.00816817 -0.0476156 -0.00916724 0.00702254 -0.038756 0.00632191 -0.0300137 0.00607971 -0.0212644 0.00624752 -0.0136515 0.00669066 -0.00721662 0.00725161 -0.00263514 0.00782128 0.000108217 0.00834398 0.00103232 0.000222633 0.00599001 -0.0464924 -0.00711317 0.00484384 -0.0376098 0.00416923 -0.0293391 0.00390288 -0.0209981 0.00399851 -0.0137471 0.00434411 -0.00756222 0.00480413 -0.00309515 0.00528939 -0.00037705 0.00569599 0.000625717 0.000105282 0.00350517 -0.0452694 -0.00472819 0.00237638 -0.036481 0.00174252 -0.0287052 0.00147728 -0.0207329 0.00152886 -0.0137987 0.00181515 -0.00784851 0.00221265 -0.00349265 0.00264353 -0.000807925 0.0029758 0.000293443 3.64617e-05 0.000812374 -0.0439856 -0.00209613 -0.000279983 -0.0353887 -0.000901626 -0.0280836 -0.00115195 -0.0204826 -0.00111031 -0.0138404 -0.000838601 -0.00812022 -0.000465781 -0.00386547 -5.21057e-05 -0.0012216 0.00021741 2.39268e-05 -1.42595e-05 -0.0020945 -0.0425842 0.000693106 -0.00316928 -0.0343139 -0.00371056 -0.0275423 -0.00393109 -0.020262 -0.00386562 -0.0139058 -0.00358905 -0.00839678 -0.00321079 -0.00424373 -0.00281994 -0.00161245 -0.00253788 -0.000258138 -6.96497e-05 -0.00501936 -0.0410914 0.00352648 -0.00602889 -0.0333044 -0.00652245 -0.0270488 -0.00670915 -0.0200753 -0.00661446 -0.0140005 -0.00631526 -0.00869598 -0.00592361 -0.00463539 -0.00552931 -0.00200675 -0.00524934 -0.000538109 -0.000146779 -0.00782916 -0.0395705 0.0063083 -0.00878959 -0.0323439 -0.00924779 -0.0265906 -0.00940041 -0.0199227 -0.00927859 -0.0141224 -0.00895466 -0.0090199 -0.00855119 -0.00503885 -0.00815263 -0.00240532 -0.00787012 -0.000820616 -0.000253491 -0.0104424 -0.0380694 0.0089413 -0.0113641 -0.0314223 -0.0118047 -0.0261499 -0.0119222 -0.0198052 -0.011784 -0.0142606 -0.0114441 -0.00935981 -0.0110393 -0.00544367 -0.010643 -0.0028016 -0.0103586 -0.00110499 -0.000389473 -0.0128216 -0.0366106 0.0113629 -0.013693 -0.0305509 -0.0141296 -0.0257133 -0.0142142 -0.0197206 -0.014076 -0.0143988 -0.0137344 -0.00970139 -0.0133438 -0.00583426 -0.0129611 -0.00318427 -0.0126817 -0.00138442 -0.000547009 -0.0149166 -0.0352157 0.0135217 -0.0157344 -0.0297331 -0.0161767 -0.025271 -0.0162384 -0.0196589 -0.0161168 -0.0145204 -0.0157922 -0.010026 -0.0154333 -0.00619318 -0.015079 -0.00353854 -0.0148164 -0.00164699 -0.000711616 -0.0167051 -0.0338968 0.0153862 -0.0174645 -0.0289736 -0.017923 -0.0248126 -0.017976 -0.0196059 -0.0178864 -0.01461 -0.0175999 -0.0103125 -0.0172897 -0.00650341 -0.0169808 -0.00384739 -0.0167507 -0.00187708 -0.000863499 -0.0181842 -0.0326501 0.0169374 -0.0188792 -0.0282786 -0.0193623 -0.0243295 -0.0194246 -0.0195436 -0.0193799 -0.0146547 -0.0191529 -0.0105395 -0.0189075 -0.00674882 -0.0186628 -0.0040921 -0.0184834 -0.00205652 -0.000979213 -0.0193645 -0.031449 0.0181634 -0.0199909 -0.0276522 -0.020501 -0.0238194 -0.020594 -0.0194506 -0.0206034 -0.0146453 -0.0204571 -0.0106858 -0.0202918 -0.00691406 -0.0201313 -0.00425262 -0.0200226 -0.00216524 -0.0010331 -0.0202604 -0.0302424 0.0190538 -0.0208219 -0.0270908 -0.0213513 -0.02329 -0.0215001 -0.0193018 -0.0215706 -0.0145748 -0.0215258 -0.0107305 -0.021456 -0.00698383 -0.0214006 -0.00430802 -0.0213839 -0.00218194 -0.000998429 -0.0208568 -0.0289857 0.0196001 -0.0213832 -0.0265644 -0.0219218 -0.0227514 -0.0221584 -0.0190651 -0.0222994 -0.0144338 -0.0223771 -0.0106529 -0.0224192 -0.00694169 -0.0224903 -0.0042369 -0.022588 -0.00208432 -0.000848174 -0.0211144 -0.0276871 0.0198158 -0.0216859 -0.025993 -0.0222263 -0.022211 -0.022584 -0.0187074 -0.0228093 -0.0142085 -0.023029 -0.0104331 -0.0232015 -0.00676918 -0.0234216 -0.00401681 -0.0236576 -0.00184836 -0.000555102 -0.0210567 -0.0264316 0.0198012 -0.0217483 -0.0253013 -0.0222432 -0.0217162 -0.0227329 -0.0182177 -0.023069 -0.0138725 -0.0234595 -0.0100426 -0.0238007 -0.00642796 -0.0242042 -0.00361334 -0.0246191 -0.00143341 -9.44467e-05 -0.0835413 -0.023107 0.0802166 -0.0888178 -0.0200247 -0.0928196 -0.0177144 -0.0965515 -0.0144857 -0.0990655 -0.0113585 -0.100918 -0.00818968 -0.101887 -0.00545987 -0.102412 -0.00308823 -0.102561 -0.00128416 -9.62212e-05 -0.102609 -0.0199793 0.0994812 -0.106097 -0.0165362 -0.109034 -0.014778 -0.111854 -0.0116655 -0.113875 -0.00933799 -0.115441 -0.00662362 -0.116345 -0.00455559 -0.116876 -0.00255753 -0.117028 -0.00113186 -9.02611e-05 -0.120997 -0.0172833 0.118301 -0.123673 -0.0138606 -0.126135 -0.012316 -0.128321 -0.00947893 -0.129987 -0.00767264 -0.13125 -0.00536044 -0.132007 -0.00379822 -0.132442 -0.00212292 -0.132552 -0.00102197 -7.93984e-05 -0.141308 -0.0150527 0.139078 -0.143494 -0.0116749 -0.145535 -0.0102754 -0.147284 -0.00772923 -0.148649 -0.00630763 -0.14967 -0.00434028 -0.150289 -0.00317862 -0.150635 -0.00177745 -0.150714 -0.000942209 -6.93414e-05 -0.165418 -0.0128853 0.163251 -0.167306 -0.0097867 -0.16904 -0.00854177 -0.170499 -0.00626984 -0.171657 -0.00514944 -0.172518 -0.00347942 -0.17307 -0.00262739 -0.173397 -0.00145007 -0.173508 -0.000831162 -3.80217e-05 -0.194619 -0.0106404 0.192374 -0.196363 -0.00804173 -0.198022 -0.00688292 -0.199372 -0.00491982 -0.200452 -0.00406937 -0.201257 -0.00267525 -0.201845 -0.00203942 -0.20226 -0.00103487 -0.202497 -0.000593776 2.76944e-05 -0.227489 -0.00816739 0.225016 -0.229767 -0.00576429 -0.231675 -0.00497494 -0.233009 -0.00358551 -0.234066 -0.00301301 -0.234885 -0.00185545 -0.235569 -0.00135576 -0.236113 -0.000491331 -0.236466 -0.000240778 0.000112648 -0.262223 -0.00558023 0.259636 -0.263565 -0.00442219 -0.264868 -0.00367161 -0.266043 -0.00241051 -0.26713 -0.00192584 -0.267955 -0.00103136 -0.268633 -0.000677185 -0.2691 -2.46963e-05 -0.269382 4.17911e-05 0.000164569 -0.284378 -0.0028186 0.281617 -0.287201 -0.00159938 -0.289491 -0.00138117 -0.290936 -0.000966302 -0.292034 -0.00082722 -0.29262 -0.000445584 -0.29305 -0.000246923 -0.29316 8.52513e-05 -0.293215 9.69542e-05 9.80629e-05 -0.300029 0.297211 -0.301629 -0.30301 -0.303976 -0.304803 -0.305249 -0.305496 -0.305411 -0.305314 -0.0226416 0.0820389 0.0208193 -0.0234091 0.100249 -0.023617 0.118509 -0.0233094 0.13877 -0.0224952 0.162437 -0.0208192 0.190698 -0.0181349 0.222332 -0.0121216 0.253622 -0.00735934 0.276854 0.289851 -0.0214039 0.0830485 0.0203943 -0.0220295 0.100874 -0.0221135 0.118593 -0.0216863 0.138343 -0.0207571 0.161507 -0.0190477 0.188988 -0.0162837 0.219568 -0.0117961 0.249135 -0.00647506 0.271533 0.283376 -0.0203723 0.083821 0.0195998 -0.0208394 0.101341 -0.0208059 0.118559 -0.020317 0.137854 -0.0193632 0.160554 -0.0177022 0.187327 -0.0150094 0.216875 -0.0109474 0.245073 -0.00587937 0.266465 0.277497 -0.0192174 0.0844956 0.0185429 -0.0195347 0.101659 -0.0193657 0.11839 -0.0188004 0.137289 -0.0178206 0.159574 -0.0162075 0.185714 -0.0136469 0.214315 -0.00996608 0.241392 -0.00526526 0.261764 0.272232 -0.0179068 0.0850985 0.0173038 -0.0181043 0.101856 -0.0178225 0.118109 -0.0171922 0.136659 -0.0161942 0.158576 -0.0146346 0.184155 -0.012244 0.211924 -0.00890469 0.238053 -0.00466935 0.257529 0.267562 -0.0164489 0.0856121 0.0159354 -0.0165284 0.101936 -0.0161557 0.117736 -0.0154811 0.135984 -0.0144829 0.157578 -0.0129961 0.182668 -0.0108037 0.209732 -0.00780475 0.235054 -0.00408321 0.253808 0.263479 -0.0148777 0.0860154 0.0144744 -0.0148317 0.10189 -0.0143752 0.117279 -0.0136681 0.135277 -0.0126854 0.156595 -0.0112933 0.181276 -0.00932203 0.20776 -0.00668587 0.232418 -0.00349186 0.250613 0.259987 -0.0132254 0.0862879 0.0129529 -0.0130538 0.101718 -0.0125152 0.116741 -0.0117797 0.134541 -0.010821 0.155636 -0.00953994 0.179994 -0.00780693 0.206027 -0.00555667 0.230167 -0.0028922 0.247949 0.257095 -0.0115216 0.0864062 0.0114033 -0.0112309 0.101427 -0.0106113 0.116121 -0.0098503 0.13378 -0.00891959 0.154705 -0.00775973 0.178835 -0.00627528 0.204543 -0.00442362 0.228316 -0.00228794 0.245813 0.254807 -0.00979348 0.0863399 0.00985972 -0.00939651 0.10103 -0.00869269 0.115417 -0.00791076 0.132998 -0.00700862 0.153803 -0.00597745 0.177803 -0.00474688 0.203312 -0.00329699 0.226866 -0.00168681 0.244203 0.25312 -0.00807571 0.0860511 0.00836455 -0.0075916 0.100546 -0.00679175 0.114618 -0.00599501 0.132202 -0.00511737 0.152926 -0.00421783 0.176904 -0.00324024 0.202335 -0.00218746 0.225813 -0.00109495 0.243111 0.252025 -0.00643415 0.0855429 0.00694229 -0.00585332 0.0999654 -0.00496206 0.113726 -0.00414514 0.131385 -0.00328995 0.152071 -0.0025114 0.176125 -0.00177481 0.201598 -0.00110893 0.225147 -0.000519353 0.242521 0.251506 -0.00491692 0.084832 0.00562788 -0.00422187 0.0992703 -0.00325333 0.112758 -0.00240648 0.130538 -0.00157798 0.151242 -0.000909924 0.175457 -0.000405667 0.201094 -0.000108261 0.22485 1.80578e-06 0.242411 0.251508 -0.00355207 0.0839448 0.0044393 -0.00271831 0.0984366 -0.00170211 0.111742 -0.000817916 0.129654 -6.63796e-05 0.15049 0.000596212 0.174795 0.000921248 0.200769 0.000888682 0.224882 0.000543166 0.242757 0.252051 -0.00235849 0.0829204 0.00338287 -0.00136143 0.0974395 -0.000353922 0.110734 0.000669212 0.128631 0.00153377 0.149626 0.00206998 0.174258 0.00218853 0.20065 0.00182622 0.225245 0.00104208 0.243541 0.253093 -0.00134562 0.0818132 0.00245279 -0.000199494 0.0962934 0.000983177 0.109551 0.00207589 0.127538 0.00292256 0.148779 0.00338973 0.173791 0.00333482 0.200705 0.00267739 0.225902 0.00149364 0.244724 0.254587 -0.000515775 0.0807006 0.00162835 0.000938529 0.0948391 0.00218027 0.10831 0.00331456 0.126404 0.00417408 0.14792 0.00459958 0.173366 0.00440185 0.200903 0.00347767 0.226826 0.00192129 0.246281 0.256508 0.000150259 0.0796755 0.000874877 0.00187462 0.0931147 0.00315098 0.107033 0.00432967 0.125225 0.00520285 0.147047 0.00559861 0.17297 0.00528983 0.201212 0.00414803 0.227968 0.00227556 0.248153 0.258784 0.000993802 0.0785559 0.000125743 0.00275304 0.0913555 0.00407688 0.105709 0.00529939 0.124002 0.00619559 0.14615 0.00657276 0.172593 0.00616088 0.201624 0.00480692 0.229322 0.00262783 0.250332 0.261411 0.00130091 0.0778377 -0.000582632 0.00312537 0.089531 0.004502 0.104333 0.00575073 0.122754 0.00666806 0.145233 0.00705935 0.172202 0.00662066 0.202062 0.00516845 0.230774 0.00280916 0.252692 0.264221 -0.069786 0.0697702 0.0778534 -0.0619957 0.0817407 -0.0564289 0.0987659 -0.0505559 0.116881 -0.044558 0.139235 -0.0379542 0.165598 -0.0301947 0.194303 -0.0210516 0.221631 -0.0107614 0.242401 0.253459 -0.0812003 0.0633488 0.0876217 -0.0744747 0.0750152 -0.0682636 0.0925548 -0.0613715 0.109989 -0.0545446 0.132408 -0.046703 0.157756 -0.037332 0.184932 -0.0262313 0.21053 -0.0136892 0.229859 0.23977 -0.0944714 0.0569565 0.100864 -0.0879003 0.0684441 -0.0809506 0.085605 -0.0733953 0.102433 -0.0655208 0.124534 -0.0559234 0.148159 -0.0445336 0.173542 -0.0310516 0.197049 -0.0157709 0.214579 0.223999 -0.111004 0.0508639 0.117096 -0.104222 0.0616621 -0.0968171 0.0782004 -0.088631 0.0942474 -0.0793196 0.115222 -0.0676617 0.136501 -0.0539451 0.159825 -0.0377341 0.180838 -0.0196642 0.196509 0.204335 -0.130387 0.0442034 0.137048 -0.123504 0.0547794 -0.115323 0.0700188 -0.105629 0.0845539 -0.0939312 0.103524 -0.0795623 0.122132 -0.0629108 0.143174 -0.0433003 0.161227 -0.0216949 0.174903 0.18264 -0.155402 0.038109 0.161496 -0.14762 0.046998 -0.138026 0.0604247 -0.126313 0.0728408 -0.112066 0.0892772 -0.0949535 0.105019 -0.074927 0.123147 -0.0516559 0.137956 -0.0269339 0.150181 0.155706 -0.182045 0.030491 0.189663 -0.172936 0.0378888 -0.161269 0.0487579 -0.146904 0.0584758 -0.129408 0.0717812 -0.108386 0.0839966 -0.083468 0.0982298 -0.0554808 0.109969 -0.0268026 0.121503 0.128903 -0.213175 0.0224437 0.221223 -0.202369 0.0270828 -0.188612 0.0350005 -0.171663 0.0415266 -0.151035 0.0511534 -0.126254 0.0592158 -0.0974401 0.0694156 -0.0663769 0.0789055 -0.0350698 0.0901961 0.0938337 -0.236751 0.0108557 0.248339 -0.223028 0.0133601 -0.205479 0.0174512 -0.184631 0.020679 -0.159216 0.0257384 -0.129728 0.0297278 -0.0958396 0.0355268 -0.0575877 0.0406536 -0.0177868 0.0503952 0.076047 -0.309579 0.320435 -0.296219 -0.278768 -0.258089 -0.23235 -0.202623 -0.167096 -0.126442 -0.076047 -0.00190784 0.079712 4.93094e-05 -0.00348379 0.0891977 -0.00470849 0.102088 -0.0056206 0.118008 -0.00616432 0.137591 -0.00628837 0.16162 -0.00578532 0.18916 -0.00455321 0.219991 -0.00347259 0.247258 0.316962 -0.00143754 0.0817696 -0.000620066 -0.00317733 0.0909375 -0.00449801 0.103409 -0.00543434 0.118945 -0.00601334 0.13817 -0.0061379 0.161745 -0.00569103 0.188713 -0.00447899 0.218779 -0.00317642 0.245956 0.313786 -0.000758996 0.0837679 -0.00123937 -0.00249134 0.0926698 -0.00382506 0.104743 -0.00475776 0.119877 -0.00536423 0.138777 -0.00550701 0.161888 -0.0051588 0.188365 -0.00404323 0.217663 -0.00290294 0.244815 0.310883 -0.000126696 0.0857539 -0.00185922 -0.00179358 0.0943367 -0.00302774 0.105977 -0.00392772 0.120777 -0.00451278 0.139362 -0.00470147 0.162076 -0.00442942 0.188093 -0.00349391 0.216728 -0.00254819 0.24387 0.308335 0.000528873 0.0877278 -0.00250282 -0.00111997 0.0959856 -0.00226111 0.107118 -0.00310123 0.121617 -0.00364475 0.139905 -0.00384851 0.16228 -0.00364193 0.187886 -0.00288605 0.215972 -0.00214722 0.243131 0.306187 0.00122404 0.0896645 -0.00316075 -0.00038908 0.0975987 -0.00143039 0.108159 -0.00221175 0.122399 -0.00271792 0.140412 -0.00293013 0.162492 -0.00280578 0.187762 -0.00222303 0.215389 -0.00170998 0.242618 0.304477 0.00196295 0.0915292 -0.0038276 0.000469166 0.0990925 -0.000507764 0.109136 -0.00122758 0.123119 -0.00169708 0.140881 -0.00192079 0.162716 -0.00188471 0.187726 -0.00149742 0.215002 -0.00123332 0.242354 0.303244 0.00273951 0.0932902 -0.00450059 0.00140391 0.100428 0.000496988 0.110043 -0.000173393 0.123789 -0.000587489 0.141295 -0.000828127 0.162957 -0.000866674 0.187765 -0.000714885 0.21485 -0.000713968 0.242353 0.30253 0.00354123 0.0949209 -0.00517191 0.00235265 0.101617 0.00154514 0.110851 0.000983448 0.124351 0.000599914 0.141679 0.000332632 0.163224 0.000231804 0.187865 0.000103516 0.214978 -0.000145348 0.242602 0.302385 0.00436278 0.0963851 -0.00582699 0.0033189 0.102661 0.00261676 0.111553 0.00215203 0.124815 0.00181669 0.142014 0.00155451 0.163486 0.00130893 0.188111 0.00101306 0.215274 0.000405553 0.243209 0.30279 0.00518296 0.0976387 -0.00643655 0.00428506 0.103558 0.00369408 0.112144 0.00332447 0.125185 0.00304555 0.142293 0.00277467 0.163757 0.00242537 0.18846 0.00190719 0.215792 0.000971069 0.244145 0.303761 0.00599187 0.0986409 -0.00699404 0.00524362 0.104307 0.00476734 0.11262 0.00449411 0.125458 0.00427371 0.142513 0.00400095 0.16403 0.00355183 0.188909 0.00281052 0.216534 0.00155054 0.245405 0.305312 0.00676034 0.0993627 -0.00748211 0.00616523 0.104902 0.00580484 0.112981 0.00562857 0.125635 0.00547358 0.142668 0.00520792 0.164295 0.00466538 0.189452 0.00371447 0.217484 0.00213205 0.246988 0.307444 0.0074685 0.0997829 -0.00788873 0.00702958 0.105341 0.00678146 0.113229 0.00670053 0.125715 0.00661909 0.14275 0.00636744 0.164547 0.00574419 0.190075 0.0045991 0.21863 0.00270306 0.248884 0.310147 0.00810032 0.0998844 -0.00820179 0.00782199 0.105619 0.00767894 0.113372 0.00768937 0.125705 0.00768604 0.142753 0.00746205 0.164771 0.00678046 0.190757 0.0054572 0.219953 0.00326321 0.251078 0.31341 0.0086346 0.0996636 -0.00841385 0.00851999 0.105734 0.00847219 0.11342 0.00856659 0.125611 0.00864237 0.142677 0.00845543 0.164958 0.00773832 0.191474 0.00625933 0.221432 0.00379437 0.253543 0.317205 0.0090792 0.0991125 -0.00852808 0.00913655 0.105676 0.00917012 0.113386 0.00933884 0.125442 0.00949638 0.14252 0.00936106 0.165093 0.00863028 0.192205 0.00701894 0.223043 0.00430557 0.256256 0.32151 0.00937015 0.0982946 -0.00855221 0.00959844 0.105448 0.00970595 0.113278 0.00993591 0.125212 0.0101691 0.142287 0.0100921 0.16517 0.00937581 0.192921 0.00767754 0.224741 0.00476088 0.259173 0.326271 0.00969994 0.097142 -0.00854738 0.0101031 0.105045 0.0102433 0.113138 0.0105062 0.124949 0.0108034 0.141989 0.0107868 0.165187 0.0100891 0.193619 0.0083059 0.226525 0.00519412 0.262284 0.331465 0.00954805 0.0960638 -0.00846983 0.0100925 0.1045 0.0103333 0.112897 0.0106332 0.124649 0.0110027 0.14162 0.0110673 0.165122 0.0104732 0.194213 0.00869368 0.228304 0.00551667 0.265461 0.336982 -0.0503266 0.0899734 0.056417 -0.0431982 0.097372 -0.0374961 0.107195 -0.0319133 0.119066 -0.0263181 0.136025 -0.0205011 0.159305 -0.0144198 0.188131 -0.00833818 0.222222 -0.00386082 0.260984 0.333121 -0.0688271 0.0831662 0.0756343 -0.0616295 0.0901744 -0.0544187 0.0999845 -0.0465507 0.111198 -0.0387852 0.128259 -0.0307173 0.151237 -0.0221086 0.179523 -0.0134107 0.213525 -0.00626175 0.253835 0.326859 -0.089396 0.0757176 0.0968446 -0.0808447 0.0816232 -0.0714104 0.0905501 -0.0618106 0.101599 -0.0524667 0.118915 -0.0420667 0.140837 -0.0307147 0.168171 -0.0189733 0.201783 -0.00858255 0.243444 0.318277 -0.111976 0.066873 0.120821 -0.100702 0.0703491 -0.0898674 0.0797152 -0.0792521 0.0909833 -0.0679096 0.107573 -0.0546749 0.127603 -0.0404067 0.153902 -0.0253094 0.186686 -0.0113422 0.229477 0.306935 -0.134897 0.0558066 0.145963 -0.122876 0.0583278 -0.111938 0.0687769 -0.0995799 0.0786256 -0.0857604 0.0937533 -0.0698537 0.111696 -0.0525303 0.136579 -0.0332624 0.167418 -0.0146368 0.210852 0.292298 -0.161575 0.0450491 0.172332 -0.14947 0.0462225 -0.137572 0.0568792 -0.123037 0.0640907 -0.107135 0.0778515 -0.0884615 0.0930225 -0.06734 0.115458 -0.0433366 0.143415 -0.0199743 0.187489 0.272323 -0.193151 0.0326954 0.205505 -0.181741 0.0348121 -0.168325 0.0434637 -0.15236 0.0481252 -0.134578 0.0600696 -0.112779 0.0712238 -0.0874421 0.0901206 -0.0585324 0.114505 -0.0282417 0.157199 0.244082 -0.232338 0.0214618 0.243571 -0.219857 0.0223311 -0.204573 0.0281805 -0.187434 0.0309862 -0.167222 0.0398567 -0.142754 0.0467564 -0.114226 0.0615927 -0.0810485 0.0813271 -0.0432631 0.119413 0.200819 -0.283271 0.00920928 0.295524 -0.270741 0.00980103 -0.254992 0.0124315 -0.238144 0.0141387 -0.216951 0.0186633 -0.19278 0.0225858 -0.162782 0.031594 -0.125045 0.0435908 -0.0735938 0.0679617 0.127225 -0.347992 0.357201 -0.338191 -0.325759 -0.31162 -0.292957 -0.270371 -0.238777 -0.195187 -0.127225 0.00606252 0.0581193 -0.00776486 0.00318645 0.0785103 6.25528e-05 0.0999685 -0.00198404 0.122868 -0.00376425 0.147744 -0.0051733 0.173741 -0.00575015 0.206082 -0.00574584 0.243567 -0.00389091 0.293669 0.35331 0.00641381 0.0595191 -0.00781356 0.0038419 0.0810822 0.00107018 0.10274 -0.00131433 0.125252 -0.00322616 0.149656 -0.00470436 0.17522 -0.00542526 0.206803 -0.00544485 0.243586 -0.00374657 0.29197 0.349563 0.00707009 0.0602992 -0.00785018 0.00485816 0.0832942 0.00224881 0.10535 -0.00028588 0.127787 -0.002204 0.151574 -0.00374999 0.176766 -0.00460851 0.207661 -0.00468432 0.243662 -0.00338363 0.29067 0.34618 0.00775021 0.060463 -0.00791398 0.00594305 0.0851013 0.00351031 0.107782 0.00104518 0.130252 -0.00100705 0.153626 -0.00262099 0.178379 -0.0035896 0.20863 -0.00384093 0.243914 -0.00293021 0.289759 0.34325 0.00844884 0.0600397 -0.00802563 0.00707718 0.086473 0.00484486 0.110015 0.00246572 0.132631 0.000280483 0.155811 -0.00139818 0.180058 -0.00246461 0.209696 -0.0029425 0.244391 -0.00238351 0.2892 0.340866 0.00920224 0.0590334 -0.00819587 0.00830687 0.0873684 0.00630396 0.112018 0.00400708 0.134928 0.00186989 0.157948 -0.000121128 0.182049 -0.00123507 0.21081 -0.00197519 0.245132 -0.00177249 0.288997 0.339094 0.0100038 0.0574573 -0.00842772 0.00962527 0.0877469 0.00789488 0.113748 0.00569452 0.137128 0.00354996 0.160093 0.00158191 0.184017 0.000119651 0.212272 -0.00093351 0.246185 -0.00110441 0.289168 0.337989 0.0108308 0.0553407 -0.0087142 0.0109983 0.0875794 0.00958901 0.115157 0.00750999 0.139207 0.00535407 0.162249 0.00330196 0.186069 0.00162506 0.213949 0.000186732 0.247623 -0.000377057 0.289732 0.337612 0.0116558 0.0527235 -0.00903858 0.012387 0.0868482 0.0113458 0.116198 0.00941925 0.141134 0.00725613 0.164412 0.00509907 0.188226 0.00319035 0.215858 0.00152021 0.249293 0.000370081 0.290882 0.337982 0.012447 -0.00938041 0.0137497 0.0131189 0.0113852 0.00922041 0.00696886 0.00482554 0.00282868 0.00112623 0.000607583 -0.00259266 0.00179792 -0.00699573 0.00325005 -0.0101252 0.00476858 -0.0120034 0.00625693 -0.0128774 0.00768227 -0.0130295 0.00904482 -0.0127014 0.0103578 -0.0120758 0.011637 -0.0112853 -0.0104416 0.000660021 -0.00325268 0.00188912 -0.00822483 0.003328 -0.0115641 0.00477757 -0.0134529 0.00615462 -0.0142544 0.00744363 -0.0143185 0.00865903 -0.0139168 0.00982252 -0.0132392 0.0109517 -0.0124145 -0.0115419 0.000694288 -0.00394697 0.00191671 -0.00944724 0.00327987 -0.0129272 0.00459267 -0.0147657 0.00579376 -0.0154555 0.00688967 -0.0154144 0.007912 -0.0149391 0.00889437 -0.0142216 0.00986182 -0.0133819 -0.0125034 0.000705149 -0.00465212 0.00187023 -0.0106123 0.00309498 -0.014152 0.00420888 -0.0158796 0.00517878 -0.0164254 0.0060347 -0.0162704 0.00682421 -0.0157286 0.00759096 -0.0149884 0.00836656 -0.0141575 -0.013304 0.000688316 -0.00534044 0.00174405 -0.0116681 0.00277315 -0.0151811 0.0036372 -0.0167437 0.00433452 -0.0171227 0.00491672 -0.0168526 0.00544342 -0.0162553 0.00596415 -0.0155091 0.00651381 -0.0147072 -0.0139034 0.000641036 -0.00598147 0.00153814 -0.0125652 0.00232441 -0.0159673 0.00290211 -0.0173214 0.00330078 -0.0175214 0.0035891 -0.0171409 0.00383325 -0.0164995 0.00408375 -0.0157596 0.00437492 -0.0149984 -0.0142567 0.000562562 -0.00654404 0.0012582 -0.0132608 0.0017673 -0.0164764 0.00203744 -0.0175915 0.00212579 -0.0176097 0.002112 -0.0171271 0.00206308 -0.0164506 0.00202582 -0.0157223 0.00203044 -0.015003 -0.0143224 0.00045438 -0.00699841 0.000914885 -0.0137213 0.00112629 -0.0166878 0.0010819 -0.0175471 0.000860228 -0.0173881 0.000545726 -0.0168126 0.00020101 -0.0161058 -0.000133441 -0.0153879 -0.00043488 -0.0147015 -0.0140641 0.000320111 -0.00731852 0.000522572 -0.0139238 0.000428894 -0.0165942 7.38425e-05 -0.0171921 -0.000446981 -0.0168672 -0.00105239 -0.0162072 -0.00168717 -0.0154711 -0.00232012 -0.014755 -0.00293545 -0.0140862 -0.0134731 0.000164865 -0.00748339 9.88673e-05 -0.0138578 -0.00029647 -0.0161988 -0.000946396 -0.0165422 -0.00175059 -0.0160631 -0.00263174 -0.015326 -0.00354439 -0.0145584 -0.00446588 -0.0138335 -0.00538723 -0.0131649 -0.012552 2.89124e-05 -0.0075123 -0.000297229 -0.0135316 -0.000980351 -0.0155157 -0.00191039 -0.0156121 -0.00298143 -0.014992 -0.00412377 -0.0141837 -0.00530102 -0.0133812 -0.00649778 -0.0126367 -0.00771018 -0.0119525 -0.0113209 -0.000138095 -0.00737421 -0.000725219 -0.0129445 -0.00167649 -0.0145644 -0.00285771 -0.0144309 -0.00416502 -0.0136847 -0.00553858 -0.0128101 -0.00695076 -0.011969 -0.0083919 -0.0111956 -0.00986123 -0.0104831 -0.00981925 -0.000304505 -0.0070697 -0.00113774 -0.0121113 -0.0023324 -0.0133698 -0.00373598 -0.0130273 -0.00525065 -0.01217 -0.00682699 -0.0112338 -0.00844504 -0.0103509 -0.0100991 -0.00954146 -0.0117899 -0.00879234 -0.00808746 -0.00046461 -0.00660509 -0.00152319 -0.0110527 -0.00293242 -0.0119605 -0.00452717 -0.0114326 -0.00621824 -0.010479 -0.00796659 -0.00948544 -0.00975875 -0.00855877 -0.0115917 -0.00770848 -0.0134663 -0.00691773 -0.00616761 -0.000613315 -0.00599178 -0.00187207 -0.00979394 -0.00346475 -0.0103679 -0.00521824 -0.00967908 -0.00705334 -0.00864386 -0.00894108 -0.0075977 -0.0108738 -0.00662609 -0.0128503 -0.00573192 -0.0148709 -0.00489715 -0.00410105 -0.000746527 -0.00524525 -0.00217746 -0.00836301 -0.00392161 -0.00862371 -0.00580113 -0.00779956 -0.00774705 -0.00669794 -0.00973991 -0.00560484 -0.0117777 -0.00458835 -0.0138614 -0.00364818 -0.0159902 -0.00276829 -0.00192787 -0.000861286 -0.00438396 -0.00243504 -0.00678926 -0.00429921 -0.00675954 -0.006273 -0.00582576 -0.00829665 -0.00467429 -0.0103591 -0.00354239 -0.0124641 -0.00248339 -0.014616 -0.0014962 -0.0168141 -0.000570232 0.000311838 -0.000955721 -0.00342824 -0.00264288 -0.0051021 -0.00459755 -0.00480487 -0.00663663 -0.00378668 -0.00870724 -0.00260368 -0.0108043 -0.00144533 -0.0129365 -0.000351233 -0.0151133 0.000680625 -0.0173363 0.00165277 0.00257564 -0.00102887 -0.00239938 -0.00280096 -0.00333001 -0.00481987 -0.00278596 -0.00690057 -0.00170598 -0.00899414 -0.000510107 -0.0110976 0.000658129 -0.0132206 0.00177173 -0.0153763 0.00283632 -0.0175695 0.00384603 0.00482193 -0.00108034 -0.00131904 -0.00291022 -0.00150013 -0.00497098 -0.000725201 -0.00707735 0.000400388 -0.00918397 0.00159651 -0.0112886 0.0027628 -0.0133972 0.00388028 -0.0155184 0.00495749 -0.01767 0.00599772 0.00695307 -0.00111128 -0.00020776 -0.00297421 0.000362806 -0.00505727 0.00135786 -0.00717847 0.00252159 -0.00930128 0.00371932 -0.0114366 0.00489812 -0.0136094 0.00605304 -0.0158512 0.00719932 -0.0182079 0.00835443 0.00956446 -0.00111853 0.00091077 -0.00298502 0.00222929 -0.00506625 0.00343909 -0.00718357 0.0046389 -0.00930524 0.00584099 -0.0114451 0.00703801 -0.0136239 0.00823176 -0.0158537 0.0094292 -0.0181314 0.0106321 0.0118274 -0.00110163 0.00201241 -0.00294331 0.00407097 -0.00499698 0.00549276 -0.00708391 0.00672583 -0.00916978 0.00792686 -0.0112615 0.00912975 -0.0133663 0.0103365 -0.015477 0.0115399 -0.0175694 0.0127244 0.0138579 -0.00106136 0.00307377 -0.00284976 0.00585937 -0.00484858 0.00749158 -0.00687582 0.00875306 -0.00888953 0.00994057 -0.010887 0.0111272 -0.0128654 0.0123149 -0.014812 0.0134865 -0.0167084 0.0146208 0.0156924 -0.000999247 0.00407301 -0.00270707 0.00756719 -0.00462466 0.00940918 -0.00656508 0.0106935 -0.00847675 0.0118523 -0.0103488 0.0129993 -0.0121743 0.0141404 -0.0139439 0.0152561 -0.0156513 0.0163282 0.0173449 -0.000917629 0.00499064 -0.00251994 0.0091695 -0.00433267 0.0112219 -0.00616383 0.0125246 -0.00795203 0.0136404 -0.00968036 0.0147276 -0.0113421 0.0158022 -0.012934 0.016848 -0.0144598 0.0178541 0.0188205 -0.000819524 0.00581017 -0.00229471 0.0106447 -0.00398267 0.0129099 -0.00568753 0.0142295 -0.00733854 0.0152915 -0.00891428 0.0163033 -0.0104095 0.0172974 -0.0118265 0.018265 -0.0131754 0.019203 0.0201194 -0.0007084 0.00651857 -0.00203877 0.0119751 -0.00358614 0.0144572 -0.00515279 0.0157961 -0.00665919 0.0167979 -0.00807976 0.0177239 -0.0094103 0.0186279 -0.0106568 0.0195115 -0.0118317 0.0203779 0.0212406 -0.000587858 0.00710642 -0.00175996 0.0131472 -0.00315503 0.0158523 -0.00457602 0.0172171 -0.00593524 0.0181571 -0.00720251 0.0189911 -0.00837334 0.0197987 -0.00945492 0.0205931 -0.0104599 0.0213829 0.022184 -0.000461122 0.00756755 -0.00146601 0.014152 -0.00270107 0.0170874 -0.00397271 0.0184888 -0.00518589 0.0193703 -0.00630503 0.0201103 -0.00732376 0.0208175 -0.00824852 0.0215178 -0.00909016 0.0222245 0.0229536 -0.000366728 0.00793427 -0.00121135 0.0149967 -0.00228291 0.0181589 -0.00340123 0.0196071 -0.00446735 0.0204364 -0.00544047 0.0210834 -0.0063111 0.0216881 -0.00708356 0.0222903 -0.00776599 0.0229069 0.0235522 -0.000250572 0.00818485 -0.000925656 0.0156718 -0.0018319 0.0190652 -0.00280079 0.020576 -0.00372889 0.0213645 -0.00456927 0.0219238 -0.00530817 0.022427 -0.00594697 0.0229291 -0.00649102 0.023451 0.0240034 -0.00013998 0.00832483 -0.000647258 0.016179 -0.00138889 0.0198068 -0.0022116 0.0213987 -0.00300905 0.0221619 -0.00372801 0.0226427 -0.00434975 0.0230487 -0.00487231 0.0234517 -0.0052987 0.0238774 0.0243326 -3.74486e-05 0.00836227 -0.00038109 0.0165227 -0.000961203 0.0203869 -0.00164233 0.0220798 -0.00231726 0.0228369 -0.00292684 0.0232523 -0.00344691 0.0235688 -0.00387201 0.0238768 -0.00420361 0.024209 0.0245683 5.6812e-05 0.00830546 -0.000129598 0.0167091 -0.000554755 0.0208121 -0.00109975 0.0226248 -0.00166047 0.0233976 -0.00217257 0.0237644 -0.00260627 0.0240025 -0.0029523 0.0242228 -0.00321147 0.0244682 0.0247397 0.000139351 0.00816611 9.97299e-05 0.0167487 -0.000174101 0.0210859 -0.000588865 0.0230396 -0.0010433 0.023852 -0.00146894 0.0241901 -0.00183026 0.0243639 -0.0021134 0.0245059 -0.00231893 0.0246737 0.0248736 0.000210289 0.00795582 0.000303904 0.0166551 0.000176698 0.0212131 -0.000112852 0.0233291 -0.000468469 0.0242076 -0.000817355 0.0245389 -0.00111858 0.0246651 -0.00135222 0.0247396 -0.00151489 0.0248364 0.024987 0.000270077 0.00768574 0.000487182 0.016438 0.00049558 0.0212047 0.000325494 0.0234992 6.29811e-05 0.0244702 -0.000217018 0.0248189 -0.000467576 0.0249156 -0.000663269 0.0249353 -0.000785518 0.0249586 0.0250764 0.000318878 0.00736687 0.000647209 0.0161097 0.000783314 0.0210686 0.000726584 0.0235559 0.000551193 0.0246455 0.000332205 0.0250379 0.000122583 0.0251253 -4.30648e-05 0.0251009 -0.000144416 0.02506 0.0250577 0.00035722 0.00700965 0.000784267 0.0156826 0.00103954 0.0208133 0.00109118 0.0235043 0.000998629 0.0247381 0.000835639 0.0252009 0.000661383 0.0252995 0.000520507 0.0252418 0.000475328 0.0251051 0.0249504 0.00038425 0.0066254 0.000900257 0.0151666 0.0012707 0.0204429 0.00143116 0.0233438 0.001422 0.0247473 0.00130806 0.0253149 0.00113983 0.0254677 0.000931562 0.02545 0.000616069 0.0254206 0.0256158 0.000412347 0.00621305 0.00100741 0.0145715 0.00148227 0.019968 0.00174334 0.0230828 0.00181143 0.0246792 0.00174174 0.0253845 0.00158044 0.025629 0.00134453 0.025686 0.00101627 0.0257489 0.026012 0.00043134 0.00578171 0.00109392 0.013909 0.00166635 0.0193956 0.00202785 0.0227213 0.00217934 0.0245277 0.00216778 0.0253961 0.00204076 0.0257561 0.0018275 0.0258992 0.00154237 0.026034 0.026315 0.000442497 0.00533921 0.00116143 0.01319 0.00182467 0.0187324 0.0022869 0.022259 0.00252895 0.0242856 0.0025886 0.0253364 0.00251396 0.0258307 0.00234289 0.0260703 0.00210713 0.0262698 0.0265629 0.000446906 0.00489231 0.00121132 0.0124256 0.00195804 0.0179856 0.0025205 0.0216966 0.00285904 0.0239471 0.00300018 0.0251953 0.00299044 0.0258405 0.002874 0.0261867 0.00269366 0.0264501 0.0267538 0.000445514 0.00444679 0.00124469 0.0116264 0.00206661 0.0171637 0.00272742 0.0210358 0.00316698 0.0235075 0.00339867 0.0249636 0.00346531 0.0257738 0.00341489 0.0262371 0.00329616 0.0265689 0.0268892 0.000439145 0.00400765 0.00126243 0.0108031 0.00215014 0.016276 0.00290565 0.0202803 0.00344918 0.022964 0.00377935 0.0246334 0.00393276 0.0256204 0.00395814 0.0262118 0.00390654 0.0266204 0.0269681 0.000428525 0.00357912 0.00126535 0.00996632 0.00220812 0.0153332 0.00305262 0.0194358 0.00370096 0.0223157 0.00413572 0.0241987 0.00438477 0.0253714 0.00449472 0.0261018 0.00451701 0.0265982 0.0269845 0.000414344 0.00316478 0.00125425 0.00912641 0.00224004 0.0143475 0.00316539 0.0185104 0.00391672 0.0215643 0.0044599 0.0236555 0.00481171 0.0250196 0.00501414 0.0258994 0.00511765 0.0264947 0.0269303 0.000397316 0.00276746 0.00123031 0.00829341 0.00224599 0.0133318 0.00324146 0.0175149 0.00409076 0.020715 0.00474319 0.0230031 0.00520258 0.0245602 0.00550386 0.0255981 0.00569489 0.0263036 0.0267982 0.000359989 0.00240747 0.0011625 0.0074909 0.00218565 0.0123086 0.00323478 0.0164658 0.00417461 0.0197752 0.00493784 0.0222398 0.00551299 0.023985 0.00592472 0.0251864 0.00621562 0.0260127 0.0265772 0.000335851 0.00207162 0.00111106 0.00671569 0.00213477 0.0112849 0.00322538 0.0153752 0.00424335 0.0187573 0.00510762 0.0213756 0.00579167 0.023301 0.00630845 0.0246696 0.00669332 0.0256279 0.0262765 0.000309864 0.00176176 0.00104978 0.00597578 0.00206011 0.0102746 0.00317601 0.0142593 0.00425802 0.0176752 0.0052139 0.0204197 0.00600218 0.0225127 0.00662261 0.0240491 0.00710141 0.0251491 0.0258958 0.000282115 0.00147964 0.000979506 0.00527839 0.00196309 0.009291 0.00308734 0.013135 0.00421703 0.0165456 0.00525197 0.0193847 0.00613682 0.0216278 0.00685731 0.0233287 0.00742876 0.0245776 0.0254358 0.000252749 0.0012269 0.000901316 0.00462983 0.00184578 0.00834653 0.00296144 0.0120194 0.00412097 0.015386 0.00521977 0.0182859 0.00619054 0.0206571 0.00700487 0.0225143 0.00766558 0.0239169 0.0248996 0.00022201 0.00100489 0.000816548 0.00403529 0.00171101 0.00745207 0.00280196 0.0109284 0.00397288 0.0142151 0.0051184 0.0171404 0.00616184 0.0196136 0.00706148 0.0216147 0.00780635 0.023172 0.0242921 0.00019025 0.000814635 0.000726866 0.00349867 0.00156236 0.00661658 0.0026141 0.00987669 0.00377843 0.0130508 0.00495253 0.0159663 0.00605343 0.0185127 0.00702808 0.02064 0.00785196 0.0223481 0.023616 0.000157953 0.000656682 0.000634306 0.00302232 0.00140425 0.00584663 0.00240475 0.0088762 0.00354602 0.0119095 0.00473071 0.0147816 0.0058728 0.0173706 0.00691143 0.0196014 0.00781083 0.0214487 0.0228746 0.000125761 0.00053092 0.000541309 0.00260677 0.00124195 0.00514599 0.00218235 0.0079358 0.00328673 0.0108051 0.00446519 0.0136032 0.00563126 0.0162046 0.00672025 0.0185124 0.00770174 0.0204672 0.022029 9.44888e-05 0.000436431 0.000450723 0.00225054 0.00108146 0.00451526 0.0019568 0.00706046 0.00301418 0.00974775 0.0041722 0.0124451 0.00534543 0.0150313 0.00646266 0.0173952 0.00750858 0.0194213 0.0210678 6.49176e-05 0.000371514 0.000366011 0.00194944 0.00093106 0.00395021 0.00174321 0.00624831 0.00275155 0.00873941 0.00388251 0.0113142 0.00505112 0.0138627 0.00616477 0.0162815 0.00711087 0.0184752 0.0204138 3.93134e-05 0.0003322 0.000291556 0.0016972 0.000796608 0.00344515 0.00154826 0.00549666 0.00250622 0.00778145 0.00360618 0.0102142 0.00476967 0.0126992 0.00591186 0.0151394 0.00694663 0.0174405 0.0195468 1.72695e-05 0.000314931 0.000227959 0.00148651 0.000681942 0.00299117 0.00138162 0.00479698 0.00229627 0.00686681 0.00337182 0.00913866 0.00453955 0.0115315 0.00572386 0.013955 0.00684718 0.0163171 0.0185438 5.27605e-07 0.000314403 0.000177538 0.0013095 0.000591518 0.00257719 0.00125062 0.00413788 0.00213187 0.00598555 0.00319034 0.00808019 0.00436629 0.0103556 0.00559127 0.0127301 0.0067933 0.0151151 0.0174231 -1.37146e-05 0.000328117 0.000141451 0.00115433 0.000527937 0.0021907 0.00115941 0.00350641 0.00201894 0.00512603 0.0030689 0.00703022 0.00425728 0.0091672 0.00552255 0.0114648 0.0067986 0.0138391 0.0161961 -2.17094e-05 0.000349827 0.000120569 0.00101206 0.000491982 0.00181929 0.00110906 0.00288933 0.00195922 0.00427587 0.00301055 0.00597889 0.00421745 0.0079603 0.0055247 0.0101575 0.00687118 0.0124926 0.0148714 -2.44181e-05 0.000374245 0.000114783 0.000872856 0.000482957 0.00145112 0.0010979 0.00227439 0.00195012 0.00342365 0.00301229 0.00491672 0.00424417 0.00672842 0.00559589 0.00880581 0.0070107 0.0110778 0.0134544 -2.18941e-05 0.000396139 0.00012375 0.000727211 0.000499508 0.00107536 0.00112272 0.00165118 0.00198604 0.00256033 0.00306617 0.00383659 0.00432773 0.00546686 0.0057258 0.00740773 0.00720779 0.00959579 0.011948 -1.378e-05 0.000409919 0.000147472 0.000565959 0.000540772 0.00068206 0.00118078 0.00101116 0.00206127 0.00167984 0.00316279 0.00273508 0.00445516 0.00417448 0.00589879 0.00596411 0.00744562 0.00804896 0.010355 1.06914e-06 0.000186723 0.00060755 0.00127199 0.00217347 0.00329625 0.00461617 0.00610021 0.00770613 ) ; boundaryField { inlet { type calculated; value uniform 0; } outlet { type calculated; value nonuniform List<scalar> 40 ( 0.0824601 0.115438 0.139945 0.157917 0.17591 0.200437 0.236412 0.285559 0.342081 0.388996 0.0163775 0.0138388 0.0112268 0.00854729 0.00581334 0.00304462 0.000268131 -0.00248249 -0.00517221 -0.00776341 -0.0102226 -0.0125242 -0.0146518 -0.0165989 -0.0183677 -0.0199687 -0.0214186 -0.0227382 -0.0239506 -0.0250798 -0.102559 -0.117034 -0.132562 -0.150724 -0.173539 -0.202563 -0.23655 -0.269434 -0.293149 -0.305216 ) ; } cylinder { type calculated; value uniform 0; } top { type symmetryPlane; value uniform 0; } bottom { type symmetryPlane; value uniform 0; } defaultFaces { type empty; value nonuniform 0(); } } // ************************************************************************* //
825595f662eeb7de8490a655ac5aad5f0f6db4be
2b4fbc21a8bc43e6c485612cb665664a10cf7bf7
/Server/NetworkManager.cpp
dcc3fe7143f7e17472501974c8f03f11e265124c
[]
no_license
lexablackstar/aMessage
54fe7da30f57188174d78490a40692e57a9ecf3d
fb69981caa466d7cfb60481375adb8afdb47db8a
refs/heads/master
2022-11-27T07:20:34.926802
2020-07-27T14:46:02
2020-07-27T14:46:02
282,925,492
0
0
null
null
null
null
UTF-8
C++
false
false
914
cpp
NetworkManager.cpp
#include "NetworkManager.h" #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <arpa/inet.h> #include <netinet/in.h> NetworkManager::NetworkManager(){ } int NetworkManager::getIpByName(/*IN*/char* hostname,/*OUT*/ char* ip) { addrinfo hints, *res; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; int status = getaddrinfo(hostname, NULL, &hints, &res); if (status != 0) return status; void* addr; if (res->ai_family == AF_INET) { struct sockaddr_in *ipv4 = (struct sockaddr_in *)res->ai_addr; addr = &(ipv4->sin_addr); } else { struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)res->ai_addr; addr = &(ipv6->sin6_addr); } inet_ntop(res->ai_family, addr, ip, sizeof(ip)); freeaddrinfo(res); return 0; }
1be817d43a0f16a32efd1d0ffee031310685750d
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/components/password_manager/core/browser/ui/credential_ui_entry_unittest.cc
8d412ba698e864621e43a1e56202f3fb2cfd20b4
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
10,102
cc
credential_ui_entry_unittest.cc
// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/password_manager/core/browser/ui/credential_ui_entry.h" #include <vector> #include "base/strings/utf_string_conversions.h" #include "components/password_manager/core/browser/passkey_credential.h" #include "components/password_manager/core/browser/password_form.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" namespace password_manager { namespace { using testing::ElementsAre; using testing::UnorderedElementsAre; constexpr char kTestCom[] = "https://test.com"; constexpr char kTestComChangePassword[] = "https://test.com/.well-known/change-password"; constexpr char kAndroidSignonRealm[] = "android://certificate_hash@com.test.client/"; // Creates matcher for a given domain info auto ExpectDomain(const std::string& name, const GURL& url) { return AllOf(testing::Field(&CredentialUIEntry::DomainInfo::name, name), testing::Field(&CredentialUIEntry::DomainInfo::url, url)); } // Creates a CredentialUIEntry with the given insecurity issue. CredentialUIEntry CreateInsecureCredential(InsecureType insecure_type) { base::flat_map<InsecureType, InsecurityMetadata> form_issues; form_issues[insecure_type] = InsecurityMetadata(); PasswordForm form; form.password_issues = form_issues; return CredentialUIEntry(form); } } // namespace TEST(CredentialUIEntryTest, CredentialUIEntryFromForm) { const std::u16string kUsername = u"testUsername00"; const std::u16string kPassword = u"testPassword01"; PasswordForm form; form.app_display_name = "g.com"; form.signon_realm = "https://g.com/"; form.url = GURL(form.signon_realm); form.blocked_by_user = false; form.username_value = kUsername; form.password_value = kPassword; form.in_store = PasswordForm::Store::kProfileStore; CredentialUIEntry entry = CredentialUIEntry(form); unsigned long size = 1; EXPECT_TRUE(entry.passkey_credential_id.empty()); EXPECT_EQ(entry.facets.size(), size); EXPECT_EQ(entry.facets[0].signon_realm, "https://g.com/"); EXPECT_EQ(entry.stored_in.size(), size); EXPECT_EQ(entry.username, kUsername); EXPECT_EQ(entry.password, kPassword); EXPECT_EQ(entry.blocked_by_user, false); } TEST(CredentialUIEntryTest, CredentialUIEntryFromFormsVectorWithIdenticalNotes) { std::vector<PasswordForm> forms; const std::u16string kUsername = u"testUsername00"; const std::u16string kPassword = u"testPassword01"; const std::u16string kNote = u"Test New Note \n"; PasswordForm form; form.app_display_name = "g.com"; form.signon_realm = "https://g.com/"; form.url = GURL(form.signon_realm); form.blocked_by_user = false; form.username_value = kUsername; form.password_value = kPassword; form.SetNoteWithEmptyUniqueDisplayName(kNote); form.in_store = PasswordForm::Store::kProfileStore; forms.push_back(std::move(form)); PasswordForm form2; form2.app_display_name = "g2.com"; form2.signon_realm = "https://g2.com/"; form2.url = GURL(form2.signon_realm); form2.blocked_by_user = false; form2.username_value = kUsername; form2.password_value = kPassword; form2.SetNoteWithEmptyUniqueDisplayName(kNote); form2.in_store = PasswordForm::Store::kAccountStore; forms.push_back(std::move(form2)); PasswordForm form3; form3.app_display_name = "g3.com"; form3.signon_realm = "https://g3.com/"; form3.url = GURL(form3.signon_realm); form3.blocked_by_user = false; form3.username_value = kUsername; form3.password_value = kPassword; form3.in_store = PasswordForm::Store::kAccountStore; forms.push_back(std::move(form3)); CredentialUIEntry entry = CredentialUIEntry(forms); EXPECT_EQ(entry.facets.size(), forms.size()); EXPECT_EQ(entry.facets[0].signon_realm, "https://g.com/"); EXPECT_EQ(entry.facets[1].signon_realm, "https://g2.com/"); EXPECT_EQ(entry.facets[2].signon_realm, "https://g3.com/"); unsigned long stored_in_size = 2; EXPECT_EQ(entry.stored_in.size(), stored_in_size); EXPECT_EQ(entry.username, kUsername); EXPECT_EQ(entry.password, kPassword); EXPECT_EQ(entry.note, kNote); EXPECT_EQ(entry.blocked_by_user, false); } TEST(CredentialUIEntryTest, CredentialUIEntryFromPasskey) { const std::vector<uint8_t> cred_id = {1, 2, 3, 4}; const std::vector<uint8_t> user_id = {5, 6, 7, 4}; const std::u16string kUsername = u"marisa"; const std::u16string kDisplayName = u"Marisa Kirisame"; PasskeyCredential passkey( PasskeyCredential::Source::kAndroidPhone, PasskeyCredential::RpId("rpid.com"), PasskeyCredential::CredentialId(cred_id), PasskeyCredential::UserId(user_id), PasskeyCredential::Username(base::UTF16ToUTF8(kUsername)), PasskeyCredential::DisplayName(base::UTF16ToUTF8(kDisplayName))); CredentialUIEntry entry(passkey); EXPECT_EQ(entry.passkey_credential_id, cred_id); EXPECT_EQ(entry.username, kUsername); EXPECT_EQ(entry.user_display_name, kDisplayName); ASSERT_EQ(entry.facets.size(), 1u); EXPECT_EQ(entry.facets.at(0).url, GURL("https://rpid.com/")); EXPECT_EQ(entry.facets.at(0).signon_realm, "https://rpid.com"); EXPECT_TRUE(entry.stored_in.empty()); } TEST(CredentialUIEntryTest, TestGetAffiliatedDomains) { std::vector<PasswordForm> forms; PasswordForm android_form; android_form.signon_realm = kAndroidSignonRealm; android_form.app_display_name = "g3.com"; android_form.affiliated_web_realm = kTestCom; PasswordForm web_form; web_form.signon_realm = "https://g.com/"; web_form.url = GURL(web_form.signon_realm); CredentialUIEntry entry = CredentialUIEntry({android_form, web_form}); EXPECT_THAT(entry.GetAffiliatedDomains(), UnorderedElementsAre( ExpectDomain(android_form.app_display_name, GURL(android_form.affiliated_web_realm)), ExpectDomain("g.com", web_form.url))); } TEST(CredentialUIEntryTest, TestGetAffiliatedDomainsHttpForm) { PasswordForm form; form.signon_realm = "http://g.com/"; form.url = GURL(form.signon_realm); CredentialUIEntry entry = CredentialUIEntry({form}); EXPECT_THAT(entry.GetAffiliatedDomains(), ElementsAre(ExpectDomain("http://g.com", GURL(form.url)))); } TEST(CredentialUIEntryTest, TestGetAffiliatedDomainsEmptyAndroidForm) { PasswordForm android_form; android_form.signon_realm = kAndroidSignonRealm; CredentialUIEntry entry = CredentialUIEntry({android_form}); EXPECT_THAT(entry.GetAffiliatedDomains(), ElementsAre(ExpectDomain( "client.test.com", GURL("https://play.google.com/store/apps/" "details?id=com.test.client")))); } TEST(CredentialUIEntryTest, CredentialUIEntryFromFormsVectorWithDifferentNotes) { std::vector<PasswordForm> forms; const std::u16string kNotes[] = {u"Note", u"", u"Another note"}; for (const auto& kNote : kNotes) { PasswordForm form; form.signon_realm = "https://g.com/"; form.url = GURL(form.signon_realm); form.password_value = u"pwd"; form.SetNoteWithEmptyUniqueDisplayName(kNote); forms.push_back(std::move(form)); } CredentialUIEntry entry = CredentialUIEntry(forms); // Notes are concatenated alphabetically. EXPECT_EQ(entry.note, kNotes[2] + u"\n" + kNotes[0]); } TEST(CredentialUIEntryTest, CredentialUIEntryInsecureHelpers) { PasswordForm form; auto entry = CredentialUIEntry(form); EXPECT_FALSE(entry.IsLeaked()); EXPECT_FALSE(entry.IsPhished()); EXPECT_FALSE(entry.IsWeak()); EXPECT_FALSE(entry.IsReused()); auto leaked_entry = CreateInsecureCredential(InsecureType::kLeaked); EXPECT_TRUE(leaked_entry.IsLeaked()); EXPECT_TRUE(IsCompromised(leaked_entry)); auto phished_entry = CreateInsecureCredential(InsecureType::kPhished); EXPECT_TRUE(phished_entry.IsPhished()); EXPECT_TRUE(IsCompromised(phished_entry)); auto weak_entry = CreateInsecureCredential(InsecureType::kWeak); EXPECT_TRUE(weak_entry.IsWeak()); auto reused_entry = CreateInsecureCredential(InsecureType::kReused); EXPECT_TRUE(reused_entry.IsReused()); } TEST(CredentialUIEntryTest, TestGetAffiliatedDomainsWithDuplicates) { PasswordForm form1; form1.signon_realm = "https://g.com/"; form1.url = GURL("https://g.com/"); PasswordForm form2; form2.signon_realm = "https://g.com/"; form2.url = GURL("https://g.com/"); CredentialUIEntry entry = CredentialUIEntry({form1, form2}); EXPECT_THAT(entry.GetAffiliatedDomains(), ElementsAre(ExpectDomain("g.com", form1.url))); } TEST(CredentialUIEntryTest, TestGetAffiliatedDuplicatesWithDifferentUrls) { PasswordForm form1; form1.signon_realm = "https://g.com/"; form1.url = GURL("https://g.com/login/"); PasswordForm form2; form2.signon_realm = "https://g.com/"; form2.url = GURL("https://g.com/sign%20in/"); CredentialUIEntry entry = CredentialUIEntry({form1, form2}); EXPECT_THAT(entry.GetAffiliatedDomains(), UnorderedElementsAre(ExpectDomain("g.com", form1.url), ExpectDomain("g.com", form2.url))); } TEST(CredentialUIEntryTest, TestGetChangeURLAndroid) { PasswordForm android_form; android_form.signon_realm = kAndroidSignonRealm; android_form.affiliated_web_realm = kTestCom; CredentialUIEntry entry = CredentialUIEntry(android_form); EXPECT_EQ(entry.GetChangePasswordURL(), GURL(kTestComChangePassword)); } TEST(CredentialUIEntryTest, TestGetChangeURLAndroidNoAffiliatedWebRealm) { PasswordForm android_form; android_form.signon_realm = kAndroidSignonRealm; CredentialUIEntry entry = CredentialUIEntry(android_form); EXPECT_FALSE(entry.GetChangePasswordURL()); } TEST(CredentialUIEntryTest, TestGetChangeURLWebForm) { PasswordForm web_form; web_form.url = GURL(kTestCom); CredentialUIEntry entry = CredentialUIEntry(web_form); EXPECT_EQ(entry.GetChangePasswordURL(), GURL(kTestComChangePassword)); } } // namespace password_manager
bec64a4b33521378fc24f06612ea29d1db63e9fb
d4aa4759471cc50f4bbb666fd48cabcdc2fba294
/leetcode/cpp/Array/33.cpp
662cc8b8818f1aab4b21cf473a4c709743cb8f32
[ "MIT" ]
permissive
zubairwazir/code_problems
e9cfc528a90c3ab676fe5959445dcaa7666b5767
a2085f19f0cc7340f1fc0c71e3a61151e435e484
refs/heads/master
2023-09-02T03:08:09.303116
2021-11-17T03:40:42
2021-11-17T03:40:42
429,559,611
1
0
MIT
2021-11-18T19:47:49
2021-11-18T19:47:49
null
UTF-8
C++
false
false
1,971
cpp
33.cpp
class Solution { public: int binarySearchHelper(vector<int> &nums, int lo, int hi, int target){ //simple binary search int mid; while(lo<=hi){ mid= lo + (hi-lo)/2; if (nums[mid]==target) return mid; else if (nums[mid]>target){ hi= mid-1; } else lo= mid +1; } return -1; } // using the binary search predicate framework: more info at https://www.topcoder.com/community/competitive-programming/tutorials/binary-search/ int search(vector<int>& nums, int target) { int n= nums.size(), lo= 0, hi= n-1, mid; int resIdx=-1;//final result index if (n==0) return -1; //find the minimum of the input array using, the predicate //P(x): A[x]<=A[0] //3 4 5 1 2 //F F F T T, x=mid, thus F*T* framework and the finding the first T is the aim while (lo<hi){ mid= lo+ (hi-lo)/2; if (nums[mid]<nums[0]) hi= mid; else lo= mid+1; } int min= lo; //lo is the index of the minimum element //now we have 2 sorted(ascending) subarrays, thus do a binary search on each of them if (nums[lo]==target){ return lo; } else { //simple binary search on nums[0:lo-1] resIdx= binarySearchHelper(nums, 0, min-1, target); if (resIdx!=-1) return resIdx; //not found in the first part resIdx= binarySearchHelper(nums, min, n-1, target); //binary search on nums[lo+1,n-1] second part } return resIdx;//target not found anywhere } }; //================================================== //Time complexity of the algorithm(asymptotically): O(log(n)), where n is the size of the input array //Space complexity: O(1), constant
7ed00687b67d32f75c8b5467d5036a9322e94531
0e7af5c612f009ad3e234519ec52743d7e287882
/MythCore/message/message.hxx.pb.cc
ac3d8da432ec2efaffe6705d2f33dd71f622c5fa
[]
no_license
jefferyyellow/MythCore
678b1f777f51b8cf3e4f40299b4e2f29882b9cf1
4f2d09dec8e772b190c48f718febec8853671cd9
refs/heads/master
2021-08-01T00:58:58.711347
2021-07-22T15:06:17
2021-07-22T15:06:17
43,931,424
3
1
null
null
null
null
UTF-8
C++
false
true
3,973
cc
message.hxx.pb.cc
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: message.hxx #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include "message.hxx.pb.h" #include <algorithm> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/port.h> #include <google/protobuf/stubs/once.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/wire_format_lite_inl.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> // @@protoc_insertion_point(includes) namespace { const ::google::protobuf::EnumDescriptor* MESSAGE_MODULE_ID_descriptor_ = NULL; } // namespace void protobuf_AssignDesc_message_2ehxx() GOOGLE_ATTRIBUTE_COLD; void protobuf_AssignDesc_message_2ehxx() { protobuf_AddDesc_message_2ehxx(); const ::google::protobuf::FileDescriptor* file = ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( "message.hxx"); GOOGLE_CHECK(file != NULL); MESSAGE_MODULE_ID_descriptor_ = file->enum_type(0); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_message_2ehxx); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); } } // namespace void protobuf_ShutdownFile_message_2ehxx() { } void protobuf_InitDefaults_message_2ehxx_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; } GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_message_2ehxx_once_); void protobuf_InitDefaults_message_2ehxx() { ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_message_2ehxx_once_, &protobuf_InitDefaults_message_2ehxx_impl); } void protobuf_AddDesc_message_2ehxx_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; protobuf_InitDefaults_message_2ehxx(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\013message.hxx*\304\002\n\021MESSAGE_MODULE_ID\022\030\n\024M" "ESSAGE_MODULE_LOGIN\020\000\022\034\n\027MESSAGE_MODULE_" "PROPERTY\020\200\010\022\030\n\023MESSAGE_MODULE_ITEM\020\200\020\022\027\n" "\022MESSAGE_MODULE_MAP\020\200\030\022\030\n\023MESSAGE_MODULE" "_TASK\020\200 \022\031\n\024MESSAGE_MODULE_SKILL\020\200(\022\030\n\023M" "ESSAGE_MODULE_CHAT\020\2000\022\036\n\031MESSAGE_MODULE_" "SERVER_ACT\020\2008\022\035\n\030MESSAGE_MODULE_DAILY_AC" "T\020\200@\022\030\n\023MESSAGE_MODULE_RANK\020\200H\022\034\n\027MESSAG" "E_MODULE_INSTANCE\020\200Pb\006proto3", 348); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "message.hxx", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_message_2ehxx); } GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_message_2ehxx_once_); void protobuf_AddDesc_message_2ehxx() { ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_message_2ehxx_once_, &protobuf_AddDesc_message_2ehxx_impl); } // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_message_2ehxx { StaticDescriptorInitializer_message_2ehxx() { protobuf_AddDesc_message_2ehxx(); } } static_descriptor_initializer_message_2ehxx_; const ::google::protobuf::EnumDescriptor* MESSAGE_MODULE_ID_descriptor() { protobuf_AssignDescriptorsOnce(); return MESSAGE_MODULE_ID_descriptor_; } bool MESSAGE_MODULE_ID_IsValid(int value) { switch (value) { case 0: case 1024: case 2048: case 3072: case 4096: case 5120: case 6144: case 7168: case 8192: case 9216: case 10240: return true; default: return false; } } // @@protoc_insertion_point(namespace_scope) // @@protoc_insertion_point(global_scope)
d54fd92f05f9a0a776b66ecbbdaf642f4ffbbc32
44227276cdce0d15ee0cdd19a9f38a37b9da33d7
/arcane/extras/NumericalModel/src/NumericalModel/Algorithms/FiniteVolumeAlgo/LinearSystemAssembleOp.h
c5e6149c7c77c948c00404ed091fdce22801e68d
[ "Apache-2.0", "LGPL-2.1-or-later" ]
permissive
arcaneframework/framework
7d0050f0bbceb8cc43c60168ba74fff0d605e9a3
813cfb5eda537ce2073f32b1a9de6b08529c5ab6
refs/heads/main
2023-08-19T05:44:47.722046
2023-08-11T16:22:12
2023-08-11T16:22:12
357,932,008
31
21
Apache-2.0
2023-09-14T16:42:12
2021-04-14T14:21:07
C++
UTF-8
C++
false
false
31,857
h
LinearSystemAssembleOp.h
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*- #ifndef LINEARSYATEMASSEMBLEOP #define LINEARSYATEMASSEMBLEOP #include "Numerics/LinearSolver/Impl/LinearSystemTwoStepBuilder.h" //#define DEBUG_INFO template<class CellExpr> Real upStream(const Cell& T0,const Cell& T1,CellExpr& cell_exp) { return 1. ; } template<typename SystemBuilder> struct MassTerm { template<typename MassExpr, typename RHSExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::Entry const& uhi_entry, typename SystemBuilder::Equation const& bal_eqn, const CellGroup& internal_cells, const MassExpr& mass, const RHSExpr& rhs) { IIndexManager* manager = builder.getIndexManager(); // on assemble le terme d/dt ENUMERATE_CELL(icell, internal_cells) { const Cell& cell = *icell ; if (icell->isOwn()) { const IIndexManager::EquationIndex currentEquationIndex = manager->getEquationIndex(bal_eqn,cell); const IIndexManager::EntryIndex currentEntryIndex = manager->getEntryIndex(uhi_entry,cell); builder.addData(currentEquationIndex, currentEntryIndex, mass[cell] ); // Vol/dt * P^n builder.setRHSData(currentEquationIndex,rhs[cell]); //#define DEBUG_INFO #ifdef DEBUG_INFO cout<<"MASS["<<currentEquationIndex<<"]["<<currentEntryIndex<<"]="<<mass[cell]<<" S="<<rhs[cell]<<endl; #endif } } } static void defineProfile(LinearSystemTwoStepBuilder& builder, LinearSystemTwoStepBuilder::Entry const& uhi_entry, LinearSystemTwoStepBuilder::Equation const& bal_eqn, const CellGroup& internal_cells) { IIndexManager* manager = builder.getIndexManager(); // on assemble le terme d/dt ENUMERATE_CELL(icell, internal_cells) { const Cell & cell = *icell; builder.defineData(manager->defineEquationIndex(bal_eqn,cell), manager->defineEntryIndex(uhi_entry,cell)); } } } ; template<class SystemBuilder,class FluxModel> struct FluxTerm { template<typename LambdaExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::Entry const& uhi_entry, typename SystemBuilder::Equation const& bal_eqn, const FluxModel* model, const LambdaExpr& lambda_exp) { // DEFINE ENTRIES AND EQUATIONS IIndexManager* index_manager = builder.getIndexManager(); CoefficientArrayT<Cell>* cell_coefficients = model->getCellCoefficients() ; //////////////////////////////////////////////////////////// // Internal faces whose stencil contains cell unknowns only // ENUMERATE_FACE(iF, model->getCInternalFaces()) { const Face& F = *iF; const Cell& T0 = F.backCell(); // back cell const Cell& T1 = F.frontCell(); // front cell Real lambda = upStream(T0,T1,lambda_exp) ; // May be improved using a global array Array<Integer> entry_indices(cell_coefficients->stencilSize(F)); index_manager->getEntryIndex(uhi_entry, cell_coefficients->stencil(F), entry_indices); if(T0.isOwn()) builder.addData(index_manager->getEquationIndex(bal_eqn, T0), lambda, entry_indices, cell_coefficients->coefficients(F)); if(T1.isOwn()) builder.addData(index_manager->getEquationIndex(bal_eqn, T1), -lambda, entry_indices, cell_coefficients->coefficients(F)); #ifdef DEBUG_INFO cout<<"M["<<index_manager->getEquationIndex(bal_eqn, T0) <<"]["<<entry_indices[0]<<"]="<<lambda*cell_coefficients->coefficients(F)[0]<<endl; cout<<"M["<<index_manager->getEquationIndex(bal_eqn, T0) <<"]["<<entry_indices[1]<<"]="<<lambda*cell_coefficients->coefficients(F)[1]<<endl; cout<<"M["<<index_manager->getEquationIndex(bal_eqn, T1) <<"]["<<entry_indices[0]<<"]="<<-lambda*cell_coefficients->coefficients(F)[0]<<endl; cout<<"M["<<index_manager->getEquationIndex(bal_eqn, T1) <<"]["<<entry_indices[1]<<"]="<<-lambda*cell_coefficients->coefficients(F)[1]<<endl; #endif } } static void defineProfile(LinearSystemTwoStepBuilder& builder, LinearSystemTwoStepBuilder::Entry const& uhi_entry, LinearSystemTwoStepBuilder::Equation const& bal_eqn, FluxModel const* model) { IIndexManager* index_manager = builder.getIndexManager(); CoefficientArrayT<Cell>* cell_coefficients = model->getCellCoefficients() ; //////////////////////////////////////////////////////////// // Internal faces whose stencil contains cell unknowns only // ENUMERATE_FACE(iF, model->getCInternalFaces()) { const Face& F = *iF; const Cell& T0 = F.backCell(); // back cell const Cell& T1 = F.frontCell(); // front cell // May be improved using a global array Integer stencil_size = cell_coefficients->stencilSize(F) ; ItemVectorView stencil = cell_coefficients->stencil(F) ; Array<Integer> entry_indices(stencil_size); for(Integer i=0;i<stencil_size;++i) entry_indices[i] = index_manager->defineEntryIndex(uhi_entry,stencil[i]) ; if(T0.isOwn()) builder.defineData(index_manager->defineEquationIndex(bal_eqn, T0), entry_indices) ; if(T1.isOwn()) builder.defineData(index_manager->defineEquationIndex(bal_eqn, T1), entry_indices) ; } } template<typename LambdaExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::Entry const& uhi_entry, typename SystemBuilder::Equation const& bal_eqn, const LambdaExpr& velocity, const FaceGroup& faces) { // DEFINE ENTRIES AND EQUATIONS IIndexManager* index_manager = builder.getIndexManager(); //////////////////////////////////////////////////////////// // Internal faces whose stencil contains cell unknowns only // ENUMERATE_FACE(iF, faces) { const Face& F = *iF; const Cell& T0 = F.backCell(); // back cell const Cell& T1 = F.frontCell(); // front cell const IIndexManager::EntryIndex entryIndexT0 = index_manager->getEntryIndex(uhi_entry,T0); const IIndexManager::EntryIndex entryIndexT1 = index_manager->getEntryIndex(uhi_entry,T1); if(T0.isOwn()) builder.addData(index_manager->getEquationIndex(bal_eqn, T0), entryIndexT1, velocity[F]) ; if(T1.isOwn()) builder.addData(index_manager->getEquationIndex(bal_eqn, T1), entryIndexT0, -velocity[F]) ; } } } ; template<class SystemBuilder,class Model, typename Model::BCType bc_type> struct BCIFluxTerm { template<typename BCExpr> static void assemble(const Face& Fi, IIndexManager* index_manager, SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EquationIndex& bal_eqn_T1, typename SystemBuilder::Entry const& uhb_entry, Real taui, const BCExpr& bc_exp) ; } ; template<> template< class SystemBuilder> struct BCIFluxTerm<SystemBuilder,SubDomainModelProperty,SubDomainModelProperty::Neumann> { template<typename BCExpr> static void assemble(const Face& Fi, IIndexManager* index_manager, SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EquationIndex& bal_eqn_T1, typename SystemBuilder::Entry const& uhb_entry, Real taui, const BCExpr& bc_exp) { typename SystemBuilder::EntryIndex uhb_Fi = index_manager->getEntryIndex(uhb_entry, Fi); //if (T0.isOwn()) builder.addData(bal_eqn_T0, uhb_Fi, taui); //if (T1.isOwn()) builder.addData(bal_eqn_T1, uhb_Fi, -taui); } } ; template<> template<class SystemBuilder> struct BCIFluxTerm<SystemBuilder,SubDomainModelProperty,SubDomainModelProperty::Dirichlet> { template<typename BCExpr> static void assemble(const Face& Fi, IIndexManager* index_manager, SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EquationIndex& bal_eqn_T1, typename SystemBuilder::Entry const& uhb_entry, Real taui, const BCExpr& bc_exp) { //if (T0.isOwn()) builder.addRHSData(bal_eqn_T0, -taui * bc_exp[Fi]); //if (T1.isOwn()) builder.addRHSData(bal_eqn_T1, taui * bc_exp[Fi]); } } ; template<class SystemBuilder, class FluxModel, class Model, typename Model::BCType bc_type> struct MultiPtsBCIFluxTerm { template<typename LambdaExpr,typename BCExpr> static void assembleMultiPtsBCIFluxTerm(SystemBuilder& builder, typename SystemBuilder::Entry const& uhi_entry, typename SystemBuilder::Equation const& bal_eqn, typename SystemBuilder::Entry const& uhb_entry, typename SystemBuilder::Equation const& bnd_eqn, const FluxModel* model, const FaceGroup& cf_internal_faces, ItemGroupMapT<Face,typename Model::BCType>& face_bc_type, const LambdaExpr lambda_exp, const BCExpr& bc_exp) { //////////////////////////////////////////////////////////// // Internal faces whose stencil contains both cell and boundary face // unknowns CoefficientArrayT<Cell>* cell_coefficients = model->getCellCoefficients() ; CoefficientArrayT<Face>* face_coefficients = model->getFaceCoefficients(); IIndexManager* index_manager = builder.getIndexManager(); ENUMERATE_FACE(iF, cf_internal_faces) { const Face& F = *iF; const ItemVectorView& f_stencilF = face_coefficients->stencil(F); const Cell& T0 = F.backCell(); // back cell const Cell& T1 = F.frontCell(); // front cell Real lambda = upStream(lambda_exp[T0],lambda_exp[T1],lambda_exp) ; if (T0.isOwn() || T1.isOwn()) { typename SystemBuilder::EquationIndex bal_eqn_T0 = T0.isOwn() ? index_manager->getEquationIndex(bal_eqn, T0) : -1; typename SystemBuilder::EquationIndex bal_eqn_T1 = T1.isOwn() ? index_manager->getEquationIndex(bal_eqn, T1) : -1; // Cell coefficients // May be improved using a global array Array<Integer> entry_indices(cell_coefficients->stencilSize(F)); index_manager->getEntryIndex(uhi_entry, cell_coefficients->stencil(F), entry_indices); if (T0.isOwn()) builder.addData(index_manager->getEquationIndex(bal_eqn, T0), lambda, entry_indices, cell_coefficients->coefficients(F)); if (T1.isOwn()) builder.addData(index_manager->getEquationIndex(bal_eqn, T1), -lambda, entry_indices, cell_coefficients->coefficients(F)); // Face coefficients ArrayView<Real> face_coefficients_F = face_coefficients->coefficients(F); int f_i = 0; for (ItemEnumerator Fi_it = f_stencilF.enumerator(); Fi_it.hasNext(); ++Fi_it) { const Face& Fi = (*Fi_it).toFace(); Real taui = lambda*face_coefficients_F[f_i++]; switch(face_bc_type[Fi]) { case SubDomainModelProperty::Neumann : BCIFluxTerm<SystemBuilder, Model, SubDomainModelProperty::Neumann>::assemble(builder, index_manager, Fi, bal_eqn_T0, bal_eqn_T1, uhb_entry, taui, bc_exp) ; break ; case SubDomainModelProperty::Dirichlet : BCIFluxTerm<SystemBuilder, Model, SubDomainModelProperty::Dirichlet>::assemble(builder, index_manager, Fi, bal_eqn_T0, bal_eqn_T1, uhb_entry, taui, bc_exp) ; break ; } } } } } } ; template<class SystemBuilder,class Model, typename Model::BCType bc_type> struct BCFluxTerm { static void assemble(typename SystemBuilder::EquationIndex& bnd_eqn_F, typename SystemBuilder::EntryIndex& uhi_Ti1, Real taui) ; } ; template<> template<class SystemBuilder> struct BCFluxTerm<SystemBuilder,SubDomainModelProperty,SubDomainModelProperty::Neumann> { static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, typename SystemBuilder::EntryIndex& uhi_Ti, Real taui) { builder.addData(bnd_eqn_F, uhi_Ti, taui) ; } } ; template<> template<class SystemBuilder> struct BCFluxTerm<SystemBuilder,SubDomainModelProperty,SubDomainModelProperty::Dirichlet> { static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, typename SystemBuilder::EntryIndex& uhi_Ti1, Real taui) { } } ; template<class SystemBuilder, class Model, typename Model::BCType bc_type> struct MassBCFluxTerm { static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EntryIndex& uhb_Fi, Real taui, Real bc_Fi_value) ; static void assembleTwoPts(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EntryIndex& uhi_T0, Real taui, Real bc_Fi_value, Integer sgn) ; } ; template<> template<class SystemBuilder> struct MassBCFluxTerm<SystemBuilder,SubDomainModelProperty,SubDomainModelProperty::Neumann> { static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EntryIndex& uhb_Fi, Real taui, Real bc_Fi_value) { builder.addData(bal_eqn_T0, uhb_Fi, taui); } static void assembleTwoPtsTest(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EntryIndex& uhi_T0, Real taui, Real tausigma, Real bc_Fi_value, Integer sgn) { #ifdef DEBUG_INFO cout<<"BOUNDARYFLUX NEUNMAN["<<bal_eqn_T0<<"]["<<uhi_T0<<"]"<<" RHS="<<sgn<<"*"<<bc_Fi_value<<endl; #endif builder.addRHSData(bal_eqn_T0, -bc_Fi_value); } static void assembleTwoPts(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EntryIndex& uhi_T0, Real taui, Real bc_Fi_value, Integer sgn) { #ifdef DEBUG_INFO cout<<"BOUNDARYFLUX NEUNMAN["<<bal_eqn_T0<<"]["<<uhi_T0<<"]="<<taui/2<<" RHS="<<sgn<<"*"<<bc_Fi_value<<endl; #endif builder.addRHSData(bal_eqn_T0, sgn*bc_Fi_value); } } ; template<> template<class SystemBuilder> struct MassBCFluxTerm<SystemBuilder,SubDomainModelProperty,SubDomainModelProperty::Dirichlet> { static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EntryIndex& uhb_Fi, Real taui, Real bc_Fi_value) { builder.addRHSData(bal_eqn_T0, -taui * bc_Fi_value); } static void assembleTwoPts(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EntryIndex& uhi_T0, Real taui, Real bc_Fi_value, Integer sgn) { builder.addData(bal_eqn_T0,uhi_T0,taui); builder.addRHSData(bal_eqn_T0, taui*bc_Fi_value); #ifdef DEBUG_INFO cout<<"BOUNDARYFLUX DIRICHLET["<<bal_eqn_T0<<"]["<<uhi_T0<<"]="<<taui/2<<" RHS="<<taui*bc_Fi_value<<endl; #endif } static void assembleTwoPtsTest(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bal_eqn_T0, typename SystemBuilder::EntryIndex& uhi_T0, Real taui, Real tausigma, Real bc_Fi_value, Integer sgn) { builder.addData(bal_eqn_T0, uhi_T0, sgn * taui); builder.addRHSData(bal_eqn_T0, -sgn * tausigma * bc_Fi_value); #ifdef DEBUG_INFO cout<<"TEST BOUNDARYFLUX DIRICHLET["<<bal_eqn_T0<<"]["<<uhi_T0<<"]="<<sgn * taui<<" RHS="<<sgn * tausigma<< "*" <<bc_Fi_value<<endl; #endif } }; template< class SystemBuilder, class Model, typename Model::BCType bc_type> struct BNDEqTerm { static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, typename SystemBuilder::EntryIndex& uhb_Fi, Real taui, Real bc_Fi_value) ; template<typename BNDExpr,typename MeasureExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, const Face& F, const MeasureExpr& f_measures, const BNDExpr& bnd_exp, Real bc_F_value) ; } ; template<> template<class SystemBuilder> struct BNDEqTerm<SystemBuilder,SubDomainModelProperty,SubDomainModelProperty::Neumann> { static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, typename SystemBuilder::EntryIndex& uhb_Fi, Real taui, Real bc_Fi_value) { builder.addData(bnd_eqn_F, uhb_Fi, taui); } template<typename BNDExpr,typename MeasureExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, const Face& F, const MeasureExpr& f_measures, const BNDExpr& bnd_exp, Real bc_F_value) { Real meas_F = f_measures[F]; builder.addRHSData(bnd_eqn_F, meas_F * bc_F_value); } } ; template<> template<class SystemBuilder> struct BNDEqTerm<SystemBuilder,SubDomainModelProperty,SubDomainModelProperty::Dirichlet> { static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, typename SystemBuilder::EntryIndex& uhb_Fi, Real taui, Real bc_Fi_value) { builder.addRHSData(bnd_eqn_F, -taui * bc_Fi_value); } template<typename BNDExpr,typename MeasureExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, const Face& F, const MeasureExpr& f_measures, const BNDExpr& bnd_exp, Real bc_F_value) { ; } } ; template< class SystemBuilder, class Model1, typename Model1::BCType bc_type1, class Model2, typename Model2::BCType bc_type2> struct BNDEqBCTerm { template<typename BNDExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, const Face& F, const BNDExpr& bnd_exp, Real bc_F_value) ; } ; template<> template<class SystemBuilder, class Model1, typename Model1::BCType bc_type1> struct BNDEqBCTerm<SystemBuilder,Model1,bc_type1,SubDomainModelProperty,SubDomainModelProperty::Neumann> { template<typename BNDExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, const Face& F, const BNDExpr& bnd_exp, Real bc_F_value) { builder.addRHSData(bnd_eqn_F, bnd_exp[F] * bc_F_value); } } ; template<> template<class SystemBuilder,class Model1, typename Model1::BCType bc_type1> struct BNDEqBCTerm<SystemBuilder,Model1,bc_type1,SubDomainModelProperty,SubDomainModelProperty::Dirichlet> { template<typename BNDExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::EquationIndex& bnd_eqn_F, const Face& F, const BNDExpr& bnd_exp, Real bc_F_value) { } } ; //typedef SubDomainModelProperty::eBoundaryConditionType BCType ; template< class SystemBuilder, class FluxModel, class Model, typename Model::BCType bc_type> struct TwoPtsBCFluxTerm { template<typename LambdaExpr,typename BCExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::Entry const& uhi_entry, typename SystemBuilder::Equation const& bal_eqn, typename SystemBuilder::Entry const& uhb_entry, const FluxModel* model, const FaceGroup& boundary_faces, const ItemGroupMapT<Face,Cell>& boundary_cells, const ItemGroupMapT<Face,Integer>& boundary_sgn, const LambdaExpr& lambda_exp, const BCExpr& bc_exp) { //////////////////////////////////////////////////////////// // Boundary faces CoefficientArrayT<Cell>* cell_coefficients = model->getCellCoefficients(); CoefficientArrayT<Face>* face_coefficients = model->getFaceCoefficients(); IIndexManager* index_manager = builder.getIndexManager(); ENUMERATE_FACE(iF, boundary_faces.own()) { const Face& F = *iF; ItemVectorView c_stencilF = cell_coefficients->stencil(F); ItemVectorView f_stencilF = face_coefficients->stencil(F); //const Cell& T0 = F.boundaryCell(); // boundary cell const Cell& T0 = boundary_cells[F] ; #ifdef DEV Real lambda = lambda_exp[T0] ; #endif // Element balance typename SystemBuilder::EquationIndex bal_eqn_T0 = index_manager->getEquationIndex(bal_eqn, T0); typename SystemBuilder::EntryIndex uhi_T0 = index_manager->getEntryIndex(uhi_entry, T0); ConstArrayView<Real> cell_coefficients_F = cell_coefficients->coefficients(F); ConstArrayView<Real> face_coefficients_F = face_coefficients->coefficients(F); #warning PATCH FOR OVERLAP DIRICHLET CONDITION TO BE FIXED Real tau_sigma = 0.; Real tau_i = 0.; // Case of Overlap Dirichlet condition if(face_coefficients_F.size()==0 && cell_coefficients_F.size()==2) { int c_i = 0; for(ItemEnumerator Ti_it = c_stencilF.enumerator(); Ti_it.hasNext(); ++Ti_it) { const Cell& Ti = (*Ti_it).toCell(); if (Ti == T0) tau_i = cell_coefficients_F[c_i++]; else tau_sigma = cell_coefficients_F[c_i++]; } } // Case of REAL Dirichlet condition on global boundary else if(face_coefficients_F.size()==1 && cell_coefficients_F.size()==1) { tau_i = cell_coefficients_F[0]; tau_sigma = face_coefficients_F[0]; } // Wrong case else std::cout << "FATAL : Inconsistent Stencil Sizes, Do not know what to do!"; MassBCFluxTerm<SystemBuilder,Model,bc_type>::assembleTwoPtsTest(builder, bal_eqn_T0, uhi_T0, tau_i, tau_sigma, bc_exp[F], boundary_sgn[F]) ; } } } ; template< class SystemBuilder, class FluxModel, class Model, typename Model::BCType bc_type> struct MultiPtsBCFluxTerm { template<typename LambdaExpr,typename BCExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::Entry const& uhi_entry, typename SystemBuilder::Equation const& bal_eqn, typename SystemBuilder::Entry const& uhb_entry, typename SystemBuilder::Equation const& bnd_eqn, const FluxModel* model, const FaceGroup& boundary_faces, const LambdaExpr& lambda_exp, const BCExpr& bc_exp) { //////////////////////////////////////////////////////////// // Boundary faces CoefficientArrayT<Cell>* cell_coefficients = model->getCellCoefficients(); CoefficientArrayT<Face>* face_coefficients = model->getFaceCoefficients(); IIndexManager* index_manager = builder.getIndexManager(); const ItemGroupMapT<Face,Cell>& boundary_cells = model->boundaryCells() ; ENUMERATE_FACE(iF, boundary_faces.own()) { const Face& F = *iF; ItemVectorView c_stencilF = cell_coefficients->stencil(F); ItemVectorView f_stencilF = face_coefficients->stencil(F); //const Cell& T0 = F.boundaryCell(); // boundary cell const Cell& T0 = boundary_cells[F] ; Real lambda = lambda_exp[T0] ; //if(!T0.isOwn()) fatal() << "Boundary cell expected to be own"; // Element balance typename SystemBuilder::EquationIndex bal_eqn_T0 = index_manager->getEquationIndex(bal_eqn, T0); Real bc_F_value = bc_exp[F]; ConstArrayView<Real> cell_coefficients_F = cell_coefficients->coefficients(F); ConstArrayView<Real> face_coefficients_F = face_coefficients->coefficients(F); // Cell coefficients int c_i = 0; for(ItemEnumerator Ti_it = c_stencilF.enumerator(); Ti_it.hasNext(); ++Ti_it) { const Cell& Ti = (*Ti_it).toCell(); Real taui = cell_coefficients_F[c_i++]; typename SystemBuilder::EntryIndex uhi_Ti = index_manager->getEntryIndex(uhi_entry, Ti); // Balance equation builder.addData(bal_eqn_T0, uhi_Ti, lambda*taui); } // Face coefficients int f_i = 0; for(ItemEnumerator Fi_it = f_stencilF.enumerator(); Fi_it.hasNext(); ++Fi_it) { const Face& Fi = (*Fi_it).toFace(); Real taui = face_coefficients_F[f_i++]; typename SystemBuilder::EntryIndex uhb_Fi = index_manager->getEntryIndex(uhb_entry, Fi); MassBCFluxTerm<SystemBuilder,Model,bc_type>::assemble(builder,bal_eqn_T0,uhb_Fi,taui,bc_exp[Fi]) ; } } } } ; template< class SystemBuilder, class FluxModel, class Model, typename Model::BCType bc_type> struct MultiPtsBNDTerm { template<typename LambdaExpr, typename BCExpr, typename BNDExpr, typename MeasureExpr> static void assemble(SystemBuilder& builder, typename SystemBuilder::Entry const& uhi_entry, typename SystemBuilder::Equation const& bal_eqn, typename SystemBuilder::Entry const& uhb_entry, typename SystemBuilder::Equation const& bnd_eqn, const FluxModel* model, const FaceGroup& boundary_faces, ItemGroupMapT<Face,typename Model::BCType>& face_bc_type, const MeasureExpr& face_measures, const LambdaExpr& lambda_exp, const BCExpr& bc_exp, const BNDExpr& bnd_exp) { //////////////////////////////////////////////////////////// // Boundary faces CoefficientArrayT<Cell>* cell_coefficients = model->getCellCoefficients(); CoefficientArrayT<Face>* face_coefficients = model->getFaceCoefficients(); IIndexManager* index_manager = builder.getIndexManager(); const ItemGroupMapT<Face,Cell>& boundary_cells = model->boundaryCells() ; ENUMERATE_FACE(iF, boundary_faces.own()) { const Face& F = *iF; ItemVectorView c_stencilF = cell_coefficients->stencil(F); ItemVectorView f_stencilF = face_coefficients->stencil(F); //const Cell& T0 = F.boundaryCell(); // boundary cell const Cell& T0 = boundary_cells[F] ; Real lambda = lambda_exp[T0] ; ConstArrayView<Real> cell_coefficients_F = cell_coefficients->coefficients(F); ConstArrayView<Real> face_coefficients_F = face_coefficients->coefficients(F); typename SystemBuilder::EquationIndex bnd_eqn_F = index_manager->getEquationIndex(bnd_eqn, F); int c_i = 0; for(ItemEnumerator Ti_it = c_stencilF.enumerator(); Ti_it.hasNext(); ++Ti_it) { const Cell& Ti = (*Ti_it).toCell(); Real taui = cell_coefficients_F[c_i++]; typename SystemBuilder::EntryIndex uhi_Ti = index_manager->getEntryIndex(uhi_entry, Ti); //typename SystemBuilder::EntryIndex uhi_Ti = index_manager->getEntryIndex(uhi_entry, Ti); BNDEqTerm<SystemBuilder,Model,bc_type>::assemble(builder,bnd_eqn_F,uhi_Ti,taui) ; } // Face coefficients int f_i = 0; for(ItemEnumerator Fi_it = f_stencilF.enumerator(); Fi_it.hasNext(); ++Fi_it) { const Face& Fi = (*Fi_it).toFace(); Real taui = face_coefficients_F[f_i++]; Real bc_Fi_value = bc_exp[Fi]; typename SystemBuilder::EntryIndex uhb_Fi = index_manager->getEntryIndex(uhb_entry, Fi); switch(face_bc_type[Fi]) { case SubDomainModelProperty::Dirichlet : BNDEqBCTerm<SystemBuilder,Model,bc_type,SubDomainModelProperty,SubDomainModelProperty::Dirichlet>::assemble(builder,bnd_eqn_F,uhb_Fi,taui,bc_exp[Fi]) ; break ; case SubDomainModelProperty::Neumann : BNDEqBCTerm<SystemBuilder,Model,bc_type,SubDomainModelProperty,SubDomainModelProperty::Neumann>::assemble(builder,bnd_eqn_F,uhb_Fi,taui,bc_exp[Fi]) ; break ; } } BNDEqTerm<SystemBuilder,Model,bc_type>::assemble(builder,bnd_eqn_F,F,face_measures,bnd_exp,bc_exp[F]) ; } } } ; #endif
76910c9daeffc7222556027e4b30b72ac0b1a8a6
84b7ef7ab7bc91c184cbe8d7ee1c48f08cbfa2a9
/hexToDecimal.cpp
d057aa640f791de90dbeb5cbc1921f000e1bbf49
[]
no_license
parakramchauhan98/8085-Emulator
86eb00861ad7e426340ebb30676526a61161d270
bb1249d31959387cda25395b61649d7115a9e4d5
refs/heads/main
2023-03-15T18:35:57.431029
2021-03-16T04:15:17
2021-03-16T04:15:17
348,210,324
0
0
null
null
null
null
UTF-8
C++
false
false
244
cpp
hexToDecimal.cpp
#include "MASTER.h" #include <string> void hexToDecimal(string pc,int arr[]){ int l = pc.length(); int p = 0; for(int i =0 ;i<l;i++){ if(pc[i]>='0' && pc[i]<='9') arr[i] = pc[i] - '0'; else arr[i] = 10 + (pc[i] - 'A'); } }
1472c69ce6efbe8996ad1aedfd94276c0c1568b7
5863588c32c110e57fe985a5d9c2598be82e6311
/RayTracer/Surface.h
916073e3385e1f576cbbaf0e172d80ab525788e0
[]
no_license
jpbream/RayTracer
37300c6a5f3cfdc9a094114898bca03867561ece
da2f0ac64971e5a97acacec03b797929f7bd6cee
refs/heads/master
2022-12-23T23:43:42.258021
2020-09-19T00:06:52
2020-09-19T00:06:52
286,766,545
0
0
null
null
null
null
UTF-8
C++
false
false
2,973
h
Surface.h
#pragma once #include <string> #include <iostream> #include "Vec4.h" #include "Vec3.h" #define PI 3.14159265358979323846 // returns an integer color value from a Vec4 #define COMPRESS4(v) ((int)(v.r * 255) | (int)(v.g * 255) << 8 | (int)(v.b * 255) << 16 | (int)(v.a * 255) << 24) // returns an integer color value from a Vec3 #define COMPRESS3(v) ((int)(v.r * 255) | (int)(v.g * 255) << 8 | (int)(v.b * 255) << 16 | (unsigned char)-1 << 24) // returns a Vec4 from an integer color value #define EXPAND4(i) Vec4((i & rMask) / 255.0f, ((i & gMask) >> 8) / 255.0f, ((i & bMask) >> 16) / 255.0f, ((i & aMask) >> 24) / 255.0f ) // returns a Vec3 from an integer color value #define EXPAND3(i) Vec3((i & rMask) / 255.0f, ((i & gMask) >> 8) / 255.0f, ((i & bMask) >> 16) / 255.0f ) class Surface { private: int* pPixels; int width; int height; int allocatedSpace; int pitch; unsigned int aMask; unsigned int rMask; unsigned int gMask; unsigned int bMask; Surface* mipMap = nullptr; std::string GetAllocationString() const; public: static constexpr int BPP = 32; Surface(int width, int height); Surface(const Surface& surface); Surface(Surface&& surface) noexcept; Surface(const std::string& filename); Surface& operator=(const Surface& surface); Surface& operator=(Surface&& surface) noexcept; ~Surface(); const int* GetPixels() const; int GetWidth() const; int GetHeight()const; int GetPitch() const; int GetRMask() const; int GetGMask() const; int GetBMask() const; int GetAMask() const; int GetBufferSize() const; void Resize(int width, int height, bool maintainImage); void Rescale(float xScale, float yScale); void SetColorMasks(int aMask, int rMask, int gMask, int bMask); void SaveToFile(const std::string& filename) const; void WhiteOut(); void BlackOut(); void DrawLine(int x1, int y1, int x2, int y2, int rgb); void GenerateMipMaps(); void DeleteMipMaps(); const Surface* GetMipMap(int level) const; void FlipHorizontally(); void FlipVertically(); void RotateRight(); void RotateLeft(); void Tint(const Vec4& target, float alpha); enum { BLUR_VERTICAL, BLUR_HORIZONTAL, BLUR_BOTH }; void GaussianBlur(int kernelSize, float stdDev, int blurType); void Invert(); void SetContrast(float contrast); inline const Vec4& GetPixel(int x, int y) const { int color = pPixels[width * y + x]; return EXPAND4(color); } inline void PutPixel(int x, int y, const Vec4& v) { pPixels[width * y + x] = COMPRESS4(v); } inline void PutPixel(int x, int y, const Vec3& v) { pPixels[width * y + x] = COMPRESS3(v); } inline void PutPixel(int x, int y, int rgb) { pPixels[width * y + x] = rgb; } inline void PutPixel(int x, int y, float grayscale) { // memset to the grayscale value * 255, or'd with the Alpha mask so it does not vary in transparency memset(pPixels + width * y + x, (unsigned char)(255 * grayscale), sizeof(int)); pPixels[width * y + x] |= aMask; } };
348366c291f087fd6047626438f97ac8c5c95db0
3a39b41a8f76d7d51b48be3c956a357cc183ffae
/BeakjoonOJ/4000/4013_ATM.cpp
b068d322ee01c1c2f104aac14f754d88b91d82f9
[]
no_license
Acka1357/ProblemSolving
411facce03d6bf7fd4597dfe99ef58eb7724ac65
17ef7606af8386fbd8ecefcc490a336998a90b86
refs/heads/master
2020-05-05T10:27:43.356584
2019-11-07T06:23:11
2019-11-07T06:23:11
179,933,949
0
0
null
null
null
null
UTF-8
C++
false
false
2,566
cpp
4013_ATM.cpp
// // Created by Acka on 2017. 7. 13.. // //http://ideone.com/J3CVpI smu's tarjan #include <stdio.h> #include <vector> #include <stack> #include <algorithm> #include <queue> using namespace std; bool chk[500001]; int idx[500001], low[500001], sn[500001], cnt, scnt; vector<int> adj[500001], memb[500001]; stack<int> seq; int dfs(int cur){ idx[cur] = low[cur] = ++cnt; seq.push(cur); chk[cur] = true; for(int i = 0; i < adj[cur].size(); i++){ int next = adj[cur][i]; if(!idx[next]) low[cur] = min(low[cur], dfs(next)); else if(chk[next]) low[cur] = min(low[cur], idx[next]); } if(idx[cur] == low[cur]){ ++scnt; while(seq.top() != cur){ memb[scnt].push_back(seq.top()); chk[seq.top()] = false; sn[seq.top()] = scnt; seq.pop(); } memb[scnt].push_back(cur); chk[cur] = false; sn[seq.top()] = scnt; seq.pop(); } return low[cur]; } vector<int> sadj[500001]; int mon[500001], smon[500001], linked[500001], sind[500001], sum[500001]; bool res[500001], sres[500001]; int main() { int N, M; scanf("%d %d", &N, &M); for(int i = 0, u, v; i < M; i++){ scanf("%d %d", &u, &v); adj[u].push_back(v); } for(int i = 1; i <= N; i++) scanf("%d", &mon[i]); int S, P; scanf("%d %d", &S, &P); for(int i = 0, x; i < P; i++){ scanf("%d", &x); res[x] = true; } for(int i = 1; i <= N; i++) if(!idx[i]) dfs(i); for(int i = 1; i <= scnt; i++) for(int j = 0; j < memb[i].size(); j++){ int& mem = memb[i][j]; sres[i] |= res[mem]; smon[i] += mon[mem]; linked[i] = i; for(int k = 0; k < adj[mem].size(); k++) if(linked[sn[adj[mem][k]]] != i){ linked[sn[adj[mem][k]]] = i; sind[sn[adj[mem][k]]]++; sadj[i].push_back(sn[adj[mem][k]]); } } queue<int> q; sum[sn[S]] = smon[sn[S]]; for(int i = 1; i <= scnt; i++) if(!sind[i]) q.push(i); while(!q.empty()){ int cur = q.front(); q.pop(); for(int i = 0; i < sadj[cur].size(); i++){ int& to = sadj[cur][i]; if(!(--sind[to])) q.push(to); if(sum[cur]) sum[to] = max(sum[to], sum[cur] + smon[to]); } } int ans = 0; for(int i = 1; i <= scnt; i++) if(sres[i]) ans = max(ans, sum[i]); printf("%d\n", ans); return 0; }
016154b92a0d2dbd788e336aa738acd4fa419474
5a4b8d25508f6a820365dfacdf067e56d09fea93
/PictureBookEditor/Layout.cpp
d914b0e1303a4fdfd308de3ce4534041e5d7677f
[]
no_license
ajiponzu/PictureBookEditor
9cb093a3351d53e234d4e7610943b23e3b48264d
281427a16f9f7b8dfee16758471af503a2464244
refs/heads/master
2023-01-24T08:50:46.019875
2020-12-05T15:43:41
2020-12-05T15:43:41
315,276,359
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,095
cpp
Layout.cpp
#include "Layout.h" //コンストラクタで呼ばれる初期化処理 void Layout::init() { //dpi取得,高DPI,高解像度のディスプレイを使用している場合, //位置を修正できる dpi = Graphics::GetDPIScaling(); initMenuViewMacro(); initPictureSetViewMacro(); initScenarioSetViewMacro(); initPageSetViewMacro(); BTN_F_SIZE = 20 * dpi; BACK_RECT_WID = 450 * dpi; SLIDER_L_WID = 200 * dpi; SLIDER_WID = 150 * dpi; RECT_FRAME_THICK = 1.0 * dpi; initPos(); } void Layout::initMenuViewMacro() { MENU_BTN_WID = 80 * dpi; MENU_BTN_HIGH = 32 * dpi; MENU_BTN_GAP = MENU_BTN_WID + 8 * dpi; MENU_BAR_TH = MENU_BTN_HIGH + 8 * dpi; CLBTN_X = Window::ClientWidth() - MENU_BAR_TH; } void Layout::initPictureSetViewMacro() { BTN_WID = 48 * dpi; BTN_HIGH = 32 * dpi; BTN_GAP = BTN_HIGH + 8 * dpi; PICTURE_BACK_RECT_HIGH = 420 * dpi; } void Layout::initScenarioSetViewMacro() { SCENARIO_BACK_RECT_HIGH = 400 * dpi; INPUT_ARER_WID = 420 * dpi; INPUT_AREA_HIGH = 80 * dpi; TXT_MAX_SIZE = 200 * dpi; } void Layout::initPageSetViewMacro() { PAGE_BACK_RECT_WID = 1000 * dpi; PAGE_BACK_RECT_HIGH = 680 * dpi; MOVE_RECT1_POS = 20 * dpi; MOVE_RECT2_POS = MOVE_RECT1_POS + 20 * dpi; MOVE_RECT3_POS = MOVE_RECT2_POS + 20 * dpi; FONT_RECT1_POS = 80 * dpi; FONT_RECT2_POS = FONT_RECT1_POS + 60 * dpi; FONT_SIZE = 60 * dpi; PAGE_RECT_WID = 150 * dpi; } void Layout::initPos() { X0 = 0; X1 = 16 * dpi; X2 = X1 + MENU_BTN_GAP; X3 = X2 + MENU_BTN_GAP; X4 = 240 * dpi; X5 = X3 + MENU_BTN_GAP; X6 = X5 + MENU_BTN_GAP; X7 = X6 + 80 * dpi; X8 = X7 + 320 * dpi; X9 = 1070 * dpi; X10 = X9 + 16 * dpi; X11 = X10 + BTN_WID + 20 * dpi; Y0 = 0; Y1 = 60 * dpi; Y2 = Y1 + 9 * dpi; Y3 = Y2 + BTN_GAP; Y4 = Y3 + BTN_GAP; Y5 = Y4 + BTN_GAP + 20 * dpi; Y6 = Y5 + BTN_GAP; Y7 = Y6 + BTN_GAP; Y8 = Y7 + BTN_GAP + 20 * dpi; Y9 = Y8 + BTN_GAP; Y10 = Y9 + BTN_GAP; Y11 = Y10 + BTN_GAP * 2; Y12 = Y11 + 9 * dpi; Y13 = Y12 + BTN_GAP; Y14 = Y13 + BTN_GAP; Y15 = Y14 + BTN_GAP + 60 * dpi; Y16 = Y15 + BTN_GAP; Y17 = 780 * dpi; Y18 = Y16 + BTN_GAP; }
e3b5ec6971fefa4df3e40247d7a974e80bc29bd2
d69d609c0c80aade62c98f583c671dc0b27d0b27
/Block.cpp
454dfbad4bae807a95b71e7e91a754a64437b463
[]
no_license
shakedguy/Tetris_Project
a525d6332153df3d75e4ce59dd452fbe106024a7
235827d5308e6bb35d41ba4e69557dabcea04cea
refs/heads/master
2023-05-08T15:56:13.000791
2021-05-31T20:10:08
2021-05-31T20:10:08
350,011,730
0
0
null
2021-04-28T16:14:13
2021-03-21T13:47:41
C++
UTF-8
C++
false
false
7,221
cpp
Block.cpp
#include "Block.h" Block::Block(const Point& _pos) : pos(_pos), shape(SHAPE) { std::random_device rnd; const std::uniform_int_distribution<> shapeRange(0, 6); const std::uniform_int_distribution<> colorRange(1, 14); shapeNum = (shapeRange(rnd)); color = static_cast<Color>(colorRange(rnd)); cleanBlock(); setFigure(); } Block::Block(const Point& _pos, const short& _shapeNum) : pos(_pos), shape(SHAPE), shapeNum(_shapeNum) { std::random_device rnd; const std::uniform_int_distribution<> colorRange(1, 14); color = static_cast<Color>(colorRange(rnd)); cleanBlock(); setFigure(); } bool Block::silent = false; void Block::setBlockFromFile(const ushort& _shapeNum) { shapeNum = _shapeNum; color = WHITE; cleanBlock(); setFigure(); } Bomb::Bomb(const Point& _pos, const uchar& _shape) { pos = _pos; shape = _shape; cleanBlock(); ++figure[0][0]; } bool Block::colorsMode = false; void Block::assign(const Block& _block) { cleanBlock(); for (int i = 0; i < figure.size(); i++) for (int j = 0; j < figure[i].size(); j++) figure[i][j] = _block.figure[i][j]; pos = _block.pos; shape = _block.shape; color = _block.color; shapeNum = _block.shapeNum; color = _block.color; } Block& Block::operator=(const Block& b) { if (&b != this) this->assign(b); return *this; } void Block::createNewBlock() { cleanBlock(); std::random_device rnd; const std::uniform_int_distribution<> shapeRange(0, 6); const std::uniform_int_distribution<> colorRange(1, 14); shapeNum = (shapeRange(rnd)); color = static_cast<Color>(colorRange(rnd)); setFigure(); } /********** Set figures ***********/ void Block::setFigure() { switch (shapeNum) { case I: setShapeI(); break; case L: setShapeL(); break; case J: setShapeJ(); break; case O: setShapeO(); break; case S: setShapeS(); break; case T: setShapeT(); break; case Z: setShapeZ(); break; default: break; } } void Block::setShapeI() { for (array<ushort, COLUMNS>& row : figure) ++row[0]; } void Block::setShapeL() { for (size_t i = 0; i < figure.size() - 1; ++i) { for (size_t j = 0; j < figure[i].size() - 2; ++j) { if (!(i + j)) ++figure[i][j]; else if (j) ++figure[i][j]; } } } void Block::setShapeJ() { for (size_t i = 0; i < figure.size() - 1; ++i) for (size_t j = 0; j < figure[i].size() - 2; ++j) if ((!j && i > 1) || j) ++figure[i][j]; } void Block::setShapeO() { for (size_t i = 0; i < figure.size() - 2; ++i) for (size_t j = 0; j < figure[i].size() - 2; ++j) ++figure[i][j]; } void Block::setShapeS() { for (size_t i = 0; i < figure.size() - 1; ++i) for (size_t j = 0; j < figure[i].size() - 2; ++j) if ((!j && i) || (j && i < 2)) ++figure[i][j]; } void Block::setShapeT() { for (size_t i = 0; i < figure.size() - 1; ++i) for (size_t j = 0; j < figure[i].size() - 2; ++j) if ((!j && i == 1) || j) ++figure[i][j]; } void Block::setShapeZ() { for (size_t i = 0; i < figure.size() - 1; ++i) for (size_t j = 0; j < figure[i].size() - 2; ++j) if ((!j && i < 2) || (j && i)) ++figure[i][j]; } /********** End set figures ***********/ /* Swap rows and columns as needed so that the block shape starts at point (0,0) of the matrix */ void Block::arrangeMatrix() { if (isRowZeroEmpty()) { pullFigureUp(); arrangeMatrix(); } if (isColumnZeroEmpty()) { pullFigureLeft(); arrangeMatrix(); } } // This function checks if the first row is empty bool Block::isRowZeroEmpty() { for (array<ushort, COLUMNS>& row : figure) if (row[0]) return false; return true; } //This function checks if the first collumn is empty bool Block::isColumnZeroEmpty() { for (size_t i = 0; i < ROWS; ++i) if (figure[0][i]) return false; return true; } /* Swap rows so that the block shape starts with row 0 of the matrix */ void Block::pullFigureUp() { for (size_t i = 0; i < figure.size(); i++) for (size_t j = 0; j < figure[i].size() - 1; j++) std::swap(figure[i][j], figure[i][j + 1]); } /* Swap columns so that the block shape starts with column 0 of the matrix */ void Block::pullFigureLeft() { for (int i = 0; i < figure.size() - 1; i++) for (int j = 0; j < figure[i].size(); j++) std::swap(figure[i][j], figure[i + 1][j]); } // This function cleans the block (by reseting the matrix that holds the block's figure) void Block::cleanBlock() { for (int i = 0; i < Block::COLUMNS; i++) for (int j = 0; j < Block::ROWS; j++) figure[i][j] = 0; } // print the EMPTY_CELL on the matrix void Block::cleanPrint() const { for (size_t i = 0; i < figure.size(); i++) { for (size_t j = 0; j < figure[i].size(); j++) { gotoxy(pos.getX() + i, pos.getY() + j); cout << EMPTY_CELL; } } } // This function rotates the block clockwise - transpose the matrix and than reverses the order of the columns void Block::clockwiseRotate() { transpose_Matrix(); reverseColumns(); arrangeMatrix(); } // this function rotates the block counter clockwise - transpose the matrix and than reverses the order of the rows void Block::counterClockwiseRotate() { transpose_Matrix(); reverseRows(); arrangeMatrix(); } // This fucntion tranpose the matrix (swaps the collumn and the rows) void Block::transpose_Matrix() { for (size_t i = 0; i < figure.size(); i++) for (size_t j = i + 1; j < figure[i].size(); j++) std::swap(figure[i][j], figure[j][i]); } // Function reverse row order in a matrix void Block::reverseRows() { for(array<ushort,Block::ROWS>& col:figure ) { size_t start = 0; size_t end = col.size() - 1; while (start < end) { std::swap(col[start], col[end]); start++; end--; } } } // Function Reverses the order of the columns in the matrix void Block::reverseColumns() { for (size_t i = 0; i < figure.size(); i++) { size_t start = 0; size_t end = figure[i].size() - 1; while (start < end) { std::swap(figure[start][i], figure[end][i]); start++; end--; } } } void Block::drawBlock() const { if (Block::colorsMode) setTextColor(color); for (int i = 0; i < Block::COLUMNS; ++i) { for (int j = 0; j < Block::ROWS; ++j) { if (figure[i][j]) { gotoxy(pos.getX() + i, pos.getY() + j); cout << shape; } } } if (Block::colorsMode) setTextColor(WHITE); } // Raise the y componente in the position data member of the block void Block::moveDown() { cleanPrint(); pos++; if (!silent) cout << *this; } // Reduction the x componente in the position data member of the block void Block::moveLeft() { cleanPrint(); pos <<= 1; if (!silent) cout << *this; } // Raise the x componente in the position data member of the block void Block::moveRight() { cleanPrint(); pos >>= 1; if (!silent) cout << *this; } void Block::changeColorsMode() { if (Block::colorsMode) Block::colorsMode = false; else Block::colorsMode = true; } bool Block::isColEmpty(const ushort& col)const { for (size_t i = 0; i < Block::ROWS; ++i) if (figure[col][i]) return false; return true; } size_t Block::getLowestRow()const { size_t max = 0; for (size_t i = 0; i < figure.size(); ++i) for (size_t j = 0; j < figure[i].size(); ++j) if (figure[i][j] && j > max) max = j; return max; }
fa141974c02fdd78c69795af65628f4ef0a36dc8
5ac4af1856032d41cedcd83b481b247c9cd2ede0
/lib/Runtime/old/opengl/mpi-old/glVolumeRenderable.cpp
55770e4df459242cc48fb0cbe46bdbfc332e6bf1
[ "BSD-3-Clause", "LicenseRef-scancode-other-permissive" ]
permissive
lineCode/scout
884bf2a6bf5c0e9963ef6af36f8559ec635929f3
a7b66c9bb6940625005c05bc350491a443a23866
refs/heads/master
2021-05-30T14:55:14.591760
2016-02-18T22:45:02
2016-02-18T22:45:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,665
cpp
glVolumeRenderable.cpp
/* * ----- The Scout Programming Language ----- * * This file is distributed under an open source license by Los Alamos * National Security, LCC. See the file License.txt (located in the * top level of the source distribution) for details. * *----- * * $Revision$ * $Date$ * $Author$ * *----- * */ #include <iostream> #include <mpi.h> #include "scout/Runtime/opengl/glVolumeRenderable.h" #include "scout/Runtime/volren/hpgv/hpgv_block.h" #include "scout/Runtime/volren/hpgv/matrix_util.h" using namespace std; using namespace scout; glVolumeRenderable::glVolumeRenderable(int npx, int npy, int npz, int nx, int ny, int nz, double* x, double* y, double* z, int win_width, int win_height, glCamera* camera, trans_func_ab_t trans_func, int id, int root, MPI_Comm gcomm) :_npx(npx), _npy(npy), _npz(npz), _nx(nx), _ny(ny), _nz(nz), _x(x), _y(y), _z(z), _win_width(win_width), _win_height(win_height), _trans_func(trans_func), _id(id), _root(root), _gcomm(gcomm), _para_input(NULL), _block(NULL), _texture(NULL), _vbo(NULL), _pbo(NULL), _tcbo(NULL) { if (!hpgv_vis_valid()) { hpgv_vis_init(MPI_COMM_WORLD, _root); } size_t xdim = win_width; size_t ydim = win_height; setMinPoint(glfloat3(0, 0, 0)); setMaxPoint(glfloat3(xdim, ydim, 0)); // Set up vis params initialize(camera); hpgv_vis_para(_para_input); if (id == root) { // set up opengl stuff _ntexcoords = 2; _texture = new glTexture2D(xdim, ydim); _texture->addParameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); _texture->addParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); _texture->addParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR); _pbo = new glTextureBuffer; _pbo->bind(); _pbo->alloc(sizeof(float) * 4 * xdim * ydim, GL_STREAM_DRAW_ARB); _pbo->release(); _vbo = new glVertexBuffer; _vbo->bind(); _vbo->alloc(sizeof(float) * 3 * 4, GL_STREAM_DRAW_ARB); fill_vbo(_min_pt.x, _min_pt.y, _max_pt.x, _max_pt.y); _vbo->release(); _nverts = 4; _tcbo = new glTexCoordBuffer; _tcbo->bind(); _tcbo->alloc(sizeof(float) * 8, GL_STREAM_DRAW_ARB); // two-dimensional texture coordinates. fill_tcbo2d(0.0f, 0.0f, 1.0f, 1.0f); _tcbo->release(); oglErrorCheck(); } createBlock(); } glVolumeRenderable::~glVolumeRenderable() { if (_para_input) { hpgv_para_delete(_para_input); } if (_block) { free(_block); } if (_id == _root) { if (_texture != 0) delete _texture; if (_pbo != 0) delete _pbo; if (_vbo != 0) delete _vbo; if (_tcbo != 0) delete _tcbo; _texture = NULL; _pbo = NULL; _vbo = NULL; _tcbo = NULL; } } void glVolumeRenderable::initialize(glCamera* camera) { initializeRenderer(camera); if (_id == _root) { initializeOpenGL(camera); } } void glVolumeRenderable::initializeRenderer(glCamera* camera) { /* new param struct */ para_input_t *pi = (para_input_t *)calloc(1, sizeof(para_input_t)); HPGV_ASSERT_P(_id, pi, "Out of memory.", HPGV_ERR_MEM); // no need to set colormap for that data structure anymore // but it wants this info for compositing pi->image_format = HPGV_RGBA; pi->image_type = HPGV_FLOAT; // compute view and projection matrices int width = _win_width; int height = _win_height; double mym[16]; getViewMatrix((double)camera->position[0], (double)camera->position[1], (double) camera->position[2], (double)camera->look_at[0], (double)camera->look_at[1], (double)camera->look_at[2], (double)camera->up[0], (double)camera->up[1], (double)camera->up[2], (double (*)[4])&mym[0]); /* int i,j; fprintf(stderr, "My modelview matrix:\n"); for (i = 0; i < 4; i++ ) { for (j = 0; j < 4; j++ ) { fprintf(stderr, "%lf ", mym[j*4 + i]); } fprintf(stderr, "\n"); } fprintf(stderr, "\n"); */ // transpose mine and use it -- Hongfeng takes a transpose of opengl matrix transposed(&pi->para_view.view_matrix[0], &mym[0]); getProjectionMatrix((double)camera->fov, (double)_win_width/_win_height, (double)camera->near, (double)camera->far, (double (*)[4])&mym[0]); /* fprintf(stderr, "My projection matrix:\n"); for (i = 0; i < 4; i++ ) { for (j = 0; j < 4; j++ ) { fprintf(stderr, "%lf ", mym[j*4 + i]); } fprintf(stderr, "\n"); } fprintf(stderr, "\n"); */ // transpose mine and use it -- Hongfeng takes a transpose of opengl matrix transposed(&pi->para_view.proj_matrix[0], &mym[0]); // probably want to use framebuffer_rt and viewport_rt for this? // for now, hardwire pi->para_view.view_port[0] = 0; pi->para_view.view_port[1] = 0; pi->para_view.view_port[2] = _win_width; pi->para_view.view_port[3] = _win_height; pi->para_view.frame_width = _win_width; pi->para_view.frame_height = _win_height; // hardwire to 1 image, 1 volume, and no particles for now // To change this we increase num_vol to the number of different // vars we want to vis, then set the corresponding id for each // variable H2, H, O, O2, etc. (which enables the value lookup in the data). pi->num_image = 1; pi->para_image = (para_image_t *)calloc(1, sizeof(para_image_t)); pi->para_image->num_particle = 0; pi->para_image->num_vol = 1; pi->para_image->id_vol = (int*)calloc (1, sizeof (int)); pi->para_image->id_vol[0] = 0; //pi->para_image->sampling_spacing = 2.0; //pi->para_image->sampling_spacing = 1.297920; pi->para_image->sampling_spacing = 1.0; pi->para_image->tf_vol = (para_tf_t *)calloc(1, sizeof(para_tf_t)); pi->para_image->light_vol = (para_light_t *)calloc(1, sizeof(para_light_t)); pi->para_image->light_vol[0].withlighting = 1; pi->para_image->light_vol[0].lightpar[0] = 0.2690;//ambient reflection coef pi->para_image->light_vol[0].lightpar[1] = 0.6230;//diffuse reflection coef pi->para_image->light_vol[0].lightpar[2] = 0.8890;//specular reflection coef pi->para_image->light_vol[0].lightpar[3] = 128.0000; //spec. refl. exponent _para_input = pi; } void glVolumeRenderable::initializeOpenGL(glCamera* camera) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); size_t width = _max_pt.x - _min_pt.x; size_t height = _max_pt.y - _min_pt.y; static const float pad = 0.05; if(height == 0){ float px = pad * width; gluOrtho2D(-px, width + px, -px, width + px); } else{ if(width >= height){ float px = pad * width; float py = (1 - float(height)/width) * width * 0.50; gluOrtho2D(-px, width + px, -py - px, width - py + px); } else{ float py = pad * height; float px = (1 - float(width)/height) * height * 0.50; gluOrtho2D(-px - py, width + px + py, -py, height + py); } } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.5, 0.55, 0.65, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } // must have a block first, so createBlock() would need to be called before this void glVolumeRenderable::addVolume(void* dataptr, unsigned volumenum) { if (_block != NULL) { block_add_volume(_block, HPGV_FLOAT, dataptr, volumenum); } } void glVolumeRenderable::createBlock() { /* new block */ _block = (block_t *)calloc(1, sizeof(block_t)); HPGV_ASSERT_P(_id, _block, "Out of memory.", HPGV_ERR_MEM); /* mpi */ _block->mpiid = _id; _block->mpicomm = _gcomm; MPI_Comm_size(_gcomm, &_groupsize); /* new header */ blk_header_t header; header_new(_id, _gcomm, _groupsize, _x, _y, _z, _nx, _ny, _nz, _npx, _npy, _npz, &header); memcpy(&(_block->blk_header), &header, sizeof(blk_header_t)); /* initalize timing module */ if (!HPGV_TIMING_VALID()) { HPGV_TIMING_INIT(_root, *_gcomm); } static int init_timing = HPGV_FALSE; if (init_timing == HPGV_FALSE) { init_timing = HPGV_TRUE; HPGV_TIMING_NAME(MY_STEP_SLOVE_TIME, "T_slove"); HPGV_TIMING_NAME(MY_STEP_VIS_TIME, "T_vis"); HPGV_TIMING_NAME(MY_STEP_SAVE_IMAGE_TIME, "T_saveimg"); HPGV_TIMING_NAME(MY_STEP_GHOST_VOL_TIME, "T_ghostvol"); HPGV_TIMING_NAME(MY_ALL_SLOVE_TIME, "T_tslove"); HPGV_TIMING_NAME(MY_ALL_VIS_TIME, "T_tvis"); HPGV_TIMING_NAME(MY_ENDTOEND_TIME, "T_end2end"); HPGV_TIMING_BEGIN(MY_ENDTOEND_TIME); HPGV_TIMING_BEGIN(MY_STEP_SLOVE_TIME); HPGV_TIMING_BEGIN(MY_ALL_SLOVE_TIME); } } void glVolumeRenderable::render() { MPI_Comm_size(_gcomm, &_groupsize); HPGV_TIMING_END(MY_STEP_SLOVE_TIME); HPGV_TIMING_END(MY_ALL_SLOVE_TIME); HPGV_TIMING_BEGIN(MY_STEP_VIS_TIME); HPGV_TIMING_COUNT(MY_STEP_VIS_TIME); HPGV_TIMING_BEGIN(MY_ALL_VIS_TIME); if ( !_id && _id == _root) { //fprintf(stderr, "render call at %.3e.\n", 0); } int i, j; MPI_Barrier(_gcomm); #ifdef NOTYET if (_id == _root) { struct tm *start_time; time_t start_timer; time(&start_timer); start_time = localtime(&start_timer); fprintf(stderr, "render call starts at %02d:%02d:%02d\n", start_time->tm_hour, start_time->tm_min, start_time->tm_sec); } #endif HPGV_TIMING_BEGIN(MY_STEP_GHOST_VOL_TIME); HPGV_TIMING_COUNT(MY_STEP_GHOST_VOL_TIME); /* exchange ghost area */ for (i = 0; i < _para_input->num_image; i++) { para_image_t *image = &(_para_input->para_image[i]); for (j = 0; j < image->num_vol; j++) { block_exchange_boundary(_block, image->id_vol[j]); } } HPGV_TIMING_END(MY_STEP_GHOST_VOL_TIME); hpgv_vis_render(_block, _root, _gcomm, 0, _trans_func); HPGV_TIMING_END(MY_STEP_VIS_TIME); HPGV_TIMING_END(MY_ALL_VIS_TIME); MPI_Barrier(_gcomm); #ifdef NOTYET if (_id == _root) { struct tm *end_time; time_t end_timer; time(&end_timer); end_time = localtime(&end_timer); fprintf(stderr, "render call ends at %02d:%02d:%02d\n\n", end_time->tm_hour, end_time->tm_min, end_time->tm_sec); } #endif } void glVolumeRenderable::writePPM(double time) { HPGV_TIMING_BEGIN(MY_STEP_SAVE_IMAGE_TIME); HPGV_TIMING_COUNT(MY_STEP_SAVE_IMAGE_TIME); if (_id == _root) { char filename[MAXLINE]; char varname[MAXLINE]; char *imgptr = (char *) hpgv_vis_get_imageptr(); int imgformat = hpgv_vis_get_imageformat(); int imgtype = hpgv_vis_get_imagetype(); long imgsize = _para_input->para_view.frame_width * _para_input->para_view.frame_height * hpgv_formatsize(imgformat) * hpgv_typesize(imgtype); int i; if (1) { for (i = 0; i < _para_input->num_image; i++) { para_image_t *image = &(_para_input->para_image[i]); sprintf(varname, "test"); /* for (j = 0; j < image->num_vol; j++) { sprintf(varname, "%s_v%s", varname, theDataName[image->id_vol[j]]); } if (image->num_particle == 1) { sprintf(varname, "%s_v%s", varname, theDataName[image->vol_particle]); } */ snprintf(filename, MAXLINE, "%s/image_p%04d_s%04d%s_t%.3e.ppm", ".", _groupsize, 0, varname, time); hpgv_vis_saveppm(_para_input->para_view.frame_width, _para_input->para_view.frame_height, imgformat, imgtype, imgptr + imgsize * i, filename); printf("finished hpgv_vis_saveppm()\n"); } } } } void glVolumeRenderable::draw(glCamera* camera) { render(); if (_id == _root) { // now put it up in the window float4* _colors = map_colors(); hpgv_vis_copyraw( _para_input->para_view.frame_width, _para_input->para_view.frame_height, _para_input->image_format, _para_input->image_type, _para_input->num_image, 0, hpgv_vis_get_imageptr(), (void*)_colors); /* for (int i = 0; i < _para_input->para_view.frame_height; i++) { for (int j = 0; j < _para_input->para_view.frame_width; j++) { float4 color = _colors[(i*_para_input->para_view.frame_width) + j]; printf(" %f:%f:%f", color.components[0], color.components[1], color.components[2]); } printf("\n"); } */ unmap_colors(); _pbo->bind(); _texture->enable(); _texture->update(0); _pbo->release(); glEnableClientState(GL_TEXTURE_COORD_ARRAY); _tcbo->bind(); glTexCoordPointer(_ntexcoords, GL_FLOAT, 0, 0); glEnableClientState(GL_VERTEX_ARRAY); _vbo->bind(); glVertexPointer(3, GL_FLOAT, 0, 0); oglErrorCheck(); glDrawArrays(GL_POLYGON, 0, _nverts); glDisableClientState(GL_VERTEX_ARRAY); _vbo->release(); glDisableClientState(GL_TEXTURE_COORD_ARRAY); _tcbo->release(); _texture->disable(); } } void glVolumeRenderable::fill_vbo(float x0, float y0, float x1, float y1) { float* verts = (float*)_vbo->mapForWrite(); verts[0] = x0; verts[1] = y0; verts[2] = 0.0f; verts[3] = x1; verts[4] = y0; verts[5] = 0.f; verts[6] = x1; verts[7] = y1; verts[8] = 0.0f; verts[9] = x0; verts[10] = y1; verts[11] = 0.0f; _vbo->unmap(); } void glVolumeRenderable::fill_tcbo2d(float x0, float y0, float x1, float y1) { float* coords = (float*)_tcbo->mapForWrite(); coords[0] = x0; coords[1] = y0; coords[2] = x1; coords[3] = y0; coords[4] = x1; coords[5] = y1; coords[6] = x0; coords[7] = y1; _tcbo->unmap(); } float4* glVolumeRenderable::map_colors() { return (float4*)_pbo->mapForWrite(); } void glVolumeRenderable::unmap_colors() { _pbo->unmap(); _pbo->bind(); _texture->initialize(0); _pbo->release(); }
55021a96c7ed0676c0e291557c00914765938113
6b7487a2f9b8bd58b0553e001e7a378c7484d384
/src/util/HashMap.h
8cb2e43adc52f948dbed66acdb44e504cab7de2b
[ "Apache-2.0" ]
permissive
joka921/QLever
7b41039f64690349bc6412a5acb9cb4a5f2c9026
c9b1958a13f41736d43b14da5c74abfbff4e968e
refs/heads/master
2023-08-31T21:30:15.049684
2023-03-16T18:30:07
2023-03-16T18:30:07
127,433,123
0
1
null
2018-03-30T13:47:32
2018-03-30T13:47:32
null
UTF-8
C++
false
false
594
h
HashMap.h
// Copyright 2018, University of Freiburg, Chair of Algorithms and Data // Structures. // Author: Björn Buchhold <buchholb@informatik.uni-freiburg.de> // Author: Niklas Schnelle <schnelle@informatik.uni-freiburg.de> #pragma once #include <absl/container/flat_hash_map.h> namespace ad_utility { // Wrapper for HashMaps to be used everywhere throughout code for the semantic // search. This wrapper interface is not designed to be complete from the // beginning. Feel free to extend it at need. template <typename... Ts> using HashMap = absl::flat_hash_map<Ts...>; } // namespace ad_utility
31ed630b8b5ab165cdb7fa4a52dc4aec6d6a1187
c98bd90167d63866d7824186039b95d3b5b2bc1f
/perfectNumber.cpp
17f199330340ca6ae90d1da31dbfc5c7d0273aab
[]
no_license
Tariqul2h2/BasicC
a14bcb4a3dcecd7ed4d1ec14cf30a3aa7a791f68
c3d5c115120a974f65b29ffc95bf123c86aa1282
refs/heads/master
2023-01-28T16:28:41.604140
2020-11-29T17:15:17
2020-11-29T17:15:17
272,958,453
0
0
null
null
null
null
UTF-8
C++
false
false
389
cpp
perfectNumber.cpp
#include<stdio.h> int main() { int n, l = 0, i; scanf("%d",&n); printf("Divisors are: "); for(i = 1; i <= n/2; i++) { if(n%i==0) { printf("%d ",i); l = l+i; } } printf("\n"); if(l == n) printf("%d is a Perfect Number",n); else printf("%d is not a Perfect Number",n); }
df13ae03df72601cc7843ce3a2a328c212b1df82
42541dd5c8f7409cc160d512bebaa69b7fe2d869
/RATA_PDF/input/hist_maker.h
db0f66867a8fcfe1ff3a9ff449f420311774fa94
[]
no_license
Aachen-3A/tools3a
29f37c58c2758ee1b78fafe2012b84425b8bcdc0
6ed78c89ac085b8366d85414759dd9fc576f5423
refs/heads/master
2018-12-28T18:02:33.762660
2015-10-24T08:38:46
2015-10-24T08:38:46
29,477,699
0
1
null
2015-10-24T08:38:47
2015-01-19T15:38:25
Python
UTF-8
C++
false
false
15,374
h
hist_maker.h
/** \file hist_maker.h * * \brief Functions to calculate the PDF uncertainties. * The functions will be called by tha RATA_PDF package. * */ #include <TROOT.h> #include <TH2.h> #include <TStyle.h> #include <TCanvas.h> #include <iostream> #include <fstream> #include "TSystem.h" #include <TChain.h> #include <TFile.h> #include <TH1.h> #include <TEfficiency.h> #include <THnSparse.h> #include <TKey.h> #include <vector> #include <map> #include <TStopwatch.h> #include <string> //#include "RunPDFErrors.h" #include "LHAPDF/LHAPDF.h" using namespace std; // global Variable to log errors (1), warnings (2), info (3), debug(4,5,...) int gLogLevel = 4; /*!< Logging level, coded as an integer (errors=1, warnings=2, info=3, debug=4,5,...) */ #ifndef NDEBUG #define LOG(level, message) { if (gLogLevel >= level) { switch (level) { \ case 1: std::cerr << "ERROR: " << message << std::endl; break; \ case 2: std::cerr << "WARNING: " << message << std::endl; break; \ case 3: std::cout << "INFO: " << message << std::endl; break; \ default: std::cout << "DEBUG: " << message << std::endl; } } } #else #define LOG(level, message) ; #endif #define ERROR(message) LOG(1, message); #define WARNING(message) LOG(2, message); #define INFO(message) LOG(3, message); #define DEBUG(message) LOG(10000, message); // throw an exception that tells me where the exception happened #define THROW(errmsg) throw (std::string( __PRETTY_FUNCTION__ )+std::string(" (file: ")+std::string( __FILE__ )+std::string(", line: ")+std::string( Form("%d", __LINE__) )+std::string(") ")+std::string(errmsg)); ProcInfo_t info; /*!< Process info, to get present memory usage etc. */ /*! \brief Function to simulate raw_input from python * * This function prints a message and waits for user input. * \param[in] question TString of the message that should be printed */ void raw_input(TString question); /*! \brief Function to read the MC scale factor from the number of events * * This function takes the luminosity, data/MC scale factor and the * cross section for the process, reads the number of events from a * given files and returns the scale factor for this sample. * \param[in] f_name Name of the file from which the number of events should be read * \param[in] lumi Luminosity * \param[in] data_mc_scf Optional scale factor between MC and data * \param[in] xs Cross section of the process * \param[out] scf Scale factor for the given sample */ double get_scalefactor(char* f_name,double lumi,double data_mc_scf,double xs); /*! \brief Function to initialze the necessary PDF sets * * This function is called by RATA_PDF to initiate the PDF sets, * used later for the calculation of the PDF uncertainties. * \param[in] PDFpath Path to where the PDF sets are installed * \param[in] n_pdfs Number of PDF sets that should be initialized * \param[in] PDFsets Array of the PDF set names that should be initialized * \param[in] loglevel Coded logging level */ extern "C" void init_bg(char* PDFpath, int n_pdfs, char** PDFsets, int loglevel); /*! \brief Function to read and cut a tree from a .root file * * This function reads in a TTree from a given .root files, * applies given cuts and stores the cutted tree in the memory * \param[in] filename Name of the file from which the tree should be read * \param[in] tree_name Name of the TTree that should be read * \param[in] tree_cuts String of cuts that should be applied * \param[out] smallerTree Final read in and cutted tree */ TTree* read_tree(char* filename, char* tree_name, char* tree_cuts); /*! \brief Function to create for a given TTree the reweighted histograms * * This function reads the necessary information from a given TTree and * reweights all event according to the specified PDF sets. This events * are then filled in histograms fro further processing. * \param[in] tree TTree that should be analyzed * \param[in] branches Array with the name of the branches in the tree * \param[in] histname Name that all filled histograms should get * \param[in] n_pdfs Number of PDF sets to be analyzed * \param[in] PDFsets Array with the name of the PDF sets to be analyzed * \param[in] scalefactor Scalefactor that should be applied to the histograms * \param[out] bool Either true(successfull loop) or false(something failed) */ bool analyser(TTree* tree, char** branches, char* histname, int n_pdfs, char** PDFsets, double scalefactor); /*! \brief Function to write the histograms in an output file * * This function writes the histograms in an output files, and checks * the bin content of each histogram, negative bin contents are set to * zero. * \param[in] histname Name that all filled histograms have * \param[in] n_pdfs Number of PDF sets to be analyzed * \param[in] PDFsets Array with the name of the PDF sets to be analyzed * \param[out] bool Either true(successfull writing) or false(something failed) */ bool writer(char* histname, int n_pdfs, char** PDFsets); /*! \brief Function to coordinate the creation of the reweighted histograms * * This function prints if necessary the most important information on * the reweighting process. It creates the output file an initialzes the * necessary histograms with the user defined binning. It calls the * analyser and the writer and cleans all histograms and files in the * end. This function is also called by RATA_PDF. * \param[in] input_file Name of the file from which the tree should be read * \param[in] tree_name Name of the TTree that should be read * \param[in] tree_cuts String of cuts that should be applied to the tree * \param[in] branches Array with the name of the branches in the tree * \param[in] lumi Luminosity * \param[in] cross_section Cross section of the process * \param[in] n_pdfs Number of PDF sets to be analyzed * \param[in] PDFsets Array with the name of the PDF sets to be analyzed * \param[in] PDFnorm Name of the PDF set which should be used for the normalization * \param[in] histname Name that all filled histograms should have * \param[in] output_file Name that the output file should get * \param[in] n_binning Number of bins that each histogram should have * \param[in] binning Array with the bin edges for the histograms */ extern "C" void make_hists(char* input_file, char* tree_name, char* tree_cuts, char** branches, double lumi, double cross_section, int n_pdfs, char** PDFsets, char* PDFnorm, char* histname, char* output_file, int n_binning, double* binning); /*! \brief Function to calculate the overall uncertainty for a hessian PDF set * * This function calculates the overall uncertainty for a hessian PDF * set. It also calculates the uncertainties due to the alpha_S and * adds this two uncertainties in quadrature. The whole procedure follows * the PDF4LHC recommendation. * \param[in] hist_scaled Vector of Vector of all histograms necessary * \param[in] pdf_correction Global correction factor for this PDF set * \param[in] as_plus_correction Correction factor for the alpha_S plus uncertainties * \param[in] as_minus_correction Correction factor for the alpha_S minus uncertainties * \param[in] as_plus_number Number of the alpha_S plus member, defined by the PDF config * \param[in] as_minus_number Number of the alpha_S minus member, defined by the PDF config * \param[out] v_as_errors Vector of Vector with the resulting uncertainties for each bin */ vector< vector<Float_t> > hessian_pdf_asErr(vector< vector< TH1D* > > hist_scaled, double pdf_correction, double as_plus_correction, double as_minus_correction, int* as_plus_number, int* as_minus_number); /*! \brief Function to get the final uncertainty histograms for a hessian PDF set * * This function reads in the necessary reweighted histograms, calls * hessian_pdf_asErr and structures the output in a nice histogram * format. This function is called by RATA_PDF. * \param[in] n_pdfSet Number of PDF sets to be analyzed * \param[in] pdf_sets Array with the name of the PDF sets to be analyzed * \param[in] outfile Name that the output file should get * \param[in] out_par How to handle the output file (RECREATE, UPDATE, ...) * \param[in] infile Name of the input file * \param[in] main_hist Base name of all histograms * \param[in] shortname Short name that the output histograms should get * \param[in] pdf_correction Global correction factor for this PDF set * \param[in] as_plus_correction Correction factor for the alpha_S plus uncertainties * \param[in] as_minus_correction Correction factor for the alpha_S minus uncertainties * \param[in] as_plus_number Number of the alpha_S plus member, defined by the PDF config * \param[in] as_minus_number Number of the alpha_S minus member, defined by the PDF config */ extern "C" void pdf_calcer_hessian(int n_pdfSet, char** pdf_sets, char* outfile, char* out_par, char* infile, char* main_hist, char* shortname, double pdf_correction, double as_plus_correction, double as_minus_correction, int* as_plus_number, int* as_minus_number); /*! \brief Function to calculate the overall uncertainty for a MC PDF set * * This function calculates the overall uncertainty for a MC PDF * set directly combined with the uncertainties due to alpha_S. The * whole procedure follows the PDF4LHC recommendation. * \param[in] hist_scaled Vector of Vector of all histograms necessary * \param[out] v_as_errors Vector of Vector with the resulting uncertainties for each bin */ vector< vector<Float_t> > NNPDF_weighted_mean( vector< vector< TH1D* > > hist_scaled); /*! \brief Function to get the final uncertainty histograms for a MC PDF set * * This function reads in the necessary reweighted histograms, calls * NNPDF_weighted_mean and structures the output in a nice histogram * format. This function is called by RATA_PDF. * \param[in] n_pdfSet Number of PDF sets to be analyzed * \param[in] pdf_sets Array with the name of the PDF sets to be analyzed * \param[in] outfile Name that the output file should get * \param[in] out_par How to handle the output file (RECREATE, UPDATE, ...) * \param[in] infile Name of the input file * \param[in] main_hist Base name of all histograms * \param[in] shortname Short name that the output histograms should get */ extern "C" void pdf_calcer_MC(int n_pdfSet, char** pdf_sets, char* outfile, char* out_par, char* infile, char* main_hist, char* shortname); LHAPDF::PDF* Mainpdf; /*!< PDF set that will be used for normalization. */ vector<vector< LHAPDF::PDF* > > allPdfsets; /*!< Vector of Vector of all necessary PDF sets. */ static map<TString, TH1D * > histo; /*!< Map of a string and histogram, for easy histogram handling. */ /** \namespace HistClass * * \brief Functions to have easy histogram handling * * In this namespace different functions to interact with the histogram * map are included, to create, fill and write histograms in a convinient * way. */ namespace HistClass { /*! \brief Function to create histograms in the histo map * * \param[in] n_histos Number of histograms that should be created with different numbers * \param[in] name Name of the histograms that should be created * \param[in] title Title of the histograms that should be created * \param[in] nbinsx Number of bins on the x-axis * \param[in] xlow Lower edge of the x-axis * \param[in] xup Upper edge of the x-axis * \param[in] xtitle Optinal title of the x-axis (DEFAULT = "") */ static void CreateHisto(Int_t n_histos, const char* name, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, TString xtitle = "") { for(int i = 0; i < n_histos; i++){ string dummy = Form("h1_%d_%s", i, name); histo[dummy] = new TH1D(Form("h1_%d_%s", i, name), title, nbinsx, xlow, xup); histo[dummy] -> Sumw2(); histo[dummy] -> GetXaxis() ->SetTitle(xtitle); } } /*! \brief Function to clear histograms in the histo map * * \param[in] n_histos Number of histograms with the same name * \param[in] name Name of the histograms that should be cleared */ static void ClearHisto(Int_t n_histos, const char* name) { for(int i = 0; i < n_histos; i++){ string dummy = Form("h1_%d_%s", i, name); histo[dummy] -> Reset(); } } /*! \brief Function to rebin histograms in the histo map * * \param[in] n_histos Number of histograms with the same name * \param[in] name Name of the histograms that should be rebinned * \param[in] n_rebin Number of bins that the rebinned histogram should have * \param[in] bins Array of bin edges that the rebinned histogram should have */ static void RebinHisto(Int_t n_histos, const char* name, Int_t n_rebin, Double_t* bins) { for(int i = 0; i < n_histos; i++){ string dummy = Form("h1_%d_%s", i, name); char* cdummy = Form("h1_%d_%s", i, name); histo[dummy] = (TH1D*)histo[dummy] -> Rebin(n_rebin,cdummy, bins); } } /*! \brief Function to fille events in a histogram in the histo map * * \param[in] n_histos Number of the histograms to be filled * \param[in] name Name of the histogram to be filled * \param[in] value Value that should be filled in the histogram * \param[in] weight Weight the the event should get */ static void Fill(Int_t n_histo, const char * name, double value, double weight) { string dummy = Form("h1_%d_%s", n_histo, name); histo[dummy]->Fill(value,weight); } /*! \brief Function to write a histogram from the histo map * * \param[in] n_histos Number of histogram to be written * \param[in] name Name of the histogram to be written */ static void Write(Int_t n_histo, const char * name) { string dummy = Form("h1_%d_%s", n_histo, name); histo[dummy]->Write(); } /*! \brief Function to set every negative bin content to zero * * \param[in] n_histos Number of histogram to be adapted * \param[in] name Name of the histogram to be adapted */ static void SetToZero(Int_t n_histo, const char * name) { string dummy = Form("h1_%d_%s", n_histo, name); int Nbins2 = histo[dummy] -> GetNbinsX(); for ( int bb = 0; bb < Nbins2+1; bb++) { double binValue = histo[dummy] -> GetBinContent(bb); if (binValue < 0) { //cout << "Bin " << bb << " " << dummy << " is negative: " << binValue << " and is being set to zero!" << endl; histo[dummy] -> SetBinContent(bb,0.); } } } /*! \brief Function to get a histogram from the histo map * * \param[in] n_histos Number of histogram to be read * \param[in] name Name of the histogram to be read */ static TH1D* ReturnHist(Int_t n_histo, const char * name) { string dummy = Form("h1_%d_%s", n_histo, name); return histo[dummy]; } /*! \brief Function to delete a histogram from the histo map * * \param[in] n_histos Number of histogram to be deleted * \param[in] name Name of the histogram to be deleted */ static void DeleteHisto(Int_t n_histos, const char* name){ for(int i = 0; i < n_histos; i++){ string dummy = Form("h1_%d_%s", i, name); delete histo[dummy]; } } }
8906a5223229b0bd3958f6a15593e7cbef002fc5
b831452a8efdf7559db62df7c5d3fea95656230f
/oddgravitysdk/CxImage/demo/DlgMix.cpp
ab3b1bd3fc7c8036a3e372e12b928e627c69ac04
[ "MIT" ]
permissive
mschulze46/PlaylistCreator
83760d984f41c138b701fd2e0a55d86ed92b8740
d1fb60c096eecb816f469754cada3e5c8901157b
refs/heads/master
2020-09-29T04:41:39.271163
2019-12-18T10:11:02
2019-12-18T10:11:02
226,953,263
1
0
null
null
null
null
UTF-8
C++
false
false
5,559
cpp
DlgMix.cpp
// DlgMix.cpp : implementation file // #include "stdafx.h" #include "demo.h" #include "demoDoc.h" #include "DlgMix.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // DlgMix dialog DlgMix::DlgMix(CWnd* pParent /*=NULL*/) : CDialog(DlgMix::IDD, pParent) { //{{AFX_DATA_INIT(DlgMix) m_xoffset = 0; m_yoffset = 0; m_mixalpha = FALSE; //}}AFX_DATA_INIT } void DlgMix::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(DlgMix) DDX_Control(pDX, IDC_PICTURE, m_picture); DDX_Control(pDX, IDC_BUTTON1, m_preview); DDX_Control(pDX, IDOK, m_ok); DDX_Control(pDX, IDCANCEL, m_canc); DDX_Control(pDX, IDC_SRC, m_cbSrc); DDX_Control(pDX, IDC_OP, m_cbOpType); DDX_Control(pDX, IDC_DST, m_cbDst); DDX_Text(pDX, IDC_EDIT1, m_xoffset); DDX_Text(pDX, IDC_EDIT2, m_yoffset); DDX_Check(pDX, IDC_CHECK1, m_mixalpha); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(DlgMix, CDialog) //{{AFX_MSG_MAP(DlgMix) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_WM_DESTROY() ON_CBN_SELCHANGE(IDC_DST, OnSelchangeDst) ON_CBN_SELCHANGE(IDC_SRC, OnSelchangeSrc) ON_CBN_SELCHANGE(IDC_OP, OnSelchangeOp) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // DlgMix message handlers BOOL DlgMix::OnInitDialog() { CDialog::OnInitDialog(); m_bitmap=0; m_ratio=1.0f; m_xoffset=m_yoffset=0; pDocSrc = pDocDst = 0; OpType=0; m_mixalpha = 0; m_ok.SetIcon(IDI_G,BS_LEFT); m_canc.SetIcon(IDI_R,BS_LEFT); POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition(); while (pos != NULL) { CDocTemplate* pTemplate = AfxGetApp()->GetNextDocTemplate(pos); ASSERT(pTemplate->IsKindOf(RUNTIME_CLASS(CDocTemplate))); POSITION pos2 = pTemplate->GetFirstDocPosition(); while (pos2 != NULL) { CDemoDoc* pDoc = (CDemoDoc*) pTemplate->GetNextDoc(pos2); ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CDemoDoc))); CString title = pDoc->GetTitle(); m_cbSrc.AddString(title); m_cbSrc.SetItemData(m_cbSrc.GetCount()-1, (DWORD)pDoc); m_cbDst.AddString(title); m_cbDst.SetItemData(m_cbDst.GetCount()-1, (DWORD)pDoc); } } m_cbSrc.SetCurSel(0); if (m_cbDst.GetCount()>1){ m_cbDst.SetCurSel(1); } else { m_cbDst.SetCurSel(0); } m_cbOpType.AddString("OpAdd"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpAdd); m_cbOpType.AddString("OpAnd"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpAnd); m_cbOpType.AddString("OpXor"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpXor); m_cbOpType.AddString("OpOr"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpOr); m_cbOpType.AddString("OpScreen"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpScreen); m_cbOpType.AddString("OpMask"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpMask); m_cbOpType.AddString("OpSrcCopy"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpSrcCopy); m_cbOpType.AddString("OpDstCopy"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpDstCopy); m_cbOpType.AddString("OpSub"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpSub); m_cbOpType.AddString("OpSrcBlend"); m_cbOpType.SetItemData(m_cbOpType.GetCount()-1, (DWORD)CxImage::ImageOpType::OpSrcBlend); m_cbOpType.SetCurSel(1); SetMix(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void DlgMix::OnButton1() { UpdateData(1); SetMix(); } void DlgMix::OnDestroy() { CDialog::OnDestroy(); if (m_bitmap) DeleteObject(m_bitmap); } void DlgMix::OnSelchangeDst() { UpdateData(1); SetMix(); } void DlgMix::OnSelchangeSrc() { UpdateData(1); SetMix(); } void DlgMix::OnSelchangeOp() { UpdateData(1); SetMix(); } void DlgMix::SetThumbs(CxImage* pSrc, CxImage* pDst) { if (pSrc==0 || pDst==0) return; if (pDst->GetWidth() > pDst->GetHeight()){ m_ratio = 200.0f/pDst->GetWidth(); } else { m_ratio = 200.0f/pDst->GetHeight(); } if (m_ratio > 1.0f) m_ratio = 1.0f; pSrc->Resample((long)(pSrc->GetWidth()*m_ratio),(long)(pSrc->GetHeight()*m_ratio),1,&m_imageSrc); pDst->Resample((long)(pDst->GetWidth()*m_ratio),(long)(pDst->GetHeight()*m_ratio),1,&m_imageDst); } void DlgMix::SetMix() { pDocSrc = (CDemoDoc*) m_cbSrc.GetItemData(m_cbSrc.GetCurSel()); pDocDst = (CDemoDoc*) m_cbDst.GetItemData(m_cbDst.GetCurSel()); OpType = m_cbOpType.GetItemData(m_cbOpType.GetCurSel()); if (pDocSrc==0 || pDocDst==0) return; CxImage* pImageSrc = pDocSrc->GetImage(); CxImage* pImageDst = pDocDst->GetImage(); SetThumbs(pImageSrc,pImageDst); CxImage tmp; tmp.Copy(m_imageDst); tmp.Mix(m_imageSrc,(CxImage::ImageOpType)OpType,(long)(m_xoffset*m_ratio),(long)(m_yoffset*m_ratio),m_mixalpha!=0); if (m_mixalpha!=0){ RGBQUAD c={255,255,255,0}; tmp.SetTransColor(c); tmp.AlphaStrip(); } if (m_bitmap) DeleteObject(m_bitmap); m_bitmap = tmp.MakeBitmap(m_picture.GetDC()->m_hDC); m_picture.SetBitmap(m_bitmap); } void DlgMix::OnOK() { SetMix(); CDialog::OnOK(); }
ddff719019e2d9ef0d588f71199ec552d046aa4e
c1b1f9e168ff4d707097290a8b410cc160b41bfd
/ObjectPooling/src/StackPool.hpp
3e6edc80ba6f204615d35b48b277ad6a7a2b531d
[ "MIT" ]
permissive
swrni/object_pooling
25c22b4d6f1dd7567933ebdecda1c0e8df97b31a
81d82e257a2ddb2c3871e8c2af77bf416c423502
refs/heads/master
2021-04-18T21:39:06.052423
2018-03-26T07:38:19
2018-03-26T07:38:19
126,790,336
0
0
null
null
null
null
UTF-8
C++
false
false
5,030
hpp
StackPool.hpp
#pragma once #include <iostream> #include <vector> #include <array> #include <memory> #include <numeric> // std::iota. struct EmptyType {}; template <typename Object, typename Store = EmptyType> struct Initialize { static_assert( !std::is_same<Object,Store>(), "Object and Store must differ" ); // Simple initializer. template <typename ...Args> void operator()( Object& object, Args&&... args ) const { object = Object( std::forward<Args>( args )... ); } // std::unique_ptr initializer. template <typename ...Args> void operator()( Store& store, Args&&... args ) const { store = std::make_unique<Object>( std::forward<Args>( args )... ); } }; template <typename Object, typename Store = EmptyType> struct GetRawPointer { Object* operator()( Object& object ) const { return &object; } Object* operator()( Store& store ) const { return store.get(); } }; template < typename Object, typename _StoreObject = Object, typename _StoreToPointer = GetRawPointer<Object>, typename _InitializeStore = Initialize<Object>> struct StackPoolTraits { using StoreObject = _StoreObject; using StoreToPointer = _StoreToPointer; using InitializeStore = _InitializeStore; }; template <typename Pool> class BorrowPtrDeleter { public: BorrowPtrDeleter( const BorrowPtrDeleter& ) = delete; BorrowPtrDeleter& operator=( const BorrowPtrDeleter& ) = delete; BorrowPtrDeleter& operator=( BorrowPtrDeleter&& ) = delete; BorrowPtrDeleter( Pool& pool ) : pool_( pool ) {} template <typename Object> void operator()( Object* object ) { // std::cout << "BorrowPtrDeleter::operator()\n"; if ( !object ) { #ifdef _DEBUG std::cout << "object is nullptr\n"; #endif return; } pool_.Destroy( object ); } private: Pool& pool_; }; template <typename _Object, size_t N, typename Traits = StackPoolTraits<_Object>> class StackPool { static_assert( N != 0, "N must be larger than zero." ); public: using Object = _Object; using StoreObject = typename Traits::StoreObject; using StoreToPointer = typename Traits::StoreToPointer; using InitializeStore = typename Traits::InitializeStore; using BorrowPtr = std::unique_ptr< Object, BorrowPtrDeleter<StackPool> >; StackPool( const StackPool& ) = delete; StackPool& operator=( const StackPool& ) = delete; StackPool& operator=( StackPool&& ) = delete; template <typename StoreToPointer, typename InitializeStore> explicit StackPool( StoreToPointer&& store_to_pointer, InitializeStore&& initialize_store ) : store_to_pointer_( std::forward<StoreToPointer>( store_to_pointer ) ), initialize_store_( std::forward<InitializeStore>( initialize_store ) ), unused_indices_( N ), used_indices_( 0 ) { InitializeIndices(); } StackPool() : store_to_pointer_( Traits::StoreToPointer{} ), initialize_store_( Traits::InitializeStore{} ), unused_indices_( N ), used_indices_( 0 ) { InitializeIndices(); } constexpr static std::size_t MaxSize() noexcept { return N; } std::size_t SizeLeft() const { return unused_indices_.size(); } template <typename ...Args> BorrowPtr Create( Args&&... args ) { // Are all objects already in use? if ( SizeLeft() == 0 ) { return CreateBorrowPtr( nullptr ); } StoreObject& store = TakeUnusedStoreObject(); initialize_store_( store, std::forward<Args>( args )... ); return CreateBorrowPtr( store ); } template <typename ...Args> BorrowPtr CreateOrFail( Args&&... args ) { if ( auto ptr = Create( std::forward<Args>( args )... ); ptr ) { return ptr; } throw std::bad_alloc(); } void Destroy( Object* object ) { // TODO:: Fix this raw loop monster. for ( auto i=0u; i<N; ++i ) { if ( store_to_pointer_( buffer_[i] ) == object ) { unused_indices_.push_back( i ); for ( auto j=0u; j<N; ++j ) { if ( used_indices_[j] == i ) { // Remove i (at position j) from used_indices_. used_indices_[j] = used_indices_.back(); used_indices_.pop_back(); return; } } } } } private: void InitializeIndices() { std::iota( std::begin( unused_indices_ ), std::end( unused_indices_ ), 0 ); used_indices_.reserve( N ); } BorrowPtr CreateBorrowPtr( Object* object ) { return { object, *this }; } BorrowPtr CreateBorrowPtr( StoreObject& store ) { return { store_to_pointer_( store ), *this }; } StoreObject& TakeUnusedStoreObject() { const std::size_t index = unused_indices_.back(); used_indices_.push_back( index ); unused_indices_.pop_back(); return buffer_[ index ]; } private: const StoreToPointer store_to_pointer_; const InitializeStore initialize_store_; std::array<StoreObject, N> buffer_; std::vector<std::size_t> unused_indices_; std::vector<std::size_t> used_indices_; /*const std::size_t max_object_count_; const std::size_t buffer_size_{ max_object_count_ * sizeof(Object) }; std::uint8_t pool_[ buffer_size_ ];*/ };
510ef68c6e0f2cc3d2b602057878389e59bc9855
17bd992d9b0bed53db905988cf5e0667b15dffb3
/kb4/poj2502.cpp
1fe5d31291049129bc59ee57be4a4b491161aa4d
[]
no_license
Amano-Sei/acmnomichi
2c1cc640a5dd63ea930e7a1b4555da554ba6bc9c
80bc7fa29720c4f724e7f64afb253f52eff252b3
refs/heads/master
2020-09-27T06:16:23.669010
2019-12-22T14:55:21
2019-12-22T14:55:21
226,448,318
0
0
null
null
null
null
UTF-8
C++
false
false
2,767
cpp
poj2502.cpp
/************************************************************************* > File Name: poj2502.cpp > Author: Amano Sei > Mail: amano_sei@outlook.com > Created Time: 2019/9/27 9:04:12 ************************************************************************/ #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <queue> using namespace std; const int maxn = 205; const double inf = 1/0.0; struct qnode{ int ci; double cost; qnode(){} qnode(int ci, double cost):ci(ci), cost(cost){} bool operator < (const qnode &a) const{ return cost > a.cost; } }; struct point{ int x, y; int pi; point(){} point(int x, int y, int pi):x(x), y(y), pi(pi){} }; vector<point> subline[maxn]; double dis[maxn][maxn]; double d[maxn]; bool book[maxn]; int si, n; void dijkstra(){ for(int i = 1; i < n; i++) d[i] = inf; //memset(book, 0, sizeof(book)); priority_queue<qnode> q; d[0] = 0; q.push(qnode(0,0)); while(!q.empty()){ int u = q.top().ci; q.pop(); if(book[u]) continue; if(u == 1) return; book[u] = true; for(int i = 1; i < n; i++) if(!book[i] && d[i] > d[u]+dis[u][i]){ d[i] = d[u]+dis[u][i]; q.push(qnode(i, d[i])); } } } int main(){ int cx, cy; scanf("%d%d", &cx, &cy); subline[si++].push_back(point(cx, cy, n++)); scanf("%d%d", &cx, &cy); subline[si++].push_back(point(cx, cy, n++)); while(scanf("%d%d", &cx, &cy) != EOF){ subline[si].push_back(point(cx, cy, n++)); while(scanf("%d%d", &cx, &cy) != EOF && cx >= 0) subline[si].push_back(point(cx, cy, n++)); si++; } for(int i = 0; i < si; i++) for(int j = 0; j <= i; j++) for(int ii = 0; ii < subline[i].size(); ii++) for(int jj = 0; jj < subline[j].size(); jj++){ int u = subline[i][ii].pi; int v = subline[j][jj].pi; dis[u][v] = dis[v][u] = sqrt((subline[i][ii].x-subline[j][jj].x)*(subline[i][ii].x-subline[j][jj].x)+(subline[i][ii].y-subline[j][jj].y)*(subline[i][ii].y-subline[j][jj].y))/10000.0*60.0; } for(int i = 0; i < si; i++) for(int j = 0; j < subline[i].size()-1; j++){ int u = subline[i][j].pi; int v = subline[i][j+1].pi; dis[u][v] = dis[v][u] = min(dis[u][v], sqrt((subline[i][j].x-subline[i][j+1].x)*(subline[i][j].x-subline[i][j+1].x)+(subline[i][j].y-subline[i][j+1].y)*(subline[i][j].y-subline[i][j+1].y))/40000.0*60.0); } dijkstra(); printf("%d\n", (int)(d[1]+0.5)); return 0; }
a19f83265aa9f8fd1e0789fcaaa5bca774b8f5fa
ec113fe9174910f622d7b4b46b9fd0241388b009
/Splash.cpp
90ab9852d3115070615873f8f60141e242e1045d
[]
no_license
RamseyX/RamseyX-client
150d67bc5b0cd81420883568dddabc277d54f8e2
d03a6af1d4e9d5bdc8849ff5de893c0b55fc544f
refs/heads/master
2020-12-24T14:18:31.017496
2013-12-29T15:12:17
2013-12-29T15:12:17
15,371,939
1
0
null
null
null
null
UTF-8
C++
false
false
1,625
cpp
Splash.cpp
// Splash.cpp : 实现文件 // #include "stdafx.h" #include "RamseyX.h" #include "Splash.h" // CSplash IMPLEMENT_DYNAMIC(CSplash, CWnd) CSplash::CSplash() { } CSplash::~CSplash() { } BEGIN_MESSAGE_MAP(CSplash, CWnd) ON_WM_PAINT() ON_MESSAGE(WM_INIT, CSplash::OnInit) ON_MESSAGE(WM_BENCHMARK, CSplash::OnBenchmark) END_MESSAGE_MAP() // CSplash 消息处理程序 void CSplash::Create(UINT nBitmapID) { m_bmp.LoadBitmap(nBitmapID); BITMAP bmp; m_bmp.GetBitmap(&bmp); int x = (::GetSystemMetrics(SM_CXSCREEN) - bmp.bmWidth) / 2; int y = (::GetSystemMetrics(SM_CYSCREEN) - bmp.bmHeight) / 2; CRect rect(x, y, x + bmp.bmWidth, y + bmp.bmHeight); CreateEx(0, AfxRegisterWndClass(0), _T(""), WS_POPUP | WS_VISIBLE, rect, NULL, 0); } void CSplash::OnPaint() { CPaintDC dc(this); // device context for painting BITMAP bmp; m_bmp.GetBitmap(&bmp); CDC dcComp; dcComp.CreateCompatibleDC(&dc); dcComp.SelectObject(&m_bmp); dc.BitBlt(0, 0, bmp.bmWidth, bmp.bmHeight, &dcComp, 0, 0, SRCCOPY); } LRESULT CSplash::OnInit(WPARAM wParam, LPARAM lParam) { CClientDC dc(this); dc.SetBkMode(TRANSPARENT); dc.SetTextColor(RGB(255, 255, 255)); CString strInit(_T("Initializing...")); if (wParam) strInit += _T("OK"); dc.TextOut(520, 220, strInit, strInit.GetLength()); return 0; } LRESULT CSplash::OnBenchmark(WPARAM wParam, LPARAM lParam) { CClientDC dc(this); dc.SetBkMode(TRANSPARENT); dc.SetTextColor(RGB(255, 255, 255)); CString strBenchmark(_T("Benchmarking...")); if (wParam) strBenchmark += _T("OK"); dc.TextOut(520, 240, strBenchmark, strBenchmark.GetLength()); return 0; }
496dbd0231e7c42cb894460a51931b59aedc176d
56968444705bb68823c547a93f6f7580d7aa00ac
/monday_gsm_code.ino
6d4fcdf6d1f8359cf3ea5c61cb320baedc21e1c4
[]
no_license
Agatha18/Remote-Alert-System
d1dee49fc76b07933d9f1c72f723a99cd4a4110c
593eeb7eb1ec1626da36c6d907f93bcb7017b361
refs/heads/master
2020-06-24T15:37:18.345830
2019-07-30T15:04:16
2019-07-30T15:04:16
199,002,963
1
0
null
null
null
null
UTF-8
C++
false
false
1,659
ino
monday_gsm_code.ino
#include <RH_ASK.h> #include <SPI.h> #include <SoftwareSerial.h> #include <Sim800l.h> SoftwareSerial mySerial (9,10); #define dataout 12 #define datain 11 RH_ASK rf_driver; int buttonState1 =0; int buttonPin = 2; int buzzerPin = 3; int ledPin = 6; const int toneFreq = 423; void setup() { rf_driver.init(); pinMode(dataout,OUTPUT); pinMode(buttonPin, INPUT); pinMode(buzzerPin, OUTPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); mySerial.begin(9600); delay(500); } void loop() { updateSerial(); buttonState1 = digitalRead(buttonPin); if (buttonState1==HIGH) { sendsms(); delay(500); const char *msg = "EMERGENCY!"; rf_driver.send((uint8_t *)msg, strlen(msg)); rf_driver.waitPacketSent(); //delay(1000); tone(buzzerPin, toneFreq); delay(500); digitalWrite(ledPin, HIGH); tone(buzzerPin, toneFreq); delay(500); digitalWrite(ledPin, LOW); noTone(buzzerPin); } else { /* digitalWrite(ledPin, LOW); noTone(buzzerPin); */ } } void updateSerial(){ delay(500); while(mySerial.available()) { Serial.write(mySerial.read()); } while(Serial.available()) { mySerial.write(Serial.read()); } } void sendsms() { mySerial.println("AT\r"); delay(500); Serial.write(mySerial.read()); mySerial.println("AT+CMGF=1\r"); delay(500); mySerial.println("AT+CMGS=\"+256783420711\"\r"); delay(500); mySerial.println("EMERGENCY!"); delay(500); mySerial.println((char)26); delay(100); }
3fa2f0ab375142a820cc05241df56e6ffbc8494b
8e53ec500653d1836ece3366e6d0fba8332b6acb
/pr09/5.cpp
17b2f7d10df0003e270ce2c46bd85d5d5eac4514
[]
no_license
artnitolog/cpp-grammars_course
184bd38b4847476a1a30c3c7cd3249db47a03eb2
2382e7db12bbad4f30b81c678e75ce93d8daa2aa
refs/heads/master
2022-11-24T23:53:27.766214
2020-07-23T22:51:16
2020-07-23T22:51:16
282,063,945
0
0
null
null
null
null
UTF-8
C++
false
false
1,444
cpp
5.cpp
#include <iostream> #include <map> #include <set> #include <vector> #include <utility> #include <cctype> #include <algorithm> #include <iterator> class CFGrammar { public: CFGrammar(std::vector<std::pair<char, std::string>> &&rules) : rules_(std::move(rules)) { for (auto &[from, to]: rules_) { std::copy_if(to.begin(), to.end(), std::inserter(nt_graph_[from], nt_graph_[from].end()), [](char c){ return isupper(c); }); } } void print_reachable() { std::set<char> visited; dfs('S', visited); for (auto &[from, to]: rules_) { if (visited.find(from) != visited.end()) { std::cout << from << " " << to << std::endl; } } } private: std::vector<std::pair<char, std::string>> rules_{}; std::map<char, std::set<char>> nt_graph_{}; // not a sym-graph, bc without terminals void dfs(char cur, std::set<char> &visited) { visited.insert(cur); for (auto now : nt_graph_[cur]) { if (visited.find(now) == visited.end()) { dfs(now, visited); } } } }; int main() { char from; std::string to; std::vector<std::pair<char, std::string>> rules; while (std::cin >> from >> to) { rules.push_back({from, to}); } CFGrammar grammar(std::move(rules)); grammar.print_reachable(); return 0; }
7dfe318dfcd5ab286436ab1481e0e6c8314106e9
7c616726fd00dfd390bc88264cb0a60f7eb12445
/projects/Getting_Started/src/Robot.cpp
fe10e54dc59bb1a23bda2a364a967b4ee9d54818
[]
no_license
Sparky384/FRC_2015
0c343cc8e211b3f05a2286e7265cc51ac9e5a75e
75d5bca1dae977068ad44778156375490bfab191
refs/heads/master
2021-01-16T19:08:21.034521
2015-03-18T00:40:35
2015-03-18T00:40:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,596
cpp
Robot.cpp
#include "WPILib.h" #include "Commands/ExtendRightWiper.h" #include "Commands/RetractRightWiper.h" #include "Utilities.h" #include "RobotDefinitions.h" #include "ElevatorController.h" #include "DerivedCameraServer.h" #include <math.h> class Robot: public IterativeRobot { Gyro *rateGyro; RobotDrive myRobot; // robot drive system Jaguar *elevatorMotorA; Jaguar *elevatorMotorB; Jaguar *swingArmMotor; Joystick rightStick; Joystick leftStick; Joystick controlBox; DoubleSolenoid *dsLeft; DoubleSolenoid *dsRight; DoubleSolenoid *dsGrappler; //Camera Servo Servo *camYServo; Servo *camXServo; LiveWindow *lw; USBCamera *camera; CameraServer *cameraServer; Relay *leftIntakeWheel; Relay *rightIntakeWheel; JoystickButton *button1; JoystickButton *button2; AnalogPotentiometer *elevatorPot; AnalogInput *elevatorVertPotInput; AnalogInput *elevatorHorizPotInput; ElevatorController *elevatorController; AnalogPotentiometer *vertPot; // PIDController *elevatorPidController_0; // PIDController *elevatorPidController_1; int autoLoopCounter; int teleLoopCounter; float prevAngle; float prevPot; float prevLeftEnc; float prevRightEnc; float autoDistCounter; float autoMaxDistance; float autoGyroAngle; int autoState; bool b[7]; int wiperState = 0; bool grappling = true; Compressor *compressor; Encoder *encLeft; Encoder *encRight; public: Robot() : myRobot(FRONT_LEFT_MOTOR_CHANNEL, REAR_LEFT_MOTOR_CHANNEL, FRONT_RIGHT_MOTOR_CHANNEL, REAR_RIGHT_MOTOR_CHANNEL), // these must be initialized in the same order // as they are declared above. rightStick(LEFT_JOYSTICK_USB_PORT), leftStick(RIGHT_JOYSTICK_USB_PORT), controlBox(CONTROL_BOX_USB_PORT), lw(NULL), autoLoopCounter(0) { myRobot.SetExpiration(0.1); //myRobot.SetInvertedMotor(MotorType::) // This code enables the USB Microsoft Camera display. // You must pick "USB Camera HW" on the Driverstation Dashboard // the name of the camera "cam1" can be found in the RoboRio web dashboard // CameraServer::GetInstance()->SetQuality(90); // CameraServer::GetInstance()->SetSize(2); // CameraServer::GetInstance()->StartAutomaticCapture("cam1"); // CameraServer::GetInstance()->m_camera->SetExposureAuto(); DerivedCameraServer *cameraServer = DerivedCameraServer::GetInstance(); cameraServer->SetQuality(90); cameraServer->SetSize(2); cameraServer->StartAutomaticCapture("cam1"); cameraServer->setExposureAuto(); cameraServer->setWhiteBalanceAuto(); compressor = new Compressor(); rateGyro = new Gyro(GYRO_RATE_INPUT_CHANNEL); dsLeft = new DoubleSolenoid(LEFT_WIPER_SOLENOID_FWD_CHANNEL, LEFT_WIPER_SOLENOID_REV_CHANNEL); dsRight = new DoubleSolenoid(RIGHT_WIPER_SOLENOID_FWD_CHANNEL, RIGHT_WIPER_SOLENOID_REV_CHANNEL); dsGrappler = new DoubleSolenoid(GRAPPLER_SOLENOID_FWD_CHANNEL, GRAPPLER_SOLENOID_REV_CHANNEL); encLeft = new Encoder(LEFT_WHEEL_ENCODER_CHANNEL_A, LEFT_WHEEL_ENCODER_CHANNEL_B, false, Encoder::EncodingType::k4X); encRight = new Encoder(RIGHT_WHEEL_ENCODER_CHANNEL_A, RIGHT_WHEEL_ENCODER_CHANNEL_B, true, Encoder::EncodingType::k4X); encLeft->SetDistancePerPulse(WHEEL_DIAMETER * M_PI / PULSES_PER_ROTATION); // 4" diameter wheel * PI / 360 pulses/rotation encRight->SetDistancePerPulse(WHEEL_DIAMETER * M_PI / PULSES_PER_ROTATION); leftIntakeWheel = new Relay(LEFT_INTAKE_WHEEL_CHANNEL); rightIntakeWheel = new Relay(RIGHT_INTAKE_WHEEL_CHANNEL); elevatorVertPotInput = new AnalogInput(ELEVATOR_VERT_INPUT_CHANNEL); elevatorHorizPotInput = new AnalogInput(ELEVATOR_HORIZ_INPUT_CHANNEL); elevatorMotorA = new Jaguar(ELEVATOR_MOTOR_CHANNEL_A); elevatorMotorB = new Jaguar(ELEVATOR_MOTOR_CHANNEL_B); swingArmMotor = new Jaguar(SWING_ARM_MOTOR_CHANNEL); button1 = new JoystickButton(&rightStick, 1); button2 = new JoystickButton(&rightStick, 2); camYServo = new Servo(9); camXServo = new Servo(8); //button1->ToggleWhenPressed(new ExtendRightWiper(doubleSolenoid)); //button2->ToggleWhenPressed(new RetractRightWiper(doubleSolenoid)); // fill in horizontal relay variable when available // elevatorController = new ElevatorController(elevatorVertPotInput, elevatorHorizPotInput, // elevatorMotorA, elevatorMotorB, (Relay*)NULL); // analog input min value: 1.352539 // analog input max value: 4.964599 // analog range = 3.61206 // 0.992130 vertPot = new AnalogPotentiometer(elevatorVertPotInput, 5.0, -1.372931); // elevatorPidController_0 = new PIDController(0.5, 0.0, 0.0, vertPot, elevatorMotorA); // elevatorPidController_1 = new PIDController(0.5, 0.0, 0.0, vertPot, elevatorMotorB); } private: void RobotInit() { lw = LiveWindow::GetInstance(); printf("Team 812 - It's alive! 2015-02-12\n"); } void DisabledInit() { printf("Team 812 - DisabledInit\n"); } void DisabledPeriodic() { //printf("Team 812 - DisabledPeriodic\n"); } void AutonomousInit() { autoLoopCounter = 0; autoDistCounter = 0; autoMaxDistance = 12.0 * 4.0 * 3.14159; // 12 rotations * 4" diameter wheel * PI autoGyroAngle = 0; autoState = 0; encRight->Reset(); encLeft->Reset(); rateGyro->Reset(); for (int i = 1; i <= 7; i++) { b[i] = controlBox.GetRawButton(i); printf("button[%d] = %s\n", i, b[i] ? "true":"false"); } //printf("Hello 812!"); } void AutonomousPeriodic() { double robotDriveCurve; if(autoLoopCounter++ < 500) { if(b[4]==0) { if( autoState == 0 ) { // make sure the elevator is down elevatorMotorA->Set(-0.1); elevatorMotorB->Set(-0.1); Wait(0.5); elevatorMotorA->Set(0.0); elevatorMotorB->Set(0.0); autoState = 1; } if( autoState == 1) { // drive the robot into the box a bit myRobot.Drive(-0.15,0.0); Wait(0.5); autoState = 2; } if( autoState == 2) { // pick up the box elevatorMotorA->Set(0.5); elevatorMotorB->Set(0.5); Wait(0.2); myRobot.Drive(0.0, 0.0); // stop driving forward Wait(0.3); elevatorMotorA->Set(0.1); elevatorMotorB->Set(0.1); autoState = 3; encRight->Reset(); encLeft->Reset(); // rateGyro->Reset(); } if( autoState == 3) { autoDistCounter = encRight->GetDistance(); autoGyroAngle = rateGyro->GetAngle(); robotDriveCurve = PwrLimit(-autoGyroAngle * 1.2, -1.0, 1.0); if (-autoDistCounter <= BACKUP_INCHES && autoState == 3) { printf("Distance: %f, Turn direction: %f, Direction error: %f, Goal: %f\n", autoDistCounter, robotDriveCurve, autoGyroAngle, -BACKUP_INCHES); myRobot.Drive(BACKUP_SPEED, robotDriveCurve); // drive forwards half speed Wait(0.02); } else { myRobot.Drive(0.0, 0.0); autoState = 4; } } // if (autoState == 1) { // if (autoGyroAngle > -90.0 && autoState == 1) { // printf("Try turning left, autoGyroAngle = %f\n", autoGyroAngle); // myRobot.Drive(-0.2, -1.0); // Wait(0.01); // } else { // autoState = 2; // myRobot.Drive(0.0, 0.0); // stop robot // printf("Robot stopped\n"); // } // } } else { printf("Autonomous mode is OFF\n"); Wait(3.0); } } myRobot.Drive(0.0, 0.0); } void TeleopInit() { printf("Team 812 - Tally Ho! You're in control.\n"); encRight->Reset(); encLeft->Reset(); rateGyro->Reset(); // elevatorPidController_0->Enable(); // elevatorPidController_0->SetSetpoint(1.0); // elevatorPidController_1->Enable(); // elevatorPidController_1->SetSetpoint(1.0); } void TeleopPeriodic() { float currAngle; float currLeftEnc; float currRightEnc; float currPot; double elevatorPower, swingArmPower; myRobot.ArcadeDrive(PwrLimit(Linearize( rightStick.GetY()),-0.8, 0.8), PwrLimit(Linearize(-rightStick.GetX()),-0.65, 0.65)); // drive with arcade style (use right stick) // if(leftStick.GetRawButton(4)){ // float setpoint = elevatorPidController_0->GetSetpoint(); // setpoint -= 0.1; // if(setpoint < 0.0){ // setpoint = 0.0; // } // elevatorPidController_0->SetSetpoint(setpoint); // elevatorPidController_1->SetSetpoint(setpoint); // } // if(leftStick.GetRawButton(5)){ // float setpoint = elevatorPidController_0->GetSetpoint(); // setpoint += 0.1; // if(setpoint > 4.0){ // setpoint = 4.0; // } // elevatorPidController_0->SetSetpoint(setpoint); // elevatorPidController_1->SetSetpoint(setpoint); // } if(leftStick.GetRawButton(3)){ //vertPot = new AnalogPotentiometer(elevatorVertPotInput printf("Analog input: %f, Potentiometer output: %f \n", elevatorVertPotInput->GetVoltage(), vertPot->Get()); } currAngle = rateGyro->GetAngle(); if (fabs(currAngle - prevAngle) > 0.10) { printf("gyro angle = %f, %f, %f\n", currAngle, prevAngle, fabs(currAngle - prevAngle)); prevAngle = currAngle; } /* This Code causes the robot to crash due to timeouts as elevatorPot is not instantiated * 2015-01-10 dano currPot = elevatorPot->Get(); if (fabs(currPot - prevPot) > 0.01) { printf("pot reading: %f\n", currPot); prevPot = currPot; } */ currLeftEnc = encLeft->GetDistance(); currRightEnc = encRight->GetDistance(); if (fabs(currLeftEnc - prevLeftEnc) + fabs(currRightEnc - prevRightEnc) > 0.01) { printf("Left Encoder = %f\n", currLeftEnc); printf("Right Encoder = %f\n", currRightEnc); prevLeftEnc = currLeftEnc; prevRightEnc = currRightEnc; } Scheduler::GetInstance()->Run(); for (int i = 1; i <= 7; i++) { b[i] = controlBox.GetRawButton(i); } if (b[1] == 0 && b[2] == 1 && wiperState != 1) { printf("Tail off\n"); wiperState = 1; // Pistons should be contracted. Wedge should be closed //Retract left piston. dsLeft->Set(DoubleSolenoid::kReverse); Wait(.2); dsLeft->Set(DoubleSolenoid::kOff); //Retract right piston dsRight->Set(DoubleSolenoid::kReverse); Wait(.2); dsRight->Set(DoubleSolenoid::kOff); } else if (b[1] == 0 && b[2] == 0 && wiperState != 2) { printf("Tail Rev\n"); wiperState = 2; //Left side wedge should be open. Left piston extended and right piston contracted //Extend left piston dsLeft->Set(DoubleSolenoid::kForward); Wait(.2); dsLeft->Set(DoubleSolenoid::kOff); //Retract right piston dsRight->Set(DoubleSolenoid::kReverse); Wait(.2); dsRight->Set(DoubleSolenoid::kOff); } else if (b[1] == 1 && b[2] == 1 && wiperState != 3) { printf("Tail Fwd\n"); wiperState = 3; //Right side wedge should be open. Right piston extended and left piston contracted. //Extend right piston dsRight->Set(DoubleSolenoid::kForward); Wait(.2); dsRight->Set(DoubleSolenoid::kOff); //Retract left piston dsLeft->Set(DoubleSolenoid::kReverse); Wait(.2); dsLeft->Set(DoubleSolenoid::kOff); } else if (b[1] && !b[2]) { printf("Uh oh Button problem!\n"); wiperState = 0; } if (rightStick.GetRawButton(10)) { encLeft->Reset(); encRight->Reset(); rateGyro->Reset(); } if (rightStick.GetRawButton(4)) { printf("Button 4 pressed - intake wheels forward\n"); leftIntakeWheel->Set(Relay::kForward); rightIntakeWheel->Set(Relay::kForward); } if (rightStick.GetRawButton(5)) { printf("Button 5 pressed - intake wheels reverse\n"); leftIntakeWheel->Set(Relay::kReverse); rightIntakeWheel->Set(Relay::kReverse); } if (rightStick.GetRawButton(6)) { printf("Button 6 pressed - intake wheels off\n"); leftIntakeWheel->Set(Relay::kOff); rightIntakeWheel->Set(Relay::kOff); } /* Manual elevator control * - The Linearize() function is a polynomial that scales the joystick output * along a predefined curve thus dampening the power at low increments */ elevatorPower = PwrLimit(Linearize(leftStick.GetY()),-0.2, 0.5); // Joystick Y position, low limit, high limit swingArmPower = PwrLimit(Linearize(leftStick.GetX()), -0.3, 0.3); // printf("Elevator power: %f, Swing arm power: %f\n", elevatorPower, swingArmPower); // printf("Elevator pot = %f\n", elevatorVertPotInput->GetVoltage()); elevatorMotorA->Set(elevatorPower); elevatorMotorB->Set(elevatorPower); swingArmMotor->Set(-swingArmPower); // if integration of the ElevatorController class is desired call the following // function to periodically check the elevator height/angle and update the motor // controls accordingly // elevatorController->run(); //Camera and Servo camXServo->Set( (controlBox.GetX() * 0.5) + 0.5); if(b[4]){ camYServo->Set(1.0); } else { camYServo->Set(0.0); } // This handles the grappling solenoids // button 3 is the momentary contact switch on the control box // This same logic could be used on a joystick button if you wish // The default should be with the grappling arms open and the code // implements the default state as button 3 not pressed AND grappling = false if(b[3] and ! grappling) { dsGrappler->Set(DoubleSolenoid::kForward); grappling = true; Wait(.2); dsGrappler->Set(DoubleSolenoid::kOff); } else if (! b[3] and grappling) { dsGrappler->Set(DoubleSolenoid::kReverse); // Default initial state grappling = false; Wait(.2); dsGrappler->Set(DoubleSolenoid::kOff); } } void TestPeriodic() { lw->Run(); } }; START_ROBOT_CLASS(Robot);
e587b124e92b91ef779f049c140aff60c7aed2a4
1d00c762556a1e86144f61a4f6a6bddd4d3270bd
/HW5/HW5-2.cpp
bee1fa8e7fb1806c6cfc2cba639ee65d6508f53c
[]
no_license
wei8596/C_Programming_2
2cb80942c848ea9d3c19c89907cee3ce264c892e
5577f222115346a03813f1546f057948e11bd4be
refs/heads/master
2020-03-29T11:58:28.501387
2018-11-03T16:13:42
2018-11-03T16:13:42
149,879,538
0
0
null
null
null
null
UTF-8
C++
false
false
4,677
cpp
HW5-2.cpp
#include <iostream> #include <cmath> using namespace std; class Polynomial { public: Polynomial(); // default constructor Polynomial(const Polynomial& object); // copy constructor const Polynomial& operator=(const Polynomial & rhs); // operator= ~Polynomial(); // destructor Polynomial(double coefficient[], int size); // parameterized constructor friend Polynomial operator+(const Polynomial& lsh, const Polynomial& rhs); // operator+ friend Polynomial operator-(const Polynomial& lsh, const Polynomial& rhs); // operator- friend Polynomial operator*(const Polynomial& lsh, const Polynomial& rhs); // operator* const double& operator[](int degree)const; // assign and inspect function friend double evaluate(const Polynomial& ploy, double x); //evaluate int getSize() const; // returns size double max(double lhs, double rhs); // find max private: double *coef; int size; }; int main() { double quad[] = {3, 2, 1}; double cubic[] = {1, 2, 0, 3}; Polynomial q(quad, 3); // 3 + 2*x + x*x Polynomial c(cubic, 4); // 1 + 2*x + 0*x*x + 3*x*x*x Polynomial p(q); // test copy constructor Polynomial r; r = c; //test operator= cout << "Polynomial q " << endl; for(int i = 0; i < q.getSize(); i++) cout << "term with degree " << i << " has coefficient " << q[i] << endl; cout << "Polynomial c " << endl; for(int i = 0; i < c.getSize(); i++) cout << "term with degree " << i << " has coefficient " << c[i] << endl; cout << "value of q(2) is " << evaluate(q, 2) << endl; // x = 2 cout << "value of p(2) is " << evaluate(p, 2) << endl; cout << "value of r(2) is " << evaluate(r, 2) << endl; cout << "value of c(2) is " << evaluate(c, 2) << endl; r = q + c; cout << "value of (q + c)(2) is " << evaluate(r, 2) << endl; r = q - c; cout << "value of (q - c)(2) is " << evaluate(r, 2) << endl; r = q * c; cout << "size of q*c is " << r.getSize() << endl; cout << "Polynomial r (= q*c) " << endl; for(int i = 0; i < r.getSize(); i++) cout << "term with degree " << i << " has coefficient " << r[i] << endl; cout << "value of (q * c)(2) is " << evaluate(r, 2) << endl; return 0; } // creates an empty polynomial Polynomial::Polynomial():coef(0), size(0) {// deliberately empty } Polynomial::Polynomial(const Polynomial& object) : size(object.size) { coef = new double[size]; for(int i = 0; i < size; i++) coef[i] = object.coef[i]; } const Polynomial& Polynomial::operator=(const Polynomial & rhs) // rhs:right-hand-side { if(rhs.coef == coef) return rhs; else { delete [] coef; size = rhs.size; coef = new double[size]; for(int i = 0; i < size; i++) coef[i] = rhs.coef[i]; } return *this; } Polynomial::~Polynomial() { delete [] coef; } Polynomial::Polynomial(double coefficient[], int newSize) : size(newSize) { coef = new double[size]; for(int i = 0; i < size; i++) coef[i] = coefficient[i]; } Polynomial operator+(const Polynomial& lhs, const Polynomial& rhs) // lhs:left-hand-side { const int sumSize = max(lhs.size, rhs.size); double* sumCoef = new double[sumSize]; for(int i = 0; i < sumSize; i++) sumCoef[i] = 0; for(int i = 0; i < sumSize; i++) { if(i < lhs.size) sumCoef[i] += lhs.coef[i]; if(i < rhs.size) sumCoef[i] += rhs.coef[i]; } return Polynomial(sumCoef, sumSize); } Polynomial operator-(const Polynomial& lhs, const Polynomial& rhs) { const int sumSize = max(lhs.size, rhs.size); double* sumCoef = new double[sumSize]; for(int i = 0; i < sumSize; i++) sumCoef[i] = 0; for(int i = 0; i < sumSize; i++) { if(i < lhs.size) sumCoef[i] += lhs.coef[i]; if(i < rhs.size) sumCoef[i] -= rhs.coef[i]; } return Polynomial(sumCoef, sumSize); } Polynomial operator*(const Polynomial& lhs, const Polynomial& rhs) { const int prodSize = lhs.size + rhs.size - 1; double* prodCoef = new double[prodSize]; for(int i = 0; i < prodSize; i++) prodCoef[i] = 0; for(int i = 0; i < lhs.size; i++) { for(int j = 0; j < rhs.size; j++) prodCoef[i + j] += lhs[i] * rhs[j]; } return Polynomial(prodCoef, prodSize); } const double& Polynomial::operator[](int degree) const { return coef[degree]; } double evaluate(const Polynomial& poly, double x) { double value = 0; for(int i = 0; i < poly.getSize(); i++) value += poly[i]*pow(x, i); return value; } int Polynomial::getSize() const { return size; } double max(double lhs, double rhs) { return (lhs > rhs) ? lhs : rhs; }
dab61aa69db52e7ec4e9ae0bdd042f17cea7b862
dadf1befe13c33f601db63b9dbb3f67d2d932ed5
/Tetris/Block.cpp
ac1ad42aac99fe0d865b35c30ee80c3292216175
[]
no_license
ZhengLiChina/Tetris
821f9e6532a03fdcaea51ed4917e8a8eaa3b536c
18f2e14b2ff139ad0acbd3843f0eeb49cb53019f
refs/heads/master
2016-09-05T09:57:13.778337
2013-10-24T11:55:32
2013-10-24T11:55:32
null
0
0
null
null
null
null
ISO-8859-7
C++
false
false
2,278
cpp
Block.cpp
#include"Block.h" #include<algorithm> Block::Block(Chessboard* cb):chessboard(cb) { //Init(1); shapeKinds=7; } Block::Block(int shape) { //Init(1); SetBlock(shape); chessboard=NULL; shapeKinds=7; } Block::~Block() { } Block::iterator Block::begin() { return block.begin(); } Block::iterator Block::end() { return block.end(); } bool Block::Init(int shape) { position=CP(3,0); SetBlock(shape); bool result=true; for(auto i=block.begin();i!=block.end();i++) { result&=NoCollide(position+*i); if (!result) { return false; } } //for(auto i=block.begin();i!=block.end();i++) //{ // chessboard.SetChessPoint(*i+position,color); //} return true; } bool Block::Move(ChessPoint dir) { bool result=true; for(auto i=block.begin();i!=block.end();i++) { //ascertain the shape's edge of the moving direction //if (std::find(block.begin(),block.end(), (*i+dir))==block.end()) //{ result&=NoCollide(position+*i+dir); //} } if (result) { //for(auto i=block.begin();i!=block.end();i++) //{ // chessboard.SetChessPoint(*i+position,0); //} position=position+dir; //for(auto i=block.begin();i!=block.end();i++) //{ // chessboard.SetChessPoint(position+*i,color); //} } return result; } bool Block::Rotate() { auto temp(block); bool result=true; for(auto i=temp.begin();i!=temp.end();i++) { int tempx=i->x; int tempy=i->y; i->x=tempy; i->y=-tempx+offside; result&=NoCollide(CP(i->x+position.x,i->y+position.y)); } if (result) { block=temp; } return true; } bool Block::NoCollide(CP cp) { return (!chessboard->GetIdOfPoint(cp)); } bool Block::SetBlock(int shape) { block.clear(); ChessPoint cp[]= { CP(0,0),CP(0,1),CP(1,0),CP(1,1) }; int len=4; //color=shape+1; color=1; switch (shape) { case 0://Μο offside=1; break; case 1://T cp[2]=CP(0,2); offside=2; break; case 2:// ---- cp[2]=CP(0,2); cp[3]=CP(0,3); offside=3; break; case 3://L cp[3]=CP(0,2); offside=2; break; case 4://oppsite L cp[2]=CP(0,2); cp[3]=CP(1,2); offside=2; break; case 5://Z cp[2]=CP(1,2); offside=2; break; case 6://oppsite Z cp[0]=CP(0,2); offside=2; break; default: break; } for (int i = 0; i < len; i++) { block.push_back(cp[i]); } return true; }
2a0085b3aea5d9cf6b3adab6173275ed6fbaae13
a12b6eba2cf6e7199f8b98713696d7ac83d5f1ec
/main.cpp
4a6eb5fc2f97f9ace0e60bdf2812369fa615d063
[]
no_license
mezamarco/SortingAlgorithms
622843fac6431b84f86bf09a9dc5c268285bcf6d
3a68b4672c282150834cfffa6a3f6e15aebf19ab
refs/heads/master
2020-03-09T03:02:50.235538
2018-04-16T20:36:09
2018-04-16T20:36:09
128,555,728
0
0
null
null
null
null
UTF-8
C++
false
false
8,019
cpp
main.cpp
// sortingAlgorithm.cpp : Defines the entry point for the console application. #include <iostream> #include <ctime> #include <vector> #include <queue> #include <set> #include <iterator> //Function prototypes //Function that will print the contents of our vector void display(std::vector<int> & myVect); //These are my sorting algorithms. NOTE:(pass-by-reference) //Lets run the function and determine the running time for each sorting alogrithm. void minSort(std::vector<int> & myVect, int size); void bubbleSort(std::vector<int> & vect, int size); void insertionSort(std::vector<int> & A, int size); void Rmerge(std::queue<int> & A, std::queue<int> & B,std::queue<int> & C); int main() { std::cout << "\n\nThis program will go over the different types of Sorting Algorithms.\n"<< std::endl; std::cout << "\n\nLets get an vector with random values:\n"; std::cout << "Pick the size of the array(1-20)? "; int size; std::cin >> size; while (size < 1 || size > 20) { std::cout << "\n\nTry again: Pick the size of the vector(1-20)? "; std::cin >> size; } //We got the size that the user wants. std::cout << "\n\n\nLets do minSort on this vector with random values.\n"; std::cout << "\nThis vector will be sorted using the minSort algorithm:\n\n"; //Create our vector and populate it with random numbers. (Running time is O(n) ) std::vector<int> myVect; srand(time(NULL)); for (int m = 0; m < size; m++) { myVect.push_back( (rand() % 500) + 1 ); //Produce an element between 1-500. } //We now have the vector that we wanted so diplay the element and state that this step is k = 0 std::cout << "At k = 0\n"; display(myVect); //Run the minSort function. //What is the running time for minSort? = minSort(myVect,size); //We are done with minSort //Now lets create a new vector and do bubbleSort on this new vector. std::vector<int> vect; for (int m = 0; m < size; m++) { vect.push_back((rand() % 500) + 1); //Produce an element between 1-500. } std::cout << "\n\n\n\n\nThis vector will be sorted using the bubbleSort algorithm\n\n"; //We now have the vector that we wanted so diplay the element and state that this step is k = 0 std::cout << "\nAt k = 0\n"; display(vect); bubbleSort(vect, size); //Now lets create a new vector and do insertionSort on this new vector. std::vector<int> A; for (int m = 0; m < size; m++) { A.push_back((rand() % 500) + 1); //Produce an element between 1-500. } std::cout << "\n\n\n\n\nThis vector will be sorted using the insertionSort algorithm\n\n"; //We now have the vector that we wanted so diplay the element and state that this step is k = 0 std::cout << "\nAt k = 0\n"; display(A); insertionSort(A, size); //Nows lets write code for my Recursive merge algorithm //Create 3 vectors of the same lenght std::queue<int> queueA; std::queue<int> queueB; std::set<int> setA; std::set<int> setB; for (int r = 0; r < 6; r++) { setA.insert((rand() % 5000) + 1); setB.insert((rand() % 5000) + 1); } std::set<int>::iterator it = setA.begin(); std::set<int>::iterator itEnd = setA.end(); std::cout << "\n\n\nFor the recursive merge, \nA = "; while (it != itEnd) { if (it != std::prev(itEnd)) { std::cout << *it << ","; } else { std::cout << *it; } queueA.push(*it); ++it; } std::cout << "\nB = "; std::set<int>::iterator itB = setB.begin(); std::set<int>::iterator itBEnd = setB.end(); while (itB != itBEnd) { if (itB != std::prev(itBEnd)) { std::cout << *itB << ","; } else { std::cout << *itB << "\n\n"; } queueB.push(*itB); ++itB; } std::queue<int> queueC; //Now lets recursive merge A and B in order to get C as a sorted vector //C will be printed Rmerge(queueA, queueB, queueC); std::cout << "The resulting array of the Recursive Merge of A and B is:\nC = "; int temporary; //C should now be sorted, so lets display the values while (!queueC.empty()) { temporary = queueC.front(); queueC.pop(); std::cout << temporary << " "; } std::cout << "\n\n"; return 0; } //Function to display the vector. //The runnning time for the display function is: O(n) void display(std::vector<int> & myVect) { for (int n = 0; n < myVect.size(); n++) { if (n != myVect.size() - 1) { std::cout << myVect[n] << ","; } else { std::cout << myVect[n] << "\n\n"; } } } //The loop invariant of the minSort: //After the kth pass thorugh the outer for loop //the first k positions A[1] to A[k] //contain the first k smallest elements in order //The running time for the the selection sort algorithm is: O(n^2) void minSort(std::vector<int> & myVect, int size) { //For all the positions except the last postion for (int k = 0; k < size-1; k++) { //Set the min to be equal to the element in that position k //Set the index to be the kth position int min = myVect[k]; int index = k; //Traverse through all the elements in the vector or array except the values that already have been previously setup //Use j to keep track of this loop for (int j = k + 1; j < size ; j++) { //If we find a smaller element in the array than the min. //Set the smaller element to be the min and then save the index value j. if (myVect[j] < min) { min = myVect[j]; index = j; } } std::cout << "At k = " << k + 1 << "\n"; //We now have the min to swap with the position k. //First place the position kth element into the min position index //Then place the min value into the kth position. myVect[index] = myVect[k]; myVect[k] = min; display(myVect); } } // THe loop invariant of the BubbleSort //After the kth run through the outer for loop //The last i elements are the largest elements in the array and in sorted order. //Function that uses the bubbleSort algorithm //The running time for bubble sort is: O(n^2) void bubbleSort(std::vector<int> & vect, int size) { int temp; //For all the elements in the array, except the last two elements for (int i = 0; i < size - 2; i++) { //For all the elements, except the last element. for (int j = 0; j < size - i -1 ; j++) { //If we find that the visisted element is greater than the next element //Then we must swap these two elements. if (vect[j] > vect[j + 1]) { temp = vect[j + 1]; vect[j + 1] = vect[j]; vect[j] = temp; } } //This comparison goes on for the all the elements, so in the end the last kth elements must be sorted std::cout << "At k = " << i + 1 << "\n"; display(vect); } } //The loop invariant of the insertion sort //After the ith iteration through the outer forloop //the first i+1 elements are sorted. //Function that uses the insertionSort algorithm void insertionSort(std::vector<int> & A, int size) { for (int i = 1; i < size; i++) { int element = A[i]; int j = i; while (j > 0 && A[j - 1] > element) { A[j] = A[j - 1]; j = j - 1; } A[j] = element; std::cout << "At k = " << i << "\n"; display(A); } } //Recursive merge function void Rmerge(std::queue<int> & A, std::queue<int> & B, std::queue<int> & C) { //If array A is empty, place the remaining elementsof B into the C array and we are done if (A.empty()) { int tempB; //Place the rest of the B elements into the C vector while (!B.empty()) { tempB = B.front(); C.push(tempB); B.pop(); } return; } //If array B is empty, place the remaining elements of A into the C array and we are done if (B.empty()) { int tempA; //Place the rest of the A elements into the C vector while (!A.empty()) { tempA = A.front(); C.push(tempA); A.pop(); } return ; } //This is where we compare the values of A[0] and B[0] //The smaller element will be placed in the C array if ((A.front()) <= (B.front())) { C.push(A.front()); A.pop(); Rmerge(A, B, C); } else { C.push(B.front()); B.pop(); Rmerge(A, B, C); } }
90ad2eba1710eccb50a3876d88852f132568f1b6
76e49a7bed55e4fdd31d753cce7f79a29881c0e8
/src/ui/imgui/GUIElement.cpp
d40f1a083b5725665bfbf1eef13a34fec3b7b0c1
[]
no_license
defcanuck/cse_public
ff66f4544e89b9b78baca9948ce469824fcc80df
23f4d3376f131ddd1765ad1da8fc59a32ad29366
refs/heads/main
2023-05-11T10:15:33.317658
2021-06-02T22:40:00
2021-06-02T22:40:00
373,317,769
0
0
null
null
null
null
UTF-8
C++
false
false
1,770
cpp
GUIElement.cpp
#include "PCH.h" #include "ui/imgui/GUIElement.h" #include "ui/imgui/GUIContext.h" #include "imgui.h" namespace cs { bool GUIElement::prepareGUI(bool inWindow, size_t depth) { if (!GUIContext::isContextValid()) return false; if (!this->enabled) return false; RectF thisRect = this->getScreenRect(); bool isWindow = false; if (!inWindow) { std::string useName = this->name; if (this->tag.length() > 0) useName = this->tag; this->collapsed = ImGui::Begin(useName.c_str(), &this->shouldClose, ImGuiWindowFlags_NoResize); isWindow = true; ImGui::SetWindowSize(ImVec2(thisRect.size.w, thisRect.size.h)); ImGui::SetWindowPos(ImVec2(thisRect.pos.x, thisRect.pos.y)); } bool ret = this->batchFields(thisRect); ret |= BASECLASS::prepareGUI(true, depth); if (isWindow) ImGui::End(); return ret; } void GUIElement::clearFields() { this->fields.clear(); } bool GUIElement::batchFields(const RectF& rect) { if (!this->enabled || !this->visible) return false; return this->fields.batch(rect); } void GUIElement::doCloseImpl() { if (this->onCloseCallback) this->onCloseCallback->invoke(); } bool GUIElement::onCursor(ClickInput input, ClickParams& params, UIClickResults& results, uint32 depth) { if (!this->enabled) return false; for (auto it : this->children) (*it).onCursor(input, params, results, depth + 1); // ImGUI elements always consume input vec2 adjusted_position = params.position; if (this->span.getRawY().alignment == VAlignBottom) { adjusted_position.y = params.screen_dimm.y - params.position.y; } RectF rect = this->getScreenRect(); if (rectContains<float32, vec2>(rect, adjusted_position)) { return true; } return false; } }
97c4a1dcf18bbf8f9eba033235571b7b603f78a4
635553aec5febc8ac53f5cb792ca0487c542edc3
/CPPBasics/6 Arrays.cpp
d275c9fb124d326c6ce62a273e5b199389311561
[]
no_license
joeslee94/UnrealCDoublePlus
9cf273af21873b37ce228a9e0d530a56a366e7d1
f7f7b963381553078db9ae592741fe5f909227ca
refs/heads/main
2023-04-04T06:27:52.602044
2021-04-19T16:03:13
2021-04-19T16:03:13
353,158,317
1
0
null
null
null
null
UTF-8
C++
false
false
376
cpp
6 Arrays.cpp
// 6 Arrays.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> #include <cmath> using namespace std; int main() { //Arrays int number[] = { 1, 2, 3, 4, 5, 6, 7 }; cout << number[0] << " " << number[1] << " " << number[2] << endl; //the basics of an array are equal to that of C# }
6d98e5259f0678a2345be990a2b3344e50e15116
ab1a5e0268aca022dc8f3f3824cae7e506710897
/aQR.cpp
ba042748c538c6fc0328e86031fcbc91be7b59d3
[]
no_license
clip71/aQR
e39202d02497d52d0db2f1aa5a39d09f0144fe27
9bbead0c67749e503aa80cff70354e2a5ccb7199
refs/heads/master
2021-05-16T02:58:29.264780
2020-06-25T05:49:07
2020-06-25T05:49:07
19,936,801
4
2
null
null
null
null
UTF-8
C++
false
false
35,153
cpp
aQR.cpp
/* * aQR - QR Code encoder class C++ * * version 0.3.2 - 19.05.2014 * * Copyright (C) 2014 Tyumenska region, Surgut * Konstantin Slabouzov <clip71@inbox.ru> * * temporary restrictions: * support QR_ENC_BYTE only */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aQR.h" const aQR::QR_MAXIMUMS aQR::m_info[QR_MAX_VERSIONS+1] = { 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 21, 26, { 7, 10, 13, 17 }, { 1, 1, 1, 1 }, // 1 25, 44, { 10, 16, 22, 28 }, { 1, 1, 1, 1 }, // 2 29, 70, { 15, 26, 18, 22 }, { 1, 1, 2, 2 }, // 3 33, 100, { 20, 18, 26, 16 }, { 1, 2, 2, 4 }, // 4 37, 134, { 26, 24, 18, 22 }, { 1, 2, 4, 4 }, // 5 41, 172, { 18, 16, 24, 28 }, { 2, 4, 4, 4 }, // 6 45, 196, { 20, 18, 18, 26 }, { 2, 4, 6, 5 }, // 7 49, 242, { 24, 22, 22, 26 }, { 2, 4, 6, 6 }, // 8 53, 292, { 30, 22, 20, 24 }, { 2, 5, 8, 8 }, // 9 57, 346, { 18, 26, 24, 28 }, { 4, 5, 8, 8 }, // 10 61, 404, { 20, 30, 28, 24 }, { 4, 5, 8, 11 }, // 11 65, 466, { 24, 22, 26, 28 }, { 4, 8, 10, 11 }, // 12 69, 532, { 26, 22, 24, 22 }, { 4, 9, 12, 16 }, // 13 73, 581, { 30, 24, 20, 24 }, { 4, 9, 16, 16 }, // 14 77, 655, { 22, 24, 30, 24 }, { 6, 10, 12, 18 }, // 15 81, 733, { 24, 28, 24, 30 }, { 6, 10, 17, 16 }, // 16 85, 815, { 28, 28, 28, 28 }, { 6, 11, 16, 19 }, // 17 89, 901, { 30, 26, 28, 28 }, { 6, 13, 18, 21 }, // 18 93, 991, { 28, 26, 26, 26 }, { 7, 14, 21, 25 }, // 19 97, 1085, { 28, 26, 30, 28 }, { 8, 16, 20, 25 }, // 20 101, 1156, { 28, 26, 28, 30 }, { 8, 17, 23, 25 }, // 21 105, 1258, { 28, 28, 30, 24 }, { 9, 17, 23, 34 }, // 22 109, 1364, { 30, 28, 30, 30 }, { 9, 18, 25, 30 }, // 23 113, 1474, { 30, 28, 30, 30 }, { 10, 20, 27, 32 }, // 24 117, 1588, { 26, 28, 30, 30 }, { 12, 21, 29, 35 }, // 25 121, 1706, { 28, 28, 28, 30 }, { 12, 23, 34, 37 }, // 26 125, 1828, { 30, 28, 30, 30 }, { 12, 25, 34, 40 }, // 27 129, 1921, { 30, 28, 30, 30 }, { 13, 26, 35, 42 }, // 28 133, 2051, { 30, 28, 30, 30 }, { 14, 28, 38, 45 }, // 29 137, 2185, { 30, 28, 30, 30 }, { 15, 29, 40, 48 }, // 30 141, 2323, { 30, 28, 30, 30 }, { 16, 31, 43, 51 }, // 31 145, 2465, { 30, 28, 30, 30 }, { 17, 33, 45, 54 }, // 32 149, 2611, { 30, 28, 30, 30 }, { 18, 35, 48, 57 }, // 33 153, 2761, { 30, 28, 30, 30 }, { 19, 37, 51, 60 }, // 34 157, 2876, { 30, 28, 30, 30 }, { 19, 38, 53, 63 }, // 35 161, 3034, { 30, 28, 30, 30 }, { 20, 40, 56, 66 }, // 36 165, 3196, { 30, 28, 30, 30 }, { 21, 43, 59, 70 }, // 37 169, 3362, { 30, 28, 30, 30 }, { 22, 45, 62, 74 }, // 38 173, 3532, { 30, 28, 30, 30 }, { 24, 47, 65, 77 }, // 39 177, 3706, { 30, 28, 30, 30 }, { 25, 49, 68, 81 }, // 40 }; aQR::aQR(void) { memset(m_pixels, 0, sizeof m_pixels); memset(m_szData, 0, sizeof m_szData); m_nEncoding = QR_ENC_BYTE; // пока только QR_ENC_BYTE m_nVersion = 0; m_nMask = -1; m_nEcl = QR_LEVEL_M; m_nDataSize = 0; m_nPixels = 0; m_nPixelSize = 10; m_nQuiteZone = 30; m_bModeOrder = false; m_bShowData = m_bShowEc = m_bShowMask = true; } aQR::~aQR(void) { } int aQR::init(const BYTE* pszString, int nLength, int nEcl, int nMask) { memset(m_pixels, 0, sizeof m_pixels); memset(m_szData, 0, sizeof m_szData); m_nEcl = (short)nEcl; m_nMask = (short)nMask; m_nPixels = 0; // int nRC = calcVersion(nLength); if (nRC <= 0 || nRC > QR_MAX_VERSIONS) return -1; fillServiceInfo(); fillVersionCode(); // m_nDataSize = getData(m_szData, sizeof m_szData, pszString, nLength); // дополняем байтами 236 и 17 не заполненные поля int nBitsOffset = m_nDataSize * 8; for (int i=m_nDataSize,nOdd=0; i<getDataSize(); i++,nOdd++) { pushData(m_szData, sizeof m_szData, nBitsOffset, nOdd & 1 ? 17 : 236, 8); // 00010001 | 11101100 m_nDataSize++; } // заполнение матрицы QR_NEXT_XY nxy; short nBlocks = getNumBlocks(); int nOffset; memset(&nxy, 0, sizeof nxy); for (int i=0; i<m_nDataSize; i++) { nOffset = getBlockIndex(i, m_nDataSize); pushByte(nxy, m_bShowData ? m_szData[nOffset] : 0); } BYTE ec[81 * 30]; short nEcBlockSize = m_info[m_nVersion].ec[m_nEcl]; for (short b=0; b<nBlocks; b++) { int nDataBlockSize = getBlockSize(b, m_nDataSize); int nDataBlockStart = getBlockOffset(b, m_nDataSize); short nEcBlockStart = b * nEcBlockSize; getEc(&ec[nEcBlockStart], nEcBlockSize, &m_szData[nDataBlockStart], nDataBlockSize); } for (int i=0; i<nEcBlockSize*nBlocks; i++) { nOffset = getBlockIndex(i, nEcBlockSize*nBlocks); pushByte(nxy, m_bShowEc ? ec[nOffset] : 0); } // маска if (m_bShowMask) { // если маска не задана, то поищем автоматически if (m_nMask < 0) { calcBestMask(); } fillMask(); } return 0; } int aQR::calcVersion(int nDataSize) { for (m_nVersion=1; m_nVersion<=QR_MAX_VERSIONS; m_nVersion++) { WORD wSize = m_info[m_nVersion].wModules - m_info[m_nVersion].ec[m_nEcl] * getNumBlocks(); if (wSize == 0) break; // проверим на вместимость: данных + размера поля данных + (0.5 + 0.5) тип данных и конец if (wSize >= nDataSize + getDataLengthBits() + 1) return m_nVersion; } //ASSERT(0); // таблица не заполнена или переполнение return -1; } void aQR::fillServiceInfo() { // поисковые узоры fillFinderPattern(0, 0); fillFinderPattern(0, getSizeXY() - 7); fillFinderPattern(getSizeXY() - 7, 0); for (int x=0; x<=7; x++) { setPixel(x, 7, QR_VALUE_FP0); setPixel(7, x, QR_VALUE_FP0); setPixel(getSizeXY() - 8 + x, 7, QR_VALUE_FP0); setPixel(getSizeXY() - 8, x, QR_VALUE_FP0); setPixel(x, getSizeXY() - 8, QR_VALUE_FP0); setPixel(7, getSizeXY() - 8 + x, QR_VALUE_FP0); } // fillAligmentPatterns(); // пиксель всегда черен setPixel(8, getSizeXY() - 8, QR_VALUE_FP1); // Полосы синхронизации // всегда после fillAligmentPatterns(), т.к. пересекаются с выравнивающими узорами for (int x=8; x<getSizeXY()-8; x++) { setPixel(x, 6, x & 1 ? QR_VALUE_FP0 : QR_VALUE_FP1); setPixel(6, x, x & 1 ? QR_VALUE_FP0 : QR_VALUE_FP1); } // служебная информация fillFormatInfo(); } // Код версии void aQR::fillVersionCode() { if (m_nVersion < 7) return; const char* pszCode = NULL; switch (m_nVersion) { case 7: pszCode = "000010011110100110"; break; case 8: pszCode = "010001011100111000"; break; case 9: pszCode = "110111011000000100"; break; case 10: pszCode = "101001111110000000"; break; case 11: pszCode = "001111111010111100"; break; case 12: pszCode = "001101100100011010"; break; case 13: pszCode = "101011100000100110"; break; case 14: pszCode = "110101000110100010"; break; case 15: pszCode = "010011000010011110"; break; case 16: pszCode = "011100010001011100"; break; case 17: pszCode = "111010010101100000"; break; case 18: pszCode = "100100110011100100"; break; case 19: pszCode = "000010110111011000"; break; case 20: pszCode = "000000101001111110"; break; case 21: pszCode = "100110101101000010"; break; case 22: pszCode = "111000001011000110"; break; case 23: pszCode = "011110001111111010"; break; case 24: pszCode = "001101001101100100"; break; case 25: pszCode = "101011001001011000"; break; case 26: pszCode = "110101101111011100"; break; case 27: pszCode = "010011101011100000"; break; case 28: pszCode = "010001110101000110"; break; case 29: pszCode = "110111110001111010"; break; case 30: pszCode = "101001010111111110"; break; case 31: pszCode = "001111010011000010"; break; case 32: pszCode = "101000011000101101"; break; case 33: pszCode = "001110011100010001"; break; case 34: pszCode = "010000111010010101"; break; case 35: pszCode = "110110111110101001"; break; case 36: pszCode = "110100100000001111"; break; case 37: pszCode = "010010100100110011"; break; case 38: pszCode = "001100000010110111"; break; case 39: pszCode = "101010000110001011"; break; case 40: pszCode = "111001000100010101"; break; default: return; } DWORD dwCode = strtol(pszCode, 0, 2); DWORD dwMask = 0x20000; int nX = 0, nY = getSizeXY() - 11; for (int i=0; i<18; i++) { setPixel(nX, nY, dwMask & dwCode ? QR_VALUE_FP1 : QR_VALUE_FP0); setPixel(nY, nX, dwMask & dwCode ? QR_VALUE_FP1 : QR_VALUE_FP0); if (++nX >= 6) { nX = 0; nY++; } dwMask >>= 1; } } void aQR::fillFinderPattern(int nX, int nY) { for (int x=0; x<7; x++) { for (int y=0; y<7; y++) { setPixel(nX + x, nY + y, QR_VALUE_FP1); } } for (int x=1; x<6; x++) { setPixel(nX + x, nY + 1, QR_VALUE_FP0); setPixel(nX + x, nY + 5, QR_VALUE_FP0); } setPixel(nX + 1, nY + 2, QR_VALUE_FP0); setPixel(nX + 1, nY + 3, QR_VALUE_FP0); setPixel(nX + 1, nY + 4, QR_VALUE_FP0); setPixel(nX + 5, nY + 2, QR_VALUE_FP0); setPixel(nX + 5, nY + 3, QR_VALUE_FP0); setPixel(nX + 5, nY + 4, QR_VALUE_FP0); } void aQR::fillAligmentPattern(int nX, int nY) { // проверка на попадание на служебную область (поисковые узоры) bool bFree = true; for (int x=0; x<5 && bFree; x++) { for (int y=0; y<5 && bFree; y++) { if (isPixelService(nX + x - 2, nY + y - 2)) bFree = false; } } if (!bFree) return; // нарисуем выравнивающий узор на пустом месте for (int x=0; x<5; x++) { for (int y=0; y<5; y++) { setPixel(nX + x - 2, nY + y - 2, QR_VALUE_FP1); } } for (int x=0; x<3; x++) { for (int y=0; y<3; y++) { setPixel(nX + x - 1, nY + y - 1, QR_VALUE_FP0); } } setPixel(nX, nY, QR_VALUE_FP1); } void aQR::fillAligmentPatterns() { const static WORD ap2[] = { 18 }; const static WORD ap3[] = { 22 }; const static WORD ap4[] = { 26 }; const static WORD ap5[] = { 30 }; const static WORD ap6[] = { 34 }; const static WORD ap7[] = { 6, 22, 38 }; const static WORD ap8[] = { 6, 24, 42 }; const static WORD ap9[] = { 6, 26, 46 }; const static WORD ap10[] = { 6, 28, 50 }; const static WORD ap11[] = { 6, 30, 54 }; const static WORD ap12[] = { 6, 32, 58 }; const static WORD ap13[] = { 6, 34, 62 }; const static WORD ap14[] = { 6, 26, 46, 66 }; const static WORD ap15[] = { 6, 26, 48, 70 }; const static WORD ap16[] = { 6, 26, 50, 74 }; const static WORD ap17[] = { 6, 30, 54, 78 }; const static WORD ap18[] = { 6, 30, 56, 82 }; const static WORD ap19[] = { 6, 30, 58, 86 }; const static WORD ap20[] = { 6, 34, 62, 90 }; const static WORD ap21[] = { 6, 28, 50, 72, 94 }; const static WORD ap22[] = { 6, 26, 50, 74, 98 }; const static WORD ap23[] = { 6, 30, 54, 78, 102 }; const static WORD ap24[] = { 6, 28, 54, 80, 106 }; const static WORD ap25[] = { 6, 32, 58, 84, 110 }; const static WORD ap26[] = { 6, 30, 58, 86, 114 }; const static WORD ap27[] = { 6, 34, 62, 90, 118 }; const static WORD ap28[] = { 6, 26, 50, 74, 98, 122 }; const static WORD ap29[] = { 6, 30, 54, 78, 102, 126 }; const static WORD ap30[] = { 6, 26, 52, 78, 104, 130 }; const static WORD ap31[] = { 6, 30, 56, 82, 108, 134 }; const static WORD ap32[] = { 6, 34, 60, 86, 112, 138 }; const static WORD ap33[] = { 6, 30, 58, 86, 114, 142 }; const static WORD ap34[] = { 6, 34, 62, 90, 118, 146 }; const static WORD ap35[] = { 6, 30, 54, 78, 102, 126, 150 }; const static WORD ap36[] = { 6, 24, 50, 76, 102, 128, 154 }; const static WORD ap37[] = { 6, 28, 54, 80, 106, 132, 158 }; const static WORD ap38[] = { 6, 32, 58, 84, 110, 136, 162 }; const static WORD ap39[] = { 6, 26, 54, 82, 110, 138, 166 }; const static WORD ap40[] = { 6, 30, 58, 86, 114, 142, 170 }; WORD xy[8]; memset(&xy, 0, sizeof xy); #define initxy(a) memcpy(xy, a, sizeof a) switch (m_nVersion) { case 1: return; case 2: initxy(ap2); break; case 3: initxy(ap3); break; case 4: initxy(ap4); break; case 5: initxy(ap5); break; case 6: initxy(ap6); break; case 7: initxy(ap7); break; case 8: initxy(ap8); break; case 9: initxy(ap9); break; case 10: initxy(ap10); break; case 11: initxy(ap11); break; case 12: initxy(ap12); break; case 13: initxy(ap13); break; case 14: initxy(ap14); break; case 15: initxy(ap15); break; case 16: initxy(ap16); break; case 17: initxy(ap17); break; case 18: initxy(ap18); break; case 19: initxy(ap19); break; case 20: initxy(ap20); break; case 21: initxy(ap21); break; case 22: initxy(ap22); break; case 23: initxy(ap23); break; case 24: initxy(ap24); break; case 25: initxy(ap25); break; case 26: initxy(ap26); break; case 27: initxy(ap27); break; case 28: initxy(ap28); break; case 29: initxy(ap29); break; case 30: initxy(ap30); break; case 31: initxy(ap31); break; case 32: initxy(ap32); break; case 33: initxy(ap33); break; case 34: initxy(ap34); break; case 35: initxy(ap35); break; case 36: initxy(ap36); break; case 37: initxy(ap37); break; case 38: initxy(ap38); break; case 39: initxy(ap39); break; case 40: initxy(ap40); break; default: //ASSERT(0); return; } for (int i=0; xy[i]; i++) for (int j=0; xy[j]; j++) fillAligmentPattern(xy[i], xy[j]); } WORD aQR::getMaskEcl(int nEcl, int nMask) { const char* pszCode = NULL; switch (nEcl) { case QR_LEVEL_L: switch (nMask) { case 0: pszCode = "111011111000100"; break; case 1: pszCode = "111001011110011"; break; case 2: pszCode = "111110110101010"; break; case 3: pszCode = "111100010011101"; break; case 4: pszCode = "110011000101111"; break; case 5: pszCode = "110001100011000"; break; case 6: pszCode = "110110001000001"; break; case 7: pszCode = "110100101110110"; break; } break; case QR_LEVEL_M: switch (nMask) { case 0: pszCode = "101010000010010"; break; case 1: pszCode = "101000100100101"; break; case 2: pszCode = "101111001111100"; break; case 3: pszCode = "101101101001011"; break; case 4: pszCode = "100010111111001"; break; case 5: pszCode = "100000011001110"; break; case 6: pszCode = "100111110010111"; break; case 7: pszCode = "100101010100000"; break; } break; case QR_LEVEL_Q: switch (nMask) { case 0: pszCode = "011010101011111"; break; case 1: pszCode = "011000001101000"; break; case 2: pszCode = "011111100110001"; break; case 3: pszCode = "011101000000110"; break; case 4: pszCode = "010010010110100"; break; case 5: pszCode = "010000110000011"; break; case 6: pszCode = "010111011011010"; break; case 7: pszCode = "010101111101101"; break; } break; case QR_LEVEL_H: switch (nMask) { case 0: pszCode = "001011010001001"; break; case 1: pszCode = "001001110111110"; break; case 2: pszCode = "001110011100111"; break; case 3: pszCode = "001100111010000"; break; case 4: pszCode = "000011101100010"; break; case 5: pszCode = "000001001010101"; break; case 6: pszCode = "000110100001100"; break; case 7: pszCode = "000100000111011"; break; } break; } return (WORD)(pszCode ? strtol(pszCode, 0, 2) : 0); } void aQR::fillFormatInfo() { static QR_POINT mecl1[15] = { { 0, 8 }, { 1, 8 }, { 2, 8 }, { 3, 8 }, { 4, 8 }, { 5, 8 }, { 7, 8 }, { 8, 8 }, { 8, 7 }, { 8, 5 }, { 8, 4 }, { 8, 3 }, { 8, 2 }, { 8, 1 }, { 8, 0 } }; short nSize = getSizeXY(); QR_POINT mecl2[15] = { { 8, nSize - 1 }, { 8, nSize - 2 }, { 8, nSize - 3 }, { 8, nSize - 4 }, { 8, nSize - 5 }, { 8, nSize - 6 }, { 8, nSize - 7 }, { nSize - 8, 8 }, { nSize - 7, 8 }, { nSize - 6, 8 }, { nSize - 5, 8 }, { nSize - 4, 8 }, { nSize - 3, 8 }, { nSize - 2, 8 }, { nSize - 1, 8 } }; WORD wMaskEcl = getMaskEcl(m_nEcl, m_nMask); for (int i=0; i<15; i++) { setPixel(mecl1[i].x, mecl1[i].y, wMaskEcl & 0x4000 ? QR_VALUE_FP1 : QR_VALUE_FP0); setPixel(mecl2[i].x, mecl2[i].y, wMaskEcl & 0x4000 ? QR_VALUE_FP1 : QR_VALUE_FP0); wMaskEcl <<= 1; } } void aQR::fillMask() { if (m_nMask < 0 || m_nMask > 7) return; BYTE bValue, bMask; for (int x=0; x<getSizeXY(); x++) for (int y=0; y<getSizeXY(); y++) { bValue = getPixel(x, y); if (bValue == QR_VALUE_FP1 || bValue == QR_VALUE_FP0) continue; switch (m_nMask) { case 0: bMask = (x + y) % 2 == 0; break; case 1: bMask = y % 2 == 0; break; case 2: bMask = x % 3 == 0; break; case 3: bMask = (x + y) % 3 == 0; break; case 4: bMask = (x/3 + y/2) % 2 == 0; break; case 5: bMask = ((x*y) % 2 + (x*y) % 3) == 0; break; case 6: bMask = ((x * y) % 2 + (x * y) % 3) % 2 == 0; break; case 7: bMask = ((x * y) % 3 + (x + y) % 2) % 2 == 0; break; default: //ASSERT(0); bMask = 0; break; } if (bMask) setPixel(x, y, !bValue); } } int aQR::getBlockIndex(int nIndex, short nDataSize) const { int nBlocks = getNumBlocks(); if (nBlocks == 0) return 0; int nBlockSize = getBlockSize(0, nDataSize); if (nIndex < nBlockSize * nBlocks) { int nBlock = nIndex % nBlocks; int nBlockOffset = getBlockOffset(nBlock, nDataSize); return nBlockOffset + nIndex / nBlocks; } else { return nIndex; } } int aQR::getBlockSize(int nBlock, int nDataSize) const { int nBlocks = getNumBlocks(); int nBlockSize = nDataSize / nBlocks; int nExtra = nDataSize - nBlockSize * nBlocks; if (nExtra > 0) { if (nBlocks - nBlock % nBlocks <= nExtra) return nBlockSize + 1; } return nBlockSize; } int aQR::getBlockOffset(int nBlock, int nDataSize) const { int nBlocks = getNumBlocks(); int nBlockSize = nDataSize / nBlocks; int nExtra = nDataSize - nBlockSize * nBlocks; if (nExtra > 0) { if (nBlock > nBlocks - nExtra) nExtra = nBlock - (nBlocks - nExtra); else nExtra = 0; } int nBlockStart = nBlock * (nDataSize / nBlocks) + nExtra; return nBlockStart; } int aQR::getGenPoly(BYTE* pBytes) { int nBytes = m_info[m_nVersion].ec[m_nEcl]; //ASSERT(nBytes != 0); // const static BYTE cb7[7] = { 87, 229, 146, 149, 238, 102, 21 }; const static BYTE cb10[10] = { 251, 67, 46, 61, 118, 70, 64, 94, 32, 45 }; const static BYTE cb13[13] = { 74, 152, 176, 100, 86, 100, 106, 104, 130, 218, 206, 140, 78 }; const static BYTE cb15[15] = { 8, 183, 61, 91, 202, 37, 51, 58, 58, 237, 140, 124, 5, 99, 105 }; const static BYTE cb16[16] = { 120, 104, 107, 109, 102, 161, 76, 3, 91, 191, 147, 169, 182, 194, 225, 120 }; const static BYTE cb17[17] = { 43, 139, 206, 78, 43, 239, 123, 206, 214, 147, 24, 99, 150, 39, 243, 163, 136 }; const static BYTE cb18[18] = { 215, 234, 158, 94, 184, 97, 118, 170, 79, 187, 152, 148, 252, 179, 5, 98, 96, 153 }; const static BYTE cb20[20] = { 17, 60, 79, 50, 61, 163, 26, 187, 202, 180, 221, 225, 83, 239, 156, 164, 212, 212, 188, 190 }; const static BYTE cb22[22] = { 210, 171, 247, 242, 93, 230, 14, 109, 221, 53, 200, 74, 8, 172, 98, 80, 219, 134, 160, 105, 165, 231 }; const static BYTE cb24[24] = { 229, 121, 135, 48, 211, 117, 251, 126, 159, 180, 169, 152, 192, 226, 228, 218, 111, 0, 117, 232, 87, 96, 227, 21 }; const static BYTE cb26[26] = { 173, 125, 158, 2, 103, 182, 118, 17, 145, 201, 111, 28, 165, 53, 161, 21, 245, 142, 13, 102, 48, 227, 153, 145, 218, 70 }; const static BYTE cb28[28] = { 168, 223, 200, 104, 224, 234, 108, 180, 110, 190, 195, 147, 205, 27, 232, 201, 21, 43, 245, 87, 42, 195, 212, 119, 242, 37, 9, 123 }; const static BYTE cb30[30] = { 41, 173, 145, 152, 216, 31, 179, 182, 50, 48, 110, 86, 239, 96, 222, 125, 42, 173, 226, 193, 224, 130, 156, 37, 251, 216, 238, 40, 192, 180 }; switch (nBytes) { case 7: memcpy(pBytes, cb7, 7); break; case 10: memcpy(pBytes, cb10, 10); break; case 13: memcpy(pBytes, cb13, 13); break; case 15: memcpy(pBytes, cb15, 15); break; case 16: memcpy(pBytes, cb16, 16); break; case 17: memcpy(pBytes, cb17, 17); break; case 18: memcpy(pBytes, cb18, 18); break; case 20: memcpy(pBytes, cb20, 20); break; case 22: memcpy(pBytes, cb22, 22); break; case 24: memcpy(pBytes, cb24, 24); break; case 26: memcpy(pBytes, cb26, 26); break; case 28: memcpy(pBytes, cb28, 28); break; case 30: memcpy(pBytes, cb30, 30); break; default: //ASSERT(0); break; } return nBytes; } BYTE aQR::getGalois(BYTE cValue, bool bRevert) { const static BYTE aGalois[256] = { 1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, 70, 140, 5, 10, 20, 40, 80, 160, 93, 186, 105, 210, 185, 111, 222, 161, 95, 190, 97, 194, 153, 47, 94, 188, 101, 202, 137, 15, 30, 60, 120, 240, 253, 231, 211, 187, 107, 214, 177, 127, 254, 225, 223, 163, 91, 182, 113, 226, 217, 175, 67, 134, 17, 34, 68, 136, 13, 26, 52, 104, 208, 189, 103, 206, 129, 31, 62, 124, 248, 237, 199, 147, 59, 118, 236, 197, 151, 51, 102, 204, 133, 23, 46, 92, 184, 109, 218, 169, 79, 158, 33, 66, 132, 21, 42, 84, 168, 77, 154, 41, 82, 164, 85, 170, 73, 146, 57, 114, 228, 213, 183, 115, 230, 209, 191, 99, 198, 145, 63, 126, 252, 229, 215, 179, 123, 246, 241, 255, 227, 219, 171, 75, 150, 49, 98, 196, 149, 55, 110, 220, 165, 87, 174, 65, 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167, 83, 166, 81, 162, 89, 178, 121, 242, 249, 239, 195, 155, 43, 86, 172, 69, 138, 9, 18, 36, 72, 144, 61, 122, 244, 245, 247, 243, 251, 235, 203, 139, 11, 22, 44, 88, 176, 125, 250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142, 1 }; if (bRevert) { for (short rc=0; rc<256; rc++) if (aGalois[rc] == cValue) return (BYTE)rc; return 0; } return aGalois[cValue]; } short aQR::getData(BYTE* pData, int nDataSize, const BYTE* pInput, int nInputSize) { int nBitsOffset = 0; // формат данных // возможно вставить сюда автоопределение pushData(pData, nDataSize, nBitsOffset, m_nEncoding, 4); // поле количества данных pushData(pData, nDataSize, nBitsOffset, nInputSize, getDataLengthBits() * 8); for (int i=0; i<nInputSize; i++) pushData(pData, nDataSize, nBitsOffset, pInput[i], 8); // конец данных pushData(pData, nDataSize, nBitsOffset, 0, 4); return (short)(nBitsOffset-1) / 8 + 1; } int aQR::getEc(BYTE* pEc, int nEcSize, BYTE* pData, int nDataSize) { // байты коррекции BYTE aGenPoly[QR_MAX_CORR_BYTES]; memset(aGenPoly, 0, sizeof aGenPoly); int nGenPoly = getGenPoly(aGenPoly); int nEc = max(nDataSize, nGenPoly); memset(pEc, 0, nEcSize); memcpy(pEc, pData, nDataSize); int nz; for (int d=0; d<nDataSize; d++) { BYTE z = pEc[0]; for (int i=0; i<nEc; i++) pEc[i] = pEc[i + 1]; pEc[nEc - 1] = 0; if (z == 0) continue; z = getGalois(z, true); for (WORD i=0; i<nGenPoly; i++) { nz = aGenPoly[i] + z; if (nz > 254) nz = nz % 255; BYTE zz = getGalois((BYTE)nz, false); pEc[i] ^= zz; } z = 0; } return nGenPoly; } bool aQR::getNextXY(QR_NEXT_XY &nxy) { do { nxy.x--; if (!nxy.bVerticalTiming && nxy.x < 6) { nxy.nColumn--; nxy.bVerticalTiming = true; } if (nxy.x < nxy.nColumn - 1) { nxy.x = nxy.nColumn; nxy.y += nxy.nDirectionY; } if (nxy.x < 0) return false; if (nxy.y < 0) { nxy.y = 0; nxy.nColumn -= 2; nxy.x = nxy.nColumn; nxy.nDirectionY = -nxy.nDirectionY; } if (nxy.y >= getSizeXY()) { nxy.y = getSizeXY() - 1; nxy.nColumn -= 2; nxy.x = nxy.nColumn; nxy.nDirectionY = -nxy.nDirectionY; } } while (isPixelService(nxy.x, nxy.y)); return true; } bool aQR::pushPixel(QR_NEXT_XY &nxy, BYTE cValue) { if (nxy.x == 0 && nxy.y == 0) { nxy.x = nxy.y = nxy.nColumn = getSizeXY() - 1; nxy.nDirectionY = -1; nxy.bVerticalTiming = 0; m_nPixels = 0; } setPixel(nxy.x, nxy.y, m_bModeOrder ? (BYTE)m_nPixels : cValue); m_nPixels++; return getNextXY(nxy); } bool aQR::pushByte(QR_NEXT_XY &nxy, BYTE cByte) { for (int j=0; j<8 && nxy.x>=0; j++) { if (!pushPixel(nxy, cByte & 0x80 ? 1 : 0)) return false; // что то не так, не хватило места cByte <<= 1; } return true; } bool aQR::pushData(BYTE* pData, int nDataSize, int& nBitsOffset, unsigned int nData, int nBits) { // если вдруг переполнение, то прервемся if (nBitsOffset/8 >= nDataSize) return false; DWORD dwMask = 1; for (int i=0; i<nBits-1; i++) dwMask <<= 1; DWORD dwMaskData = 0x80; for (int i=0; i<(nBitsOffset%8); i++) dwMaskData >>= 1; BYTE* pPtr = pData + nBitsOffset/8; for (int i=0; i<nBits; i++) { if (nData & dwMask) *pPtr |= dwMaskData; dwMask >>= 1; if (++nBitsOffset % 8 == 0) { dwMaskData = 0x80; pPtr++; } else { dwMaskData >>= 1; } // если вдруг переполнение, то прервемся if (nBitsOffset/8 >= nDataSize) return false; } return true; } void aQR::calcBestMask() { short nBestMask = -1; short nBestCost = -1; for (m_nMask=0; m_nMask<8; m_nMask++) { fillFormatInfo(); fillMask(); // выставим маску short nCost1 = checkPenaltyRule1(); short nCost2 = checkPenaltyRule2(); short nCost3 = checkPenaltyRule3(); short nCost4 = checkPenaltyRule4(); fillMask(); // снесем маску short nCost = nCost1 + nCost2 + nCost3 + nCost4; if (nCost < nBestCost || nBestCost < 0) { nBestMask = m_nMask; nBestCost = nCost; } } m_nMask = nBestMask; fillFormatInfo(); } short aQR::checkPenaltyRule1() { short nPenaltyX = 0; short nPenaltyY = 0; for (int x=0; x<getSizeXY(); x++) { bool bPreviousWhiteX = !isPixelWhite(x, 0); int nSeriesX = 0; bool bPreviousWhiteY = !isPixelWhite(0, x); int nSeriesY = 0; for (int y=0; y<getSizeXY(); y++) { if (x == 7) { x = 7; } // X if (bPreviousWhiteX == isPixelWhite(x, y)) { nSeriesX++; } else { bPreviousWhiteX = !bPreviousWhiteX; nSeriesX = 1; } if (nSeriesX == 5) nPenaltyX += 3; else if (nSeriesX > 5) nPenaltyX++; // Y if (bPreviousWhiteY == isPixelWhite(y, x)) { nSeriesY++; } else { bPreviousWhiteY = !bPreviousWhiteY; nSeriesY = 1; } if (nSeriesY == 5) nPenaltyY += 3; else if (nSeriesY > 5) nPenaltyY++; } } return nPenaltyX + nPenaltyY; } short aQR::checkPenaltyRule2() { short nPenalty = 0; for (int x=0; x<getSizeXY()-2; x++) for (int y=0; y<getSizeXY()-2; y++) if (isPixelWhite(x, y) == isPixelWhite(x + 1, y) && isPixelWhite(x + 1, y) == isPixelWhite(x, y + 1) && isPixelWhite(x, y + 1) == isPixelWhite(x + 1, y + 1) ) nPenalty += 3; return nPenalty; } short aQR::checkPenaltyRule3() { short nPenalty = 0; // X for (int y=0; y<getSizeXY()-11; y++) for (int x=0; x<getSizeXY()-11; x++) { if (x < getSizeXY()-15) { if ( isPixelWhite(x, y) && isPixelWhite(x + 1, y) && isPixelWhite(x + 2, y) && isPixelWhite(x + 3, y) && !isPixelWhite(x + 4, y) && isPixelWhite(x + 5, y) && !isPixelWhite(x + 6, y) && !isPixelWhite(x + 7, y) && !isPixelWhite(x + 8, y) && isPixelWhite(x + 9, y) && !isPixelWhite(x + 10, y) && isPixelWhite(x + 11, y) && isPixelWhite(x + 12, y) && isPixelWhite(x + 13, y) && isPixelWhite(x + 14, y) ) { nPenalty += 40; x += 15; } } if (x < getSizeXY()-11) { if (!isPixelWhite(x, y) && isPixelWhite(x + 1, y) && !isPixelWhite(x + 2, y) && !isPixelWhite(x + 3, y) && !isPixelWhite(x + 4, y) && isPixelWhite(x + 5, y) && !isPixelWhite(x + 6, y) && isPixelWhite(x + 7, y) && isPixelWhite(x + 8, y) && isPixelWhite(x + 9, y) && isPixelWhite(x + 10, y)) { nPenalty += 40; x += 11; } } if (x < getSizeXY()-11) { if ( isPixelWhite(x, y) && isPixelWhite(x + 1, y) && isPixelWhite(x + 2, y) && isPixelWhite(x + 3, y) && !isPixelWhite(x + 4, y) && isPixelWhite(x + 5, y) && !isPixelWhite(x + 6, y) && !isPixelWhite(x + 7, y) && !isPixelWhite(x + 8, y) && isPixelWhite(x + 9, y) && !isPixelWhite(x + 10, y)) { nPenalty += 40; x += 11; } } } // Y for (int x=0; x<getSizeXY()-11; x++) for (int y=0; y<getSizeXY()-11; y++) { if (y < getSizeXY()-15) { if ( isPixelWhite(y, x) && isPixelWhite(y + 1, x) && isPixelWhite(y + 2, x) && isPixelWhite(y + 3, x) && !isPixelWhite(y + 4, x) && isPixelWhite(y + 5, x) && !isPixelWhite(y + 6, x) && !isPixelWhite(y + 7, x) && !isPixelWhite(y + 8, x) && isPixelWhite(y + 9, x) && !isPixelWhite(y + 10, x) && isPixelWhite(y + 11, x) && isPixelWhite(y + 12, x) && isPixelWhite(y + 13, x) && isPixelWhite(y + 14, x) ) { nPenalty += 40; y += 15; } } if (y < getSizeXY()-11) { if (!isPixelWhite(y, y) && isPixelWhite(y + 1, x) && !isPixelWhite(y + 2, x) && !isPixelWhite(y + 3, x) && !isPixelWhite(y + 4, x) && isPixelWhite(y + 5, x) && !isPixelWhite(y + 6, x) && isPixelWhite(y + 7, x) && isPixelWhite(y + 8, x) && isPixelWhite(y + 9, x) && isPixelWhite(y + 10, x)) { nPenalty += 40; y += 11; } } if (y < getSizeXY()-11) { if ( isPixelWhite(y, y) && isPixelWhite(y + 1, x) && isPixelWhite(y + 2, x) && isPixelWhite(y + 3, x) && !isPixelWhite(y + 4, x) && isPixelWhite(y + 5, x) && !isPixelWhite(y + 6, x) && !isPixelWhite(y + 7, x) && !isPixelWhite(y + 8, x) && isPixelWhite(y + 9, x) && !isPixelWhite(y + 10, x)) { nPenalty += 40; y += 11; } } } return nPenalty; } short aQR::checkPenaltyRule4() { int nWhite = 0; int nBlack = 0; for (int x=0; x<getSizeXY(); x++) for (int y=0; y<getSizeXY(); y++) if (isPixelWhite(x, y)) nWhite++; else nBlack++; double d = (double)nBlack / nWhite; d *= 100; d -= 50; d *= 2; if (d < 0) d = -d; return (short)d; }
ca098f97583ee7eaafe1c2379d447d283fbf61d3
f4a7677b7ea55fd4816483f3dc73d1c7b0de799e
/lib/include/prjxray/database.h
76b10935d4ae4a5945853bd5774afe158bd903de
[ "ISC", "LicenseRef-scancode-dco-1.1" ]
permissive
unixb0y/prjxray
ff9352f09b0488600c809c04dbabf11ac0e03783
569a44d8beadb7cf6548f7437e46fb456bacdd90
refs/heads/master
2021-04-30T04:54:49.106084
2018-02-20T00:19:00
2018-02-20T00:19:00
121,402,689
2
0
ISC
2018-02-15T02:45:43
2018-02-13T15:57:44
Verilog
UTF-8
C++
false
false
438
h
database.h
#ifndef PRJXRAY_LIB_DATABASE_H #define PRJXRAY_LIB_DATABASE_H #include <memory> #include <string> #include <vector> #include <prjxray/segbits_file_reader.h> namespace prjxray { class Database { public: Database(const std::string& path) : db_path_(path) {} std::vector<std::unique_ptr<SegbitsFileReader>> segbits() const; private: std::string db_path_; }; } // namespace prjxray #endif // PRJXRAY_LIB_DATABASE_H
34c0401c549f5979b2a4108ed9670c3b0ef18eb0
05db1d0c4b5fabce4a5fdb76bb4a286f141c1939
/calcLenString.cpp
6e7996705c327477e6a5ad1b5a5aab3853bac497
[]
no_license
dtfabio/calc-Len-string
a4e10c99fcef8d4bfdef787ee66cc0e83a815d6b
9103c1d5011f42aa4159f23cc7e6dca09d695f1b
refs/heads/master
2022-04-21T21:38:55.437249
2020-04-20T21:44:20
2020-04-20T21:44:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
309
cpp
calcLenString.cpp
#include <iostream> using namespace std; int len (char s[]) { int d=0; while(s[d]!='\0') d++; return d; } int main() { char stri[50]; int lungh; gets(stri); lungh=len(stri); cout<<"la lunghezza della stringa " <<stri<<" e': "<<lungh<<endl; system("pause"); }
8f194bd8450e44170f14ea8a2205c83087286a31
aac83bbda97ab5f7efc4ae131dcb2da33ec9a97e
/app/kdelibs/krandomsequence.cpp
3a20007b1ab0f67602384a32ea4c42865a5e433a
[]
no_license
phedlund/WordQuiz
e8d731033bd62f09c3e7cedb64a921de0e8249a1
adbc7ba0773d29901a2c52c4af95e4db9544183a
refs/heads/master
2021-01-01T05:48:34.828473
2012-11-14T18:49:51
2012-11-14T18:49:51
1,973,988
2
0
null
null
null
null
UTF-8
C++
false
false
5,494
cpp
krandomsequence.cpp
/* This file is part of the KDE libraries Copyright (c) 1999 Sean Harmer <sh@astro.keele.ac.uk> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "krandomsequence.h" #include "krandom.h" #include <string.h> //WQ Comment #include <config.h> static const int s_nShuffleTableSize = 32; class KRandomSequence::Private { public: // Generate the random number void draw(); long lngSeed1; long lngSeed2; long lngShufflePos; long shuffleArray[s_nShuffleTableSize]; }; ////////////////////////////////////////////////////////////////////////////// // Construction / Destruction ////////////////////////////////////////////////////////////////////////////// KRandomSequence::KRandomSequence( long lngSeed1 ) : d(new Private) { // Seed the generator setSeed( lngSeed1 ); } KRandomSequence::~KRandomSequence() { delete d; } KRandomSequence::KRandomSequence(const KRandomSequence &a) : d(new Private) { *d = *a.d; } KRandomSequence & KRandomSequence::operator=(const KRandomSequence &a) { if ( this != &a ) { *d = *a.d; } return *this; } ////////////////////////////////////////////////////////////////////////////// // Member Functions ////////////////////////////////////////////////////////////////////////////// void KRandomSequence::setSeed( long lngSeed1 ) { // Convert the positive seed number to a negative one so that the draw() // function can intialise itself the first time it is called. We just have // to make sure that the seed used != 0 as zero perpetuates itself in a // sequence of random numbers. if ( lngSeed1 < 0 ) { d->lngSeed1 = -1; } else if (lngSeed1 == 0) { d->lngSeed1 = -((KRandom::random() & ~1)+1); } else { d->lngSeed1 = -lngSeed1; } } static const long sMod1 = 2147483563; static const long sMod2 = 2147483399; void KRandomSequence::Private::draw() { static const long sMM1 = sMod1 - 1; static const long sA1 = 40014; static const long sA2 = 40692; static const long sQ1 = 53668; static const long sQ2 = 52774; static const long sR1 = 12211; static const long sR2 = 3791; static const long sDiv = 1 + sMM1 / s_nShuffleTableSize; // Long period (>2 * 10^18) random number generator of L'Ecuyer with // Bayes-Durham shuffle and added safeguards. Returns a uniform random // deviate between 0.0 and 1.0 (exclusive of the endpoint values). Call // with a negative number to initialize; thereafter, do not alter idum // between successive deviates in a sequence. RNMX should approximate // the largest floating point value that is less than 1. int j; // Index for the shuffle table long k; // Initialise if ( lngSeed1 <= 0 ) { lngSeed2 = lngSeed1; // Load the shuffle table after 8 warm-ups for ( j = s_nShuffleTableSize + 7; j >= 0; j-- ) { k = lngSeed1 / sQ1; lngSeed1 = sA1 * ( lngSeed1 - k*sQ1) - k*sR1; if ( lngSeed1 < 0 ) { lngSeed1 += sMod1; } if ( j < s_nShuffleTableSize ) { shuffleArray[j] = lngSeed1; } } lngShufflePos = shuffleArray[0]; } // Start here when not initializing // Compute lngSeed1 = ( lngIA1*lngSeed1 ) % lngIM1 without overflows // by Schrage's method k = lngSeed1 / sQ1; lngSeed1 = sA1 * ( lngSeed1 - k*sQ1 ) - k*sR1; if ( lngSeed1 < 0 ) { lngSeed1 += sMod1; } // Compute lngSeed2 = ( lngIA2*lngSeed2 ) % lngIM2 without overflows // by Schrage's method k = lngSeed2 / sQ2; lngSeed2 = sA2 * ( lngSeed2 - k*sQ2 ) - k*sR2; if ( lngSeed2 < 0 ) { lngSeed2 += sMod2; } j = lngShufflePos / sDiv; lngShufflePos = shuffleArray[j] - lngSeed2; shuffleArray[j] = lngSeed1; if ( lngShufflePos < 1 ) { lngShufflePos += sMM1; } } void KRandomSequence::modulate(int i) { d->lngSeed2 -= i; if ( d->lngSeed2 < 0 ) { d->lngShufflePos += sMod2; } d->draw(); d->lngSeed1 -= i; if ( d->lngSeed1 < 0 ) { d->lngSeed1 += sMod1; } d->draw(); } double KRandomSequence::getDouble() { static const double finalAmp = 1.0 / double( sMod1 ); static const double epsilon = 1.2E-7; static const double maxRand = 1.0 - epsilon; double temp; d->draw(); // Return a value that is not one of the endpoints if ( ( temp = finalAmp * d->lngShufflePos ) > maxRand ) { // We don't want to return 1.0 return maxRand; } else { return temp; } } unsigned long KRandomSequence::getLong(unsigned long max) { d->draw(); return max ? (((unsigned long) d->lngShufflePos) % max) : 0; } bool KRandomSequence::getBool() { d->draw(); return (((unsigned long) d->lngShufflePos) & 1); }
41a64fbc75be762ff3f3f488337541830310eb30
bc6b55224c05e7f662c4147d499989609ff8cd1c
/ZCWebServer/Interface/InterfaceUserChangePassword.cpp
a7a53b05b4219356b2e03394f2b8c28052b8744e
[]
no_license
lossed1990/jinying
76fb2aabfbc9ca240549a00046d02e2100cddaf4
0d4131d773ff3b2a872a37a87b29064ee32e9e80
refs/heads/master
2021-09-02T11:38:41.390743
2018-01-02T09:26:35
2018-01-02T09:26:35
114,993,525
0
0
null
null
null
null
UTF-8
C++
false
false
2,079
cpp
InterfaceUserChangePassword.cpp
#include <Windows.h> #include <io.h> #include <stdio.h> #include <stdlib.h> #include "../JsonRequest/EncodingToolsClass.h" #include "../ToolFuncs/ToolFuncs.h" #include "document.h" #include "prettywriter.h" #include "stringbuffer.h" #include "CommonFunction.h" #include "InterfaceUserChangePassword.h" using namespace rapidjson; CInterfaceUserChangePassword::CInterfaceUserChangePassword() { } CInterfaceUserChangePassword::~CInterfaceUserChangePassword() { } string CInterfaceUserChangePassword::GetUrl() { return I_USER_CHANGEPW; } void CInterfaceUserChangePassword::ExecuteInterface(char* pReqBody, int nReqBodyLen, string& strReturn) { //检查参数 Document doc; doc.Parse(pReqBody); if (!doc.IsObject()) { strReturn = "{\"ok\":1,\"errorinfo\":\"请求参数为非法json数据\"}"; return; } char pcTemp[256] = { 0 }; CEncodingTools::ConvertUTF8ToGB(doc["name"].GetString(), pcTemp, 256); string chUserName = string(pcTemp); if (strcmp(chUserName.c_str(), "") == 0) { strReturn = "{\"ok\":1,\"errorinfo\":\"修改密码失败,用户名不能为空!\"}"; return; } CEncodingTools::ConvertUTF8ToGB(doc["oldpw"].GetString(), pcTemp, 256); string chOldPw = string(pcTemp); if (strcmp(chOldPw.c_str(), "") == 0) { strReturn = "{\"ok\":1,\"errorinfo\":\"修改密码失败,原始密码不能为空!\"}"; return; } CEncodingTools::ConvertUTF8ToGB(doc["newpw"].GetString(), pcTemp, 256); string chNewPw = string(pcTemp); if (strcmp(chNewPw.c_str(), "") == 0) { strReturn = "{\"ok\":1,\"errorinfo\":\"修改密码失败,新密码不能为空!\"}"; return; } int nRet = CMainModel::Instance()->ChangeUserPassword(chUserName, chOldPw, chNewPw); if (nRet == -1) { strReturn = "{\"ok\":1,\"errorinfo\":\"修改密码失败,用户不存在!\"}"; return; } else if (nRet == -2) { strReturn = "{\"ok\":1,\"errorinfo\":\"修改密码失败,原始密码错误!\"}"; return; } strReturn = "{\"ok\":0,\"errorinfo\":\"\"}"; CDBHelper::Instance()->Log(pcTemp, "修改密码", "修改密码"); return; }
1f630156c31be2ac1a83fb446f197b38c69d286a
fba6ee80ae03468ad5c6f29c07be4b7f88456e47
/test9_program_options.cpp
783952e092ae9bff04033e6d16e7720ab154ac2f
[]
no_license
shane0314/testcpp
397df85eaab2244debe000fd366c30037d83b60e
480f70913e6b3939cc4b60b1a543810890b3e317
refs/heads/master
2021-07-09T15:35:37.373116
2020-07-17T09:13:49
2020-07-17T09:13:49
163,728,721
0
0
null
null
null
null
UTF-8
C++
false
false
2,731
cpp
test9_program_options.cpp
/* compile command at linux: g++ test9_program_options.cpp -o t9 -lboost_program_options */ #include <boost/program_options.hpp> #include <boost/algorithm/string.hpp> #include <boost/regex.hpp> #include <boost/foreach.hpp> #include "myHfile.h" #include <vector> using namespace std; int main(int argc, char** argv ) { string configFilename; std::vector<int> values; bool flag; int pos1; std::vector<int> pos2; namespace po = boost::program_options; po::options_description desc( "test program options" "\n" "usage: ./t9 -c hello -v 1 2 4 6 7 8 9 \n" "options"); desc.add_options() ("help", "produce help messages/haha") ("config,c", po::value<std::string>( &configFilename), "config file") ("value,v", po::value( &values), "int values, -v 1 -v 2 -v 3") ("flag,f", po::bool_switch( &flag ), "swith option") ("pos1,p", po::value( &pos1 ), "positional option 1") ; // this option will be hidden at "help" show po::options_description hiddenDesc( "hidden options"); hiddenDesc.add_options() ("pos2,q", po::value( &pos2 ), "positional option 2") ; // the second arg of add, species that up to 'max_count' next positional options should be given the 'name'. The value of '-1' means 'unlimited'. po::positional_options_description pos; pos.add( "pos1", 1 ).add( "pos2", -1 ); po::variables_map vm; try{ po::store( po::command_line_parser( argc, argv ).options( po::options_description().add( desc ).add( hiddenDesc ) ).positional( pos ).run(), vm ); } catch(...){ std::cout << "unknown options!" << std::endl; } po::notify( vm ); if( vm.count("help") ){ std::cout << desc << std::endl; } if( vm.count( "cofing") ) { //not work std::cout << "config file is:" << vm["config"].as<std::string>() << std::endl; std::cout << "config file is:" << configFilename << std::endl; } std::cout << "config file is:" << vm["config"].as<std::string>() << std::endl; std::cout << "config file is:" << configFilename << std::endl; if( vm.empty() ) { std::cout << "no options found" << std::endl; } if( !values.empty() ) { std::cout << "values: "; BOOST_FOREACH( int var, values ) { std::cout << var << ","; } std::cout << std::endl; } std::cout << "positional options, pos1: " << pos1 << std::endl; if( !pos2.empty() ) { std::cout << "positional options, pos2: "; BOOST_FOREACH( int var, pos2 ) { std::cout << var << ","; } std::cout << std::endl; } std::cout << "orig args:" << std::endl; for( int idx=0; idx<argc; idx++) cout << "agrv[" << idx << "] = " << argv[idx] <<endl; return 0; }
4759b2d97eb988cc1b775712f4cf1bc49356d6cf
72f6aca80d0bdc1e16f3bdb11b6e280f26e00f34
/src/media_player_82/id3_frame.cpp
1ead8f703e0d5ce90bd01b49f6c3f25b59c3561b
[]
no_license
antsaukk/media-player
5c22769f3703b3950872865288db8500ce11a2a4
a38d7c79c8bdbf6d661401040c84249a84e4111d
refs/heads/master
2023-07-08T02:34:39.232055
2021-08-13T08:16:50
2021-08-13T08:16:50
330,608,063
0
0
null
null
null
null
UTF-8
C++
false
false
2,366
cpp
id3_frame.cpp
#include "id3_frame.h" #include <string> #include <iostream> #include <fstream> #include <algorithm> // A constructor to be used when reading the data from a file ID3_Frame::ID3_Frame(std::vector<char> header_, std::vector<char> value_) : header(header_), value(value_) { } // Helper function to get the frame size bytes from an int std::vector<char> intToBytes_frame(int a) { std::vector<char> res; for (int i = 0; i < 4; i++) { res.push_back((a >> (3-i)*8) & (0xff)); } return res; } // A constructor to be used when creating a new frame. ID and value given as strings, // flags as an int (default value 0). Parses the header to match the id, the value and the flags ID3_Frame::ID3_Frame(std::string& id, std::string& value_, int flags) : value(value_.begin(), value_.end()) { std::vector<char> sizeBytes = intToBytes_frame(value_.length() + 1); for (int i = 0; i < 4; i++) header.push_back(id[i]); for (int i = 0; i < 4; i++) header.push_back(sizeBytes[i]); header.push_back((flags >> 8) & 0xff); header.push_back(flags & 0xff); value.insert(value.begin(), 0); for (auto c : header) { std::cout << (int) c << " "; } std::cout << std::endl; } // Returns the value of the frame, parsed into a string std::string ID3_Frame::getValue() const { std::string s(value.begin(), value.end()); return s; } // Returns the ID of the frame (first 4 bytes of header) std::string ID3_Frame::getID() const { std::string s(header.begin(), header.begin() + 4); return s; } // Returns the flags of frame (last two bytes of header) int ID3_Frame::getFlags() const { return ((int) header[8] << 8 | (int) header[9]); } // Returns the size of the value of the frame, ie. the total length of the frame // excluding the length of the header int ID3_Frame::getFrameSize() const { return value.size(); } // Modifies the value of the frame. Updates the header to match the new value length as well void ID3_Frame::modifyValue(std::string& newValue) { value.clear(); for (auto chr : newValue) { value.push_back(chr); } std::vector<char> newSizeBytes = intToBytes_frame(value.size() + 1); for (int i = 4; i < 8; i++) { header[i] = newSizeBytes[i-4]; } }
6fc056d9f3ce055f2a49b4bd94cf7ae98d28da69
be0204c1b95839adee1ad204be022be38e32e2d6
/BOJ/2743.cpp
10e048f61c08e32848e405200f6b8ac992e2b09e
[]
no_license
tlsdorye/Problem-Solving
507bc8d3cf1865c10067ef2e8eb7cb2ee42e16dd
5c112d2238bfb1fc092612a76f10c7785ba86c78
refs/heads/master
2021-06-12T19:19:19.337092
2021-04-23T06:39:43
2021-04-23T06:39:43
179,432,390
4
0
null
null
null
null
UTF-8
C++
false
false
121
cpp
2743.cpp
#include <stdio.h> #include <cstring> char c[101]; int main() { scanf("%s", c); printf("%d", strlen(c)); return 0; }
555827ffdc82b6a2559725ae5038dbd7fb959731
42e0984a94f42bb7f74ffa63493e232debae24e7
/cpp-cnn/layers/max_pooling_layer.hpp
9513632c8b78ce3c1a4b4669177b8e25fddb987f
[]
no_license
RoboTums/find-people
8a2c32307144b1a9950857c74e39c37ebce88dd9
8bc5f3f232cd4096023f67aee4b41750fc7e0adb
refs/heads/master
2021-08-24T16:19:18.559264
2020-04-13T02:22:26
2020-04-13T02:22:26
159,381,254
2
0
null
2018-11-27T18:30:49
2018-11-27T18:30:49
null
UTF-8
C++
false
false
4,396
hpp
max_pooling_layer.hpp
#ifndef MAX_POOLING_LAYER_HPP #define MAX_POOLING_LAYER_HPP #include <iostream> #include <armadillo> #include <cassert> #define DEBUG false #define DEBUG_PREFIX "[DEBUG POOL LAYER ]\t" class MaxPoolingLayer { public: MaxPoolingLayer(size_t inputHeight, size_t inputWidth, size_t inputDepth, size_t poolingWindowHeight, size_t poolingWindowWidth, size_t verticalStride, size_t horizontalStride) : inputHeight(inputHeight), inputWidth(inputWidth), inputDepth(inputDepth), poolingWindowHeight(poolingWindowHeight), poolingWindowWidth(poolingWindowWidth), verticalStride(verticalStride), horizontalStride(horizontalStride) { // Nothing to do here. } void Forward(arma::cube& input, arma::cube& output) { assert((inputHeight - poolingWindowHeight)%verticalStride == 0); assert((inputWidth - poolingWindowWidth)%horizontalStride == 0); output = arma::zeros( (inputHeight - poolingWindowHeight)/verticalStride + 1, (inputWidth - poolingWindowWidth)/horizontalStride + 1, inputDepth ); for (size_t sidx = 0; sidx < inputDepth; sidx ++) { for (size_t ridx = 0; ridx <= inputHeight - poolingWindowHeight; ridx += verticalStride) { for (size_t cidx = 0; cidx <= inputWidth - poolingWindowWidth; cidx += horizontalStride) { output.slice(sidx)(ridx/verticalStride, cidx/horizontalStride) = input.slice(sidx).submat(ridx, cidx, ridx+poolingWindowHeight-1, cidx+poolingWindowWidth-1) .max(); } } } this->input = input; this->output = output; #if DEBUG std::cout << DEBUG_PREFIX << "---------------------------------------------" << std::endl << DEBUG_PREFIX << "FORWARD PASS DEBUG OUTPUT" << std::endl << DEBUG_PREFIX << "---------------------------------------------" << std::endl; std::cout << DEBUG_PREFIX << std::endl; std::cout << DEBUG_PREFIX << "Input to Max pooling layer:" << std::endl; for (size_t i=0; i<inputDepth; i++) { std::cout << DEBUG_PREFIX << "Slice #" << i << std::endl; for (size_t r=0; r < input.slice(i).n_rows; r++) std::cout << DEBUG_PREFIX << input.slice(i).row(r); } std::cout << DEBUG_PREFIX << std::endl; std::cout << DEBUG_PREFIX << "Output of Max pooling layer:" << std::endl; for (size_t i=0; i<inputDepth; i++) { std::cout << DEBUG_PREFIX << "Slice #" << i << std::endl; for (size_t r=0; r < output.slice(i).n_rows; r++) std::cout << DEBUG_PREFIX << output.slice(i).row(r); } #endif } void Backward(arma::cube& upstreamGradient) { assert (upstreamGradient.n_rows == output.n_rows); assert (upstreamGradient.n_cols == output.n_cols); assert (upstreamGradient.n_slices == output.n_slices); gradientWrtInput = arma::zeros(inputHeight, inputWidth, inputDepth); for (size_t i=0; i<inputDepth; i++) { for (size_t r=0; r + poolingWindowHeight <= inputHeight; r += verticalStride) { for (size_t c=0; c + poolingWindowWidth <= inputWidth; c += horizontalStride) { arma::mat tmp(poolingWindowHeight, poolingWindowWidth, arma::fill::zeros); tmp(input.slice(i).submat(r, c, r+poolingWindowHeight-1, c+poolingWindowWidth-1) .index_max()) = upstreamGradient.slice(i)(r/verticalStride, c/horizontalStride); gradientWrtInput.slice(i).submat(r, c, r+poolingWindowHeight-1, c+poolingWindowWidth-1) += tmp; } } } } arma::cube getGradientWrtInput() { return gradientWrtInput; } private: size_t inputHeight; size_t inputWidth; size_t inputDepth; size_t poolingWindowHeight; size_t poolingWindowWidth; size_t verticalStride; size_t horizontalStride; arma::cube input; arma::cube output; arma::cube gradientWrtInput; }; #undef DEBUG #undef DEBUG_PREFIX #endif
7dceaef453b28a5e1315717ead165f5db0dfaa0b
ff24e041d4e08c4257ee9e6a987d2bbb5ef68306
/bleep/functions.hpp
1abdd7163d5133458592a5537dafece53999180d
[]
no_license
seagleNet/codecademy-cpp
10a0f488c096c0d7a3b4aa529d5dbae0a37a8aa2
6594e1861f1306062a82d40c8c5b6f61e681fb02
refs/heads/master
2020-05-07T18:43:58.743470
2019-07-28T21:29:07
2019-07-28T21:29:07
180,780,874
0
0
null
null
null
null
UTF-8
C++
false
false
109
hpp
functions.hpp
using namespace std; void asterisk(string word, string &text, int i); void bleep(string word, string &text);
4493017e0d2035ddb1760e21f9322c16b87b5994
103a7320969e0153cda6951aba9e009397a5d79d
/include/FixedArrayStorage.h
8693db79c0f2f886e3a1cf4ba136e1effdf52992
[ "MIT" ]
permissive
tailsu/QuickSig
0f27113c2eba42a235ce8112302c867498b5df75
6ee56638cc6d3945ed88f74fe00158658f9bb1bd
refs/heads/master
2021-01-01T19:10:20.464777
2015-01-10T14:21:54
2015-01-10T14:21:54
29,059,302
0
0
null
null
null
null
UTF-8
C++
false
false
1,289
h
FixedArrayStorage.h
// This file is part of the QuickSig library. // Copyright 2008 Stefan Dragnev. // The library and all its files are distributed under the MIT license. // See the full text of the license in the accompanying LICENSE.txt file or at http://www.opensource.org/licenses/mit-license.php #pragma once #include "StoragePolicy.h" namespace QuickSig { template <size_t MaxSlots> class FixedArrayStorage : public virtual DefaultPolicies { public: struct Impl { template <class Slot, class /*Allocator*/> class Storage { public: typedef Slot SlotContainer[MaxSlots]; typedef const Slot* SlotIterator; Storage() { m_SlotCount = 0; } void Add(const Slot& c) { assert(m_SlotCount < MaxSlots); m_Slots[m_SlotCount++] = c; } template <class Pred> void RemoveIf(Pred p) { Slot* newEnd = std::remove_if(m_Slots, m_Slots+m_SlotCount, p); m_SlotCount = newEnd - m_Slots; } SlotIterator SlotsBegin() const { return m_Slots; } SlotIterator SlotsEnd() const { return m_Slots + m_SlotCount; } void DeleteSlots() { m_SlotCount = 0; } private: SlotContainer m_Slots; size_t m_SlotCount; }; }; typedef Impl StoragePolicy; }; }
9fcf0dd39b63619af6ebaebf775cebd93fec0f5f
c81ef20ab259c0941b25054ad07fde801db8a615
/src/Graphic/Circle.cpp
928711626b5b4b9659d2739e8f59d3ff287c0dc0
[]
no_license
gerald5867/GFMEngine
d449c55b356a4839fba7e64f013f8bdd60494453
b1d4dd3da93872e64a3dc3edd204f9e9bbdc992b
refs/heads/master
2021-04-29T23:17:17.540132
2019-06-18T08:06:53
2019-06-18T08:06:53
121,552,006
0
0
null
null
null
null
UTF-8
C++
false
false
1,284
cpp
Circle.cpp
#include "CircleRenderer.h" #include "Circle.h" gfm::graphic::Circle::~Circle() noexcept { static int dtorcall = 0; CircleRenderer::instance().Remove(*this); m_rendererIndex = 0; dtorcall++; } gfm::graphic::Circle::Circle() : Shape() , m_radius(1.0f) , m_scale(1.0f) { m_rendererIndex = CircleRenderer::instance().Submit(*this); } gfm::graphic::Circle::Circle(const Circle& other) : Shape(other.m_position, other.m_color) , m_radius(other.m_radius) , m_scale(other.m_scale) { m_rendererIndex = CircleRenderer::instance().Submit(*this); } gfm::graphic::Circle::Circle(const math::Vec2& position, float radius, const math::Vec4& color) : Shape(position, color) , m_radius(radius) , m_scale(1.0f) { m_rendererIndex = CircleRenderer::instance().Submit(*this); } gfm::graphic::Circle::Circle(float x, float y, float radius, const math::Vec4& color) : Shape(x, y, color) , m_radius(radius) , m_scale(1.0f) { m_rendererIndex = CircleRenderer::instance().Submit(*this); } void gfm::graphic::Circle::SetScale(float scale) noexcept { m_scale = scale; OnChangeState(); } void gfm::graphic::Circle::SetRadius(float radius) noexcept { m_radius = radius; OnChangeState(); } void gfm::graphic::Circle::OnChangeState() const { CircleRenderer::instance().NeedUpdate(*this); }
d16e677b303434e3432a123a82e16d5b9f6e1c91
4f5691998e1e55451b17fe6c0d35f294cc38c405
/CharMemoryPool.hpp
461971ecb1ac952d34efcc39f58a53e0bf0b2db6
[ "BSD-3-Clause" ]
permissive
PankeyCR/aMonkeyEngine
9bb3c3f89ec9cab2a181f3cfd43d89f379a39124
a5fb3f7f73f51b17cfe90f6fc26c529b7e8e6c2d
refs/heads/master
2023-06-22T01:36:55.745033
2023-06-15T22:03:09
2023-06-15T22:03:09
198,529,019
1
0
null
null
null
null
UTF-8
C++
false
false
1,410
hpp
CharMemoryPool.hpp
#include "ame_Enviroment.hpp" #if defined(DISABLE_CharMemoryPool) #define CharMemoryPool_hpp #endif #ifndef CharMemoryPool_hpp #define CharMemoryPool_hpp #define CharMemoryPool_AVAILABLE #ifndef ame_Enviroment_Defined #endif #ifdef ame_Windows #endif #ifdef ame_ArduinoIDE #include "Arduino.h" #endif #include "MemoryChunk.hpp" #ifdef CharMemoryPoolLogApp #include "Logger.hpp" #define CharMemoryPoolLog(name,method,type,mns) Log(name,method,type,mns) #else #define CharMemoryPoolLog(name,method,type,mns) #endif namespace ame{ class CharMemoryPool : public MemoryPool{ public: CharMemoryPool(size_t poolsize, size_t chunksize) : MemoryPool(poolsize, chunksize){ CharMemoryPoolLog("CharMemoryPool", "Constructor", "println", ""); } CharMemoryPool(size_t poolsize, size_t chunksize, void* p) : MemoryPool(poolsize, chunksize, p){ CharMemoryPoolLog("CharMemoryPool", "Constructor", "println", ""); } virtual ~CharMemoryPool(){ CharMemoryPoolLog("CharMemoryPool", "Destructor", "println", ""); } virtual void onRecycle(){ } virtual void recycle(MemoryChunk* varDeleted){ } virtual void recycle(void* varDeleted){ } virtual void deleteMemoryPool(CharMemoryPool* CharMemoryPool){} virtual void deleteMemoryChunk(MemoryChunk* memorychunk){} virtual void initialize(){} virtual void update(float tpc){} protected: }; } #endif
24ca8608315e91e9ec4b3e30800a3a1df7ca6fd7
7d14d0124135e83fb09af1ccb043d00be691ea74
/src/service/api/rapidjson_utils.h
055a3b67cb4767e94593e8ab2e39d099f8e97103
[ "Apache-2.0" ]
permissive
browsermt/mts
236089ebb54e17a28395801db891e6bd6c0367da
7352e6dde196ac16293728b43d75ed8cad4f61ba
refs/heads/master
2023-03-03T22:11:03.238838
2021-02-12T22:07:07
2021-02-12T22:07:07
276,864,839
11
2
Apache-2.0
2020-07-03T09:46:42
2020-07-03T09:46:41
null
UTF-8
C++
false
false
1,899
h
rapidjson_utils.h
#pragma once // #include "3rd_party/rapidjson/include/rapidjson/rapidjson.h" // #include "3rd_party/rapidjson/include/rapidjson/fwd.h" #include "rapidjson/allocators.h" #include "rapidjson/fwd.h" #include "rapidjson/document.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" #include "service/common/translation_service.h" #include "service/common/translation_job.h" #include "service/api/output_options.h" // Utility functions for dealing with Rapidjson namespace rapidjson { Value* ensure_path(Value& node, MemoryPoolAllocator<>& alloc, char const* key); template<typename ... Rest> Value* ensure_path(Value& node, MemoryPoolAllocator<>& alloc, char const* key, Rest ... restpath){ if (!node.IsObject()) return NULL; auto m = node.FindMember(key); if (m != node.MemberEnd()) return ensure_path(m->value, alloc, restpath ...); Value k(key,alloc); auto& x = node.AddMember(k, Value().Move(), alloc)[key].SetObject(); return ensure_path(x, alloc, restpath ...); } std::string get(const Value& D, const char* key, std::string const& dflt); int get(const Value& D, const char* key, int const& dflt); Value job2json(const marian::server::Job& job, const marian::server::TranslationService& service, const marian::server::OutputOptions& opts, MemoryPoolAllocator<>& alloc); std::string serialize(Document const& D); // void dump(rapidjson::Value& v, std::ostream& out) { // if (v.IsString()) { out << v.GetString() << std::endl; } // else if (v.IsArray()) { for (auto& c: v.GetArray()) dump(c,out); } // } // Override values from specs in Json object v. // Return false if there's a problem with v (not a JSON object type) bool setOptions(marian::server::OutputOptions& opts, const rapidjson::Value& v); } // end of namespace rapidjson
c86510ce06107adc21e7eddb4ac6af10f617fea0
70418d8faa76b41715c707c54a8b0cddfb393fb3
/738.cpp
ef5ed2246f30e6ba0d0886c1b568d0309a4ea30c
[]
no_license
evandrix/UVa
ca79c25c8bf28e9e05cae8414f52236dc5ac1c68
17a902ece2457c8cb0ee70c320bf0583c0f9a4ce
refs/heads/master
2021-06-05T01:44:17.908960
2017-10-22T18:59:42
2017-10-22T18:59:42
107,893,680
3
1
null
null
null
null
UTF-8
C++
false
false
5,233
cpp
738.cpp
#include <bits/stdc++.h> using namespace std; #define REP(i, b, n) for (int i = b; i < n; i++) #define rep(i, n) REP(i, 0, n) #define pb push_back #define N 5000 #define OUTPUT 0 #define OR 1 #define AND 2 #define NOT 3 #define ALPHABET 4 typedef vector<int> vint; typedef vector<bool> vbool; class Node { public: vbool val; int type; int chara; void take_and(vbool &a, vbool &b) { val.clear(); rep(i, a.size()) val.pb(a[i] & b[i]); } void take_or(vbool &a, vbool &b) { val.clear(); rep(i, a.size()) val.pb(a[i] | b[i]); } void take_not(vbool &a) { val.clear(); rep(i, a.size()) val.pb(!a[i]); } }; Node node[N]; vint edge[N]; //should be clear vbool alpha[26]; //should be clear int assign[100][100]; //should be initialize with -1 bool visited[100][100];//initialiize with false string m[128]; //should be clear?? int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int opp[] = {1, 0, 3, 2}; char verify[4] = {'|', '|', '-', '-'}; int convert(int r) { int index = 0; rep(i, r) { rep(j, m[i].size()) { if (isupper(m[i][j])) { node[index].type = ALPHABET; node[index].chara = m[i][j] - 'A'; assign[i][j] = index++; } else if (m[i][j] == ':') { if (i != 0 && i + 1 < r && m[i - 1][j] == ':' && m[i + 1][j] == ':') { m[i][j] = ' '; } } else if (m[i][j] == '\\' || m[i][j] == '/') { } else if (m[i][j] == ')')//AND { node[index].type = AND; assign[i][j] = index++; } else if (m[i][j] == '>')//OR { node[index].type = OR; assign[i][j] = index++; } else if (m[i][j] == 'o')//NOT { node[index].type = NOT; assign[i][j] = index++; } else if (m[i][j] == '?')//OUTPUT { node[index].type = OUTPUT; assign[i][j] = index++; } } } rep(i, r) rep(j, m[i].size()) if (m[i][j] == ':') { m[i][j] = '-'; } return index; } void tsort(int r, int y, int x, vint &res, int prev, int prevnode) { // cout << y <<" " <<x << " " << m[y][x] << " " <<" " << prev <<" " << prevnode << " " << assign[y][x] << endl; if (assign[y][x] != -1 && node[assign[y][x]].type != ALPHABET) { edge[assign[y][x]].pb(prevnode); prevnode = assign[y][x]; } if (visited[y][x] == true) { return; } visited[y][x] = true; if (m[y][x] == '+') { rep(i, 4) { int ney = y + dy[i], nex = x + dx[i]; if (nex < 0 || nex >= 100 || ney < 0 || ney >= r) { continue; } if ((m[ney][nex] == '-' || m[ney][nex] == '|') && m[ney][nex] != verify[prev] && m[ney][nex] == verify[i]) { tsort(r, ney, nex, res, i, prevnode); } } } else if (m[y][x] == '-') { int nex = x + dx[prev], ney = y + dy[prev]; if (m[ney][nex] == '\\') { tsort(r, ney + 1, nex + 1, res, prev, prevnode); } else if (m[ney][nex] == '/') { tsort(r, ney - 1, nex + 1, res, prev, prevnode); } else { tsort(r, ney, nex, res, prev, prevnode); } } else if (m[y][x] == '|') { int nex = x + dx[prev], ney = y + dy[prev]; tsort(r, ney, nex, res, prev, prevnode); } else if (isupper(m[y][x])) { rep(i, 4) { int nex = x + dx[i], ney = y + dy[i]; if (nex < 0 || nex >= 100 || ney < 0 || ney >= r) { continue; } if (verify[i] == m[ney][nex]) { tsort(r, ney, nex, res, i, prevnode); } } } else if (m[y][x] == 'o') { int nex = x + dx[prev], ney = y + dy[prev]; tsort(r, ney, nex, res, prev, prevnode); } else if (m[y][x] == ')' || m[y][x] == '>') { int nex = x + dx[prev], ney = y + dy[prev]; tsort(r, ney, nex, res, prev, prevnode); } else if (m[y][x] == '?') { } else { assert(false); } if (assign[y][x] != -1) { res.pb(assign[y][x]); } } void solve(int r)//2nd argument , in, is result of tsort { int n = convert(r); int tar = -10000; /* rep(i,r){ rep(j,m[i].size()){ if (assign[i][j] == -1)cout << m[i][j]; else cout << (int)assign[i][j]; } cout << endl; } */ rep(i, n) edge[i].clear(); vint in; rep(i, r) rep(j, m[i].size()) if (isupper(m[i][j])) { tsort(r, i, j, in, -1, assign[i][j]); } reverse(in.begin(), in.end()); rep(i, in.size()) { int now = in[i]; if (node[now].type == ALPHABET) { node[now].val = alpha[node[now].chara]; } else if (node[now].type == OUTPUT) { node[now].val = node[edge[now][0]].val; tar = now; } else if (node[now].type == AND) { node[now].take_and(node[edge[now][0]].val, node[edge[now][1]].val); } else if (node[now].type == OR) { node[now].take_or(node[edge[now][0]].val, node[edge[now][1]].val); } else if (node[now].type == NOT) { node[now].take_not(node[edge[now][0]].val); } } rep(i, node[tar].val.size()) cout << node[tar].val[i] << endl; } main() { int tc = 0; while (getline(cin, m[0])) { //if (tc++)puts(""); rep(i, 26) alpha[i].clear(); rep(i, 100) rep(j, 100) { assign[i][j] = -1; visited[i][j] = false; } int r = 1; while (getline(cin, m[r]) && m[r][0] != '*') { r++; } rep(i, r) while (m[i].size() < 100) { m[i] += ' '; } REP(i, r + 1, 100) { m[i].clear(); } string tmp; while (getline(cin, tmp) && tmp != "*") { rep(i, 26) alpha[i].pb(tmp[i] == '1' ? true : false); } solve(r); puts(""); } }
2a77dbb0401c0a53ea289c80f4011917e5ae973b
dc930010abc738d5a52b7a445f759f87ccb50132
/ms_mpi_static.cc
b30bc6b31a4f97c034f59b9c7269ffc13eabf372
[]
no_license
taffy128s/PP_HW2
fba9fb1cc9ee58bf71fbf6f78b11f2da353be493
9f5ef2f6eb5144cdc8f4d5137c3c134e9c3caae3
refs/heads/master
2021-07-18T20:09:11.483603
2017-10-27T15:17:05
2017-10-27T15:17:05
108,161,407
0
0
null
null
null
null
UTF-8
C++
false
false
3,590
cc
ms_mpi_static.cc
#define PNG_NO_SETJMP #include <mpi.h> #include <png.h> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> int calc(double y0, double x0) { int repeats = 0; double x = 0; double y = 0; double length_squared = 0; while (repeats < 100000 && length_squared < 4) { double temp = x * x - y * y + x0; y = 2 * x * y + y0; x = temp; length_squared = x * x + y * y; ++repeats; } return repeats; } void write_png(const char* filename, const int width, const int height, const int* buffer) { FILE* fp = fopen(filename, "wb"); assert(fp); png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); assert(png_ptr); png_infop info_ptr = png_create_info_struct(png_ptr); assert(info_ptr); png_init_io(png_ptr, fp); png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_write_info(png_ptr, info_ptr); size_t row_size = 3 * width * sizeof(png_byte); png_bytep row = (png_bytep)malloc(row_size); for (int y = 0; y < height; ++y) { memset(row, 0, row_size); for (int x = 0; x < width; ++x) { int p = buffer[(height - 1 - y) * width + x]; row[x * 3] = ((p & 0xf) << 4); } png_write_row(png_ptr, row); } free(row); png_write_end(png_ptr, NULL); png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); } int main(int argc, char** argv) { /* argument parsing */ assert(argc == 9); MPI_Init(&argc, &argv); int num_threads = strtol(argv[1], 0, 10); double left = strtod(argv[2], 0); double right = strtod(argv[3], 0); double lower = strtod(argv[4], 0); double upper = strtod(argv[5], 0); int width = strtol(argv[6], 0, 10); int height = strtol(argv[7], 0, 10); const char* filename = argv[8]; int rank, size; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); /* allocate memory for image */ int* image = new int[width * height]; assert(image); int divided_height = height / size; int start_height = divided_height * rank; int end_height = (rank == size - 1) ? height : start_height + divided_height; /* mandelbrot set */ for (int j = start_height; j < end_height; ++j) { double y0 = j * ((upper - lower) / height) + lower; for (int i = 0; i < width; ++i) { double x0 = i * ((right - left) / width) + left; image[j * width + i] = calc(y0, x0); } } MPI_Request req; if (size == 1) { write_png(filename, width, height, image); } else { if (rank == 0) { for (int i = 1; i < size - 1; i++) MPI_Recv(image + i * divided_height * width, divided_height * width, MPI_INT, i, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE); MPI_Recv(image + (size - 1) * divided_height * width, (divided_height + height % size) * width, MPI_INT, size - 1, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE); write_png(filename, width, height, image); } else if (rank == size - 1) { MPI_Send(image + (size - 1) * divided_height * width, (divided_height + height % size) * width, MPI_INT, 0, 0, MPI_COMM_WORLD); } else { MPI_Send(image + rank * divided_height * width, divided_height * width, MPI_INT, 0, 0, MPI_COMM_WORLD); } } delete[] image; MPI_Finalize(); }
34738a2c7e35c8638e020936cdd1b114ca188aeb
cf2756bdc6c366715f8e8bc953ba4b8e19765a4a
/cpp/oneapi/dal/backend/primitives/reduction/reduction_1d.hpp
fe64e2fc275dcd1542026613ab0c7061daa4e5db
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "Intel", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause", "MIT", "Zlib" ]
permissive
oneapi-src/oneDAL
c88b1f59218aa3b3b624a7b9f457bfc5823d583b
f4abbf2a18e27fa4165eb6b91b3456b5039e03a6
refs/heads/master
2023-09-06T00:47:52.411627
2023-09-05T22:29:42
2023-09-05T22:29:42
54,928,587
260
115
Apache-2.0
2023-09-14T17:51:26
2016-03-28T22:39:32
C++
UTF-8
C++
false
false
4,743
hpp
reduction_1d.hpp
/******************************************************************************* * Copyright 2023 Intel Corporation * * 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 "oneapi/dal/backend/primitives/common.hpp" #include "oneapi/dal/backend/primitives/ndarray.hpp" #include "oneapi/dal/backend/primitives/reduction/functors.hpp" #include "oneapi/dal/detail/profiler.hpp" namespace oneapi::dal::backend::primitives { #ifdef ONEDAL_DATA_PARALLEL template <typename Float, typename BinaryOp, typename UnaryOp> Float reduce_1d_impl(sycl::queue& q, const ndview<Float, 1>& input, const BinaryOp& binary = {}, const UnaryOp& unary = {}, const event_vector& deps = {}); template <typename Float, typename BinaryOp, typename UnaryOp> sycl::event reduce_1d_impl(sycl::queue& q, const ndview<Float, 1>& input, ndview<Float, 1>& output, const BinaryOp& binary = {}, const UnaryOp& unary = {}, const event_vector& deps = {}); /// Reduces `input` rows and returns the result /// /// @tparam Float Floating-point type used to perform computations /// @tparam BinaryOp Type of binary operator functor /// @tparam UnaryOp Type of unary operator functor /// /// @param[in] queue The SYCL queue /// @param[in] input The [n] input array /// @param[in] binary The binary functor that reduces two values into one /// @param[in] unary The unary functor that performs element-wise operation before reduction /// @param[in] deps The vector of `sycl::event`s that represents list of dependencies template <typename Float, typename BinaryOp, typename UnaryOp> inline Float reduce_1d(sycl::queue& q, const ndview<Float, 1>& input, const BinaryOp& binary = {}, const UnaryOp& unary = {}, const event_vector& deps = {}) { ONEDAL_PROFILER_TASK(reduction.reduce_1d, q); static_assert(dal::detail::is_tag_one_of_v<BinaryOp, reduce_binary_op_tag>, "BinaryOp must be a special binary operation defined " "at the primitives level"); static_assert(dal::detail::is_tag_one_of_v<UnaryOp, reduce_unary_op_tag>, "UnaryOp must be a special unary operation defined " "at the primitives level"); return reduce_1d_impl(q, input, binary, unary, deps); } /// Reduces `input` rows and put the result in output /// /// @tparam Float Floating-point type used to perform computations /// @tparam BinaryOp Type of binary operator functor /// @tparam UnaryOp Type of unary operator functor /// /// @param[in] queue The SYCL queue /// @param[in] input The [n] input array /// @param[out] output The [1] array where the output is put /// @param[in] binary The binary functor that reduces two values into one /// @param[in] unary The unary functor that performs element-wise operation before reduction /// @param[in] deps The vector of `sycl::event`s that represents list of dependencies template <typename Float, typename BinaryOp, typename UnaryOp> inline sycl::event reduce_1d(sycl::queue& q, const ndview<Float, 1>& input, ndview<Float, 1>& output, const BinaryOp& binary = {}, const UnaryOp& unary = {}, const event_vector& deps = {}) { ONEDAL_PROFILER_TASK(reduction.reduce_1d, q); static_assert(dal::detail::is_tag_one_of_v<BinaryOp, reduce_binary_op_tag>, "BinaryOp must be a special binary operation defined " "at the primitives level"); static_assert(dal::detail::is_tag_one_of_v<UnaryOp, reduce_unary_op_tag>, "UnaryOp must be a special unary operation defined " "at the primitives level"); return reduce_1d_impl(q, input, output, binary, unary, deps); } #endif } // namespace oneapi::dal::backend::primitives
87b0934543e4e897619a80d0e227b82133d3876c
fd0b0d053e7d67487baa2f48d294704acacf5a32
/Linked_list_bag/lbag.h
f6b48715c707c544596bc3ea19fcff2c509d1001
[]
no_license
CanavanNeeson/CSCI_60
dc7037c054603f8cc45d14215c3a71dfec632320
8aefa05d3bb45966bad387468cd6684ec0b9eff6
refs/heads/master
2020-04-14T04:08:52.927046
2018-12-31T00:29:07
2018-12-31T00:29:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,273
h
lbag.h
#ifndef LBAG_H #define LBAG_H #include <cstdlib> #include <ostream> #include <iostream> #include "node.h" template <class T> class lbag { public: typedef T value_type; typedef std::size_t size_type; // pre: none // post: creates an empty lbag lbag(); // pre: none // post: creates an lbag that is a copy of given lbag lbag(const lbag &); //Returns all memory to the runtime environment and sets head and tail to nullptr ~lbag(); //pre: none //post: change this bag to be a copy of the parameter bag void operator =(const lbag &); //pre: none //post: returns the number of nodes in the linked list size_type size() const; //pre: none //post: returns the number of times the parameter value appears in the bag size_type count(const T &) const; //pre: none //Post: the parameter value is inserted at the head of the bag void insert(const T &); //pre: none //post: our bag includes all of its elements, followed by all of the parameter bag's elements void operator +=(const lbag &);//homework //pre: none //post: removes the first instance of the parameter value in the bag, if there is one. bool erase_one(const T &);//homework //pre: none //post: removes all instances of the parameter value in the bag. size_type erase(const T &);//homework template <class T2>//Don't use class's type variable, because this is NOT part of the class friend std::ostream& operator <<(std::ostream& out, const lbag<T2> &); private: node<T> *head, *tail; }; template <class T> lbag<T> operator +(const lbag<T> &, const lbag<T> &); //------------------------------------------------------------------------ template <class T> lbag<T>::lbag(){ head = nullptr; tail = nullptr; } template <class T> lbag<T>::lbag(const lbag<T> & b){ head = tail = nullptr; list_copy(b.head, b.tail, head, tail); } template <class T> lbag<T>::~lbag(){ list_clear(head, tail); head = tail = nullptr; } template <class T> void lbag<T>::operator =(const lbag<T> & b){ list_clear(head, tail); head = tail = nullptr; list_copy(b.head, b.tail, head, tail); } template <class T> typename lbag<T>::size_type lbag<T>::size() const{ list_size(head); size_type count = 0; for(node<T>* p = head; p!=nullptr; p=p->link()) count++; return count; } template <class T> typename lbag<T>::size_type lbag<T>::count(const T & value) const{ size_type count = 0; for(node<T>* p = head; p!=nullptr; p=p->link()){ if(p->data()==value) count++; } return count; } template <class T> void lbag<T>::insert(const T & value){ list_head_insert(head, tail, value); } template <class T> bool lbag<T>::erase_one(const T & value) { node<T> *temp = head, *prevtemp = nullptr; while (temp != nullptr) { if (temp->data() == value) { if (temp == head) { // std::cout << "H\n"; head = head->link(); delete temp; } /*else if (temp == tail) { std::cout << "T\n"; prevtemp->set_link(nullptr); delete temp; } */else { // std::cout << '*' << prevtemp << '*'; prevtemp->set_link(temp->link()); delete temp; } return true; } else { prevtemp = temp; temp = temp->link(); } } return false; } template <class T> lbag<int>::size_type lbag<T>::erase(const T & value) { size_type count = 0; while (this->erase_one(value)) ++count; return count; } template <class T> void lbag<T>::operator +=(const lbag<T>& r) { node<T> *wtemp = tail, *rtemp = r.head; while (rtemp != nullptr) { wtemp->set_link(new node<T>(rtemp->data(), nullptr)); rtemp = rtemp->link(); wtemp = wtemp->link(); } } template <class T> lbag<T> operator +(const lbag<T> & r, const lbag<T> & l) { lbag<T> ret(r); ret += l; return ret; } template <class T> std::ostream& operator <<(std::ostream& out, const lbag<T> & b){//Use << from linked list toolkit. Problems? out<<b.head; return out; } // template <class T> #endif // LBAG_H
211dfcda0c87646184ec90756262760d6bf5900f
bb97a4efbfbd153cc9f9fe1889e7a8eb447c3c40
/main.cpp
f22f41a73a5dae9b32e405125e0c0b73e2d240a5
[]
no_license
Pcornat/VulkanTutorial
285fbe8d5de2fbccb9320040c97a3764ae95793b
c2277cdd8e5e0ffee295fa9289bb1d97e94f21e8
refs/heads/master
2021-06-27T16:32:28.995163
2020-11-01T13:43:34
2020-11-01T13:43:34
163,547,989
0
0
null
null
null
null
UTF-8
C++
false
false
269
cpp
main.cpp
#include <iostream> #include "hello_triangle_app.h" int main() { // try { HelloTriangleApp coucou("Hello", 1280, 720); coucou.run(); // } catch (const std::exception &e) { // std::cerr << e.what() << std::endl; // return EXIT_FAILURE; // } return EXIT_SUCCESS; }
24829d8c0d7e18249cee15bccbed924edff87441
ffb789dd717001da2da181593ecb562f19a210d0
/src/patch.cpp
fb4c091c2c0e23ccb59d1ca10aa14ced1168d64e
[]
no_license
lithium/ym2612-synth
26c7188667ed1ae7dcaee85c91b4adfd99eae27e
b541d01ccdc4cfb228a8f1a8fb17d27985530fb2
refs/heads/master
2020-03-12T16:49:05.209826
2018-06-15T05:33:44
2018-06-15T05:33:44
130,724,284
1
0
null
null
null
null
UTF-8
C++
false
false
348
cpp
patch.cpp
#include "patch.h" const struct ym2612_patch_t GrandPianoPatch = { 2, 6, 0, 0, 0, 0, { {1, 7, 35, 1, 31, 5, 2, 1, 1, 0, 0}, {13, 0, 45, 2, 25, 5, 2, 1, 1, 0, 0}, {3, 3, 38, 1, 31, 5, 2, 1, 1, 0, 0}, {1, 0, 0, 2, 20, 7, 2, 6, 10, 0, 0}, }, 0, "Grand Piano\0\0\0\0", 0 };
f010efe982afc792ac424a23fcfc5ce3303026c8
0c95b4de0c9793908b068667366bedd000f6e800
/Psong/Ball.hpp
078b507d1a692fdc337be18b7f791ed022b146b5
[]
no_license
aclonegeek/Psong
a32704e99944e306455778eb450130ecb2466881
3b9eb866751dbb7ec04276b8c7af4e3a7306334a
refs/heads/master
2021-01-21T14:19:55.101355
2016-07-25T00:58:52
2016-07-25T00:58:52
57,413,296
0
0
null
null
null
null
UTF-8
C++
false
false
359
hpp
Ball.hpp
#pragma once #include "Entity.hpp" #include "Paddle.hpp" class Ball : public Entity { public: Ball(Paddle& paddle1, Paddle& paddle2); void update(const sf::Time dt, const int windowWidth, const int windowHeight); void reset(const int windowWidth, const int windowHeight); private: Paddle* m_paddle1; Paddle* m_paddle2; const float m_speed = 200.0f; };
91470ed501f7599671b7588f5c458d354e1da8b6
88678d6377075eb1589fb53e59c908dbc7f26071
/angel_1_1/Code/Angel/CVarChangedAIEvent.h
31a387ef94c474244736d420d52e5ce18a8c530c
[]
no_license
chrishaukap/GameDev
89d76eacdae34ae96e83496f2c34c61e101d2600
fb364cea6941e9b9074ecdd0d9569578efb0f937
refs/heads/master
2020-05-28T11:23:41.750257
2013-08-08T21:59:30
2013-08-08T21:59:30
2,401,748
1
0
null
null
null
null
UTF-8
C++
false
false
380
h
CVarChangedAIEvent.h
#pragma once #include "StringUtil.h" #include "Brain.h" class ConsoleVariable; class OnConsoleVariableChangedAIEvent : public AIEvent { public: virtual OnConsoleVariableChangedAIEvent* Initialize( const String& cVarId ); virtual void Update(float dt); private: ConsoleVariable* _variable; String _lastValue; }; DECLARE_AIEVENT_BASE( OnConsoleVariableChangedAIEvent )
5f9b24143b2c1ca2a8569d0c27a185bf2141ba65
fa7d6675fe20d6a4c08fcb5721f0569572f857c8
/BerryCPP/berry/berry_gl_client/source/DrawWithVAO.h
31ead9ff6d2dae933ca1212284c83886dc9bfe4a
[]
no_license
yunyou730/berry_project
47cf5876b7cbdc3611c18bef91556aaaabcca678
1b4a96b0bfaca2fce2d8e4997dda326aec268898
refs/heads/master
2022-11-09T04:29:39.427913
2020-06-17T14:41:55
2020-06-17T14:41:55
260,653,922
0
0
null
null
null
null
UTF-8
C++
false
false
553
h
DrawWithVAO.h
#pragma once #include <GL/glew.h> #include <GLFW/glfw3.h> #include "DrawTestcaseBase.h" #include "Renderer.h" #include "VertexBuffer.h" /* Draw with simple VAO ,VBO */ namespace berry { class DrawWithVAO : public berry::DrawTestcaseBase { public: ~DrawWithVAO(); virtual void Prepare() override; virtual void Renderer(berry::Renderer* renderer) override; private: GLuint m_vao = 0; float* m_vertice = nullptr; berry::VertexBuffer* m_vertexBuffer = nullptr; }; }
619e6a5c2bfc5849ddbbefa8c453648b01cc9ae1
d106ecb5f5526d265fd435ed4e1fb02c48a4bed7
/1. 算法部分/第9章 动态规划/第二节 背包问题/3.采药/medic.cpp
28728874e063590cb5483e94fb6cd9c6e707811e
[]
no_license
Lucifer-ww/NOIP_ReC
acd53ccd6fc8a845f8fdba87ed12ec6811154d6c
ed20057f68bd7151c9d9e7067290b7cb0e637a9a
refs/heads/main
2023-01-07T14:52:51.502799
2020-11-04T06:32:27
2020-11-04T06:32:27
309,902,344
43
19
null
null
null
null
UTF-8
C++
false
false
620
cpp
medic.cpp
#include <iostream> #include <cassert> using namespace std; int tt[200]; int vv[200]; int dp[1005][105]; int main () { int T, M; cin >> T >> M; assert(1 <= T && T <= 1000); assert(1 <= M && M <= 100); int i, j; for (i = 1; i <= M; i++) { cin >> tt[i] >> vv[i]; assert(1 <= tt[i] && tt[i] <= 100); assert(1 <= vv[i] && vv[i] <= 100); } for (i = 1; i <= T; i++) { for (j = 1; j <= M; j++) { int a = dp[i][j - 1]; if (i >= tt[j]) { int b = dp[i - tt[j]][j - 1] + vv[j]; if (b > a) a = b; } dp[i][j] = a; } } cout << dp[T][M] << endl; {char c;assert(!(cin >> c));} return 0; }
d86cfed7ed852b8247179f0758b8f82afcbcae31
23ed90539a98ab6a1a053ea25e81ad892423f899
/add_protein_window.h
74659638438838175e3e47b48c9ab0c086532107
[]
no_license
moukraintsev/oop_lab_1
27ae35ad27480286705d29ca2123935d2f9da39a
2d075b1e91b647da060bbf0df5e5bd2f3c057475
refs/heads/master
2023-01-24T08:31:40.468003
2020-11-30T13:59:02
2020-11-30T13:59:02
304,902,528
0
0
null
null
null
null
UTF-8
C++
false
false
411
h
add_protein_window.h
#ifndef ADD_PROTEIN_WINDOW_H #define ADD_PROTEIN_WINDOW_H #include <QMainWindow> namespace Ui { class add_protein_window; } class add_protein_window : public QMainWindow { Q_OBJECT public: explicit add_protein_window(QWidget *parent = nullptr); ~add_protein_window(); private slots: void on_pushButton_clicked(); private: Ui::add_protein_window *ui; }; #endif // ADD_PROTEIN_WINDOW_H
d0510cf11899712310ca18bb6dea2b2100aba3ee
827405b8f9a56632db9f78ea6709efb137738b9d
/CodingWebsites/URAL/Volume1/1077#3.cpp
847a92a1f48e882718ce3601afc6cea6a6be3f4f
[]
no_license
MingzhenY/code-warehouse
2ae037a671f952201cf9ca13992e58718d11a704
d87f0baa6529f76e41a448b8056e1f7ca0ab3fe7
refs/heads/master
2020-03-17T14:59:30.425939
2019-02-10T17:12:36
2019-02-10T17:12:36
133,694,119
0
0
null
null
null
null
GB18030
C++
false
false
2,920
cpp
1077#3.cpp
/* 用最小生成树的思想。 每次加入一条边,如果边连接的两点已经相连,则形成了一个环,找到这个环并输出,不加入这条边。 如果两点不相连,则加入这条边。 相连部分永远保持为一棵树(或几棵树)。所以从起点找终点的DFS就很好写了 */ #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #define inf 0x5fffffff #define FOR(i,n) for(long long (i)=1;(i)<=(n);(i)++) #define For(i,n) for(long long (i)=0;(i)<(n);(i)++) #define out(i) <<#i<<"="<<(i)<<" " #define OUT1(a1) cout out(a1) <<endl #define OUT2(a1,a2) cout out(a1) out(a2) <<endl #define OUT3(a1,a2,a3) cout out(a1) out(a2) out(a3)<<endl using namespace std; //图 struct ArcNode{ int from,to; ArcNode *next; }Arc[40000]; struct Node{ bool vis; int path; ArcNode *List; void init(){vis=0;List=NULL;path=-1;} }node[200]; void AddArc(int i){ Arc[2*i].next=node[Arc[2*i].from].List; node[Arc[2*i].from].List=&Arc[2*i]; Arc[2*i+1].next=node[Arc[2*i+1].from].List; node[Arc[2*i+1].from].List=&Arc[2*i+1]; } void MinusArc(int i){ node[Arc[2*i].from].List=node[Arc[2*i].from].List->next; node[Arc[2*i+1].from].List=node[Arc[2*i+1].from].List->next; } int N,M,ALL;//点,边 //并查集 int U[200]; int Find(int x){ if(x==U[x]) return x; else return U[x]=Find(U[x]); } void Union(int x,int y){ //printf("连接%d与%d\n",x+1,y+1); int a=Find(x),b=Find(y); if(a!=b) U[a]=b,ALL--; } // void DFS(int i,int depth,int target){ //OUT2(i+1,depth); //For(t,depth) printf(" "); //printf("->%d\n",i+1); if(i==target){ int k=i; printf("%d",depth); For(j,depth){ printf(" %d",k+1); k=node[k].path; } cout<<endl; return; } node[i].vis=1; ArcNode *temp=node[i].List; while(temp){ if(!node[temp->to].vis||temp->to==target){ node[temp->to].path=i; DFS(temp->to,depth+1,target); } temp=temp->next; } } int main(void) { freopen("1077.txt","r",stdin); while(cin>>N>>M){ For(i,N) { node[i].init(); U[i]=i; } //读取 ALL=N; For(i,M){ scanf("%d%d",&Arc[2*i].from,&Arc[2*i].to); Arc[2*i].from--;Arc[2*i].to--; Arc[2*i+1].from=Arc[2*i].to;Arc[2*i+1].to=Arc[2*i].from; AddArc(i); Union(Arc[2*i].from,Arc[2*i].to); } cout<<M-N+ALL<<endl; For(i,N) U[i]=i,node[i].List=NULL; For(i,M) Arc[2*i].next=NULL,Arc[2*i+1].next=NULL; For(i,M){ //printf("第%d条边\n",i+1); int a=Find(Arc[2*i].from),b=Find(Arc[2*i].to); if(a==b){ //找环(找from到to的路径) //printf("\t起点:%d 终点 :%d \n",Arc[2*i].from+1,Arc[2*i].to+1); DFS(Arc[2*i].from,1,Arc[2*i].to); For(j,N) node[j].vis=0; } else{ AddArc(i); Union(Arc[2*i].from,Arc[2*i].to); } } } return 0; }
524e779ee4880249babc55d7dd8e30acc70eb0a5
e2283e0f8d4477e6d81a71b22a305788cd238ba9
/Outrun/ObjectsGenerator.cpp
984f1209205cb5c05055268c0c34aefa5c77ab03
[]
no_license
SilviuShader/TemaPOO
fff2a6185d91583f8345e949000e0044e88aa6cb
cf316a8d45c9497ac365ae4e0ac925539c875290
refs/heads/master
2021-02-08T21:17:02.231058
2020-09-23T12:05:23
2020-09-23T12:05:23
244,197,904
2
0
null
null
null
null
UTF-8
C++
false
false
8,946
cpp
ObjectsGenerator.cpp
#include "pch.h" #include "ObjectsGenerator.h" using namespace std; ObjectsGenerator::ObjectsGenerator(shared_ptr<Texture2DManager> contentManager) : m_zone(ObjectsGenerator::Zone::Beach), m_lastBorder(false), m_borderAccumulatedDistance(0.0f), m_accumulatedDistance(0.0f), m_accumulatedZone(0.0f), m_accumulatedCarChance(0.0f), m_accumulatedMotorChance(0.0f), m_accumulatedLifeChance(0.0f) { m_prevZone = m_zone; shared_ptr<Texture2D> border = contentManager->Load("Border.png"); m_textures["Border"] = border; shared_ptr<Texture2D> palmTree = contentManager->Load("Palm.png"); m_textures["Palm"] = palmTree; shared_ptr<Texture2D> tower = contentManager->Load("Tower.png"); m_textures["Tower"] = tower; shared_ptr<Texture2D> mountains = contentManager->Load("Mountains.png"); m_textures["Mountains"] = mountains; shared_ptr<Texture2D> car = contentManager->Load("CarBack.png"); m_textures["CarBack"] = car; car = contentManager->Load("CarFront.png"); m_textures["CarFront"] = car; shared_ptr<Texture2D> motor = contentManager->Load("MotorBack.png"); m_textures["MotorBack"] = motor; shared_ptr<Texture2D> life = contentManager->Load("Life.png"); m_textures["Life"] = life; } ObjectsGenerator::~ObjectsGenerator() { for (const auto& [k, v] : m_textures) m_textures[k].reset(); m_textures.clear(); } void ObjectsGenerator::Update(Game* game, float deltaTime) { if (game->GetPlayer() == nullptr) return; BorderSpawnUpdate(game, deltaTime); ZoneSpawnUpdate(game, deltaTime); CarSpawnUpdate(game, deltaTime); MotorSpawnUpdate(game, deltaTime); LifeSpawnUpdate(game, deltaTime); } void ObjectsGenerator::BorderSpawnUpdate(Game* game, float deltaTime) { float playerSpeed = game->GetPlayer()->GetSpeed(); list<shared_ptr<GameObject> >& gameObjects = game->GetGameObjects(); m_borderAccumulatedDistance += playerSpeed * deltaTime; if (m_borderAccumulatedDistance >= BORDER_ACCUMULATE_TO_SPAWN) { shared_ptr<GameObject> gameObject = make_shared<GameObject>(game); shared_ptr<ObjectTranslator> objTranslator = make_shared<ObjectTranslator>(gameObject.get()); gameObject->AddComponent(objTranslator); gameObject->GetTransform()->SetPositionX((m_lastBorder ? 1.0f : -1.0f) * (game->GetRoadWidth() + 0.05f)); shared_ptr<SpriteRenderer> spriteRenderer = make_shared<SpriteRenderer>(gameObject.get(), m_textures["Border"]); gameObject->AddComponent(spriteRenderer); gameObjects.push_back(gameObject); m_borderAccumulatedDistance -= BORDER_ACCUMULATE_TO_SPAWN; m_lastBorder = !m_lastBorder; } } void ObjectsGenerator::ZoneSpawnUpdate(Game* game, float deltaTime) { float playerSpeed = game->GetPlayer()->GetSpeed(); list<shared_ptr<GameObject> >& gameObjects = game->GetGameObjects(); m_accumulatedDistance += playerSpeed * deltaTime; m_accumulatedZone += playerSpeed * deltaTime; if (m_accumulatedZone >= ACCUMULATE_TO_CHANGE_ZONE) { m_prevZone = m_zone; m_zone = (ObjectsGenerator::Zone)(rand() % ((int)ObjectsGenerator::Zone::Last)); if (m_zone == m_prevZone) m_zone = (ObjectsGenerator::Zone)(((int)m_zone + 1) % (int)ObjectsGenerator::Zone::Last); m_accumulatedZone -= ACCUMULATE_TO_CHANGE_ZONE; } if (m_accumulatedDistance > ACCUMULATE_TO_SPAWN) { string textureIndex = ""; float prevChance = (m_accumulatedZone / ACCUMULATE_TO_CHANGE_ZONE); switch (Zone crtZone = ((Utils::RandomFloat() > prevChance) ? m_prevZone : m_zone); crtZone) { case ObjectsGenerator::Zone::Beach: textureIndex = "Palm"; break; case ObjectsGenerator::Zone::City: textureIndex = "Tower"; break; case ObjectsGenerator::Zone::Mountains: textureIndex = "Mountains"; break; } if (m_textures.find(textureIndex) != m_textures.end()) { shared_ptr<GameObject> gameObject = make_shared<GameObject>(game); shared_ptr<ObjectTranslator> objTranslator = make_shared<ObjectTranslator>(gameObject.get()); gameObject->AddComponent(objTranslator); float displacement = Utils::RandomFloat() * MAX_OBJECT_DISPLACEMENT; gameObject->GetTransform()->SetPositionX((rand() % 2 ? 1.0f : -1.0f) * (game->GetRoadWidth() / 2.0f + 3.0f + displacement)); shared_ptr<SpriteRenderer> spriteRenderer = make_shared<SpriteRenderer>(gameObject.get(), m_textures[textureIndex]); gameObject->AddComponent(spriteRenderer); shared_ptr<Killer> killer = make_shared<Killer>(gameObject.get()); gameObject->AddComponent(killer); gameObjects.push_back(gameObject); m_accumulatedDistance -= ACCUMULATE_TO_SPAWN; } } } void ObjectsGenerator::CarSpawnUpdate(Game* game, float deltaTime) { list<shared_ptr<GameObject> >& gameObjects = game->GetGameObjects(); m_accumulatedCarChance += deltaTime * Utils::RandomFloat(); if (m_accumulatedCarChance >= CAR_CHANCE) { bool goingForward = rand() % 2; shared_ptr<GameObject> gameObject = make_shared<GameObject>(game); shared_ptr<ObjectTranslator> objTranslator = make_shared<ObjectTranslator>(gameObject.get()); objTranslator->SetObjectSpeed(Utils::Lerp(Utils::RandomFloat(), MIN_CAR_SPEED, MAX_CAR_SPEED) * (goingForward ? -1.0f : 1.0f)); gameObject->AddComponent(objTranslator); gameObject->GetTransform()->SetPositionX((goingForward ? 1.0f : -1.0f) * (game->GetRoadWidth() / 2.0f)); shared_ptr<SpriteRenderer> spriteRenderer = make_shared<SpriteRenderer>(gameObject.get(), m_textures[(goingForward ? "CarBack" : "CarFront")]); gameObject->AddComponent(spriteRenderer); shared_ptr<Killer> killer = make_shared<Killer>(gameObject.get()); gameObject->AddComponent(killer); gameObjects.push_back(gameObject); m_accumulatedCarChance -= CAR_CHANCE; } } void ObjectsGenerator::MotorSpawnUpdate(Game* game, float deltaTime) { list<shared_ptr<GameObject> >& gameObjects = game->GetGameObjects(); m_accumulatedMotorChance += deltaTime * Utils::RandomFloat(); if (m_accumulatedMotorChance >= MOTOR_CHANCE) { shared_ptr<GameObject> gameObject = make_shared<GameObject>(game); shared_ptr<ObjectTranslator> objTranslator = make_shared<ObjectTranslator>(gameObject.get()); objTranslator->SetObjectSpeed(Utils::Lerp(Utils::RandomFloat(), MIN_CAR_SPEED, MAX_CAR_SPEED) * -1.0f); gameObject->AddComponent(objTranslator); gameObject->GetTransform()->SetPositionX(0.0f); shared_ptr<SpriteRenderer> spriteRenderer = make_shared<SpriteRenderer>(gameObject.get(), m_textures["MotorBack"]); gameObject->AddComponent(spriteRenderer); shared_ptr<Killer> killer = make_shared<Killer>(gameObject.get()); gameObject->AddComponent(killer); gameObjects.push_back(gameObject); m_accumulatedMotorChance -= MOTOR_CHANCE; } } void ObjectsGenerator::LifeSpawnUpdate(Game* game, float deltaTime) { list<shared_ptr<GameObject> >& gameObjects = game->GetGameObjects(); m_accumulatedLifeChance += deltaTime * Utils::RandomFloat(); if (m_accumulatedLifeChance >= LIFE_CHANCE) { shared_ptr<GameObject> gameObject = make_shared<GameObject>(game); shared_ptr<ObjectTranslator> objTranslator = make_shared<ObjectTranslator>(gameObject.get()); gameObject->AddComponent(objTranslator); gameObject->GetTransform()->SetPositionX((rand() % 2 ? 1.0f : -1.0f) * ((game->GetRoadWidth() / 2.0f) * Utils::RandomFloat())); shared_ptr<SpriteRenderer> spriteRenderer = make_shared<SpriteRenderer>(gameObject.get(), m_textures["Life"]); gameObject->AddComponent(spriteRenderer); shared_ptr<Life> life = make_shared<Life>(gameObject.get()); gameObject->AddComponent(life); gameObjects.push_back(gameObject); m_accumulatedLifeChance -= LIFE_CHANCE; } }
90a686b5b4572a7c9cddb28f911db8cebfc9b6e6
3c2dbdfd5b9d1d49bf37066e18f1c5bb7e965159
/ANano_xBee/ANano_xBee.ino
2505e3ebeec362babde67f7bad99190251a8e780
[]
no_license
werdroid/Coupe2017
da96c1b8439146377c711e5cb7e58be376437d35
864c1546792bbb25548f6a6c8ac9e534f4d84710
refs/heads/master
2023-04-30T16:54:39.851246
2019-06-15T21:00:51
2019-06-15T21:00:51
76,724,798
2
0
null
2023-04-17T18:45:24
2016-12-17T13:11:46
JavaScript
UTF-8
C++
false
false
1,344
ino
ANano_xBee.ino
/*!!!!!!!!!!!!!! !! ATTENTION !! !!!!!!!!!!!!!!! Choisir Type de Carte = Arduino Uno (et non Nano !) pour le téléversement ! */ const uint8_t PIN_MOTOR = 2; const uint8_t PIN_LED = 13; void setup() { Serial.begin(9600); pinMode(PIN_LED, OUTPUT); // sets the digital pin 13 as output pinMode(PIN_MOTOR, OUTPUT); delay(200); digitalWrite(PIN_MOTOR, LOW); delay(200); //test_activer_experience(); } void loop() { char c; if(Serial.available() > 0) { c = Serial.read(); switch(c) { case '1': allumerLED(true); break; case '0': allumerLED(false); break; case '7': Serial.print('A'); break; case '9': activer_experience(); break; } } } void activer_experience() { Serial.print('!'); digitalWrite(PIN_MOTOR, HIGH); delay(90000); digitalWrite(PIN_MOTOR, LOW); Serial.print('.'); } void allumerLED(bool allumer) { if(allumer) digitalWrite(PIN_LED, HIGH); else digitalWrite(PIN_LED, LOW); } void test_activer_experience() { delay(1000); allumerLED(true); delay(200); allumerLED(false); delay(200); allumerLED(true); delay(200); allumerLED(false); delay(200); allumerLED(true); delay(200); allumerLED(false); delay(200); activer_experience(); }
d54ecdf188dfc584004f684f8ef6ecd455b69871
7a310d01d1a4361fd06b40a74a2afc8ddc23b4d3
/src/MainFrame_InitTerm.cpp
faf452cc0aae18b422a6d57eb992c77a65be2392
[]
no_license
plus7/DonutG
b6fec6111d25b60f9a9ae5798e0ab21bb2fa28f6
2d204c36f366d6162eaf02f4b2e1b8bc7b403f6b
refs/heads/master
2020-06-01T15:30:31.747022
2010-08-21T18:51:01
2010-08-21T18:51:01
767,753
1
2
null
null
null
null
SHIFT_JIS
C++
false
false
25,661
cpp
MainFrame_InitTerm.cpp
/** * @file MainFrame_InitTerm.cpp * @brief CMainFrame の 初期化/終了処理 * @note * +++ MainFrame.cpp から分離. */ #include "stdafx.h" #include "MainFrame.h" #include "Donut.h" #include "DialogHook.h" #if defined USE_ATLDBGMEM #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #include "nsICookieManager.h" #include "nsIBrowserHistory.h" #include "nsICacheService.h" //void _PrivateTerm(); // =========================================================================== // 初期化 CMainFrame::CMainFrame() : m_FavoriteMenu(this, ID_INSERTPOINT_FAVORITEMENU) , m_FavGroupMenu(this, ID_INSERTPOINT_GROUPMENU) #ifndef NO_STYLESHEET , m_styleSheetMenu(ID_INSERTPOINT_CSSMENU, _T("(empty)"), ID_INSERTPOINT_CSSMENU, ID_INSERTPOINT_CSSMENU_END) #endif , m_LinkBar(this, ID_INSERTPOINT_FAVORITEMENU) , m_nBackUpTimerID(0) , m_wndMDIClient(this, 1) , CDDEMessageHandler<CMainFrame>( _T("Donut") ) , m_hWndFocus(NULL) , m_ExplorerBar(m_wndSplit, m_wndAdditionalSplit) , m_ScriptMenu(ID_INSERTPOINT_SCRIPTMENU, _T("(empty)"), ID_INSERTPOINT_SCRIPTMENU, ID_INSERTPOINT_SCRIPTMENU_END) , m_DropFavoriteMenu(this, ID_INSERTPOINT_FAVORITEMENU) , m_DropFavGroupMenu(this, ID_INSERTPOINT_GROUPMENU) , m_DropScriptMenu(ID_INSERTPOINT_SCRIPTMENU, _T("(empty)"), ID_INSERTPOINT_SCRIPTMENU, ID_INSERTPOINT_SCRIPTMENU_END) , m_bShow(FALSE) , m_hGroupThread(NULL) , m_OnUserOpenFile_nCmdShow(0) , m_nMenuBarStyle(-1) //+++ , m_nBgColor(-1) //+++ , m_bTray(0) //+++ , m_bFullScreen(0) //+++ , m_bOldMaximized(0) //+++ //, m_bMinimized(0) //+++ , m_strIcon() //+++ , m_strIconSm() //+++ { g_pMainWnd = this; //+++ CreateEx()中にプラグイン初期化とかで参照されるので、呼び元でなく CMainFreameで設定するように変更. } //+++ 各初期化処理ごとに関数分離 /** メインフレーム作成. 各種初期化. */ LRESULT CMainFrame::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/) { CFavoritesMenuOption::Add(m_hWnd); init_font(); // フォント初期化 m_wndDebug.Create(); // デバッグウィンドウの作成 init_menus_infomation(); // メニュー情報の初期化 HWND hWndCmdBar = init_commandBarWindow(); // メニューバーの初期化 HWND hWndToolBar = init_toolBar(); // ツールバーの初期化 HWND hWndAddressBar = init_addressBar(); // アドレスバーの初期化 HWND hWndSearchBar = init_searchBar(); // 検索バーの初期化 HWND hWndMDITab = init_tabCtrl(); // タブバーの初期化 HWND hWndLinkBar = init_linkBar(); // リンクバーの初期化 init_rebar(); // リバーの初期化 init_statusBar(); // ステータスバーの初期化 init_progressBar(); // プログレスバーの初期化 init_pluginManager(); // プラグインマネージャの初期化 // 各種バーの配置 init_band_position( hWndCmdBar,hWndToolBar,hWndAddressBar,hWndMDITab,hWndLinkBar,hWndSearchBar ); init_loadStatusBarState(); // ステータスバーの状態設定 init_mdiClientWindow(); // init_splitterWindow(); // 窓分割(エクスプローラバーと通常ページ)の初期化 init_findBar(); // ページ検索バーの初期化 init_explorerBar(); // エクスプローラバーの初期化 init_mdiClient_misc(hWndCmdBar, hWndToolBar); // mdi-client関係の雑多な設定 CmdUIAddToolBar(hWndToolBar); // set up UI //CmdUIAddToolBar(m_SearchBar.m_wndToolBar); // set up UI CmdUIAddToolBar(m_SearchBar.GetHWndToolBar()); // set up UI init_setUserAgent(); // ユーザーエージェントの設定 init_message_loop(); // メッセージループの準備 init_mdiTab(); // タブに関する設定 //SetAutoBackUp();//OnBackUpOptionChanged(0,0,0);// OnCreate後の処理で別途呼び出すようにした. RegisterDragDrop(); //DragAcceptFiles(); // ドラッグ&ドロップ準備 CCriticalIdleTimer::InstallCriticalIdleTimer(m_hWnd, ID_VIEW_IDLE); init_sysMenu(); // システムメニューに追加 ::SetTimer(m_hWnd, ENT_READ_ACCEL, 200, NULL); // アクセラキー読み込み. 遅延させるためにWM_TIMERで処理. InitSkin(); //スキンを初期化 CDonutSimpleEventManager::RaiseEvent(EVENT_INITIALIZE_COMPLETE); // イベント関係の準備 //CDialogHook::InstallHook(m_hWnd); // ダイアログ関係の準備 init_loadPlugins(); // プラグインを読み込む UpdateLayout(); // 画面更新 return 0; //return lRet; } /// フォント void CMainFrame::init_font() { CIniFileI prFont( g_szIniFileName, _T("Main") ); MTL::CLogFont lf; lf.InitDefault(); if ( lf.GetProfile(prFont) ) { CFontHandle font; MTLVERIFY( font.CreateFontIndirect(&lf) ); if (font.m_hFont) { if (m_font.m_hFont != NULL) m_font.DeleteObject(); m_font.Attach(font.m_hFont); SetFont(m_font); } } } // //デバッグウィンドウの作成 // m_wndDebug.Create(); /// initialize menus' infomation void CMainFrame::init_menus_infomation() { CMenuHandle menu = m_hMenu; CMenuHandle menuFav = menu.GetSubMenu(_nPosFavoriteMenu); m_FavoriteMenu.InstallExplorerMenu(menuFav); m_FavoriteMenu.SetTargetWindow(m_hWnd); CMenuHandle menuGroup = menuFav.GetSubMenu(_nPosFavGroupMenu); m_FavGroupMenu.InstallExplorerMenu(menuGroup); m_FavGroupMenu.SetTargetWindow(m_hWnd); #ifndef NO_STYLESHEET CMenuHandle menuCss = menu.GetSubMenu(_nPosCssMenu); CMenuHandle menuCssSub = menuCss.GetSubMenu(_nPosSubCssMenu); m_styleSheetMenu.SetRootDirectoryPath( Misc::GetExeDirectory() + _T("CSS") ); m_styleSheetMenu.SetTargetWindow(m_hWnd); m_styleSheetMenu.ResetIDCount(TRUE); m_styleSheetMenu.InstallExplorerMenu(menuCssSub); #endif m_ScriptMenuMst.LoadMenu(IDR_SCRIPT); m_ScriptMenu.SetRootDirectoryPath( Misc::GetExeDirectory() + _T("Script") ); m_ScriptMenu.SetTargetWindow(m_hWnd); m_ScriptMenu.ResetIDCount(TRUE); m_ScriptMenu.InstallExplorerMenu(m_ScriptMenuMst); OnMenuGetFav(); //initialize custom context dropdown OnMenuGetFavGroup(); OnMenuGetScript(); CMenuHandle menuEncode = menu.GetSubMenu(_nPosEncodeMenu); m_MenuEncode.Init(menuEncode, m_hWnd, _nPosEncodeMenuSub); // MRU list CMainOption::SetMRUMenuHandle(menu, _nPosMRU); //MenuDropTaget m_wndMenuDropTarget.Create(m_hWnd, rcDefault, _T("MenuDropTargetWindow"), WS_POPUP, 0); m_wndMenuDropTarget.SetTargetMenu(menu); } /// create command bar window HWND CMainFrame::init_commandBarWindow() { SetMenu(NULL); // remove menu HWND hWndCmdBar = m_CmdBar.Create(m_hWnd,rcDefault,NULL,MTL_SIMPLE_CMDBAR2_PANE_STYLE,0,ATL_IDW_COMMAND_BAR); if (m_font.m_hFont) { LOGFONT lf; m_font.GetLogFont(lf); m_CmdBar.SetMenuLogFont(lf); } m_CmdBar.AttachMenu(m_hMenu); m_CmdBar.EnableButton(_nPosWindowMenu, false); return hWndCmdBar; } /// create toolbar HWND CMainFrame::init_toolBar() { #if 1 //+++ 関数分離の都合取得しなおし CMenuHandle menu = m_hMenu; CMenuHandle menuFav = menu.GetSubMenu(_nPosFavoriteMenu); CMenuHandle menuGroup = menuFav.GetSubMenu(_nPosFavGroupMenu); CMenuHandle menuCss = menu.GetSubMenu(_nPosCssMenu); CMenuHandle menuCssSub = menuCss.GetSubMenu(_nPosSubCssMenu); #endif HWND hWndToolBar = m_ToolBar.DonutToolBar_Create(m_hWnd); ATLASSERT( ::IsWindow(hWndToolBar) ); m_ToolBar.DonutToolBar_SetFavoritesMenu(menuFav, menuGroup, menuCssSub); if (m_CmdBar.m_fontMenu.m_hFont) m_ToolBar.SetFont(m_CmdBar.m_fontMenu.m_hFont); return hWndToolBar; } /// create addressbar HWND CMainFrame::init_addressBar() { HWND hWndAddressBar = m_AddressBar.Create( m_hWnd, IDC_ADDRESSBAR, ID_VIEW_GO, /*+++ IDB_GOBUTTON, IDB_GOBUTTON_HOT,*/ 16, 16, RGB(255, 0, 255) ); ATLASSERT( ::IsWindow(hWndAddressBar) ); if (m_CmdBar.m_fontMenu.m_hFont) m_AddressBar.SetFont(m_CmdBar.m_fontMenu.m_hFont); m_AddressBar.m_comboFlat.SetDrawStyle(CSkinOption::s_nComboStyle); return hWndAddressBar; } /// create searchbar HWND CMainFrame::init_searchBar() { HWND hWndSearchBar = m_SearchBar.Create(m_hWnd); if (m_CmdBar.m_fontMenu.m_hFont) m_SearchBar.SetFont(m_CmdBar.m_fontMenu.m_hFont); m_SearchBar.SetDlgCtrlID(IDC_SEARCHBAR); m_SearchBar.SetComboStyle(CSkinOption::s_nComboStyle); return hWndSearchBar; } /// create findbar HWND CMainFrame::init_findBar() { //HWND hWndFindBar = m_fayt.Create(m_hWnd); m_hWndFAYT = m_fayt.Create(m_hWndAdditionalSplit);//,rcDefault,_T("X"),WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX|BS_CENTER|BS_VCENTER); if (m_CmdBar.m_fontMenu.m_hFont) m_fayt.SetFont(m_CmdBar.m_fontMenu.m_hFont); m_fayt.SetDlgCtrlID(IDC_SEARCHBAR); //m_fayt.SetComboStyle(CSkinOption::s_nComboStyle); return m_hWndFAYT;//hWndFindBar; } /// create tabctrl HWND CMainFrame::init_tabCtrl() { HWND hWndMDITab = m_MDITab.Create(m_hWnd, CRect(0, 0, 200, 20), _T("Donut MDITab"), WS_CHILD | WS_VISIBLE, NULL, IDC_MDITAB); m_MDITab.LoadMenu(IDR_MENU_TAB); m_MDITab.LoadConnectingAndDownloadingImageList( IDB_MDITAB, 6, 6, RGB(255, 0, 255) ); return hWndMDITab; } /// create link bar HWND CMainFrame::init_linkBar() { CIniFileI prLnk( g_szIniFileName, _T("LinkBar") ); DWORD dwStyle = prLnk.GetValue( _T("ExtendedStyle") ); prLnk.Close(); m_LinkBar.SetOptionalStyle(dwStyle); HWND hWndLinkBar = m_LinkBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_TOOLBAR_PANE_STYLE, 0, IDC_LINKBAR); return hWndLinkBar; } /// create rebar void CMainFrame::init_rebar() { DWORD dwRebarStyle = MTL_SIMPLE_REBAR_STYLE | RBS_DBLCLKTOGGLE; { CIniFileI pr( g_szIniFileName, _T("ReBar") ); DWORD dwNoBoader = pr.GetValue( _T("NoBoader") ); if (dwNoBoader) dwRebarStyle &= ~RBS_BANDBORDERS; } CreateSimpleReBar(dwRebarStyle); m_ReBar.SubclassWindow(m_hWndToolBar); //CreateSimpleReBar(MTL_SIMPLE_REBAR_STYLE | RBS_DBLCLKTOGGLE); if (m_CmdBar.m_fontMenu.m_hFont) { ::SendMessage( m_hWndToolBar, WM_SETFONT, (WPARAM) m_CmdBar.m_fontMenu.m_hFont, MAKELPARAM(TRUE, 0) ); m_LinkBar.SetFont(m_CmdBar.m_fontMenu.m_hFont); } } /// create statusbar void CMainFrame::init_statusBar() { //CreateSimpleStatusBar(); m_wndStatusBar.Create(m_hWnd, ATL_IDS_IDLEMESSAGE, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP | SBT_TOOLTIPS); m_hWndStatusBar = m_wndStatusBar.m_hWnd; // int nPanes[] = { ID_DEFAULT_PANE, ID_PROGRESS_PANE, ID_COMBOBOX_PANE}; static const int nPanes[] = { ID_DEFAULT_PANE, ID_PROGRESS_PANE, ID_PRIVACY_PANE, ID_SECURE_PANE, ID_COMBOBOX_PANE }; m_wndStatusBar.SetPanes( (int *) nPanes, 5, false ); m_wndStatusBar.SetCommand( ID_PRIVACY_PANE, ID_PRIVACYREPORT ); m_wndStatusBar.SetCommand( ID_SECURE_PANE, ID_SECURITYREPORT); m_wndStatusBar.SetIcon( ID_PRIVACY_PANE, 1 ); //minit m_wndStatusBar.SetIcon( ID_SECURE_PANE , 0 ); //minit m_wndStatusBar.SetOwnerDraw( m_wndStatusBar.IsValidBmp() ); // UH InitStatusBar(); } // UH void CMainFrame::InitStatusBar() { enum { //+++ IDはデフォルトの名前になっているが、交換した場合にややこしいので、第一領域、第二領域として扱う. ID_PAIN_1 = ID_PROGRESS_PANE, ID_PAIN_2 = ID_COMBOBOX_PANE, }; DWORD dwSzPain1 = 125; DWORD dwSzPain2 = 125; { DWORD dwVal = 0; CIniFileI pr( g_szIniFileName, _T("StatusBar") ); if (pr.QueryValue( dwVal, _T("SizePain") ) == ERROR_SUCCESS) { dwSzPain1 = LOWORD(dwVal); dwSzPain2 = HIWORD(dwVal); } if (pr.QueryValue( dwVal, _T("SwapPain") ) == ERROR_SUCCESS) g_bSwapProxy = dwVal != 0; } //+++ 位置交換の修正. if (g_bSwapProxy == 0) { g_dwProgressPainWidth = dwSzPain1; //+++ 手抜きでプログレスペインの横幅をグローバル変数に控える. m_wndStatusBar.SetPaneWidth(ID_PAIN_1, 0); //dwSzPain1); //起動時はペインサイズが0 if (m_cmbBox.IsUseIE()) dwSzPain2 = 0; // IEのProxyを使う場合はProxyペインサイズを0に m_wndStatusBar.SetPaneWidth(ID_PAIN_2, dwSzPain2); } else { // 交換しているとき. g_dwProgressPainWidth = dwSzPain2; //+++ 手抜きでプログレスペインの横幅をグローバル変数に控える. m_wndStatusBar.SetPaneWidth(ID_PAIN_2, dwSzPain2); //+++ 交換してるときは、最初からサイズ確保. if (m_cmbBox.IsUseIE()) dwSzPain1 = 0; // IEのProxyを使う場合はProxyペインサイズを0に m_wndStatusBar.SetPaneWidth(ID_PAIN_1, dwSzPain1); } m_wndStatusBar.SetPaneWidth(ID_SECURE_PANE , 25); m_wndStatusBar.SetPaneWidth(ID_PRIVACY_PANE , 25); } /// create prgress bar void CMainFrame::init_progressBar() { RECT rect; m_wndProgress.Create(m_hWndStatusBar, NULL, NULL, WS_CHILD | WS_CLIPSIBLINGS | PBS_SMOOTH, 0, IDC_PROGRESS); m_wndProgress.ModifyStyleEx(WS_EX_STATICEDGE, 0); // Proxyコンボボックス // IEのProxyを使う場合、コンボボックスとステータスバーのProxyペインを削除 m_cmbBox.Create(m_hWndStatusBar, rect, NULL, WS_CHILD | WS_CLIPSIBLINGS | PBS_SMOOTH | CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP, 0, IDC_COMBBOX); m_cmbBox.SetFont( m_wndStatusBar.GetFont() ); m_cmbBox.SetDrawStyle(CSkinOption::s_nComboStyle); m_cmbBox.IsUseIE() ? m_cmbBox.ShowWindow(SW_HIDE) : m_cmbBox.ShowWindow(SW_SHOWNORMAL); m_cmbBox.ResetProxyList(); } /// Plugin Toolbar Load void CMainFrame::init_pluginManager() { CPluginManager::Init(); CPluginManager::ReadPluginData(PLT_TOOLBAR, m_hWnd); CPluginManager::LoadAllPlugin(PLT_TOOLBAR, m_hWnd, true); //ツールバープラグインを全部ロード { int nCount = CPluginManager::GetCount(PLT_TOOLBAR); for (int i = 0; i < nCount; i++) { HWND hWnd = CPluginManager::GetHWND(PLT_TOOLBAR, i); if ( ::IsWindow(hWnd) ) ::SetProp( hWnd, _T("Donut_Plugin_ID"), HANDLE( IDC_PLUGIN_TOOLBAR + i) ); } } //LoadPluginToolbars(); } /// load band position void CMainFrame::init_band_position( HWND hWndCmdBar, HWND hWndToolBar, HWND hWndAddressBar, HWND hWndMDITab, HWND hWndLinkBar, HWND hWndSearchBar ) { CSimpleArray<HWND> aryHWnd; aryHWnd.Add( hWndCmdBar ); // メニューバー aryHWnd.Add( hWndToolBar ); // ツールバー aryHWnd.Add( hWndAddressBar ); // アドレスバー aryHWnd.Add( hWndMDITab ); // タブバー aryHWnd.Add( hWndLinkBar ); // リンクバー aryHWnd.Add( hWndSearchBar ); // 検索バー int nToolbarPluginCount = CPluginManager::GetCount(PLT_TOOLBAR); CReBarBandInfo * pRbis = new CReBarBandInfo[STDBAR_COUNT + nToolbarPluginCount]; int nIndex; for (nIndex = 0; nIndex < aryHWnd.GetSize(); nIndex++) { pRbis[nIndex].nIndex = nIndex; pRbis[nIndex].hWnd = aryHWnd [ nIndex ]; pRbis[nIndex].nID = STDBAR_ID [ nIndex ]; pRbis[nIndex].fStyle = STDBAR_STYLE[ nIndex ]; pRbis[nIndex].lpText = STDBAR_TEXT [ nIndex ]; pRbis[nIndex].cx = 0; } for (nIndex = 0; nIndex < nToolbarPluginCount; nIndex++) { pRbis[STDBAR_COUNT + nIndex].nIndex = STDBAR_COUNT + nIndex; pRbis[STDBAR_COUNT + nIndex].hWnd = CPluginManager::GetHWND(PLT_TOOLBAR, nIndex); pRbis[STDBAR_COUNT + nIndex].nID = IDC_PLUGIN_TOOLBAR + nIndex; pRbis[STDBAR_COUNT + nIndex].fStyle = RBBS_BREAK; pRbis[STDBAR_COUNT + nIndex].lpText = NULL; pRbis[STDBAR_COUNT + nIndex].cx = 0; } { CIniFileI pr( g_szIniFileName, _T("ReBar") ); MtlGetProfileReBarBandsState( pRbis, pRbis + STDBAR_COUNT + nToolbarPluginCount, pr, *this); //x pr.Close(); //+++ } delete[] pRbis; //memory leak bug Fix minit m_CmdBar.RefreshBandIdealSize(m_hWndToolBar); m_AddressBar.InitReBarBandInfo(m_hWndToolBar); // if you dislike a header, remove this. ShowLinkText( (m_AddressBar.m_dwAddressBarExtendedStyle & ABR_EX_TEXTVISIBLE) != 0 ); } /// load status bar state void CMainFrame::init_loadStatusBarState() { CIniFileI pr( g_szIniFileName, _T("Main") ); BOOL bStatusBarVisible = TRUE; MtlGetProfileStatusBarState(pr, m_hWndStatusBar, bStatusBarVisible); m_bStatusBarVisibleUnlessFullScreen = bStatusBarVisible; //x pr.Close(); } /// create mdi client window void CMainFrame::init_mdiClientWindow() { m_menuWindow = ::GetSubMenu(m_hMenu, _nPosWindowMenu); CreateMDIClient(m_menuWindow.m_hMenu); m_wndMDIClient.SubclassWindow(m_hWndMDIClient); // NOTE: If WS_CLIPCHILDREN not set, MDI Client will try erase background over MDI child window, // but as OnEraseBkgnd does nothing, it goes well. if (CMainOption::s_bTabMode) m_wndMDIClient.ModifyStyle(WS_CLIPCHILDREN, 0); // to avoid flicker, but scary } /// splitter window void CMainFrame::init_splitterWindow() { m_hWndClient = m_wndSplit.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); m_wndSplit.SetSplitterExtendedStyle(0); m_hWndAdditionalSplit = m_wndAdditionalSplit.Create(m_hWndClient, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); //m_wndAdditionalSplit.SetSplitterExtendedStyle(SPLIT_BOTTOMALIGNED); //m_wndAdditionalSplit.m_cxySplitBar = 0; ///m_wndAdditionalSplit.SetSinglePaneMode(SPLIT_PANE_TOP); } /* void CMainFrame::init_faytWindow(){ m_hWndFAYT = m_fayt.Create(m_hWndAdditionalSplit,rcDefault,_T("X"),WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX|BS_CENTER|BS_VCENTER); }*/ /// pane container void CMainFrame::init_explorerBar() { m_ExplorerBar.Create(m_hWndClient); m_ExplorerBar.Init(m_hWndMDIClient, m_hWndFAYT); } /// MDIClient misc void CMainFrame::init_mdiClient_misc(HWND hWndCmdBar, HWND hWndToolBar) { m_mcCmdBar.InstallAsMDICmdBar(hWndCmdBar, m_hWndMDIClient, CMainOption::s_bTabMode); m_mcToolBar.InstallAsStandard(hWndToolBar, m_hWnd, true, ID_VIEW_FULLSCREEN); CIniFileI pr( _GetFilePath( _T("Menu.ini") ), _T("Option") ); DWORD dwNoButton = pr.GetValue( _T("NoButton") ); pr.Close(); bool bNoButton = dwNoButton != 0/*? true : false*/; m_mcCmdBar.ShowButton(!bNoButton); //m_mcToolBar.ShowButton(!bNoButton); m_MDITab.SetMDIClient(m_hWndMDIClient); } // // set up UI // CmdUIAddToolBar(hWndToolBar); // CmdUIAddToolBar(m_SearchBar.m_wndToolBar); void CMainFrame::init_setUserAgent() { nsCOMPtr<nsIPrefBranch> pb = do_GetService("@mozilla.org/preferences-service;1"); if(!pb) return; std::vector<char> userAgent = Misc::tcs_to_sjis( CDLControlOption::userAgent() ); pb->SetCharPref("general.useragent.override", &userAgent[0]); } void CMainFrame::init_message_loop() { // message loop CMessageLoop *pLoop = _Module.GetMessageLoop(); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); } /// mdiタブに関する情報の読み込み void CMainFrame::init_mdiTab() { CIniFileI pr( g_szIniFileName, _T("MDITab") ); MtlGetProfileMDITab(pr, m_MDITab); pr.Close(); // フォント if (m_font.m_hFont) { MTL::CLogFont lf; m_font.GetLogFont(lf); m_MDITab.SetMDITabLogFont(lf); } } // // for dragging files // RegisterDragDrop(); //DragAcceptFiles(); // CCriticalIdleTimer::InstallCriticalIdleTimer(m_hWnd, ID_VIEW_IDLE); // システムメニューに追加 void CMainFrame::init_sysMenu() { // システムメニューに追加 HMENU hSysMenu = ::GetSystemMenu(m_hWnd, FALSE); // ::AppendMenu(hSysMenu, MF_ENABLED|MF_STRING, ID_VIEW_COMMANDBAR, _T("メニューを表示")); TCHAR cText[] = _T("メニューを表示"); MENUITEMINFO menuInfo; memset( &menuInfo, 0, sizeof (MENUITEMINFO) ); menuInfo.cbSize = sizeof (MENUITEMINFO); menuInfo.fMask = MIIM_ID | MIIM_TYPE; menuInfo.fType = MFT_STRING; menuInfo.wID = ID_VIEW_COMMANDBAR; menuInfo.dwTypeData = cText; menuInfo.cch = sizeof (cText); ::InsertMenuItem(hSysMenu, 0, MF_BYPOSITION, &menuInfo); } // ::SetTimer(m_hWnd, ENT_READ_ACCEL, 200, NULL); // //スキンを初期化 // InitSkin(); // CDonutSimpleEventManager::RaiseEvent(EVENT_INITIALIZE_COMPLETE); // //Hook InputDialogMessage (javascript prompt()) // CDialogHook::InstallHook(m_hWnd); // //CSearchBoxHook::InstallSearchHook(m_hWnd); void CMainFrame::init_loadPlugins() { //プラグインのアーリーローディング CPluginManager::LoadAllPlugin(PLT_EXPLORERBAR, m_ExplorerBar.m_PluginBar); //オペレーションプラグインのロード CPluginManager::ReadPluginData(PLT_OPERATION); #if 1 //+++ 無理やり DockingBarプラグインを、ExplorerBarとして扱ってみる... CPluginManager::LoadAllPlugin(PLT_DOCKINGBAR, m_ExplorerBar.m_PluginBar); #else CPluginManager::LoadAllPlugin(PLT_DOCKINGBAR, m_hWnd); #endif } // =========================================================================== // 終了処理 CMainFrame::~CMainFrame() { if ( m_wndMDIClient.IsWindow() ) m_wndMDIClient.UnsubclassWindow(); } void CMainFrame::OnEndSession(BOOL wParam, UINT lParam) // ShutDown minit { if (wParam == TRUE) { OnDestroy(); _PrivateTerm(); } } void CMainFrame::OnDestroy() { SetMsgHandled(FALSE); MtlSendCommand(m_hWnd, ID_VIEW_STOP_ALL); // added by DOGSTORE //CSearchBoxHook::UninstallSearchHook(); //CDialogHook::UninstallHook(); //デバッグウィンドウ削除 m_wndDebug.Destroy(); //全プラグイン解放 CPluginManager::Term(); m_ReBar.UnsubclassWindow(); //バックアップスレッドの開放 if (m_hGroupThread) { DWORD dwResult = ::WaitForSingleObject(m_hGroupThread, DONUT_BACKUP_THREADWAIT); if (dwResult == WAIT_TIMEOUT) { ErrorLogPrintf(_T("MainFrame::OnDestroyにて、自動更新スレッドの終了が出来ない模様\n")); ::TerminateThread(m_hGroupThread, 1); } CloseHandle(m_hGroupThread); m_hGroupThread = NULL; //+++ 最後とはいえ、一応 NULLしとく. } // Note. The script error dialog makes the app hung up. // I can't find the reason, but I can avoid it by closing // windows explicitly. MtlCloseAllMDIChildren(m_hWndMDIClient); CCriticalIdleTimer::UninstallCriticalIdleTimer(); // what can I trust? ATLASSERT( ::IsMenu(m_hMenu) ); ::DestroyMenu(m_hMenu); _RemoveTmpDirectory(); DestroyCustomDropDownMenu(); RevokeDragDrop(); } void CMainFrame::DestroyCustomDropDownMenu() { OnMenuRefreshFav(FALSE); OnMenuRefreshFavGroup(FALSE); OnMenuRefreshScript(FALSE); } struct CMainFrame::_Function_DeleteFile { int m_dummy; _Function_DeleteFile(int ndummy) : m_dummy(ndummy) { } void operator ()(const CString &strFile) { if ( MtlIsExt( strFile, _T(".tmp") ) ) ::DeleteFile(strFile); } }; void CMainFrame::_RemoveTmpDirectory() { CString strTempPath = Misc::GetExeDirectory() + _T("ShortcutTmp\\"); if (::GetFileAttributes(strTempPath) != 0xFFFFFFFF) { MtlForEachFile( strTempPath, CMainFrame::_Function_DeleteFile(0) ); ::RemoveDirectory(strTempPath); } } void CMainFrame::OnClose() { SetMsgHandled(FALSE); if ( !CDonutConfirmOption::OnDonutExit(m_hWnd) ) { SetMsgHandled(TRUE); if (IsWindowVisible() == FALSE) { SetHideTrayIcon(); Sleep(100); } return; } // タイマーをとめる. if (m_nBackUpTimerID != 0) { KillTimer(m_nBackUpTimerID); m_nBackUpTimerID = 0; //+++ 一応 0クリアしとく. } #if 0 //+++ _WriteProfile()からバックアップの処理をこちらに移す(先に行う) ... やっぱりやめ _SaveGroupOption( CStartUpOption::GetDefaultDFGFilePath() ); #endif CChildFrame::SetMainframeCloseFlag(); //+++ mainfrmがcloseすることをChildFrameに教える(ナビロックのclose不可をやめるため) if ( IsFullScreen() ) { CMainOption::s_dwMainExtendedStyle |= MAIN_EX_FULLSCREEN; // save style _ShowBandsFullScreen(FALSE); // restore bands position } else { CMainOption::s_dwMainExtendedStyle &= ~MAIN_EX_FULLSCREEN; } m_mcCmdBar.Uninstall(); m_mcToolBar.Uninstall(); _WriteProfile(); CMainOption::s_bAppClosing = true; DelCache(); DelCookie(); DelHistory(); } void CMainFrame::DelCookie() { bool bDelCookie = (CMainOption::s_dwMainExtendedStyle2 & MAIN_EX2_DEL_COOKIE) != 0; //+++ ? TRUE : FALSE; if(!bDelCookie) return; nsCOMPtr<nsICookieManager> cm = do_GetService("@mozilla.org/cookiemanager;1"); cm->RemoveAll(); } void CMainFrame::DelCache() { bool bDelCache = (CMainOption::s_dwMainExtendedStyle2 & MAIN_EX2_DEL_CASH ) != 0; //+++ ? TRUE : FALSE; if(!bDelCache) return; nsCOMPtr<nsICacheService> cs = do_GetService("@mozilla.org/network/cache-service;1"); cs->EvictEntries(nsICache::STORE_ON_DISK); cs->EvictEntries(nsICache::STORE_IN_MEMORY); } void CMainFrame::DelHistory() { bool bDelHistory = (CMainOption::s_dwMainExtendedStyle2 & MAIN_EX2_DEL_HISTORY) != 0; //+++ ? TRUE : FALSE; if (bDelHistory == false) return; nsCOMPtr<nsIBrowserHistory> history = do_GetService("@mozilla.org/browser/nav-history-service;1"); history->RemoveAllPages(); }
b028c3bc1db265cb219860dfc8a5fe51c54b3440
76228a9bbb0c4e36bb70fcb8bf63a84d9cceddec
/c++/elab/intsch.cpp
18bbeec629c0e340ad5a92f1703b8a42d709800d
[]
no_license
Noboomta/Data-Algo-Lab-SKE-KU-2020
df6300018572e3481afd8f50f23e0b673879fc5f
7f39abaad3e8e8cfd6b319004805d3a073a189b0
refs/heads/master
2023-02-25T22:39:09.735755
2021-01-28T09:21:45
2021-01-28T09:21:45
324,841,334
1
3
null
null
null
null
UTF-8
C++
false
false
661
cpp
intsch.cpp
// // Created by NoBoomTa on 12/26/2020. // #include "iostream" #include "vector" #include "bits/stdc++.h" using namespace std; int main(){ int n; cin >> n; vector< pair <int,int> > vect; for(int op = 0; op<n; op++){ int st, stop; cin >> st >> stop; vect.push_back( make_pair(stop, st) ); } sort(vect.begin(), vect.end()); int all =0; if(!vect.empty()){ int now_stop = vect[0].first; all++; for(int i=1; i<n; i++){ if(vect[i].second >= now_stop){ now_stop = vect[i].first; all++; } } } cout << all << endl; }
b673e1cf3ee2600167d8b999ef56453c78e61bdc
f013497448ff24ed15a2b5c978b0e9e745703697
/algorithms/matrix_layer_rotation.cpp
57ed4d2f4b32668003f5446226f66ad796bd4495
[]
no_license
milbak/hackerrank
a2f81f08d78439049a3c3faf82a758f749bd5d88
42b7df199623c5d9db7b0dda7e96b7da158b7e16
refs/heads/master
2021-01-12T13:14:51.158832
2016-11-16T18:28:52
2016-11-16T18:28:52
72,160,955
0
0
null
null
null
null
UTF-8
C++
false
false
1,787
cpp
matrix_layer_rotation.cpp
// matrix layer rotation #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using std::cin; using std::cout; using std::vector; void tracker(int &c, int i, int C){ if(C%2 == 0){ if(i < C/2 - 1) c++; else if(i >= C/2)c--; } else { if(i < C/2) c++; else c--; } } int main() { int N, M, R; cin >> N >> M >> R; vector< vector<unsigned> > G; int len = M, wid = N; int lay_sz = 2*len + 2*wid - 4; while(lay_sz > 0){ vector<unsigned>v(lay_sz); G.push_back(v); len-=2; wid-=2; lay_sz = 2*len + 2*wid - 4; } int layer = 0; for(int i = 0; i < N; i++){ int count = 0; for(int j = 0; j < M; j++){ int l = std::min(layer,count); int pos; if(i == l || j == M - 1 - l){ pos = (i+j) - 2*l; } else { pos = G[l].size() - ((i+j) - 2*l); } cin >> G[l][(pos + R*G[l].size() - R)%G[l].size()]; //cout << "("<< l <<"," <<pos<<")\t"; tracker(count, j, M); } //cout << std::endl; tracker(layer, i, N); } int lay = 0; for(int i = 0; i < N; i++){ int count = 0; for(int j = 0; j < M; j++){ int l = std::min(lay,count); int pos; if(i == l || j == M - 1 - l){ pos = (i+j) - 2*l; } else { pos = G[l].size() - ((i+j) - 2*l); } cout << G[l][pos] << " "; tracker(count, j, M); } tracker(lay,i,N); cout << std::endl; } return 0; }
3ca4e118d0fa45c1f7ceb91e08b717676b7c0bb2
ba2857bccb9efa4ae7fd53ced44912433d7e3ef6
/src/base/Uncopy.h
9040e2650954a7616ef064fd1e62108eec3206e8
[]
no_license
LZhuY/snode
1ab09140d150cc2f50c96c5be4c5959a35776b2e
3727072e92d8380617383009e8696231815f2100
refs/heads/master
2020-03-16T21:06:35.704647
2018-10-09T06:42:13
2018-10-09T06:42:13
132,985,073
0
0
null
null
null
null
UTF-8
C++
false
false
174
h
Uncopy.h
#ifndef UNCOPY_H #define UNCOPY_H namespace SNODE{ class Uncopy{ public: Uncopy(){} private: Uncopy(Uncopy& ori){} Uncopy& operator = (Uncopy& rhs){} }; } #endif
32a0336ddccaa0031ae796eab64b57eb156763cf
362e321d0c4f054a3877fc0a36b168531f0746b5
/LC912_Sort an Array_Quick Sort.cpp
a04ab685099b8584b978ffe478de7204b7e40ac6
[]
no_license
logic-life/LeetCode
4935b5d57c7d1b673d392e50ad5cfa50d873fb58
3a6e825e114fee2568ec6866833d85a4b4557f02
refs/heads/main
2023-04-08T19:03:24.791258
2021-04-13T05:36:13
2021-04-13T05:36:13
357,615,164
1
0
null
2021-04-13T16:12:07
2021-04-13T16:12:06
null
UTF-8
C++
false
false
1,160
cpp
LC912_Sort an Array_Quick Sort.cpp
class Solution { int partition(vector<int>& nums, int left, int right) { // 快速排序 C++ int pivot = nums[right]; // 选一个数值作为pivot int i = left - 1; for (int j = left; j <= right - 1; j++) { // 将数组中的数值按照选中的pivot大小进行划分,小于等于的在一起,大于的在一起 if (nums[j] <= pivot) { i = i + 1; swap(nums[i], nums[j]); // 交换位置 } } swap(nums[i + 1], nums[right]); // 这一行代码的意义是:把一开始就搁置的pivot再拉回来,放回中间的位置。左边是小于等于的元素,右边是大于的。 return i + 1; // 输出pivot位置 } void quicksort(vector<int>& nums, int left, int right) { if (left < right) { // 快速排序 int pos = partition(nums, left, right); quicksort(nums, left, pos - 1); quicksort(nums, pos + 1, right); } } public: vector<int> sortArray(vector<int>& nums) { quicksort(nums, 0, (int)nums.size() - 1); return nums; } };
3797367e71213ded04480fa25671cdaef617d0e9
cb7fd88891c1573360acfb5b476291f6b07e0e09
/Hello hii.cpp
f7f77924378bbb9baad55e9509091f6bdeb96ee6
[]
no_license
chiragrathi24/code-samples
b212d072bbf7651fbfebcca26ad85328f6eadd61
d7fbfb1cbf735aed30d088f10895c4dca1eabc36
refs/heads/master
2021-07-16T08:46:56.689794
2020-10-02T10:27:39
2020-10-02T10:27:39
212,636,326
0
2
null
2020-10-02T10:27:40
2019-10-03T17:16:56
C++
UTF-8
C++
false
false
94
cpp
Hello hii.cpp
#include <iostream> using namespace std; int main() { cout<<"Hi there!!"<<endl; return 0; }
46be8ac50fc3102958aa0e36f7c29b52692cb210
3a7247e5382e028de6f06d4be35d5300fb08bf83
/Rune Engine/Rune/Symphony/RuSoundChannel.h
b3ab5a10c5c5c394c3631edf623fc951c66a5cc6
[]
no_license
g91/RomLibraries
8c68cfabe6a68dad7937941a9ec90c3948588a85
55a98a86057500527e208a6fd593397839465384
refs/heads/main
2023-05-14T07:03:34.253295
2021-06-08T07:44:44
2021-06-08T07:44:44
356,100,453
1
2
null
null
null
null
UTF-8
C++
false
false
3,082
h
RuSoundChannel.h
/*! @file RuSoundChannel.h Copyright (c) 2004-2011 Runewaker Entertainment Ltd. All rights reserved. */ #pragma once #include "../Core/Type/RuType_Object.h" #include "../Core/Math/RuMathVector.h" #include "../Core/Thread/RuThread_CriticalSection.h" #pragma managed(push, off) // ************************************************************************************************************************************************************ enum RuSoundFlag { ruSOUNDFLAG_2D = 0x00000008, //!< 2D sound (DEFAULT) ruSOUNDFLAG_3D = 0x00000010, //!< 3D sound ruSOUNDFLAG_LOOP_OFF = 0x00000001, //!< Looping off (DEFAULT) ruSOUNDFLAG_LOOP_NORMAL = 0x00000002, //!< Unidirectional looping ruSOUNDFLAG_LOOP_BIDIR = 0x00000004, //!< Bidirectional looping ruSOUNDFLAG_3D_HEADRELATIVE = 0x00040000, //!< 3D placement relative to the listener ruSOUNDFLAG_3D_WORLDRELATIVE = 0x00080000, //!< 3D placement in absolute world frame ruSOUNDFLAG_FALLOFF_LOG = 0x00100000, //!< Logarithmic falloff ruSOUNDFLAG_FALLOFF_LINEAR = 0x00200000, //!< Linear falloff ruSOUNDFLAG_FALLOFF_CUSTOM = 0x04000000 //!< Custom falloff }; // ************************************************************************************************************************************************************ class IRuSoundChannel : public IRuObject { ruRTTI_DECLARE ruHEAP_DECLARE ruCLASSGUID_DECLARE public: virtual ~IRuSoundChannel(); virtual void CopySettingsFrom(IRuSoundChannel *srcChannel) = 0; virtual void Swap(IRuSoundChannel *srcChannel) = 0; virtual IRuObject* GetHost() = 0; virtual void SetHost(IRuObject *hostObj) = 0; virtual INT32 Get3DAttributes(CRuVector3 &positionOut, CRuVector3 &velocityOut) = 0; virtual INT32 Set3DAttributes(const CRuVector3 &position, const CRuVector3 &velocity) = 0; virtual void Get3DMinMaxDistance(REAL &minDist, REAL &maxDist) = 0; virtual void Set3DMinMaxDistance(REAL minDist, REAL maxDist) = 0; virtual UINT32 GetPosition() = 0; virtual void SetPosition(UINT32 positionMS) = 0; virtual INT32 FadeAndStop(REAL fadeTime) = 0; virtual INT32 Is3D() = 0; virtual INT32 IsPaused() = 0; virtual INT32 IsPlaying() = 0; virtual INT32 Pause(INT32 pause) = 0; virtual INT32 GetLoopCount() = 0; virtual INT32 SetLoopCount(INT32 loopCount) = 0; virtual DWORD GetMode() = 0; virtual INT32 SetMode(DWORD mode) = 0; virtual REAL GetVolume() = 0; virtual INT32 SetVolume(REAL volume) = 0; virtual void SetFrequency(REAL frequencyRatio) = 0; virtual void SetMute(INT32 mute) = 0; virtual INT32 Stop() = 0; virtual void Update(REAL elapsedTime) = 0; }; // ************************************************************************************************************************************************************ #pragma managed(pop)
0011912c23f6da84a976bd3fd38e4c04a5018ed0
85326d34a0c6024e310e21152487a84e1f14fb7a
/struct5/main.cpp
e35bd9e98c8f3afa8dcd7eaf58f59ccf87f9cc93
[]
no_license
damianF1996/practica-de-c-
dcb1cdb532705a80fe9933a3730a6757e258040a
0a714fb1a77e959afb90960ac130dd6c6b16dd49
refs/heads/main
2023-07-17T20:01:53.854130
2021-08-26T22:10:53
2021-08-26T22:10:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,228
cpp
main.cpp
#include <iostream> #include <conio.h> #include <string.h> using namespace std; struct datos { char nombre[25]; int discapacidad; }perso[100],personad[100],personass[100]; int main() { int n,a=0,b=0; char persona1[25]; cout << "ingrese la cantidad de personas: "; cin>>n; for(int i = 0; i < n; i++) { fflush(stdin); cout<<"ingrese su nombre: "; cin.getline(perso[i].nombre,25,'\n'); cout<<"ingrese si tiene una discapacidad 1 si no tiene es 0: "; cin>>perso[i].discapacidad; cout<<'\n'; if ( perso[i].discapacidad == 1) { strcpy(personad[a].nombre,perso[i].nombre); a++; } else { strcpy(personass[b].nombre,perso[i].nombre); b++; } } cout<<"lista de las personas sin discapacidad: "<< endl; for(int i = 0; i < n; i++) { cout<<personass[i].nombre<<endl; } cout<<'\n'; cout<<"lista de las personas con discapacidad: "<<endl; for(int i = 0; i < n; i++) { cout<<personad[i].nombre<<endl; } return 0; }
d90c26b0e336640a8a29fdf4588b5719d2385ac3
04fe7d81c43e9d1e064c48272dd46b3d5b0fbcfb
/Resueltos/uva855.cpp
9e3b095de79caa5137fc8739cacf457df1694bb2
[]
no_license
nachopepper/progcomp-2018_2-
42bd58fe5c1dd0c460356ddda7cacef936642ea8
c914091794634bb769c6b8b4ca762427262f640c
refs/heads/master
2021-07-20T02:03:07.698388
2018-12-07T00:13:00
2018-12-07T00:13:00
145,021,845
0
0
null
null
null
null
UTF-8
C++
false
false
1,856
cpp
uva855.cpp
/*Codigo copiado de internet...*/ #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> #include <vector> /*Sabemos que el valor medio para un arreglo de largo pares largoarreglo/2 en otro caso largoarreglo-1/2 con esto se toma una planno cartesiano x e y todos los valores de calles quedan en el array x y todos los valores de avenida quedan en el array y se ordena x e y y de salida nos da el valor medio*/ #define FileIn(file) freopen(file".inp", "r", stdin) #define FileOut(file) freopen(file".out", "w", stdout) #define FOR(i, a, b) for (int i=a; i<=b; i++) #define REP(i, n) for (int i=0; i<n; i++) #define Fill(ar, val) memset(ar, val, sizeof(ar)) #define PI 3.1415926535897932385 #define uint64 unsigned long long #define int64 long long #define all(ar) ar.begin(), ar.end() #define pb push_back #define bit(n) (1<<(n)) #define Last(i) (i & -i) #define INF 500000000 #define maxN 1001 using namespace std; int n, m, x[maxN], y[maxN]; main() { // FileIn("test"); FileOut("test"); int Case, a, b, k; for (scanf("%d", &Case); Case--; ) { scanf("%d %d %d", &a, &b, &n); m = max(a, b); for (int i=1; i<=m; i++) x[i] = y[i] = 0; k = (n%2)? n/2+1 : n/2; while (n--) { scanf("%d %d", &a, &b); x[a]++; y[b]++; } bool fa = false, fb = false; a = b = 0; for (int i=1; i<=m; i++) { if (!fa) { a += x[i]; if (a>=k) a = i, fa = true; } if (!fb) { b += y[i]; if (b>=k) b = i, fb = true; } if (fa && fb) break; } printf("(Street: %d, Avenue: %d)\n", a, b); } }
f943f4b66a73c9ffaa324242ca97c4f7123c1f8b
6acfb82696512fa7203a68cca867fc11b19273fa
/HW1/house.h
a07c2bbcac561bab591681c9cde07a937a3d5a7e
[]
no_license
dangalang/COP3330
8eed0f601efc455d27885a898f1f7e2872b4d5b6
f6314fab5cc703c7e063125968b9c05fb324392e
refs/heads/master
2022-04-15T23:32:33.672727
2020-04-10T22:10:22
2020-04-10T22:10:22
235,830,969
0
0
null
null
null
null
UTF-8
C++
false
false
1,099
h
house.h
/* Name: Forrest Lang * Date: 21 JAN 2020 * Section: 0005 * Assignment: Homework 1 */ class House { public: House(int size, char wall='X', char filler='*'); // Mutators: // If the base is less than 37 units, increase the size by 1. bool Grow(); // If the base is larger than 3 units, shrink the size by 1. bool Shrink(); // Change the border character to a valid ascii char (between 33 and 126). bool SetBorder(char wall); // Change the filler character to a valid ascii char (between 33 and 126). bool SetFill(char filler); // Accessors: // Get the size of the base of the house. int GetSize() const; // Calculate the perimeter of the house. Returns answer as integer. int Perimeter() const; // Calculate the area of the house. Returns answer as double double Area() const; // Draw an ascii representation of the house. void Draw() const; // Print the base width, perimeter, area and ascii depiction of the house. void Summary() const; private: int base; char border; char fill; };
28218e90b66c92085fa47435e6c0abddbe152f0b
d43c584d45b0929c4ca33a36107888d0099ad0c1
/source/menu.cpp
94719cbd2e999d33739cdc3ee77ea57af802497a
[]
no_license
TeamJungle/JungleSafeHouse
aa318908fe7dc5be2b4da900b8b2634c23adfb2e
a9814280979c13ec8edab8dc18eea5eede756f96
refs/heads/master
2021-09-13T02:07:33.823426
2018-04-23T19:55:57
2018-04-23T19:55:57
117,973,810
0
2
null
2018-02-15T10:27:50
2018-01-18T11:25:30
C++
UTF-8
C++
false
false
1,146
cpp
menu.cpp
#include "menu.hpp" #include "assets.hpp" #include "game.hpp" #include "editor.hpp" #include "test.hpp" menu_state::menu_state() { menu.font = &fonts.hud; menu.add_button("Play", [] { ne::swap_state<game_state>(); }); menu.add_button("Settings", [] { ne::swap_state<settings_state>(); }); menu.add_button("Editor", [] { ne::swap_state<editor_state>(); }); #if _DEBUG menu.add_button("Test", [] { ne::swap_state<test_state>(1); }); #endif menu.add_button("Quit", [] { std::exit(ne::stop_engine(0)); }); settings::play(&audio.safehouse, 0.15f); } menu_state::~menu_state() { } void menu_state::update() { camera.transform.scale.xy = ne::window_size().to<float>(); camera.update(); camera.bind(); menu.update(camera.size(), 0.0f, textures.bg.menu.size.to<float>()); } void menu_state::draw() { shaders.basic.bind(); camera.bind(); textures.bg.menu.bind(); ne::transform3f bg; bg.scale.xy = textures.bg.menu.size.to<float>() * 2.0f; ne::shader::set_transform(&bg); ne::shader::set_color(1.0f); still_quad().draw(); menu.draw(camera.size(), { 0.0f, 40.0f }, textures.ui.popup.size.to<float>() * 0.58f); }
07ef6befbc5302af85348e97c40259b01abaebed
e3afeab04cfed95b18affeb766bdffec6c610ab3
/tools/step/StepOptDlg.cpp
e715e9eee392d76ec013a31e32bb4111d2ab3e6a
[]
no_license
VB6Hobbyst7/NCL_in_VisualStudio
2831e101163d34be5b5775c458471313cd6c035b
998a5a4ca9eb1cfdee0b276ae9541f7d1f7e6371
refs/heads/master
2023-06-24T12:03:34.428725
2021-07-27T20:30:46
2021-07-27T20:30:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
25,706
cpp
StepOptDlg.cpp
/************************************************************************ c c FILE NAME: StepOptDlg.cpp c c CONTAINS: c Functions for the class StepOptDlg c c COPYRIGHT 2013 (c) Numerical Control Computer Sciences. c All Rights Reserved c MODULE NAME AND RELEASE LEVEL c StepOptDlg.cpp , 25.4 c DATE AND TIME OF LAST MODIFICATION c 04/05/18 , 15:03:16 c c********************************************************************** */ // GgesOptDlg.cpp : implementation file // #include "wsntstdafx.h" #include <io.h> #include "wsntres.h" #include "step.h" #include "StepOptDlg.h" #include "tiges.h" #include "xenv1.h" #include "ulist.h" #include "StepModalDlg.h" #include "StepAttrDlg.h" #include <gdiplus.h> #include "wsntclrdlg.h" using namespace Gdiplus; struct IG_igesclr_rec { UU_KEY_ID key; int rel_num; UU_REAL red; UU_REAL green; UU_REAL blue; char name[20]; }; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern "C" char iges_fname[UX_MAX_PATH_LEN]; extern "C" int MAX_PARA_REC; extern "C" int UG_def_line_wt; extern "C" int ul_break_fname(char*, char*, char*); extern "C" int ul_get_full_dir(char* dir, char* fullname); extern "C" int uig_terminal_rec(); extern "C" int uu_free(void *); extern "C" int iges_config(int ); extern "C" int uig_update_surface_prim(); extern "C" int ur_saveu_active(int ); extern "C" int uig_open_secondary(char unifile[],int *index); extern "C" char *ux_getenv(char*); extern "C" void ul_short_filename(char *fin, char *fout, int maxc); extern "C" void utp_reset_shape_range(); extern "C" int utp_shape_label_nstack(); extern "C" char *uu_malloc(int); extern "C" void utp_set_shape_range(int,int); extern "C" char *utp_get_shape_label(int); extern "C" void utp_get_label_method(int *,int *,int *); extern "C" void utp_set_label_method(int,int,int); extern "C" int utp_read_step_file(char *); extern "C" int utp_count_entities(); extern "C" int utp_get_units(); extern "C" int utp_load_color_mode(char *); extern "C" void uig_init_color(); extern "C" void utp_set_layer_flag(int); extern "C" int utp_get_layer_flag(); extern "C" int utp_set_start_layer(int); extern "C" int utp_get_start_layer(); ///////////////////////////////////////////////////////////////////////////// // CStepOptDlg dialog CStepOptDlg::CStepOptDlg(CWnd* pParent, char *fname) : CDialog(CStepOptDlg::IDD, pParent) { if (fname==NULL) m_fname[0] = '\0'; else if (fname[0]=='\0') m_fname[0] = '\0'; else strcpy(m_fname, fname); m_edge_color = UIG_edge_color; } void CStepOptDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CStepOptDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CStepOptDlg, CDialog) //{{AFX_MSG_MAP(CStepOptDlg) ON_BN_CLICKED(IDC_SELECT_ALL, OnSelectAll) ON_BN_CLICKED(IDC_CLEAR_ALL, OnClearAll) ON_CBN_SELCHANGE(IDC_COPTION, OnSelchangeCoption) ON_BN_CLICKED(IDC_CHECK_LAYERS, OnLayers) ON_CBN_SELCHANGE(IDC_LABEL_OPTION, OnSelchangeLabelOption) ON_BN_CLICKED(IDC_BROWSE, OnBrowse) ON_BN_CLICKED(IDC_MODALSN, OnNameModals) ON_BN_CLICKED(IDC_ATTRIBUTES, OnAttr) ON_BN_CLICKED(IDC_CHECK_NODUPS, OnNoDups) ON_BN_CLICKED(IDC_SRF_EDGE, OnEdgeColor) ON_BN_CLICKED(IDC_EDGE_COLR_NEW, OnEdgeColorSel) ON_BN_CLICKED(IDC_SHADE, OnShade) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CStepOptDlg message handlers /*********************************************************************** c c FUNCTION: OnSelectAll() c c This function called when user push the "Select All" button c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnSelectAll() { CListBox* lstbox = (CListBox*)GetDlgItem(IDC_LAYER_LIST); int cont = lstbox->GetCount(); for (int i = 0; i<cont; i++) { lstbox->SetSel(i, TRUE); } } /*********************************************************************** c c FUNCTION: OnOK() c c This function called when user push the "OK" button c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnOK() { int status,index,len,nent; int label_type,use_sub,concat_lab; CString tmpstr; UX_pathname unifile; char msg[300],toler[10],in_mm[10],*text; int sel_num,srf_edge,edge_color; int *ans; int count =0,j,i = 0; int layer_flag,start_layer,temp_layer; /* .....Define the shapes to import */ CListBox* lstbox = (CListBox*)GetDlgItem(IDC_LAYER_LIST); if (lstbox->GetCurSel()==0) utp_reset_shape_range(); else { nent = utp_shape_label_nstack(); ans = (int *)uu_malloc(sizeof(int)*nent); sel_num = lstbox->GetSelItems(nent, ans) ; if (sel_num==0) utp_reset_shape_range(); else { for (i=0; i<sel_num; i++) utp_set_shape_range(ans[i],sel_num); } uu_free(ans); } /* .....Set unique layer flag for shapes .....Parse the string to get the starting layer number */ layer_flag = ((CButton*)GetDlgItem(IDC_CHECK_LAYERS))->GetState(); if (layer_flag) { ((CWnd*)GetDlgItem(IDC_LAYNUM))->GetWindowText(tmpstr); len = tmpstr.GetLength(); text = tmpstr.GetBuffer(len); start_layer = utp_get_start_layer(); for (i = 0; i < len; i++) { if (text[i] == '.' || isalpha(text[i])) { sprintf(msg,"Integer value required for layer."); MessageBox(msg, "Error!", MB_OK); goto use_mod_layer; } } sscanf(text,"%d", &temp_layer); if (temp_layer >= 0 && temp_layer <= 9999) start_layer = temp_layer; else { sprintf(msg,"Layer number out of range. (0-9999 expected)"); MessageBox(msg, "Error!", MB_OK); } use_mod_layer:; utp_set_start_layer(start_layer); } utp_set_layer_flag(layer_flag); /* .....Label modals */ label_type = ((CComboBox*)GetDlgItem(IDC_LABEL_OPTION))->GetCurSel(); use_sub = ((CButton*)GetDlgItem(IDC_CHECK_USE_SUBSCRIPT))->GetState(); concat_lab = ((CButton*)GetDlgItem(IDC_CHECK_CONCAT_SUBSCRIPT))->GetState(); /* .....Match existing Unibase labels .....Load secondary unibase */ if (label_type==4) { ((CWnd*)GetDlgItem(IDC_UNIBASEL))->GetWindowText(tmpstr); len = tmpstr.GetLength(); if (len!=0) { text = tmpstr.GetBuffer(UX_MAX_PATH_LEN); strcpy(unifile, text); } else unifile[0] = '\0'; status = uig_open_secondary(unifile,&index); if (status == UU_SUCCESS) { ur_saveu_active(2); if (index <= 9) uig_update_surface_prim(); ur_saveu_active(1); UIG_matchlevel = ((CComboBox*)GetDlgItem(IDC_COMBO_MATCHLEVEL))->GetCurSel(); UIG_unmatch_sec = ((CButton*)GetDlgItem(IDC_CHK_UNMATCH_SEC))->GetState(); UIG_start_unmatch = ((CComboBox*)GetDlgItem(IDC_COMBO_STARTUNMATCH))->GetCurSel(); UIG_regressive = ((CButton*)GetDlgItem(IDC_CHK_REG_MATCH))->GetState(); } else label_type =1; } /* .....Set the labeling method */ utp_set_label_method(label_type,use_sub,concat_lab); /* .....Parse the string to get the tolerance and the units(mm/in) */ ((CWnd*)GetDlgItem(IDC_MATCHTOL))->GetWindowText(tmpstr); len = tmpstr.GetLength(); text = tmpstr.GetBuffer(len); count =0; toler[0]='\0'; in_mm[0]='\0'; for (i = 0; i < len; i++) { if (text[i] == '.') { if(count == 0) count = 1; else { sprintf(msg,"Text input not in format required by tolerance."); MessageBox(msg, "Error!", MB_OK); goto use_mod; } } else { if (isalpha(text[i])) { strncpy(toler,text,i); toler[i]='\0'; sscanf((text+i), "%s", in_mm); if(strlen(in_mm) ==2) { if((in_mm[0] == 'm' || in_mm[0] == 'M') && (in_mm[1] == 'm'||in_mm[1] == 'M')) UIG_units_factor =25.4; else if((in_mm[0] == 'i' || in_mm[0] == 'I') && (in_mm[1] == 'n'||in_mm[1] == 'N')) UIG_units_factor =1; else { sprintf(msg, "Text input not in format required by tolerance."); MessageBox(msg, "Error!", MB_OK); goto use_mod; } break; } else { sprintf(msg, "Text input not in format required by tolerance."); MessageBox(msg, "Error!", MB_OK); goto use_mod; } } else if (isdigit(text[i])) { if(i == len-1) strcpy(toler,text); } else { sprintf(msg, "Text input not in the format required by tolerance."); MessageBox(msg, "Error!", MB_OK); goto use_mod; } } } sscanf(toler,"%lf", &UIG_match_tol_disp); UIG_match_tol = UIG_match_tol_disp / UIG_units_factor; if (UIG_match_tol < .0001) UIG_match_tol = .0001; use_mod:; if (UIG_units_factor == 1) UIG_match_tol = UIG_match_tol_disp; if (UIG_units_factor == 25.4) UIG_match_tol = UIG_match_tol_disp / UIG_units_factor; /* .....Added for importing surfaces as shaded or unshaded. JLS 7/29/99 */ shade_set = ((CButton*)GetDlgItem(IDC_SHADE))->GetState(); /* ......translucency */ ((CWnd*)GetDlgItem(IDC_LUCENCY))->GetWindowText(tmpstr); len = tmpstr.GetLength(); text = tmpstr.GetBuffer(len); UIG_lucency = atoi(text); /* .....Set re-initialize label counter flag. */ UIG_reinit_lab = ((CButton*)GetDlgItem(IDC_CHECK_REINIT_LAB))->GetState(); /* .....Set no duplicates flag. */ UIG_nodups = ((CButton*)GetDlgItem(IDC_CHECK_NODUPS))->GetState(); /* .....Set the color scheme. */ UIG_color_iges = ((CButton*)GetDlgItem(IDC_COLOR))->GetState(); /* ...Default; White; Yellow; Blue; Red; Green; Magenta; Cyan; Black; Brown; Tan; Lt Blue; Sea Green; Orange; Pink; Purple; Grey */ srf_edge = ((CButton*)GetDlgItem(IDC_SRF_EDGE))->GetState(); if (srf_edge) { if (m_edge_color == -1) UIG_edge_color = UIG_MAXCOLOR; else { UIG_edge_color = m_edge_color; } } UIG_srf_edge = srf_edge; CDialog::OnOK(); } /*********************************************************************** c c FUNCTION: OnInitDialog() c c This function Set the initialized parameter into dialog c This member function is called in response to c the WM_INITDIALOG message. This message is sent to c the dialog box during the Create, CreateIndirect, c or DoModal calls, which occur immediately before c the dialog box is displayed. c INPUT: None. c c OUTPUT : None c RETURN: None c **********************************************************************/ BOOL CStepOptDlg::OnInitDialog() { int label_type,use_sub,concat_lab,layer_flag,start_layer; CString ctmp; UX_pathname tmp; CDialog::OnInitDialog(); /* .....Get labeling method */ utp_get_label_method(&label_type,&use_sub,&concat_lab); /* .....Get unique layer flag. */ layer_flag = utp_get_layer_flag(); start_layer = utp_get_start_layer(); /* .....Initialize these parameters according to the modfile parameters. */ ((CButton*)GetDlgItem(IDC_CHECK_LAYERS))->SetCheck(layer_flag); ((CComboBox*)GetDlgItem(IDC_COPTION))->SetCurSel(UIG_conv_opt); ((CButton*)GetDlgItem(IDC_CHECK_USE_SUBSCRIPT))->SetCheck(use_sub); ((CButton*)GetDlgItem(IDC_CHECK_CONCAT_SUBSCRIPT))->SetCheck(concat_lab); ((CComboBox*)GetDlgItem(IDC_LABEL_OPTION))->SetCurSel(label_type); if ((label_type==0)||(label_type==4)) GetDlgItem(IDC_MODALSN)->EnableWindow(TRUE); else GetDlgItem(IDC_MODALSN)->EnableWindow(FALSE); ((CComboBox*)GetDlgItem(IDC_COMBO_MATCHLEVEL))->SetCurSel(UIG_matchlevel); ((CComboBox*)GetDlgItem(IDC_COMBO_STARTUNMATCH))->SetCurSel(UIG_start_unmatch); ((CButton*)GetDlgItem(IDC_SHADE))->SetCheck(shade_set); char snum[40]; sprintf(snum,"%d", UIG_lucency); ctmp = snum; ((CWnd*)GetDlgItem(IDC_LUCENCY))->SetWindowText(ctmp); ((CButton*)GetDlgItem(IDC_CHECK_REINIT_LAB))->SetCheck(UIG_reinit_lab); ((CButton*)GetDlgItem(IDC_CHK_UNMATCH_SEC))->SetCheck(UIG_unmatch_sec); ((CButton*)GetDlgItem(IDC_CHK_REG_MATCH))->SetCheck(UIG_regressive); ((CButton*)GetDlgItem(IDC_CHECK_NODUPS))->SetCheck(UIG_nodups); ((CButton*)GetDlgItem(IDC_COLOR))->SetCheck(UIG_color_iges); ((CButton*)GetDlgItem(IDC_SRF_EDGE))->SetCheck(UIG_srf_edge); sprintf(tmp,"%d",start_layer); ctmp = tmp; GetDlgItem(IDC_LAYNUM)->SetWindowText(ctmp); InitColor(); int color; color = UIG_edge_color; if (color == UIG_MAXCOLOR) color = -1; CRect rbtn; GetDlgItem(IDC_EDGE_COLR)->GetWindowRect(&rbtn); GetDlgItem(IDC_EDGE_COLR)->ShowWindow(SW_HIDE); ScreenToClient(&rbtn); m_button.Create("", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_CENTER | WS_TABSTOP | BS_OWNERDRAW | BS_NOTIFY, rbtn, this, IDC_EDGE_COLR_NEW); COLORREF bcolor; if (color<0) { bcolor = ::GetSysColor(COLOR_BTNFACE); } else { bcolor = RGB(uw_color_table[color][0], uw_color_table[color][1], uw_color_table[color][2]); } m_button.set_color(bcolor, bcolor); m_button.ShowWindow(SW_SHOW); if (UIG_srf_edge) { GetDlgItem(IDC_ECLABEL)->EnableWindow(TRUE); GetDlgItem(IDC_EDGE_COLR_NEW)->EnableWindow(TRUE); } else { GetDlgItem(IDC_ECLABEL)->EnableWindow(FALSE); GetDlgItem(IDC_EDGE_COLR_NEW)->EnableWindow(FALSE); } InitRangeList(); OnSelchangeCoption(); OnSelchangeLabelOption(); OnLayers(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } /*********************************************************************** c c FUNCTION: InitRangeList() c c This function gets all shape labels and places them in the list. c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::InitRangeList() { struct global_rec gblk; int status,i,j,k,fstat,inc,units,lfl; char *sptr; UX_pathname filename,fname,dir,tmp; char *cc, msg[300],unit[3]; struct dir_rec dblk; char layer_str[IG_LAYER][5]; char *p; CString ctmp; /* .....Check if user entered filename */ strcpy(filename,m_fname); ul_break_fname(filename, dir, fname); if (strlen(fname)==0) { fstat = UU_FAILURE; iges_fname[0] = '\0'; MessageBox( "No STEP file specified! No entities will appear in Components list.", "WARNING!", MB_OK); } /* .....Load step file */ else { if (dir[0] == '\0') ul_get_full_dir(".",dir); strcat(dir,"\\"); strcat(dir,fname); strcpy(filename,dir); fstat = utp_read_step_file(filename); if (fstat == UU_SUCCESS) { utp_count_entities(); strcpy(iges_fname,filename); } else iges_fname[0] = '\0'; } /* .....Display the tolerance and the units. */ if (fstat == UU_SUCCESS) { unit[0] = '\0'; units = utp_get_units(); if (units == 2) { if(UIG_units_factor==1) UIG_match_tol_disp =UIG_match_tol * 25.4; UIG_units_factor = 25.4; strcpy(unit, "mm"); } else if (units == 1) { if(UIG_units_factor==25.4) UIG_match_tol_disp =UIG_match_tol ; UIG_units_factor = 1; strcpy(unit, "in"); } if (UIG_match_tol < .0001) { if ((p=(char *)ux_getenv("UIG_MATCH_TOL"))) UIG_match_tol = atof(p); else UIG_match_tol = .001; } UIG_match_tol_disp = UIG_match_tol * UIG_units_factor; sprintf(tmp,"%6.4lf%s",UIG_match_tol_disp,unit); ctmp = tmp; GetDlgItem(IDC_MATCHTOL)->SetWindowText(ctmp); ((CComboBox*)GetDlgItem(IDC_COMBO_MATCHLEVEL))->SetCurSel(UIG_matchlevel); /* .....Store shape names */ CListBox* lstbox = (CListBox*)GetDlgItem(IDC_LAYER_LIST); inc = 0; do { sptr = utp_get_shape_label(inc++); if (sptr == UU_NULL) break; lstbox->AddString(sptr); } while (sptr != UU_NULL); inc--; } else { /* .....Display the default tolerance and units from the mod file .....if user does not enter a filename. */ unit[0] = '\0'; if (UIG_units_factor == 25.4 ) strcpy(unit, "mm"); else if (UIG_units_factor == 1) strcpy(unit, "in"); sprintf(tmp,"%6.4lf%s",UIG_match_tol_disp,unit); ctmp = tmp; GetDlgItem(IDC_MATCHTOL)->SetWindowText(ctmp); inc = 0; } lfl = (inc > 0); ((CWnd*)GetDlgItem(IDC_COPTION))->EnableWindow(lfl); ((CWnd*)GetDlgItem(IDC_SELECT_ALL))->EnableWindow(lfl); ((CWnd*)GetDlgItem(IDC_CLEAR_ALL))->EnableWindow(lfl); ((CWnd*)GetDlgItem(IDC_STATIC1))->EnableWindow(lfl); ((CWnd*)GetDlgItem(IDC_LAYER_LIST))->EnableWindow(lfl); } /*********************************************************************** c c FUNCTION: OnClearAll() c c This function called when user push the "Clear All" button c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnClearAll() { CListBox* lstbox = (CListBox*)GetDlgItem(IDC_LAYER_LIST); int cont = lstbox->GetCount(); for (int i = 0; i<cont; i++) { lstbox->SetSel(i, FALSE); } } /*********************************************************************** c c FUNCTION: OnSelchangeCoption() c c This function called when user changed "Conversion Option" choices c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnSelchangeCoption() { CComboBox* cmbbox = (CComboBox*)GetDlgItem(IDC_COPTION); UIG_conv_opt=cmbbox->GetCurSel(); if (cmbbox->GetCurSel()==1) { ((CWnd*)GetDlgItem(IDC_SELECT_ALL))->EnableWindow(TRUE); ((CWnd*)GetDlgItem(IDC_CLEAR_ALL))->EnableWindow(TRUE); ((CWnd*)GetDlgItem(IDC_STATIC1))->EnableWindow(TRUE); ((CWnd*)GetDlgItem(IDC_LAYER_LIST))->EnableWindow(TRUE); } else { ((CWnd*)GetDlgItem(IDC_SELECT_ALL))->EnableWindow(FALSE); ((CWnd*)GetDlgItem(IDC_CLEAR_ALL))->EnableWindow(FALSE); ((CWnd*)GetDlgItem(IDC_STATIC1))->EnableWindow(FALSE); ((CWnd*)GetDlgItem(IDC_LAYER_LIST))->EnableWindow(FALSE); } } /*********************************************************************** c c FUNCTION: OnSelchangeLabelOption() c c This function called when user changed "Entity Label Option" choices c c INPUT: None c c RETURN: None c **********************************************************************/ void CStepOptDlg::OnSelchangeLabelOption() { CComboBox* cmbbox = (CComboBox*)GetDlgItem(IDC_LABEL_OPTION); UIG_lab_opt =cmbbox->GetCurSel(); if ((UIG_lab_opt==0)||(UIG_lab_opt==4)) GetDlgItem(IDC_MODALSN)->EnableWindow(TRUE); else GetDlgItem(IDC_MODALSN)->EnableWindow(FALSE); int nodups,state = FALSE; int choice = cmbbox->GetCurSel() + 1; if (choice==5) state = TRUE; ((CWnd*)GetDlgItem(IDC_UNIBASEP))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_UNIBASEL))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_BROWSE))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_MATCHLEVTEXT))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_COMBO_MATCHLEVEL))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_CHK_UNMATCH_SEC))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_CHK_REG_MATCH))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_ATTRIBUTES))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_COMBO_STARTUNMATCH))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_STARTUNMATCHTEXT))->EnableWindow(state); /* .....Keep the match tolerance field activated if the "No Duplicates" .....check box is checked or the Enitity Label Ooption is set to From Existing .....Unibase. */ nodups = ((CButton*)GetDlgItem(IDC_CHECK_NODUPS))->GetCheck(); if(nodups)state = TRUE; ((CWnd*)GetDlgItem(IDC_MATCHTOL))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_MATCHTXT))->EnableWindow(state); state = FALSE; if (choice==2 || choice==3 /*|| choice==4*/) state = TRUE; ((CWnd*)GetDlgItem(IDC_CHECK_USE_SUBSCRIPT))->EnableWindow(state); if (choice != 2) state = FALSE; ((CWnd*)GetDlgItem(IDC_CHECK_CONCAT_SUBSCRIPT))->EnableWindow(state); } /*********************************************************************** c c FUNCTION: OnBrowse() c c This function called when user pushed "Browse" button c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnBrowse() { DWORD dwFlags; dwFlags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; LPCTSTR filter = "Unibase File (*.u)|*.u|All Files (*.*)|*.*||"; CFileDialog *filedlg = new CFileDialog(TRUE, "step", NULL, dwFlags, filter, this); if (filedlg->DoModal()==IDCANCEL) return; CString FileName = filedlg->GetPathName(); GetDlgItem(IDC_UNIBASEL)->SetWindowText(FileName); delete filedlg; } /*********************************************************************** c c FUNCTION: OnNameModals() c c This function called when user pushed "Name Modals" button c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnNameModals() { /* .....initialed on uio_init() status = iges_config(0); if (status != UU_SUCCESS) return; */ CStepModalDlg* modaldlg = new CStepModalDlg(this); modaldlg->DoModal(); delete modaldlg; } /*********************************************************************** c c FUNCTION: OnAttr() c c This function is called when user pushes the "Attributes" button c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnAttr() { CStepAttrDlg* attrdlg = new CStepAttrDlg(this); attrdlg->DoModal(); delete attrdlg; } /*********************************************************************** c c FUNCTION: OnNoDups() c c This function is called when user checks the "No Duplicates" Check box c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnNoDups() { int nodups,state = FALSE; nodups = ((CButton*)GetDlgItem(IDC_CHECK_NODUPS))->GetCheck(); CComboBox* cmbbox = (CComboBox*)GetDlgItem(IDC_LABEL_OPTION); int choice = cmbbox->GetCurSel() + 1; /* .....Keep the match tolerance field activated if the "No Duplicates" .....check box is checked or the Enitity Label Ooption is set to From Existing .....Unibase. */ if (choice==5 || nodups) state = TRUE; ((CWnd*)GetDlgItem(IDC_MATCHTOL))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_MATCHTXT))->EnableWindow(state); } /*********************************************************************** c c FUNCTION: OnEdgeColor() c c This function called when user pushed "Edge Color" checkbox c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnEdgeColor() { int check = ((CButton*)GetDlgItem(IDC_SRF_EDGE))->GetCheck(); if (check) { GetDlgItem(IDC_ECLABEL)->EnableWindow(TRUE); GetDlgItem(IDC_EDGE_COLR_NEW)->EnableWindow(TRUE); } else { GetDlgItem(IDC_ECLABEL)->EnableWindow(FALSE); GetDlgItem(IDC_EDGE_COLR_NEW)->EnableWindow(FALSE); } } void CStepOptDlg::OnEdgeColorSel() { GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; int color; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); CNCLColorDlg dlg; color = m_edge_color; if (color == UIG_MAXCOLOR) color = -1; dlg.SetColorIndex(color); dlg.SetColorDefault(1, "Default"); dlg.disable_addcolor(); int nResponse = dlg.DoModal(); if (nResponse == IDOK) { /* .....set the field color to select color */ SetButColor(dlg.m_current_color); } else if (nResponse == IDCANCEL) { } GdiplusShutdown(gdiplusToken); } /********************************************************************** ** I_FUNCTION : SetButColor(int color) ** set color button color ** PARAMETERS ** INPUT : color ** OUTPUT : none ** RETURNS : none ** SIDE EFFECTS : none ** WARNINGS : none *********************************************************************/ void CStepOptDlg::SetButColor(int color) { COLORREF bcolor; if (color<0) { bcolor = ::GetSysColor(COLOR_BTNFACE); } else { bcolor = RGB(uw_color_table[color][0], uw_color_table[color][1], uw_color_table[color][2]); } m_button.set_color(bcolor, bcolor); m_button.Invalidate(); m_button.UpdateWindow(); m_edge_color = color; } /*********************************************************************** c c FUNCTION: OnLayers() c c This function is called when user checks the "Place Components on c Different Layers" Check box c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnLayers() { int on_layers,state = FALSE; on_layers = ((CButton*)GetDlgItem(IDC_CHECK_LAYERS))->GetCheck(); if (on_layers) state = TRUE; ((CWnd*)GetDlgItem(IDC_LAYNUM))->EnableWindow(state); ((CWnd*)GetDlgItem(IDC_LAYTXT))->EnableWindow(state); } /*********************************************************************** c c FUNCTION: InitColor() c c This function get the color information c from step file and put into color global value c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::InitColor() { /* .....Initialize default colors */ uig_init_color(); utp_load_color_mode(""); } /*********************************************************************** c c FUNCTION: OnShade() c c This function called when user pushed "Shaded" checkbox c c INPUT: None c c OUTPUT : None c RETURN: None c **********************************************************************/ void CStepOptDlg::OnShade() { int check = ((CButton*)GetDlgItem(IDC_SHADE))->GetCheck(); if (check) { GetDlgItem(IDC_LUCENCY)->EnableWindow(TRUE); GetDlgItem(IDC_LUCENCY_LABEL)->EnableWindow(TRUE); } else { GetDlgItem(IDC_LUCENCY)->EnableWindow(FALSE); GetDlgItem(IDC_LUCENCY_LABEL)->EnableWindow(FALSE); } }
e7cbadc78bff1baebb340aee8e5c8f935f356ae3
56345c289644498f96d79dcdbee0476ea4342daa
/lc034-1.cpp
020737aee799af820327614f08a6b8fe530fb9a6
[]
no_license
boyima/Leetcode
8023dd39d06bcb3ebb4c35c45daa193c78ce2bfe
0802822e1cbf2ab45931d31017dbd8167f3466cc
refs/heads/master
2020-12-13T06:35:00.834628
2019-11-05T22:27:50
2019-11-05T22:27:50
47,539,183
0
1
null
null
null
null
UTF-8
C++
false
false
1,614
cpp
lc034-1.cpp
class Solution { public: vector<int> searchRange(vector<int>& nums, int target) { vector<int> res; int start = 0; int end = nums.size() - 1; if((nums[start] > target) || (nums[end] < target)){ res = {-1, -1}; return res; } bool found = false; if(nums[end] == target){ found = true; } if(nums[0] == target){ found = true; res.push_back(0); } else{ while(start < end){ int mid = (start + end) / 2; if(nums[mid] == target){ found = true; end = mid; } else if(nums[mid] > target){ end = mid; } else{ start = mid + 1; } } if(found == false){ res = {-1, -1}; return res; } res.push_back(end); } start = 0; end = nums.size() - 1; if(nums[end] == target){ res.push_back(end); } else{ while(start < end){ int mid = (start + end) / 2; if(nums[mid] == target){ start = mid + 1; } else if(nums[mid] > target){ end = mid; } else{ start = mid + 1; } } res.push_back(end - 1); } return res; } };
54f22e8d1b830c3ef506c9d8f35305a3ae910db5
06394bc34f4298ddc625ced2ac68530a257810c0
/geeks/problems/LexicographicallyFirstPalindromicString.cpp
649ea570d409ea08ff62b464de25f6e2baf04e46
[]
no_license
dubeyalok7/problems
a052e5e06e009a4df40972eb48f204c2193aea3b
6e2b74cf7188dcaa26c368ce847a0d0a873f15d0
refs/heads/master
2020-03-26T05:11:37.206457
2019-02-16T18:00:27
2019-02-16T20:18:52
144,542,942
0
0
null
null
null
null
UTF-8
C++
false
false
1,460
cpp
LexicographicallyFirstPalindromicString.cpp
/* * LexicographicallyFirstPalindromicString.cpp * * Created on: 28-Jan-2019 * Author: dubeyalo */ #if 0 #include <bits/stdc++.h> using namespace std; const char MAX_CHAR = 26; void countFreq(string str, int freq[], int len) { for(int i=0;i<len; ++i) freq[str.at(i)-'a']++; } bool canMakePalindrome(int freq[], int len) { int count_odd = 0; for(int i=0;i<MAX_CHAR;i++) if(freq[i]%2 != 0) count_odd++; if(len%2 == 0) { if(count_odd > 0) return false; else return true; } if(count_odd !=1) return false; return true; } string findOddAndRemoveItsFreq(int freq[]) { string odd_str = ""; for(int i=0;i<MAX_CHAR;++i) { if(freq[i]%2 != 0) { freq[i]--; odd_str = odd_str+ (char)(i+'a'); return odd_str; } } return odd_str; } string findPalindromicString(string str) { int len = str.length(); int freq[MAX_CHAR]={0}; countFreq(str,freq, len); if(!canMakePalindrome(freq, len)) return "No Palindrome string"; string odd_str = findOddAndRemoveItsFreq(freq); string front_str = "", rear_str = " "; for(int i=0;i<MAX_CHAR; ++i) { string temp = ""; if(freq[i] != 0) { char ch = (char)(i+'a'); for(int j=1; j<=freq[i]/2;j++) temp = temp+ch; front_str = front_str + temp; rear_str = temp + rear_str; } } return (front_str + odd_str+ rear_str); } // Driver program int main() { string str = "appeea"; cout << findPalindromicString(str); return 0; } #endif